cancel
Showing results for 
Search instead for 
Did you mean: 

PLC Signal Change Event

Creator
Creator

I am curently getting all the plc output signals from an active study using this :-

 

TxDocument active = TxApplication.ActiveDocument;
TxPlcProgramRoot progRoot = active.PlcProgramRootOrNull;
if (progRoot != null)
{
  TxPlcProgram prog = progRoot.CurrentPlcProgramOrNull;
  if (prog != null)
  {
    TxTypeFilter filter = new TxTypeFilter(typeof(TxPlcOutputSignal));
    TxObjectList sigs = prog.GetSignals(filter);
    foreach (TxPlcOutputSignal sig in sigs)
    {
      ***  sig.change += signalchangedevent ***
    }
  }
}

 

What I want to to do is monitor the signals for a value change event but this does not seem to exist. Am I missing something or is this not implemented or do I have to go about it another way?

3 REPLIES

Re: PLC Signal Change Event

Siemens Legend Siemens Legend
Siemens Legend

Hi,

 

You can try to use the following:

 

TxApplication.ActiveDocument.SimulationPlayer.TimeIntervalReached += this.SimulationPlayer_TimeIntervalReached;

 

After each time interval (can be changed in Simulation Panel or Path Editor) you can check the status of your signals.

 

Best regards

Re: PLC Signal Change Event

Creator
Creator

Hi,

 

Thanks for your answer.

 

I had already considered that approach but then it means the simulation would be working on time slices and not event based which is what I thought PLC simulation was supposed to be.

 

This would add an extra time response overhead  (100ms using the base interval) onto the the connection update rate (100 ms each way (if they poll the OPC writes)). This could mean 400ms response allowing for time synchonisation overlaps.

 

I can reduce the time interval but am worried it might start getting unresponsive.

 

Re: PLC Signal Change Event

Siemens Genius Siemens Genius
Siemens Genius

Psiwolf wrote:

 

 

I had already considered that approach but then it means the simulation would be working on time slices and not event based which is what I thought PLC simulation was supposed to be.

 

This would add an extra time response overhead  (100ms using the base interval) onto the the connection update rate (100 ms each way (if they poll the OPC writes)). This could mean 400ms response allowing for time synchonisation overlaps.

 

 


You can use TxSimulationPlayer.SignificantTimeReached event instead (not certain about the exact event name, but it is something similar).

This way you don't need to modify your time interval.

Details: this event is triggered (among other occasions) on EVERY time slice where the PS logic is being evaluated and I/Os are exchanged.

 

Best of luck,

Zachi