-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRules.clj
259 lines (242 loc) · 6.44 KB
/
Rules.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
(czm0:CZML Navob Leg Generation2 1
(CZMLGenerator delay ?del
visibility ?vis)
(Onboard label ?onb)
?cs (CZMLSpan time ?tim
object ?obj
options ?ops)
(Clock0 time ?t ((not= ?obj ?onb)
(> ?t ?tim)))
=>
(if-let [omo (ru.igis.omtab.OMT/getMapOb ?onb)]
(if-let [nmo (ru.igis.omtab.OMT/getMapOb ?obj)]
(let [dis (.distanceNM omo nmo)]
(if (< dis ?vis)
(light.cesium.core/model-leg
nmo
(+ ?del 4)
(read-string (.getDescription nmo))))
(modify ?cs time (+ ?t ?del))))))
(czm:Check Onboard 0
(CZMLGenerator delay ?del)
?onb (Onboard label ?lab
time ?tim)
(Clock time ?t (> ?t ?tim))
=>
(let [onb (deref light.pro.server/ONBOARD)
fut (+ ?t ?del)]
(if (not= onb ?lab)
(modify ?onb time fut label onb)
(modify ?onb time fut))))
(czm:CZML Navob Leg Generation 1
(CZMLGenerator delay ?del
visibility ?vis)
(Onboard label ?onb)
?cs (CZMLSpan time ?tim
object ?obj
options ?ops)
(Clock time ?t (> ?t ?tim))
=>
(if-let [omo (ru.igis.omtab.OMT/getMapOb ?onb)]
(if-let [nmo (ru.igis.omtab.OMT/getMapOb ?obj)]
(let [dis (.distanceNM omo nmo)]
(if (< dis ?vis)
(light.cesium.core/navob-leg
nmo
dis
(+ ?del 2)
?ops))
(modify ?cs time (+ ?t ?del))))))
(czm:CZMLSpan Init 0
?cs (CZMLSpan time ?tim
object ?obj
options ?ops
((not (string? ?obj))
(not (string? ?ops))))
=>
(modify ?cs object (protege.core/sv ?obj "label")
options (apply hash-map
(mapcat #(list (read-string (protege.core/sv % "keyword"))
(read-string (protege.core/sv % "argument"))) ?ops))))
(sim0:RetractMapObEvent0 -10
?moe (MapObEvent0)
=>
(retract ?moe))
(sim0:RetractSecondClock0 10
?c1 (Clock0 time ?t1)
?c2 (Clock0 time ?t2
(< ?t2 ?t1))
=>
(retract ?c2))
(sim0:Start Simulation 0
(CZMLGenerator)
(not Clock0)
=>
(light.sim/start-sim))
(czm0:Check Onboard 0
(CZMLGenerator delay ?del)
?onb (Onboard label ?lab
time ?tim)
(Clock0 time ?t (> ?t ?tim))
=>
(let [onb (deref light.pro.server/ONBOARD)
fut (+ ?t ?del)]
(if (not= onb ?lab)
(modify ?onb time fut label onb)
(modify ?onb time fut))))
(czm0:CZML Navob Leg Generation 1
(CZMLGenerator delay ?del
visibility ?vis)
(Onboard label ?onb)
?cs (CZMLSpan time ?tim
object ?obj
options ?ops)
(Clock0 time ?t (> ?t ?tim))
=>
(if-let [omo (ru.igis.omtab.OMT/getMapOb ?onb)]
(if-let [nmo (ru.igis.omtab.OMT/getMapOb ?obj)]
(let [dis (.distanceNM omo nmo)]
(if (< dis ?vis)
(light.cesium.core/navob-leg
nmo
dis
(+ ?del 2)
?ops))
(modify ?cs time (+ ?t ?del))))))
(vr:NavOb off Map 0
(CZMLGenerator)
(MapObEvent0 status "REMOVED"
label ?lab)
?czs (CZMLSpan object ?lab)
?bt (BoatToss label ?lab)
=>
(retract ?czs ?bt)
(println "NavOb off map:" ?lab))
(vr:Boat Tossing 0
(Onboard label ?boat)
(Wave pitch ?pit
pitch-interval ?pin
roll ?rol
roll-interval ?rin
status "ON")
?bt (BoatToss label ?boat
slope ?slp
time ?tim)
(Clock0 time ?t (> ?t ?tim))
=>
(let [[ivl act amp slp]
(condp = ?slp
'UP [?rin :roll (+ ?rol) 'RIGHT]
'RIGHT [?pin :pitch (- ?pit) 'DOWN]
'DOWN [?rin :roll (- ?rol) 'LEFT]
'LEFT [?pin :pitch (+ ?pit) 'UP])]
(vr.dashcli/camera-control act amp)
(modify ?bt slope slp
time (+ ?t ivl))))
(vr:Update Wave 0
?w1 (Wave status ?current-stat)
?w2 (Wave status "TOGGLE"
instance ?wins)
=>
(retract ?w1)
(condp = ?current-stat
"OFF" (do (protege.core/ssv ?wins "status" "ON")
(modify ?w2 status "ON"))
"ON" (do (vr.dashcli/camera-control :pitch 0)
(vr.dashcli/camera-control :roll 0)
(protege.core/ssv ?wins "status" "OFF")
(modify ?w2 status "OFF"))))
(vr:Set Wikipedia Coordinates 1
(CZMLGenerator)
?onb (Onboard label ?lab
time ?tim)
(Clock0 time ?t (> ?t ?tim))
=>
(vr.dashcli/set-wiki-coords ?lab))
(vr:NMEA Start 0
(VRDashboardControl race ?rce)
?c (NMEAControl status "START"
delay ?del)
?d (NMEAData object ?obj)
?w (Wave instance ?wins
status ?wsts)
(Clock0 time ?t)
=>
(println "NMEA Start boat" (protege.core/sv ?obj "label"))
(vr.dashcli/clear-external-data (str "NMEA_CACHE/" ?rce "/GPRMC.txt"))
(vr.dashcli/clear-external-data (str "NMEA_CACHE/" ?rce "/AIVDM.txt"))
(when-let [mo (ru.igis.omtab.OMT/getOrAdd ?obj)]
(modify ?d data [""
(.getLatitude mo)
(.getLongitude mo)
(.getCourse mo)
(.getSpeed mo)
""]
time ?t)
(modify ?c status "RUN")
(when (not= ?wsts "ON")
(modify ?w status "ON")
(protege.core/ssv ?wins "status" "ON"))
(if (nil? light.sim/ES-TIMER)
(light.sim/start-sim))))
(vr:NMEA Run 0
(VRDashboardControl onboard ?onb
visibility ?vis
boat_skin ?bsk
race ?rce)
(NMEAControl status "RUN"
delay ?del)
?d (NMEAData object ?obj
time ?t0)
?cv (CesiumView status ?cesium-status)
(Clock0 time ?t1 (> ?t1 ?t0))
=>
(future (vr.dashcli/get-external-data (str "NMEA_CACHE/" ?rce "/GPRMC.txt") vr.dashcli/GPRMC))
(when-let [[tim lat lon spd crs dat :as bdata] (vr.dashcli/get-boat-data)]
(when-let [mo (ru.igis.omtab.OMT/getOrAdd ?obj)]
(.setLatitude mo lat)
(.setLongitude mo lon)
(.setCourse mo (int crs))
(.setSpeed mo spd)
(vr.dashcli/fly-to lat lon)
(println "boat:" (protege.core/sv ?obj "label") bdata))
(vr.dashcli/get-external-data (str "NMEA_CACHE/" ?rce "/AIVDM.txt") vr.dashcli/AIVDM)
(vr.dashcli/get-fleet-data)
(vr.dashcli/show-neighbors ?onb ?vis ?bsk)
(vr.dashcli/unvisible-offmap ?onb)
(when (= ?cesium-status "START")
(light.pro.server/start-server)
(light.pro.server/start-client)
(light.pro.server/go-onboard ?onb)
(modify ?cv status "ONBOARD")))
(modify ?d time (+ ?t1 ?del)))
(vr:NMEA Init 0
?vc (VRDashboardControl race ?rce)
?nc (NMEAControl status "INIT")
(Clock0 time ?t)
=>
(vr.dashcli/show-controls)
(let [rc (slurp "NMEA_CACHE/RACE.txt")]
(if (= rc "")
(if (= (mod ?t 5) 0)
(println ".. waiting for race data .." ?t))
(do (println "Race" rc)
(when (not= ?rce rc)
(vr.dashcli/new-race rc)
(modify ?vc race rc))
(modify ?nc status "START")))))
(vr:NavOb on Map 0
(CZMLGenerator)
(MapObEvent0 status "ADDED"
object ?obj
label ?lab
(= (.getName (class ?obj)) "ru.igis.omtab.NavOb"))
(Clock0 time ?t)
(not CZMLSpan object ?lab)
=>
(asser CZMLSpan object ?lab
time ?t)
(asser BoatToss label ?lab
slope 'UP
time 0)
(println "NavOb on map:" ?lab))