-
-
Save simonbowen/c8a5f141a68c184df35223313873a205 to your computer and use it in GitHub Desktop.
Reading Pitch Array
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
})(); |
Author
simonbowen
commented
Apr 16, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment