I am utilizing an OPC interface in a simple model to test sending and receiving of OPC data. Currently, I have succeeded in sending data to Kepware KepServerEx (Simple data such as Machine name, MU entity number, and mu entry time).
For receiving opc data, I am somewhat succeeding. I made a method to handle this communication. This method is supposed to stop the running simulation if I change a tag in Kepware to the string "stop". Currently with my code, I change the tag to "stop" but the simulation continues to run. But, if I reset the simulation, the play button does not work. When I change the tag back to " ", then the play button works again.
The question I am trying to answer is how can I stop the simulation with an OPC tag as soon as the OPCInterface reads the change?
My code is below:
(attribute: string; oldValue: any)
s : string;
if root.EventController.isRunning = true then
s := OPCInterface.getItemValue("Group1|Stop");
if s = "stop" then
This method is called by an observer on the EventController for the value IsRunning.
Thank you for taking a look at my problem!
Solved! Go to Solution.
I think the problem is that you use observer for IsRunning control. This method is called only once when simulation is started (if it never stops). So If you change tag to "stop", method is not called!
Instead I'd use Changed-Value control, which you can define in the list of items. This way your control would be called when tag value changes and simulation would stop.