Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
baloghlaszlo committed Jul 2, 2017
1 parent 443206e commit 312d20f
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import hu.bme.mit.inf.modes3.messaging.communication.state.interfaces.ComputerVi

class SafetyLogic extends AbstractRailRoadCommunicationComponent implements INotifiable {

var initializeRailRoad = false

@Accessors(PUBLIC_GETTER) protected IModelInteractor model
private ILoggerFactory factory

Expand Down Expand Up @@ -148,19 +150,25 @@ class SafetyLogic extends AbstractRailRoadCommunicationComponent implements INot
}
}

initRailRoad
if(initializeRailRoad){
initRailRoad
}

logger.info('adding the cv callback')

locator.computerVisionCallback.setComputerVisionListener(new IComputerVisionListener(){

override onComputerVisionDetection(List<ComputerVisionInformation> information, long timestamp, long frameindex) {
// println('''
// Information recieved @ «timestamp» frame #«frameindex»
// «FOR info : information»
// CV Estimated train «info.name» on segment #«computerVisionEstimator.getElementByCoordinates(info.realPosition.x, info.realPosition.y).id»
// «ENDFOR»
// ''')
val segmentIds = information.map[computerVisionEstimator.getElementByCoordinates(it.realPosition.x, it.realPosition.y)]
val infoIter = information.iterator
val combined = segmentIds.map[it -> infoIter.next]
println('''
Information recieved @ «timestamp» frame #«frameindex»
«FOR info : information»
CV Estimated train «info.name» on segment #«computerVisionEstimator.getElementByCoordinates(info.realPosition.x, info.realPosition.y).id»
«ENDFOR»
''')
model.ensureIds(combined)
}
})

Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?><plugin>
<extension id="hu.bme.mit.inf.safetylogic.patterns.DerivedFeatures" point="org.eclipse.viatra.query.runtime.queryspecification">
<group group="org.eclipse.viatra.query.runtime.extensibility.SingletonExtensionFactory:hu.bme.mit.inf.safetylogic.patterns.DerivedFeatures" id="hu.bme.mit.inf.safetylogic.patterns.DerivedFeatures">
<query-specification fqn="hu.bme.mit.inf.safetylogic.patterns.currentlyConnected"/>
<query-specification fqn="hu.bme.mit.inf.safetylogic.patterns.connected"/>
<query-specification fqn="hu.bme.mit.inf.safetylogic.patterns.viablePaths"/>
</group>
</extension>
<extension id="hu.bme.mit.inf.safetylogic.patterns.PathBuildingHelperQueries" point="org.eclipse.viatra.query.runtime.queryspecification">
<group group="org.eclipse.viatra.query.runtime.extensibility.SingletonExtensionFactory:hu.bme.mit.inf.safetylogic.patterns.PathBuildingHelperQueries" id="hu.bme.mit.inf.safetylogic.patterns.PathBuildingHelperQueries">
<query-specification fqn="hu.bme.mit.inf.safetylogic.patterns.threeConnectedRailRoadParts"/>
</group>
</extension>
<extension id="hu.bme.mit.inf.safetylogic.patterns.SafetyPatterns" point="org.eclipse.viatra.query.runtime.queryspecification">
<group group="org.eclipse.viatra.query.runtime.extensibility.SingletonExtensionFactory:hu.bme.mit.inf.safetylogic.patterns.SafetyPatterns" id="hu.bme.mit.inf.safetylogic.patterns.SafetyPatterns">
<query-specification fqn="hu.bme.mit.inf.safetylogic.patterns.nextSection"/>
<query-specification fqn="hu.bme.mit.inf.safetylogic.patterns.trainHitsAnotherTrain"/>
<query-specification fqn="hu.bme.mit.inf.safetylogic.patterns.trainTrailingTurnout"/>
</group>
</extension>
<extension id="hu.bme.mit.inf.safetylogic.rulepatterns.RulePatterns" point="org.eclipse.viatra.query.runtime.queryspecification">
<group group="org.eclipse.viatra.query.runtime.extensibility.SingletonExtensionFactory:hu.bme.mit.inf.safetylogic.rulepatterns.RulePatterns" id="hu.bme.mit.inf.safetylogic.rulepatterns.RulePatterns">
<query-specification fqn="hu.bme.mit.inf.safetylogic.rulepatterns.trainOnStation"/>
<query-specification fqn="hu.bme.mit.inf.safetylogic.rulepatterns.trainLeftStation"/>
<query-specification fqn="hu.bme.mit.inf.safetylogic.rulepatterns.trainIsNotInStation"/>
<query-specification fqn="hu.bme.mit.inf.safetylogic.rulepatterns.noTrainOnStation"/>
<query-specification fqn="hu.bme.mit.inf.safetylogic.rulepatterns.multipleTrainsOnStation"/>
</group>
</extension>
</plugin>
<?xml version="1.0" encoding="UTF-8"?><plugin>
<extension id="hu.bme.mit.inf.safetylogic.patterns.DerivedFeatures" point="org.eclipse.viatra.query.runtime.queryspecification">
<group group="org.eclipse.viatra.query.runtime.extensibility.SingletonExtensionFactory:hu.bme.mit.inf.safetylogic.patterns.DerivedFeatures" id="hu.bme.mit.inf.safetylogic.patterns.DerivedFeatures">
<query-specification fqn="hu.bme.mit.inf.safetylogic.patterns.currentlyConnected"/>
<query-specification fqn="hu.bme.mit.inf.safetylogic.patterns.connected"/>
<query-specification fqn="hu.bme.mit.inf.safetylogic.patterns.viablePaths"/>
</group>
</extension>
<extension id="hu.bme.mit.inf.safetylogic.patterns.PathBuildingHelperQueries" point="org.eclipse.viatra.query.runtime.queryspecification">
<group group="org.eclipse.viatra.query.runtime.extensibility.SingletonExtensionFactory:hu.bme.mit.inf.safetylogic.patterns.PathBuildingHelperQueries" id="hu.bme.mit.inf.safetylogic.patterns.PathBuildingHelperQueries">
<query-specification fqn="hu.bme.mit.inf.safetylogic.patterns.threeConnectedRailRoadParts"/>
</group>
</extension>
<extension id="hu.bme.mit.inf.safetylogic.patterns.SafetyPatterns" point="org.eclipse.viatra.query.runtime.queryspecification">
<group group="org.eclipse.viatra.query.runtime.extensibility.SingletonExtensionFactory:hu.bme.mit.inf.safetylogic.patterns.SafetyPatterns" id="hu.bme.mit.inf.safetylogic.patterns.SafetyPatterns">
<query-specification fqn="hu.bme.mit.inf.safetylogic.patterns.nextSection"/>
<query-specification fqn="hu.bme.mit.inf.safetylogic.patterns.trainHitsAnotherTrain"/>
<query-specification fqn="hu.bme.mit.inf.safetylogic.patterns.trainTrailingTurnout"/>
</group>
</extension>
<extension id="hu.bme.mit.inf.safetylogic.rulepatterns.RulePatterns" point="org.eclipse.viatra.query.runtime.queryspecification">
<group group="org.eclipse.viatra.query.runtime.extensibility.SingletonExtensionFactory:hu.bme.mit.inf.safetylogic.rulepatterns.RulePatterns" id="hu.bme.mit.inf.safetylogic.rulepatterns.RulePatterns">
<query-specification fqn="hu.bme.mit.inf.safetylogic.rulepatterns.trainOnStation"/>
<query-specification fqn="hu.bme.mit.inf.safetylogic.rulepatterns.trainLeftStation"/>
<query-specification fqn="hu.bme.mit.inf.safetylogic.rulepatterns.trainIsNotInStation"/>
<query-specification fqn="hu.bme.mit.inf.safetylogic.rulepatterns.noTrainOnStation"/>
<query-specification fqn="hu.bme.mit.inf.safetylogic.rulepatterns.multipleTrainsOnStation"/>
</group>
</extension>
</plugin>
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ public static QueryEngine2ViatraCep register(final ResourceSet resourceSet, fina

public EventDrivenTransformationRuleGroup getRules() {
EventDrivenTransformationRuleGroup ruleGroup = new EventDrivenTransformationRuleGroup(
createnoTrainOnStation_MappingRule(),
createtrainOnStation_MappingRule(),
createmultipleTrainsOnStation_MappingRule()
createmultipleTrainsOnStation_MappingRule(),
createnoTrainOnStation_MappingRule()
);
return ruleGroup;
}
Expand All @@ -59,24 +59,24 @@ private void registerRules() {
}
}

