Skip to content

Instantly share code, notes, and snippets.

@simonbowen

simonbowen/pitch.js Secret

Created Apr 16, 2021
Embed
What would you like to do?
Reading Pitch Array
import { OPCUAClient, AttributeIds, TimestampsToReturn } from "node-opcua";
const endpoint = "opc.tcp://192.168.100.64:4840";
const PITCH_NODE = "ns=6;s=::CuttingLab:DataExchange.Cfg.Cutting.Pitch";
const PITCH_NODE_INDEX = "ns=6;s=::CuttingLab:DataExchange.Cfg.Cutting.Pitch[0].PitchWidth";
(async () => {
try {
const client = OPCUAClient.create({
endpointMustExist: false,
connectionStrategy: {
maxRetry: 2,
initialDelay: 2000,
maxDelay: 10 * 1000
}
});
await client.connect(endpoint);
const session = await client.createSession({ userName: 'XXXXX', password: 'XXXXX' });
const pitch_index = await session.read({
nodeId: PITCH_NODE_INDEX,
attributeId: AttributeIds.Value,
});
console.log(pitch_index.toString());
const pitch = await session.read({
nodeId: PITCH_NODE,
attributeId: AttributeIds.Value,
});
console.log(pitch.toString());
await session.close();
await client.disconnect()
} catch (err) {
console.log(err);
}
})();
@simonbowen

This comment has been minimized.

Copy link
Owner Author

@simonbowen simonbowen commented Apr 16, 2021

{ /* DataValue */
   value: Variant(Scalar<Int16>, value: 0)
   statusCode:      Good (0x00000)
   serverTimestamp: 2021-04-16T08:31:25.233Z $ 400.000.000
   sourceTimestamp: 2021-04-16T08:31:25.233Z $ 400.000.000
}
{ /* DataValue */
   value: Variant(Scalar<Null>, value: <null>)
   statusCode:      BadNotSupported (0x803d0000)
   serverTimestamp: 2021-04-16T08:31:25.243Z $ 000.000.000
   sourceTimestamp: 2021-04-16T08:31:25.408Z $ 600.000.000
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment