As a weekend project, I put together a command-line MTConnect client. It’s coded in C# for .NET 5.0, and I’ve published the source code on GitHub. It’s still a little rough around the edges, but here’s a quick look.
One use for a command-line client might be for easily checking whether an MTConnect agent is running at a given address. The test just runs a probe and checks whether an MTConnectDevicesDocument is returned.
Obviously the error message is not great, but OK means ok, and Error means not ok.
(Part of the check didn’t make it into the initial release, but the client should still identify a webserver serving non-XML data as not being an MTConnect agent. This’ll be fixed in the next release.)
Another use might be to easily feed data to stdout for scripting purposes. The client will output the entirety of a “Current” or “Sample” MTConnectStreamsDocument by default. Output can be configured for XML or JSON.
It can also be configured to filter dataItems by id, name, category, type, and/or subtype. In this case, the client will output a list of dataItems that match the filter. Output can be configured for XML, JSON, or CSV.
(Ok, the CSV output is pretty broken. It doesn’t include column headers. It doesn’t include condition. It doesn’t deal with escaping commas etc.)
If no commands are passed on the command-line, the client will start interactive mode. Enter a command at the > prompt, and it will be run immediately. The screenshot above shows outputting a particular dataItem as XML or JSON, displaying help, and outputting a probe request.
I’ll update this client as time permits and whenever I notice bugs. If you’re interested in seeing features (or notice bugs that I’ve missed) please contact me here or on GitHub.