TrakHound / MTConnect.NET

Fully featured .NET library in C# to build MTConnect Agent, Adapter, and Client Applications. Pre-built Agents with Windows Installers. Support for Windows and Linux. Supports MTConnect Versions up to 2.3. Supports .NET Framework 4.6.1 up to .NET 8
http://www.TrakHound.com
MIT License
96 stars 36 forks source link

Receiving Category information with Flat topic mode #45

Closed benaish closed 1 year ago

benaish commented 1 year ago

I'm using the Flat topic mode due to level limitation in AWS IoT Core. By doing that I'm losing important information that i would like to get as part of each message - Category (Event/Sample/..). It would be great to keep getting this information also on the flat topic mode. Another option could be to get this as part of the payload - but currently the Json formatter skips the Category when creating the payload out of the observation: return CreateMessage(topic, Formatters.EntityFormatter.Format(documentFormatterId, observation));

Related to a discussion in issue #42

PatrickRitchie commented 1 year ago

@benaish I agree that each message should contain Category. I'm looking at how to handle the MQTT Json to contain Category but the regular Json (sent over Http) to not contain Category since it is part of a full Response Document as opposed to MQTT that only sends the Entity.

My approach will most likely be to use an Options list (KeyValuePair) to pass a flag to the JsonEntityFormatter.Format(IEnumerable observations). I have a similar Options list for other methods in the EntityFormatter class.

I should have this added in a new release over the weekend.

Let me know if you have any further thoughts on how to handle this or if you have any other questions.

Thanks, -Patrick

PatrickRitchie commented 1 year ago

I just published the new 5.4.0 Release that contains this fix as well as some other additions to the MQTT implementation. More information can be found Here.

Let me know if this is what you were looking for.

Thanks, -Patrick

benaish commented 1 year ago

have a similar Options list for other methods in the EntityFormatter class. UPDATE: Works as expected

That's great, I will look into it!

Thanks, Moshe