aboutsummaryrefslogtreecommitdiffstats
path: root/Domains/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql
diff options
context:
space:
mode:
Diffstat (limited to 'Domains/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql')
-rw-r--r--Domains/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql295
1 files changed, 295 insertions, 0 deletions
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql b/Domains/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql
new file mode 100644
index 00000000..d22bdd8b
--- /dev/null
+++ b/Domains/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql
@@ -0,0 +1,295 @@
1package modes3.queries
2
3import "http://www.ece.mcgill.ca/wcet/modes3"
4
5pattern connectedTo(S1 : Segment, S2 : Segment) {
6 Segment.connectedTo(S1, S2);
7}
8
9@Constraint(message = "connectedToNotSymmetric", severity = "error", key = { S1, S2 })
10pattern connectedToNotSymmetric(S1 : Segment, S2 : Segment) {
11 Segment.connectedTo(S1, S2);
12 neg find connectedTo(S2, S1);
13}
14
15@Constraint(message = "connectedToReflexive", severity = "error", key = { S })
16pattern connectedToReflexive(S : Segment) {
17 Segment.connectedTo(S, S);
18}
19
20pattern turnoutOutput(T : Turnout, S : Segment) {
21 Turnout.straight(T, S);
22} or {
23 Turnout.divergent(T, S);
24}
25
26@Constraint(message = "outputReflexive", severity = "error", key = { T })
27pattern outputReflexive(T : Turnout) {
28 find turnoutOutput(T, T);
29}
30
31@Constraint(message = "turnoutOutputsAreSame", severity = "error", key = { T })
32pattern turnoutOutputsAreSame(T : Turnout) {
33 Turnout.straight(T, S);
34 Turnout.divergent(T, S);
35}
36
37pattern output(S1 : Segment, S2 : Segment) {
38 Segment.connectedTo(S1, S2);
39} or {
40 find turnoutOutput(S1, S2);
41}
42
43@Constraint(message = "tooManyInputsOfSegment", severity = "error", key = { S })
44pattern tooManyInputsOfSegment(S : SimpleSegment) {
45 find output(I1, S);
46 find output(I2, S);
47 find output(I3, S);
48 I1 != I2;
49 I1 != I3;
50 I2 != I3;
51}
52
53@Constraint(message = "turnoutConnectedToBothOutputs", severity = "error", key = { T })
54pattern turnoutConnectedToBothOutputs(T : Turnout) {
55 Turnout.straight(T, Straight);
56 Turnout.divergent(T, Divergent);
57 Segment.connectedTo(T, Straight);
58 Segment.connectedTo(T, Divergent);
59}
60
61pattern adjacent(S1 : Segment, S2 : Segment) {
62 find output(S1, S2);
63} or {
64 find turnoutOutput(S2, S1);
65}
66
67@Constraint(message = "turnoutConnectedToBothOutputs", severity = "error", key = { T })
68pattern tooManyInputsOfTurnout(T : Turnout) {
69 find adjacent(I1, T);
70 find adjacent(I2, T);
71 find adjacent(I3, T);
72 find adjacent(I4, T);
73 I1 != I2;
74 I1 != I3;
75 I1 != I4;
76 I2 != I3;
77 I2 != I4;
78 I3 != I4;
79}
80
81pattern inputsOfTurnout(T : Turnout) {
82 find adjacent(I1, T);
83 find adjacent(I2, T);
84 find adjacent(I3, T);
85 I1 != I2;
86 I1 != I3;
87 I2 != I3;
88}
89
90@Constraint(message = "tooFewInputsOfTurnout", severity = "error", key = { T })
91pattern tooFewInputsOfTurnout(T : Turnout) {
92 neg find inputsOfTurnout(T);
93}
94
95pattern reachable(S1 : Segment, S2 : Segment) {
96 S1 == S2;
97} or {
98 find adjacent+(S1, S2);
99}
100
101@Constraint(message = "unreachable", severity = "error", key = { S1, S2 })
102pattern unreachable(S1 : Segment, S2 : Segment) {
103 neg find reachable(S1, S2);
104}
105
106//
107// closeTrains
108//
109
110pattern closeTrains_step_2(in train : Train) {
111// frame->t1 = model->trains[i0];
112// frame->start = frame->t1->location;
113// if(frame->start != 0){
114// ...
115// }
116// + OUTER FOR LOOP COUNTER INCREMENT
117 Train(train);
118}
119
120pattern closeTrains_step_3(in train : Train, in start : Segment) {
121// int loop_bound1 = frame->start->connected_to_count;
122// for (int i1 = 0; i1 < loop_bound1; i1++) { LOOP COUNTER INCREMENT IS NOT INCLUDED HERE
123// ...
124// }
125 Train.location(train, start);
126}
127
128pattern closeTrains_step_4(in train : Train, in start : Segment, in middle : Segment) {
129// frame->middle = frame->start->connected_to[i1];
130// int loop_bound2 = frame->middle->connected_to_count;
131
132// for (int i2 = 0; i2 < loop_bound2; i2++) { LOOP COUNTER INCREMENT IS NOT INCLUDED HERE
133// ...
134// }
135// + OUTER FOR LOOP COUNTER INCREMENT
136 Train.location(train, start);
137 Segment.connectedTo(start, middle);
138}
139
140pattern closeTrains_step_5(in train : Train, in start : Segment, in middle : Segment, in end : Segment) {
141// frame->end = frame->middle->connected_to[i2];
142// if (frame->start != frame->end) {
143// ...
144// }
145// + OUTER FOR LOOP COUNTER INCREMENT
146 Train.location(train, start);
147 Segment.connectedTo(start, middle);
148 Segment.connectedTo(middle, end);
149}
150
151pattern closeTrains_step_6(in train : Train, in start : Segment, in middle : Segment, in end : Segment) {
152// frame->t2 = frame->end->train;
153// if (frame->t2 != 0) {
154// ...
155// }
156 Train.location(train, start);
157 Segment.connectedTo(start, middle);
158 Segment.connectedTo(middle, end);
159 start != end;
160}
161
162pattern closeTrains_step_7(in train : Train, in start : Segment, in middle : Segment, in end : Segment, in otherTrain : Train) {
163// results->matches[match_cntr].start = frame->start;
164// results->matches[match_cntr++].end = frame->end;
165 Train.location(train, start);
166 Segment.connectedTo(start, middle);
167 Segment.connectedTo(middle, end);
168 start != end;
169 Segment.occupiedBy(end, otherTrain);
170}
171
172//
173// trainLocations
174//
175
176pattern trainLocations_step_2(in train : Train) {
177// frame->train = model->trains[i0];
178// frame->location = frame->train->location;
179// if (frame->location != NULL) {
180// ...
181// }
182
183 Train(train);
184}
185
186pattern trainLocations_step_3(in train : Train, in location : Segment) {
187// results->matches[match_cntr].location = frame->location;
188// results->matches[match_cntr++].train = frame->train;
189 Train(train);
190 Train.location(train, location);
191}
192
193//
194// misalignedTurnout
195//
196
197pattern misalignedTurnout_step_2(in turnout : Turnout) {
198// frame->turnout = model->turnouts[i0];
199// frame->location = frame->turnout->straight;
200// if (frame->location != NULL) {
201// ...
202// }
203 Turnout(turnout);
204}
205
206pattern misalignedTurnout_step_3(in turnout : Turnout, in location : Segment) {
207// Segment *disconnected = ((Segment *)frame->turnout);
208// if (disconnected->connected_to[0] != frame->location &&
209// disconnected->connected_to[1] != frame->location) {
210// ...
211// }
212 Turnout(turnout);
213 Turnout.straight(turnout, location);
214}
215
216pattern misalignedTurnout_step_4(in turnout : Turnout, in location : Segment) {
217// frame->train = frame->location->train;
218// if (frame->train != NULL) {
219// ...
220// }
221 Turnout(turnout);
222 Turnout.straight(turnout, location);
223 neg find connectedSegmentsDirected(turnout, location);
224}
225
226pattern misalignedTurnout_step_5(in turnout : Turnout, in location : Segment, in train : Train) {
227// results->matches[match_cntr].start = frame->start;
228// results->matches[match_cntr++].end = frame->end;
229 Turnout(turnout);
230 Turnout.straight(turnout, location);
231 neg find connectedSegmentsDirected(turnout, location);
232 Segment.occupiedBy(location, train);
233}
234
235pattern connectedSegmentsDirected(s1 : Segment, s2 : Segment) {
236 Segment.connectedTo(s1, s2);
237}
238
239//
240// endOfSiding
241//
242
243pattern endOfSiding_step_2(in train : Train) {
244// frame->train = model->trains[i0];
245// frame->location = frame->train->location;
246// if (frame->location != NULL) {
247// ...
248// }
249
250 Train(train);
251}
252
253pattern endOfSiding_step_3(in train : Train, in location : Segment) {
254// int loop_bound1 = frame->location->connected_to_count;
255// for (int i1 = 0; i1 < loop_bound1; i1++) {
256// ...
257// }
258 Train(train);
259 Train.location(train, location);
260}
261
262pattern endOfSiding_step_4(in train : Train, in location : Segment, in end : Segment) {
263// frame->end = frame->location->connected_to[i1];
264// if (frame->end != NULL &&
265// frame->end->connected_to[1] == frame->location &&
266// frame->end->connected_to[0] == NULL) {
267// ...
268// }
269// if (frame->end != NULL &&
270// frame->end->connected_to[0] == frame->location &&
271// frame->end->connected_to[1] == NULL) {
272// ...
273// }
274 Train(train);
275 Train.location(train, location);
276 Segment.connectedTo(location, end);
277}
278
279pattern endOfSiding_step_5(in train : Train, in location : Segment, in end : Segment) {
280// results->matches[match_cntr].location = frame->location;
281// results->matches[match_cntr++].train = frame->train;
282// ...OR...
283// results->matches[match_cntr].location = frame->location;
284// results->matches[match_cntr++].train = frame->train;
285 Train(train);
286 Train.location(train, location);
287 Segment.connectedTo(location, end);
288 neg find multipleConnectedTo(end);
289}
290
291pattern multipleConnectedTo(s : Segment) {
292 Segment.connectedTo(s, n1);
293 Segment.connectedTo(s, n2);
294 n1 != n2;
295}