0.1.7 • Published 4 years ago

automationhat-opcua v0.1.7

Weekly downloads
-
License
Apache-2.0
Repository
gitlab
Last release
4 years ago

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);
0.1.7

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.4

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.3

4 years ago

0.1.0

4 years ago