-
Notifications
You must be signed in to change notification settings - Fork 1
/
Bus.cs
77 lines (58 loc) · 1.84 KB
/
Bus.cs
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
using System;
using System.Xml;
using System.Xml.Serialization;
using System.Collections.Generic;
namespace Tracker
{
public class Bus {
//=================================================
//=== Constants ===
//=================================================
public static readonly int MIN_BUS_ID = 1;
public static readonly int MAX_BUS_ID = 9;
//=================================================
//=== Members ===
//=================================================
[XmlAttribute]
public String name;
[XmlIgnore]
public bool running;
[XmlElement("running")]
public string runningPretty{
get{return running ? "1":"0";}
set{running = XmlConvert.ToBoolean(value);}
}
public long lastUpdated;
public int route;
public double latitude;
public double longitude;
public double lastLatitude;
public double lastLongitude;
public int heading;
public int lastStop;
public int nextStop;
public long timeSinceLastStop;
public String status;
public String address;
[XmlIgnore]
public SerializableDictionary<int,long> stopCheckInTimes;
//=================================================
//=== Methods ===
//=================================================
public Bus() {
stopCheckInTimes = new SerializableDictionary<int, long>();
foreach (int id in Stop.STOP_IDS) {
stopCheckInTimes.Add (id,0L); //Start out with not having visited any stops
}
}
public void setRoute(int r) {
if (r == this.route || r == 0) return;
this.route = r;
//Wipe out saved trip times, as they don't apply to this route
this.stopCheckInTimes = new SerializableDictionary<int, long>();
foreach (int id in Stop.STOP_IDS) {
stopCheckInTimes.Add (id,0L);
}
}
}
}