diff --git a/src/OMSimulatorLib/Component.h b/src/OMSimulatorLib/Component.h index d49d3ef58..3604ddd46 100644 --- a/src/OMSimulatorLib/Component.h +++ b/src/OMSimulatorLib/Component.h @@ -65,6 +65,7 @@ namespace oms virtual oms_status_enu_t exportToSSD(pugi::xml_node& node, Snapshot& snapshot, std::string variantName) const = 0; virtual oms_status_enu_t exportToSSV(pugi::xml_node& ssvNode) { return logError_NotImplemented; } virtual void getFilteredUnitDefinitionsToSSD(std::map>& unitDefinitions) { return ; } + virtual void getFilteredEnumerationDefinitionsToSSD(std::map>& enumerationDefinitions) { return ; } virtual oms_status_enu_t initialize() = 0; virtual oms_status_enu_t instantiate() = 0; diff --git a/src/OMSimulatorLib/ComponentFMUCS.cpp b/src/OMSimulatorLib/ComponentFMUCS.cpp index 755ab2ba7..c79cd082f 100644 --- a/src/OMSimulatorLib/ComponentFMUCS.cpp +++ b/src/OMSimulatorLib/ComponentFMUCS.cpp @@ -259,6 +259,11 @@ oms::Component* oms::ComponentFMUCS::NewComponent(const oms::ComRef& cref, oms:: std::string unitName = component->values.getUnitFromModeldescription(connectorCref); if (!unitName.empty()) connector->connectorUnits[unitName] = component->values.modeldescriptionUnitDefinitions[unitName]; + + // get enumerationTypes + std::string enumType = component->values.getEnumerationTypeFromModeldescription(connectorCref); + if (!enumType.empty()) + connector->enumerationName[connectorCref] = enumType; } } @@ -304,6 +309,16 @@ oms::Component* oms::ComponentFMUCS::NewComponent(const pugi::xml_node& node, om if (!unitName.empty()) component->connectors.back()->connectorUnits[unitName] = component->values.modeldescriptionUnitDefinitions[unitName]; } + // set enumeration definitions + if ((*itConnectors).child(oms::ssp::Version1_0::ssc::enumeration_type)) + { + std::string enumTypeName = (*itConnectors).child(oms::ssp::Version1_0::ssc::enumeration_type).attribute("name").as_string(); + if (!enumTypeName.empty()) + component->connectors.back()->enumerationName[component->connectors.back()->getName().c_str()] = enumTypeName; + + // give priority to enum definitions in ssd over modeldescription.xml, it is possible the user might have manually change values in ssd file + component->values.importEnumerationDefinitions(ssdNode, enumTypeName); + } } } else if(name == oms::ssp::Draft20180219::ssd::element_geometry) @@ -389,6 +404,11 @@ void oms::ComponentFMUCS::getFilteredUnitDefinitionsToSSD(std::map>& enumerationDefinitions) +{ + return values.getFilteredEnumerationDefinitionsToSSD(enumerationDefinitions); +} + oms_status_enu_t oms::ComponentFMUCS::exportToSSV(pugi::xml_node& ssvNode) { return values.exportToSSV(ssvNode); diff --git a/src/OMSimulatorLib/ComponentFMUCS.h b/src/OMSimulatorLib/ComponentFMUCS.h index fcb99773d..872de7baf 100644 --- a/src/OMSimulatorLib/ComponentFMUCS.h +++ b/src/OMSimulatorLib/ComponentFMUCS.h @@ -63,6 +63,7 @@ namespace oms oms_status_enu_t exportToSSD(pugi::xml_node& node, Snapshot& snapshot, std::string variantName) const; oms_status_enu_t exportToSSV(pugi::xml_node& ssvNode); void getFilteredUnitDefinitionsToSSD(std::map>& unitDefinitions); + void getFilteredEnumerationDefinitionsToSSD(std::map>& enumerationDefinitions); oms_status_enu_t exportToSSVTemplate(pugi::xml_node& ssvNode, Snapshot& snapshot); oms_status_enu_t exportToSSMTemplate(pugi::xml_node& ssmNode); oms_status_enu_t instantiate(); diff --git a/src/OMSimulatorLib/ComponentFMUME.cpp b/src/OMSimulatorLib/ComponentFMUME.cpp index 422ee7fcd..ea936a672 100644 --- a/src/OMSimulatorLib/ComponentFMUME.cpp +++ b/src/OMSimulatorLib/ComponentFMUME.cpp @@ -257,6 +257,11 @@ oms::Component* oms::ComponentFMUME::NewComponent(const oms::ComRef& cref, oms:: std::string unitName = component->values.getUnitFromModeldescription(connectorCref); if (!unitName.empty()) connector->connectorUnits[unitName] = component->values.modeldescriptionUnitDefinitions[unitName]; + + // get enumerationTypes + std::string enumType = component->values.getEnumerationTypeFromModeldescription(connectorCref); + if (!enumType.empty()) + connector->enumerationName[connectorCref] = enumType; } } @@ -302,6 +307,16 @@ oms::Component* oms::ComponentFMUME::NewComponent(const pugi::xml_node& node, om if (!unitName.empty()) component->connectors.back()->connectorUnits[unitName] = component->values.modeldescriptionUnitDefinitions[unitName]; } + // set enumeration definitions + if ((*itConnectors).child(oms::ssp::Version1_0::ssc::enumeration_type)) + { + std::string enumTypeName = (*itConnectors).child(oms::ssp::Version1_0::ssc::enumeration_type).attribute("name").as_string(); + if (!enumTypeName.empty()) + component->connectors.back()->enumerationName[component->connectors.back()->getName().c_str()] = enumTypeName; + + // give priority to enum definitions in ssd over modeldescription.xml + component->values.importEnumerationDefinitions(ssdNode, enumTypeName); + } } } else if(name == oms::ssp::Draft20180219::ssd::element_geometry) @@ -387,6 +402,11 @@ void oms::ComponentFMUME::getFilteredUnitDefinitionsToSSD(std::map>& enumerationDefinitions) +{ + return values.getFilteredEnumerationDefinitionsToSSD(enumerationDefinitions); +} + oms_status_enu_t oms::ComponentFMUME::exportToSSV(pugi::xml_node& ssvNode) { return values.exportToSSV(ssvNode); diff --git a/src/OMSimulatorLib/ComponentFMUME.h b/src/OMSimulatorLib/ComponentFMUME.h index 812513a28..bb9e029d3 100644 --- a/src/OMSimulatorLib/ComponentFMUME.h +++ b/src/OMSimulatorLib/ComponentFMUME.h @@ -61,6 +61,7 @@ namespace oms oms_status_enu_t exportToSSD(pugi::xml_node& node, Snapshot& snapshot, std::string variantName) const; oms_status_enu_t exportToSSV(pugi::xml_node& ssvNode); void getFilteredUnitDefinitionsToSSD(std::map>& unitDefinitions); + void getFilteredEnumerationDefinitionsToSSD(std::map>& enumerationDefinitions); oms_status_enu_t exportToSSVTemplate(pugi::xml_node& ssvNode, Snapshot& snapshot); oms_status_enu_t exportToSSMTemplate(pugi::xml_node& ssmNode); oms_status_enu_t instantiate(); diff --git a/src/OMSimulatorLib/Connector.cpp b/src/OMSimulatorLib/Connector.cpp index 7225ee9f2..6db6ad034 100644 --- a/src/OMSimulatorLib/Connector.cpp +++ b/src/OMSimulatorLib/Connector.cpp @@ -234,6 +234,8 @@ oms_status_enu_t oms::Connector::exportToSSD(pugi::xml_node &root) const break; case oms_signal_type_enum: node.append_child(oms::ssp::Version1_0::ssc::enumeration_type); + for (const auto & it : this->enumerationName) + node.child(oms::ssp::Version1_0::ssc::enumeration_type).append_attribute("name") = it.second.c_str(); break; case oms_signal_type_integer: node.append_child(oms::ssp::Version1_0::ssc::integer_type); diff --git a/src/OMSimulatorLib/Connector.h b/src/OMSimulatorLib/Connector.h index bdab62f90..4cd41c120 100644 --- a/src/OMSimulatorLib/Connector.h +++ b/src/OMSimulatorLib/Connector.h @@ -72,6 +72,7 @@ namespace oms void setGeometry(const oms::ssd::ConnectorGeometry* newGeometry); std::map> connectorUnits; ///< single entry map which contains unit as key and BaseUnits as value for a connector + std::map enumerationName; ///< single entry map which contains connector name as key and enumerationName as value for a connector of type ssc:Enumeration const oms_causality_enu_t getCausality() const {return causality;} const oms_signal_type_enu_t getType() const {return type;} diff --git a/src/OMSimulatorLib/Model.cpp b/src/OMSimulatorLib/Model.cpp index f29861700..ac26c70e8 100644 --- a/src/OMSimulatorLib/Model.cpp +++ b/src/OMSimulatorLib/Model.cpp @@ -830,7 +830,7 @@ oms_status_enu_t oms::Model::exportToSSD(Snapshot& snapshot) const if (oms_status_ok != system->exportToSSD(system_node, snapshot, this->variantName)) return logError("export of system failed"); } - + exportEnumerationDefinitionsToSSD(ssdNode); exportUnitDefinitionsToSSD(ssdNode); pugi::xml_node default_experiment = ssdNode.append_child(oms::ssp::Draft20180219::ssd::default_experiment); @@ -890,6 +890,10 @@ oms_status_enu_t oms::Model::importFromSnapshot(const Snapshot& snapshot) { // allow importing unitDefinitions, the unitDefinitions are handled in Values.cpp importFromSnapshot } + else if (name == oms::ssp::Draft20180219::ssd::enumerations) + { + // allow importing enumerations, the enumerationDefinitions are handled in Values.cpp importFromSnapshot + } else if (name == oms::ssp::Draft20180219::ssd::default_experiment) { startTime = it->attribute("startTime").as_double(0.0); @@ -1520,6 +1524,34 @@ void oms::Model::exportUnitDefinitionsToSSD(pugi::xml_node& node) const } } +void oms::Model::exportEnumerationDefinitionsToSSD(pugi::xml_node& node) const +{ + if (!system) + return; + + std::map> enumerationDefinitions; + for (const auto& component : system->getComponents()) + component.second->getFilteredEnumerationDefinitionsToSSD(enumerationDefinitions); + + if (enumerationDefinitions.empty()) + return; + + pugi::xml_node node_enumeration = node.append_child(oms::ssp::Draft20180219::ssd::enumerations); + + for (const auto &it : enumerationDefinitions) + { + pugi::xml_node ssc_enumeration = node_enumeration.append_child(oms::ssp::Version1_0::ssc::enumeration_type); + ssc_enumeration.append_attribute("name") = it.first.c_str(); + for (const auto & item: it.second) + { + pugi::xml_node enumItem = ssc_enumeration.append_child(oms::ssp::Version1_0::ssc::enum_item); + enumItem.append_attribute("name") = item.first.c_str(); + enumItem.append_attribute("value") = item.second.c_str(); + } + } + +} + oms_status_enu_t oms::Model::importSignalFilter(const std::string& filename, const Snapshot& snapshot) { if (".*" == filename) // avoid error messages for older ssp files diff --git a/src/OMSimulatorLib/Model.h b/src/OMSimulatorLib/Model.h index 4246e9f28..8a0d14fb7 100644 --- a/src/OMSimulatorLib/Model.h +++ b/src/OMSimulatorLib/Model.h @@ -85,6 +85,7 @@ namespace oms oms_status_enu_t exportSSMTemplate(const ComRef& cref, const std::string& filename); void exportSignalFilter(Snapshot& snapshot) const; void exportUnitDefinitionsToSSD(pugi::xml_node& node) const; + void exportEnumerationDefinitionsToSSD(pugi::xml_node& node) const; oms_status_enu_t importFromSnapshot(const Snapshot& snapshot); oms_status_enu_t importSnapshot(const char* snapshot, char** newCref); oms_status_enu_t importSignalFilter(const std::string& filename, const Snapshot& snapshot); diff --git a/src/OMSimulatorLib/Values.cpp b/src/OMSimulatorLib/Values.cpp index d5fe4d368..7288af21e 100644 --- a/src/OMSimulatorLib/Values.cpp +++ b/src/OMSimulatorLib/Values.cpp @@ -96,6 +96,19 @@ void oms::Values::getFilteredUnitDefinitionsToSSD(std::map>& enumerationDefinitions) +{ + if (modeldescriptionTypeDefinitions.empty()) + return; + + for(const auto &it: modeldescriptionTypeDefinitions) + { + auto enumType = enumerationDefinitions.find(it.first); + if (enumType == enumerationDefinitions.end()) + enumerationDefinitions[it.first] = it.second; + } +} + oms_status_enu_t oms::Values::setInteger(const ComRef& cref, int value) { integerStartValues[cref] = value; @@ -575,6 +588,16 @@ std::string oms::Values::getUnitFromModeldescription(ComRef& cref) const return ""; } +std::string oms::Values::getEnumerationTypeFromModeldescription(ComRef& cref) const +{ + // search in modelDescription.xml + auto enumType = modeldescriptionEnumeration.find(cref); + if (enumType != modeldescriptionEnumeration.end()) + return enumType->second; + + return ""; +} + oms_status_enu_t oms::Values::getIntegerFromModeldescription(const ComRef& cref, int& value) { // search in modelDescription.xml @@ -1486,6 +1509,29 @@ void oms::Values::importUnitDefinitions(const pugi::xml_node& node) } } +void oms::Values::importEnumerationDefinitions(const pugi::xml_node& node, std::string& enumTypename) +{ + + if (!node) + return; + + pugi::xml_node enumeration = node.child(oms::ssp::Draft20180219::ssd::enumerations); + + for (pugi::xml_node enumItems = enumeration.child(oms::ssp::Version1_0::ssc::enumeration_type); enumItems; enumItems = enumItems.next_sibling(oms::ssp::Version1_0::ssc::enumeration_type)) + { + // entry found + if (enumItems.attribute("name").as_string() == enumTypename) + { + std::map enumerationItems; + for (pugi::xml_node enumItem = enumItems.child(oms::ssp::Version1_0::ssc::enum_item); enumItem; enumItem = enumItem.next_sibling(oms::ssp::Version1_0::ssc::enum_item)) + { + enumerationItems[enumItem.attribute("name").as_string()] = enumItem.attribute("value").as_string(); + } + modeldescriptionTypeDefinitions[enumTypename] = enumerationItems; + } + } +} + oms_status_enu_t oms::Values::parseModelDescription(const filesystem::path& root, std::string& guid_) { @@ -1513,6 +1559,21 @@ oms_status_enu_t oms::Values::parseModelDescription(const filesystem::path& root for(pugi::xml_node_iterator it = node.begin(); it != node.end(); ++it) { std::string name = it->name(); + if (name == "TypeDefinitions") + { + pugi::xml_node simpleType = it->child("SimpleType"); + pugi::xml_node Enumeration = simpleType.child("Enumeration"); + if (Enumeration) + { + std::map enumerationItems; + for (pugi::xml_node enumItem = Enumeration.child("Item"); enumItem; enumItem = enumItem.next_sibling("Item")) + { + // std::cout << "\n loop: " << enumItem.attribute("name").as_string() << "==>" << enumItem.attribute("value").as_string(); + enumerationItems[enumItem.attribute("name").as_string()] = enumItem.attribute("value").as_string(); + } + modeldescriptionTypeDefinitions[simpleType.attribute("name").as_string()] = enumerationItems; + } + } if (name == "UnitDefinitions") { //std::cout << "\nParse Unit Definitions"; @@ -1563,6 +1624,10 @@ oms_status_enu_t oms::Values::parseModelDescription(const filesystem::path& root { modelDescriptionBooleanStartValues[scalarVariable.attribute("name").as_string()] = scalarVariable.child("Boolean").attribute("start").as_bool(); } + if (strlen(scalarVariable.child("Enumeration").attribute("declaredType").as_string()) != 0) + { + modeldescriptionEnumeration[scalarVariable.attribute("name").as_string()] = scalarVariable.child("Enumeration").attribute("declaredType").as_string(); + } } } if (name == "ModelStructure") diff --git a/src/OMSimulatorLib/Values.h b/src/OMSimulatorLib/Values.h index b2329a736..3a420e8da 100644 --- a/src/OMSimulatorLib/Values.h +++ b/src/OMSimulatorLib/Values.h @@ -55,6 +55,7 @@ namespace oms oms_status_enu_t setUnit(const ComRef& cref, const std::string& value); void setUnitDefinitions(const ComRef& cref); void getFilteredUnitDefinitionsToSSD(std::map>& unitDefinitions); + void getFilteredEnumerationDefinitionsToSSD(std::map>& enumerationDefinitions); void updateModelDescriptionRealStartValue(const ComRef& cref, double value); void updateModelDescriptionIntegerStartValue(const ComRef& cref, int value); void updateModelDescriptionBooleanStartValue(const ComRef& cref, bool value); @@ -86,7 +87,7 @@ namespace oms std::string getUnit(ComRef& cref) const; std::string getUnitFromModeldescription(ComRef& cref) const; - + std::string getEnumerationTypeFromModeldescription(ComRef& cref) const; oms_status_enu_t exportToSSD(pugi::xml_node& node) const; oms_status_enu_t importFromSnapshot(const pugi::xml_node& node, const std::string& sspVersion, const Snapshot& snapshot, std::string variantName); oms_status_enu_t importFromSnapshot(const Snapshot& snapshot, const std::string& ssvFilePath, const std::string& ssmFilename); @@ -102,6 +103,7 @@ namespace oms oms_status_enu_t exportUnitDefinitions(Snapshot &snapshot, std::string filename, std::string variantName) const; oms_status_enu_t exportUnitDefinitionsToSSVTemplate(Snapshot &snapshot, std::string filename); void importUnitDefinitions(const pugi::xml_node& node); + void importEnumerationDefinitions(const pugi::xml_node& node, std::string& enumTypeName); void exportToSSVTemplate(pugi::xml_node& ssvNode, const ComRef& cref); ///< start values read from modelDescription.xml and creates a ssv template void exportReduceSSV(pugi::xml_node& ssvNode, const ComRef& cref); ///< reduced SSV file which contains only the referenced crefs in parametermapping @@ -167,6 +169,9 @@ namespace oms std::map> modeldescriptionUnitDefinitions; ///< list read from modeldescription.xml + std::map> modeldescriptionTypeDefinitions; ///< list read from modeldescription.xml + std::map modeldescriptionEnumeration; ///< enumeration declared type list list read from modeldescription.xml + std::multimap mappedEntry; ///< parameter names and values provided in the parameter source are to be mapped to the parameters of the component or system std::vector parameterResources; ///< list of parameter resources provided inline or .ssv files diff --git a/src/OMSimulatorLib/XercesValidator.cpp b/src/OMSimulatorLib/XercesValidator.cpp index 63e0af5c6..97c9f0e41 100644 --- a/src/OMSimulatorLib/XercesValidator.cpp +++ b/src/OMSimulatorLib/XercesValidator.cpp @@ -149,11 +149,12 @@ oms_status_enu_t oms::XercesValidator::validateSSP(const char *ssd, const std::s return logError("executable path could not be found"); filesystem::path schemaRootPath (path); - filesystem::path schemaSSDPath, schemaSSVPath, schemaSSMPath; + filesystem::path schemaSSDPath, schemaSSVPath, schemaSSMPath, schemaSSCPath; schemaSSDPath = schemaRootPath / "../share/OMSimulator/schema/ssp/SystemStructureDescription.xsd"; schemaSSVPath = schemaRootPath / "../share/OMSimulator/schema/ssp/SystemStructureParameterValues.xsd"; schemaSSMPath = schemaRootPath / "../share/OMSimulator/schema/ssp/SystemStructureParameterMapping.xsd"; + schemaSSCPath = schemaRootPath / "../share/OMSimulator/schema/ssp/SystemStructureCommon.xsd"; // std::cout << "schemaPath: " << schemaFilePath.generic_string() << "\n" << filesystem::absolute(schemaFilePath).generic_string() << "\n"; @@ -165,6 +166,7 @@ oms_status_enu_t oms::XercesValidator::validateSSP(const char *ssd, const std::s schemaSSDPath = schemaRootPath / "../../share/OMSimulator/schema/ssp/SystemStructureDescription.xsd"; schemaSSVPath = schemaRootPath / "../../share/OMSimulator/schema/ssp/SystemStructureParameterValues.xsd"; schemaSSMPath = schemaRootPath / "../../share/OMSimulator/schema/ssp/SystemStructureParameterMapping.xsd"; + schemaSSCPath = schemaRootPath / "../../share/OMSimulator/schema/ssp/SystemStructureCommon.xsd"; } XercesDOMParser domParser; @@ -195,6 +197,7 @@ oms_status_enu_t oms::XercesValidator::validateSSP(const char *ssd, const std::s std::string ssdTargetNameSpacePath = "http://ssp-standard.org/SSP1/SystemStructureDescription " + schemaSSDPath.generic_string(); ssdTargetNameSpacePath = ssdTargetNameSpacePath + " http://ssp-standard.org/SSP1/SystemStructureParameterValues " + schemaSSVPath.generic_string(); ssdTargetNameSpacePath = ssdTargetNameSpacePath + " http://ssp-standard.org/SSP1/SystemStructureParameterMapping " + schemaSSMPath.generic_string(); + ssdTargetNameSpacePath = ssdTargetNameSpacePath + " http://ssp-standard.org/SSP1/SystemStructureCommon " + schemaSSCPath.generic_string(); domParser.setExternalSchemaLocation(ssdTargetNameSpacePath.c_str()); diff --git a/src/OMSimulatorLib/ssd/Tags.cpp b/src/OMSimulatorLib/ssd/Tags.cpp index ecbd89725..bc640011c 100644 --- a/src/OMSimulatorLib/ssd/Tags.cpp +++ b/src/OMSimulatorLib/ssd/Tags.cpp @@ -61,7 +61,7 @@ const char* oms::ssp::Draft20180219::ssd::units = "ssd:Un // version 1.0 const char* oms::ssp::Version1_0::simulation_information = "oms:SimulationInformation"; // simulation information must be handled in a vendor specific annotation const char* oms::ssp::Version1_0::FixedStepMaster = "oms:FixedStepMaster"; // WC-System -const char* oms::ssp::Version1_0::VariableStepMaster = "oms:VariableStepMaster"; // WC-System +const char* oms::ssp::Version1_0::VariableStepMaster = "oms:VariableStepMaster"; // WC-System const char* oms::ssp::Version1_0::VariableStepSolver = "oms:VariableStepSolver"; // SC-System const char* oms::ssp::Version1_0::oms_annotations = "oms:Annotations"; // root node for all oms_annotations const char* oms::ssp::Version1_0::oms_buses = "oms:Buses"; @@ -90,6 +90,7 @@ const char* oms::ssp::Version1_0::ssc::enumeration_type = "ssc:En const char* oms::ssp::Version1_0::ssc::binary_type = "ssc:Binary"; const char* oms::ssp::Version1_0::ssc::unit = "ssc:Unit"; const char* oms::ssp::Version1_0::ssc::base_unit = "ssc:BaseUnit"; +const char* oms::ssp::Version1_0::ssc::enum_item = "ssc:Item"; const char* oms::ssp::Version1_0::ssv::real_type = "ssv:Real"; const char* oms::ssp::Version1_0::ssv::integer_type = "ssv:Integer"; diff --git a/src/OMSimulatorLib/ssd/Tags.h b/src/OMSimulatorLib/ssd/Tags.h index 0e12e8791..d403cdddb 100644 --- a/src/OMSimulatorLib/ssd/Tags.h +++ b/src/OMSimulatorLib/ssd/Tags.h @@ -90,6 +90,7 @@ namespace oms extern const char* annotation; extern const char* unit; extern const char* base_unit; + extern const char* enum_item; } } diff --git a/testsuite/simulation/Makefile b/testsuite/simulation/Makefile index 18c8c7963..f429f55a8 100644 --- a/testsuite/simulation/Makefile +++ b/testsuite/simulation/Makefile @@ -26,6 +26,7 @@ equationPair.py \ exportConnectorsToResultFile.lua \ exportSnapshotSSP.lua \ exportSSMTemplate.lua \ +importExportEnumerationDefinition.lua \ exportSSMTemplate.py \ fmuState01.lua \ fmuState02.py \ diff --git a/testsuite/simulation/PI_Controller.lua b/testsuite/simulation/PI_Controller.lua index bb0195682..62e140f98 100644 --- a/testsuite/simulation/PI_Controller.lua +++ b/testsuite/simulation/PI_Controller.lua @@ -107,8 +107,6 @@ oms_terminate("PI_Controller") oms_delete("PI_Controller") -- Result: --- warning: invalid "SystemStructureDescription" detected in file "PI_Controller.ssp" at line: 78 column: 32, missing required attribute 'name' --- warning: "SystemStructureDescription" does not conform to the SSP standard schema -- info: Parameter settings -- info: PI_Controller.co_sim.addP.k1: 1.0 -- info: PI_Controller.co_sim.addP.k2: -1.0 @@ -125,6 +123,4 @@ oms_delete("PI_Controller") -- info: Simulation -- info: limiter.u: -10.041439549286 -- info: limiter.y: -10.041439549286 --- info: 2 warnings --- info: 0 errors -- endResult diff --git a/testsuite/simulation/importExportEnumerationDefinition.lua b/testsuite/simulation/importExportEnumerationDefinition.lua new file mode 100644 index 000000000..ca939cf7c --- /dev/null +++ b/testsuite/simulation/importExportEnumerationDefinition.lua @@ -0,0 +1,189 @@ +-- status: correct +-- teardown_command: rm -rf PI_Controller-lua/ +-- linux: yes +-- mingw32: yes +-- mingw64: yes +-- win: yes +-- mac: no + +oms_setCommandLineOption("--suppressPath=true") +oms_setTempDirectory("./enumdef_lua/") +oms_setWorkingDirectory("./enumdef_lua/") + +oms_newModel("model") +oms_addSystem("model.co_sim", oms_system_wc) + +oms_addSubModel("model.co_sim.limiter", "../../resources/Modelica.Blocks.Nonlinear.Limiter.fmu") + +-- snapshot = oms_exportSnapshot("model") +-- print(snapshot) + +oms_export("model", "enumdef.ssp") +oms_delete("model") + +oms_importFile("enumdef.ssp") + +snapshot_ = oms_exportSnapshot("model") +print(snapshot_) + + +-- Result: +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- endResult