From 9e0edb452276327ba3d6f0bffdc293234a556f6b Mon Sep 17 00:00:00 2001
From: L <letitia.li@telecom-paristech.fr>
Date: Fri, 28 Oct 2016 13:07:23 +0200
Subject: [PATCH] Signal fix

---
 src/tmltranslator/toavatar/TML2Avatar.java | 19 ++++++++++++++++++-
 src/ui/GTURTLEModeling.java                |  8 ++++++--
 2 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/src/tmltranslator/toavatar/TML2Avatar.java b/src/tmltranslator/toavatar/TML2Avatar.java
index 3b2590394c..9712fc7584 100644
--- a/src/tmltranslator/toavatar/TML2Avatar.java
+++ b/src/tmltranslator/toavatar/TML2Avatar.java
@@ -1280,9 +1280,26 @@ public class TML2Avatar {
 	System.out.println("ACCESSKEYS " +accessKeys);
 
 	for (TMLTask task:tasks){
-
+	   
 	    AvatarBlock block = avspec.getBlockWithName(task.getName());
 	    //Add temp variable for unsendable signals
+
+	    //Add all signals
+	    for (TMLChannel chan: tmlmodel.getChannels(task)){
+		System.out.println("adding channel " + chan);
+		if (chan.hasOriginTask(task)){
+		AvatarSignal sig = new AvatarSignal(block.getName()+"__OUT__"+chan.getName(), AvatarSignal.OUT, chan.getReferenceObject());
+		block.addSignal(sig);
+		signals.add(sig);
+		signalMap.put(block.getName()+"__OUT__"+chan.getName(),sig);
+		}
+		else if (chan.hasDestinationTask(task)){
+		AvatarSignal sig = new AvatarSignal(block.getName()+"__IN__"+chan.getName(), AvatarSignal.IN, chan.getReferenceObject());
+		block.addSignal(sig);
+		signals.add(sig);
+		signalMap.put(block.getName()+"__IN__"+chan.getName(),sig);
+		}
+	    }
 	    AvatarAttribute tmp = new AvatarAttribute("tmp", AvatarType.INTEGER, block, null);
 	    block.addAttribute(tmp);
 
diff --git a/src/ui/GTURTLEModeling.java b/src/ui/GTURTLEModeling.java
index 49ff442d01..5723fdf7f4 100755
--- a/src/ui/GTURTLEModeling.java
+++ b/src/ui/GTURTLEModeling.java
@@ -7794,6 +7794,11 @@ public class GTURTLEModeling {
 	    }
 	    AvatarBDBlock bl = new AvatarBDBlock(xpos, ypos, xpos, xpos*2, ypos, ypos*2, false, father, abd);
 	    bl.addCryptoElements();
+	    for (avatartranslator.AvatarSignal sig:ab.getSignals()){
+		String name=sig.getName().split("__")[sig.getName().split("__").length-1];
+		sig.setName(name);
+		bl.addSignal(new ui.AvatarSignal(sig.getInOut(), name, new String[0], new String[0]));
+	    }
 	    tranSourceMap.clear();
 /*	    if (ab.getName().contains("__")){
 	        bl.setValue(ab.getName().split("__")[1]);
@@ -7896,8 +7901,7 @@ public class GTURTLEModeling {
 
 	
 	for (AvatarRelation ar: avspec.getRelations()){
-
-	    String bl1 = ar.block1.getName();
+	    String bl1 = ar.block1.getName();	
 	    String bl2 = ar.block2.getName();
 	    if (originDestMap.containsKey(bl1)){
 		originDestMap.get(bl1).add(bl2);
-- 
GitLab