Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Fabian Vu
visb-visualisation-examples
Commits
b493fddf
Commit
b493fddf
authored
Jan 05, 2021
by
Michael Leuschel
Browse files
also visualize train position in example
parent
be0fdb7a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Train/SimpleTrainTrack.mch
View file @
b493fddf
...
...
@@ -4,7 +4,7 @@ MACHINE TrainTrack
SETS
TTDS = {ttd1,ttd2,ttd3}
CONSTANTS
TrackElementNumber, TRACK, TTD_TrackElements
TrackElementNumber, TRACK, TTD_TrackElements
, train_length
PROPERTIES
TrackElementNumber : NATURAL1
& TRACK = 0..TrackElementNumber
...
...
@@ -13,17 +13,23 @@ PROPERTIES
& TrackElementNumber = 30
& TTD_TrackElements = {ttd1 |-> 0..10 , ttd2 |-> 11..25 , ttd3 |-> 26..30}
& train_length = 2
VARIABLES
occ
occ,
train_rear_end
INVARIANT
occ <: TTDS
INITIALISATION occ := {}
occ <: TTDS &
train_rear_end : TRACK
INITIALISATION occ := {} || train_rear_end := 0
OPERATIONS
TTD_Occupied(ttd) = PRE ttd:TTDS \ occ THEN
occ := occ \/ {ttd}
END;
TTD_Free(ttd) = PRE ttd:occ THEN
occ := occ \ {ttd}
END;
TrainMoveForward = PRE train_rear_end+1:TRACK THEN
train_rear_end := train_rear_end + 1
END
DEFINITIONS
"LibrarySVG.def"; // enable to use the external functions in the VisB json file
...
...
Train/Track.json
View file @
b493fddf
...
...
@@ -2,6 +2,13 @@
"svg"
:
"Track.svg"
,
"items"
:[
{
"id"
:
"train_polygon"
,
"attr"
:
"points"
,
"value"
:
"svg_train(train_rear_end, train_length ,100.0/real(TrackElementNumber+1),1.0,3.0)"
,
"comment"
:
"show train position using a slanted polygon"
},
{
"id"
:
"track_polyline"
,
"attr"
:
"points"
,
...
...
@@ -18,13 +25,13 @@
"id"
:
"occupied_ttd_polygon"
,
"attr"
:
"points"
,
"value"
:
"svg_set_polygon(OCC_TE,100.0/real(TrackElementNumber+1),100.0,2.0)"
,
"comment"
:
"show
ticks for TTD Limit
s"
"comment"
:
"show
occupied TTD zone
s"
},
{
"id"
:
"cleared_ttd_polygon"
,
"attr"
:
"points"
,
"value"
:
"svg_set_polygon(FREE_TE,100.0/real(TrackElementNumber+1),100.0,2.0)"
,
"comment"
:
"show
ticks for TTD Limit
s"
"comment"
:
"show
free TTD zone
s"
}
],
"events"
:[
...
...
@@ -41,6 +48,13 @@
"optional"
:
true
,
"hovers"
:
[{
"attr"
:
"stroke"
,
"enter"
:
"black"
,
"leave"
:
"none"
},
{
"attr"
:
"opacity"
,
"enter"
:
"0.5"
,
"leave"
:
"1.0"
}]
},
{
"id"
:
"train_polygon"
,
"event"
:
"TrainMoveForward"
,
"optional"
:
true
,
"hovers"
:
[{
"attr"
:
"fill"
,
"enter"
:
"red"
,
"leave"
:
"lightgray"
},
{
"attr"
:
"stroke-width"
,
"enter"
:
"0.5"
,
"leave"
:
"0.3"
}]
}
]
}
\ No newline at end of file
Train/Track.svg
View file @
b493fddf
...
...
@@ -7,6 +7,12 @@
version=
"1.1"
id=
"svg5154"
>
<polygon
id =
"train_polygon"
points=
"0,0 100,0"
style=
"stroke-width: 0.3"
stroke=
"black"
fill=
"lightgray"
transform=
"translate(10,16.8)"
/>
<polygon
id =
"track_polyline"
points=
"0,0 1,0, 1,1 1,0 50,0 50,1 50,0 100,0"
style=
"stroke-width: 0.3"
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment