From e92359209883e558ab14cfc78b788778170d98d3 Mon Sep 17 00:00:00 2001
From: Daniela Genius <genius@debussy.soc.lip6.fr>
Date: Tue, 10 Mar 2020 15:57:40 +0100
Subject: [PATCH] from Master : Simulator.cpp

---
 .../c++2/src_simulator/sim/Simulator.cpp      | 79 ++++++++++---------
 src/main/java/ui/ColorManager.java            |  1 +
 .../java/ui/avatarbd/AvatarBDInterface.java   |  3 +-
 .../ui/avatarbd/AvatarBDPortConnector.java    |  6 +-
 4 files changed, 49 insertions(+), 40 deletions(-)

diff --git a/simulators/c++2/src_simulator/sim/Simulator.cpp b/simulators/c++2/src_simulator/sim/Simulator.cpp
index c2851d6ded..138974efc0 100644
--- a/simulators/c++2/src_simulator/sim/Simulator.cpp
+++ b/simulators/c++2/src_simulator/sim/Simulator.cpp
@@ -1176,8 +1176,9 @@ int countLineNumber(std::string& filename){
     std::string line;
     std::ifstream myfile(filename.c_str());
 
-    while (std::getline(myfile, line))
-        ++number_of_lines;
+    while (std::getline(myfile, line)){
+        if (line != "") ++number_of_lines;
+    }
     std::cout << "Number of lines in text file: " << number_of_lines << std::endl;
     return number_of_lines;
 }