public EventDrivenTransformationRule<NoTrainOnStationMatch, NoTrainOnStationMatcher> createnoTrainOnStation_MappingRule() {
public EventDrivenTransformationRule<TrainOnStationMatch, TrainOnStationMatcher> createtrainOnStation_MappingRule() {
try{
EventDrivenTransformationRuleFactory.EventDrivenTransformationRuleBuilder<NoTrainOnStationMatch, NoTrainOnStationMatcher> builder = new EventDrivenTransformationRuleFactory().createRule();
EventDrivenTransformationRuleFactory.EventDrivenTransformationRuleBuilder<TrainOnStationMatch, TrainOnStationMatcher> builder = new EventDrivenTransformationRuleFactory().createRule();
builder.addLifeCycle(Lifecycles.getDefault(false, true));
builder.precondition(NoTrainOnStationMatcher.querySpecification());
builder.precondition(TrainOnStationMatcher.querySpecification());

IMatchProcessor<NoTrainOnStationMatch> actionOnAppear_0 = new IMatchProcessor<NoTrainOnStationMatch>() {
public void process(final NoTrainOnStationMatch matchedPattern) {
NoTrainOnStation_Event event = new NoTrainOnStation_Event(null);
IMatchProcessor<TrainOnStationMatch> actionOnAppear_0 = new IMatchProcessor<TrainOnStationMatch>() {
public void process(final TrainOnStationMatch matchedPattern) {
TrainOnStation_Event event = new TrainOnStation_Event(null);
event.setQueryMatch(matchedPattern);
eventStream.push(event);
}
};
builder.action(CRUDActivationStateEnum.CREATED, actionOnAppear_0);

IMatchProcessor<NoTrainOnStationMatch> actionOnDisappear_0 = new IMatchProcessor<NoTrainOnStationMatch>() {
public void process(final NoTrainOnStationMatch matchedPattern) {
NoMultipleTrainsOnStation_Event event = new NoMultipleTrainsOnStation_Event(null);
IMatchProcessor<TrainOnStationMatch> actionOnDisappear_0 = new IMatchProcessor<TrainOnStationMatch>() {
public void process(final TrainOnStationMatch matchedPattern) {
TrainLeftStation_Event event = new TrainLeftStation_Event(null);
event.setQueryMatch(matchedPattern);
eventStream.push(event);
}
Expand All @@ -92,26 +92,23 @@ public void process(final NoTrainOnStationMatch matchedPattern) {
return null;
}

public EventDrivenTransformationRule<TrainOnStationMatch, TrainOnStationMatcher> createtrainOnStation_MappingRule() {
public EventDrivenTransformationRule<MultipleTrainsOnStationMatch, MultipleTrainsOnStationMatcher> createmultipleTrainsOnStation_MappingRule() {
try{
EventDrivenTransformationRuleFactory.EventDrivenTransformationRuleBuilder<TrainOnStationMatch, TrainOnStationMatcher> builder = new EventDrivenTransformationRuleFactory().createRule();
EventDrivenTransformationRuleFactory.EventDrivenTransformationRuleBuilder<MultipleTrainsOnStationMatch, MultipleTrainsOnStationMatcher> builder = new EventDrivenTransformationRuleFactory().createRule();
builder.addLifeCycle(Lifecycles.getDefault(false, true));
builder.precondition(TrainOnStationMatcher.querySpecification());
builder.precondition(MultipleTrainsOnStationMatcher.querySpecification());

IMatchProcessor<TrainOnStationMatch> actionOnAppear_0 = new IMatchProcessor<TrainOnStationMatch>() {
public void process(final TrainOnStationMatch matchedPattern) {
TrainOnStation_Event event = new TrainOnStation_Event(null);
IMatchProcessor<MultipleTrainsOnStationMatch> actionOnAppear_0 = new IMatchProcessor<MultipleTrainsOnStationMatch>() {
public void process(final MultipleTrainsOnStationMatch matchedPattern) {
MultipleTrainsOnStation_Event event = new MultipleTrainsOnStation_Event(null);
event.setQueryMatch(matchedPattern);
eventStream.push(event);
}
};
builder.action(CRUDActivationStateEnum.CREATED, actionOnAppear_0);

IMatchProcessor<TrainOnStationMatch> actionOnDisappear_0 = new IMatchProcessor<TrainOnStationMatch>() {
public void process(final TrainOnStationMatch matchedPattern) {
TrainLeftStation_Event event = new TrainLeftStation_Event(null);
event.setQueryMatch(matchedPattern);
eventStream.push(event);
IMatchProcessor<MultipleTrainsOnStationMatch> actionOnDisappear_0 = new IMatchProcessor<MultipleTrainsOnStationMatch>() {
public void process(final MultipleTrainsOnStationMatch matchedPattern) {
}
};
builder.action(CRUDActivationStateEnum.DELETED, actionOnDisappear_0);
Expand All @@ -125,23 +122,26 @@ public void process(final TrainOnStationMatch matchedPattern) {
return null;
}

public EventDrivenTransformationRule<MultipleTrainsOnStationMatch, MultipleTrainsOnStationMatcher> createmultipleTrainsOnStation_MappingRule() {
public EventDrivenTransformationRule<NoTrainOnStationMatch, NoTrainOnStationMatcher> createnoTrainOnStation_MappingRule() {
try{
EventDrivenTransformationRuleFactory.EventDrivenTransformationRuleBuilder<MultipleTrainsOnStationMatch, MultipleTrainsOnStationMatcher> builder = new EventDrivenTransformationRuleFactory().createRule();
EventDrivenTransformationRuleFactory.EventDrivenTransformationRuleBuilder<NoTrainOnStationMatch, NoTrainOnStationMatcher> builder = new EventDrivenTransformationRuleFactory().createRule();
builder.addLifeCycle(Lifecycles.getDefault(false, true));
builder.precondition(MultipleTrainsOnStationMatcher.querySpecification());
builder.precondition(NoTrainOnStationMatcher.querySpecification());

IMatchProcessor<MultipleTrainsOnStationMatch> actionOnAppear_0 = new IMatchProcessor<MultipleTrainsOnStationMatch>() {
public void process(final MultipleTrainsOnStationMatch matchedPattern) {
MultipleTrainsOnStation_Event event = new MultipleTrainsOnStation_Event(null);
IMatchProcessor<NoTrainOnStationMatch> actionOnAppear_0 = new IMatchProcessor<NoTrainOnStationMatch>() {
public void process(final NoTrainOnStationMatch matchedPattern) {
NoTrainOnStation_Event event = new NoTrainOnStation_Event(null);
event.setQueryMatch(matchedPattern);
eventStream.push(event);
}
};
builder.action(CRUDActivationStateEnum.CREATED, actionOnAppear_0);

IMatchProcessor<MultipleTrainsOnStationMatch> actionOnDisappear_0 = new IMatchProcessor<MultipleTrainsOnStationMatch>() {
public void process(final MultipleTrainsOnStationMatch matchedPattern) {
IMatchProcessor<NoTrainOnStationMatch> actionOnDisappear_0 = new IMatchProcessor<NoTrainOnStationMatch>() {
public void process(final NoTrainOnStationMatch matchedPattern) {
NoMultipleTrainsOnStation_Event event = new NoMultipleTrainsOnStation_Event(null);
event.setQueryMatch(matchedPattern);
eventStream.push(event);
}
};
builder.action(CRUDActivationStateEnum.DELETED, actionOnDisappear_0);
Expand Down

0 comments on commit 312d20f

Please sign in to comment.