Have ideas to improve npm?Join in the discussion! »

    automationhat-opcua

    0.1.7 • Public • Published

    Description

    This is an NPM package for building OPC-UA enabled applications with the Pimoroni Automation HAT.

    Donations pipeline coverage npm version

    Installation

    npm i --save automationhat-opcua

    Usage

    The following example creates creates an OPC-UA server called 'AutomationHAT' and runs the myApp function every 500 milliseconds.

    GPIO, ADC and the content of the 'variables' object is exposed to OPC-UA.

    'use strict'
    const hat = require('automationhat-opcua');
     
    // My OPC variables
    const variables = { resetCounter1: 0 };
     
    // My application
    const myApp = (app_var) => {
        // Local variables copy
        const app = { ...app_var };
     
        // Log message    
        console.log(`MyApp was called! App.resetCounter1 has value ${app.resetCounter1}`);
     
        // Reset counter1
        if (app.resetCounter1 === 1) {
            hat.gpio.resetCounter(hat.pins.gpio.input1);
            app.resetCounter1 = 0;
        }
     
        // Return updated application variables
        return app;
    }
     
    // Start OPC-UA server and run myApp
    hat.run('AutomationHAT', myApp, variables, 500);

    Install

    npm i automationhat-opcua

    DownloadsWeekly Downloads

    1

    Version

    0.1.7

    License

    Apache-2.0

    Unpacked Size

    112 kB

    Total Files

    27

    Last publish

    Collaborators

    • avatar