本文整理汇总了TypeScript中node-opcua-client.OPCUAClient.on方法的典型用法代码示例。如果您正苦于以下问题:TypeScript OPCUAClient.on方法的具体用法?TypeScript OPCUAClient.on怎么用?TypeScript OPCUAClient.on使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类node-opcua-client.OPCUAClient
的用法示例。
在下文中一共展示了OPCUAClient.on方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: startOnGoingConnection
async function startOnGoingConnection(endpointUri: string) {
onGoingClient = OPCUAClient.create({
certificateFile: clientCertificateFile,
privateKeyFile: clientPrivateKeyFile,
securityMode: MessageSecurityMode.SignAndEncrypt,
securityPolicy: SecurityPolicy.Basic256
});
onGoingClient.on("start_reconnection", () => {
debugLog(chalk.bgWhite.red(" !!!!!!!!!!!!!!!!!!!!!!!! Starting Reconnection !!!!!!!!!!!!!!!!!!!"));
});
onGoingClient.on("backoff", (retry: number, delay: number) => {
debugLog(chalk.bgWhite.yellow("backoff attempt #"), retry, " retrying in ", delay / 1000.0, " seconds");
});
onGoingClient.on("connection_reestablished", () => {
debugLog(chalk.bgWhite.red(" !!!!!!!!!!!!!!!!!!!!!!!! CONNECTION RE-ESTABLISHED !!!!!!!!!!!!!!!!!!!"));
debugLog(" Server certificate is now ", makeSHA1Thumbprint(onGoingClient.serverCertificate!).toString("base64"));
});
onGoingClient.on("connection_lost", () => {
debugLog(chalk.bgWhite.red("Client has lost connection ..."));
debugLog(chalk.bgWhite.red(" Server certificate was ", makeSHA1Thumbprint(onGoingClient.serverCertificate!).toString("base64")));
});
onGoingClient.on("close", () => {
debugLog(chalk.bgWhite.red("client has CLOOOOOOOOOOSSSSSED"));
});
await onGoingClient.connect(endpointUri);
onGoingSession = await onGoingClient.createSession();
const subscription = await onGoingSession.createSubscription2({
requestedPublishingInterval: 500,
maxNotificationsPerPublish: 1000,
publishingEnabled: true,
requestedLifetimeCount: 100,
requestedMaxKeepAliveCount: 10
});
const monitoredItem = await subscription.monitor({
attributeId: AttributeIds.Value,
nodeId: "i=2258" // Current Time
},
{ samplingInterval: 500 }, TimestampsToReturn.Both);
count = 0;
monitoredItem.on("changed", (dataValue: DataValue) => {
debugLog(" ", chalk.cyan(dataValue.value.toString()));
count++;
});
await new Promise((resolve) => setTimeout(resolve, 1500));
}