Cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted

Stopping a simulation through OPC value

Solution Partner Pioneer Solution Partner Pioneer
Solution Partner Pioneer

Hello,

 

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)
is
s : string;
do
if root.EventController.isRunning = true then

s := OPCInterface.getItemValue("Group1|Stop");

if s = "stop" then
root.EventController.Stop;
end;
end;
end; 

 

This method is called by an observer on the EventController for the value IsRunning.

 

 

Thank you for taking a look at my problem!

2 REPLIES 2

Re: Stopping a simulation through OPC value

Siemens Phenom Siemens Phenom
Siemens Phenom

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.

Regards, Vladimir.

Re: Stopping a simulation through OPC value

Solution Partner Pioneer Solution Partner Pioneer
Solution Partner Pioneer
This worked perfectly. Thank you!