bengeisler / TcLog

Flexible logging functionality for TwinCAT 3.
MIT License
54 stars 10 forks source link

Question: how to log multiple Boolean transitions within one FB. #19

Closed paulbarron85 closed 9 months ago

paulbarron85 commented 9 months ago

How should one log multiple Boolean signals in the same FB? Is it ok to use the same instance or do you require a new FB for each thing you want to log. Specifically, I'm looking at the TcLogTrig. For example, can I do the following:

FUNCTION_BLOCK FB_DigitalInputLogger
VAR_INPUT
        input1 : BOOL;
        input2 : BOOL;
    fbCoreLog : REFERENCE TO TcLogCore;
END_VAR
VAR
    fbTcLogTrig : TcLogTrig;
END_VAR

fbTcLogTrig.SetLogger(fbCoreLog);
fbTcLogTrig
    .OnRisingEdge(input1)
    .Information('Input 1 is TRUE');
fbTcLogTrig
    .OnFallingEdge(input1)
    .Information('Input 2 is FALSE');

fbTcLogTrig
    .OnRisingEdge(input2)
    .Information('Input 2 is TRUE');
fbTcLogTrig
    .OnFallingEdge(input2)
    .Information('Input 2 FALSE');
bengeisler commented 9 months ago

You have two options:

You can, however, use the same instance to log one rising and one falling edge.