@@ -1213,44 +1214,48 @@ ServerIF* Simulator::run(int iLen, char ** iArgs){
     std::vector<std::string> parameters = readFromFile(aArgString);
     std::string aNewCmd;
     int previousTransTime = 0;
-    if(lineNumber != 0){
-        for (int i = 0; i < lineNumber; i++){
-            std::string channelName =_simComp->getChannelList(parameters[i*4+1]);
-            TMLChannel* t = _simComp->getChannelByName(channelName);
-            if(t != 0){
-                aNewCmd += "1 5 " + parameters[i*4] + "; 6 " + to_string(t->getID()) + " 1 " + parameters[i*4+3] + "; ";
+    if((parameters.size() != (lineNumber*4))){
+        std::cout << "Error: Wrong format, each line should contains 4 parameters.\n";
+    } else {
+        if(lineNumber != 0){
+            for (int i = 0; i < lineNumber; i++){
+                std::string channelName =_simComp->getChannelList(parameters[i*4+1]);
+                TMLChannel* t = _simComp->getChannelByName(channelName);
+                if(t != 0){
+                    aNewCmd += "1 5 " + parameters[i*4] + "; 6 " + to_string(t->getID()) + " 1 " + parameters[i*4+3] + "; ";
+                }
+                else {
+                    std::cout << "Error: Wrong channel name\n";
+                    previousTransTime++;
+                }
             }
-            else {
-                std::cout << "Error: Wrong channel name\n";
-                previousTransTime++;
+            if(previousTransTime != lineNumber){
+                aNewCmd += "1 0; 7 1 test.html;  1 7 100 100 test";
+            } else {
+                aNewCmd = "1 0; 7 1 test.html;  1 7 100 100 test";
             }
-        }
-        if(previousTransTime != lineNumber){
-            aNewCmd += "1 0; 7 1 test.html;  1 7 100 100 test";
-        } else {
-            aNewCmd = "1 0; 7 1 test.html;  1 7 100 100 test";
-        }
 
-        std::cout<<"DecodeCommand "<< aNewCmd << std::endl;
-        std::ofstream aXmlOutFile1;
-        std::string aXmlFileName1 = getArgs("-oxml", "reply.xml", iLen, iArgs);
-        if (aXmlFileName1.empty()) aXmlOutFile1.open("/dev/null"); else aXmlOutFile1.open(aXmlFileName1.c_str());
-        if (aXmlOutFile1.is_open()){
-        std::string aNextCmd1;
-        std::istringstream iss1(aNewCmd+";");
-        getline(iss1, aNextCmd1, ';');
-        while (!(iss1.eof() || aNextCmd1.empty())){
-          std::cout << "next cmd to execute: \"" << aNextCmd1 << "\"\n";
-          decodeCommand(aNextCmd1, aXmlOutFile1);
-          getline(iss1, aNextCmd1, ';');
-        }
-        aXmlOutFile1.close();
-      } else{
-            std::cout << "XML output file could not be opened, aborting.\n";
-        }
-      } else {
-         std::cout << "Signal file contains nothing, aborting.\n";
-      }
+            std::cout<<"DecodeCommand "<< aNewCmd << std::endl;
+            std::ofstream aXmlOutFile1;
+            std::string aXmlFileName1 = getArgs("-oxml", "reply.xml", iLen, iArgs);
+            if (aXmlFileName1.empty()) aXmlOutFile1.open("/dev/null"); else aXmlOutFile1.open(aXmlFileName1.c_str());
+            if (aXmlOutFile1.is_open()){
+            std::string aNextCmd1;
+            std::istringstream iss1(aNewCmd+";");
+            getline(iss1, aNextCmd1, ';');
+            while (!(iss1.eof() || aNextCmd1.empty())){
+              std::cout << "next cmd to execute: \"" << aNextCmd1 << "\"\n";
+              decodeCommand(aNextCmd1, aXmlOutFile1);
+              getline(iss1, aNextCmd1, ';');
+            }
+            aXmlOutFile1.close();
+          } else{
+                std::cout << "XML output file could not be opened, aborting.\n";
+            }
+          } else {
+             std::cout << "Signal file contains nothing, aborting.\n";
+          }
+    }
   }
   aArgString =getArgs("-help", "help", iLen, iArgs);
   if (aArgString.empty()){
diff --git a/src/main/java/ui/ColorManager.java b/src/main/java/ui/ColorManager.java
index 64498851ed..173f2ec474 100644
--- a/src/main/java/ui/ColorManager.java
+++ b/src/main/java/ui/ColorManager.java
@@ -283,6 +283,7 @@ public class ColorManager {
     public static void noColor() {
         UML_NOTE_BG = Color.white;
         AVATAR_BLOCK = Color.white;
+	AVATAR_INTERFACE = Color.white;
         AVATAR_DATATYPE = Color.white;
         AVATAR_STATE = Color.white;
         AVATAR_REQUIREMENT_TOP = Color.white;
diff --git a/src/main/java/ui/avatarbd/AvatarBDInterface.java b/src/main/java/ui/avatarbd/AvatarBDInterface.java
index c1fdd35199..673a06a0c9 100644
--- a/src/main/java/ui/avatarbd/AvatarBDInterface.java
+++ b/src/main/java/ui/avatarbd/AvatarBDInterface.java
@@ -80,7 +80,8 @@ public class AvatarBDInterface extends TGCScalableWithInternalComponent implemen
 //    private static String stereotypeCrypto = "cryptoblock";
 
     protected static List<String> BLOCK_TYPE_STR = new ArrayList<String>(Arrays.asList("block", "cryptoblock"));
-    protected static List<Color> BLOCK_TYPE_COLOR = new ArrayList<Color>(Arrays.asList(ColorManager.AVATAR_BLOCK, ColorManager.AVATAR_BLOCK));
+    //protected static List<Color> BLOCK_TYPE_COLOR = new ArrayList<Color>(Arrays.asList(ColorManager.AVATAR_BLOCK, ColorManager.AVATAR_BLOCK));
+    protected static List<Color> BLOCK_TYPE_COLOR = new ArrayList<Color>(Arrays.asList(ColorManager.AVATAR_INTERFACE, ColorManager.AVATAR_INTERFACE));
     private int typeStereotype = 0; // <<block>> by default
 
     private int maxFontSize = 12;
diff --git a/src/main/java/ui/avatarbd/AvatarBDPortConnector.java b/src/main/java/ui/avatarbd/AvatarBDPortConnector.java
index 70886eb78d..34c9cfddd9 100644
--- a/src/main/java/ui/avatarbd/AvatarBDPortConnector.java
+++ b/src/main/java/ui/avatarbd/AvatarBDPortConnector.java
@@ -128,7 +128,7 @@ public class AvatarBDPortConnector extends TGConnectorWithCommentConnectionPoint
         //g.drawLine(x1, y1, x2, y2);
         Color col = g.getColor();
         int cz = (int) (tdp.getZoom() * c);
-        if (isAsynchronous()) {
+        if (isAsynchronous()&&!(isAMS())) {
             g.setColor(Color.WHITE);
         }
 	 if (isAMS()) {
@@ -490,7 +490,8 @@ public class AvatarBDPortConnector extends TGConnectorWithCommentConnectionPoint
                                 val5 = elt.getAttribute("lossy");
 				val6 = elt.getAttribute("ams");
 
-                                if ((val != null) && (!(val.equals("null")))) {
+				//     if ((val != null) && (!(val.equals("null")))) {
+				if ((val != null) && (!(val6.equals("null"))) && (!(val.equals("null")))){			
                                     asynchronous = val.trim().toLowerCase().compareTo("true") == 0;
 
                                 }
@@ -531,6 +532,7 @@ public class AvatarBDPortConnector extends TGConnectorWithCommentConnectionPoint
                                 }
 				if ((val6 != null) && (!(val6.equals("null")))) {
                                     isAMS = val6.trim().toLowerCase().compareTo("true") == 0;
+				    System.out.println("@@@ AMS reconnu @@@");
 
                                 } else {
                                     isAMS = false;
-- 
GitLab