diff --git a/examples/server_example_config_file/vmd-filestore/model.cfg b/examples/server_example_config_file/vmd-filestore/model.cfg index d0507a1..c50a26d 100644 --- a/examples/server_example_config_file/vmd-filestore/model.cfg +++ b/examples/server_example_config_file/vmd-filestore/model.cfg @@ -1,7 +1,6 @@ MODEL(simpleIO){ LD(GenericIO){ LN(LLN0){ -SG(1 2) DO(Mod 0){ DA(q 0 23 0 2 0); DA(t 0 22 0 0 0); @@ -36,7 +35,7 @@ DE(GGIO1$MX$AnIn2); DE(GGIO1$MX$AnIn3); DE(GGIO1$MX$AnIn4); } -RC(EventsRCB01 - 0 Events 1 8 111 50 1000); +RC(EventsRCB01 Events 0 Events 1 8 111 50 1000); RC(AnalogValuesRCB01 AnalogValues 0 AnalogValues 1 8 111 50 1000); GC(gcbEvents events Events 2 0){ PA(4 111 1000 010ccd010001); diff --git a/src/doxygen.config b/src/doxygen.config index a71d55b..d4b7390 100644 --- a/src/doxygen.config +++ b/src/doxygen.config @@ -219,7 +219,8 @@ INPUT += "iec61850/inc/iec61850_config_file_parser.h" INPUT += "iec61850/inc/iec61850_cdc.h" INPUT += "goose/goose_subscriber.h" INPUT += "mms/inc/mms_device_model.h" -INPUT += "mms/inc/mms_types.h" +INPUT += "mms/inc/mms_types.h" +INPUT += "mms/inc/mms_common.h" INPUT += "mms/inc/mms_server.h" INPUT += "mms/inc/iso_server.h" INPUT += "mms/inc/mms_named_variable_list.h" diff --git a/src/iec61850/inc/iec61850_dynamic_model.h b/src/iec61850/inc/iec61850_dynamic_model.h index 8870158..43d1182 100644 --- a/src/iec61850/inc/iec61850_dynamic_model.h +++ b/src/iec61850/inc/iec61850_dynamic_model.h @@ -238,7 +238,7 @@ DataSetEntry_getNext(DataSetEntry* self); * \return the new data set entry instance */ DataSetEntry* -DataSetEntry_create(DataSet* dataSet, char* variable, int index, char* component); +DataSetEntry_create(DataSet* dataSet, const char* variable, int index, const char* component); /**@}*/ diff --git a/src/iec61850/inc/iec61850_model.h b/src/iec61850/inc/iec61850_model.h index 01d1a1e..a4a091a 100644 --- a/src/iec61850/inc/iec61850_model.h +++ b/src/iec61850/inc/iec61850_model.h @@ -186,6 +186,7 @@ struct sDataAttribute { typedef struct sDataSetEntry { char* logicalDeviceName; + bool isLDNameDynamicallyAllocated; char* variableName; int index; char* componentName; diff --git a/src/iec61850/server/model/dynamic_model.c b/src/iec61850/server/model/dynamic_model.c index 6e8af66..f536d47 100644 --- a/src/iec61850/server/model/dynamic_model.c +++ b/src/iec61850/server/model/dynamic_model.c @@ -514,11 +514,28 @@ DataSet_addEntry(DataSet* self, DataSetEntry* newEntry) } DataSetEntry* -DataSetEntry_create(DataSet* dataSet, char* variable, int index, char* component) +DataSetEntry_create(DataSet* dataSet, const char* variable, int index, const char* component) { DataSetEntry* self = (DataSetEntry*) GLOBAL_MALLOC(sizeof(DataSetEntry)); - self->variableName = copyString(variable); + char variableName[130]; + + strncpy(variableName, variable, 129); + + char* separator = strchr(variableName, '/'); + + if (separator != NULL) { + *separator = 0; + + self->variableName = copyString(separator + 1); + self->logicalDeviceName = copyString(variableName); + self->isLDNameDynamicallyAllocated = true; + } + else { + self->variableName = copyString(variable); + self->logicalDeviceName = dataSet->logicalDeviceName; + self->isLDNameDynamicallyAllocated = false; + } if (component != NULL) self->componentName = copyString(component); @@ -526,7 +543,7 @@ DataSetEntry_create(DataSet* dataSet, char* variable, int index, char* component self->componentName = NULL; self->index = index; - self->logicalDeviceName = dataSet->logicalDeviceName; + self->sibling = NULL; DataSet_addEntry(dataSet, self); @@ -622,6 +639,9 @@ IedModel_destroy(IedModel* model) GLOBAL_FREEMEM(dse->variableName); + if (dse->isLDNameDynamicallyAllocated) + GLOBAL_FREEMEM(dse->logicalDeviceName); + GLOBAL_FREEMEM(dse); dse = nextDse; diff --git a/src/mms/inc/mms_common.h b/src/mms/inc/mms_common.h index 705b402..495c8d1 100644 --- a/src/mms/inc/mms_common.h +++ b/src/mms/inc/mms_common.h @@ -42,6 +42,13 @@ typedef enum MMS_ERROR, MMS_INITIATE, MMS_CONFIRMED_REQUEST, MMS_OK, MMS_CONCLUDE } MmsIndication; +/** + * \addtogroup common_api_group + */ +/**@{*/ + + + typedef enum { /* generic error codes */ @@ -107,21 +114,33 @@ typedef enum typedef enum ATTRIBUTE_PACKED { + /*! this represents all MMS array types (arrays contain uniform elements) */ MMS_ARRAY = 0, + /*! this represents all complex MMS types (structures) */ MMS_STRUCTURE = 1, + /*! boolean value */ MMS_BOOLEAN = 2, + /*! bit string */ MMS_BIT_STRING = 3, + /*! represents all signed integer types */ MMS_INTEGER = 4, + /*! represents all unsigned integer types */ MMS_UNSIGNED = 5, + /*! represents all float type (32 and 64 bit) */ MMS_FLOAT = 6, + /*! octet string (unstructured bytes) */ MMS_OCTET_STRING = 7, + /*! MMS visible string */ MMS_VISIBLE_STRING = 8, MMS_GENERALIZED_TIME = 9, MMS_BINARY_TIME = 10, MMS_BCD = 11, MMS_OBJ_ID = 12, + /*! MMS unicode string */ MMS_STRING = 13, + /*! MMS UTC time type */ MMS_UTC_TIME = 14, + /*! This represents an error code as returned by MMS read services */ MMS_DATA_ACCESS_ERROR = 15 } MmsType; @@ -146,6 +165,9 @@ typedef struct typedef struct sMmsNamedVariableList* MmsNamedVariableList; typedef struct sMmsAccessSpecifier* MmsNamedVariableListEntry; +/**@}*/ + + #ifdef __cplusplus } #endif diff --git a/tools/model_generator/genconfig.jar b/tools/model_generator/genconfig.jar index 6b33f74..32b327e 100644 Binary files a/tools/model_generator/genconfig.jar and b/tools/model_generator/genconfig.jar differ diff --git a/tools/model_generator/src/com/libiec61850/tools/DynamicModelGenerator.java b/tools/model_generator/src/com/libiec61850/tools/DynamicModelGenerator.java index d2e65a5..03d3cc6 100644 --- a/tools/model_generator/src/com/libiec61850/tools/DynamicModelGenerator.java +++ b/tools/model_generator/src/com/libiec61850/tools/DynamicModelGenerator.java @@ -122,7 +122,7 @@ public class DynamicModelGenerator { } for (DataSet dataSet : logicalNode.getDataSets()) - exportDataSet(output, dataSet); + exportDataSet(output, dataSet, logicalNode); for (ReportControlBlock rcb : logicalNode.getReportControlBlocks()) { @@ -217,7 +217,7 @@ public class DynamicModelGenerator { output.println(");"); } - private void exportDataSet(PrintStream output, DataSet dataSet) { + private void exportDataSet(PrintStream output, DataSet dataSet, LogicalNode logicalNode) { output.print("DS(" + dataSet.getName() + "){\n"); for (FunctionalConstraintData fcda : dataSet.getFcda()) { String mmsVariableName = ""; @@ -237,7 +237,21 @@ public class DynamicModelGenerator { if (fcda.getDaName() != null) mmsVariableName += "$" + toMmsString(fcda.getDaName()); - output.print("DE(" + mmsVariableName + ");\n"); + String logicalDeviceName = null; + + if (fcda.getLdInstance() != null) { + + if (!fcda.getLdInstance().equals(logicalNode.getParentLogicalDevice().getInst())) { + logicalDeviceName = fcda.getLdInstance(); + } + } + + + if (logicalDeviceName != null) + output.print("DE(" + logicalDeviceName + "/" + mmsVariableName + ");\n"); + else + output.print("DE(" + mmsVariableName + ");\n"); + } output.println("}"); }