Extend of #1
This commit is contained in:
parent
3f75dba452
commit
bdd78832f9
@ -36,16 +36,12 @@ namespace Fraunhofer.Fit.IoT.LoraMap {
|
||||
&& d.ContainsKey("Name") && d["Name"].IsString) {
|
||||
String name = (String)d["Name"];
|
||||
Botclient b = new Botclient(d);
|
||||
if (b.Fix || b.Longitude != 0 || b.Latitude != 0) {
|
||||
if (this.locations.ContainsKey(name)) {
|
||||
this.locations[name] = b;
|
||||
} else {
|
||||
this.locations.Add(name, b);
|
||||
}
|
||||
Console.WriteLine("Koodinate erhalten!");
|
||||
} else {
|
||||
Console.WriteLine("Daten erhalten! (Kein Fix)");
|
||||
}
|
||||
Console.WriteLine("Koordinate erhalten!");
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
Helper.WriteError(ex.Message);
|
||||
|
@ -17,12 +17,19 @@ namespace Fraunhofer.Fit.IoT.LoraMap.Model {
|
||||
this.Snr = (Double)json["Snr"];
|
||||
}
|
||||
if (json.ContainsKey("Receivedtime") && json["Receivedtime"].IsString) {
|
||||
if (DateTime.TryParse((String)json["Receivedtime"], DateTimeFormatInfo.InvariantInfo, DateTimeStyles.AssumeLocal, out DateTime updatetime)) {
|
||||
if (DateTime.TryParse((String)json["Receivedtime"], DateTimeFormatInfo.InvariantInfo, DateTimeStyles.AssumeUniversal, out DateTime updatetime)) {
|
||||
this.Upatedtime = updatetime;
|
||||
}
|
||||
}
|
||||
if (json.ContainsKey("BatteryLevel") && json["BatteryLevel"].IsDouble) {
|
||||
this.Battery = Math.Round((Double)json["BatteryLevel"], 2);
|
||||
if(this.Battery < 3) {
|
||||
this.Batterysimple = 0;
|
||||
} else if(this.Battery < 3.5) {
|
||||
this.Batterysimple = 1;
|
||||
} else {
|
||||
this.Batterysimple = 2;
|
||||
}
|
||||
}
|
||||
if (json.ContainsKey("Gps") && json["Gps"].IsObject) {
|
||||
if (json["Gps"].ContainsKey("Latitude") && json["Gps"]["Latitude"].IsDouble) {
|
||||
@ -56,6 +63,7 @@ namespace Fraunhofer.Fit.IoT.LoraMap.Model {
|
||||
public Double Longitude { get; private set; }
|
||||
public Double Hdop { get; private set; }
|
||||
public Double Battery { get; private set; }
|
||||
public Int32 Batterysimple { get; private set; }
|
||||
public Boolean Fix { get; private set; }
|
||||
public Double Height { get; private set; }
|
||||
|
||||
|
@ -14,22 +14,7 @@
|
||||
</div>
|
||||
<div id="version">vx.x.x</div>
|
||||
<div id="pannels">
|
||||
<div id="pannels_pos">
|
||||
<div class="item">
|
||||
<span class="color" style="background-color: red;"></span>
|
||||
<span class="icon"></span>
|
||||
<div class="line1">
|
||||
<span class="name">A</span>
|
||||
<span class="akku"></span>
|
||||
</div>
|
||||
<div class="line2" style="color: green;">
|
||||
GPS-Empfang
|
||||
</div>
|
||||
<div class="line3">
|
||||
Letzter Datenempfang: vor 10 s
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="pannels_pos"></div>
|
||||
</div>
|
||||
<script type="text/javascript" src="js/leaflet/leaflet.js"></script>
|
||||
<script type="text/javascript" src="js/nav.js"></script>
|
||||
|
@ -24,6 +24,7 @@ function parsedata() {
|
||||
for (var key in items) {
|
||||
if (items.hasOwnProperty(key)) {
|
||||
var markeritem = items[key];
|
||||
if (markeritem['Latitude'] != 0 || markeritem['Longitude'] != 0) {
|
||||
if (!markers.hasOwnProperty(key)) {
|
||||
markers[key] = L.marker([markeritem['Latitude'], markeritem['Longitude']]).addTo(mymap);
|
||||
} else {
|
||||
@ -32,6 +33,72 @@ function parsedata() {
|
||||
}
|
||||
}
|
||||
}
|
||||
parseStatus(items);
|
||||
}
|
||||
}
|
||||
|
||||
function parseStatus(items) {
|
||||
document.getElementById("pannels_pos").innerHTML = "";
|
||||
for (var name in items) {
|
||||
if (items.hasOwnProperty(name)) {
|
||||
var markeritem = items[name];
|
||||
var divItem = document.createElement("div");
|
||||
divItem.className = "item";
|
||||
var spanColor = document.createElement("span");
|
||||
spanColor.className = "color";
|
||||
if (markeritem["Batterysimple"] == 0) {
|
||||
spanColor.style.backgroundColor = "red";
|
||||
} else if (markeritem["Batterysimple"] == 1) {
|
||||
spanColor.style.backgroundColor = "yellow";
|
||||
} else if (markeritem["Batterysimple"] == 2) {
|
||||
spanColor.style.backgroundColor = "green";
|
||||
}
|
||||
divItem.appendChild(spanColor);
|
||||
var spanIcon = document.createElement("span");
|
||||
spanIcon.className = "icon";
|
||||
divItem.appendChild(spanIcon);
|
||||
var divLine1 = document.createElement("div");
|
||||
divLine1.className = "line1";
|
||||
var spanName = document.createElement("span");
|
||||
spanName.className = "name";
|
||||
spanName.innerText = name;
|
||||
divLine1.appendChild(spanName);
|
||||
var spanAkku = document.createElement("span");
|
||||
spanAkku.className = "akku";
|
||||
divLine1.appendChild(spanAkku);
|
||||
divItem.appendChild(divLine1);
|
||||
var divLine2 = document.createElement("div");
|
||||
divLine2.className = "line2";
|
||||
if (markeritem["Fix"]) {
|
||||
divLine2.style.color = "green";
|
||||
divLine2.innerText = "GPS-Empfang";
|
||||
} else {
|
||||
divLine2.style.color = "red";
|
||||
divLine2.innerText = "kein GPS-Empfang";
|
||||
}
|
||||
divItem.appendChild(divLine2);
|
||||
var divLine3 = document.createElement("div");
|
||||
divLine3.className = "line3";
|
||||
divLine3.innerText = "Letzter Datenempfang: vor " + timeDiffToText(markeritem["Upatedtime"]);
|
||||
divItem.appendChild(divLine3);
|
||||
document.getElementById("pannels_pos").appendChild(divItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function timeDiffToText(time) {
|
||||
var diff = Date.now() - Date.parse(time);
|
||||
diff = Math.round(diff / 1000);
|
||||
if (diff < 60) {
|
||||
return diff + " s";
|
||||
}
|
||||
if (diff < (60 * 60)) {
|
||||
return Math.floor(diff / 60) + " m";
|
||||
}
|
||||
if (diff < (60 * 60 * 24)) {
|
||||
return Math.floor(diff / (60 * 60)) + " h";
|
||||
}
|
||||
return Math.floor(diff / (60 * 60 * 24)) + " d";
|
||||
}
|
||||
|
||||
var visiblePanel = null;
|
||||
|
Loading…
Reference in New Issue
Block a user