Skip to content

Commit 60e4df9

Browse files
author
yongzx
committed
Firefighters movement
1 parent 5127ae1 commit 60e4df9

File tree

4 files changed

+254
-30
lines changed

4 files changed

+254
-30
lines changed

__pycache__/server.cpython-36.pyc

1.35 KB
Binary file not shown.

index.html

Lines changed: 221 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,18 @@
130130
//FIREFIGHTER
131131
//*retrieve elevation data from Samsung Gear
132132
//level = elevation / level_height
133-
var fLvl = 1;
133+
var fLvl1 = 1;
134134
//*retrieve latitude and longitude from Samsung Gear
135-
var fLat = 34.056025;
136-
var fLong = -117.195750;
135+
var fLat1 = 34.056102774043914
136+
var fLong1 = -117.19569445234714
137+
var fLvl2 = 1;
138+
//*retrieve latitude and longitude from Samsung Gear
139+
var fLat2 = 34.056102774043914
140+
var fLong2 = -117.19569445234714
141+
var fLvl3 = 1;
142+
//*retrieve latitude and longitude from Samsung Gear
143+
var fLat3 = 34.056102774043914
144+
var fLong3 = -117.19569445234714
137145
/*
138146
var fLat = [34.056166050304356, 34.05604351028498, 34.0560324451615]
139147
var fLong = [-117.19569956078443, -117.1957325361164, -117.19569938406546]
@@ -154,15 +162,124 @@
154162
geometry: ffpoint,
155163
symbol: markerSymbol
156164
});
157-
ffpoint["z"] += 1.5
165+
ffpoint["z"] += 1.5;
158166
var ffpointText = new Graphic({
159167
geometry: ffpoint,
160168
symbol: {
161169
type: "text",
162170
text: "#01"
163171
}
164172
});
165-
ffpoint["z"] -= 1.5
173+
ffpoint["z"] -= 1.5;
174+
175+
ffgraphicsLayer.add(ffpointGraphic);
176+
ffgraphicsLayer.add(ffpointText);
177+
178+
var deleteold = setTimeout(del_f, 499);
179+
180+
function del_f() {
181+
ffgraphicsLayer.remove(ffpointGraphic);
182+
ffgraphicsLayer.remove(ffpointText);
183+
}
184+
}
185+
186+
187+
function f2(lvl, lat, long) {
188+
var ffpoint = {
189+
type: "point", // autocasts as new Point()
190+
latitude: lat,
191+
longitude: long,
192+
z: human_height + (lvl - 1) * level_height
193+
};
194+
markerSymbol = {
195+
type: "simple-marker", // autocasts as new SimpleMarkerSymbol()
196+
color: fcolor
197+
};
198+
var ffpointGraphic = new Graphic({
199+
geometry: ffpoint,
200+
symbol: markerSymbol
201+
});
202+
ffpoint["z"] += 1.5;
203+
var ffpointText = new Graphic({
204+
geometry: ffpoint,
205+
symbol: {
206+
type: "text",
207+
text: "#02"
208+
}
209+
});
210+
ffpoint["z"] -= 1.5;
211+
212+
ffgraphicsLayer.add(ffpointGraphic);
213+
ffgraphicsLayer.add(ffpointText);
214+
215+
var deleteold = setTimeout(del_f, 499);
216+
217+
function del_f() {
218+
ffgraphicsLayer.remove(ffpointGraphic);
219+
ffgraphicsLayer.remove(ffpointText);
220+
}
221+
}
222+
223+
function f3(lvl, lat, long) {
224+
var ffpoint = {
225+
type: "point", // autocasts as new Point()
226+
latitude: lat,
227+
longitude: long,
228+
z: human_height + (lvl - 1) * level_height
229+
};
230+
markerSymbol = {
231+
type: "simple-marker", // autocasts as new SimpleMarkerSymbol()
232+
color: fcolor
233+
};
234+
var ffpointGraphic = new Graphic({
235+
geometry: ffpoint,
236+
symbol: markerSymbol
237+
});
238+
ffpoint["z"] += 1.5;
239+
var ffpointText = new Graphic({
240+
geometry: ffpoint,
241+
symbol: {
242+
type: "text",
243+
text: "#03"
244+
}
245+
});
246+
ffpoint["z"] -= 1.5;
247+
248+
ffgraphicsLayer.add(ffpointGraphic);
249+
ffgraphicsLayer.add(ffpointText);
250+
251+
var deleteold = setTimeout(del_f, 499);
252+
253+
function del_f() {
254+
ffgraphicsLayer.remove(ffpointGraphic);
255+
ffgraphicsLayer.remove(ffpointText);
256+
}
257+
}
258+
259+
function f3_change_v(lvl, lat, long) {
260+
var ffpoint = {
261+
type: "point", // autocasts as new Point()
262+
latitude: lat,
263+
longitude: long,
264+
z: human_height + (lvl - 1) * level_height
265+
};
266+
markerSymbol = {
267+
type: "simple-marker", // autocasts as new SimpleMarkerSymbol()
268+
color: vcolor
269+
};
270+
var ffpointGraphic = new Graphic({
271+
geometry: ffpoint,
272+
symbol: markerSymbol
273+
});
274+
ffpoint["z"] += 1.5;
275+
var ffpointText = new Graphic({
276+
geometry: ffpoint,
277+
symbol: {
278+
type: "text",
279+
text: "#03"
280+
}
281+
});
282+
ffpoint["z"] -= 1.5;
166283

167284
ffgraphicsLayer.add(ffpointGraphic);
168285
ffgraphicsLayer.add(ffpointText);
@@ -175,6 +292,45 @@
175292
}
176293
}
177294

295+
function f3_change_crit(lvl, lat, long) {
296+
var ffpoint = {
297+
type: "point", // autocasts as new Point()
298+
latitude: lat,
299+
longitude: long,
300+
z: human_height + (lvl - 1) * level_height
301+
};
302+
markerSymbol = {
303+
type: "simple-marker", // autocasts as new SimpleMarkerSymbol()
304+
color: critvcolor
305+
};
306+
var ffpointGraphic = new Graphic({
307+
geometry: ffpoint,
308+
symbol: markerSymbol
309+
});
310+
ffpoint["z"] += 1.5;
311+
var ffpointText = new Graphic({
312+
geometry: ffpoint,
313+
symbol: {
314+
type: "text",
315+
text: "#03"
316+
}
317+
});
318+
ffpoint["z"] -= 1.5;
319+
320+
ffgraphicsLayer.add(ffpointGraphic);
321+
ffgraphicsLayer.add(ffpointText);
322+
323+
var deleteold = setTimeout(del_f, 499);
324+
325+
function del_f() {
326+
ffgraphicsLayer.remove(ffpointGraphic);
327+
ffgraphicsLayer.remove(ffpointText);
328+
}
329+
}
330+
331+
332+
333+
// monitoring the health condition of the victim
178334
var vpoint2_changed = {
179335
type: "point", // autocasts as new Point()
180336
latitude: 34.05607,
@@ -190,7 +346,6 @@
190346
symbol: markerSymbol
191347
});
192348

193-
// monitoring the health condition of the victim
194349
function v_change_health() {
195350

196351
vgraphicsLayer.remove(vpointGraphic2);
@@ -201,52 +356,87 @@
201356

202357
//refresh firefighter position every second
203358

204-
var update = setInterval(fmovement1, 500);
359+
var update = setInterval(fmovement, 500);
205360
var steps1 = [false, false, false, false, false, false]
206361

207-
function fmovement1() {
362+
var steps2 = [false, false, false, false]
363+
var steps3 = [false, false, false, false]
364+
365+
function fmovement() {
208366
if (!steps1[0]){
209-
fLat = fLat + 0.000002;
210-
f(fLvl, fLat, fLong);
211-
if (fLat > 34.05605633804347){
367+
fLat1 = fLat1 + 0.000001;
368+
f(fLvl1, fLat1, fLong1);
369+
if (fLat1 > 34.05605633804347){
212370
steps1[0] = true;
213371
}
214372
} else if (!steps1[1]) {
215-
fLvl = fLvl + 0.05;
216-
f(fLvl, fLat, fLong);
217-
if (fLvl > 1.90) {
373+
fLvl1 = fLvl1 + 0.05;
374+
f(fLvl1, fLat1, fLong1);
375+
if (fLvl1 > 1.90) {
218376
steps1[1] = true;
219377
}
220378
} else if (!steps1[2]) {
221-
fLong = fLong + -0.00002;
222-
f(fLvl, fLat, fLong);
223-
if (fLong < -117.19582414483669){
379+
fLong1 = fLong1 + -0.00002;
380+
f(fLvl1, fLat1, fLong1);
381+
if (fLong1 < -117.19582414483669){
224382
steps1[2] = true;
225383
vgraphicsLayer.remove(vpointGraphic1); // save the first victim
226384
}
227385
} else if (!steps1[3]) {
228-
fLong = fLong + 0.00002;
229-
f(fLvl, fLat, fLong);
230-
if (fLong > -117.195750){
231-
steps[3] = true;
386+
fLong1 = fLong1 + 0.00002;
387+
f(fLvl1, fLat1, fLong1);
388+
if (fLong1 > -117.195750){
389+
steps1[3] = true;
232390
}
233391
} else if (!steps1[4]) {
234-
fLvl = fLvl + 0.05;
235-
f(fLvl, fLat, fLong);
236-
if (fLvl > 2.90) {
237-
steps[4] = true;
392+
fLvl1 = fLvl1 + 0.05;
393+
f(fLvl1, fLat1, fLong1);
394+
if (fLvl1 > 2.90) {
395+
steps1[4] = true;
238396
}
239397
} else if (!steps1[5]) {
240-
fLong = fLong - 0.00002;
241-
console.log(fLong);
242-
f(fLvl, fLat, fLong);
243-
if (fLong < -117.19589000000005) {
244-
steps[5] = true;
398+
fLong1 = fLong1 - 0.00002;
399+
f(fLvl1, fLat1, fLong1);
400+
if (fLong1 < -117.19589000000005) {
401+
steps1[5] = true;
245402
vgraphicsLayer.remove(vpointGraphic2_changed); // save the second victim
246403
clearInterval(health_change);
247404
}
248405

249406
}
407+
408+
if (!steps2[0]){
409+
fLat2 = fLat2 + 0.000001;
410+
fLat3 = fLat3 + 0.000001;
411+
f2(fLvl2, fLat2, fLong2);
412+
f3(fLvl3, fLat3, fLong3);
413+
if (fLat2 > 34.05605633804347){
414+
steps2[0] = true;
415+
}
416+
} else if (!steps2[1]) {
417+
fLvl2 = fLvl2 + 0.05;
418+
f2(fLvl2, fLat2, fLong2);
419+
fLong3 = fLong3 - 0.00001;
420+
f3(fLvl3, fLat3, fLong3);
421+
if (fLvl2 > 1.90) {
422+
steps2[1] = true;
423+
}
424+
} else if (!steps2[2]) {
425+
fLvl2 = fLvl2 - 0.05;
426+
f2(fLvl2, fLat2, fLong2);
427+
f3_change_v(fLvl3, fLat3, fLong3);
428+
if (fLvl2 <1) {
429+
steps2[2] = true;
430+
}
431+
} else if (!steps2[3]) {
432+
fLong2 = fLong2- 0.00001;
433+
f2(fLvl2, fLat2, fLong2);
434+
f3_change_crit(fLvl3, fLat3, fLong3);
435+
if (fLong2 < fLong3) {
436+
steps2[3] = true;
437+
}
438+
}
439+
250440
}
251441

252442

@@ -326,6 +516,7 @@
326516
<input class="checkbox" type="checkbox">1st Floor</input><br>
327517
<input class="checkbox" type="checkbox">2nd Floor</input><br>
328518
<input class="checkbox" type="checkbox">3rd Floor</input>
519+
329520
</div>
330521
</body>
331522

index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,8 @@ $(document).ready(function(){
1414
alert("All floors cleared!");
1515
}
1616
});
17+
18+
$.get("demo_test.asp", function("10.1.103.116/8000", status){
19+
alert("Data: " + data + "\nStatus: " + status);
20+
});
1721
})

server.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from http.server import BaseHTTPRequestHandler, HTTPServer
2+
import webbrowser
3+
4+
class HTTPServer_Intercom(BaseHTTPRequestHandler):
5+
def _set_headers(self):
6+
self.send_response(200)
7+
self.send_header('Content-type', 'text')
8+
self.end_headers()
9+
10+
def do_HEAD(self):
11+
self._set_headers()
12+
13+
def do_GET(self):
14+
pass
15+
16+
def do_POST(self):
17+
# Doesn't do anything with posted data
18+
pass
19+
20+
def run_server():
21+
print("Starting server http://0.0.0.0:8000/...")
22+
23+
server_address = ('0.0.0.0', 8000)
24+
httpd = HTTPServer(server_address, HTTPServer_Intercom)
25+
print("Running server http://127.0.0.1:8080/...")
26+
webbrowser.open("http://127.0.0.1:8080/")
27+
httpd.serve_forever()
28+
29+
run_server()

0 commit comments

Comments
 (0)