Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade ssp schema's to 2.0 and export as ssp 2.0 #1420

Merged
merged 9 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
353 changes: 345 additions & 8 deletions schema/ssp/SystemStructureCommon.xsd

Large diffs are not rendered by default.

398 changes: 263 additions & 135 deletions schema/ssp/SystemStructureDescription.xsd

Large diffs are not rendered by default.

221 changes: 162 additions & 59 deletions schema/ssp/SystemStructureDescription11.xsd

Large diffs are not rendered by default.

13 changes: 8 additions & 5 deletions schema/ssp/SystemStructureParameterMapping.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
<xs:annotation>
<xs:documentation xml:lang="en">
This is the normative XML Schema 1.0 schema for the MAP SSP
SystemStructureParameterMapping 1.0 format.
SystemStructureParameterMapping 2.0 format.

Version: 1.0
Version: 2.0

Copyright 2016 -- 2019 Modelica Association Project "SSP"
Copyright 2016 -- 2024 Modelica Association Project "SSP"

Redistribution and use in source and binary forms, with or
without modification, are permitted provided that the
Expand Down Expand Up @@ -48,17 +48,20 @@
<xs:complexType>
<xs:sequence>
<xs:element name="MappingEntry" minOccurs="0" maxOccurs="unbounded" type="ssm:TMappingEntry"/>
<xs:group ref="ssc:GMetaData"/>
<xs:group ref="ssc:GSignature"/>
<xs:element name="Annotations" minOccurs="0" type="ssc:TAnnotations"/>
</xs:sequence>
<xs:attribute name="version" use="required">
<xs:annotation>
<xs:documentation xml:lang="en">
Version of SSM format, 1.0 for this release.
Version of SSM format, 1.0 or 2.0 for this release.
</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:normalizedString">
<xs:pattern value="1[.][0-9]+(-.*)?"/>
<xs:pattern value="1[.]0"/>
<xs:pattern value="2[.]0"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
Expand Down
304 changes: 283 additions & 21 deletions schema/ssp/SystemStructureParameterValues.xsd

Large diffs are not rendered by default.

14 changes: 9 additions & 5 deletions schema/ssp/SystemStructureSignalDictionary.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
<xs:annotation>
<xs:documentation xml:lang="en">
This is the normative XML Schema 1.0 schema for the MAP SSP
SystemStructureSignalDictionary 1.0 format.
SystemStructureSignalDictionary 2.0 format.

Version: 1.0
Version: 2.0

Copyright 2016 -- 2019 Modelica Association Project "SSP"
Copyright 2016 -- 2024 Modelica Association Project "SSP"

