本文整理匯總了TypeScript中node-opcua-client.OPCUAClient.createSession方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript OPCUAClient.createSession方法的具體用法?TypeScript OPCUAClient.createSession怎麽用?TypeScript OPCUAClient.createSession使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類node-opcua-client.OPCUAClient
的用法示例。
在下文中一共展示了OPCUAClient.createSession方法的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));
}