Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function monitor_item(treeItem) {
const node = treeItem.node;
g_subscription.monitor({
nodeId: node.nodeId,
attributeId: opcua.AttributeIds.Value
//, dataEncoding: { namespaceIndex: 0, name:null }
}, {
samplingInterval: 1000,
discardOldest: true,
queueSize: 100
},
opcua.TimestampsToReturn.Both,
function (err, monitoredItem) {
if (err) {
console.log("cannot create monitored item", err.message);
return;
}
node.monitoredItem = monitoredItem;
function toString1(attribute, dataValue) {
if (!dataValue || !dataValue.value || !dataValue.value.hasOwnProperty("value")) {
return "";
}
switch (attribute) {
case opcua.AttributeIds.DataType:
return DataTypeIdsToString[dataValue.value.value.value] + " (" + dataValue.value.value.toString() + ")";
case opcua.AttributeIds.NodeClass:
return NodeClass[dataValue.value.value] + " (" + dataValue.value.value + ")";
case opcua.AttributeIds.IsAbstract:
case opcua.AttributeIds.Historizing:
case opcua.AttributeIds.EventNotifier:
return dataValue.value.value ? "true" : "false"
case opcua.AttributeIds.WriteMask:
case opcua.AttributeIds.UserWriteMask:
return " (" + dataValue.value.value + ")";
case opcua.AttributeIds.NodeId:
case opcua.AttributeIds.BrowseName:
case opcua.AttributeIds.DisplayName:
case opcua.AttributeIds.Description:
case opcua.AttributeIds.ValueRank:
case opcua.AttributeIds.ArrayDimensions:
case opcua.AttributeIds.Executable:
case opcua.AttributeIds.UserExecutable:
case opcua.AttributeIds.MinimumSamplingInterval:
if (!dataValue.value.value) {
return NodeClass[dataValue.value.value] + " (" + dataValue.value.value + ")";
case opcua.AttributeIds.IsAbstract:
case opcua.AttributeIds.Historizing:
case opcua.AttributeIds.EventNotifier:
return dataValue.value.value ? "true" : "false"
case opcua.AttributeIds.WriteMask:
case opcua.AttributeIds.UserWriteMask:
return " (" + dataValue.value.value + ")";
case opcua.AttributeIds.NodeId:
case opcua.AttributeIds.BrowseName:
case opcua.AttributeIds.DisplayName:
case opcua.AttributeIds.Description:
case opcua.AttributeIds.ValueRank:
case opcua.AttributeIds.ArrayDimensions:
case opcua.AttributeIds.Executable:
case opcua.AttributeIds.UserExecutable:
case opcua.AttributeIds.MinimumSamplingInterval:
if (!dataValue.value.value) {
return "null";
}
return dataValue.value.value.toString();
case opcua.AttributeIds.UserAccessLevel:
case opcua.AttributeIds.AccessLevel:
if (!dataValue.value.value) {
return "null";
}
return opcua.accessLevelFlagToString(dataValue.value.value) + " (" + dataValue.value.value + ")";
default:
return dataValueToString(dataValue);
}
}
return DataTypeIdsToString[dataValue.value.value.value] + " (" + dataValue.value.value.toString() + ")";
case opcua.AttributeIds.NodeClass:
return NodeClass[dataValue.value.value] + " (" + dataValue.value.value + ")";
case opcua.AttributeIds.IsAbstract:
case opcua.AttributeIds.Historizing:
case opcua.AttributeIds.EventNotifier:
return dataValue.value.value ? "true" : "false"
case opcua.AttributeIds.WriteMask:
case opcua.AttributeIds.UserWriteMask:
return " (" + dataValue.value.value + ")";
case opcua.AttributeIds.NodeId:
case opcua.AttributeIds.BrowseName:
case opcua.AttributeIds.DisplayName:
case opcua.AttributeIds.Description:
case opcua.AttributeIds.ValueRank:
case opcua.AttributeIds.ArrayDimensions:
case opcua.AttributeIds.Executable:
case opcua.AttributeIds.UserExecutable:
case opcua.AttributeIds.MinimumSamplingInterval:
if (!dataValue.value.value) {
return "null";
}
return dataValue.value.value.toString();
case opcua.AttributeIds.UserAccessLevel:
case opcua.AttributeIds.AccessLevel:
if (!dataValue.value.value) {
return "null";
}
return opcua.accessLevelFlagToString(dataValue.value.value) + " (" + dataValue.value.value + ")";
default:
return dataValueToString(dataValue);
}
return " (" + dataValue.value.value + ")";
case opcua.AttributeIds.NodeId:
case opcua.AttributeIds.BrowseName:
case opcua.AttributeIds.DisplayName:
case opcua.AttributeIds.Description:
case opcua.AttributeIds.ValueRank:
case opcua.AttributeIds.ArrayDimensions:
case opcua.AttributeIds.Executable:
case opcua.AttributeIds.UserExecutable:
case opcua.AttributeIds.MinimumSamplingInterval:
if (!dataValue.value.value) {
return "null";
}
return dataValue.value.value.toString();
case opcua.AttributeIds.UserAccessLevel:
case opcua.AttributeIds.AccessLevel:
if (!dataValue.value.value) {
return "null";
}
return opcua.accessLevelFlagToString(dataValue.value.value) + " (" + dataValue.value.value + ")";
default:
return dataValueToString(dataValue);
}
}
function toString1(attribute, dataValue) {
if (!dataValue || !dataValue.value || !dataValue.value.hasOwnProperty("value")) {
return "";
}
switch (attribute) {
case opcua.AttributeIds.DataType:
return DataTypeIdsToString[dataValue.value.value.value] + " (" + dataValue.value.value.toString() + ")";
case opcua.AttributeIds.NodeClass:
return NodeClass[dataValue.value.value] + " (" + dataValue.value.value + ")";
case opcua.AttributeIds.IsAbstract:
case opcua.AttributeIds.Historizing:
case opcua.AttributeIds.EventNotifier:
return dataValue.value.value ? "true" : "false"
case opcua.AttributeIds.WriteMask:
case opcua.AttributeIds.UserWriteMask:
return " (" + dataValue.value.value + ")";
case opcua.AttributeIds.NodeId:
case opcua.AttributeIds.BrowseName:
case opcua.AttributeIds.DisplayName:
case opcua.AttributeIds.Description:
case opcua.AttributeIds.ValueRank:
case opcua.AttributeIds.ArrayDimensions:
case opcua.AttributeIds.Executable:
case opcua.AttributeIds.UserExecutable:
case opcua.AttributeIds.MinimumSamplingInterval:
if (!dataValue.value.value) {
return "null";
}
return dataValue.value.value.toString();
case opcua.AttributeIds.UserAccessLevel:
function toString1(attribute, dataValue) {
if (!dataValue || !dataValue.value || !dataValue.value.hasOwnProperty("value")) {
return "";
}
switch (attribute) {
case opcua.AttributeIds.DataType:
return DataTypeIdsToString[dataValue.value.value.value] + " (" + dataValue.value.value.toString() + ")";
case opcua.AttributeIds.NodeClass:
return NodeClass[dataValue.value.value] + " (" + dataValue.value.value + ")";
case opcua.AttributeIds.IsAbstract:
case opcua.AttributeIds.Historizing:
case opcua.AttributeIds.EventNotifier:
return dataValue.value.value ? "true" : "false"
case opcua.AttributeIds.WriteMask:
case opcua.AttributeIds.UserWriteMask:
return " (" + dataValue.value.value + ")";
case opcua.AttributeIds.NodeId:
case opcua.AttributeIds.BrowseName:
case opcua.AttributeIds.DisplayName:
case opcua.AttributeIds.Description:
case opcua.AttributeIds.ValueRank:
case opcua.AttributeIds.ArrayDimensions:
case opcua.AttributeIds.Executable:
case opcua.AttributeIds.UserExecutable:
case opcua.AttributeIds.MinimumSamplingInterval:
if (!dataValue.value.value) {
return "null";
case opcua.AttributeIds.IsAbstract:
case opcua.AttributeIds.Historizing:
case opcua.AttributeIds.EventNotifier:
return dataValue.value.value ? "true" : "false"
case opcua.AttributeIds.WriteMask:
case opcua.AttributeIds.UserWriteMask:
return " (" + dataValue.value.value + ")";
case opcua.AttributeIds.NodeId:
case opcua.AttributeIds.BrowseName:
case opcua.AttributeIds.DisplayName:
case opcua.AttributeIds.Description:
case opcua.AttributeIds.ValueRank:
case opcua.AttributeIds.ArrayDimensions:
case opcua.AttributeIds.Executable:
case opcua.AttributeIds.UserExecutable:
case opcua.AttributeIds.MinimumSamplingInterval:
if (!dataValue.value.value) {
return "null";
}
return dataValue.value.value.toString();
case opcua.AttributeIds.UserAccessLevel:
case opcua.AttributeIds.AccessLevel:
if (!dataValue.value.value) {
return "null";
}
return opcua.accessLevelFlagToString(dataValue.value.value) + " (" + dataValue.value.value + ")";
default:
return dataValueToString(dataValue);
}
}
switch (attribute) {
case opcua.AttributeIds.DataType:
return DataTypeIdsToString[dataValue.value.value.value] + " (" + dataValue.value.value.toString() + ")";
case opcua.AttributeIds.NodeClass:
return NodeClass[dataValue.value.value] + " (" + dataValue.value.value + ")";
case opcua.AttributeIds.IsAbstract:
case opcua.AttributeIds.Historizing:
case opcua.AttributeIds.EventNotifier:
return dataValue.value.value ? "true" : "false"
case opcua.AttributeIds.WriteMask:
case opcua.AttributeIds.UserWriteMask:
return " (" + dataValue.value.value + ")";
case opcua.AttributeIds.NodeId:
case opcua.AttributeIds.BrowseName:
case opcua.AttributeIds.DisplayName:
case opcua.AttributeIds.Description:
case opcua.AttributeIds.ValueRank:
case opcua.AttributeIds.ArrayDimensions:
case opcua.AttributeIds.Executable:
case opcua.AttributeIds.UserExecutable:
case opcua.AttributeIds.MinimumSamplingInterval:
if (!dataValue.value.value) {
return "null";
}
return dataValue.value.value.toString();
case opcua.AttributeIds.UserAccessLevel:
case opcua.AttributeIds.AccessLevel:
if (!dataValue.value.value) {
return "null";
}
return opcua.accessLevelFlagToString(dataValue.value.value) + " (" + dataValue.value.value + ")";
default:
}
switch (attribute) {
case opcua.AttributeIds.DataType:
return DataTypeIdsToString[dataValue.value.value.value] + " (" + dataValue.value.value.toString() + ")";
case opcua.AttributeIds.NodeClass:
return NodeClass[dataValue.value.value] + " (" + dataValue.value.value + ")";
case opcua.AttributeIds.IsAbstract:
case opcua.AttributeIds.Historizing:
case opcua.AttributeIds.EventNotifier:
return dataValue.value.value ? "true" : "false"
case opcua.AttributeIds.WriteMask:
case opcua.AttributeIds.UserWriteMask:
return " (" + dataValue.value.value + ")";
case opcua.AttributeIds.NodeId:
case opcua.AttributeIds.BrowseName:
case opcua.AttributeIds.DisplayName:
case opcua.AttributeIds.Description:
case opcua.AttributeIds.ValueRank:
case opcua.AttributeIds.ArrayDimensions:
case opcua.AttributeIds.Executable:
case opcua.AttributeIds.UserExecutable:
case opcua.AttributeIds.MinimumSamplingInterval:
if (!dataValue.value.value) {
return "null";
}
return dataValue.value.value.toString();
case opcua.AttributeIds.UserAccessLevel:
case opcua.AttributeIds.AccessLevel:
if (!dataValue.value.value) {
return "null";
}
return opcua.accessLevelFlagToString(dataValue.value.value) + " (" + dataValue.value.value + ")";