Now the Train model in DynSolve is almost ready, except for the part of how to present the results. Mr Raid Karoumi is working on it. But I don't think it's possible to show DynSolve to Swedish Road Administration, since there's only one day but I haven't gotten the Matlab code for plotting results from Raid.
Communicating with a running Matlab program in Java makes me headache! A new break in this software design is that one could terminate a running Matlab program during calculation in Java. It's archived by making a dialog window in Matlab. This method seems simple but it is the only way that I could come up with by far(since the design of PASS).
For most of those who knows Matlab a bit, when it comes to terminating a running Matlab program, they may come up with "Ctrl+c". Unfortunately, this is totally meaningless in a Java program who calls the Matlab JAR generated by MATLAB Builder™ JA, because Java can never touch the keyboard for the uses. The bottleneck is that, Maltab code is unreachable for the users in such Java program. But there is way: a GUI window created in Matlab. It is like a bridge that connects the users directly to MCR, instead of giving the message to the Java boat man under the bridge who sends the message to MCR.
To control the Matlab program, you need to declare some global variables in Matlab code which are reachable by both the main Matlab code and the Matlab GUI(e.g, dialog window). When you want to terminate the Matlab program, change the variables via Matlab GUI, when the main Matlab program see the variables' change, it will 'return'. Do not use error command instead of 'return', cause 'error' doesn't work sometimes when it's working in Java.
One important thing: try to use 'pause' in the loop in Matlab code to check if the variables are changed. Because the Matlab GUI thread needs time to execute.
No comments:
Post a Comment