@@ -86,6 +86,7 @@ oms::Connector::~Connector()
8686oms::Connector* oms::Connector::NewConnector (const pugi::xml_node& node, const std::string& sspVersion)
8787{
8888 ComRef cref = ComRef (node.attribute (" name" ).as_string ());
89+
8990 std::string causalityString = node.attribute (" kind" ).as_string ();
9091 oms_causality_enu_t causality = oms_causality_undefined;
9192 if (causalityString == " input" )
@@ -98,14 +99,13 @@ oms::Connector* oms::Connector::NewConnector(const pugi::xml_node& node, const s
9899 causality = oms_causality_calculatedParameter;
99100 else
100101 {
101- logError (" Failed to import " + std::string (oms::ssp::Draft20180219::ssd::connector ) + " : causality" );
102+ logError (" Failed to import connector \" " + std::string (cref ) + " \" with causality \" " + causalityString + " \" " );
102103 return NULL ;
103104 }
104105
105106 // get the types of connectors
106107 std::string typeString = getTypeString (node, sspVersion);
107-
108- oms_signal_type_enu_t type = oms_signal_type_real;
108+ oms_signal_type_enu_t type;
109109 if (typeString == " Real" )
110110 type = oms_signal_type_real;
111111 else if (typeString == " Integer" )
@@ -114,70 +114,60 @@ oms::Connector* oms::Connector::NewConnector(const pugi::xml_node& node, const s
114114 type = oms_signal_type_boolean;
115115 else if (typeString == " Enumeration" )
116116 type = oms_signal_type_enum;
117- // TODO handle Binary Types for FMI-2.1 see specification
118- else if (typeString == " Binary" )
119- {
120- logError (" Failed to import " + std::string (oms::ssp::Draft20180219::ssd::connector) + " :Binary-type" );
121- return NULL ;
122- }
117+ // TODO handle "Binary" type for FMI-2.1 see specification
123118 else
124119 {
125- logError (" Failed to import " + std::string (oms::ssp::Draft20180219::ssd::connector ) + " : type" );
120+ logError (" Failed to import connector \" " + std::string (cref ) + " \" with type \" " + typeString + " \" " );
126121 return NULL ;
127122 }
128123
129124 Connector* connector = new Connector (causality, type, cref);
130125 if (!connector)
131- {
132- logError (" Failed to import " + std::string (oms::ssp::Draft20180219::ssd::connector));
133126 return NULL ;
134- }
135- else
127+
128+ // Load connector geometry
129+ pugi::xml_node connectorGeometryNode = node.child (oms::ssp::Draft20180219::ssd::connector_geometry);
130+ if (connectorGeometryNode)
136131 {
137- // Load connector geometry
138- pugi::xml_node connectorGeometryNode = node.child (oms::ssp::Draft20180219::ssd::connector_geometry);
139- if (connectorGeometryNode)
140- {
141- oms::ssd::ConnectorGeometry geometry (0.0 , 0.0 );
142- geometry.setPosition (connectorGeometryNode.attribute (" x" ).as_double (), connectorGeometryNode.attribute (" y" ).as_double ());
143- connector->setGeometry (&geometry);
144- }
132+ oms::ssd::ConnectorGeometry geometry (0.0 , 0.0 );
133+ geometry.setPosition (connectorGeometryNode.attribute (" x" ).as_double (), connectorGeometryNode.attribute (" y" ).as_double ());
134+ connector->setGeometry (&geometry);
145135 }
146136
147137 return connector;
148138}
149139
150140std::string oms::Connector::getTypeString (const pugi::xml_node &node, const std::string& sspVersion)
151141{
152- std::string typeString = " " ;
153142 if (sspVersion == " Draft20180219" )
154143 {
155- typeString = node.attribute (" type" ).as_string ();
144+ return node.attribute (" type" ).as_string ();
156145 }
157146 else if (sspVersion == " 1.0" )
158147 {
159148 for (pugi::xml_node_iterator it = node.begin (); it != node.end (); ++it)
160149 {
161150 std::string name = it->name ();
162151 if (name == oms::ssp::Version1_0::ssc::real_type)
163- typeString = " Real" ;
152+ return " Real" ;
164153 else if (name == oms::ssp::Version1_0::ssc::integer_type)
165- typeString = " Integer" ;
154+ return " Integer" ;
166155 else if (name == oms::ssp::Version1_0::ssc::boolean_type)
167- typeString = " Boolean" ;
156+ return " Boolean" ;
168157 else if (name == oms::ssp::Version1_0::ssc::string_type)
169- typeString = " String" ;
158+ return " String" ;
170159 else if (name == oms::ssp::Version1_0::ssc::enumeration_type)
171- typeString = " Enumeration" ;
160+ return " Enumeration" ;
172161 else if (name == oms::ssp::Version1_0::ssc::binary_type)
173- typeString = " Binary" ;
174- }
175- if (typeString == " " )
176- {
177- logError (" Failed to import " + std::string (oms::ssp::Draft20180219::ssd::connector) + " :type Version-1.0" );
162+ return " Binary" ;
178163 }
164+
165+ logError (" Failed to import " + std::string (oms::ssp::Draft20180219::ssd::connector) + " :type Version-1.0" );
166+ return " " ;
179167 }
180- return typeString;
168+
169+ logError (" Unknown SSP version" );
170+ return " " ;
181171}
182172
183173oms_status_enu_t oms::Connector::exportToSSD (pugi::xml_node &root) const
0 commit comments