diff --git a/build.gradle b/build.gradle index 472fa35762201d8fb5d8fa3b08885f51d0d06c8c..a31c9c7e143a9e756d8f3fde0e484ecbd6692b91 100644 --- a/build.gradle +++ b/build.gradle @@ -116,8 +116,8 @@ dependencies { implementation group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.11.2' // ragconnectClasspath group: 'de.tudresden.inf.st', name: 'ragconnect.base', version: '0.2.3' // ragconnectClasspath group: 'de.tudresden.inf.st', name: 'ragconnect.base', '1.0.0-alpha-214' - ragconnectClasspath 'de.tudresden.inf.st:ragconnect:1.0.0-alpha-214' - // ragconnectClasspath fileTree(include: ['ragconnect.base-fatjar-1.0.0-alpha.jar'], dir: './libs') + // ragconnectClasspath 'de.tudresden.inf.st:ragconnect:1.0.0-alpha-214' + ragconnectClasspath fileTree(include: ['ragconnect.base-fatjar-1.0.1.jar'], dir: './libs') // vis implementation group: 'de.tudresden.inf.st', name: 'dumpAst', version: '1.2.1-77' @@ -166,7 +166,9 @@ def ecoreInputFiles = [ecoreFile] def ecoreOutputFiles = [ecoreRelastAspect, ecoreRelastGrammar] -def relastInputFiles = [ecoreRelastGrammar, './src/main/jastadd/base/marking/Marking.relast', './src/main/jastadd/engine/connection/SignalConnection.relast','./src/main/jastadd/engine/balloonMarking/BalloonMarking.relast', './src/main/jastadd/engine/balloonMarking/BalloonExecution.relast', './src/main/jastadd/base/io/IoPN.relast', './src/main/jastadd/base/clauses/expressions.relast'] +def relastInputFiles = [ecoreRelastGrammar, './src/gen/jastadd/Marking.relast', './src/gen/jastadd/SignalConnection.relast', + './src/gen/jastadd/BalloonMarking.relast', './src/main/jastadd/engine/balloonMarking/BalloonExecution.relast', + './src/gen/jastadd/IoPN.relast', './src/gen/jastadd/expressions.relast'] def relastOutputFiles = ['src/gen/jastadd/pnml/placeTransition.ast', 'src/gen/jastadd/pnml/placeTransition.jadd'] task ecoreToRelast(type: JavaExec) { @@ -223,6 +225,7 @@ task ragConnect(type: JavaExec) { 'src/main/jastadd/engine/connection/Dineros.connect', '--rootNode=InputSignalConnector', '--List=JastAddList', + '--protocols=mqtt,java', '--incremental=param', '--tracing=flush', '--experimental-jastadd-329', diff --git a/libs/ragconnect.base-fatjar-1.0.0-alpha.jar b/libs/ragconnect.base-fatjar-1.0.1.jar similarity index 79% rename from libs/ragconnect.base-fatjar-1.0.0-alpha.jar rename to libs/ragconnect.base-fatjar-1.0.1.jar index 3680db8379096a5e0cfb25954191d770edfdb129..7f68b3d5b5b95463c07ba0b6140488aaa6639fb9 100644 Binary files a/libs/ragconnect.base-fatjar-1.0.0-alpha.jar and b/libs/ragconnect.base-fatjar-1.0.1.jar differ diff --git a/src/main/jastadd/engine/balloonMarking/BalloonExecution.relast b/src/main/jastadd/engine/balloonMarking/BalloonExecution.relast index 7d51582b9ac026e48897e8ba46f1b70228bbb1d3..66385e38cbd18d299a5f5463b96ab5e181a21cf9 100644 --- a/src/main/jastadd/engine/balloonMarking/BalloonExecution.relast +++ b/src/main/jastadd/engine/balloonMarking/BalloonExecution.relast @@ -4,6 +4,7 @@ BalloonTransition ::= <BalloonCallbacks:java.util.List<de.tudresden.inf.st.pnml. rel BalloonTransition.Transition -> Transition; abstract TransitionSelectionResult; -FiringSelectionSuccess : TransitionSelectionResult ::= Transition:Transition; +FiringSelectionSuccess : TransitionSelectionResult; +rel FiringSelectionSuccess.Transition -> Transition; FiringSelectionWait : TransitionSelectionResult ::= <WaitingTime:int>; FiringSelectionFail : TransitionSelectionResult; \ No newline at end of file diff --git a/src/main/jastadd/engine/connection/Dineros.connect b/src/main/jastadd/engine/connection/Dineros.connect index e2d0955e7e07dffbb9173bf7299c0678e8a0d0e7..560779ef26770988aec9a9b73d7d9bdce571d44f 100644 --- a/src/main/jastadd/engine/connection/Dineros.connect +++ b/src/main/jastadd/engine/connection/Dineros.connect @@ -7,3 +7,5 @@ InputSignalTransformation maps String s to boolean {: return false; :} + +send SignalConnection.CurrentValue; \ No newline at end of file diff --git a/src/main/java/de/tudresden/inf/st/pnml/engine/ros/DiNeRosNode.java b/src/main/java/de/tudresden/inf/st/pnml/engine/ros/DiNeRosNode.java index 2d65b9d97328f03051119c39dce788acc9ac3c4a..9ff3c60b2d26fe0453892c2107e74664dcd2e675 100644 --- a/src/main/java/de/tudresden/inf/st/pnml/engine/ros/DiNeRosNode.java +++ b/src/main/java/de/tudresden/inf/st/pnml/engine/ros/DiNeRosNode.java @@ -36,7 +36,7 @@ public abstract class DiNeRosNode extends AbstractNodeMain { try { marking = petriNet.initializeBalloonMarking(); callbackStorage = petriNet.initializeCallbackStorage(); - PetriNetInitializer.initInputSignalConnections(petriNet, rcHost, gcProtocol, inputSignalConnector); + PetriNetInitializer.initInputSignalConnections(petriNet, rcHost, gcProtocol, inputSignalConnector, this); } catch (IOException | SAXException | ParserConfigurationException e) { e.printStackTrace(); } @@ -110,18 +110,24 @@ public abstract class DiNeRosNode extends AbstractNodeMain { private void onStartupEndedInternal(Set<Transition> enabledTransitions){ + System.out.println("Calling onStartupEndedInternal"); + TransitionSelectionResult res = onStartupEnded(enabledTransitions); getTransitionSelectionResult(res); } private void onMarkingChangeInternal(Set<Transition> enabledTransitions){ + System.out.println("Calling onMarkingChangeInternal"); + TransitionSelectionResult res = onMarkingChange(enabledTransitions); getTransitionSelectionResult(res); } private void onSignalChangeInternal(Set<Transition> enabledTransitions){ + System.out.println("Calling onSignalChangeInternal"); + TransitionSelectionResult res = onSignalChange(enabledTransitions); getTransitionSelectionResult(res); @@ -129,6 +135,8 @@ public abstract class DiNeRosNode extends AbstractNodeMain { private void onWaitEndedInternal(Set<Transition> enabledTransitions){ + System.out.println("Calling onWaitEndedInternal"); + TransitionSelectionResult res = onWaitEnded(enabledTransitions); getTransitionSelectionResult(res); diff --git a/src/main/java/de/tudresden/inf/st/pnml/engine/testNodes/DinerosTestNode.java b/src/main/java/de/tudresden/inf/st/pnml/engine/testNodes/DinerosTestNode.java index a8c6d24c99a4ce44047ad65db312f95088874ccc..d00b700555c65b59cfcdd8c20c7b3b6a2fa16a69 100644 --- a/src/main/java/de/tudresden/inf/st/pnml/engine/testNodes/DinerosTestNode.java +++ b/src/main/java/de/tudresden/inf/st/pnml/engine/testNodes/DinerosTestNode.java @@ -39,37 +39,46 @@ public class DinerosTestNode extends DiNeRosNode { } @NotNull - private FiringSelectionSuccess fireFirstEnabled(Set<Transition> enabledTransitions) { + private TransitionSelectionResult fireFirstEnabled(Set<Transition> enabledTransitions) { + + System.out.println("Calling fireFirstEnabled"); FiringSelectionSuccess fsc = new FiringSelectionSuccess(); for(Transition t : enabledTransitions){ System.out.println("Firing transition: " + t.getId()); - System.out.println(marking.print()); - System.out.println("-------------------------------"); + //System.out.println(marking.print()); fsc.setTransition(t); break; } + if(enabledTransitions.size() == 0){ + return new FiringSelectionFail(); + } + return fsc; } @Override protected TransitionSelectionResult onMarkingChange(Set<Transition> enabledTransitions) { + System.out.println("Calling onMarkingChange"); return fireFirstEnabled(enabledTransitions); } @Override protected TransitionSelectionResult onSignalChange(Set<Transition> enabledTransitions) { + System.out.println("Calling onSignalChange"); return fireFirstEnabled(enabledTransitions); } @Override protected TransitionSelectionResult onWaitEnded(Set<Transition> enabledTransitions) { + System.out.println("Calling onWaitEnded"); return fireFirstEnabled(enabledTransitions); } @Override protected TransitionSelectionResult onStartupEnded(Set<Transition> enabledTransitions) { + System.out.println("Calling onStartupEnded"); return fireFirstEnabled(enabledTransitions); } } diff --git a/src/main/java/de/tudresden/inf/st/pnml/engine/transform/PetriNetInitializer.java b/src/main/java/de/tudresden/inf/st/pnml/engine/transform/PetriNetInitializer.java index 5e87d504271ad063f349c71bce44ff63d721f519..0f44f6f41ec480db8a18dc9ab7171d5a9f989fb3 100644 --- a/src/main/java/de/tudresden/inf/st/pnml/engine/transform/PetriNetInitializer.java +++ b/src/main/java/de/tudresden/inf/st/pnml/engine/transform/PetriNetInitializer.java @@ -1,5 +1,7 @@ package de.tudresden.inf.st.pnml.engine.transform; +import de.tudresden.inf.st.pnml.engine.ros.DiNeRosNode; +import de.tudresden.inf.st.pnml.engine.testNodes.DinerosTestNode; import de.tudresden.inf.st.pnml.jastadd.model.*; import java.io.IOException; @@ -75,26 +77,33 @@ public class PetriNetInitializer { target.setMutableTransitionInformation(tri); } - public static void initInputSignalConnections(PetriNet petriNet, String host, String protocol, InputSignalConnector inputSignalConnector) throws IOException { + public static void initInputSignalConnections(PetriNet petriNet, String host, String protocol, InputSignalConnector inputSignalConnector, DiNeRosNode node) throws IOException { + for(String signalId : petriNet.getInputSignalDefinition().keySet()){ + // mqtt connections SignalConnection sc = new SignalConnection(); sc.setCurrentValue(Boolean.parseBoolean(petriNet.getInputSignalDefinition().get(signalId))); sc.setId(signalId); inputSignalConnector.addSignalConnection(sc); sc.connectCurrentValue(protocol + "://" + host + "/" + signalId); + + // internal java connections + sc.connectCurrentValue("java://localhost:00/" + signalId, false); + inputSignalConnector.ragconnectJavaRegisterConsumer("java://localhost:00/" + signalId, + bytes -> node.notify(DiNeRosNode.NOTIFICATION_SIGNAL_CHANGE)); } } - public void init(PetriNet petriNet, String host, String protocol, InputSignalConnector isc){ + public void init(PetriNet petriNet, String host, String protocol, InputSignalConnector isc, DiNeRosNode node){ for(Transition t : petriNet.allTransitions()){ initMutableTransitionInformation(null, t, t.asDinerosTransition()); } try { - initInputSignalConnections(petriNet, host, protocol, isc); + initInputSignalConnections(petriNet, host, protocol, isc, node); } catch (IOException e) { e.printStackTrace(); } diff --git a/src/main/resources/nets/NodeNetSignalTest.pnml b/src/main/resources/nets/NodeNetSignalTest.pnml new file mode 100644 index 0000000000000000000000000000000000000000..ee31ce70c7df54634cd5cc4522df82be2198f3f1 --- /dev/null +++ b/src/main/resources/nets/NodeNetSignalTest.pnml @@ -0,0 +1,84 @@ +<?xml version="1.0" encoding="UTF-8"?> +<pnml + xmlns="http://www.pnml.org/version-2009/grammar/pnml"> + <net id="NodeNetTest-1" type="http://www.pnml.org/version-2009/grammar/ptnet"> + <name> + <text>NodeNetTest-1</text> + </name> + <toolspecific tool="de.tudresden.inf.st.pnml.distributedPN" version="0.1"> + <inputsignals> + <inputsignal> + <inputsignalID>is1</inputsignalID> + <initialvalue>false</initialvalue> + </inputsignal> + </inputsignals> + </toolspecific> + + <page id="top"> + <page id="sourcePage"> + <place id="p1"> + <toolspecific tool="de.tudresden.inf.st.pnml.distributedPN" version="0.1"> + <node>n1</node> + <subnet>s1</subnet> + <balloonMarking> + <tokens> + <token> { "id" : "red1", "target" : "binRed" } </token> + </tokens> + </balloonMarking> + </toolspecific> + <initialMarking> + <text>1</text> + </initialMarking> + <name> + <text>p1</text> + <graphics> + <offset x="0" y="0" /> + </graphics> + </name> + <graphics> + <position x="0" y="0" /> + </graphics> + </place> + <place id="p2"> + <toolspecific tool="de.tudresden.inf.st.pnml.distributedPN" version="0.1"> + <node>n1</node> + <subnet>s1</subnet> + </toolspecific> + <name> + <text>p2</text> + <graphics> + <offset x="0" y="0" /> + </graphics> + </name> + <graphics> + <position x="0" y="0" /> + </graphics> + </place> + + <transition id="t1"> + <toolspecific tool="de.tudresden.inf.st.pnml.distributedPN" version="0.1"> + <node>n1</node> + <subnet>s1</subnet> + <inputsignalbinding> + </inputsignalbinding> + <inputsignalclause>is1</inputsignalclause> + </toolspecific> + <name> + <text>t1</text> + <graphics> + <offset x="0" y="0" /> + </graphics> + </name> + <graphics> + <position x="0" y="0" /> + </graphics> + </transition> + + <arc id="a1" source="p1" target="t1"> + </arc> + <arc id="a2" source="t1" target="p2"> + </arc> + </page> + </page> + </net> +</pnml> \ No newline at end of file diff --git a/src/main/resources/nets/NodeNetTest.pnml b/src/main/resources/nets/NodeNetTest.pnml index 0791de592471b818b7603ca5e715d0f8498954fd..894f7fe77f947f06605828f12046d42df2ab205e 100644 --- a/src/main/resources/nets/NodeNetTest.pnml +++ b/src/main/resources/nets/NodeNetTest.pnml @@ -3,7 +3,7 @@ xmlns="http://www.pnml.org/version-2009/grammar/pnml"> <net id="NodeNetTest-0" type="http://www.pnml.org/version-2009/grammar/ptnet"> <name> - <text>TopicNet</text> + <text>NodeNetTest-0</text> </name> <toolspecific tool="de.tudresden.inf.st.pnml.distributedPN" version="0.1"> <inputsignals>