diff --git a/src/main/java/tmltranslator/TMLActivityElementWithIntervalAction.java b/src/main/java/tmltranslator/TMLActivityElementWithIntervalAction.java index b948d772e96ae823a0405d6cdd9be16d3d046fb8..b2347ee0a4b3e1a4de848d6201669a0beb612b77 100755 --- a/src/main/java/tmltranslator/TMLActivityElementWithIntervalAction.java +++ b/src/main/java/tmltranslator/TMLActivityElementWithIntervalAction.java @@ -52,6 +52,7 @@ import java.util.Objects; */ public class TMLActivityElementWithIntervalAction extends TMLActivityElement { protected String minDelay, maxDelay; + protected boolean isActiveDelay = false; public TMLActivityElementWithIntervalAction(String _name, Object _referenceObject) { super(_name, _referenceObject); @@ -74,16 +75,20 @@ public class TMLActivityElementWithIntervalAction extends TMLActivityElement { } public String customExtraToXML() { - return " min=\"" + minDelay + "\" max=\"" + maxDelay + "\" "; + return " min=\"" + minDelay + "\" max=\"" + maxDelay + "\" " + "isActiveDelay=\"" + isActiveDelay + "\" "; } + public void setActiveDelay(boolean _b){ + isActiveDelay = _b;} + public boolean getActiveDelay(){return isActiveDelay;} public boolean equalSpec(Object o) { if (!(o instanceof TMLActivityElementWithIntervalAction)) return false; if (!super.equalSpec(o)) return false; TMLActivityElementWithIntervalAction tmlAEIAction = (TMLActivityElementWithIntervalAction) o; return Objects.equals(minDelay, tmlAEIAction.getMinDelay()) && - Objects.equals(maxDelay, tmlAEIAction.getMaxDelay()); + Objects.equals(maxDelay, tmlAEIAction.getMaxDelay()) && + Objects.equals(isActiveDelay, tmlAEIAction.getActiveDelay()); } diff --git a/src/main/java/tmltranslator/TMLDelay.java b/src/main/java/tmltranslator/TMLDelay.java index 72750abf6cc9a60cb2a6ea9fb0aec72186e8587e..5e1e5225d5e2a854dbd4759dfb7c3c7a4ce9c6f4 100755 --- a/src/main/java/tmltranslator/TMLDelay.java +++ b/src/main/java/tmltranslator/TMLDelay.java @@ -53,7 +53,6 @@ import java.util.Objects; public class TMLDelay extends TMLActivityElementWithIntervalAction { private String timeUnit = "ns"; // Shall be either "ns" or "us" or "ms" or "s" - private boolean isActiveDelay = false; public TMLDelay(String _name, Object _referenceObject) { super(_name, _referenceObject); } @@ -93,10 +92,6 @@ public class TMLDelay extends TMLActivityElementWithIntervalAction { return ""; } - public void setActiveDelay(boolean _b){ - isActiveDelay = _b;} - public boolean getActiveDelay(){return isActiveDelay;} - public boolean equalSpec(Object o) { if (! (o instanceof TMLDelay)) return false; if (!super.equalSpec(o)) return false; diff --git a/src/main/java/tmltranslator/TMLTextSpecification.java b/src/main/java/tmltranslator/TMLTextSpecification.java index 238388fe45c81acb8d33d6c9e046a1693b97cfdf..380cc154c1f69e64a394d7bd16f86c2ce17fdcaa 100755 --- a/src/main/java/tmltranslator/TMLTextSpecification.java +++ b/src/main/java/tmltranslator/TMLTextSpecification.java @@ -426,9 +426,9 @@ public class TMLTextSpecification<E> { tmp1 = ((TMLDelay) elt).getMinDelay(); tmp2 = ((TMLDelay) elt).getMaxDelay(); if (tmp1.compareTo(tmp2) == 0) { - code = "DELAY" + SP + modifyString(((TMLDelay) elt).getMinDelay()) + SP + modifyString(((TMLDelay) elt).getUnit()) + CR; + code = "DELAY" + SP + modifyString(((TMLDelay) elt).getMinDelay()) + SP + modifyString(((TMLDelay) elt).getUnit()) + SP + "isActiveDelay" + SP + ((TMLDelay) elt).getActiveDelay() + CR; } else { - code = "DELAY" + SP + modifyString(((TMLDelay) elt).getMinDelay()) + SP + modifyString(((TMLDelay) elt).getMaxDelay()) + SP + modifyString(((TMLDelay) elt).getUnit()) + CR; + code = "DELAY" + SP + modifyString(((TMLDelay) elt).getMinDelay()) + SP + modifyString(((TMLDelay) elt).getMaxDelay()) + SP + modifyString(((TMLDelay) elt).getUnit()) + SP + "isActiveDelay" + SP + ((TMLDelay) elt).getActiveDelay() + CR; } return code + makeBehavior(task, elt.getNextElement(0)); @@ -2615,13 +2615,13 @@ public class TMLTextSpecification<E> { inTaskDec = false; // inTaskBehavior = true; - if ((_split.length < 3) || (_split.length > 5)) { - error = "A DELAY operation must be declared with 2 or 3 parameters, and not " + (_split.length - 1); + if ((_split.length < 4) || (_split.length > 6)) { + error = "A DELAY operation must be declared with 4 or 5 parameters, and not " + (_split.length - 1); addError(0, _lineNb, 0, error); return -1; } - if (_split.length == 3) { + if (_split.length == 5) { if (!checkParameter("DELAY", _split, 2, 0, _lineNb)) { error = "A DELAY operation must be specified with a valid time unit (ns, us, ms, s))"; addError(0, _lineNb, 0, error); @@ -2629,7 +2629,7 @@ public class TMLTextSpecification<E> { } } - if (_split.length == 4) { + if (_split.length == 6) { if (!checkParameter("DELAY", _split, 3, 0, _lineNb)) { error = "A DELAY operation must be specified with a valid time unit (ns, us, ms, s))"; addError(0, _lineNb, 0, error); @@ -2639,12 +2639,14 @@ public class TMLTextSpecification<E> { TMLDelay delay = new TMLDelay("delay", null); delay.setMinDelay(_split[1]); - if (_split.length == 3) { + if (_split.length == 5) { delay.setMaxDelay(_split[1]); delay.setUnit(_split[2]); + delay.setActiveDelay(Boolean.valueOf(_split[4])); // DELAY min unit isActivedelay boolean } else { delay.setMaxDelay(_split[2]); delay.setUnit(_split[3]); + delay.setActiveDelay(Boolean.valueOf(_split[5])); // DELAY min max unit isActivedelay boolean } diff --git a/src/main/java/ui/ActivityDiagram2TMLTranslator.java b/src/main/java/ui/ActivityDiagram2TMLTranslator.java index af414da23cde0d89abfd5b1ea71ec22ba648f006..7ba7e9446ccb995fc29acb83d153e94a91596d29 100644 --- a/src/main/java/ui/ActivityDiagram2TMLTranslator.java +++ b/src/main/java/ui/ActivityDiagram2TMLTranslator.java @@ -301,6 +301,7 @@ public class ActivityDiagram2TMLTranslator { tmldelay.setMinDelay(modifyString(((TMLADDelayInterval)tgc).getMinDelayValue())); tmldelay.setMaxDelay(modifyString(((TMLADDelayInterval)tgc).getMaxDelayValue())); tmldelay.setUnit(((TMLADDelayInterval)tgc).getUnit()); + tmldelay.setActiveDelay(((TMLADDelayInterval)tgc).getActiveDelayEnableValue()); activity.addElement(tmldelay); ((BasicErrorHighlight)tgc).setStateAction(ErrorHighlight.OK); corrTgElement.addCor(tmldelay, tgc); diff --git a/src/main/java/ui/tmlad/TMLADDelayInterval.java b/src/main/java/ui/tmlad/TMLADDelayInterval.java index d7234a843973ff198f44154178de647737fcf1da..8581ff199153b7053fcf12b4d345d89e1069fbd6 100755 --- a/src/main/java/ui/tmlad/TMLADDelayInterval.java +++ b/src/main/java/ui/tmlad/TMLADDelayInterval.java @@ -156,7 +156,9 @@ public class TMLADDelayInterval extends TADComponentWithSubcomponents /* Issue # public void setMaxValue(String val) { ((TGCTimeDelay)(tgcomponent[0])).setMaxDelay(val); } - + + public boolean getActiveDelayEnableValue(){return ((TGCTimeDelay)tgcomponent[0]).getActiveDelay(); } + @Override public int getType() { return TGComponentManager.TMLAD_INTERVAL_DELAY; diff --git a/ttool/src/test/resources/tmltranslator/expected/expected_spec1.tml b/ttool/src/test/resources/tmltranslator/expected/expected_spec1.tml index 7cd34eab0bf33868df2a5e9fd1e585a2734018fe..1575d44d5261db95748809b38af07a8667130c47 100644 --- a/ttool/src/test/resources/tmltranslator/expected/expected_spec1.tml +++ b/ttool/src/test/resources/tmltranslator/expected/expected_spec1.tml @@ -1,6 +1,6 @@ // TML Application - FORMAT 0.1 -// Application: /home/pham/Documents/TToolDev/TTool/ttool/src/test/resources/ui/diagram2tml/input/CloneCompositeComponentTest.xml -// Generated: Fri Sep 27 17:17:01 CEST 2019 +// Application: /home/levan/Desktop/TTool/ttool/src/test/resources/ui/diagram2tml/input/CloneCompositeComponentTest.xml +// Generated: Fri Nov 15 15:15:40 CET 2019 // Channels CHANNEL Application__channel BRBW 4 8 OUT Application__PrimitiveComp1 IN Application__PrimitiveComp2 @@ -120,10 +120,10 @@ TASK Application__PrimitiveComp5 WRITE Application__channel3 1 EXECI 10 EXECI 10 20 - DELAY 10 ms + DELAY 10 ms isActiveDelay false EXECC 100 encryption1 ADV 100 100 0 0 EXECC 100 encryption1 ADV 100 100 0 0 - DELAY 10 20 ms + DELAY 10 20 ms isActiveDelay false RANDOM 0 attr1 0 10 FOR( ; ; ) FOR(loop__0 = 0; loop__0<10; loop__0 = loop__0 + 1) @@ -154,10 +154,10 @@ TASK Application__PrimitiveComp5_0 WRITE Application__channel3_0 1 EXECI 10 EXECI 10 20 - DELAY 10 ms + DELAY 10 ms isActiveDelay false EXECC 100 encryption1 ADV 100 100 0 0 EXECC 100 encryption1 ADV 100 100 0 0 - DELAY 10 20 ms + DELAY 10 20 ms isActiveDelay false RANDOM 0 attr1 0 10 FOR( ; ; ) FOR(loop__0 = 0; loop__0<10; loop__0 = loop__0 + 1) diff --git a/ttool/src/test/resources/tmltranslator/expected/expected_spec2.tml b/ttool/src/test/resources/tmltranslator/expected/expected_spec2.tml index fc9e7125802818869a6f286f1428b48763990d86..80a588d37f19c0c5158d2927f24991c8cfb332c4 100644 --- a/ttool/src/test/resources/tmltranslator/expected/expected_spec2.tml +++ b/ttool/src/test/resources/tmltranslator/expected/expected_spec2.tml @@ -1,6 +1,6 @@ // TML Application - FORMAT 0.1 -// Application: /home/pham/Documents/TToolDev/TTool/ttool/src/test/resources/ui/diagram2tml/input/CloneCompositeComponentTest.xml -// Generated: Fri Sep 27 17:18:23 CEST 2019 +// Application: /home/levan/Desktop/TTool/ttool/src/test/resources/ui/diagram2tml/input/CloneCompositeComponentTest.xml +// Generated: Fri Nov 15 15:19:32 CET 2019 // Channels CHANNEL Application__channel BRBW 4 8 OUT Application__PrimitiveComp1 IN Application__PrimitiveComp2 @@ -88,10 +88,10 @@ TASK Application__PrimitiveComp5 WRITE Application__channel3 1 EXECI 10 EXECI 10 20 - DELAY 10 ms + DELAY 10 ms isActiveDelay false EXECC 100 encryption1 ADV 100 100 0 0 EXECC 100 encryption1 ADV 100 100 0 0 - DELAY 10 20 ms + DELAY 10 20 ms isActiveDelay false RANDOM 0 attr1 0 10 FOR( ; ; ) FOR(loop__0 = 0; loop__0<10; loop__0 = loop__0 + 1) @@ -122,10 +122,10 @@ TASK Application__PrimitiveComp5_0 WRITE Application__channel3_0 1 EXECI 10 EXECI 10 20 - DELAY 10 ms + DELAY 10 ms isActiveDelay false EXECC 100 encryption1 ADV 100 100 0 0 EXECC 100 encryption1 ADV 100 100 0 0 - DELAY 10 20 ms + DELAY 10 20 ms isActiveDelay false RANDOM 0 attr1 0 10 FOR( ; ; ) FOR(loop__0 = 0; loop__0<10; loop__0 = loop__0 + 1) diff --git a/ttool/src/test/resources/tmltranslator/expected/expected_spec3.tml b/ttool/src/test/resources/tmltranslator/expected/expected_spec3.tml index 75ba41ef403bd0c373c8f6c52c017e33bc39186b..48d0654728316da4552c088e187182be5de42643 100644 --- a/ttool/src/test/resources/tmltranslator/expected/expected_spec3.tml +++ b/ttool/src/test/resources/tmltranslator/expected/expected_spec3.tml @@ -1,6 +1,6 @@ // TML Application - FORMAT 0.1 -// Application: /home/pham/Documents/TToolDev/TTool/ttool/src/test/resources/ui/diagram2tml/input/CloneCompositeComponentTest.xml -// Generated: Fri Sep 27 17:18:55 CEST 2019 +// Application: /home/levan/Desktop/TTool/ttool/src/test/resources/ui/diagram2tml/input/CloneCompositeComponentTest.xml +// Generated: Fri Nov 15 15:20:48 CET 2019 // Channels CHANNEL Application__channel BRBW 4 8 OUT Application__PrimitiveComp1 IN Application__PrimitiveComp2 @@ -71,10 +71,10 @@ TASK Application__PrimitiveComp5 WRITE Application__channel3 1 EXECI 10 EXECI 10 20 - DELAY 10 ms + DELAY 10 ms isActiveDelay false EXECC 100 encryption1 ADV 100 100 0 0 EXECC 100 encryption1 ADV 100 100 0 0 - DELAY 10 20 ms + DELAY 10 20 ms isActiveDelay false RANDOM 0 attr1 0 10 FOR( ; ; ) FOR(loop__0 = 0; loop__0<10; loop__0 = loop__0 + 1) @@ -105,10 +105,10 @@ TASK Application__PrimitiveComp5_0 WRITE Application__channel3_0 1 EXECI 10 EXECI 10 20 - DELAY 10 ms + DELAY 10 ms isActiveDelay false EXECC 100 encryption1 ADV 100 100 0 0 EXECC 100 encryption1 ADV 100 100 0 0 - DELAY 10 20 ms + DELAY 10 20 ms isActiveDelay false RANDOM 0 attr1 0 10 FOR( ; ; ) FOR(loop__0 = 0; loop__0<10; loop__0 = loop__0 + 1) diff --git a/ttool/src/test/resources/tmltranslator/expected/expected_spec4.tml b/ttool/src/test/resources/tmltranslator/expected/expected_spec4.tml index 3e8fcfdc8bd65dbbdf2bf0a5c988ed724e8fbb7e..0c0473efbefb44f02f5c6ed11a1d8c57785a1248 100644 --- a/ttool/src/test/resources/tmltranslator/expected/expected_spec4.tml +++ b/ttool/src/test/resources/tmltranslator/expected/expected_spec4.tml @@ -1,6 +1,6 @@ // TML Application - FORMAT 0.1 -// Application: /home/pham/Documents/TToolDev/TTool/ttool/src/test/resources/ui/diagram2tml/input/CloneCompositeComponentTest.xml -// Generated: Fri Sep 27 17:19:30 CEST 2019 +// Application: /home/levan/Desktop/TTool/ttool/src/test/resources/ui/diagram2tml/input/CloneCompositeComponentTest.xml +// Generated: Fri Nov 15 15:21:23 CET 2019 // Channels CHANNEL Application__channel BRBW 4 8 OUT Application__PrimitiveComp1 IN Application__PrimitiveComp2 @@ -71,10 +71,10 @@ TASK Application__PrimitiveComp5 WRITE Application__channel3 1 EXECI 10 EXECI 10 20 - DELAY 10 ms + DELAY 10 ms isActiveDelay false EXECC 100 encryption1 ADV 100 100 0 0 EXECC 100 encryption1 ADV 100 100 0 0 - DELAY 10 20 ms + DELAY 10 20 ms isActiveDelay false RANDOM 0 attr1 0 10 FOR( ; ; ) FOR(loop__0 = 0; loop__0<10; loop__0 = loop__0 + 1)