cppagent
cppagent copied to clipboard
Building An Adapter
Anyone got any advice on building their own adapter? Right now I'm trying to build one for a local machine and it's not going great.
An adapter us host a socket server that streams pip delimited data starting with a timestamp and followed by key value pairs (for simple cases).
An adapter can be written in as little as 5 lines of ruby or python and we have some examples on GitHub.
What are the specific issues?
- W
On Aug 16, 2022, at 08:54, sdstncl @.***> wrote:
Anyone got any advice on building their own adapter? Right now I'm trying to build one for a local machine and it's not going great.
— Reply to this email directly, view it on GitHub https://github.com/mtconnect/cppagent/issues/257, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJ6BCKHJ2FPV6LR5PKNA5DVZO2SRANCNFSM56WLSLBA. You are receiving this because you are subscribed to this thread.
Currently, I'm trying to create an adapter that will utilize Modbus to read registers and upload the values that they read. I've attempted to utilize NModbus, which I've read is useful for doing Modbus stuff in C#. However, it seems that NModbus utilizes a different .NetFramework (Version 4.0) compared to the .NetFramework that the dot_net_sdk solution file uses, so that's dead in the water. Checking the MTConnect github again, there is an adapter repository that seems to have created a Modbus adapter, however I'm not exactly sure how I should go about modifying the file to suit my needs. I don't mean for this to come off as whining, I'm just not exactly sure what needs modification in these files and what doesn't. I've already managed to create a MTC agent and a modified XML file to suit my needs. I'm also fully aware that I may just be looking at the wrong files
@sdstncl For simplicity, can you spin up NodeRed and install the modbus node?
The flow would look something like this:

Once you can read data using a TCP client, we'll move into structuring the data as SHDR and managing heartbeat.
@sdstncl
Here are some alternatives:
JS https://github.com/Ladder99/ladder99/tree/main/services/adapter
.NET https://github.com/TrakHound/MTConnect.NET (used in Fanuc-Driver https://github.com/Ladder99/fanuc-driver/blob/main/fanuc/transports/SHDR.cs)
Ladder99 uses NodeJS - the latest branch is here - https://github.com/Ladder99/ladder99/tree/historian/services/adapter.
An example that reads an autoclave status - https://github.com/Ladder99/ladder99/blob/historian/services/adapter/src/drivers/autoclave/cpc.js. It writes to a cache that checks if a value changed before outputting SHDR to the agent.
We're on version 0.8. Docs are here - https://docs.ladder99.com.
If there is no more discussion I will close this issue.
Closing the issue