IEC61850S_READCONTROLBLOCK
This function can be used to read an element of an IEC61850 Control Block. The function works for URCB, BRCB, GOCB and SGCB. Reasons for a negative return may be unknown element name, wrong datatype or value out of range.
Inputs
Parameter |
Data type |
Description |
name |
STRING |
specifies the name logical device, logical node, control block name and attribute name that is to be retrieved, in IEC61850 syntax. E.g. 'IED_01/LLN0.SGCB.NumOfSG' |
@value |
ANY |
specifies the variable on which the result is stored |
Outputs
Parameter |
Data type |
Description |
Q |
BOOL |
TRUE if the function execution was successful. |
Sample
// Check the communication writing the SGCB's reservation time (s)
IF WriteReservationTime THEN
IEC61850S_WRITECONTROLBLOCK( 'IED_03CTRL/LLN0.SGCB.ResvTms', ResTimeInSec );
WriteReservationTime := FALSE;
END_IF;
// Read the SGCB attributes. Last parameter is an INOUT.
IEC61850S_READCONTROLBLOCK('IED_03CTRL/LLN0.SGCB.NumOfSG', numOfSG);
IEC61850S_READCONTROLBLOCK('IED_03CTRL/LLN0.SGCB.ActSG', actSG);
IEC61850S_READCONTROLBLOCK('IED_03CTRL/LLN0.SGCB.EditSG', editSG);
IEC61850S_READCONTROLBLOCK('IED_03CTRL/LLN0.SGCB.ResvTms', resvTms);
// Part of the program managing the Active Setting Group
// Initial state: ActSG (local value) = 0
IF {IED_03CTRL/LLN0.SGCB.ActSG} > 0 THEN
IF {IED_03CTRL/LLN0.SGCB.ActSG} > numOfSG THEN
// Error, bad Active SG, greater than what is in the SCL
{IED_03CTRL/LLN0.SGCB.ActSG} := -IEC61850S_ServiceError_parameter_value_inconsistent;
ELSE
// Update the [SG] with the shadow values (Setting Group)
sgcb_update_act({IED_03CTRL/LLN0.SGCB.ActSG} - 1); // -1 because arrays index starts at 0
{IED_03CTRL/LLN0.SGCB.ActSG} := IEC61850S_ServiceError_no_error;
Inst_now(TRUE); // Recovers current timestamp in UNIX format
IEC61850S_WRITECONTROLBLOCK('IED_03CTRL/LLN0.SGCB.LActTm', Inst_now.Q);
END_IF;
END_IF;
// Part of the program managing Editing the Setting Group
// Initial state: EditSG (local value) = 0
IF {IED_03CTRL/LLN0.SGCB.EditSG} > 0 THEN
edit_client := {IED_03CTRL/LLN0.SGCB.ClientIdentifier}; // Recovers the Client ID (IP@ + port)
IF editSG <> 0 or {IED_03CTRL/LLN0.SGCB.EditSG} > numOfSG THEN
{IED_03CTRL/LLN0.SGCB.EditSG} := -IEC61850S_ServiceError_parameter_value_inconsistent;
ELSE
// Update the [SE] with the shadow values (Setting Group)
sgcb_update_edit({IED_03CTRL/LLN0.SGCB.EditSG} - 1);
{IED_03CTRL/LLN0.SGCB.EditSG} := IEC61850S_ServiceError_no_error;
startCounting := TRUE; // SGCB reserved until confirmation (cnfEdit = 1)
END_IF;
END_IF;
// Confirms the Edit
// /!\ Must be above part managing the CnfEdit due to execution order!
IF clear_confirm THEN
IEC61850S_WRITECONTROLBLOCK('IED_03CTRL/LLN0.SGCB.CnfEdit', FALSE);
clear_confirm := FALSE;
END_IF;
// Part of the program managing the Confirm Edit of the Setting Group
IF {IED_03CTRL/LLN0.SGCB.CnfEdit} = 1 THEN
IF {IED_03CTRL/LLN0.SGCB.ClientIdentifier} <> edit_client THEN
// Client asking to Confirm is not the one which asked to Edit
{IED_03CTRL/LLN0.SGCB.CnfEdit} := -IEC61850S_ServiceError_instance_locked_by_other_client;
ELSIF editSG < 1 or editSG > numOfSG THEN
{IED_03CTRL/LLN0.SGCB.CnfEdit} := -IEC61850S_ServiceError_parameter_value_inappropriate;
ELSE
// Updates the shadow values (Setting Group) with the [SE]
sgcb_update_shadow(editSG - 1);
{IED_03CTRL/LLN0.SGCB.CnfEdit} := IEC61850S_ServiceError_no_error;
IF editSG = actSG THEN
// Setting Group being edited was the active one
sgcb_update_act(actSG - 1);
END_IF;
IEC61850S_WRITECONTROLBLOCK('IED_03CTRL/LLN0.SGCB.EditSG', 0);
clear_confirm := TRUE;
startCounting := FALSE;
END_IF;
edit_client := '';
END_IF;
// Handles the SGCB reservation time (resvTms)
Inst_TON( startCounting, ANY_TO_TIME(resvTms * 1000) );
IF Inst_TON.Q AND resvTms > 0 THEN
// TO DO
PRINTF('Reservation time elapsed');
startCounting := FALSE;
END_IF;
IEC61850S_READCONTROLBLOCK |
IEC 61131-3 Automation platform > Programming - Reference guide > Driver specific function blocks > IEC61850 Server > IEC61850S_READCONTROLBLOCK |
Created with the Personal Edition of HelpNDoc: Full-featured EPub generator