diff --git a/src/main/java/ui/GTMLModeling.java b/src/main/java/ui/GTMLModeling.java index f3d8a5b4412a30b2f31ef81b7d28e5886d29ff87..0aa80a490b6a3dbd90ab147f820e01f73609e51b 100755 --- a/src/main/java/ui/GTMLModeling.java +++ b/src/main/java/ui/GTMLModeling.java @@ -970,9 +970,7 @@ public class GTMLModeling { tt2 = tmlm.getTMLTaskByName(makeName(port2, port2.getFather().getValue())); channel.setTasks(tt1, tt2); - if (port1.isLossy()) { - channel.setLossy(true, port1.getLossPercentage(), port1.getMaxNbOfLoss()); - } + // Complex channels are used only for transformation towards the simulator TMLPort tmlport1, tmlport2; @@ -985,6 +983,10 @@ public class GTMLModeling { tmlport2.setPostex(port2.isPostex()); tmlport2.setAssociatedEvent(port2.getAssociatedEvent()); channel.setPorts(tmlport1, tmlport2); + + if (port1.isLossy()) { + channel.setLossy(true, port1.getLossPercentage(), port1.getMaxNbOfLoss()); + } tmlm.addChannel(channel); listE.addCor(channel, tgc); //TraceManager.addDev("Adding channel " + channel.getName()); diff --git a/src/main/java/ui/avatarinteractivesimulation/JFrameAvatarInteractiveSimulation.java b/src/main/java/ui/avatarinteractivesimulation/JFrameAvatarInteractiveSimulation.java index 88098c59041daa1c5e35efa1e70b4bbc4f458d51..de6790d811cce7d9cf0986ed976b1f16ec312b80 100755 --- a/src/main/java/ui/avatarinteractivesimulation/JFrameAvatarInteractiveSimulation.java +++ b/src/main/java/ui/avatarinteractivesimulation/JFrameAvatarInteractiveSimulation.java @@ -1536,30 +1536,41 @@ public class JFrameAvatarInteractiveSimulation extends JFrame implements AvatarS } } // + for (String st1 : transTimes.keySet()) { for (String st2 : transTimes.keySet()) { if (st1 != st2 && nameLatencyMap.containsKey(st1 + "--" + st2)) { SimulationLatency sl = nameLatencyMap.get(st1 + "--" + st2); if (transTimes.get(st1) != null && transTimes.get(st2) != null) { + + List<String> tmptimes2 = new ArrayList<>(transTimes.get(st2)); + ArrayList<Integer> minTimes = new ArrayList<Integer>(); /*SimulationLatency sl = new SimulationLatency(); sl.setTransaction1(st1); sl.setTransaction2(st2);*/ + + for (String time1 : transTimes.get(st1)) { + String match = ""; //Find the first subsequent transaction int time = Integer.MAX_VALUE; - for (String time2 : transTimes.get(st2)) { + for (String time2 : tmptimes2) { + int diff = Integer.valueOf(time2) - Integer.valueOf(time1); if (diff < time && diff >= 0) { time = diff; + match = time2; } } + tmptimes2.remove(match); if (time != Integer.MAX_VALUE) { minTimes.add(time); } } // if (minTimes.size() > 0) { + int sum = 0; sl.setMinTime(Integer.toString(Collections.min(minTimes))); sl.setMaxTime(Integer.toString(Collections.max(minTimes)));