LWORD_To_BinaryTime6

Converts the binary data of the type LWORD into the components of the structured type T_BinaryTime. The coding of the components in LWORD corresponds to the TwinCAT Binary-Time LWORD format specification.

Namespace: Tc3_Collections
Library: Tc3_Collections (Tc3_Collections.compiled-library)

Syntax

FUNCTION LWORD_To_BinaryTime6 : T_BinaryTime
VAR_INPUT
    in     : LWORD(0..16#FFFFFFFFFFFF);
END_VAR
VAR_OUTPUT
    bError : BOOL;
END_VAR

LWORD_To_BinaryTime6 1: Inputs

Name

Type

Description

in

LWORD(0..16#FFFFFFFFFFFF)

The time information to be converted as Binary-Time binary data.

LWORD_To_BinaryTime6 2: Outputs

Name

Type

Description

bError

BOOL

The output is "TRUE" if the value of bits 0..31 (timeOfDay component) is greater than "TOD#23:59:59.999". In this case the function returns the value "STRUCT(timeOfDay := TOD#00:00:00, day := 0)".

LWORD_To_BinaryTime6 3: Return value

Name

Type

Description

LWORD_To_BinaryTime6

T_BinaryTime

Converted time information as Binary-Time structure.

Sample

METHOD BinaryTime6_ToFrom_LWORD : BOOL
VAR_INPUT
    fbIED : REFERENCE TO FB_IED;
END_VAR
VAR
    tValue : T_BinaryTime;
    sValue : STRING;
END_VAR
IF NOT __ISVALIDREF(fbIED) THEN
    RETURN;
END_IF

tValue := LWORD_To_BinaryTime6(0);
sValue := BinaryTime6_To_String(tValue);(* sValue := 'BT#1984-01-01-00:00:00' *) 
IF fbIED.Relay.LLN0.brcb1.TimeOfEntry.nValue <> BinaryTime6_To_LWORD(tValue) THEN
    tValue := fbIED.Relay.LLN0.brcb1.TimeOfEntry.tValue; 
END_IF 

tValue := LWORD_To_BinaryTime6(1);
sValue := BinaryTime6_To_String(tValue);(* sValue := 'BT#1984-01-01-00:00:00.001'*) 
IF fbIED.Relay.LLN0.brcb2.TimeOfEntry.nValue <> BinaryTime6_To_LWORD(tValue) THEN
    tValue := fbIED.Relay.LLN0.brcb2.TimeOfEntry.tValue;
END_IF

tValue := String_To_BinaryTime6('BT#2017-03-21-11:22:33.44');
sValue := BinaryTime6_To_String(tValue);(* sValue := 'BT#2017-03-21-11:22:33.440'*)
IF fbIED.Relay.LLN0.brcb3.TimeOfEntry.nValue <> BinaryTime6_To_LWORD(tValue) THEN
    tValue := fbIED.Relay.LLN0.brcb3.TimeOfEntry.tValue;
END_IF

BinaryTime6_ToFrom_LWORD := TRUE;