Hausmeisterei Teil 3
This commit is contained in:
parent
0bf12b9b51
commit
fc947a301f
@ -109,7 +109,12 @@
|
||||
<Compile Include="AIS_Target.cs" />
|
||||
<Compile Include="IAISThread.cs" />
|
||||
<Compile Include="Lookup.cs" />
|
||||
<Compile Include="MonitorZone.cs" />
|
||||
<Compile Include="zone_alarm\Alarm.cs" />
|
||||
<Compile Include="zone_alarm\DBEntity.cs" />
|
||||
<Compile Include="zone_alarm\GeoPoint.cs" />
|
||||
<Compile Include="zone_alarm\MonitorAssignment.cs" />
|
||||
<Compile Include="zone_alarm\MonitorGroup.cs" />
|
||||
<Compile Include="zone_alarm\MonitorZone.cs" />
|
||||
<Compile Include="decoding\NMEA.cs" />
|
||||
<Compile Include="decoding\NMEA_AIS_Sentence.cs" />
|
||||
<Compile Include="decoding\NMEA_PNMLS_Sentence.cs" />
|
||||
@ -127,7 +132,7 @@
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="SerialTCPReader.cs" />
|
||||
<Compile Include="ShipLocationReport.cs" />
|
||||
<Compile Include="webservice\ShipLocationReport.cs" />
|
||||
<Compile Include="SitRep.cs" />
|
||||
<Compile Include="webservice\SLRController.cs" />
|
||||
<Compile Include="webservice\StartupWebAPI.cs" />
|
||||
|
||||
@ -1,8 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace bsmd.AIS2Service
|
||||
{
|
||||
|
||||
30
AIS/bsmd.AIS2Service/zone_alarm/Alarm.cs
Normal file
30
AIS/bsmd.AIS2Service/zone_alarm/Alarm.cs
Normal file
@ -0,0 +1,30 @@
|
||||
// Copyright (c) 2023 - schick Informatik
|
||||
// bsmd.AIS2Service [Alarm.cs]: Daniel Schick
|
||||
// Description: alarm created if vessel interacts with zone
|
||||
//
|
||||
using System;
|
||||
|
||||
namespace bsmd.AIS2Service
|
||||
{
|
||||
#region class Alarm
|
||||
|
||||
public class Alarm : DBEntity
|
||||
{
|
||||
private readonly MonitorAssignment _assignment;
|
||||
|
||||
public Alarm(long id, MonitorAssignment assignment) : base(id) { _assignment = assignment; }
|
||||
|
||||
public MonitorAssignment Assignment { get { return _assignment; } }
|
||||
|
||||
public DateTime Timestamp_First { get; set; }
|
||||
|
||||
public DateTime? Timestamp_Last { get; set; }
|
||||
|
||||
public DateTime? Acknowledged { get; set; }
|
||||
|
||||
public MonitorAssignment.ZoneMonitorType ZoneMonitorType { get; set; }
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
25
AIS/bsmd.AIS2Service/zone_alarm/DBEntity.cs
Normal file
25
AIS/bsmd.AIS2Service/zone_alarm/DBEntity.cs
Normal file
@ -0,0 +1,25 @@
|
||||
// Copyright (c) 2023 - schick Informatik
|
||||
// bsmd.AIS2Service [DBEntity.cs]: Daniel Schick
|
||||
// Description: Root class for SQlite database entities
|
||||
//
|
||||
|
||||
|
||||
namespace bsmd.AIS2Service
|
||||
{
|
||||
#region DBEntity
|
||||
|
||||
public class DBEntity
|
||||
{
|
||||
protected long _id; // PK from database
|
||||
|
||||
public DBEntity(long id)
|
||||
{
|
||||
_id = id;
|
||||
}
|
||||
|
||||
public long Id { get { return _id; } set { _id = value; } }
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
23
AIS/bsmd.AIS2Service/zone_alarm/GeoPoint.cs
Normal file
23
AIS/bsmd.AIS2Service/zone_alarm/GeoPoint.cs
Normal file
@ -0,0 +1,23 @@
|
||||
// Copyright (c) 2023 - schick Informatik
|
||||
// bsmd.AIS2Service.zone_alarm [GeoPoint.cs]: Daniel Schick
|
||||
// Description: Single vertex of a zone
|
||||
//
|
||||
|
||||
namespace bsmd.AIS2Service
|
||||
{
|
||||
#region class GeoPoint
|
||||
|
||||
public class GeoPoint : DBEntity
|
||||
{
|
||||
|
||||
public GeoPoint(long id) : base(id)
|
||||
{ }
|
||||
|
||||
public double Lat { get; set; }
|
||||
public double Lon { get; set; }
|
||||
|
||||
public long MonitorZoneId { get; set; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
44
AIS/bsmd.AIS2Service/zone_alarm/MonitorAssignment.cs
Normal file
44
AIS/bsmd.AIS2Service/zone_alarm/MonitorAssignment.cs
Normal file
@ -0,0 +1,44 @@
|
||||
// Copyright (c) 2023 - schick Informatik
|
||||
// bsmd.AIS2Service.zone_alarm [MonitorAssignment.cs]: Daniel Schick
|
||||
// Description: Mapping between targets (MMSI) and zones
|
||||
//
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace bsmd.AIS2Service
|
||||
{
|
||||
#region class MonitorAssignment
|
||||
|
||||
public class MonitorAssignment : DBEntity
|
||||
{
|
||||
|
||||
public MonitorAssignment(long id) : base(id)
|
||||
{ }
|
||||
|
||||
[Flags]
|
||||
public enum ZoneMonitorType
|
||||
{
|
||||
INACTIVE = 0,
|
||||
ENTER = 1,
|
||||
EXIT = 2,
|
||||
PASSTHROUGH = 4, // outside - enter - inside - exit - outside
|
||||
LEAVE_AND_RETURN = 8 // inside - exit - outside - enter - inside
|
||||
}
|
||||
|
||||
public int MMSI { get; set; }
|
||||
|
||||
public ZoneMonitorType MonitorType { get; set; } = ZoneMonitorType.INACTIVE;
|
||||
|
||||
public long MonitorZoneId { get; set; }
|
||||
|
||||
public List<Alarm> Alarms { get; } = new List<Alarm>();
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return String.Format("{0} {1}", MMSI, MonitorType);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
112
AIS/bsmd.AIS2Service/zone_alarm/MonitorGroup.cs
Normal file
112
AIS/bsmd.AIS2Service/zone_alarm/MonitorGroup.cs
Normal file
@ -0,0 +1,112 @@
|
||||
// Copyright (c) 2023 - schick Informatik
|
||||
// bsmd.AIS2Service [MonitorGroup.cs]: Daniel Schick
|
||||
// Description: Group container for zones
|
||||
//
|
||||
using log4net;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace bsmd.AIS2Service
|
||||
{
|
||||
#region class MonitorGroup
|
||||
|
||||
public class MonitorGroup : DBEntity
|
||||
{
|
||||
|
||||
private static readonly ILog _log = LogManager.GetLogger(typeof(MonitorGroup));
|
||||
|
||||
#region fields
|
||||
|
||||
private string _name;
|
||||
private readonly List<MonitorZone> _zones = new List<MonitorZone>();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Construction
|
||||
|
||||
public MonitorGroup(long id, string name) : base(id)
|
||||
{
|
||||
_name = name;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
public List<MonitorZone> Zones { get { return _zones; } }
|
||||
|
||||
public string Name { get { return _name; } set { _name = value; } }
|
||||
|
||||
#endregion
|
||||
|
||||
#region public static methods
|
||||
|
||||
/// <summary>
|
||||
/// Da Basti nun eine Datei mit allen Elementen exportiert gibt es eine einzelne Funktion, die alles
|
||||
/// importiert
|
||||
/// </summary>
|
||||
/// <param name="filename"></param>
|
||||
/// <returns></returns>
|
||||
public static List<MonitorGroup> LoadGroups(string filename)
|
||||
{
|
||||
List<MonitorGroup> groups = new List<MonitorGroup>();
|
||||
try
|
||||
{
|
||||
if (File.Exists(filename))
|
||||
{
|
||||
XDocument kml = XDocument.Load(filename);
|
||||
XNamespace ns = "http://www.opengis.net/kml/2.2";
|
||||
|
||||
foreach (XElement rootFolderNode in kml.Root.Element(ns + "Document").Element(ns + "Folder").Elements(ns + "Folder"))
|
||||
{
|
||||
MonitorGroup mg = new MonitorGroup(-1, rootFolderNode.Element(ns + "name").Value);
|
||||
int sequence = 1;
|
||||
foreach (XElement placemark in rootFolderNode.Elements(ns + "Placemark"))
|
||||
{
|
||||
MonitorZone mz = new MonitorZone(-1, placemark.Element(ns + "name").Value);
|
||||
mz.Active = true;
|
||||
mz.Sequence = sequence;
|
||||
// now add all vertices
|
||||
string[] vertices = placemark.Element(ns + "Polygon").Element(ns + "outerBoundaryIs").Element(ns + "LinearRing").Element(ns + "coordinates").Value.Split(' ');
|
||||
for (int i = 0; i < vertices.Length - 1; i++)
|
||||
{
|
||||
string[] pointElems = vertices[i].Trim().Split(',');
|
||||
if (pointElems.Length != 3) continue;
|
||||
GeoPoint gp = new GeoPoint(-1);
|
||||
gp.Lon = Double.Parse(pointElems[0], System.Globalization.NumberFormatInfo.InvariantInfo);
|
||||
gp.Lat = Double.Parse(pointElems[1], System.Globalization.NumberFormatInfo.InvariantInfo);
|
||||
mz.Vertices.Add(gp);
|
||||
}
|
||||
|
||||
mg.Zones.Add(mz);
|
||||
sequence++;
|
||||
}
|
||||
|
||||
groups.Add(mg);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_log.Error(ex.ToString());
|
||||
}
|
||||
return groups;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region public methods
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return this.Name;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -3,8 +3,6 @@
|
||||
// Description: Represents a geographical area that should be checked against
|
||||
// ship positions
|
||||
|
||||
using log4net;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
@ -12,124 +10,7 @@ using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace bsmd.AIS2Service
|
||||
{
|
||||
|
||||
#region DBEntity
|
||||
|
||||
public class DBEntity
|
||||
{
|
||||
protected long _id; // PK from database
|
||||
|
||||
public DBEntity(long id)
|
||||
{
|
||||
_id = id;
|
||||
}
|
||||
|
||||
public long Id { get { return _id; } set { _id = value; } }
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region class MonitorGroup
|
||||
|
||||
public class MonitorGroup : DBEntity
|
||||
{
|
||||
|
||||
private static readonly ILog _log = LogManager.GetLogger(typeof(MonitorGroup));
|
||||
|
||||
#region fields
|
||||
|
||||
private string _name;
|
||||
private readonly List<MonitorZone> _zones = new List<MonitorZone>();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Construction
|
||||
|
||||
public MonitorGroup(long id, string name) : base( id )
|
||||
{
|
||||
_name = name;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
public List<MonitorZone> Zones { get { return _zones; } }
|
||||
|
||||
public string Name { get { return _name; } set { _name = value; } }
|
||||
|
||||
#endregion
|
||||
|
||||
#region public static methods
|
||||
|
||||
/// <summary>
|
||||
/// Da Basti nun eine Datei mit allen Elementen exportiert gibt es eine einzelne Funktion, die alles
|
||||
/// importiert
|
||||
/// </summary>
|
||||
/// <param name="filename"></param>
|
||||
/// <returns></returns>
|
||||
public static List<MonitorGroup> LoadGroups(string filename)
|
||||
{
|
||||
List<MonitorGroup> groups = new List<MonitorGroup>();
|
||||
try
|
||||
{
|
||||
if (File.Exists(filename))
|
||||
{
|
||||
XDocument kml = XDocument.Load(filename);
|
||||
XNamespace ns = "http://www.opengis.net/kml/2.2";
|
||||
|
||||
foreach(XElement rootFolderNode in kml.Root.Element(ns + "Document").Element(ns + "Folder").Elements(ns + "Folder"))
|
||||
{
|
||||
MonitorGroup mg = new MonitorGroup(-1, rootFolderNode.Element(ns + "name").Value);
|
||||
int sequence = 1;
|
||||
foreach(XElement placemark in rootFolderNode.Elements(ns + "Placemark"))
|
||||
{
|
||||
MonitorZone mz = new MonitorZone(-1, placemark.Element(ns + "name").Value);
|
||||
mz.Active = true;
|
||||
mz.Sequence = sequence;
|
||||
// now add all vertices
|
||||
string[] vertices = placemark.Element(ns + "Polygon").Element(ns + "outerBoundaryIs").Element(ns + "LinearRing").Element(ns + "coordinates").Value.Split(' ');
|
||||
for (int i = 0; i < vertices.Length - 1; i++)
|
||||
{
|
||||
string[] pointElems = vertices[i].Trim().Split(',');
|
||||
if (pointElems.Length != 3) continue;
|
||||
GeoPoint gp = new GeoPoint(-1);
|
||||
gp.Lon = Double.Parse(pointElems[0], System.Globalization.NumberFormatInfo.InvariantInfo);
|
||||
gp.Lat = Double.Parse(pointElems[1], System.Globalization.NumberFormatInfo.InvariantInfo);
|
||||
mz.Vertices.Add(gp);
|
||||
}
|
||||
|
||||
mg.Zones.Add(mz);
|
||||
sequence++;
|
||||
}
|
||||
|
||||
groups.Add(mg);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
_log.Error(ex.ToString());
|
||||
}
|
||||
return groups;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region public methods
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return this.Name;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
{
|
||||
|
||||
#region class MonitorZone
|
||||
|
||||
@ -235,79 +116,6 @@ namespace bsmd.AIS2Service
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region class GeoPoint
|
||||
|
||||
public class GeoPoint : DBEntity
|
||||
{
|
||||
|
||||
public GeoPoint(long id) : base (id)
|
||||
{}
|
||||
|
||||
public double Lat { get; set; }
|
||||
public double Lon { get; set; }
|
||||
|
||||
public long MonitorZoneId { get; set; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region class MonitorAssignment
|
||||
|
||||
public class MonitorAssignment : DBEntity
|
||||
{
|
||||
|
||||
public MonitorAssignment(long id) : base(id)
|
||||
{}
|
||||
|
||||
[Flags]
|
||||
public enum ZoneMonitorType
|
||||
{
|
||||
INACTIVE = 0,
|
||||
ENTER = 1,
|
||||
EXIT = 2,
|
||||
PASSTHROUGH = 4, // outside - enter - inside - exit - outside
|
||||
LEAVE_AND_RETURN = 8 // inside - exit - outside - enter - inside
|
||||
}
|
||||
|
||||
public int MMSI { get; set; }
|
||||
|
||||
public ZoneMonitorType MonitorType { get; set; } = ZoneMonitorType.INACTIVE;
|
||||
|
||||
public long MonitorZoneId { get; set; }
|
||||
|
||||
public List<Alarm> Alarms { get; } = new List<Alarm>();
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return String.Format("{0} {1}", MMSI, MonitorType);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region class Alarm
|
||||
|
||||
public class Alarm : DBEntity
|
||||
{
|
||||
private readonly MonitorAssignment _assignment;
|
||||
|
||||
public Alarm(long id, MonitorAssignment assignment) : base(id) { _assignment = assignment; }
|
||||
|
||||
public MonitorAssignment Assignment { get { return _assignment; } }
|
||||
|
||||
public DateTime Timestamp_First { get; set; }
|
||||
|
||||
public DateTime? Timestamp_Last { get; set; }
|
||||
|
||||
public DateTime? Acknowledged { get; set; }
|
||||
|
||||
public MonitorAssignment.ZoneMonitorType ZoneMonitorType { get; set; }
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user