TON time FB

This test case it part of the test suite proposed for new devices.

Test case ID: R1023
Language: ST

Code:
tests2/t1023.st
(* TON test - this should be called several 18 times with deltaTime=100msecs  (~ 1.8 segs)  *)

(*

   cycle = 100msecs    TON: cuts 250msec

          +---------+        +---+   +-------+
IN        |         |        |   |   |       |
        --+         +--------+   +---+       +-------------
         1          6        8   10  11      15    
                +---+                     +--+
Q               |   |                     |  |
       ---------+   +---------------------+  +-------------
               3.5  6                   13.5 15
      PT        +---+                     +--+
       :       /    |            +       /   |
ET     :      /     |           /|      /    |
       :     /      |          / |     /     |
       :    /       |         /  |    /      |
       0---+        +--------+   +---+       +-------------


*)

PROGRAM T1023
   VAR 
    cycle : INT := -1; // cicles are counted started from 0, so time ~ 100msec x cycle
    ton1: TON;   // delays start by 350
    dt1 : DATE_AND_TIME; // timestamp
  END_VAR

  VAR_TEMP
   input : BOOL ; 
   msecs : DINT :=0;
  END_VAR 

  cycle := cycle + 1;

  IF cycle = 0 THEN // at cycle 1 we produce a rising edge at TP1 input
        dt1:= _GEB_NOW_TIMESTAMP(1); // record start of exec
  END_IF;
  msecs := TIME_TO_DINT(_GEB_ELAPSED_TIME(dt1));

  input := (cycle >=1 AND  cycle <6) OR (cycle >=8 AND cycle <10) OR (cycle >=11 AND cycle <15);

  ton1( IN := input , PT := T#250ms);

  IF ton1.Q THEN
         _GEB_ASSERT_(cycle = 4 OR cycle =5 OR cycle = 14);
  ELSE  
         _GEB_ASSERT_(NOT(cycle = 4 OR cycle =5 OR cycle = 14));
  END_IF;

  //_GEB_MSG_(INT_TO_STRING(cycle));      
  //_GEB_MSG_(DINT_TO_STRING(TIME_TO_DINT(ton1.ET)));      

  IF (NOT (ton1.Q )) AND  (cycle = 4 OR cycle =5 OR cycle = 14) THEN
         _GEB_MSG_(INT_TO_STRING(cycle));      
         _GEB_MSG_(INT_TO_STRING(msecs));      
         _GEB_MSG_(TIME_TO_STRING(ton1.ET));  
  END_IF;

  IF NOT input THEN
    _GEB_ASSERT_(NOT ton1.Q);
  END_IF;

END_PROGRAM