Issue a complex message

Messages can be triggered in 2 ways: simple and complex.

This Sample shows how a complex message is triggered in the PLC. The Code used for a complex message is bigger than for a simple message, but you will have more configuration possibilities.
2 Messages will be created - a simple message and a quit-requiring.

They will be shown with the TcEventbar.

  1. Create a new PLC-Project
  2. Add following code to the project:
  3. (*Variable-declaration*)
    VAR
        bSetEvent1 : BOOL;
        bSetEvent2 : BOOL;
        bQuitEvent2 : BOOL;

        event1: ADSLOGEVENT;
        event2: ADSLOGEVENT;

        CfgEvent1 : TcEvent;
        CfgEvent2 : TcEvent;
    END_VAR
     
  4.  
  5. (*PLC Code*)
    (* Event 1 *)
    CfgEvent1.Prio := 0;
    CfgEvent1.bQuitRequired := FALSE;
    CfgEvent1.Flags := TCEVENTFLAG_LOG OR TCEVENTFLAG_SRCID;
    CfgEvent1.StreamType := TCEVENTSTREAM_SIMPLE;
    CfgEvent1.ProgId := 'TcEventFormatter.TcXmlFormatter';
    CfgEvent1.Id := 1; (* Meldung 1*)
    CfgEvent1.SourceId := 17001; (* 17001: Achsregelung *)
    CfgEvent1.Class := TCEVENTCLASS_MESSAGE;

    (* Event 2 *)
    CfgEvent2.Prio := 0;
    CfgEvent2.bQuitRequired := TRUE;
    CfgEvent2.Flags := TCEVENTFLAG_LOG OR TCEVENTFLAG_SRCID;
    CfgEvent2.StreamType := TCEVENTSTREAM_SIMPLE;
    CfgEvent2.ProgId := 'TcEventFormatter.TcXmlFormatter';
    CfgEvent2.Id := 2; (* Meldung 2*)
    CfgEvent2.SourceId := 17001; (* 17001: Achsregelung *)
    CfgEvent2.Class := TCEVENTCLASS_ALARM;

    event1(
    NETID:= '',
    PORT:= 110,
    Event:= bSetEvent1,
    EventConfigData:= CfgEvent1,
    TMOUT:= t#10s);

    event2(
    NETID:= '',
    PORT:= 110,
    Event:= bSetEvent2,
    EventQuit:= bQuitEvent2,
    EventConfigData:= CfgEvent2,
    TMOUT:= t#10s);
  6. Start the PLC Program.
  7. Start the TcEventbar ('TwinCAT/Eventlogger' directory).
  8. By toggling bSetEvent1 the message will be triggered. Rising edge starts the message, otherwise it will be reset.
    Cause no message texts are configured you will have a error in the fields Source and Message.
  9. Toggling bSetEvent2 wont reset the message cause it is a quit-requiring message. It must be deleted before bSetEvent2 can be reset and bQuitEvent2 must be set.
  10. Continue with the message text configuration

 

Requirements

Language / IDE

Source code

TwinCAT PLC (Structured Text)

Sample02.zip