Vai al contenuto
Vai all indice del manuale di programmazione

Dalla versione 5.20.x.xx LogicLab supporta operatori gestione del tempo che possono essere utilizzati sia per estrarre informazioni che per eseguire operazioni.

TIME

Identificatore a 32 bit con segno, permette di specificare intervalli di tempo espressi in mS nel range da -24d_20h_31m_23s_648ms a 24d_20h_31m_23s_647ms.

TIME# o T#: Valore espresso come dd hh mm ss ms.

Dove: dd: giorni, hh: ore, mm: minuti, ss: secondi, ms: millisecondi.

LTIME

Identificatore a 64 bit con segno, permette di specificare intervalli di tempo espressi in nS nel range da -106751d_23h_47m_16s_854ms_775us_808ns a 106751d_23h_47m_16s_854ms_775us_807ns.

LTIME# o LT#: Valore espresso come dd hh mm ss ms us ns.

Dove: dd: giorni, hh: ore, mm: minuti, ss: secondi, ms: millisecondi, us: microsecondi, ns: nanosecondi.

Esempi

Come utilizzare gli esempi.
Nell’esempio vengono eseguite operazioni con gli operatori.

LogicLab (Ptp116, ST_TimeOperators)
PROGRAM ST_TimeOperators
VAR
    BTime : ARRAY[0..5] OF TIME; (* Time buffer *)
    LBTime : ARRAY[0..5] OF LTIME; (* Time buffer *)
END_VAR


// *****************************************************************************
// PROGRAM "ST_TimeOperators"
// *****************************************************************************
// Use of time operators.
// -----------------------------------------------------------------------------

    // -------------------------------------------------------------------------
    // 32 BITS TIME OPERATORS
    // -------------------------------------------------------------------------
    // Range from -24d_20h_31m_23s_648ms to 24d_20h_31m_23s_647ms
    // Some operations on TIME variables.

    BTime[0]:=TO_TIME(SysTimeGetMs()); //Get system time
    BTime[1]:=T#1s_500ms; //Define time
    BTime[2]:=BTime[0]+TIME#1m_0s_500ms; //Add a defined time
    BTime[3]:=TIME#10m15s10ms; //Define time
    BTime[4]:=t#14.5s; //Define time
    BTime[5]:=T#1d1s1ms; //Define time

    // -------------------------------------------------------------------------
    // 64 BITS TIME OPERATORS
    // -------------------------------------------------------------------------
    // Range from -106751d_23h_47m_16s_854ms_775us_808ns to 106751d_23h_47m_16s_854ms_775us_807ns
    // Some operations on LTIME variables.

    LBTime[0]:=TO_LTIME(SysDateGetNs()); //Get system long time
    LBTime[1]:=LT#1s_500ms; //Define time
    LBTime[2]:=LBTime[0]+LTIME#1m_0s_500ms; //Add a defined time
    LBTime[3]:=LTIME#10m15s10ms; //Define time
    LBTime[4]:=lt#14.5s; //Define time
    LBTime[5]:=LT#1d1s1ms; //Define time

// [End of file]
Was this article helpful?