I'm trying to get data from a server. Right now, I am polling the server every couple of seconds for the current values. I am wondering if it is possible to have Matlab get the data in real-time or if I am stuck with my current implementation. Has anyone done anything like this? If so, maybe you can tell me how you got started with it.
Any help would be greatly appreciated. Thanks!
If you're on Windows, you can listen to ActiveX (COM) events using REGISTEREVENT. You would need to provide an ActiveX control (servers might work too, I'm not sure) that triggers the event, which would invoke your MATLAB function.
Matlab timers work well for periodic events. You'll want to be careful about making sure your function executes in less time than the periodicity of the timer, though settings for the behavior when that doesn't hold do exist.
Related
I'm trying to find out how to use Eclipse Milo, and finding out how subscriptions go. I can easily get any MonitoringMode.Reporting mode subscription to work, but when I use Sampling it doesn't call the callback method (as expected). According to the docs it's supposed to "queue" up the values without calling the callback, but I can't find any place I can access that queue or anything similar. The UaMonitoredItem doesn't have anything in its interface that looks like it, neither does the request.
It's probably something obvious, but what am I doing wrong?
Thank you in advance!
Answered in the GitHub repo discussions, but for posterity:
MonitoringMode.Sampling simply means the server continues to sample the underlying but does not report the values to the client.
The queued values are not available to you. If you change back to MonitoringMode.Reporting then they would be the first values reported for that item.
I recently came across the Trading Toolbox in matlab and I was very excited to find out you can do automated trading with it. I read the documentation, which was pretty clear, a couple of functions to connect to a certain broker, some order functions and a disconnect function. What I couldn't find out though is how you can make sure that your code is run constantly, otherwise automated trading isn't possible since trades can only be made or closed once every time you run your code. That shouldn't be the case, the code should be repeated every second or minute for that matter. Does anyone know how this can be achieved?
I have a multiplayer project which has some forever loops with checking code inside of them.
The problem is, multiple computers might process this and change crabx or craby due to lag in the variables dvotes, uvotes, lvotes, or rvotes. Only one machine should change this, though.
This can be easily solved by giving each player an ID like many people do in SQL. I would just check if the ID is 1, and that would be the "operating machine". I would then do all of these checks on that one machine. It would do things a Scratch server would do if you could program it...
The problem with this is that there is no way to detect when a player leaves the game. There is no block that is called "on exit" or "on stop button pressed". How would I go about doing this? I have seen people have a button which people click to exit, but some people will not click it/not even see it.
Thanks in advance!
Option 1
I've never been especially successful with cloud data myself, but I've heard the theory on this before:
Essentially, each player gets a "counter". Their computer then constantly increases that counter. If the counter ever stops increasing (which will be detected by the other computers, who are all looking after one another), the project will know that the user has left and one of the computers will take care of removing their ID and other data.
Obviously, this is much easier said than done. (As I said, I've never gotten complex cloud data to work well for myself, but I've seen it done successfully and explained.)
Option 2
Alternatively, you might be better off taking advantage of this cloud api created by MegaApuTurkUltra. I find that stealing from others tends to be the best way of solving problems when it comes to code. ;)
I've spent 20 hours or so in the last two days trying to find a way to do this. I spent most of that time using hammer.js (javacript version) and can see how the library handles touch events (pinch, specifically) but every example I've tried kills the default.
Events are NOT my strong point. Most of my knowledge (limited as it is) was learned in VB.net, which was quite a few years ago. What I recall is that the handlers would have to return a value. One could either return null (effectively killing the system default action) or return the event arguments so as to not disrupt the native action. I can't find anything like that with mobile web apps.
Specifically, I'm looking for something like document.onScaleChange. I'm grateful for any help.
I'm embarrassed. I was making this out to be WAY more complicated than it is. There may be a better way, if so, please chime in.
The first method I found to work wasn't very elegant, but it served the purpose and led to what seems to be a better way. Part of the problem is I haven't been able to find very comprehensive references to the DOM. After running across this link, Mozilla Developer (in case others are having the same trouble as I). `var intervalID = window.setInterval(myCallback, 500);
var intervalID = window.setInterval(myCallback, 500);
function myCallback(){
// Your code here
}
The better way was just to listen for the 'touchend' event.
window.addEventListener("touchend", function() {
/* code here */
});
It couldn't have been more simple. If there are any problems using the last method, please let me know. I had seen similar methods before but when I tried them, they wouldn't work. Maybe I just messed up the syntax or something.
my laptop goes to hibernate when I'm running a matlab code because of overheating. when I turn it on again, matlab countinue to running my code. I'm worry about the results of my code! what do you think? is there any problem with hibernating and resuming the matlab code?
thank you.
I recommend looking at this: http://www.mathworks.com/matlabcentral/answers/46569-what-happens-to-a-running-program-when-my-computer-switches-to-hibernate
Theoretically, when the computer hibernates, the status of the memory and disk are saved. However, as it is pointed out in the link I provided, this is not very reliable and can lead to corruption of files and/or data.
Instead, I recommend that your program saves necessary variables from time to time using checkpoints, so that your program can run reliably even when your code is paused or your computer hibernates. Take a look at this link to see how to implement checkpoints: http://www.walkingrandomly.com/?p=5343.