Adding UnixTimestamp + Parse message type 27#149
Adding UnixTimestamp + Parse message type 27#149joshdadswellijyi wants to merge 6 commits intoais-dotnet:mainfrom
Conversation
|
|
||
| public interface ITimestamp | ||
| { | ||
| public long? UnixTimestamp { get; } |
There was a problem hiding this comment.
Unix timestamps come in two different units: seconds and milliseconds. I don't know which this is. Please could you rename it to make the units clear?
There was a problem hiding this comment.
I was simply using the field name that you had used to maintain continuity but can rename if desired?
| } | ||
|
|
||
| private void ParseMessageTypes1Through3(ReadOnlySpan<byte> asciiPayload, uint padding, int messageType) | ||
| private void ParseMessageTypes1Through3(NmeaLineParser nmeaLineParser, ReadOnlySpan<byte> asciiPayload, uint padding, int messageType) |
There was a problem hiding this comment.
The fact that we're now passing in a line parser and the ASCII payload seemed like a code smell to me, and now has me wondering: is there a layering issue here?
The timestamp isn't really part of the AIS message, it's actually from the surrounding NMEA layer, isn't it?
Before this change, these various message types represent the information that was broadcast by the vessels' AIS systems. The timestamp is not part of that. The provenance of the timestamp is not necessarily clear. It might tell us when the ground station that picked up the radio transmission received it. But in cases where messages are relayed as part of a large-scale network that collects AIS data from numerous stations, it might just tell you when the particular equipment you're plugged into received the message.
So for that reason I'm not sure if it is really correct to attach this to the types that represent AIS messages.
If you need access to information from the NMEA layer, might it be better to design in something where we make that available, and make it clear which pieces of information came from where?
There was a problem hiding this comment.
Again my scope to refactor and improve general code quality is limited as I have many other commitments but would welcome PRs on my repository if you dont want to undertake this work in yours.
|
@joshdadswellijyi - I've split out Ais.Net.Models to their own project, and implemented That's now referenced in I haven't implemented any of your Unix timestamp behaviour, because I don't believe we'd reached a conclusion as how best to implement the desired outcome. |
|
Jumping into this discussion as I have a specific problem that partly includes the need for unix timestamps. We are testing AIS.Net as the receiver component for live analysis of AIS data. We do not want to miss messages if we can avoid it, so in cases of application upgrades there will be a limited period of time where we have two receivers (R1 is running, R2 is deploying, R1 will shut down when R2 starts to receive messages) that pump messages into our data stream. There will be duplicates in our data stream and that is OK, since they will be filtered out later but to filter them out we need some sort of message uniqueness that I haven't been able to find in any of the parsed IAisMessage. A combination of the source station id and unix timestamp in My proposal, to keep backwards compatibility is as simple as adding giving users three options: |
|
@oskaremil - that's a very interesting scenario. One of the next things I wanted to look at was decoding the AIS messages and pushing them into NATS and I had an idea about using native NATS features to de-duplicate... but I've not got any further than thinking "that would be nice". |
Add metadata parsing and emission to ReceiverHost Introduced the ability to parse and emit metadata (station ID and Unix timestamp) alongside AIS messages in the `ReceiverHost` class. - Added `ParseNmeaBlockTags` method in `NmeaMessageExtensions.cs` to extract station ID and timestamp from NMEA block tags. - Created a `Metadata` record in `Metadata.cs` to encapsulate metadata. - Added a `metadata` subject and exposed it as an observable in `ReceiverHost.cs`. - Updated `StartAsyncInternal` to process and emit metadata. - Modified message processing logic to handle metadata observers. - Ensured proper completion of the `metadata` subject. - Added copyright header to `Metadata.cs`. These changes enhance the extensibility and functionality of the AIS message processing pipeline.
|
@oskaremil - I'm adding this feature request in #267 |
I have come accross the need to have the UnixTimestamp from the Nmea message so I implemented the following in order to accomplish that.
Library already read and extracted the timestamp I just needed to add it to the message records so it could be used outside the library.
This pull request also contains the parsing of message type 27 which you already had a decoder for in Ais.Net