Example - Manual - SIMATIC AX - System and Runtime clock functionality. - Siemens.Simatic.S71500.Clocks,library

Siemens.Simatic.S71500.Clocks library

Portfolio
SIMATIC AX
Product
SIMATIC AX
Software version
6.0.37
Edition
11/2023
Language
English (original)
Package Name
@ax/simatic-1500-clocks
USING Siemens.Simatic.S71500.Clocks;

PROGRAM SampleProgram
    VAR
        measurement : RuntimeMeasurement;
        timeOfOperations : LTIME;
        inSeconds : LREAL;
        inNanos : LINT;
    END_VAR
    VAR_TEMP
        index : INT;
        r1, r2 : REAL;
    END_VAR

    measurement.Start();

    FOR index := 0 TO 100 DO
        r1 := REAL#1.001 + r1 * r2;
        r2 := r1;
    END_FOR;

    // timeOfOperation now contains the value of time between start and stop
    timeOfOperations := measurement.Stop();

    // inSeconds a floating point value representing the seconds elapsed
    inSeconds := measurement.GetElapsedSeconds();
    // e.g. LREAL#0.012 representing 0.012 seconds (12 ms)

    // measurement is not running, Stop() returns the same value as before
    timeOfOperations := measurement.Stop();
END_PROGRAM