Class AISConnection
- Namespace
- NominalSystems.Maritime
- Assembly
- NominalSystems.Maritime.dll
This class handles an interface with the Automatic Identification System (AIS) for Marine vessels. This class allows for a connection to be made with a Web Socket and the AIS API and for making requests to the system. A valid API key must be present for this system to work correctly.
public class AISConnection
- Inheritance
-
AISConnection
Constructors
AISConnection(string, Simulation?)
Creates a new AIS connection with a valid AIS API key. This key must exist.
public AISConnection(string apiKey, Simulation? simulation = null)
Parameters
apiKey
string[-] A valid API key for the AIS system
simulation
SimulationAn optional simulation value for adding vessels to a simulation
Properties
ApiKey
The API key of the connection, as provided in the constructor of the connection.
public string ApiKey { get; }
Property Value
Connected
A flag indicating whether the client is connected to the AIS system or not.
public bool Connected { get; }
Property Value
ConnectionState
The current connection state if the client exists taken from the web socket client.
public WebSocketState ConnectionState { get; }
Property Value
Methods
CloseWebSocket()
Closes the websocket connection, if open and ensures that the data is safely disconnected.
public void CloseWebSocket()
CreateRequest(double[][][]?, string[]?, string[]?, int, double)
Creates a new request to the AIS system with a series of parameters that are requested within the web socket. It then, within a timeout, waits for a series of messages and vessels and adds the vessels to the list.
public Task CreateRequest(double[][][]? bounds = null, string[]? messageTypes = null, string[]? vesselIDs = null, int numVessels = 100, double timeout = 10)
Parameters
bounds
double[][][]A bounding box array set for the minimum and maximum bounds
messageTypes
string[]A filter of message types that can be returned
vesselIDs
string[]A filter of ship IDs that can be returned
numVessels
intThe number of unqiue vessels to fetch
timeout
double[s] The timeout before the request will close
Returns
- Task
[-] An asynchronous task to perform the request
GetVessels()
Returns the list of vessels contained within the current AIS connection.
public List<Vessel> GetVessels()