cancel
Showing results for 
Search instead for 
Did you mean: 

txplcsignals

Valued Contributor
Valued Contributor

Hi

 

I cannot seem to find any information on how to monitor or force a plc signal through the api. Is this possible?

 

Regards

3 REPLIES

Re: txplcsignals

Siemens Legend Siemens Legend
Siemens Legend

Hi,

 

Yes this is possible.

 

If you want to force a signal you need to indicate the signal first and then you can use:

signal.Value.BooleanValue = true;

 

To read a signal value, you can use the following:

bool value = signal.Value.BooleanValue;

 

All your signal you can get from the current PlcProgram and using a filter:

TxPlcProgram plcProgram = TxApplication.ActiveDocument.PlcProgramRoot.CurrentPlcProgram;

TxTypeFilter filter = new TxTypeFilter(typeof(ITxPlcSignal));

TxObjectList signals = plcProgram.GetSignals(filter);

 

 

 

 

 

Re: txplcsignals

Siemens Legend Siemens Legend
Siemens Legend

Hi,

 

There is no API to force a signal the way it is done in simulation Panel.

signal.Value.BooleanValue = true; will force the signal to a value, but PS simulation can change it again in the same time interval or in the next.

 

Regards

 

Re: txplcsignals

It might be possible!!

 

If you utilize a Viewer application rather than a command window you may be able force a signal to stay on. Viewers act differently than command windows and can show/manipulate active data from a simulation that is running. Create a View Model class that holds the signal as a property.  Set the signal from the simulation to the property in the View Model and set as on.  The Viewer window can hold a control to display it by binding the control to the view model utilizing MVVM pattern.  The signal should stay on as long as the viewer is active and the property of the signal object in the view model is set to on. As long as the signal object is held in the ON position by the view model class property you set the signal object too... in theory it should stay on.