diff --git a/Lora-Map/Googlelocation.cs b/Lora-Map/Googlelocation.cs index ebee39b..37002b7 100644 --- a/Lora-Map/Googlelocation.cs +++ b/Lora-Map/Googlelocation.cs @@ -36,18 +36,14 @@ 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!"); + if (this.locations.ContainsKey(name)) { + this.locations[name] = b; } 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); } } diff --git a/Lora-Map/Model/Botclient.cs b/Lora-Map/Model/Botclient.cs index 8c768f1..fd1bee5 100644 --- a/Lora-Map/Model/Botclient.cs +++ b/Lora-Map/Model/Botclient.cs @@ -13,37 +13,44 @@ namespace Fraunhofer.Fit.IoT.LoraMap.Model { if (json.ContainsKey("Rssi") && json["Rssi"].IsDouble) { this.Rssi = (Double)json["Rssi"]; } - if(json.ContainsKey("Snr") && json["Snr"].IsDouble) { + if (json.ContainsKey("Snr") && json["Snr"].IsDouble) { 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 (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) { + if (json.ContainsKey("Gps") && json["Gps"].IsObject) { + if (json["Gps"].ContainsKey("Latitude") && json["Gps"]["Latitude"].IsDouble) { 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"]; } - if(json["Gps"].ContainsKey("Fix") && json["Gps"]["Fix"].IsBoolean) { + if (json["Gps"].ContainsKey("Fix") && json["Gps"]["Fix"].IsBoolean) { 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"]; } - 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"]; } - if(json["Gps"].ContainsKey("Hdop") && json["Gps"]["Hdop"].IsDouble) { + if (json["Gps"].ContainsKey("Hdop") && json["Gps"]["Hdop"].IsDouble) { 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"]; } } @@ -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; } diff --git a/Lora-Map/resources/index.html b/Lora-Map/resources/index.html index 9fc4b91..1ef9998 100644 --- a/Lora-Map/resources/index.html +++ b/Lora-Map/resources/index.html @@ -14,22 +14,7 @@