Zonen werden erfolgreich erkannt

This commit is contained in:
Daniel Schick 2022-12-30 11:41:32 +01:00
parent 9287239f71
commit 119eebd00c
2 changed files with 39 additions and 1 deletions

View File

@ -4,10 +4,12 @@
// to monitor zones // to monitor zones
// //
using log4net;
using System; using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Security.Policy;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -23,6 +25,7 @@ namespace bsmd.AIS2Service
AIS_SQLiteStorage _storage; AIS_SQLiteStorage _storage;
private Thread _thread; private Thread _thread;
private bool _stopFlag = false; private bool _stopFlag = false;
private static readonly ILog _log = LogManager.GetLogger(typeof(AISZoneMonitor));
#endregion #endregion
@ -41,12 +44,38 @@ namespace bsmd.AIS2Service
private void Monitor() private void Monitor()
{ {
// load zones from storage // load zones from storage
List<MonitorZone> allZones = _storage.LoadMonitorZones();
Dictionary<int, List<MonitorZone>> testZones = new Dictionary<int, List<MonitorZone>>();
foreach(MonitorZone zone in allZones)
{
// load up Zone list for all assignment mmsi's (to check)
foreach(MonitorAssignment ma in zone.Assignments)
{
if(!testZones.ContainsKey(ma.MMSI)) testZones[ma.MMSI] = new List<MonitorZone>();
testZones[ma.MMSI].Add(zone);
}
}
// loop // loop
while(!_stopFlag) while(!_stopFlag)
{ {
// check all "current" AIS Targets against the zones // check all "current" AIS Targets against the zones
foreach(int mmsi in _sitRepDict.Keys)
{
if(testZones.ContainsKey(mmsi))
{
AIS_Target target = _sitRepDict[mmsi];
foreach(MonitorZone zone in testZones[mmsi]) {
if(zone.IsPointInPolygon4(target.Position))
{
_log.InfoFormat("{0} is in zone {1}", target.ToString(), zone.Name);
}
}
}
}
int currentSaturationSecs = 0; // (DateTime.Now - alarm.FirstDetected).TotalSeconds; int currentSaturationSecs = 0; // (DateTime.Now - alarm.FirstDetected).TotalSeconds;
if(currentSaturationSecs > Properties.Settings.Default.MonitorTargetSaturationSecs) if(currentSaturationSecs > Properties.Settings.Default.MonitorTargetSaturationSecs)
{ {

View File

@ -207,6 +207,15 @@ namespace bsmd.AIS2Service
public int UpdateCount { get; private set; } public int UpdateCount { get; private set; }
public GeoPoint Position
{
get { GeoPoint gp = new GeoPoint(-1);
gp.Lat = this.Latitude ?? 0;
gp.Lon = this.Longitude ?? 0;
return gp;
}
}
#endregion #endregion
#region internal update methods #region internal update methods