From 3cac798faec467b3b7523493d61e6f3176e0267b Mon Sep 17 00:00:00 2001 From: Daniel Schick Date: Wed, 11 Jan 2023 15:33:42 +0100 Subject: [PATCH] Performance verbessert und die Darstellung.. auch :P --- AIS/bsmd.AIS2Service/App.config | 2 +- .../Properties/Settings.Designer.cs | 4 ++-- .../Properties/Settings.settings | 2 +- AIS/bsmd.AIS2Service/webservice/SLRController.cs | 16 ++++++++++++---- AIS/bsmd.AIS2Service/zonen.js | 14 ++++++++++++-- 5 files changed, 28 insertions(+), 10 deletions(-) diff --git a/AIS/bsmd.AIS2Service/App.config b/AIS/bsmd.AIS2Service/App.config index da7c04e3..5c6ab800 100644 --- a/AIS/bsmd.AIS2Service/App.config +++ b/AIS/bsmd.AIS2Service/App.config @@ -50,7 +50,7 @@ 60 - Data Source=ais_initial.db;Version=3; + Data Source=ais_initial.db;Version=3;Synchronous=OFF;Journal Mode=MEMORY; 7 diff --git a/AIS/bsmd.AIS2Service/Properties/Settings.Designer.cs b/AIS/bsmd.AIS2Service/Properties/Settings.Designer.cs index a5128f39..445529ce 100644 --- a/AIS/bsmd.AIS2Service/Properties/Settings.Designer.cs +++ b/AIS/bsmd.AIS2Service/Properties/Settings.Designer.cs @@ -12,7 +12,7 @@ namespace bsmd.AIS2Service.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.4.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.2.0.0")] internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); @@ -70,7 +70,7 @@ namespace bsmd.AIS2Service.Properties { [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("Data Source=ais_initial.db;Version=3;")] + [global::System.Configuration.DefaultSettingValueAttribute("Data Source=ais_initial.db;Version=3;Synchronous=OFF;Journal Mode=MEMORY;")] public string SQLiteDBConnectionString { get { return ((string)(this["SQLiteDBConnectionString"])); diff --git a/AIS/bsmd.AIS2Service/Properties/Settings.settings b/AIS/bsmd.AIS2Service/Properties/Settings.settings index 3f43ac8f..6c152d26 100644 --- a/AIS/bsmd.AIS2Service/Properties/Settings.settings +++ b/AIS/bsmd.AIS2Service/Properties/Settings.settings @@ -18,7 +18,7 @@ 60 - Data Source=ais_initial.db;Version=3; + Data Source=ais_initial.db;Version=3;Synchronous=OFF;Journal Mode=MEMORY; 7 diff --git a/AIS/bsmd.AIS2Service/webservice/SLRController.cs b/AIS/bsmd.AIS2Service/webservice/SLRController.cs index acb66a2e..8419a31c 100644 --- a/AIS/bsmd.AIS2Service/webservice/SLRController.cs +++ b/AIS/bsmd.AIS2Service/webservice/SLRController.cs @@ -15,13 +15,21 @@ namespace bsmd.AIS2Service if (!id.HasValue) return null; List result = AISManager.SQLiteStorage.GetShipLocationReports(id.Value); + // remove results not in SitRep + int obscureTargetCnt = result.RemoveAll(x => !AISManager.SitRep.ContainsKey(x.MMSI)); + _log.InfoFormat("removed {0} obscure targets", obscureTargetCnt); + + // remove targets w/o name (i.e. static data) + int unnamedPlayerCnt = result.RemoveAll(x => string.IsNullOrEmpty(AISManager.SitRep[x.MMSI].Name)); + _log.InfoFormat("removed {0} unnamed targets", unnamedPlayerCnt); + // Class B targets entfernen - int classBReportCnt = result.RemoveAll(x => AISManager.SitRep.ContainsKey(x.MMSI) && (AISManager.SitRep[x.MMSI].IsClassB ?? false)); - _log.DebugFormat("removed {0} class B alarms from list"); // tut des? + int classBReportCnt = result.RemoveAll(x => AISManager.SitRep[x.MMSI].IsClassB ?? false); + _log.InfoFormat("removed {0} class B alarms from list", classBReportCnt); // tut des? // auch alles entfernen was "abgelaufen" ist und nicht im SitRep enthalten ist - int expiredCnt = result.RemoveAll(x => AISManager.SitRep.ContainsKey(x.MMSI) && ((DateTime.Now - x.Timestamp_Last).TotalMinutes > 1440)); - _log.InfoFormat("removed {0} expired (> 1 day) alarms from list"); + int expiredCnt = result.RemoveAll(x => (DateTime.Now - x.Timestamp_Last).TotalMinutes > 1440); + _log.InfoFormat("removed {0} expired (> 1 day) alarms from list", expiredCnt); Dictionary> mmsiDict = new Dictionary>(); foreach(ShipLocationReport report in result) { diff --git a/AIS/bsmd.AIS2Service/zonen.js b/AIS/bsmd.AIS2Service/zonen.js index 9d3cb0b3..d08c6191 100644 --- a/AIS/bsmd.AIS2Service/zonen.js +++ b/AIS/bsmd.AIS2Service/zonen.js @@ -59,7 +59,7 @@ function updateData(data, groupId) { table.childNodes[1].appendChild(row); // append row to tbody subelement } - + row.setAttribute("isActive", "true"); const colCount = row.childNodes.length; row.childNodes[0].innerHTML = data[i].Name; if(data[i].VoyageDirection == 0) row.childNodes[1].innerHTML = ''; @@ -82,7 +82,15 @@ function updateData(data, groupId) { row.childNodes[colCount - 1].innerHTML = data[i].Destination; } - // TODO: remove rows (after an interval) that are not in the result set any more + // array in-place removal taking place + var i = table.childNodes[1].rows.length; + while (i--) { + row = table.childNodes[1].rows[i]; + if(row["isActive"] !== "true") { + table.childNodes[1].rows.remove(row); + } + } + } function update() { @@ -154,6 +162,8 @@ function createAreas() th6.innerHTML='Destination'; tr.appendChild(th6); + tr.setAttribute("isActive", "true"); // set marker so it won't get deleted later + aTable.appendChild(document.createElement('tbody')); aDiv.appendChild(aTable); aDiv.appendChild(document.createElement('hr'));