Extend of #1
This commit is contained in:
parent
3f75dba452
commit
bdd78832f9
@ -36,18 +36,14 @@ namespace Fraunhofer.Fit.IoT.LoraMap {
|
|||||||
&& d.ContainsKey("Name") && d["Name"].IsString) {
|
&& d.ContainsKey("Name") && d["Name"].IsString) {
|
||||||
String name = (String)d["Name"];
|
String name = (String)d["Name"];
|
||||||
Botclient b = new Botclient(d);
|
Botclient b = new Botclient(d);
|
||||||
if (b.Fix || b.Longitude != 0 || b.Latitude != 0) {
|
if (this.locations.ContainsKey(name)) {
|
||||||
if (this.locations.ContainsKey(name)) {
|
this.locations[name] = b;
|
||||||
this.locations[name] = b;
|
|
||||||
} else {
|
|
||||||
this.locations.Add(name,b);
|
|
||||||
}
|
|
||||||
Console.WriteLine("Koodinate erhalten!");
|
|
||||||
} else {
|
} else {
|
||||||
Console.WriteLine("Daten erhalten! (Kein Fix)");
|
this.locations.Add(name, b);
|
||||||
}
|
}
|
||||||
|
Console.WriteLine("Koordinate erhalten!");
|
||||||
}
|
}
|
||||||
} catch(Exception ex) {
|
} catch (Exception ex) {
|
||||||
Helper.WriteError(ex.Message);
|
Helper.WriteError(ex.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,37 +13,44 @@ namespace Fraunhofer.Fit.IoT.LoraMap.Model {
|
|||||||
if (json.ContainsKey("Rssi") && json["Rssi"].IsDouble) {
|
if (json.ContainsKey("Rssi") && json["Rssi"].IsDouble) {
|
||||||
this.Rssi = (Double)json["Rssi"];
|
this.Rssi = (Double)json["Rssi"];
|
||||||
}
|
}
|
||||||
if(json.ContainsKey("Snr") && json["Snr"].IsDouble) {
|
if (json.ContainsKey("Snr") && json["Snr"].IsDouble) {
|
||||||
this.Snr = (Double)json["Snr"];
|
this.Snr = (Double)json["Snr"];
|
||||||
}
|
}
|
||||||
if (json.ContainsKey("Receivedtime") && json["Receivedtime"].IsString) {
|
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;
|
this.Upatedtime = updatetime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(json.ContainsKey("BatteryLevel") && json["BatteryLevel"].IsDouble) {
|
if (json.ContainsKey("BatteryLevel") && json["BatteryLevel"].IsDouble) {
|
||||||
this.Battery = Math.Round((Double)json["BatteryLevel"],2);
|
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.ContainsKey("Gps") && json["Gps"].IsObject) {
|
||||||
if(json["Gps"].ContainsKey("Latitude") && json["Gps"]["Latitude"].IsDouble) {
|
if (json["Gps"].ContainsKey("Latitude") && json["Gps"]["Latitude"].IsDouble) {
|
||||||
this.Latitude = (Double)json["Gps"]["Latitude"];
|
this.Latitude = (Double)json["Gps"]["Latitude"];
|
||||||
}
|
}
|
||||||
if(json["Gps"].ContainsKey("Longitude") && json["Gps"]["Longitude"].IsDouble) {
|
if (json["Gps"].ContainsKey("Longitude") && json["Gps"]["Longitude"].IsDouble) {
|
||||||
this.Longitude = (Double)json["Gps"]["Longitude"];
|
this.Longitude = (Double)json["Gps"]["Longitude"];
|
||||||
}
|
}
|
||||||
if(json["Gps"].ContainsKey("Fix") && json["Gps"]["Fix"].IsBoolean) {
|
if (json["Gps"].ContainsKey("Fix") && json["Gps"]["Fix"].IsBoolean) {
|
||||||
this.Fix = (Boolean)json["Gps"]["Fix"];
|
this.Fix = (Boolean)json["Gps"]["Fix"];
|
||||||
}
|
}
|
||||||
if(json["Gps"].ContainsKey("LastLatitude") && json["Gps"]["LastLatitude"].IsDouble && !this.Fix) {
|
if (json["Gps"].ContainsKey("LastLatitude") && json["Gps"]["LastLatitude"].IsDouble && !this.Fix) {
|
||||||
this.Latitude = (Double)json["Gps"]["LastLatitude"];
|
this.Latitude = (Double)json["Gps"]["LastLatitude"];
|
||||||
}
|
}
|
||||||
if(json["Gps"].ContainsKey("LastLongitude") && json["Gps"]["LastLongitude"].IsDouble && !this.Fix) {
|
if (json["Gps"].ContainsKey("LastLongitude") && json["Gps"]["LastLongitude"].IsDouble && !this.Fix) {
|
||||||
this.Longitude = (Double)json["Gps"]["LastLongitude"];
|
this.Longitude = (Double)json["Gps"]["LastLongitude"];
|
||||||
}
|
}
|
||||||
if(json["Gps"].ContainsKey("Hdop") && json["Gps"]["Hdop"].IsDouble) {
|
if (json["Gps"].ContainsKey("Hdop") && json["Gps"]["Hdop"].IsDouble) {
|
||||||
this.Hdop = (Double)json["Gps"]["Hdop"];
|
this.Hdop = (Double)json["Gps"]["Hdop"];
|
||||||
}
|
}
|
||||||
if(json["Gps"].ContainsKey("Height") && json["Gps"]["Height"].IsDouble) {
|
if (json["Gps"].ContainsKey("Height") && json["Gps"]["Height"].IsDouble) {
|
||||||
this.Height = (Double)json["Gps"]["Height"];
|
this.Height = (Double)json["Gps"]["Height"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -56,6 +63,7 @@ namespace Fraunhofer.Fit.IoT.LoraMap.Model {
|
|||||||
public Double Longitude { get; private set; }
|
public Double Longitude { get; private set; }
|
||||||
public Double Hdop { get; private set; }
|
public Double Hdop { get; private set; }
|
||||||
public Double Battery { get; private set; }
|
public Double Battery { get; private set; }
|
||||||
|
public Int32 Batterysimple { get; private set; }
|
||||||
public Boolean Fix { get; private set; }
|
public Boolean Fix { get; private set; }
|
||||||
public Double Height { get; private set; }
|
public Double Height { get; private set; }
|
||||||
|
|
||||||
|
@ -14,22 +14,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div id="version">vx.x.x</div>
|
<div id="version">vx.x.x</div>
|
||||||
<div id="pannels">
|
<div id="pannels">
|
||||||
<div id="pannels_pos">
|
<div id="pannels_pos"></div>
|
||||||
<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>
|
</div>
|
||||||
<script type="text/javascript" src="js/leaflet/leaflet.js"></script>
|
<script type="text/javascript" src="js/leaflet/leaflet.js"></script>
|
||||||
<script type="text/javascript" src="js/nav.js"></script>
|
<script type="text/javascript" src="js/nav.js"></script>
|
||||||
|
@ -24,16 +24,83 @@ function parsedata() {
|
|||||||
for (var key in items) {
|
for (var key in items) {
|
||||||
if (items.hasOwnProperty(key)) {
|
if (items.hasOwnProperty(key)) {
|
||||||
var markeritem = items[key];
|
var markeritem = items[key];
|
||||||
if (!markers.hasOwnProperty(key)) {
|
if (markeritem['Latitude'] != 0 || markeritem['Longitude'] != 0) {
|
||||||
markers[key] = L.marker([markeritem['Latitude'], markeritem['Longitude']]).addTo(mymap);
|
if (!markers.hasOwnProperty(key)) {
|
||||||
} else {
|
markers[key] = L.marker([markeritem['Latitude'], markeritem['Longitude']]).addTo(mymap);
|
||||||
markers[key].setLatLng([markeritem['Latitude'], markeritem['Longitude']]);
|
} else {
|
||||||
|
markers[key].setLatLng([markeritem['Latitude'], markeritem['Longitude']]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
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;
|
var visiblePanel = null;
|
||||||
function showHidePanel(name) {
|
function showHidePanel(name) {
|
||||||
if (visiblePanel == null) {
|
if (visiblePanel == null) {
|
||||||
|
Loading…
Reference in New Issue
Block a user