Skip to content
Snippets Groups Projects
Commit 3b49d047 authored by Johannes Mey's avatar Johannes Mey
Browse files

update the specialized variant to use the preprocessor

parent 7c51c3ed
Branches
No related tags found
No related merge requests found
Showing
with 124 additions and 117 deletions
Source diff could not be displayed: it is too large. Options to address this: view the blob.
Source diff could not be displayed: it is too large. Options to address this: view the blob.
Source diff could not be displayed: it is too large. Options to address this: view the blob.
Source diff could not be displayed: it is too large. Options to address this: view the blob.
Source diff could not be displayed: it is too large. Options to address this: view the blob.
Source diff could not be displayed: it is too large. Options to address this: view the blob.
...@@ -106,7 +106,7 @@ public class Json4AgSpecialSerializer extends ModelSerializer<Json4AgSpecialGene ...@@ -106,7 +106,7 @@ public class Json4AgSpecialSerializer extends ModelSerializer<Json4AgSpecialGene
// SwitchPosition // SwitchPosition
n.createListChild(Children.SWITCHPOSITION); n.createListChild(Children.SWITCHPOSITION);
// ManagedRequiredSensors // _impl_RequiredSensors
n.createIntrinsicRefListChild(Children.REQUIREDSENSOR); n.createIntrinsicRefListChild(Children.REQUIREDSENSOR);
// Entry // Entry
...@@ -134,26 +134,26 @@ public class Json4AgSpecialSerializer extends ModelSerializer<Json4AgSpecialGene ...@@ -134,26 +134,26 @@ public class Json4AgSpecialSerializer extends ModelSerializer<Json4AgSpecialGene
n.addChild(Children.POSITION, new ASTEnum(Values.ENUM_POSITION, attributes.get(POSITION))); n.addChild(Children.POSITION, new ASTEnum(Values.ENUM_POSITION, attributes.get(POSITION)));
} }
// ManagedTarget // _impl_Target
if (outgoingEdges.containsKey(TARGET)) { if (outgoingEdges.containsKey(TARGET)) {
n.addChild(Children.TARGET, new ASTIntrinsicRef(Grammar.SWITCH, (ASTNonterminal)outgoingEdges.get(TARGET))); n.addChild(Children.TARGET, new ASTIntrinsicRef(Grammar.SWITCH, (ASTNonterminal)outgoingEdges.get(TARGET)));
} }
break; break;
case SENSOR: case SENSOR:
// ManagedMonitors // _impl_Monitors
n.createIntrinsicRefListChild(Children.MONITOREDELEMENT); n.createIntrinsicRefListChild(Children.MONITOREDELEMENT);
// ManagedRequiringRoutes // _impl_RequiringRoutes
n.createIntrinsicRefListChild(Children.REQUIRINGROUTE); n.createIntrinsicRefListChild(Children.REQUIRINGROUTE);
break; break;
case SEGMENT: case SEGMENT:
// ManagedMonitoredBy // _impl_MonitoredBy
n.createIntrinsicRefListChild(Children.MONITOREDBY); n.createIntrinsicRefListChild(Children.MONITOREDBY);
// ManagedConnectsTo // _impl_ConnectsTo
n.createIntrinsicRefListChild(Children.CONNECTSTO); n.createIntrinsicRefListChild(Children.CONNECTSTO);
// Length // Length
...@@ -167,10 +167,10 @@ public class Json4AgSpecialSerializer extends ModelSerializer<Json4AgSpecialGene ...@@ -167,10 +167,10 @@ public class Json4AgSpecialSerializer extends ModelSerializer<Json4AgSpecialGene
break; break;
case SWITCH: case SWITCH:
// ManagedMonitoredBy // _impl_MonitoredBy
n.createIntrinsicRefListChild(Children.MONITOREDBY); n.createIntrinsicRefListChild(Children.MONITOREDBY);
// ManagedConnectsTo // _impl_ConnectsTo
n.createIntrinsicRefListChild(Children.CONNECTSTO); n.createIntrinsicRefListChild(Children.CONNECTSTO);
// CurrentPosition // CurrentPosition
...@@ -178,7 +178,7 @@ public class Json4AgSpecialSerializer extends ModelSerializer<Json4AgSpecialGene ...@@ -178,7 +178,7 @@ public class Json4AgSpecialSerializer extends ModelSerializer<Json4AgSpecialGene
n.addChild(Children.POSITION, new ASTEnum(Values.ENUM_POSITION, attributes.get(POSITION))); n.addChild(Children.POSITION, new ASTEnum(Values.ENUM_POSITION, attributes.get(POSITION)));
} }
// ManagedPositions // _impl_Positions
n.createIntrinsicRefListChild(Children.POSITIONS); n.createIntrinsicRefListChild(Children.POSITIONS);
break; break;
default: default:
...@@ -262,21 +262,20 @@ public class Json4AgSpecialSerializer extends ModelSerializer<Json4AgSpecialGene ...@@ -262,21 +262,20 @@ public class Json4AgSpecialSerializer extends ModelSerializer<Json4AgSpecialGene
static final String SIGNAL = "Signal"; static final String SIGNAL = "Signal";
static final String ACTIVE = "Active"; static final String ACTIVE = "Active";
static final String SWITCHPOSITION = "SwitchPosition"; static final String SWITCHPOSITION = "SwitchPosition";
static final String REQUIREDSENSOR = "ManagedRequiredSensors"; static final String REQUIREDSENSOR = "_impl_requires";
static final String REQUIRINGROUTE = "ManagedRequiringRoutes"; static final String REQUIRINGROUTE = "_impl_requiredBy";
static final String ENTRY = "ManagedEntry"; static final String ENTRY = "_impl_entry";
static final String EXIT = "ManagedExit"; static final String EXIT = "_impl_exit";
static final String POSITION = "Position"; static final String POSITION = "Position";
static final String POSITIONS = "ManagedPositions"; static final String POSITIONS = "_impl_positions";
static final String TARGET = "ManagedTarget"; static final String TARGET = "_impl_target";
static final String MONITOREDSENSOR = "ManagedMonitoredBy"; static final String MONITOREDELEMENT = "_impl_monitors";
static final String MONITOREDELEMENT = "ManagedMonitors"; static final String CONNECTSTO = "_impl_connectsTo";
static final String CONNECTSTO = "ManagedConnectsTo";
static final String LENGTH = "Length"; static final String LENGTH = "Length";
static final String SEMAPHORE = "Semaphore"; static final String SEMAPHORE = "Semaphore";
static final String CURRENTPOSITION = "CurrentPosition"; static final String CURRENTPOSITION = "CurrentPosition";
static final String VALUE = "Value"; static final String VALUE = "Value";
static final String MONITOREDBY = "ManagedMonitoredBy"; static final String MONITOREDBY = "_impl_monitoredBy";
} }
static class Values { static class Values {
......
*Gen.ast
*Gen.jadd
\ No newline at end of file
aspect RefList {
public class RefList<T extends ASTNode> extends java.util.ArrayList<T> {}
}
...@@ -11,7 +11,7 @@ abstract TrackElement : RailwayElement; ...@@ -11,7 +11,7 @@ abstract TrackElement : RailwayElement;
Segment : TrackElement ::= <Length:int> Semaphore*; Segment : TrackElement ::= <Length:int> Semaphore*;
Switch : TrackElement ::= <CurrentPosition:Position>; Switch : TrackElement ::= <CurrentPosition:Position>;
rel Route.requires* -> Sensor; rel Route.requires* <-> Sensor.requiredBy*;
rel Route.entry? -> Semaphore; rel Route.entry? -> Semaphore;
rel Route.exit? -> Semaphore; rel Route.exit? -> Semaphore;
rel Sensor.monitors* <-> TrackElement.monitoredBy*; rel Sensor.monitors* <-> TrackElement.monitoredBy*;
......
...@@ -55,7 +55,7 @@ aspect TreeNavigation { ...@@ -55,7 +55,7 @@ aspect TreeNavigation {
syn Collection<Segment> Sensor.monitoredSegments() { syn Collection<Segment> Sensor.monitoredSegments() {
java.util.List<Segment> segments = new ArrayList<>(); java.util.List<Segment> segments = new ArrayList<>();
for (TrackElement trackElement : getMonitoredElementList()) { for (TrackElement trackElement : monitors()) {
Segment segment = trackElement.asSegment(); Segment segment = trackElement.asSegment();
if (segment != null) { if (segment != null) {
segments.add(segment); segments.add(segment);
...@@ -66,7 +66,7 @@ aspect TreeNavigation { ...@@ -66,7 +66,7 @@ aspect TreeNavigation {
syn Collection<Switch> Sensor.monitoredSwitches() { syn Collection<Switch> Sensor.monitoredSwitches() {
java.util.List<Switch> switches = new ArrayList<>(); java.util.List<Switch> switches = new ArrayList<>();
for (TrackElement trackElement : getMonitoredElementList()) { for (TrackElement trackElement : monitors()) {
Switch sw = trackElement.asSwitch(); Switch sw = trackElement.asSwitch();
if (sw != null) { if (sw != null) {
switches.add(sw); switches.add(sw);
...@@ -77,7 +77,7 @@ aspect TreeNavigation { ...@@ -77,7 +77,7 @@ aspect TreeNavigation {
syn Collection<Segment> TrackElement.connectsToSegments() { syn Collection<Segment> TrackElement.connectsToSegments() {
java.util.List<Segment> segments = new ArrayList<>(); java.util.List<Segment> segments = new ArrayList<>();
for (TrackElement trackElement : getConnectsToList()) { for (TrackElement trackElement : connectsTo()) {
Segment segment = trackElement.asSegment(); Segment segment = trackElement.asSegment();
if (segment != null) { if (segment != null) {
segments.add(segment); segments.add(segment);
......
...@@ -63,7 +63,7 @@ aspect Queries { ...@@ -63,7 +63,7 @@ aspect Queries {
} }
syn boolean Sensor.monitors(Segment segment) { syn boolean Sensor.monitors(Segment segment) {
for (TrackElement trackElement : getMonitoredElements()) { for (TrackElement trackElement : monitors()) {
if (trackElement == segment) { if (trackElement == segment) {
return true; return true;
} }
......
...@@ -12,12 +12,11 @@ aspect Queries { ...@@ -12,12 +12,11 @@ aspect Queries {
java.util.List<JastaddRouteSensorMatch> matches = new java.util.ArrayList<>(); java.util.List<JastaddRouteSensorMatch> matches = new java.util.ArrayList<>();
// if the route follows a switch and this switch has is monitored by a sensor // if the route follows a switch and this switch has is monitored by a sensor
RefList<Sensor> requiredSensors = getRequiredSensorList();
for (SwitchPosition sp : getSwitchPositionList()) { for (SwitchPosition sp : getSwitchPositionList()) {
Switch sw = sp.target(); Switch sw = sp.target();
for (Sensor sensor : sw.getMonitoringSensorList()) { for (Sensor sensor : sw.monitoredBy()) {
boolean validSensor = false; boolean validSensor = false;
for (Sensor sensor2 : requiredSensors) { for (Sensor sensor2 : requires()) {
if (sensor2 == sensor) { if (sensor2 == sensor) {
validSensor = true; validSensor = true;
break; break;
...@@ -41,7 +40,7 @@ aspect Queries { ...@@ -41,7 +40,7 @@ aspect Queries {
syn Collection<JastaddRouteSensorInjectMatch> Route.routeSensorInjectMatches() { syn Collection<JastaddRouteSensorInjectMatch> Route.routeSensorInjectMatches() {
java.util.List<JastaddRouteSensorInjectMatch> matches = new ArrayList<JastaddRouteSensorInjectMatch>(); java.util.List<JastaddRouteSensorInjectMatch> matches = new ArrayList<JastaddRouteSensorInjectMatch>();
for (Sensor sensor: getRequiredSensorList()) { for (Sensor sensor: requires()) {
matches.add(new JastaddRouteSensorInjectMatch(this, sensor)); matches.add(new JastaddRouteSensorInjectMatch(this, sensor));
} }
return matches; return matches;
......
...@@ -16,11 +16,11 @@ aspect Queries { ...@@ -16,11 +16,11 @@ aspect Queries {
Semaphore exitSemaphore = this.exit(); Semaphore exitSemaphore = this.exit();
// get the sensors of the route // get the sensors of the route
for (Sensor sensor1 : this.getRequiredSensorList()) { for (Sensor sensor1 : this.requires()) {
for (TrackElement te1 : sensor1.getMonitoredElementList()) { for (TrackElement te1 : sensor1.monitors()) {
for (TrackElement te2 : te1.getConnectsToList()) { for (TrackElement te2 : te1.connectsTo()) {
for (Sensor sensor2 : te2.getMonitoringSensorList()) { for (Sensor sensor2 : te2.monitoredBy()) {
for (Route route2 : sensor2.getRequiringRouteList()) { for (Route route2 : sensor2.requiredBy()) {
if (this != route2) { if (this != route2) {
if (route2.entry() == null || route2.entry() != exitSemaphore) { if (route2.entry() == null || route2.entry() != exitSemaphore) {
matches.add(new JastaddSemaphoreNeighborMatch(exitSemaphore, this, route2, sensor1, sensor2, te1, te2)); matches.add(new JastaddSemaphoreNeighborMatch(exitSemaphore, this, route2, sensor1, sensor2, te1, te2));
......
...@@ -11,7 +11,7 @@ aspect Queries { ...@@ -11,7 +11,7 @@ aspect Queries {
syn java.util.Collection<Switch> Region.switchMonitoredMatches() { syn java.util.Collection<Switch> Region.switchMonitoredMatches() {
java.util.List<Switch> matches = new java.util.ArrayList<>(); java.util.List<Switch> matches = new java.util.ArrayList<>();
for (Switch sw : switches()) { for (Switch sw : switches()) {
if (sw.getMonitoringSensorList().numChildren() == 0) { if (sw.monitoredBy().isEmpty()) {
matches.add(sw); matches.add(sw);
} }
} }
......
RailwayContainer ::= Route* Region* ;
abstract RailwayElement ::= <Id:int> ;
Region:RailwayElement ::= TrackElement* Sensor* ;
Semaphore:RailwayElement ::= <Signal:Signal> ;
Route:RailwayElement ::= <Active:boolean> SwitchPosition* ManagedRequiredSensors:RefList <ManagedEntry:Semaphore> <ManagedExit:Semaphore>;
SwitchPosition:RailwayElement ::= <Position:Position> <ManagedTarget:Switch> ;
Sensor:RailwayElement ::= ManagedMonitors:RefList ManagedRequiringRoutes:RefList ;
abstract TrackElement:RailwayElement ::= ManagedMonitoredBy:RefList ManagedConnectsTo:RefList ;
Segment:TrackElement ::= <Length:int> Semaphore* ;
Switch:TrackElement ::= <CurrentPosition:Position> ManagedPositions:RefList ;
RefList:List ::= ;
...@@ -4,16 +4,14 @@ import com.fasterxml.jackson.core.JsonParser; ...@@ -4,16 +4,14 @@ import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.deser.std.StdDeserializer; import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
import de.tudresden.inf.st.train.jastadd.ast.*;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator;
import java.util.Map; import java.util.Map;
import de.tudresden.inf.st.train.jastadd.ast.*;
/** /**
* Created by jm on 5/15/17. * Created by jm on 5/15/17.
*/ */
...@@ -61,15 +59,15 @@ public class ASTNodeDeserializer extends StdDeserializer<ASTNode> { ...@@ -61,15 +59,15 @@ public class ASTNodeDeserializer extends StdDeserializer<ASTNode> {
super(vc); super(vc);
} }
private java.util.List<IM<Route>> listRouteManagedRequiredSensors = new ArrayList<>(); private java.util.List<IM<Route>> listRoute_impl_requires = new ArrayList<>();
private java.util.List<IM<Route>> listRouteManagedEntry = new ArrayList<>(); private java.util.List<IM<Route>> listRoute_impl_entry = new ArrayList<>();
private java.util.List<IM<Route>> listRouteManagedExit = new ArrayList<>(); private java.util.List<IM<Route>> listRoute_impl_exit = new ArrayList<>();
private java.util.List<IM<SwitchPosition>> listSwitchPositionManagedTarget = new ArrayList<>(); private java.util.List<IM<SwitchPosition>> listSwitchPosition_impl_target = new ArrayList<>();
private java.util.List<IM<Sensor>> listSensorManagedMonitors = new ArrayList<>(); private java.util.List<IM<Sensor>> listSensor_impl_monitors = new ArrayList<>();
private java.util.List<IM<Sensor>> listSensorManagedRequiringRoutes = new ArrayList<>(); private java.util.List<IM<Sensor>> listSensor_impl_requiredBy = new ArrayList<>();
private java.util.List<IM<TrackElement>> listTrackElementManagedMonitoredBy = new ArrayList<>(); private java.util.List<IM<TrackElement>> listTrackElement_impl_monitoredBy = new ArrayList<>();
private java.util.List<IM<TrackElement>> listTrackElementManagedConnectsTo = new ArrayList<>(); private java.util.List<IM<TrackElement>> listTrackElement_impl_connectsTo = new ArrayList<>();
private java.util.List<IM<Switch>> listSwitchManagedPositions = new ArrayList<>(); private java.util.List<IM<Switch>> listSwitch_impl_positions = new ArrayList<>();
private Map<Integer, ASTNode> idMap = new HashMap<>(); private Map<Integer, ASTNode> idMap = new HashMap<>();
...@@ -80,56 +78,74 @@ public class ASTNodeDeserializer extends StdDeserializer<ASTNode> { ...@@ -80,56 +78,74 @@ public class ASTNodeDeserializer extends StdDeserializer<ASTNode> {
JsonNode node = jp.getCodec().readTree(jp); JsonNode node = jp.getCodec().readTree(jp);
RailwayContainer result = deserializeRailwayContainer(node); RailwayContainer result = deserializeRailwayContainer(node);
for (IM<Route> e : listRouteManagedRequiredSensors) { for (IM<Route> e : listRoute_impl_requires) {
if (idMap.get(e.getRef()) == null) { if (idMap.get(e.getRef()) == null) {
throw new DeserializationException(); throw new DeserializationException();
} }
e.getNode().getManagedRequiredSensors().add((Sensor)idMap.get(e.getRef())); if (e.getNode().get_impl_requires() == null) {
e.getNode().set_impl_requires(new RefList<>());
} }
for (IM<Route> e : listRouteManagedEntry) { e.getNode().get_impl_requires().add((Sensor)idMap.get(e.getRef()));
}
for (IM<Route> e : listRoute_impl_entry) {
if (idMap.get(e.getRef()) == null) { if (idMap.get(e.getRef()) == null) {
throw new DeserializationException(); throw new DeserializationException();
} }
e.getNode().setManagedEntry((Semaphore)idMap.get(e.getRef())); e.getNode().set_impl_entry((Semaphore)idMap.get(e.getRef()));
} }
for (IM<Route> e : listRouteManagedExit) { for (IM<Route> e : listRoute_impl_exit) {
e.getNode().setManagedExit((Semaphore)idMap.get(e.getRef())); e.getNode().set_impl_exit((Semaphore)idMap.get(e.getRef()));
} }
for (IM<SwitchPosition> e : listSwitchPositionManagedTarget) { for (IM<SwitchPosition> e : listSwitchPosition_impl_target) {
if (idMap.get(e.getRef()) == null) { if (idMap.get(e.getRef()) == null) {
throw new DeserializationException(); throw new DeserializationException();
} }
e.getNode().setManagedTarget((Switch)idMap.get(e.getRef())); e.getNode().set_impl_target((Switch)idMap.get(e.getRef()));
} }
for (IM<Sensor> e : listSensorManagedMonitors) { for (IM<Sensor> e : listSensor_impl_monitors) {
if (idMap.get(e.getRef()) == null) { if (idMap.get(e.getRef()) == null) {
throw new DeserializationException(); throw new DeserializationException();
} }
e.getNode().getManagedMonitors().add((TrackElement)idMap.get(e.getRef())); if (e.getNode().get_impl_monitors() == null) {
e.getNode().set_impl_monitors(new RefList<>());
}
e.getNode().get_impl_monitors().add((TrackElement)idMap.get(e.getRef()));
} }
for (IM<Sensor> e : listSensorManagedRequiringRoutes) { for (IM<Sensor> e : listSensor_impl_requiredBy) {
if (idMap.get(e.getRef()) == null) { if (idMap.get(e.getRef()) == null) {
throw new DeserializationException(); throw new DeserializationException();
} }
e.getNode().getManagedRequiringRoutes().add((Route)idMap.get(e.getRef())); if (e.getNode().get_impl_requiredBy() == null) {
e.getNode().set_impl_requiredBy(new RefList<>());
} }
for (IM<TrackElement> e : listTrackElementManagedMonitoredBy) { e.getNode().get_impl_requiredBy().add((Route)idMap.get(e.getRef()));
}
for (IM<TrackElement> e : listTrackElement_impl_monitoredBy) {
if (idMap.get(e.getRef()) == null) { if (idMap.get(e.getRef()) == null) {
throw new DeserializationException(); throw new DeserializationException();
} }
e.getNode().getManagedMonitoredBy().add((Sensor)idMap.get(e.getRef())); if (e.getNode().get_impl_monitoredBy() == null) {
e.getNode().set_impl_monitoredBy(new RefList<>());
}
e.getNode().get_impl_monitoredBy().add((Sensor)idMap.get(e.getRef()));
} }
for (IM<TrackElement> e : listTrackElementManagedConnectsTo) { for (IM<TrackElement> e : listTrackElement_impl_connectsTo) {
if (idMap.get(e.getRef()) == null) { if (idMap.get(e.getRef()) == null) {
throw new DeserializationException(); throw new DeserializationException();
} }
e.getNode().getManagedConnectsTo().add((TrackElement)idMap.get(e.getRef())); if (e.getNode().get_impl_connectsTo() == null) {
e.getNode().set_impl_connectsTo(new RefList<>());
} }
for (IM<Switch> e : listSwitchManagedPositions) { e.getNode().get_impl_connectsTo().add((TrackElement)idMap.get(e.getRef()));
}
for (IM<Switch> e : listSwitch_impl_positions) {
if (idMap.get(e.getRef()) == null) { if (idMap.get(e.getRef()) == null) {
throw new DeserializationException(); throw new DeserializationException();
} }
e.getNode().getManagedPositions().add((SwitchPosition)idMap.get(e.getRef())); if (e.getNode().get_impl_positions() == null) {
e.getNode().set_impl_positions(new RefList<>());
}
e.getNode().get_impl_positions().add((SwitchPosition)idMap.get(e.getRef()));
} }
return result; return result;
...@@ -214,20 +230,20 @@ public class ASTNodeDeserializer extends StdDeserializer<ASTNode> { ...@@ -214,20 +230,20 @@ public class ASTNodeDeserializer extends StdDeserializer<ASTNode> {
instance.addSwitchPosition(deserializeSwitchPosition(child)); instance.addSwitchPosition(deserializeSwitchPosition(child));
} }
// ManagedRequiredSensors // _impl_requires
for (JsonNode child : node.get("c").get("ManagedRequiredSensors").get("c")) { for (JsonNode child : node.get("c").get("_impl_requires").get("c")) {
int ref = child.get("v").asInt(); int ref = child.get("v").asInt();
this.listRouteManagedRequiredSensors.add(new IM<Route>(instance, ref)); this.listRoute_impl_requires.add(new IM<Route>(instance, ref));
} }
// ManagedEntry // _impl_Entry
if (!node.get("c").get("ManagedEntry").get("v").isNull()) { if (!node.get("c").get("_impl_entry").get("v").isNull()) {
this.listRouteManagedEntry.add(new IM<Route>(instance, node.get("c").get("ManagedEntry").get("v").asInt())); this.listRoute_impl_entry.add(new IM<Route>(instance, node.get("c").get("_impl_entry").get("v").asInt()));
} }
/// ManagedExit /// _impl_Exit
if (!node.get("c").get("ManagedExit").get("v").isNull()) { if (!node.get("c").get("_impl_exit").get("v").isNull()) {
this.listRouteManagedExit.add(new IM<Route>(instance, node.get("c").get("ManagedExit").get("v").asInt())); this.listRoute_impl_exit.add(new IM<Route>(instance, node.get("c").get("_impl_exit").get("v").asInt()));
} }
return instance; return instance;
} }
...@@ -255,8 +271,8 @@ public class ASTNodeDeserializer extends StdDeserializer<ASTNode> { ...@@ -255,8 +271,8 @@ public class ASTNodeDeserializer extends StdDeserializer<ASTNode> {
throw new DeserializationException(); throw new DeserializationException();
} }
// ManagedTarget // _impl_Target
this.listSwitchPositionManagedTarget.add(new IM<SwitchPosition>(instance, node.get("c").get("ManagedTarget").get("v").asInt())); this.listSwitchPosition_impl_target.add(new IM<SwitchPosition>(instance, node.get("c").get("_impl_target").get("v").asInt()));
return instance; return instance;
...@@ -270,16 +286,16 @@ public class ASTNodeDeserializer extends StdDeserializer<ASTNode> { ...@@ -270,16 +286,16 @@ public class ASTNodeDeserializer extends StdDeserializer<ASTNode> {
instance.setId(id); instance.setId(id);
idMap.put(id, instance); idMap.put(id, instance);
// ManagedMonitors // _impl_Monitors
for (JsonNode child : node.get("c").get("ManagedMonitors").get("c")) { for (JsonNode child : node.get("c").get("_impl_monitors").get("c")) {
int ref = child.get("v").asInt(); int ref = child.get("v").asInt();
this.listSensorManagedMonitors.add(new IM<Sensor>(instance, ref)); this.listSensor_impl_monitors.add(new IM<Sensor>(instance, ref));
} }
// ManagedRequiringRoutes // _impl_RequiringRoutes
for (JsonNode child : node.get("c").get("ManagedRequiringRoutes").get("c")) { for (JsonNode child : node.get("c").get("_impl_requiredBy").get("c")) {
int ref = child.get("v").asInt(); int ref = child.get("v").asInt();
this.listSensorManagedRequiringRoutes.add(new IM<Sensor>(instance, ref)); this.listSensor_impl_requiredBy.add(new IM<Sensor>(instance, ref));
} }
return instance; return instance;
...@@ -302,16 +318,16 @@ public class ASTNodeDeserializer extends StdDeserializer<ASTNode> { ...@@ -302,16 +318,16 @@ public class ASTNodeDeserializer extends StdDeserializer<ASTNode> {
instance.setId(id); instance.setId(id);
idMap.put(id, instance); idMap.put(id, instance);
// ManagedMonitoredBy // _impl_MonitoredBy
for (JsonNode child : node.get("c").get("ManagedMonitoredBy").get("c")) { for (JsonNode child : node.get("c").get("_impl_monitoredBy").get("c")) {
int ref = child.get("v").asInt(); int ref = child.get("v").asInt();
this.listTrackElementManagedMonitoredBy.add(new IM<TrackElement>(instance, ref)); this.listTrackElement_impl_monitoredBy.add(new IM<TrackElement>(instance, ref));
} }
// ManagedConnectsTo // _impl_ConnectsTo
for (JsonNode child : node.get("c").get("ManagedConnectsTo").get("c")) { for (JsonNode child : node.get("c").get("_impl_connectsTo").get("c")) {
int ref = child.get("v").asInt(); int ref = child.get("v").asInt();
this.listTrackElementManagedConnectsTo.add(new IM<TrackElement>(instance, ref)); this.listTrackElement_impl_connectsTo.add(new IM<TrackElement>(instance, ref));
} }
return instance; return instance;
...@@ -349,10 +365,10 @@ public class ASTNodeDeserializer extends StdDeserializer<ASTNode> { ...@@ -349,10 +365,10 @@ public class ASTNodeDeserializer extends StdDeserializer<ASTNode> {
throw new DeserializationException(); throw new DeserializationException();
} }
// ManagedPositions // _impl_Positions
for (JsonNode child : node.get("c").get("ManagedPositions").get("c")) { for (JsonNode child : node.get("c").get("_impl_positions").get("c")) {
int ref = child.get("v").asInt(); int ref = child.get("v").asInt();
this.listSwitchManagedPositions.add(new IM<Switch>(instance, ref)); this.listSwitch_impl_positions.add(new IM<Switch>(instance, ref));
} }
return instance; return instance;
......
...@@ -21,19 +21,19 @@ public class JastaddTransformationInjectConnectedSegments<TJastaddDriver extends ...@@ -21,19 +21,19 @@ public class JastaddTransformationInjectConnectedSegments<TJastaddDriver extends
// create segment2 // create segment2
Segment segment2 = new Segment(); Segment segment2 = new Segment();
segment2.setId(driver.nextId()); segment2.setId(driver.nextId());
segment2.addConnectsTo(match.getSegment3()); segment2.addToConnectsTo(match.getSegment3());
segment2.setLength(TrainBenchmarkConstants.DEFAULT_SEGMENT_LENGTH); segment2.setLength(TrainBenchmarkConstants.DEFAULT_SEGMENT_LENGTH);
match.getSegment1().containingRegion().addTrackElement(segment2); match.getSegment1().containingRegion().addTrackElement(segment2);
// have the sensor monitor the segment // have the sensor monitor the segment
match.getSensor().addMonitoredElement(segment2); match.getSensor().addToMonitors(segment2);
// remove the connection of segment1 to segment3 // remove the connection of segment1 to segment3
match.getSegment1().removeConnectsTo(match.getSegment3()); match.getSegment1().removeFromConnectsTo(match.getSegment3());
// connect segment1 to segment2 // connect segment1 to segment2
match.getSegment1().addConnectsTo(segment2); match.getSegment1().addToConnectsTo(segment2);
} }
driver.flushCache(); driver.flushCache();
} }
......
...@@ -21,7 +21,7 @@ public class JastaddTransformationInjectRouteSensor<TJastaddDriver extends Jasta ...@@ -21,7 +21,7 @@ public class JastaddTransformationInjectRouteSensor<TJastaddDriver extends Jasta
@Override @Override
public void activate(final Collection<JastaddRouteSensorInjectMatch> matches) { public void activate(final Collection<JastaddRouteSensorInjectMatch> matches) {
for (final JastaddRouteSensorInjectMatch match : matches) { for (final JastaddRouteSensorInjectMatch match : matches) {
match.getRoute().removeRequiredSensor(match.getSensor()); match.getRoute().removeFromRequires(match.getSensor());
} }
driver.flushCache(); driver.flushCache();
} }
......
...@@ -21,7 +21,9 @@ public class JastaddTransformationInjectSwitchMonitored<TJastaddDriver extends J ...@@ -21,7 +21,9 @@ public class JastaddTransformationInjectSwitchMonitored<TJastaddDriver extends J
@Override @Override
public void activate(final Collection<JastaddSwitchMonitoredInjectMatch> matches) { public void activate(final Collection<JastaddSwitchMonitoredInjectMatch> matches) {
for (final JastaddSwitchMonitoredInjectMatch match : matches) { for (final JastaddSwitchMonitoredInjectMatch match : matches) {
match.getSw().getMonitoringSensorList().clear(); for (Sensor sensor : new java.util.ArrayList<Sensor>(match.getSw().monitoredBy())) {
match.getSw().removeFromMonitoredBy(sensor);
}
} }
driver.flushCache(); driver.flushCache();
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment