From 618a84d37c414eb04ffe41316387f4459304ad88 Mon Sep 17 00:00:00 2001 From: Michael Zillgith Date: Wed, 5 Dec 2018 05:53:15 +0100 Subject: [PATCH] - IEC 61850 client: add public header for function ControlObjectClient_createEx to create a client control object without the need to request information from the server --- src/iec61850/client/client_control.c | 16 ++++++++-------- src/iec61850/inc/iec61850_client.h | 21 ++++++++++++++++++--- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/src/iec61850/client/client_control.c b/src/iec61850/client/client_control.c index 1677223a..42ed71dd 100644 --- a/src/iec61850/client/client_control.c +++ b/src/iec61850/client/client_control.c @@ -110,7 +110,7 @@ resetLastApplError(ControlObjectClient self) } ControlObjectClient -ControlObjectClient_createEx(const char* objectReference, IedConnection connection, uint32_t ctlModel, MmsVariableSpecification* operSpec) +ControlObjectClient_createEx(const char* objectReference, IedConnection connection, ControlModel ctlModel, MmsVariableSpecification* controlObjectSpec) { ControlObjectClient self = NULL; @@ -122,8 +122,8 @@ ControlObjectClient_createEx(const char* objectReference, IedConnection connecti MmsVariableSpecification* ctlVal = NULL; MmsVariableSpecification* t = NULL; - if (MmsVariableSpecification_getType(operSpec) == MMS_STRUCTURE) { - MmsVariableSpecification* oper = MmsVariableSpecification_getNamedVariableRecursive(operSpec, "Oper"); + if (MmsVariableSpecification_getType(controlObjectSpec) == MMS_STRUCTURE) { + MmsVariableSpecification* oper = MmsVariableSpecification_getNamedVariableRecursive(controlObjectSpec, "Oper"); if (oper) { @@ -151,6 +151,8 @@ ControlObjectClient_createEx(const char* objectReference, IedConnection connecti t = MmsVariableSpecification_getNamedVariableRecursive(oper, "T"); } + + /* TODO Add additional checks dependent on control model */ } if (hasOper == false) { @@ -173,7 +175,7 @@ ControlObjectClient_createEx(const char* objectReference, IedConnection connecti self->objectReference = StringUtils_copyString(objectReference); self->connection = connection; - self->ctlModel = (ControlModel) ctlModel; + self->ctlModel = ctlModel; self->hasTimeActivatedMode = hasTimeActivatedControl; self->hasCtlNum = hasCtlNum; self->ctlVal = MmsValue_newDefaultValue(ctlVal); @@ -199,7 +201,6 @@ ControlObjectClient_createEx(const char* objectReference, IedConnection connecti iedConnection_addControlClient(connection, self); exit_function: - MmsVariableSpecification_destroy(operSpec); return self; } @@ -239,10 +240,9 @@ ControlObjectClient_create(const char* objectReference, IedConnection connection goto exit_function; } - self = ControlObjectClient_createEx(objectReference, connection, ctlModel, ctlVarSpec); + self = ControlObjectClient_createEx(objectReference, connection, (ControlModel) ctlModel, ctlVarSpec); - if (self == NULL) - MmsVariableSpecification_destroy(ctlVarSpec); + MmsVariableSpecification_destroy(ctlVarSpec); exit_function: return self; diff --git a/src/iec61850/inc/iec61850_client.h b/src/iec61850/inc/iec61850_client.h index 26e1f69e..d08f277c 100644 --- a/src/iec61850/inc/iec61850_client.h +++ b/src/iec61850/inc/iec61850_client.h @@ -68,10 +68,10 @@ typedef struct ControlAddCause addCause; } LastApplError; -/** Connection state of the IedConnection instance (either idle, connected or closed) */ +/** Connection state of the IedConnection instance - either closed(idle), connecting, connected, or closing) */ typedef enum { - IED_STATE_CLOSED, + IED_STATE_CLOSED = 0, IED_STATE_CONNECTING, IED_STATE_CONNECTED, IED_STATE_CLOSING @@ -1774,7 +1774,7 @@ typedef struct sControlObjectClient* ControlObjectClient; /** * \brief Create a new client control object * - * A client control object is used to handle all client side aspects of a controllable + * A client control object is used to handle all client side functions of a controllable * data object. A controllable data object is an instance of a controllable CDC like e.g. * SPC, DPC, APC, ... * @@ -1790,6 +1790,21 @@ typedef struct sControlObjectClient* ControlObjectClient; LIB61850_API ControlObjectClient ControlObjectClient_create(const char* objectReference, IedConnection connection); +/** + * \brief Create a new client control object - doesn't send requests to the server (doesn't block) + * + * A client control object is used to handle all client side functions of a controllable + * data object. A controllable data object is an instance of a controllable CDC like e.g. + * SPC, DPC, APC, ... + * + * \param objectReference the reference of the controllable data object + * \param connection the connection instance where the control object has to be reached + * \param ctlModel the control model used by the controllable data object + * \param controlObjectSpec specification of the controllable data objects - used to derive required information to handle the control object + */ +LIB61850_API ControlObjectClient +ControlObjectClient_createEx(const char* objectReference, IedConnection connection, ControlModel ctlModel, MmsVariableSpecification* controlObjectSpec); + /** * \brief Destroy the client control object instance and release all related resources *