eclipse-aaspe / server

C# based server for AASX packages
Other
69 stars 51 forks source link

Infos about MQTT usage #69

Open tonivss opened 3 years ago

tonivss commented 3 years ago

I can not find any information about the usage of the mqtt publisher, like topic and subsriber information. Please provide some documentation.

JoelKrec commented 2 years ago

Tldr: I am really new to Mqtt so I cant be certain but I think this feature seems unfinished and the timer that publishes submodels is not started currently. Release version I looked through: 2022-01-13.alpha

As said in tldr: I dont have a lot of qualifications to say something of high value here but I think I can just say what I found and think. If that is against any kind of rules here, please tell me. I will delete my comment afterwards.

If you use the option "--mqtt" in command line, aasxs will set up a mqtt broker on localhost with the standard mqtt port 1883.

In AasxServerStandardBib/Program.cs at 1792, there is code to start a mqtt client in the backround which will publish every submodel as json with topic "Submodel_" + submodel id short.

This code is in a method called OnRestTimedEvent which is added as an event listener in a method called SetRestTimer. This set-timer-method is never used and therefore, it wont publish anything. The rest of the OnRestTimedEvent method contains as the name implies stuff about updating Rest stuff for GET and POST. But I didnt look much into that as this wasnt my problem.

To get the server to publish submodels I just called SetRestTimer(2000) at 518 in AasxServerStandardBib/Program.cs. The integer is the rate in milliseconds at which the timer event fires. For now, it seems like the other unused code doesnt throw any problems but I didnt test it too much.

My plan for the future is to create a mqtt timer like the rest and opc timers with the backround worker code I mentioned earlier extracted from the current rest timer. Maybe even add an option to the command line thingy ( I dont know what it is called ), so that I can use a different broker and credentials (like --mqtt-broker and --mqtt-credentials ). But that seems to be out of my reach for now.

Again, please tell me if I did something against the rules. I will react the fastest to an email at jk@iniationware.com

I hoped my comment helped a little bit.