MTConnect's REST protocol and digital twin methods in typescript. Perfect for React apps.
Huge credit to Will Sobel (Chief Architect of MTConnect) for his original work in cppagent.
This library is born from MTConnect's reference cppagent's demo.
Major changes include:
- translation from JavaScript to TypeScript
- adjustments to enable streaming multiple devices (whereas original presumed single device per instance)
A basic demo is provided as an included npm script.
cd to/repo/location
npm install
npm build
launch demo server specifying target agent url as launch arg
npm run demo -- [targetAgentIP]:5000
replace [targetAgentIP]:5000
with your target agent's address and port
finally check out the demo at localhost:3000
npm install mtconnect-ts
Add it as a submodule to your project
git submodule add https://github.com/processrobotics/mtconnect-ts
Build it
npm run build
Install locally
cd path/to/your/project/root && npm run install ./path/to/submodule
import { Rest } from "@mx-interface/mtconnect-ts"
const rest = new Rest(`http://${host}`, (values: any) => {
if (values.length !== 0) {
values.forEach((item) => {
console.log(item);
}
}
})
const probe = await rest.probeMachine();
console.log(probe)
await rest.current();
await rest.streamSample();