Redistribution and use in source and binary forms, with or
without modification, are permitted provided that the
Expand Down Expand Up @@ -50,17 +50,20 @@
<xs:element name="DictionaryEntry" minOccurs="0" maxOccurs="unbounded" type="ssb:TDictionaryEntry"/>
<xs:element name="Enumerations" minOccurs="0" type="ssc:TEnumerations"/>
<xs:element name="Units" minOccurs="0" type="ssc:TUnits"/>
<xs:group ref="ssc:GMetaData"/>
<xs:group ref="ssc:GSignature"/>
<xs:element name="Annotations" minOccurs="0" type="ssc:TAnnotations"/>
</xs:sequence>
<xs:attribute name="version" use="required">
<xs:annotation>
<xs:documentation xml:lang="en">
Version of SSB format, 1.0 for this release.
Version of SSB format, 1.0 or 2.0 for this release.
</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:normalizedString">
<xs:pattern value="1[.][0-9]+(-.*)?"/>
<xs:pattern value="1[.]0"/>
<xs:pattern value="2[.]0"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
Expand All @@ -72,6 +75,7 @@
<xs:complexType name="TDictionaryEntry">
<xs:sequence>
<xs:group ref="ssc:GTypeChoice"/>
<xs:group ref="ssc:GDimensions"/>
<xs:element name="Annotations" minOccurs="0" type="ssc:TAnnotations"/>
</xs:sequence>
<xs:attributeGroup ref="ssc:ABaseElement"/>
Expand Down
2 changes: 1 addition & 1 deletion src/OMSimulatorLib/Connector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ std::string oms::Connector::getTypeString(const pugi::xml_node& node, const std:
{
return node.attribute("type").as_string();
}
else if (sspVersion == "1.0")
else if (sspVersion == "1.0" || sspVersion == "2.0")
{
for(pugi::xml_node_iterator it = node.begin(); it != node.end(); ++it)
{
Expand Down
8 changes: 4 additions & 4 deletions src/OMSimulatorLib/Model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ oms_status_enu_t oms::Model::importSnapshot(const char* snapshot_, char** newCre
if (new_cref != getCref() && Scope::GetInstance().getModel(new_cref))
return logError("Renaming the model \"" + std::string(getCref()) + "\" to \"" + std::string(new_cref) + "\" failed because another model with the same name already exists in the scope.");

if (ssdVersion != "Draft20180219" && ssdVersion != "1.0")
if (ssdVersion != "Draft20180219" && ssdVersion != "1.0" && ssdVersion != "2.0")
logWarning("Unknown SSD version: " + ssdVersion);

System* old_root_system = system;
Expand Down Expand Up @@ -892,7 +892,7 @@ oms_status_enu_t oms::Model::importFromSnapshot(const Snapshot& snapshot)
oms_system_enu_t systemType = getSystemType(*it, sspVersion);

if (oms_status_ok != addSystem(systemCref, systemType))
return oms_status_error;
return logError("Unable to add System \"" + std::string(systemCref.c_str()) + "\"");

System* system = getSystem(systemCref);
if (!system)
Expand Down Expand Up @@ -939,7 +939,7 @@ oms_status_enu_t oms::Model::importFromSnapshot(const Snapshot& snapshot)
{
name = itAnnotations->name();
// check for oms_default_experiment from version 1.0
if (std::string(name) == oms::ssp::Version1_0::simulation_information && sspVersion == "1.0")
if (std::string(name) == oms::ssp::Version1_0::simulation_information && (sspVersion == "1.0" || sspVersion == "2.0"))
{
resultFilename = itAnnotations->attribute("resultFile").as_string();
loggingInterval = itAnnotations->attribute("loggingInterval").as_double();
Expand Down Expand Up @@ -971,7 +971,7 @@ oms_system_enu_t oms::Model::getSystemType(const pugi::xml_node& node, const std
}

/* from Version "1.0" simulationInformation is handled in vendor annotation */
if (name == oms::ssp::Draft20180219::ssd::annotations && sspVersion == "1.0")
if (name == oms::ssp::Draft20180219::ssd::annotations && (sspVersion == "1.0" || sspVersion == "2.0"))
{
pugi::xml_node annotation_node;
annotation_node = itElements->child(oms::ssp::Version1_0::ssc::annotation);
Expand Down
6 changes: 3 additions & 3 deletions src/OMSimulatorLib/Scope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ oms_status_enu_t oms::Scope::importModel(const std::string& filename, char** _cr
if (!model)
return oms_status_error;

if (ssdVersion != "Draft20180219" && ssdVersion != "1.0")
if (ssdVersion != "Draft20180219" && ssdVersion != "1.0" && ssdVersion != "2.0")
logWarning("Unknown SSD version: " + ssdVersion);

// extract the ssp file
Expand Down Expand Up @@ -436,8 +436,8 @@ oms_status_enu_t oms::Scope::loadSnapshot(const oms::ComRef& cref, const char* s
return logError("failed to load snapshot, because it would change the model's name but it already exists in the scope");

std::string ssdVersion = node.attribute("version").as_string();
if (ssdVersion != "Draft20180219" && ssdVersion != "1.0")
return logError("Unknown SSD version \"" + ssdVersion + "\"; supported version are \"1.0\" and \"Draft20180219\".");
if (ssdVersion != "Draft20180219" && ssdVersion != "1.0" && ssdVersion != "2.0")
return logError("Unknown SSD version \"" + ssdVersion + "\"; supported version are \"1.0\" and \"2.0\" and\"Draft20180219\".");

oms_status_enu_t status = getModel(cref)->loadSnapshot(node);

Expand Down
2 changes: 1 addition & 1 deletion src/OMSimulatorLib/Snapshot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ pugi::xml_node oms::Snapshot::getTemplateResourceNodeSSD(const filesystem::path&
ssdNode.append_attribute("xmlns:ssb") = "http://ssp-standard.org/SSP1/SystemStructureSignalDictionary";
ssdNode.append_attribute("xmlns:oms") = "https://raw.githubusercontent.com/OpenModelica/OMSimulator/master/schema/oms.xsd";
ssdNode.append_attribute("name") = cref.c_str();
ssdNode.append_attribute("version") = "1.0";
ssdNode.append_attribute("version") = "2.0";

return ssdNode;
}
Expand Down
11 changes: 8 additions & 3 deletions src/OMSimulatorLib/System.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -862,9 +862,14 @@ oms_status_enu_t oms::System::importFromSnapshot(const pugi::xml_node& node, con
// allow component type to be empty, as type is optional according to SSP-1.0 and default type is application/x-fmu-sharedlibrary
if ("application/x-fmu-sharedlibrary" == type || type.empty())
{
if (getType() == oms_system_wc)
std::string source = itElements->attribute("source").as_string();
filesystem::path modelDescriptionPath = filesystem::path(getModel().getTempDirectory()) / filesystem::path(source);
std::string fmiVersion = getFmiVersion(modelDescriptionPath.generic_string());
if (getType() == oms_system_wc && fmiVersion == "2.0")
component = ComponentFMUCS::NewComponent(*itElements, this, sspVersion, snapshot, variantName);
else if (getType() == oms_system_sc)
else if (getType() == oms_system_wc && fmiVersion == "3.0")
component = ComponentFMU3CS::NewComponent(*itElements, this, sspVersion, snapshot, variantName);
else if (getType() == oms_system_sc && fmiVersion == "2.0")
component = ComponentFMUME::NewComponent(*itElements, this, sspVersion, snapshot, variantName);
else
return logError("wrong xml schema detected: " + name);
Expand Down Expand Up @@ -914,7 +919,7 @@ oms_status_enu_t oms::System::importFromSnapshot(const pugi::xml_node& node, con
name = itAnnotations->name();

// check for oms:simulationInformation from version 1.0
if (std::string(name) == oms::ssp::Version1_0::simulation_information && sspVersion == "1.0")
if (std::string(name) == oms::ssp::Version1_0::simulation_information && (sspVersion == "1.0" || sspVersion == "2.0"))
{
if (oms_status_ok != importFromSSD_SimulationInformation(*itAnnotations, sspVersion))
return logError("Failed to import " + std::string(oms::ssp::Version1_0::simulation_information));
Expand Down
4 changes: 2 additions & 2 deletions src/OMSimulatorLib/SystemWC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ oms_status_enu_t oms::SystemWC::importFromSSD_SimulationInformation(const pugi::
pugi::xml_node fixedStepMaster = node.child(oms::ssp::Version1_0::FixedStepMaster);
if (fixedStepMaster)
{
if (sspVersion == "1.0")
if (sspVersion == "1.0" || sspVersion == "2.0")
{
solverName = fixedStepMaster.attribute("description").as_string();
FixedStepMaster = oms::ssp::Version1_0::FixedStepMaster;
Expand All @@ -150,7 +150,7 @@ oms_status_enu_t oms::SystemWC::importFromSSD_SimulationInformation(const pugi::
pugi::xml_node variableStepMaster = node.child(oms::ssp::Version1_0::VariableStepMaster);
if (variableStepMaster)
{
if (sspVersion == "1.0")
if (sspVersion == "1.0" || sspVersion == "2.0")
{
solverName = variableStepMaster.attribute("description").as_string();
VariableStepMaster = oms::ssp::Version1_0::VariableStepMaster;
Expand Down