Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
});
const session = await client.createSession();
const variableNodeID = "ns=2;s=Demo.WorkOrder.WorkOrderVariable";
const dataValueDataType = await session.read({ nodeId: variableNodeID, attributeId: AttributeIds.DataType });
console.log(" DataType =", dataValueDataType.value.value.toString());
const dataTypeNodeId = dataValueDataType.value.value as NodeId;
const extraDataTypeManager = await session.extractNamespaceDataType();
await getDataTypeDefinition(session, dataTypeNodeId, extraDataTypeManager);
const dataValueDataTypeBrowseName = await session.read({
attributeId: AttributeIds.BrowseName,
nodeId: dataValueDataType.value.value
});
console.log(" DataType BrowseName", dataValueDataTypeBrowseName.value.value.toString());
const dataValue = await session.read({ nodeId: variableNodeID, attributeId: AttributeIds.Value });
console.log(dataValue.toString());
await session.close();
await client.disconnect();
console.log("Done !");
}
return "";
}
switch (attribute) {
case AttributeIds.DataType:
return DataTypeIdsToString[dataValue.value.value.value] + " (" + dataValue.value.value.toString() + ")";
case AttributeIds.NodeClass:
return NodeClass[dataValue.value.value] + " (" + dataValue.value.value + ")";
case AttributeIds.IsAbstract:
case AttributeIds.Historizing:
case AttributeIds.EventNotifier:
return dataValue.value.value ? "true" : "false"
case AttributeIds.WriteMask:
case AttributeIds.UserWriteMask:
return " (" + dataValue.value.value + ")";
case AttributeIds.NodeId:
case AttributeIds.BrowseName:
case AttributeIds.DisplayName:
case AttributeIds.Description:
case AttributeIds.ValueRank:
case AttributeIds.ArrayDimensions:
case AttributeIds.Executable:
case AttributeIds.UserExecutable:
case AttributeIds.MinimumSamplingInterval:
if (!dataValue.value.value) {
return "null";
}
return dataValue.value.value.toString();
case AttributeIds.UserAccessLevel:
case AttributeIds.AccessLevel:
if (!dataValue.value.value) {
return "null";
}