From cd8f5f483dfbf8f3ff1f880a37e00f6344fe1181 Mon Sep 17 00:00:00 2001 From: Michael Zillgith Date: Thu, 26 Oct 2017 09:32:16 +0200 Subject: [PATCH] - IED server: added new function IedServer_udpateDbposValue; added new return code for control check callback function --- src/iec61850/inc/iec61850_server.h | 18 +++++++++++++++- src/iec61850/server/impl/ied_server.c | 21 +++++++++++++++++++ src/iec61850/server/mms_mapping/control.c | 25 ++--------------------- src/vs/libiec61850-wo-goose.def | 1 + src/vs/libiec61850.def | 1 + 5 files changed, 42 insertions(+), 24 deletions(-) diff --git a/src/iec61850/inc/iec61850_server.h b/src/iec61850/inc/iec61850_server.h index 90b266c..8b08e14 100644 --- a/src/iec61850/inc/iec61850_server.h +++ b/src/iec61850/inc/iec61850_server.h @@ -560,6 +560,21 @@ IedServer_updateFloatAttributeValue(IedServer self, DataAttribute* dataAttribute void IedServer_updateInt32AttributeValue(IedServer self, DataAttribute* dataAttribute, int32_t value); +/** + * \brief Update the value of an IEC 61850 Dbpos (double point/position) data attribute. + * + * Update the value of a integer data attribute without handling with MmsValue instances. + * + * This function will also check if a trigger condition is satisfied in the case when a report or GOOSE + * control block is enabled. + * + * \param self the instance of IedServer to operate on. + * \param dataAttribute the data attribute handle + * \param value the new Dbpos value of the data attribute. + */ +void +IedServer_udpateDbposValue(IedServer self, DataAttribute* dataAttribute, Dbpos value); + /** * \brief Update the value of an IEC 61850 integer64 data attribute (like BCR actVal) * @@ -820,7 +835,8 @@ typedef enum { CONTROL_HARDWARE_FAULT = 1, /** check failed due to hardware fault */ CONTROL_TEMPORARILY_UNAVAILABLE = 2, /** control is already selected or operated */ CONTROL_OBJECT_ACCESS_DENIED = 3, /** check failed due to access control reason - access denied for this client or state */ - CONTROL_OBJECT_UNDEFINED = 4 /** object not visible in this security context ??? */ + CONTROL_OBJECT_UNDEFINED = 4, /** object not visible in this security context ??? */ + CONTROL_VALUE_INVALID = 11 /** ctlVal out of range */ } CheckHandlerResult; /** diff --git a/src/iec61850/server/impl/ied_server.c b/src/iec61850/server/impl/ied_server.c index 8dfa507..60778bb 100644 --- a/src/iec61850/server/impl/ied_server.c +++ b/src/iec61850/server/impl/ied_server.c @@ -985,6 +985,27 @@ IedServer_updateInt32AttributeValue(IedServer self, DataAttribute* dataAttribute } } +void +IedServer_udpateDbposValue(IedServer self, DataAttribute* dataAttribute, Dbpos value) +{ + Dbpos currentValue = Dbpos_fromMmsValue(dataAttribute->mmsValue); + + if (currentValue == value) { + checkForUpdateTrigger(self, dataAttribute); + } + else { +#if (CONFIG_MMS_THREADLESS_STACK != 1) + Semaphore_wait(self->dataModelLock); +#endif + Dbpos_toMmsValue(dataAttribute->mmsValue, value); +#if (CONFIG_MMS_THREADLESS_STACK != 1) + Semaphore_post(self->dataModelLock); +#endif + + checkForChangedTriggers(self, dataAttribute); + } +} + void IedServer_updateInt64AttributeValue(IedServer self, DataAttribute* dataAttribute, int64_t value) { diff --git a/src/iec61850/server/mms_mapping/control.c b/src/iec61850/server/mms_mapping/control.c index 3759211..71b3e5a 100644 --- a/src/iec61850/server/mms_mapping/control.c +++ b/src/iec61850/server/mms_mapping/control.c @@ -1211,27 +1211,6 @@ checkValidityOfOriginParameter(MmsValue* origin) return true; } -static MmsDataAccessError -getDataAccessErrorFromCheckHandlerResult(CheckHandlerResult checkResult) -{ - MmsDataAccessError indication; - - if (checkResult == CONTROL_HARDWARE_FAULT) - indication = DATA_ACCESS_ERROR_HARDWARE_FAULT; - else - if (checkResult == CONTROL_TEMPORARILY_UNAVAILABLE) - indication = DATA_ACCESS_ERROR_TEMPORARILY_UNAVAILABLE; - else - if (checkResult == CONTROL_OBJECT_UNDEFINED) - indication = DATA_ACCESS_ERROR_OBJECT_UNDEFINED; - else if (checkResult == CONTROL_OBJECT_ACCESS_DENIED) - indication = DATA_ACCESS_ERROR_OBJECT_ACCESS_DENIED; - else - indication = DATA_ACCESS_ERROR_SUCCESS; - - return indication; -} - MmsDataAccessError Control_writeAccessControlObject(MmsMapping* self, MmsDomain* domain, char* variableIdOrig, MmsValue* value, MmsServerConnection connection) @@ -1378,7 +1357,7 @@ Control_writeAccessControlObject(MmsMapping* self, MmsDomain* domain, char* vari printf("SBOw: selected successful\n"); } else { - indication = getDataAccessErrorFromCheckHandlerResult(checkResult); + indication = (MmsDataAccessError) checkResult; ControlObject_sendLastApplError(controlObject, connection, "SBOw", 0, ADD_CAUSE_SELECT_FAILED, ctlNum, origin, true); @@ -1523,7 +1502,7 @@ Control_writeAccessControlObject(MmsMapping* self, MmsDomain* domain, char* vari } else { - indication = getDataAccessErrorFromCheckHandlerResult(checkResult); + indication = (MmsDataAccessError) checkResult; abortControlOperation(controlObject); } diff --git a/src/vs/libiec61850-wo-goose.def b/src/vs/libiec61850-wo-goose.def index 29379a0..e3dcacc 100644 --- a/src/vs/libiec61850-wo-goose.def +++ b/src/vs/libiec61850-wo-goose.def @@ -572,3 +572,4 @@ EXPORTS MmsConnection_writeNamedVariableList IedConnection_writeDataSetValues MmsVariableSpecification_isValueOfType + IedServer_udpateDbposValue diff --git a/src/vs/libiec61850.def b/src/vs/libiec61850.def index d4589e1..a69d763 100644 --- a/src/vs/libiec61850.def +++ b/src/vs/libiec61850.def @@ -653,3 +653,4 @@ EXPORTS SVClientASDU_getRefrTmAsMs IedConnection_writeDataSetValues MmsVariableSpecification_isValueOfType + IedServer_udpateDbposValue