[v1.7.0] Add support for IC880A Board
This commit is contained in:
parent
251b178ad6
commit
3b98e1878c
@ -1,70 +1,20 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using BlubbFish.Utils;
|
||||
using BlubbFish.Utils.IoT.Bots;
|
||||
using BlubbFish.Utils.IoT.Connector;
|
||||
using BlubbFish.Utils.IoT.Events;
|
||||
using Fraunhofer.Fit.IoT.MqttMap.Model;
|
||||
using LitJson;
|
||||
|
||||
namespace Fraunhofer.Fit.IoT.Bots.LoraBot.Moduls_broken {
|
||||
class Botclient {
|
||||
namespace Fraunhofer.Fit.IoT.MqttMap {
|
||||
|
||||
public Botclient(Int32 paketrssi, Int32 rssi, Double snr, String updatetime, Double lat, Double lon, Double hdop, Int32 battery, Boolean fix) {
|
||||
this.PacketRssi = paketrssi;
|
||||
this.Rssi = rssi;
|
||||
this.Snr = snr;
|
||||
this.Upatedtime = updatetime;
|
||||
this.Latitude = lat;
|
||||
this.Longitude = lon;
|
||||
this.Hdop = hdop;
|
||||
this.Battery = battery;
|
||||
this.Fix = fix;
|
||||
}
|
||||
|
||||
public Int32 PacketRssi { get; private set; }
|
||||
public Int32 Rssi { get; private set; }
|
||||
public Double Snr { get; private set; }
|
||||
public String Upatedtime { get; private set; }
|
||||
public Double Latitude { get; private set; }
|
||||
public Double Longitude { get; private set; }
|
||||
public Double Hdop { get; private set; }
|
||||
public Int32 Battery { get; private set; }
|
||||
public Boolean Fix { get; private set; }
|
||||
|
||||
public virtual Dictionary<String, Object> ToDictionary() {
|
||||
Dictionary<String, Object> dictionary = new Dictionary<String, Object>();
|
||||
foreach (PropertyInfo item in this.GetType().GetProperties()) {
|
||||
if (item.CanRead && item.GetValue(this) != null) {
|
||||
if (item.GetValue(this).GetType().GetMethod("ToDictionary") != null) {
|
||||
dictionary.Add(item.Name, item.GetValue(this).GetType().GetMethod("ToDictionary").Invoke(item.GetValue(this), null));
|
||||
} else if (item.GetValue(this).GetType().HasInterface(typeof(IDictionary))) {
|
||||
Dictionary<String, Object> subdict = new Dictionary<String, Object>();
|
||||
foreach (DictionaryEntry subitem in (IDictionary)item.GetValue(this)) {
|
||||
if (subitem.Value.GetType().GetMethod("ToDictionary") != null) {
|
||||
subdict.Add(subitem.Key.ToString(), subitem.Value.GetType().GetMethod("ToDictionary").Invoke(subitem.Value, null));
|
||||
}
|
||||
}
|
||||
dictionary.Add(item.Name, subdict);
|
||||
} else if (item.GetValue(this).GetType().BaseType == typeof(Enum)) {
|
||||
dictionary.Add(item.Name, Helper.GetEnumDescription((Enum)item.GetValue(this)));
|
||||
} else {
|
||||
dictionary.Add(item.Name, item.GetValue(this));
|
||||
}
|
||||
}
|
||||
}
|
||||
return dictionary;
|
||||
}
|
||||
}
|
||||
|
||||
class Googlelocation : Webserver
|
||||
{
|
||||
private readonly Dictionary<String, List<Botclient>> locations = new Dictionary<String, List<Botclient>>();
|
||||
private readonly Dictionary<String, Botclient> locations = new Dictionary<String, Botclient>();
|
||||
|
||||
public Googlelocation(ADataBackend backend, Dictionary<String, String> settings, InIReader requests) : base(backend, settings, requests) { }
|
||||
|
||||
@ -75,7 +25,7 @@ namespace Fraunhofer.Fit.IoT.Bots.LoraBot.Moduls_broken {
|
||||
&& d.ContainsKey("Rssi") && d["Rssi"].IsInt
|
||||
&& d.ContainsKey("Snr") && d["Snr"].IsDouble
|
||||
&& d.ContainsKey("Receivedtime") && d["Receivedtime"].IsString
|
||||
&& d.ContainsKey("BatteryLevel") && d["BatteryLevel"].IsInt
|
||||
&& d.ContainsKey("BatteryLevel") && d["BatteryLevel"].IsDouble
|
||||
&& d.ContainsKey("Gps") && d["Gps"].IsObject
|
||||
&& d["Gps"].ContainsKey("Latitude") && d["Gps"]["Latitude"].IsDouble
|
||||
&& d["Gps"].ContainsKey("Longitude") && d["Gps"]["Longitude"].IsDouble
|
||||
@ -83,12 +33,12 @@ namespace Fraunhofer.Fit.IoT.Bots.LoraBot.Moduls_broken {
|
||||
&& d["Gps"].ContainsKey("Fix") && d["Gps"]["Fix"].IsBoolean
|
||||
&& d.ContainsKey("Name") && d["Name"].IsString) {
|
||||
String name = (String)d["Name"];
|
||||
Botclient b = new Botclient((Int32)d["PacketRssi"], (Int32)d["Rssi"], (Double)d["Snr"], (String)d["Receivedtime"], (Double)d["Gps"]["Latitude"], (Double)d["Gps"]["Longitude"], (Double)d["Gps"]["Hdop"], (Int32)d["BatteryLevel"], (Boolean)d["Gps"]["Fix"]);
|
||||
Botclient b = new Botclient((Int32)d["PacketRssi"], (Int32)d["Rssi"], (Double)d["Snr"], (String)d["Receivedtime"], (Double)d["Gps"]["Latitude"], (Double)d["Gps"]["Longitude"], (Double)d["Gps"]["Hdop"], (Double)d["BatteryLevel"], (Boolean)d["Gps"]["Fix"]);
|
||||
if (b.Fix) {
|
||||
if (this.locations.ContainsKey(name)) {
|
||||
this.locations[name].Add(b);
|
||||
this.locations[name] = b;
|
||||
} else {
|
||||
this.locations.Add(name, new List<Botclient> { b });
|
||||
this.locations.Add(name,b);
|
||||
}
|
||||
Console.WriteLine("Koodinate erhalten!");
|
||||
} else {
|
||||
|
56
mqtt-map/Model/Botclient.cs
Normal file
56
mqtt-map/Model/Botclient.cs
Normal file
@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using BlubbFish.Utils;
|
||||
|
||||
namespace Fraunhofer.Fit.IoT.MqttMap.Model {
|
||||
class Botclient {
|
||||
|
||||
public Botclient(Int32 paketrssi, Int32 rssi, Double snr, String updatetime, Double lat, Double lon, Double hdop, Double battery, Boolean fix) {
|
||||
this.PacketRssi = paketrssi;
|
||||
this.Rssi = rssi;
|
||||
this.Snr = snr;
|
||||
this.Upatedtime = updatetime;
|
||||
this.Latitude = lat;
|
||||
this.Longitude = lon;
|
||||
this.Hdop = hdop;
|
||||
this.Battery = battery;
|
||||
this.Fix = fix;
|
||||
}
|
||||
|
||||
public Int32 PacketRssi { get; private set; }
|
||||
public Int32 Rssi { get; private set; }
|
||||
public Double Snr { get; private set; }
|
||||
public String Upatedtime { get; private set; }
|
||||
public Double Latitude { get; private set; }
|
||||
public Double Longitude { get; private set; }
|
||||
public Double Hdop { get; private set; }
|
||||
public Double Battery { get; private set; }
|
||||
public Boolean Fix { get; private set; }
|
||||
|
||||
public virtual Dictionary<String, Object> ToDictionary() {
|
||||
Dictionary<String, Object> dictionary = new Dictionary<String, Object>();
|
||||
foreach (PropertyInfo item in this.GetType().GetProperties()) {
|
||||
if (item.CanRead && item.GetValue(this) != null) {
|
||||
if (item.GetValue(this).GetType().GetMethod("ToDictionary") != null) {
|
||||
dictionary.Add(item.Name, item.GetValue(this).GetType().GetMethod("ToDictionary").Invoke(item.GetValue(this), null));
|
||||
} else if (item.GetValue(this).GetType().HasInterface(typeof(IDictionary))) {
|
||||
Dictionary<String, Object> subdict = new Dictionary<String, Object>();
|
||||
foreach (DictionaryEntry subitem in (IDictionary)item.GetValue(this)) {
|
||||
if (subitem.Value.GetType().GetMethod("ToDictionary") != null) {
|
||||
subdict.Add(subitem.Key.ToString(), subitem.Value.GetType().GetMethod("ToDictionary").Invoke(subitem.Value, null));
|
||||
}
|
||||
}
|
||||
dictionary.Add(item.Name, subdict);
|
||||
} else if (item.GetValue(this).GetType().BaseType == typeof(Enum)) {
|
||||
dictionary.Add(item.Name, Helper.GetEnumDescription((Enum)item.GetValue(this)));
|
||||
} else {
|
||||
dictionary.Add(item.Name, item.GetValue(this));
|
||||
}
|
||||
}
|
||||
}
|
||||
return dictionary;
|
||||
}
|
||||
}
|
||||
}
|
@ -2,9 +2,8 @@
|
||||
using System.Collections.Generic;
|
||||
using BlubbFish.Utils;
|
||||
using BlubbFish.Utils.IoT.Connector;
|
||||
using Fraunhofer.Fit.IoT.Bots.LoraBot.Moduls_broken;
|
||||
|
||||
namespace mqtt_map {
|
||||
namespace Fraunhofer.Fit.IoT.MqttMap {
|
||||
class Program {
|
||||
static void Main(String[] args) {
|
||||
InIReader.SetSearchPath(new List<String>() { "/etc/mqttmap", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\mqttmap" });
|
||||
@ -20,7 +19,7 @@ namespace mqtt_map {
|
||||
}
|
||||
InIReader ini = InIReader.GetInstance("settings");
|
||||
ADataBackend b = (ADataBackend)ABackend.GetInstance(ini.GetSection("mqtt"), ABackend.BackendType.Data);
|
||||
new Googlelocation(b, ini.GetSection("google"), InIReader.GetInstance("requests"));
|
||||
new Googlelocation(b, ini.GetSection("webserver"), InIReader.GetInstance("requests"));
|
||||
while(true) {
|
||||
System.Threading.Thread.Sleep(1000);
|
||||
}
|
||||
|
@ -1,2 +1,3 @@
|
||||
[index.html]
|
||||
your_api_key=abc
|
||||
[js/nav.js]
|
||||
your_api_key=abc
|
||||
start_location=50.7, 7.2
|
@ -2,6 +2,5 @@
|
||||
type=mqtt
|
||||
server=127.0.0.1
|
||||
|
||||
[google]
|
||||
api_key=abc
|
||||
[webserver]
|
||||
prefix=http://+:8080/
|
@ -6,8 +6,8 @@
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{95D6F48A-9488-42A6-A973-941B45B26DB8}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>mqtt_map</RootNamespace>
|
||||
<AssemblyName>mqtt-map</AssemblyName>
|
||||
<RootNamespace>Fraunhofer.Fit.IoT.MqttMap</RootNamespace>
|
||||
<AssemblyName>mqttmap</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
@ -46,6 +46,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Googlelocation.cs" />
|
||||
<Compile Include="Model\Botclient.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
|
@ -1,4 +1,4 @@
|
||||
var mymap = L.map('bigmap').setView([51.396851, 12.401617], 15);
|
||||
var mymap = L.map('bigmap').setView([{%START_LOCATION%}], 14);
|
||||
|
||||
L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={accessToken}', {
|
||||
attribution: 'Map data © <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, <a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
|
||||
@ -16,16 +16,17 @@ function datarunner() {
|
||||
xhttp.open("GET", "http://{%REQUEST_URL_HOST%}:8080/loc", true);
|
||||
xhttp.send();
|
||||
}
|
||||
|
||||
//https://leafletjs.com/reference-1.4.0.html#marker
|
||||
function parsedata() {
|
||||
if (this.readyState == 4 && this.status == 200) {
|
||||
var obj = JSON.parse(this.responseText);
|
||||
for (var names in obj) {
|
||||
if (obj.hasOwnProperty(names)) {
|
||||
var markeritem = obj[names];
|
||||
|
||||
if (!markers.hasOwnProperty(names)) {
|
||||
markers[names] = L.marker([51.396851, 12.401617]).addTo(mymap);
|
||||
var items = JSON.parse(this.responseText);
|
||||
for (var key in items) {
|
||||
if (items.hasOwnProperty(key)) {
|
||||
var markeritem = items[key];
|
||||
if (!markers.hasOwnProperty(key)) {
|
||||
markers[key] = L.marker([markeritem['Latitude'], markeritem['Longitude']]).addTo(mymap);
|
||||
} else {
|
||||
markers[key].setLatLng([markeritem['Latitude'], markeritem['Longitude']]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user