Richtungspfeile für die Webübersicht

This commit is contained in:
Daniel Schick 2023-01-03 16:30:03 +01:00
parent fc947a301f
commit ff1a036124
12 changed files with 73 additions and 4 deletions

View File

@ -72,6 +72,7 @@ namespace bsmd.AIS2Service
{ {
if(testDict.ContainsKey(mmsi)) if(testDict.ContainsKey(mmsi))
{ {
if (!_sitRepDict.ContainsKey(mmsi)) continue;
AIS_Target target = _sitRepDict[mmsi]; AIS_Target target = _sitRepDict[mmsi];
foreach(AlarmAssignmentZone aazone in testDict[mmsi]) { foreach(AlarmAssignmentZone aazone in testDict[mmsi]) {
if(aazone.Zone.IsPointInPolygon4(target.Position)) if(aazone.Zone.IsPointInPolygon4(target.Position))

View File

@ -400,7 +400,7 @@ namespace bsmd.AIS2Service
string loadSLRString = "SELECT a.timestamp_first, a.timestamp_last, za.mmsi, mz.id FROM alarm a " + string loadSLRString = "SELECT a.timestamp_first, a.timestamp_last, za.mmsi, mz.id FROM alarm a " +
"INNER JOIN zone_assignment za ON a.zone_assignment_id = za.id " + "INNER JOIN zone_assignment za ON a.zone_assignment_id = za.id " +
"INNER JOIN monitor_zone mz ON za.monitor_zone_id = mz.id " + "INNER JOIN monitor_zone mz ON za.monitor_zone_id = mz.id " +
$"WHERE mz.monitor_group_id = {groupId}"; $"WHERE mz.monitor_group_id = {groupId} ORDER BY mz.sequence";
SQLiteCommand laCmd = new SQLiteCommand(loadSLRString, _connection); SQLiteCommand laCmd = new SQLiteCommand(loadSLRString, _connection);
SQLiteDataReader reader = laCmd.ExecuteReader(); SQLiteDataReader reader = laCmd.ExecuteReader();

View File

@ -70,6 +70,9 @@
<setting name="MinAlarmIntervalMins" serializeAs="String"> <setting name="MinAlarmIntervalMins" serializeAs="String">
<value>60</value> <value>60</value>
</setting> </setting>
<setting name="AutoAlarmExpiryHours" serializeAs="String">
<value>24</value>
</setting>
</bsmd.AIS2Service.Properties.Settings> </bsmd.AIS2Service.Properties.Settings>
</applicationSettings> </applicationSettings>
<runtime> <runtime>

View File

@ -12,7 +12,7 @@ namespace bsmd.AIS2Service.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.2.0.0")] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.4.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
@ -130,5 +130,14 @@ namespace bsmd.AIS2Service.Properties {
return ((int)(this["MinAlarmIntervalMins"])); return ((int)(this["MinAlarmIntervalMins"]));
} }
} }
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("24")]
public int AutoAlarmExpiryHours {
get {
return ((int)(this["AutoAlarmExpiryHours"]));
}
}
} }
} }

View File

@ -38,5 +38,8 @@
<Setting Name="MinAlarmIntervalMins" Type="System.Int32" Scope="Application"> <Setting Name="MinAlarmIntervalMins" Type="System.Int32" Scope="Application">
<Value Profile="(Default)">60</Value> <Value Profile="(Default)">60</Value>
</Setting> </Setting>
<Setting Name="AutoAlarmExpiryHours" Type="System.Int32" Scope="Application">
<Value Profile="(Default)">24</Value>
</Setting>
</Settings> </Settings>
</SettingsFile> </SettingsFile>

Binary file not shown.

After

Width:  |  Height:  |  Size: 933 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 950 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 446 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@ -1,4 +1,5 @@
using System.Collections.Generic; using System;
using System.Collections.Generic;
using System.Web.Http; using System.Web.Http;
namespace bsmd.AIS2Service namespace bsmd.AIS2Service
@ -11,7 +12,10 @@ namespace bsmd.AIS2Service
if (!id.HasValue) return null; if (!id.HasValue) return null;
List<ShipLocationReport> result = AISManager.SQLiteStorage.GetShipLocationReports(id.Value); List<ShipLocationReport> result = AISManager.SQLiteStorage.GetShipLocationReports(id.Value);
Dictionary<int, List<ShipLocationReport>> mmsiDict = new Dictionary<int, List<ShipLocationReport>>();
foreach(ShipLocationReport report in result) { foreach(ShipLocationReport report in result) {
if (!mmsiDict.ContainsKey(report.MMSI)) mmsiDict[report.MMSI] = new List<ShipLocationReport>();
mmsiDict[report.MMSI].Add(report);
if (AISManager.SitRep.ContainsKey(report.MMSI)) if (AISManager.SitRep.ContainsKey(report.MMSI))
{ {
report.Destination = AISManager.SitRep[report.MMSI].Destination; report.Destination = AISManager.SitRep[report.MMSI].Destination;
@ -21,6 +25,51 @@ namespace bsmd.AIS2Service
} }
} }
// determine "state" of vessel through alarm comparison. Possible values are:
// 0 = stationary (= equals)
// 1 = incoming
// 2 = outgoing
// 3 = expired
foreach(int key in mmsiDict.Keys)
{
bool expired = true;
DateTime? lastDate= null;
bool? incoming = null;
// first run through alarm list to determine state
foreach(ShipLocationReport slr in mmsiDict[key])
{
if((DateTime.Now - slr.Timestamp_Last).TotalHours < Properties.Settings.Default.AutoAlarmExpiryHours) expired = false;
if (lastDate == null)
{
lastDate = slr.Timestamp_Last;
}
else
{
incoming = slr.Timestamp_Last < lastDate;
}
}
// second run through alarm list to set state flag in all entries
foreach (ShipLocationReport slr in mmsiDict[key])
{
if (expired)
{
slr.VoyageDirection = 3;
}
else if (incoming.HasValue)
{
if (incoming.Value) { slr.VoyageDirection = 1; }
else { slr.VoyageDirection = 2; }
}
else
{
slr.VoyageDirection = 0; // stationary / no comparison value
}
}
}
return result; return result;
} }
} }

View File

@ -23,5 +23,6 @@ namespace bsmd.AIS2Service
public string NavStatus { get; set; } public string NavStatus { get; set; }
public int VoyageDirection { get; set; }
} }
} }

View File

@ -62,7 +62,10 @@ function updateData(data, groupId) {
const colCount = row.childNodes.length; const colCount = row.childNodes.length;
row.childNodes[0].innerHTML = data[i].Name; row.childNodes[0].innerHTML = data[i].Name;
// TODO: incoming/outgoing symbol if(data[i].VoyageDirection == 0) row.childNodes[1].innerHTML = '<img src="img/bullet_square_yellow.png" />';
if(data[i].VoyageDirection == 1) row.childNodes[1].innerHTML = '<img src="img/arrow_down_red.png" />';
if(data[i].VoyageDirection == 2) row.childNodes[1].innerHTML = '<img src="img/arrow_up_green.png" />';
if(data[i].VoyageDirection == 3) row.childNodes[1].innerHTML = '<img src="img/clock.png" />';
row.childNodes[2].innerHTML = data[i].IMO; row.childNodes[2].innerHTML = data[i].IMO;
// find alarm cell and set value // find alarm cell and set value