Communication between Java and Matlab Simulink Stateflow?
Ältere Kommentare anzeigen
Hey everyone:
I have a question of communication between Java and Matlab Simulink Stateflow.
My goal is:
Have a java application and a Matlab Simulnik Stateflow run parallel on the same machine.
Have communicating between Java and Matlab Simulink Stateflow. Prefer TCP/IP.
Basically, the idea is using the Stateflow as a statemachine. The input of Sateflow comes from the Java and Java can get the updated state of the Stateflow model via Scope in Simulink.
I know that I can generate C/C++ from Stateflow. But I would rather go for interacting between Java and Stateflow.
Any one have idea how to achieve this goal? Am I on the right track to do this or is it possible to achieve the goal? Thank you very much.
Some information after I google the web for your reference
"Those experts from The MathWorks support team also issued a warning that it will be very tricky to pass back the result of a MATLAB function to Java." according to "An Asynchronous Java Interface to MATLAB"
http://www.softwareresearch.net/fileadmin/src/docs/publications/C102.pdf
TCP/IP Socket Communications in MATLAB
http://iheartmatlab.blogspot.com/2008/08/tcpip-socket-communications-in-matlab.html
Waiting for asynchronous events
http://undocumentedmatlab.com/blog/waiting-for-asynchronous-events
Antworten (1)
Sebastian Castro
am 2 Feb. 2015
Bearbeitet: Sebastian Castro
am 2 Feb. 2015
0 Stimmen
Hi Yi-Zong,
First thing I would ask you to do is check whether you have Instrument Control Toolbox, as this provides built-in functionality to do TCP/IP communication from Simulink. The blocks of interest are TCP/IP Receive and TCP/IP Send. If you end up going for UDP communication, there are blocks for that too.
Otherwise, there is a generic way of calling Java from MATLAB code, as shown in this page. Given that Stateflow charts use MATLAB, you can include this code in your charts.
NOTE: This will work if your chart won't be used for code generation, since Java calls aren't supported in C/C++ generated code. You will have to declare any unsupported functions as extrinsic, which is shown in steps 6-8 of this page.
- Sebastian
Kategorien
Mehr zu Stateflow finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!