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{
}
BalloonMarkedPlace bmp=this.resolveBalloonPlace(place);
org.ros.node.topic.Publisher<std_msgs.String> pub = node.getPublisherByPlaceId(place.getId());
if(pub != null) {
std_msgs.String msg = pub.newMessage();
msg.setData(result.getValue());
pub.publish(msg);
} else {
result.setCreationTime(System.currentTimeMillis());
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){
// flush the entire marking tree
this.flushTreeCache();
......
......@@ -127,38 +127,47 @@ public abstract class DiNeRosNode extends AbstractNodeMain {
switch (event.eventType) {
case DiNeRosEventTypes.NOTIFICATION_MARKING_CHANGE:
System.out.println("NOTIFICATION_MARKING_CHANGE");
onChangeInternal(signalFilteredTransitions);
break;
case DiNeRosEventTypes.NOTIFICATION_SIGNAL_CHANGE:
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);
System.out.println("NOTIFICATION_SIGNAL_CHANGE");
handleSignalChange(event);
onChangeInternal(signalFilteredTransitions);
break;
case DiNeRosEventTypes.NOTIFICATION_STARTUP_ENDED:
System.out.println("NOTIFICATION_STARTUP_ENDED");
onStartupEndedInternal(signalFilteredTransitions);
break;
case DiNeRosEventTypes.NOTIFICATION_SERVICE_REQ_CLIENT:
System.out.println("NOTIFICATION_SERVICE_REQ_CLIENT");
onServiceRequestAvailableOnClientSide(event.payload);
break;
case DiNeRosEventTypes.NOTIFICATION_TOPIC_PUB:
System.out.println("NOTIFICATION_TOPIC_PUB");
onTopicPublisherAvailable(event.payload);
break;
case DiNeRosEventTypes.NOTIFICATION_SERVICE_RES_SERVER:
System.out.println("NOTIFICATION_SERVICE_RES_SERVER");
onServiceResponseAvailableOnServerSide(event.payload);
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) {
java.lang.String[] split = placeId.split("-INSTANCE-");
......@@ -166,11 +175,11 @@ public abstract class DiNeRosNode extends AbstractNodeMain {
java.lang.String topicName = petriNet.getPortNameByPlaceId(originalId, PnmlConstants.CHANNEL_PLACE_TYPE_PUB_KEY);
Place place = petriNet.getPlaceById(placeId);
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(),
this.connectedNode, getPublisherByPlaceId(placeId));
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();
petriNet.flushTreeCache();
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