How to use the node-opcua.ClientMonitoredItem.create function in node-opcua

To help you get started, we’ve selected a few node-opcua examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github node-opcua / node-opcua / packages / node-opcua-samples / bin / simple_client_ts.ts View on Github external
const results1 = await the_subscription.getMonitoredItems();
        console.log("MonitoredItems clientHandles", results1.clientHandles);
        console.log("MonitoredItems serverHandles", results1.serverHandles);
    } catch (err) {
        console.log("Server doesn't seems to implement getMonitoredItems method ", err.message);
    }
    // get_monitored_item

    // monitor_a_variable_node_value
    console.log("Monitoring monitor_a_variable_node_value");

    // ---------------------------------------------------------------
    //  monitor a variable node value
    // ---------------------------------------------------------------
    console.log(" Monitoring node ", monitored_node.toString());
    const monitoredItem = ClientMonitoredItem.create(
        the_subscription,
        {
            attributeId: AttributeIds.Value,
            nodeId: monitored_node
        },
        {
            discardOldest: true,
            queueSize: 10000,
            samplingInterval: 1000
            // xx filter:  { parameterTypeId: "ns=0;i=0",  encodingMask: 0 },
        }
    );
    monitoredItem.on("initialized", () => {
        console.log("monitoredItem initialized");
    });
    monitoredItem.on("changed", (dataValue1: DataValue) => {
github node-opcua / node-opcua / documentation / sample_client_ts.ts View on Github external
console.log("terminated");
      });
    
    // install monitored item
    
    const itemToMonitor: ReadValueIdLike = {
      nodeId: "ns=3;s=Scalar_Simulation_Float",
      attributeId: AttributeIds.Value
    };
    const parameters: MonitoringParametersOptions = {
      samplingInterval: 100,
      discardOldest: true,
      queueSize: 10
    };
    
    const monitoredItem = ClientMonitoredItem.create(
      subscription,
      itemToMonitor,
      parameters,
      TimestampsToReturn.Both
    );
    
    monitoredItem.on("changed", (dataValue: DataValue) => {
      console.log(" value has changed : ", dataValue.value.toString());
    });
    
    async function timeout(ms: number) {
      return new Promise(resolve => setTimeout(resolve, ms));
    }
    await timeout(10000);
    
    console.log("now terminating subscription");
github node-opcua / node-opcua / packages / node-opcua-samples / bin / simple_client_ts.ts View on Github external
"InputNode",
        "SuppressedState",

        "HighLimit",
        "LowLimit",
        "HighHighLimit",
        "LowLowLimit",

        "Value"
    ];

    const eventFilter = constructEventFilter(fields, [
        resolveNodeId("ConditionType")
    ]);

    const event_monitoringItem = ClientMonitoredItem.create(
        the_subscription,
        {
            attributeId: AttributeIds.EventNotifier,
            nodeId: serverObjectId
        },
        {
            discardOldest: true,
            filter: eventFilter,
            queueSize: 100000
        }
    );

    event_monitoringItem.on("initialized", () => {
        console.log("event_monitoringItem initialized");
    });