Cancel
Showing results for 
Search instead for 
Did you mean: 

Getting Signal change time

Solution Partner Valued Contributor Solution Partner Valued Contributor
Solution Partner Valued Contributor

Hello,

 

I am trying to find specific simulation time for when a signal changes his value.

The purpose of this is get those times in a report for establishing devices cycle times(similar to Robotic cycle time report command )

The problem i encounter is that the time that gets written in the .txt is the end simulation time. I would like to write the time when signal value changes.

Here is my code :

public override void Execute(object cmdParams)
{
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);
TxApplication.ActiveDocument.SimulationPlayer.Play();
foreach (TxPlcOutputSignal sig in sigs)

{


var Val = sig.Value.BooleanValue;
string value = Convert.ToString(Val);


if (Val == true)
{

var time = new TxSimulationPlayer();
string time_value = Convert.ToString(time.CurrentTime);
string[] lines = { time_value };
System.IO.File.WriteAllLines(@"E:\folder\WriteTime.txt", lines);

}

 

Any ideea how i can get the specific time of the changing value of signal?

 

Thank you .

1 REPLY

Re: Getting Signal change time

Siemens Phenom Siemens Phenom
Siemens Phenom

Hi Lonut,

 

You can check this post.

 

Best Regards,

DianaG