Hello all,
I have been looking around and trying to find an example of publishing a component service using C++ online, but I couldn’t find anything. So I decided to ask my questions here.
My guess is that I should implement a service component and then publish it by overriding the the Arp ComponentBase::PublishServices() method. Here again, my guess is that I should call the static ServiceManager::PublishService method. I was looking for an example of how this can be done.
To make it more concrete I explain a simple use case:
I would like to implement a SettingsManagerService with the following service calls:
LoadSetting(string path): reads my Json settings file and returns the value stored for path
WriteSetting(string path, string value): writes a value for path in my Json file
Can you please elaborate on how the above can be achieved, or even better direct me to examples where something similar has been done?
Thanks in advance!
I do see both by looking at IDataAccessService header file and the video here: https://www.youtube.com/watch?v=iBM5qE1t5UQ
That the official (and maybe only) way seems to be through C#. Is that correct? If I have to use C#, is starting from a gRPC proto file to define my service interface a more efficient way of doing things?
Hi, you found the right video, but unfortunately it has not aged particularly well.
At the time we made that video, we had plans to publish detailed documentation explaining how someone could build their own RSC services for the PLCnext Runtime. Unfortunately that procedure is so complicated and error-prone, that it was decided not to publish that information. We were hoping that eventually the process could be simplified (for example by developing software utilities that could help), but that hasn’t happened so far.
In summary, unfortunately it is practically impossible for external users to create RSC services like the ones that are included with the PLCnext Runtime.
One development that may give you some ideas - recently we introduced a gRPC server to the PLCnext Runtime, which aims to provide all the same services as the original RSC services, but using gRPC. That means all the standard gRPC libraries are now included with the firmware on every PLCnext Control device. If you are able to create gRPC services on any platform, then you could also consider creating your PLCnext Runtime component with a gRPC interface. gRPC is not specific to the PLCnext Runtime, so there is lots of help available for this on the internet.
I hope this answers your question.