diff --git a/Lora-Map/Server.cs b/Lora-Map/Server.cs index 1374279..f23f307 100644 --- a/Lora-Map/Server.cs +++ b/Lora-Map/Server.cs @@ -15,8 +15,8 @@ namespace Fraunhofer.Fit.IoT.LoraMap { class Server : Webserver { private readonly SortedDictionary positions = new SortedDictionary(); private readonly SortedDictionary alarms = new SortedDictionary(); - private readonly SortedDictionary cameras = new SortedDictionary(); - private readonly SortedDictionary crowds = new SortedDictionary(); + private readonly SortedDictionary counter = new SortedDictionary(); + private readonly SortedDictionary density = new SortedDictionary(); private readonly SortedDictionary fights = new SortedDictionary(); private JsonData marker; private readonly Settings settings; @@ -26,6 +26,8 @@ namespace Fraunhofer.Fit.IoT.LoraMap { private readonly Object lockData = new Object(); private readonly Object lockPanic = new Object(); private readonly Object lockFight = new Object(); + private readonly Object lockCount = new Object(); + private readonly Object lockDensy = new Object(); public Server(ADataBackend backend, Dictionary settings, InIReader requests) : base(backend, settings, requests) { this.logger.SetPath(settings["loggingpath"]); @@ -96,20 +98,24 @@ namespace Fraunhofer.Fit.IoT.LoraMap { Console.WriteLine("PANIC erhalten!"); } else if(Camera.CheckJson(d) && ((String)mqtt.From).Contains("camera/count")) { String cameraid = Camera.GetId(d); - if(this.cameras.ContainsKey(cameraid)) { - this.cameras[cameraid].Update(d); - } else { - this.cameras.Add(cameraid, new Camera(d)); + lock (this.lockCount) { + if (this.counter.ContainsKey(cameraid)) { + this.counter[cameraid].Update(d); + } else { + this.counter.Add(cameraid, new Camera(d)); + } } - } else if((((String)mqtt.From).Contains("sfn/crowd_density_local") && Crowd.CheckJsonCrowdDensityLocal(d)) || + } else if(((((String)mqtt.From).Contains("sfn/crowd_density_local") || ((String)mqtt.From).Contains("camera/crowd")) && Crowd.CheckJsonCrowdDensityLocal(d)) || (((String)mqtt.From).Contains("sfn/flow") && Crowd.CheckJsonFlow(d))) { String cameraid = Crowd.GetId(d); - if(this.crowds.ContainsKey(cameraid)) { - this.crowds[cameraid].Update(d); - } else { - this.crowds.Add(cameraid, new Crowd(d)); + lock (this.lockDensy) { + if (this.density.ContainsKey(cameraid)) { + this.density[cameraid].Update(d); + } else { + this.density.Add(cameraid, new Crowd(d)); + } } - } else if(((String)mqtt.From).Contains("camera/fighting_detection") && Fight.CheckJsonFightingDetection(d)) { + } else if((((String)mqtt.From).Contains("camera/fighting_detection") || ((String)mqtt.From).Contains("sfn/fighting_detection")) && Fight.CheckJsonFightingDetection(d)) { String cameraid = Fight.GetId(d); lock (this.lockFight) { if (this.fights.ContainsKey(cameraid)) { @@ -130,8 +136,8 @@ namespace Fraunhofer.Fit.IoT.LoraMap { return SendJsonResponse(new Dictionary() { { "loc", this.positions }, { "panic", this.alarms }, - { "cameracount", this.cameras }, - { "crowdcount", this.crowds }, + { "cameracount", this.counter }, + { "crowdcount", this.density }, { "fightdedect", this.fights }, { "weatherwarnings", this.weather.Warnungen } }, cont); diff --git a/Lora-Map/resources/admin/css/global.css b/Lora-Map/resources/admin/css/global.css index 3133664..1a8cdd1 100644 --- a/Lora-Map/resources/admin/css/global.css +++ b/Lora-Map/resources/admin/css/global.css @@ -30,54 +30,42 @@ margin-left: 210px; border-left: 1px solid black; } -#content #nameeditor .title { - margin-bottom: 20px; - font-weight: bold; -} -#content #nameeditor #nametable { + +#content .settingstable { margin-left: 15px; - border-collapse: collapse; + border-collapse: separate; } -#content #nameeditor #nametable thead { +#content .settingstable thead { background-color: #CCCCCC; background-color: rgba(0,0,0,0.2); } -#content #nameeditor #nametable thead th { +#content .settingstable thead th { text-align: left; } -#content #nameeditor #nametable thead .rowid { - width: 60px; -} -#content #nameeditor #nametable thead .rowicon { - width: 65px; -} -#content #nameeditor #nametable thead .rowedit { - width: 50px; -} -#content #nameeditor #nametable thead .rowname { - width: 250px; -} -#content #nameeditor #nametable tbody tr:nth-child(odd) { +#content .settingstable tbody tr:nth-child(odd) { background-color: #f39d9d; background-color: rgba(20,0,250,0.1); } -#content #nameeditor #nametable tbody tr:nth-child(even) { +#content .settingstable tbody tr:nth-child(even) { background-color: #9c9eee; background-color: rgba(250,59,0,0.1); } -#content #nameeditor #nametable tbody tr:hover { +#content .settingstable tbody tr:hover { background-color: #e4e1e1; background-color: rgba(0,0,0,0.1); } -#content #nameeditor #nametable tfoot { +#content .settingstable tfoot { background-color: #e4e1e1; background-color: rgba(0,0,0,0.1); } -#content #nameeditor .pointer { + +#content .pointer { cursor: pointer; } -#content #nameeditor #nametable tbody .name { - width: 55px; + +#content #nameeditor .title { + margin-bottom: 20px; + font-weight: bold; } #iconeditor { @@ -131,55 +119,4 @@ #content #settingseditor .crowddensity { margin-left: 15px; margin-top: 20px; -} -#content #settingseditor #fighttable, -#content #settingseditor #crowdtable { - border-collapse: collapse; -} -#content #settingseditor #fighttable thead, -#content #settingseditor #crowdtable thead { - background-color: #CCCCCC; - background-color: rgba(0,0,0,0.2); -} -#content #settingseditor #fighttable thead th, -#content #settingseditor #crowdtable thead th { - text-align: left; -} -#content #settingseditor #fighttable thead .rowid, -#content #settingseditor #crowdtable thead .rowid { - width: 60px; -} -#content #settingseditor #crowdtable thead .rownum { - width: 200px; -} -#content #settingseditor #fighttable thead .rowcoord, -#content #settingseditor #crowdtable thead .rowcoord { - width: 250px; -} -#content #settingseditor #fighttable thead .rowedit, -#content #settingseditor #crowdtable thead .rowedit { - width: 50px; -} -#content #settingseditor #fighttable tbody tr:nth-child(odd), -#content #settingseditor #crowdtable tbody tr:nth-child(odd) { - background-color: #f39d9d; - background-color: rgba(20,0,250,0.1); -} -#content #settingseditor #fighttable tbody tr:nth-child(even), -#content #settingseditor #crowdtable tbody tr:nth-child(even) { - background-color: #9c9eee; - background-color: rgba(250,59,0,0.1); -} -#content #settingseditor #fighttable tbody tr:hover, -#content #settingseditor #crowdtable tbody tr:hover { - background-color: #e4e1e1; - background-color: rgba(0,0,0,0.1); -} -#content #settingseditor #fighttable tfoot, -#content #settingseditor #crowdtable tfoot { - background-color: #e4e1e1; - background-color: rgba(0,0,0,0.1); -} -#content #settingseditor .pointer { - cursor: pointer; } \ No newline at end of file diff --git a/Lora-Map/resources/admin/js/menu.js b/Lora-Map/resources/admin/js/menu.js index 6b41cdf..79320c6 100644 --- a/Lora-Map/resources/admin/js/menu.js +++ b/Lora-Map/resources/admin/js/menu.js @@ -57,8 +57,8 @@ var NamesEditor = { document.getElementById("content").innerHTML = ""; var namesconfig = JSON.parse(jsontext); var html = "
Namenseinträge in den Einstellungen
"; - html += ""; - html += ""; + html += "
IDNameIcon
"; + html += ""; html += ""; for (var id in namesconfig) { if (namesconfig.hasOwnProperty(id)) { @@ -73,12 +73,13 @@ var NamesEditor = { } else { html += ""; } + html += ""; html += "" + ""; } } html += ""; - html += ""; + html += ""; html += "
IDNameIconFilter Gruppe
"+nameentry.Group+"
"; document.getElementById("content").innerHTML = html + "
"; }, @@ -139,9 +140,19 @@ var NamesEditor = { }, Add: function () { var newrow = document.createElement("tr"); - newrow.innerHTML = ""; - newrow.innerHTML += ""; + newrow.innerHTML = ""; + newrow.innerHTML += ""; newrow.innerHTML += " wähle Icon"; + newrow.innerHTML += ""; newrow.innerHTML += " "; document.getElementById("nametable").children[1].appendChild(newrow); }, @@ -187,13 +198,23 @@ var NamesEditor = { if (el.children[2].children[0].hasAttribute("data")) { url = el.children[2].children[0].data; } - el.innerHTML = ""; - el.innerHTML += ""; + el.innerHTML = ""; + el.innerHTML += ""; if (url === null) { el.innerHTML += " wähle Icon"; } else { el.innerHTML += " "; } + el.innerHTML += ""; el.innerHTML += " "; }, Abort: function (el) { @@ -206,6 +227,7 @@ var NamesEditor = { if (el.children[2].children.length === 2) { url = el.children[2].children[1].data; } + var group = ""; el.innerHTML = "" + id + "" + "" + name + ""; if (url === null) { @@ -213,6 +235,7 @@ var NamesEditor = { } else { el.innerHTML += ""; } + el.innerHTML += "" + group + ""; el.innerHTML += " "; }, IconEditor: function (el) { @@ -430,8 +453,8 @@ var Settings = { }, _renderFightDedection: function (json) { var ret = ""; - ret += ""; - ret += ""; + ret += "
IDKoordinaten
"; + ret += ""; ret += ""; for (var id in json) { var coords = []; @@ -451,8 +474,8 @@ var Settings = { }, _renderCrowdDensity: function (json) { var ret = ""; - ret += "
IDKoordinaten
"; - ret += ""; + ret += "
IDPersonenanzahlKoordinaten
"; + ret += ""; ret += ""; for (var id in json) { var coords = []; @@ -473,16 +496,16 @@ var Settings = { }, AddFight: function () { var newrow = document.createElement("tr"); - newrow.innerHTML = ""; - newrow.innerHTML += ""; + newrow.innerHTML = ""; + newrow.innerHTML += ""; newrow.innerHTML += ""; document.getElementById("fighttable").children[1].appendChild(newrow); }, AddDensity: function () { var newrow = document.createElement("tr"); - newrow.innerHTML = ""; - newrow.innerHTML += ""; - newrow.innerHTML += ""; + newrow.innerHTML = ""; + newrow.innerHTML += ""; + newrow.innerHTML += ""; newrow.innerHTML += ""; document.getElementById("crowdtable").children[1].appendChild(newrow); }, @@ -547,14 +570,14 @@ var Settings = { } }, EditFight: function (el) { - el.innerHTML = "" + - "" + + el.innerHTML = "" + + "" + ""; }, EditDensity: function (el) { - el.innerHTML = "" + - "" + - "" + + el.innerHTML = "" + + "" + + "" + ""; }, _filterFloat: function (value) { diff --git a/Lora-Map/resources/js/map.js b/Lora-Map/resources/js/map.js index 6b1bd89..3fb6321 100644 --- a/Lora-Map/resources/js/map.js +++ b/Lora-Map/resources/js/map.js @@ -110,7 +110,7 @@ } box.setStyle({ color: this._createRGB(cur, max) }); var p = box.getPopup().setContent("Besuchermenge:
" + - "Besucher (" + cur + "/" + max + ") Personen
" + + "Besucher (" + crowd.DensityCount + "/" + max + ") Personen
" + "").update(); } }
IDPersonenanzahlKoordinaten