Xcos ecore: fix implicit, states and solvers 05/18805/1
Clément DAVID [Tue, 20 Dec 2016 09:37:47 +0000 (10:37 +0100)]
Change-Id: I71f1a59fe5ec4e2fbd94364e29d01d2109e7d082

scilab/modules/scicos/src/cpp/XMIResource_load.cpp
scilab/modules/scicos/src/cpp/XMIResource_save.cpp

index 042490d..acd3f92 100644 (file)
@@ -277,6 +277,19 @@ int to_int(const xmlChar* xmlStr)
 }
 
 /*
+ * Convert an XML UTF-8 string to a model boolean
+ */
+bool to_boolean(const xmlChar* xmlStr)
+{
+    if (xmlStr == nullptr)
+    {
+        return 0;
+    }
+
+    return std::strcmp((const char*) xmlStr, "true") == 0;
+}
+
+/*
  * Convert an XML UTF-8 string to a model double
  */
 double to_double(const xmlChar* xmlStr)
@@ -823,7 +836,7 @@ int XMIResource::loadPort(xmlTextReaderPtr reader, const model::BaseObject& o)
                 break;
             }
             case e_implicit:
-                controller.setObjectProperty(o.id(), o.kind(), IMPLICIT, to_int(xmlTextReaderConstValue(reader)));
+                controller.setObjectProperty(o.id(), o.kind(), IMPLICIT, to_boolean(xmlTextReaderConstValue(reader)));
                 break;
             case e_connectedSignal:
                 // will be resolved later
@@ -1310,11 +1323,11 @@ int XMIResource::processText(xmlTextReaderPtr reader)
             break;
         case e_state:
             // state is a Block property
-            ret = loadDoubleArray(reader, RPAR, processed.back());
+            ret = loadDoubleArray(reader, STATE, processed.back());
             break;
         case e_dstate:
             // dstate is a Block property
-            ret = loadDoubleArray(reader, RPAR, processed.back());
+            ret = loadDoubleArray(reader, DSTATE, processed.back());
             break;
         case e_expression:
             // expression is a Block property
index c7ca3db..ebd1058 100644 (file)
@@ -85,6 +85,18 @@ static std::string to_string(int v)
     return std::to_string(v);
 }
 
+static std::string to_string(bool v)
+{
+    if (v)
+    {
+        return "true";
+    }
+    else
+    {
+        return "false";
+    }
+}
+
 static std::string to_string(double v)
 {
     if (std::trunc(v) == v)
@@ -481,7 +493,7 @@ int XMIResource::writeSimulationConfig(xmlTextWriterPtr writer, ScicosID id)
     {
         return -1;
     }
-    status = xmlTextWriterWriteAttribute(writer, BAD_CAST("absoluteTime"), BAD_CAST(to_string(doubleArrayValue[i]).c_str()));
+    status = xmlTextWriterWriteAttribute(writer, BAD_CAST("absoluteTolerance"), BAD_CAST(to_string(doubleArrayValue[i]).c_str()));
     if (status == -1)
     {
         return status;
@@ -503,7 +515,7 @@ int XMIResource::writeSimulationConfig(xmlTextWriterPtr writer, ScicosID id)
     {
         return -1;
     }
-    status = xmlTextWriterWriteAttribute(writer, BAD_CAST("absoluteTolerance"), BAD_CAST(to_string(doubleArrayValue[i]).c_str()));
+    status = xmlTextWriterWriteAttribute(writer, BAD_CAST("timeTolerance"), BAD_CAST(to_string(doubleArrayValue[i]).c_str()));
     if (status == -1)
     {
         return status;
@@ -923,6 +935,14 @@ int XMIResource::writePort(xmlTextWriterPtr writer, enum object_properties_t con
         return status;
     }
 
+    bool implicit;
+    controller.getObjectProperty(id, PORT, IMPLICIT, implicit);
+    status = xmlTextWriterWriteAttribute(writer, BAD_CAST("implicit"), BAD_CAST(to_string(implicit).c_str()));
+    if (status == -1)
+    {
+        return status;
+    }
+
     controller.getObjectProperty(id, PORT, CONNECTED_SIGNALS, idValue);
     if (idValue != 0)
     {