String_To_BinaryTime6
Converts the Binary-Time time information formatted as a string into the components of the structured type T_BinaryTime. The string to be converted must be specified and has the following structure: ‘BT#[YYYY-MM-DD-]hh:mm:ss[.n[n[n]]]‘. It corresponds to the TwinCAT Binary-Time string format specification.
Namespace: Tc3_Collections
Library: Tc3_Collections (Tc3_Collections.compiled-library)
Syntax
FUNCTION String_To_BinaryTime6 : T_BinaryTime
VAR_INPUT
in : STRING(26);
END_VAR
VAR_OUTPUT
bError : BOOL;
END_VAR
Inputs
Name | Type | Description |
---|---|---|
in | STRING(26) | The time information to be converted as a Binary-Time string. |
Outputs
Name | Type | Description |
---|---|---|
bError | BOOL | This output is "TRUE" if the input string could not be converted without error. In this case the function returns the value "STRUCT(timeOfDay := TOD#00:00:00, day := 0)". |
Return value
Name | Type | Description |
---|---|---|
String_To_BinaryTime6 | Converted time information as Binary-Time structure. |
Sample
METHOD BinaryTime6_ToFrom_String : 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 := String_To_BinaryTime6('BT#01:02:03');
sValue := BinaryTime6_To_String(tValue); (* sValue := 'BT#1984-01-01-01:02:03' *)
IF fbIED.Relay.LLN0.brcb1.TimeOfEntry.sValue <> sValue THEN
tValue := fbIED.Relay.LLN0.brcb1.TimeOfEntry.tValue;
END_IF
tValue := String_To_BinaryTime6('BT#04:05:06.7');
sValue := BinaryTime6_To_String(tValue);(* sValue := 'BT#1984-01-01-04:05:06.700' *)
IF fbIED.Relay.LLN0.brcb2.TimeOfEntry.sValue <> sValue THEN
tValue := fbIED.Relay.LLN0.brcb2.TimeOfEntry.tValue;
END_IF
tValue := String_To_BinaryTime6('BT#2017-01-18-11:12:13');
sValue := BinaryTime6_To_String(tValue);(* sValue := 'BT#2017-01-18-11:12:13' *)
IF fbIED.Relay.LLN0.brcb3.TimeOfEntry.sValue <> sValue THEN
tValue := fbIED.Relay.LLN0.brcb3.TimeOfEntry.tValue;
END_IF
BinaryTime6_ToFrom_String := TRUE;