Skip to content
Snippets Groups Projects
Commit 5e0e8c88 authored by Sebastian Ebert's avatar Sebastian Ebert
Browse files

simplified exec, fixed tracing of pubs

parent 6546e508
No related branches found
No related tags found
No related merge requests found
...@@ -152,24 +152,16 @@ aspect BalloonExecution{ ...@@ -152,24 +152,16 @@ aspect BalloonExecution{
} }
BalloonMarkedPlace bmp=this.resolveBalloonPlace(place); BalloonMarkedPlace bmp=this.resolveBalloonPlace(place);
org.ros.node.topic.Publisher<std_msgs.String> pub = node.getPublisherByPlaceId(place.getId()); org.ros.node.topic.Publisher<std_msgs.String> pub = node.getPublisherByPlaceId(place.getId());
if(pub != null) { if(pub != null) {
std_msgs.String msg = pub.newMessage();
msg.setData(result.getValue());
pub.publish(msg);
} else {
result.setCreationTime(System.currentTimeMillis()); result.setCreationTime(System.currentTimeMillis());
bmp.getBalloonMarkingList().add(result); bmp.getBalloonMarkingList().add(result);
connectedToPubPlace = true;
connectedPubPlaceId = place.getId();
} }
} }
// for(BalloonToken delToken : inToken){
// System.out.println("[Engine] Removing token: " + delToken.getValue());
// delToken.removeSelf();
// }
if(requireFlush){ if(requireFlush){
// flush the entire marking tree // flush the entire marking tree
this.flushTreeCache(); this.flushTreeCache();
......
...@@ -127,38 +127,47 @@ public abstract class DiNeRosNode extends AbstractNodeMain { ...@@ -127,38 +127,47 @@ public abstract class DiNeRosNode extends AbstractNodeMain {
switch (event.eventType) { switch (event.eventType) {
case DiNeRosEventTypes.NOTIFICATION_MARKING_CHANGE: case DiNeRosEventTypes.NOTIFICATION_MARKING_CHANGE:
System.out.println("NOTIFICATION_MARKING_CHANGE");
onChangeInternal(signalFilteredTransitions); onChangeInternal(signalFilteredTransitions);
break; break;
case DiNeRosEventTypes.NOTIFICATION_SIGNAL_CHANGE: case DiNeRosEventTypes.NOTIFICATION_SIGNAL_CHANGE:
System.out.println("NOTIFICATION_SIGNAL_CHANGE");
Boolean newVal = false; handleSignalChange(event);
for(SignalConnection sc : this.inputSignalConnector.getSignalConnections()){
if(sc.getId().equals(event.payload)){
newVal = sc.getCurrentValue();
}
}
TracePublishing.publish(TracePublishing.TraceTypeSignalChanged,
this.getDefaultNodeName()+ " " + event.payload + " " + newVal,
this.connectedNode, this.tracePublisher);
onChangeInternal(signalFilteredTransitions); onChangeInternal(signalFilteredTransitions);
break; break;
case DiNeRosEventTypes.NOTIFICATION_STARTUP_ENDED: case DiNeRosEventTypes.NOTIFICATION_STARTUP_ENDED:
System.out.println("NOTIFICATION_STARTUP_ENDED");
onStartupEndedInternal(signalFilteredTransitions); onStartupEndedInternal(signalFilteredTransitions);
break; break;
case DiNeRosEventTypes.NOTIFICATION_SERVICE_REQ_CLIENT: case DiNeRosEventTypes.NOTIFICATION_SERVICE_REQ_CLIENT:
System.out.println("NOTIFICATION_SERVICE_REQ_CLIENT");
onServiceRequestAvailableOnClientSide(event.payload); onServiceRequestAvailableOnClientSide(event.payload);
break; break;
case DiNeRosEventTypes.NOTIFICATION_TOPIC_PUB: case DiNeRosEventTypes.NOTIFICATION_TOPIC_PUB:
System.out.println("NOTIFICATION_TOPIC_PUB");
onTopicPublisherAvailable(event.payload); onTopicPublisherAvailable(event.payload);
break; break;
case DiNeRosEventTypes.NOTIFICATION_SERVICE_RES_SERVER: case DiNeRosEventTypes.NOTIFICATION_SERVICE_RES_SERVER:
System.out.println("NOTIFICATION_SERVICE_RES_SERVER");
onServiceResponseAvailableOnServerSide(event.payload); onServiceResponseAvailableOnServerSide(event.payload);
break; break;
} }
} }
private void handleSignalChange(DiNeRosEvent event) {
Boolean newVal = false;
for(SignalConnection sc : this.inputSignalConnector.getSignalConnections()){
if(sc.getId().equals(event.payload)){
newVal = sc.getCurrentValue();
}
}
TracePublishing.publish(TracePublishing.TraceTypeSignalChanged,
this.getDefaultNodeName()+ " " + event.payload + " " + newVal,
this.connectedNode, this.tracePublisher);
}
private void onTopicPublisherAvailable(java.lang.String placeId) { private void onTopicPublisherAvailable(java.lang.String placeId) {
java.lang.String[] split = placeId.split("-INSTANCE-"); java.lang.String[] split = placeId.split("-INSTANCE-");
...@@ -166,11 +175,11 @@ public abstract class DiNeRosNode extends AbstractNodeMain { ...@@ -166,11 +175,11 @@ public abstract class DiNeRosNode extends AbstractNodeMain {
java.lang.String topicName = petriNet.getPortNameByPlaceId(originalId, PnmlConstants.CHANNEL_PLACE_TYPE_PUB_KEY); java.lang.String topicName = petriNet.getPortNameByPlaceId(originalId, PnmlConstants.CHANNEL_PLACE_TYPE_PUB_KEY);
Place place = petriNet.getPlaceById(placeId); Place place = petriNet.getPlaceById(placeId);
BalloonMarkedPlace bmp = this.marking.resolveBalloonPlace(place); BalloonMarkedPlace bmp = this.marking.resolveBalloonPlace(place);
TracePublishing.publish(TracePublishing.TraceTypeTopicSend,
this.nodeName + " " + topicName + " " + placeId, this.connectedNode, this.tracePublisher);
RosCommunicationUtil.publish(topicName, bmp.getBalloonMarking(0).getValue().getBytes(), RosCommunicationUtil.publish(topicName, bmp.getBalloonMarking(0).getValue().getBytes(),
this.connectedNode, getPublisherByPlaceId(placeId)); this.connectedNode, getPublisherByPlaceId(placeId));
System.out.println("[DiNeROS-Node] [" + nodeName + "] Published msg: " + bmp.getBalloonMarking(0).getValue()); System.out.println("[DiNeROS-Node] [" + nodeName + "] Published msg: " + bmp.getBalloonMarking(0).getValue());
TracePublishing.publish(TracePublishing.TraceTypeTopicSend,
this.nodeName + " " + topicName + "-" + placeId, this.connectedNode, this.tracePublisher);
bmp.getBalloonMarking(0).removeSelf(); bmp.getBalloonMarking(0).removeSelf();
petriNet.flushTreeCache(); petriNet.flushTreeCache();
this.notify(new DiNeRosEvent(DiNeRosEventTypes.NOTIFICATION_MARKING_CHANGE)); this.notify(new DiNeRosEvent(DiNeRosEventTypes.NOTIFICATION_MARKING_CHANGE));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment