From 3559ad4cca742536d7cf8bbb7bc2f5bd9eada666 Mon Sep 17 00:00:00 2001 From: Ludovic Apvrille <ludovic.apvrille@telecom-paristech.fr> Date: Tue, 7 Jan 2014 17:05:08 +0000 Subject: [PATCH] --- Makefile | 2 +- executablecode/Makefile.src | 2 +- modeling/testavatar.xml | 54 ++--- src/avatartranslator/AvatarSpecification.java | 4 +- src/avatartranslator/AvatarSyntaxChecker.java | 5 +- .../AvatarSpecificationSimulation.java | 137 ++++++++++- src/myutil/BoolExpressionEvaluator.java | 7 +- src/myutil/Conversion.java | 1 + src/myutil/PeriodicBehavior.java | 56 +++++ src/myutil/PeriodicBehaviorThread.java | 83 +++++++ src/ui/IconManager.java | 6 +- src/ui/MainGUI.java | 38 +++- .../AvatarInteractiveSimulationActions.java | 10 +- .../AvatarInteractiveSimulationFIFOData.java | 79 +++++++ .../JFrameAvatarInteractiveSimulation.java | 212 +++++++++++++++++- .../navigation/Down16.gif | Bin 0 -> 185 bytes .../toolbarButtonGraphics/navigation/Up16.gif | Bin 0 -> 184 bytes 17 files changed, 634 insertions(+), 62 deletions(-) create mode 100755 src/myutil/PeriodicBehavior.java create mode 100755 src/myutil/PeriodicBehaviorThread.java create mode 100755 src/ui/avatarinteractivesimulation/AvatarInteractiveSimulationFIFOData.java create mode 100644 src/ui/images/toolbarButtonGraphics/navigation/Down16.gif create mode 100644 src/ui/images/toolbarButtonGraphics/navigation/Up16.gif diff --git a/Makefile b/Makefile index 5bc5ccd929..9f3eaede3b 100755 --- a/Makefile +++ b/Makefile @@ -100,7 +100,7 @@ basic: ttooljar: rm -f $(TTOOL_BIN)/$(TTOOL_BINARY) cp $(TTOOL_SRC)/ui/images/$(STD_LOGO) $(TTOOL_SRC)/ui/images/$(LOGO) - cd $(TTOOL_SRC); $(JAR) cmf $(TTOOL_JAR_TXT) $(TTOOL_BIN)/$(TTOOL_BINARY) Main.class vcd/*.class avatartranslator/*.class avatartranslator/toexecutable/*.class avatartranslator/directsimulation/*.class avatartranslator/touppaal/*.class avatartranslator/toproverif/*.class avatartranslator/totpn/* avatartranslator/*.class avatartranslator/toturtle/*.java automata/*.class compiler/tmlparser/*.class nc/*.class tepe/*.class tmltranslator/*.class tmltranslator/toautomata/*.class tmatrix/*.class tmltranslator/toturtle/*.class tmltranslator/touppaal/*.class tmltranslator/tosystemc/*.class tmltranslator/tomappingsystemc/*.class tmltranslator/tomappingsystemc2/*.class tpndescription/*.class ddtranslator/*.class launcher/*.class myutil/*.class sddescription/*.class sdtranslator/*.class translator/*.class translator/tojava/*.class translator/tosimujava/*.class translator/touppaal/*.class translator/totpn/*.class req/ebrdd/*.java ui/*.class ui/*/*.class ui/*/*/*.class proverifspec/*.class uppaaldesc/*.class ui/images/*.* ui/images/toolbarButtonGraphics/general/*.gif ui/images/toolbarButtonGraphics/media/*.gif $(TTOOL_BIN)/$(LAUNCHER_BINARY) RTLLauncher.class launcher/*.class fr/inria/oasis/vercors/cttool/model/*.class remotesimulation/*.class + cd $(TTOOL_SRC); $(JAR) cmf $(TTOOL_JAR_TXT) $(TTOOL_BIN)/$(TTOOL_BINARY) Main.class vcd/*.class avatartranslator/*.class avatartranslator/toexecutable/*.class avatartranslator/directsimulation/*.class avatartranslator/touppaal/*.class avatartranslator/toproverif/*.class avatartranslator/totpn/* avatartranslator/*.class avatartranslator/toturtle/*.java automata/*.class compiler/tmlparser/*.class nc/*.class tepe/*.class tmltranslator/*.class tmltranslator/toautomata/*.class tmatrix/*.class tmltranslator/toturtle/*.class tmltranslator/touppaal/*.class tmltranslator/tosystemc/*.class tmltranslator/tomappingsystemc/*.class tmltranslator/tomappingsystemc2/*.class tpndescription/*.class ddtranslator/*.class launcher/*.class myutil/*.class sddescription/*.class sdtranslator/*.class translator/*.class translator/tojava/*.class translator/tosimujava/*.class translator/touppaal/*.class translator/totpn/*.class req/ebrdd/*.java ui/*.class ui/*/*.class ui/*/*/*.class proverifspec/*.class uppaaldesc/*.class ui/images/*.* ui/images/toolbarButtonGraphics/general/*.gif ui/images/toolbarButtonGraphics/navigation/*.gif ui/images/toolbarButtonGraphics/media/*.gif $(TTOOL_BIN)/$(LAUNCHER_BINARY) RTLLauncher.class launcher/*.class fr/inria/oasis/vercors/cttool/model/*.class remotesimulation/*.class launcher: rm -f $(TTOOL_BIN)/$(LAUNCHER_BINARY) diff --git a/executablecode/Makefile.src b/executablecode/Makefile.src index e44f354179..bbb930b1ca 100755 --- a/executablecode/Makefile.src +++ b/executablecode/Makefile.src @@ -1 +1 @@ -SRCS = generated_src/main.c generated_src/Block1.c generated_src/Block0.c \ No newline at end of file +SRCS = generated_src/main.c generated_src/RemotelyControlledMicrowave.c generated_src/MicroWaveOven.c generated_src/WirelessInterface.c generated_src/RemoteControl.c generated_src/Magnetron.c generated_src/Door.c generated_src/ControlPanel.c generated_src/Bell.c generated_src/Controller.c generated_src/ObserverProp1.c \ No newline at end of file diff --git a/modeling/testavatar.xml b/modeling/testavatar.xml index c64279c481..d0e5db1fa9 100644 --- a/modeling/testavatar.xml +++ b/modeling/testavatar.xml @@ -12,17 +12,17 @@ <sizeparam width="0" height="0" minWidth="0" minHeight="0" maxWidth="1000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> <infoparam name="connector from Block1 to Block0" value="" /> <TGConnectingPoint num="0" id="1" /> -<P1 x="626" y="286" id="6" /> -<P2 x="495" y="278" id="32" /> +<P1 x="626" y="278" id="6" /> +<P2 x="494" y="277" id="32" /> <AutomaticDrawing data="true" /> <extraparam> <isd value="in testsig(int x, bool b)" /> <oso value="out testsig(int x, bool b)" /> -<FIFOType asynchronous="true" size="1" blocking="false" private="true" broadcast="false" lossy="true" /> +<FIFOType asynchronous="true" size="1" blocking="false" private="true" broadcast="false" lossy="false" /> </extraparam> </CONNECTOR> <COMPONENT type="5000" id="27" > -<cdparam x="626" y="186" /> +<cdparam x="626" y="178" /> <sizeparam width="250" height="200" minWidth="5" minHeight="2" maxWidth="1000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> <hidden value="false" /> <cdrectangleparam minX="10" maxX="1400" minY="10" maxY="900" /> @@ -54,13 +54,12 @@ <extraparam> <Attribute access="0" id="y" value="12" type="8" typeOther="" /> <Attribute access="0" id="b" value="true" type="4" typeOther="" /> -<Attribute access="0" id="x" value="" type="4" typeOther="" /> <Signal value="out testsig(int x, bool b)" /> </extraparam> </COMPONENT> <COMPONENT type="5000" id="52" > -<cdparam x="139" y="179" /> +<cdparam x="138" y="178" /> <sizeparam width="356" height="198" minWidth="5" minHeight="2" maxWidth="1000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> <hidden value="false" /> <cdrectangleparam minX="10" maxX="1400" minY="10" maxY="900" /> @@ -90,9 +89,9 @@ <TGConnectingPoint num="22" id="50" /> <TGConnectingPoint num="23" id="51" /> <extraparam> -<Attribute access="0" id="x" value="5" type="8" typeOther="" /> -<Attribute access="0" id="y" value="43" type="8" typeOther="" /> -<Attribute access="0" id="b" value="" type="4" typeOther="" /> +<Attribute access="0" id="y" value="41" type="8" typeOther="" /> +<Attribute access="0" id="b" value="true" type="4" typeOther="" /> +<Attribute access="0" id="x" value="" type="8" typeOther="" /> <Method value="done(int x, bool b)" /> <Signal value="in testsig(int x, bool b)" /> </extraparam> @@ -107,13 +106,13 @@ <sizeparam width="0" height="0" minWidth="0" minHeight="0" maxWidth="1000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> <infoparam name="connector from TGComponent to Send signal" value="null" /> <TGConnectingPoint num="0" id="58" /> -<P1 x="400" y="155" id="79" /> -<P2 x="438" y="195" id="83" /> +<P1 x="401" y="156" id="79" /> +<P2 x="437" y="208" id="83" /> <AutomaticDrawing data="true" /> </CONNECTOR><SUBCOMPONENT type="-1" id="57" > <father id="59" num="0" /> -<cdparam x="400" y="195" /> -<sizeparam width="10" height="15" minWidth="0" minHeight="0" maxWidth="1000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<cdparam x="452" y="172" /> +<sizeparam width="78" height="15" minWidth="0" minHeight="0" maxWidth="1000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> <hidden value="false" /> <cdrectangleparam minX="10" maxX="1400" minY="10" maxY="900" /> <infoparam name="List of all parameters of an Avatar SMD transition" value="" /> @@ -127,6 +126,7 @@ <afterMax value="" /> <computeMin value="" /> <computeMax value="" /> +<actions value="b = (!b) || (b)" /> </extraparam> </SUBCOMPONENT> @@ -136,7 +136,7 @@ <infoparam name="connector from Send signal to stop state" value="null" /> <TGConnectingPoint num="0" id="66" /> <TGConnectingPoint num="1" id="67" /> -<P1 x="438" y="225" id="84" /> +<P1 x="437" y="238" id="84" /> <P2 x="467" y="291" id="81" /> <Point x="445" y="257" /> <AutomaticDrawing data="true" /> @@ -175,7 +175,7 @@ <TGConnectingPoint num="0" id="75" /> <TGConnectingPoint num="1" id="76" /> <P1 x="347" y="55" id="94" /> -<P2 x="400" y="125" id="78" /> +<P2 x="401" y="126" id="78" /> <Point x="370" y="98" /> <AutomaticDrawing data="true" /> </CONNECTOR><SUBCOMPONENT type="-1" id="69" > @@ -188,8 +188,8 @@ </SUBCOMPONENT> <SUBCOMPONENT type="-1" id="74" > <father id="77" num="1" /> -<cdparam x="407" y="110" /> -<sizeparam width="10" height="15" minWidth="0" minHeight="0" maxWidth="1000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<cdparam x="401" y="88" /> +<sizeparam width="68" height="15" minWidth="0" minHeight="0" maxWidth="1000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> <hidden value="false" /> <cdrectangleparam minX="10" maxX="1400" minY="10" maxY="900" /> <infoparam name="List of all parameters of an Avatar SMD transition" value="" /> @@ -198,7 +198,7 @@ <TGConnectingPoint num="2" id="72" /> <TGConnectingPoint num="3" id="73" /> <extraparam> -<guard value="[ ]" /> +<guard value="[ b | b&b]" /> <afterMin value="" /> <afterMax value="" /> <computeMin value="" /> @@ -207,15 +207,15 @@ </SUBCOMPONENT> <COMPONENT type="5108" id="80" > -<cdparam x="332" y="130" /> -<sizeparam width="136" height="20" minWidth="30" minHeight="0" maxWidth="1000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<cdparam x="334" y="131" /> +<sizeparam width="135" height="20" minWidth="30" minHeight="0" maxWidth="1000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> <hidden value="false" /> <cdrectangleparam minX="10" maxX="1400" minY="10" maxY="900" /> <infoparam name="TGComponent" value="null" /> <TGConnectingPoint num="0" id="78" /> <TGConnectingPoint num="1" id="79" /> <extraparam> -<Data variable="x" minValue="0" maxValue="10" functionId="0" /> +<Data variable="y" minValue="0" maxValue="10" functionId="0" /> </extraparam> </COMPONENT> @@ -229,7 +229,7 @@ </COMPONENT> <COMPONENT type="5103" id="93" > -<cdparam x="400" y="200" /> +<cdparam x="399" y="213" /> <sizeparam width="77" height="20" minWidth="30" minHeight="0" maxWidth="1000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> <hidden value="false" /> <cdrectangleparam minX="10" maxX="1400" minY="10" maxY="900" /> @@ -299,8 +299,8 @@ <AutomaticDrawing data="true" /> </CONNECTOR><SUBCOMPONENT type="-1" id="107" > <father id="109" num="0" /> -<cdparam x="440" y="204" /> -<sizeparam width="70" height="15" minWidth="0" minHeight="0" maxWidth="1000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<cdparam x="430" y="198" /> +<sizeparam width="202" height="15" minWidth="0" minHeight="0" maxWidth="1000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> <hidden value="false" /> <cdrectangleparam minX="10" maxX="1400" minY="10" maxY="900" /> <infoparam name="List of all parameters of an Avatar SMD transition" value="" /> @@ -309,7 +309,7 @@ <TGConnectingPoint num="2" id="105" /> <TGConnectingPoint num="3" id="106" /> <extraparam> -<guard value="[not(y> 43)]" /> +<guard value="[(y== 43) || (y==42) || (y == 41)]" /> <afterMin value="" /> <afterMax value="" /> <computeMin value="" /> @@ -322,7 +322,7 @@ <sizeparam width="0" height="0" minWidth="0" minHeight="0" maxWidth="1000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> <infoparam name="connector from start state to state0" value="null" /> <TGConnectingPoint num="0" id="115" /> -<P1 x="361" y="62" id="171" /> +<P1 x="362" y="64" id="171" /> <P2 x="362" y="122" id="131" /> <AutomaticDrawing data="true" /> </CONNECTOR><SUBCOMPONENT type="-1" id="114" > @@ -424,7 +424,7 @@ </COMPONENT> <COMPONENT type="5100" id="172" > -<cdparam x="354" y="42" /> +<cdparam x="355" y="44" /> <sizeparam width="15" height="15" minWidth="0" minHeight="0" maxWidth="1000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> <hidden value="false" /> <cdrectangleparam minX="10" maxX="1400" minY="10" maxY="900" /> diff --git a/src/avatartranslator/AvatarSpecification.java b/src/avatartranslator/AvatarSpecification.java index e6cc413632..3ff494fb05 100644 --- a/src/avatartranslator/AvatarSpecification.java +++ b/src/avatartranslator/AvatarSpecification.java @@ -52,7 +52,7 @@ import java.util.*; import myutil.*; public class AvatarSpecification extends AvatarElement { - public static String[] ops = {">", "<", "+", "-", "*", "/", "[", "]", "(", ")", ":", "=", "==", ",", "!", "?", "{", "}"}; + public static String[] ops = {">", "<", "+", "-", "*", "/", "[", "]", "(", ")", ":", "=", "==", ",", "!", "?", "{", "}", "|", "&"}; private LinkedList<AvatarBlock> blocks; private LinkedList<AvatarRelation> relations; @@ -169,7 +169,7 @@ public class AvatarSpecification extends AvatarElement { } sb.append("\nPragmas:\n"); for(String pragma: pragmas) { - sb.append("Pagma:" + pragma.toString() + "\n"); + sb.append("Pragma:" + pragma.toString() + "\n"); } return sb.toString(); diff --git a/src/avatartranslator/AvatarSyntaxChecker.java b/src/avatartranslator/AvatarSyntaxChecker.java index f7651da2c3..e9e0dd2868 100644 --- a/src/avatartranslator/AvatarSyntaxChecker.java +++ b/src/avatartranslator/AvatarSyntaxChecker.java @@ -59,6 +59,8 @@ public class AvatarSyntaxChecker { } public static int isAValidGuard(AvatarSpecification _as, AvatarBlock _ab, String _guard) { + //TraceManager.addDev("Evaluating (non modified) guard:" + _guard); + String tmp = _guard.replaceAll(" ", "").trim(); if (tmp.compareTo("[]") == 0) { return 0; @@ -70,13 +72,14 @@ public class AvatarSyntaxChecker { String act = tmp; + for(AvatarAttribute aa: _ab.getAttributes()) { act = Conversion.putVariableValueInString(AvatarSpecification.ops, act, aa.getName(), aa.getDefaultInitialValue()); } BoolExpressionEvaluator bee = new BoolExpressionEvaluator(); - //TraceManager.addDev("Evaluating guard:" + act); + //TraceManager.addDev("Evaluating (modified) guard:" + act); boolean result = bee.getResultOf(act); if (bee.getError() != null) { //TraceManager.addDev("Error: " + bee.getError()); diff --git a/src/avatartranslator/directsimulation/AvatarSpecificationSimulation.java b/src/avatartranslator/directsimulation/AvatarSpecificationSimulation.java index 4fcda68a06..cbd2a4b0ba 100644 --- a/src/avatartranslator/directsimulation/AvatarSpecificationSimulation.java +++ b/src/avatartranslator/directsimulation/AvatarSpecificationSimulation.java @@ -492,7 +492,7 @@ public class AvatarSpecificationSimulation { // Simulation functions - public void gatherPendingTransactions() { + public synchronized void gatherPendingTransactions() { AvatarTransition tr; pendingTransactions.clear(); @@ -777,7 +777,7 @@ public class AvatarSpecificationSimulation { } } - public AvatarSimulationAsynchronousTransaction getAsynchronousMessage(AvatarRelation _ar, AvatarSignal _as) { + public synchronized AvatarSimulationAsynchronousTransaction getAsynchronousMessage(AvatarRelation _ar, AvatarSignal _as) { for(AvatarSimulationAsynchronousTransaction asat: asynchronousMessages) { if (asat.getRelation() == _ar) { if (_ar.getIndexOfSignal(_as) == asat.getIndex()) { @@ -788,7 +788,7 @@ public class AvatarSpecificationSimulation { return null; } - public int getNbOfAsynchronousMessages(AvatarRelation _ar) { + public synchronized int getNbOfAsynchronousMessages(AvatarRelation _ar) { int cpt = 0; for(AvatarSimulationAsynchronousTransaction asat: asynchronousMessages) { if (asat.getRelation() == _ar) { @@ -986,13 +986,13 @@ public class AvatarSpecificationSimulation { // Must verify that the FIFO is not full if not blocking if (rel.isBlocking()) { // blocking was handled before - asynchronousMessages.add(asat); + addAsyncMessage(asat); } else { // non blocking -> check the fifo size int nb = getNbOfAsynchronousMessages(rel); if (nb < rel.getSizeOfFIFO()) { TraceManager.addDev("FIFO not full: " + nb + " size=" + rel.getSizeOfFIFO()); - asynchronousMessages.add(asat); + addAsyncMessage(asat); } else { TraceManager.addDev("*** Asyn msg was dropped because FIFO is full"); } @@ -1002,13 +1002,13 @@ public class AvatarSpecificationSimulation { // Must verify that the FIFO is not full if not blocking if (rel.isBlocking()) { // blocking was handled before - asynchronousMessages.add(asat); + addAsyncMessage(asat); } else { // non blocking -> check the fifo size int nb = getNbOfAsynchronousMessages(rel); if (nb < rel.getSizeOfFIFO()) { TraceManager.addDev("FIFO not full: " + nb + " size=" + rel.getSizeOfFIFO()); - asynchronousMessages.add(asat); + addAsyncMessage(asat); } else { TraceManager.addDev("*** Asyn msg was dropped because FIFO is full"); } @@ -1018,7 +1018,7 @@ public class AvatarSpecificationSimulation { } else { // Must remove the asynchronous operation, and give the parameters AvatarSimulationAsynchronousTransaction asat = getAsynchronousMessage(rel, sig); - asynchronousMessages.remove(asat); + removeAsyncMessage(asat); _aspt.linkedAsynchronousMessage = asat; } } else { @@ -1085,11 +1085,11 @@ public class AvatarSpecificationSimulation { // Must handle asynchronous messages if (ast.receivedMessage != null) { - asynchronousMessages.add(0, ast.receivedMessage); + addAsyncMessageAt(0, ast.receivedMessage); } if (ast.sentMessage != null) { - asynchronousMessages.remove(ast.sentMessage); + removeAsyncMessage(ast.sentMessage); } if (allTransactions.size() > 0) { @@ -1425,5 +1425,120 @@ public class AvatarSpecificationSimulation { block.forceRandom(value); } } - + + public synchronized void addAsyncMessage(AvatarSimulationAsynchronousTransaction m) { + asynchronousMessages.add(m); + } + + public synchronized void addAsyncMessageAt(int index, AvatarSimulationAsynchronousTransaction m) { + asynchronousMessages.add(m); + } + + public synchronized void removeAsyncMessage(AvatarSimulationAsynchronousTransaction msg) { + asynchronousMessages.remove(msg); + } + + // Asynchronous messages manipulation + public synchronized boolean removeAsyncMessage(AvatarRelation ar, int index) { + if ((ar != null) && (index >-1)) { + int realIndex = 0; + boolean found = false; + AvatarSimulationAsynchronousTransaction mesg = null; + for(AvatarSimulationAsynchronousTransaction msg: asynchronousMessages) { + if (msg.getRelation() == ar) { + if (index == 0) { + found = true; + mesg = msg; + break; + } else { + index --; + } + } + realIndex ++; + } + if (found) { + //TraceManager.addDev("Removing at index: " + realIndex); + asynchronousMessages.remove(realIndex); + return removeAsyncMsgFromPendingTransactions(mesg); + } + } + + return false; + } + + public synchronized void moveAsyncMessage(AvatarRelation ar, int oldIndex, int newIndex) { + //TraceManager.addDev("Moving from index: " + oldIndex + " to: " + newIndex); + /*int back1 = oldIndex; + int back2 = newIndex;*/ + if ((ar != null) && (oldIndex >-1) && (newIndex >-1) && (oldIndex != newIndex)) { + int oldRealIndex = -1; + int newRealIndex = -1; + int realIndex = 0; + boolean found = false; + AvatarSimulationAsynchronousTransaction mesg = null; + for(AvatarSimulationAsynchronousTransaction msg: asynchronousMessages) { + if (msg.getRelation() == ar) { + if ((oldIndex == 0) && (oldRealIndex == -1)){ + oldRealIndex = realIndex; + mesg = msg; + } else { + oldIndex --; + } + if ((newIndex == 0) && (newRealIndex == -1)) { + newRealIndex = realIndex; + } else { + newIndex --; + } + } + realIndex ++; + } + if ((newRealIndex != -1) && (mesg != null)) { + //TraceManager.addDev("Moving from: " + oldRealIndex + " to: "+ newRealIndex); + asynchronousMessages.set(oldRealIndex, asynchronousMessages.get(newRealIndex)); + asynchronousMessages.set(newRealIndex, mesg); + + + //asynchronousMessages.insertElementAt(mesg, newRealIndex); + + /*if (back1 < back2) { + asynchronousMessages.insertElementAt(mesg, newRealIndex); + } else { + asynchronousMessages.insertElementAt(mesg, newRealIndex); + }*/ + } + } + TraceManager.addDev("Move done"); + + } + + + + public synchronized boolean removeAsyncMsgFromPendingTransactions(AvatarSimulationAsynchronousTransaction msg) { + if (msg == null) { + return false; + } + + boolean found = false; + Vector<AvatarSimulationPendingTransaction> vect = new Vector<AvatarSimulationPendingTransaction>(); + if ((pendingTransactions != null) && (pendingTransactions.size() > 0)) { + for(AvatarSimulationPendingTransaction tr: pendingTransactions) { + if (tr.linkedAsynchronousMessage == msg) { + //TraceManager.addDev("Msg to remove from pending transaction"); + vect.add(tr); + found = true; + } + } + } + + if (vect.size()>0) { + for(AvatarSimulationPendingTransaction toRem: vect) { + //TraceManager.addDev("Removing pending transaction"); + pendingTransactions.remove(toRem); + } + } + + TraceManager.addDev("Returning " + found); + + return found; + } } \ No newline at end of file diff --git a/src/myutil/BoolExpressionEvaluator.java b/src/myutil/BoolExpressionEvaluator.java index 6eace03430..97f529b016 100755 --- a/src/myutil/BoolExpressionEvaluator.java +++ b/src/myutil/BoolExpressionEvaluator.java @@ -92,7 +92,7 @@ public class BoolExpressionEvaluator { } public boolean getResultOf(String _expr) { - //TraceManager.addDev("Evaluating bool expr: " + _expr); + TraceManager.addDev("Evaluating bool expr: " + _expr); //_expr = Conversion.replaceAllString(_expr, "not", "!").trim(); nbOpen = 0; @@ -105,7 +105,8 @@ public class BoolExpressionEvaluator { return false; } - + _expr = Conversion.replaceAllString(_expr, "||", "|").trim(); + _expr = Conversion.replaceAllString(_expr, "&&", "&").trim(); _expr = Conversion.replaceAllString(_expr, "or", "|").trim(); _expr = Conversion.replaceAllString(_expr, "and", "&").trim(); _expr = Conversion.replaceAllString(_expr, "==", "=").trim(); @@ -120,7 +121,7 @@ public class BoolExpressionEvaluator { while((index = _expr.indexOf("not(")) != -1) { indexPar = Conversion.findMatchingParenthesis(_expr, index+3, '(', ')'); if( indexPar == -1) { - errorMessage = "Parenthisis not maching at index " + (index + 3) + " in expression: " + _expr; + errorMessage = "Parenthesis not maching at index " + (index + 3) + " in expression: " + _expr; return false; } diff --git a/src/myutil/Conversion.java b/src/myutil/Conversion.java index 28a97baef7..1c38393be8 100755 --- a/src/myutil/Conversion.java +++ b/src/myutil/Conversion.java @@ -534,6 +534,7 @@ public class Conversion { } public static String putVariableValueInString(String[] ops, String expr, String variableName, String value) { + //TraceManager.addDev("Putting variable value = " + value + " of " + variableName + " in " + expr); String ret = " " + expr + " "; String name = " " + variableName + " "; String s0; diff --git a/src/myutil/PeriodicBehavior.java b/src/myutil/PeriodicBehavior.java new file mode 100755 index 0000000000..14bf7fa1f8 --- /dev/null +++ b/src/myutil/PeriodicBehavior.java @@ -0,0 +1,56 @@ +/**Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + +ludovic.apvrille AT enst.fr + +This software is a computer program whose purpose is to allow the +edition of TURTLE analysis, design and deployment diagrams, to +allow the generation of RT-LOTOS or Java code from this diagram, +and at last to allow the analysis of formal validation traces +obtained from external tools, e.g. RTL from LAAS-CNRS and CADP +from INRIA Rhone-Alpes. + +This software is governed by the CeCILL license under French law and +abiding by the rules of distribution of free software. You can use, +modify and/ or redistribute the software under the terms of the CeCILL +license as circulated by CEA, CNRS and INRIA at the following URL +"http://www.cecill.info". + +As a counterpart to the access to the source code and rights to copy, +modify and redistribute granted by the license, users are provided only +with a limited warranty and the software's author, the holder of the +economic rights, and the successive licensors have only limited +liability. + +In this respect, the user's attention is drawn to the risks associated +with loading, using, modifying and/or developing or reproducing the +software by the user in light of its specific status of free software, +that may mean that it is complicated to manipulate, and that also +therefore means that it is reserved for developers and experienced +professionals having in-depth computer knowledge. Users are therefore +encouraged to load and test the software's suitability as regards their +requirements in conditions enabling the security of their systems and/or +data to be ensured and, more generally, to use and operate it in the +same conditions as regards security. + +The fact that you are presently reading this means that you have had +knowledge of the CeCILL license and that you accept its terms. + +/** + * Interface PeriodicBehavior + * For execution periodically processes + * Creation: 2014 + * @version 1.1 07/01/2014 + * @author Ludovic APVRILLE + * @see + */ + +package myutil; + + +import java.io.*; + + +public interface PeriodicBehavior { + + public void periodicAction(); +} diff --git a/src/myutil/PeriodicBehaviorThread.java b/src/myutil/PeriodicBehaviorThread.java new file mode 100755 index 0000000000..3f3350a31c --- /dev/null +++ b/src/myutil/PeriodicBehaviorThread.java @@ -0,0 +1,83 @@ +/**Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + +ludovic.apvrille AT enst.fr + +This software is a computer program whose purpose is to allow the +edition of TURTLE analysis, design and deployment diagrams, to +allow the generation of RT-LOTOS or Java code from this diagram, +and at last to allow the analysis of formal validation traces +obtained from external tools, e.g. RTL from LAAS-CNRS and CADP +from INRIA Rhone-Alpes. + +This software is governed by the CeCILL license under French law and +abiding by the rules of distribution of free software. You can use, +modify and/ or redistribute the software under the terms of the CeCILL +license as circulated by CEA, CNRS and INRIA at the following URL +"http://www.cecill.info". + +As a counterpart to the access to the source code and rights to copy, +modify and redistribute granted by the license, users are provided only +with a limited warranty and the software's author, the holder of the +economic rights, and the successive licensors have only limited +liability. + +In this respect, the user's attention is drawn to the risks associated +with loading, using, modifying and/or developing or reproducing the +software by the user in light of its specific status of free software, +that may mean that it is complicated to manipulate, and that also +therefore means that it is reserved for developers and experienced +professionals having in-depth computer knowledge. Users are therefore +encouraged to load and test the software's suitability as regards their +requirements in conditions enabling the security of their systems and/or +data to be ensured and, more generally, to use and operate it in the +same conditions as regards security. + +The fact that you are presently reading this means that you have had +knowledge of the CeCILL license and that you accept its terms. + +/** + * Class PeriodicBehaviorThread + * For execution periodically a given action + * Creation: 2014 + * @version 1.1 07/01/2014 + * @author Ludovic APVRILLE + * @see + */ + +package myutil; + + +import java.io.*; + + +public class PeriodicBehaviorThread extends Thread { + + private PeriodicBehavior pb; + private long periodValue; + + public PeriodicBehaviorThread(PeriodicBehavior _pb, long _periodValue) { + pb = _pb; + periodValue = _periodValue; + this.setDaemon(true); + this.start(); + + } + + + public void run() { + + if (pb == null) { + return; + } + + while(true) { + + try { + Thread.sleep(periodValue); //sleep for about 1s + } catch (InterruptedException e) { + + } + pb.periodicAction(); + } + } +} diff --git a/src/ui/IconManager.java b/src/ui/IconManager.java index 93aef7a2d0..e2d3829b62 100755 --- a/src/ui/IconManager.java +++ b/src/ui/IconManager.java @@ -73,7 +73,7 @@ public class IconManager { public static ImageIcon imgic40, imgic41, imgic42, imgic43, imgic44, imgic45, imgic46, imgic47, imgic48, imgic49; public static ImageIcon imgic50, imgic51, imgic52, imgic53, imgic54, imgic55, imgic56, imgic57, imgic58, imgic59; public static ImageIcon imgic60, imgic61, imgic62, imgic63, imgic64, imgic65, imgic66; - public static ImageIcon imgic70, imgic71, imgic72, imgic73, imgic75, imgic76, imgic77; + public static ImageIcon imgic70, imgic71, imgic72, imgic73, imgic75, imgic76, imgic77, imgic78, imgic79; public static ImageIcon imgic80, imgic82, imgic84, imgic86, imgic88; public static ImageIcon imgic90, imgic92, imgic94, imgic96; @@ -241,6 +241,8 @@ public class IconManager { private static String icon75 = "images/toolbarButtonGraphics/general/Refresh24.gif"; private static String icon76 = "images/toolbarButtonGraphics/general/Preferences16.gif"; private static String icon77 = "images/toolbarButtonGraphics/general/Preferences24.gif"; + private static String icon78 = "images/toolbarButtonGraphics/navigation/Up16.gif"; + private static String icon79 = "images/toolbarButtonGraphics/navigation/Down16.gif"; private static String icon80 = "images/avatarbd.gif"; @@ -666,6 +668,8 @@ public class IconManager { imgic75 = getIcon(icon75); imgic76 = getIcon(icon76); imgic77 = getIcon(icon77); + imgic78 = getIcon(icon78); + imgic79 = getIcon(icon79); imgic80 = getIcon(icon80); imgic82 = getIcon(icon82); diff --git a/src/ui/MainGUI.java b/src/ui/MainGUI.java index f8d8173385..04c99ee5a9 100755 --- a/src/ui/MainGUI.java +++ b/src/ui/MainGUI.java @@ -94,7 +94,7 @@ import ui.avatarpd.*; import ui.avatarcd.*; import ui.avatarad.*; -public class MainGUI implements ActionListener, WindowListener, KeyListener { +public class MainGUI implements ActionListener, WindowListener, KeyListener, PeriodicBehavior { public static boolean systemcOn; public static boolean lotosOn; @@ -274,6 +274,9 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { // Invariants Invariant currentInvariant; + + // Thread fof autosave + PeriodicBehaviorThread pbt; public MainGUI(boolean _systemcOn, boolean _lotosOn, boolean _proactiveOn, boolean _tpnOn, boolean _osOn, boolean _uppaalOn, boolean _ncOn, boolean _avatarOn, boolean _proverifOn) { systemcOn = _systemcOn; @@ -287,6 +290,9 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { proverifOn = _proverifOn; currentInvariant = null; + + pbt = new PeriodicBehaviorThread(this, 120000); // save every two minutes + } @@ -854,12 +860,42 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { } } + + private void activeActions(boolean b) { for(int i=0; i<TGUIAction.NB_ACTION; i++) { actions[i].setEnabled(b); } } + + public void periodicAction() { + //TraceManager.addDev("Autosaving "); + if (file == null) { + return; + } + + File fileSave = new File(file.getAbsolutePath() + "~"); + TraceManager.addDev("Autosaving in " + fileSave.getAbsolutePath()); + status.setText("Autosaving in " + fileSave.getAbsolutePath()); + + if(checkFileForSave(fileSave)) { + try { + String s = gtm.makeXMLFromTurtleModeling(-1); + FileOutputStream fos = new FileOutputStream(fileSave); + fos.write(s.getBytes()); + fos.close(); + } catch (Exception e) { + TraceManager.addDev("Error during autosave: " + e.getMessage()); + status.setText("Error during autosave: " + e.getMessage()); + return; + } + } + status.setText("Autosave done in " + fileSave.getAbsolutePath()); + + + } + public void search(String text) { Vector<Object> elements = new Vector<Object>(); diff --git a/src/ui/avatarinteractivesimulation/AvatarInteractiveSimulationActions.java b/src/ui/avatarinteractivesimulation/AvatarInteractiveSimulationActions.java index 148a6b2c0f..c009f7e9ed 100755 --- a/src/ui/avatarinteractivesimulation/AvatarInteractiveSimulationActions.java +++ b/src/ui/avatarinteractivesimulation/AvatarInteractiveSimulationActions.java @@ -97,8 +97,12 @@ public class AvatarInteractiveSimulationActions extends AbstractAction { public static final int ACT_ZOOM_IN = 30; public static final int ACT_ZOOM_OUT = 31; + + public static final int ACT_DELETE_ASYNC_MSG = 32; + public static final int ACT_UP_ASYNC_MSG = 33; + public static final int ACT_DOWN_ASYNC_MSG = 34; - public static final int NB_ACTION = 32; + public static final int NB_ACTION = 35; private static final TAction [] actions = new TAction[NB_ACTION]; @@ -181,7 +185,9 @@ public class AvatarInteractiveSimulationActions extends AbstractAction { actions[ACT_ZOOM_IN] = new TAction("zoommore-command", "Zoom +", IconManager.imgic317, IconManager.imgic317, "Zoom +", "Zoom +", '0'); actions[ACT_ZOOM_OUT] = new TAction("zoomless-command", "Zoom -", IconManager.imgic315, IconManager.imgic315, "Zoom -", "Zoom -", '0'); - + actions[ACT_DELETE_ASYNC_MSG] = new TAction("delete-async-command", "Delete", IconManager.imgic336, IconManager.imgic336, "Delete msg +", "Delete the selected message", '0'); + actions[ACT_UP_ASYNC_MSG] = new TAction("up-async-command", "Up", IconManager.imgic78, IconManager.imgic78, "Up msg", "Put a async msg closer to the FIFO exit", '0'); + actions[ACT_DOWN_ASYNC_MSG] = new TAction("up-async-command", "Down", IconManager.imgic79, IconManager.imgic79, "Down msg", "Put a async msg further from the FIFO exit", '0'); } public String getActionCommand() { diff --git a/src/ui/avatarinteractivesimulation/AvatarInteractiveSimulationFIFOData.java b/src/ui/avatarinteractivesimulation/AvatarInteractiveSimulationFIFOData.java new file mode 100755 index 0000000000..87ffd43de4 --- /dev/null +++ b/src/ui/avatarinteractivesimulation/AvatarInteractiveSimulationFIFOData.java @@ -0,0 +1,79 @@ +/**Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + +ludovic.apvrille AT enst.fr + +This software is a computer program whose purpose is to allow the +edition of TURTLE analysis, design and deployment diagrams, to +allow the generation of RT-LOTOS or Java code from this diagram, +and at last to allow the analysis of formal validation traces +obtained from external tools, e.g. RTL from LAAS-CNRS and CADP +from INRIA Rhone-Alpes. + +This software is governed by the CeCILL license under French law and +abiding by the rules of distribution of free software. You can use, +modify and/ or redistribute the software under the terms of the CeCILL +license as circulated by CEA, CNRS and INRIA at the following URL +"http://www.cecill.info". + +As a counterpart to the access to the source code and rights to copy, +modify and redistribute granted by the license, users are provided only +with a limited warranty and the software's author, the holder of the +economic rights, and the successive licensors have only limited +liability. + +In this respect, the user's attention is drawn to the risks associated +with loading, using, modifying and/or developing or reproducing the +software by the user in light of its specific status of free software, +that may mean that it is complicated to manipulate, and that also +therefore means that it is reserved for developers and experienced +professionals having in-depth computer knowledge. Users are therefore +encouraged to load and test the software's suitability as regards their +requirements in conditions enabling the security of their systems and/or +data to be ensured and, more generally, to use and operate it in the +same conditions as regards security. + +The fact that you are presently reading this means that you have had +knowledge of the CeCILL license and that you accept its terms. + +/** + * Class AvatarInteractiveSimulationFIFOData + * Abstract toolbar to be used by simulation window + * Creation: 06/12/2013 + * @version 1.0 06/12/2013 + * @author Ludovic APVRILLE + * @see TGComponent + */ + +package ui.avatarinteractivesimulation; + +import javax.swing.*; + +import avatartranslator.*; + + +public class AvatarInteractiveSimulationFIFOData { + public AvatarRelation fifo; + public int nb = 0; + + + public AvatarInteractiveSimulationFIFOData(AvatarRelation _ar) { + fifo = _ar; + } + + public String toString() { + String ret = fifo.block1.getName() + " -> " + fifo.block2.getName() + ": "; + if (nb < 1) { + return ret + "no message"; + } else if (nb == 1) { + return ret + "1 message"; + } else { + return ret + nb + " messages"; + } + } + +} // Class + + + + + diff --git a/src/ui/avatarinteractivesimulation/JFrameAvatarInteractiveSimulation.java b/src/ui/avatarinteractivesimulation/JFrameAvatarInteractiveSimulation.java index 3dad1012d2..9f56c6eac7 100755 --- a/src/ui/avatarinteractivesimulation/JFrameAvatarInteractiveSimulation.java +++ b/src/ui/avatarinteractivesimulation/JFrameAvatarInteractiveSimulation.java @@ -110,6 +110,7 @@ public class JFrameAvatarInteractiveSimulation extends JFrame implements AvatarS //protected JComboBox cpus, busses, mems, tasks, chans; //List of transactions + private JList listPendingTransactions; private TGComponent selectedComponentForTransaction; private AvatarSimulationBlock previousBlock; @@ -162,7 +163,11 @@ public class JFrameAvatarInteractiveSimulation extends JFrame implements AvatarS // Asynchronous transactions private JPanel asyncPanel; + private JComboBox comboFIFOs; + private Vector<AvatarInteractiveSimulationFIFOData> fifos; + private JButton delete, up, down; private JList asyncmsgs; + private int nbOfAsyncMsgs; // Sequence Diagram private AvatarSpecificationSimulationSDPanel sdpanel; @@ -211,11 +216,6 @@ public class JFrameAvatarInteractiveSimulation extends JFrame implements AvatarS setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE ); setIconImage(IconManager.img5100); setBackground(Color.WHITE); - - /*valueTable = new Hashtable<Integer, String>(); - rowTable = new Hashtable<Integer, Integer>(); - runningTable = new Hashtable<Integer, Integer>(); - diagramTable = new Hashtable<String, String>();*/ try { setBackground(new Color(50, 40, 40, 200)); @@ -818,6 +818,18 @@ public class JFrameAvatarInteractiveSimulation extends JFrame implements AvatarS //Asynchronous + + // Making vector of fifos + AvatarInteractiveSimulationFIFOData fifo; + fifos = new Vector<AvatarInteractiveSimulationFIFOData>(); + for(AvatarRelation ar: avspec.getRelations()) { + if (ar.isAsynchronous()) { + fifo = new AvatarInteractiveSimulationFIFOData(ar); + fifos.add(fifo); + } + } + + asyncPanel = new JPanel(); asyncPanel.setLayout(new GridBagLayout()); GridBagConstraints ca = new GridBagConstraints(); @@ -826,12 +838,46 @@ public class JFrameAvatarInteractiveSimulation extends JFrame implements AvatarS ca.weighty = 1.0; ca.weightx = 1.0; ca.gridwidth = GridBagConstraints.REMAINDER; //end row - ca.fill = GridBagConstraints.BOTH; + ca.fill = GridBagConstraints.HORIZONTAL; ca.gridheight = 1; + + comboFIFOs = new JComboBox(fifos); + comboFIFOs.addActionListener(this); + asyncPanel.add(comboFIFOs, ca); + ca.fill = GridBagConstraints.BOTH; + + JPanel borderjlist = new JPanel(new GridBagLayout()); + GridBagConstraints cb = new GridBagConstraints(); + + cb.gridheight = 1; + cb.weighty = 1.0; + cb.weightx = 1.0; + cb.gridwidth = GridBagConstraints.REMAINDER; //end row + cb.fill = GridBagConstraints.BOTH; + cb.gridheight = 1; + borderjlist.setBorder(new javax.swing.border.TitledBorder("Top of selected FIFO:")); asyncmsgs = new JList(); - asyncPanel.add(asyncmsgs, ca); + JScrollPane pane = new JScrollPane(asyncmsgs); + borderjlist.add(pane, cb); + asyncPanel.add(borderjlist, ca); infoTab.addTab("Asynch. msg", IconManager.imgic1202, asyncPanel, "Asynch. msg."); + ca.fill = GridBagConstraints.NONE; + ca.gridwidth = 1; + delete = new JButton(actions[AvatarInteractiveSimulationActions.ACT_DELETE_ASYNC_MSG]); + //delete.addActionListener(this); + asyncPanel.add(delete, ca); + up = new JButton(actions[AvatarInteractiveSimulationActions.ACT_UP_ASYNC_MSG]); + //up.addActionListener(this); + asyncPanel.add(up, ca); + ca.gridwidth = GridBagConstraints.REMAINDER; //end row + down = new JButton(actions[AvatarInteractiveSimulationActions.ACT_DOWN_ASYNC_MSG]); + //down.addActionListener(this); + asyncPanel.add(down, ca); + setDeleteUpDown(); + asyncmsgs.addListSelectionListener(this); + + pack(); } @@ -991,6 +1037,7 @@ public class JFrameAvatarInteractiveSimulation extends JFrame implements AvatarS actions[AvatarInteractiveSimulationActions.ACT_RUN_X_COMMANDS].setEnabled(true); actions[AvatarInteractiveSimulationActions.ACT_RESET_SIMU].setEnabled(true); actions[AvatarInteractiveSimulationActions.ACT_STOP_SIMU].setEnabled(false); + b = true; break; case AvatarSpecificationSimulation.GATHER: @@ -1045,8 +1092,35 @@ public class JFrameAvatarInteractiveSimulation extends JFrame implements AvatarS sdpanel.scrollToLowerPosition(); } + // Delete, up, down + setDeleteUpDown(b); + } + + public boolean isBusy() { + if (busyMode == AvatarSpecificationSimulation.EXECUTE) { + return true; + } + + if (busyMode == AvatarSpecificationSimulation.GATHER) { + return true; + } + + return false; + } + + + public void setDeleteUpDown() { + setDeleteUpDown(!isBusy()); } + public void setDeleteUpDown(boolean b) { + if (down != null) { + delete.setEnabled(b && (asyncmsgs.getSelectedIndex() > -1)); + up.setEnabled(b && (asyncmsgs.getSelectedIndex() > 0)); + down.setEnabled(b && (asyncmsgs.getSelectedIndex() > -1) && (asyncmsgs.getSelectedIndex() < (nbOfAsyncMsgs-1 ))); + } + } + public void animateFutureTransactions() { setContentOfListOfPendingTransactions(); } @@ -1162,12 +1236,55 @@ public class JFrameAvatarInteractiveSimulation extends JFrame implements AvatarS } public void updateAsynchronousChannels() { + if (ass != null) { Vector<AvatarSimulationAsynchronousTransaction> msgs = ass.getAsynchronousMessages(); + + if (fifos != null) { + for(AvatarInteractiveSimulationFIFOData fifo: fifos) { + fifo.nb=0; + } + + + } + if (msgs != null) { - if (asyncmsgs != null) { - asyncmsgs.setListData(msgs); + + if (msgs.size() > 0) { + for(AvatarSimulationAsynchronousTransaction msg: msgs) { + for(AvatarInteractiveSimulationFIFOData fifo0: fifos) { + if (fifo0.fifo == msg.getRelation()) { + fifo0.nb ++; + break; + } + } + } } + + if (asyncPanel != null) { + asyncPanel.revalidate(); + comboFIFOs.revalidate(); + comboFIFOs.repaint(); + } + + + + if (asyncmsgs != null) { + AvatarInteractiveSimulationFIFOData currentFifo = (AvatarInteractiveSimulationFIFOData)(comboFIFOs.getSelectedItem()); + if (currentFifo != null) { + nbOfAsyncMsgs = 0; + Vector<AvatarSimulationAsynchronousTransaction> vectorForList = new Vector<AvatarSimulationAsynchronousTransaction>(); + for(AvatarSimulationAsynchronousTransaction as: msgs) { + if (as.getRelation() == currentFifo.fifo) { + vectorForList.add(as); + nbOfAsyncMsgs++; + } + } + //Collections.reverse(vectorForList); + asyncmsgs.setListData(vectorForList); + } + } + } } } @@ -1364,6 +1481,62 @@ public class JFrameAvatarInteractiveSimulation extends JFrame implements AvatarS mgui.writeImageCapture(bi, file, true); } + public void deleteAsyncMsg() { + //TraceManager.addDev("Deleting async msg"); + if ((ass != null) && (!isBusy())){ + int index = asyncmsgs.getSelectedIndex(); + if (index > -1) { + boolean pendingModified = ass.removeAsyncMessage(((AvatarInteractiveSimulationFIFOData)(comboFIFOs.getSelectedItem())).fifo, index); + updateAsynchronousChannels(); + if (pendingModified) { + updatePending(); + } + } + } + + } + + public void upAsyncMsg() { + //TraceManager.addDev("Up async msg"); + if ((ass != null) && (!isBusy())){ + int index = asyncmsgs.getSelectedIndex(); + if (index > 0) { + ass.moveAsyncMessage(((AvatarInteractiveSimulationFIFOData)(comboFIFOs.getSelectedItem())).fifo, index ,index-1); + updateAsynchronousChannels(); + asyncmsgs.setSelectedIndex(index-1); + } + } + + //printFullList(); + + } + + public void downAsyncMsg() { + //TraceManager.addDev("Down async msg"); + if ((ass != null) && (!isBusy())){ + int index = asyncmsgs.getSelectedIndex(); + if (index > -1) { + //TraceManager.addDev("Moving from index: " + index + " to: " + (index+1)); + ass.moveAsyncMessage(((AvatarInteractiveSimulationFIFOData)(comboFIFOs.getSelectedItem())).fifo, index, index+1); + updateAsynchronousChannels(); + //TraceManager.addDev("Selecting list at index:" + index); + asyncmsgs.repaint(); + asyncmsgs.setSelectedIndex(index+1); + } + } + //printFullList(); + } + + public void printFullList() { + int i = 0; + if (ass != null) { + for(AvatarSimulationAsynchronousTransaction tr: ass.getAsynchronousMessages()) { + TraceManager.addDev("#" + i + "\t: " + tr); + i++; + } + } + } + // Mouse management public void mouseReleased(MouseEvent e) {} @@ -1463,9 +1636,20 @@ public class JFrameAvatarInteractiveSimulation extends JFrame implements AvatarS ass.forceRandom(-1); } } + } else if (evt.getSource() == comboFIFOs) { + updateAsynchronousChannels(); + setDeleteUpDown(); + } else if (evt.getSource() == delete) { + deleteAsyncMsg(); + return; + } else if (evt.getSource() == up) { + TraceManager.addDev("Source = up"); + upAsyncMsg(); + } else if (evt.getSource() == down) { + TraceManager.addDev("Source = up"); + downAsyncMsg(); } - // Check for source of jcheckbox int index = 0; for(JCheckBox jcb: displayedBlocks) { @@ -1485,6 +1669,11 @@ public class JFrameAvatarInteractiveSimulation extends JFrame implements AvatarS } public void valueChanged(ListSelectionEvent e) { + if (e.getSource() == asyncmsgs) { + setDeleteUpDown(); + return; + } + int index = listPendingTransactions.getSelectedIndex(); //TraceManager.addDev("Selected index = " + index); if (index > -1) { @@ -1566,6 +1755,5 @@ public class JFrameAvatarInteractiveSimulation extends JFrame implements AvatarS public void windowDeactivated(WindowEvent e) { } - - + } // Class diff --git a/src/ui/images/toolbarButtonGraphics/navigation/Down16.gif b/src/ui/images/toolbarButtonGraphics/navigation/Down16.gif new file mode 100644 index 0000000000000000000000000000000000000000..39849181f1d0b1e96de5fa17ca2a5ee5c76f9b49 GIT binary patch literal 185 zcmZ?wbhEHb6krfwSoELa|NsAI&itP_^9%z6!+`?_fFuMc{$ycfU|?a;0dYZU8JM*_ zcHQ}BaLV)8=3JINChHp&3TFM_eZ(=#VcN9h*9$UbE^ce#`*bAuz=8=A7#I})`8($q zR2F5XXOt)y85kHSBvmQ|m*y$>W+oTq7grXSq~;duD0t>2>nS+q<R}Dz6c#H4r52|a dm8GWW@p5_jxGA^?DTJjKDH!S*@NzL&0|3`tKd1lz literal 0 HcmV?d00001 diff --git a/src/ui/images/toolbarButtonGraphics/navigation/Up16.gif b/src/ui/images/toolbarButtonGraphics/navigation/Up16.gif new file mode 100644 index 0000000000000000000000000000000000000000..cebe60d956c076a382dcbc1fbd4e1677b160212b GIT binary patch literal 184 zcmZ?wbhEHb6krfwSoELa|NsAI&itP_^9%z6!+`?_fFuMc{$ycfU|?a;0dYZU8JM*^ zcHQ}Ba7yte$CfxnqdPI*S?>r`aa%B?Wloe`uq8<<db_H5_S63d7AP??DE{+z&M&Ae z%1qBFQ7|$vFi=RUR0uB3Q}E49F3K;iEG|jSE!I)+%uCi&aLmb32m&cARtQQhPAw`+ bP0{1!^73(0a1T-lOD$3`)HC4aVz34PIlDXY literal 0 HcmV?d00001 -- GitLab