Giter Site home page Giter Site logo

axiscommunications / opc-ua-gaugereader-acap Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 2.48 MB

Small example ACAP application that reads analog gauges with video analytics and exposes the value via OPC UA.

Home Page: https://www.axis.com/developer-community/industry-4-0-integration

License: Apache License 2.0

Dockerfile 7.58% Makefile 2.06% C++ 82.73% JavaScript 6.13% HTML 1.50%
industry40 opc opc-ua opcua acap axis industry-4 industry-40 video-analytics opencv

opc-ua-gaugereader-acap's Introduction

Copyright (C) 2022, Axis Communications AB, Lund, Sweden. All Rights Reserved.

OPC UA Gauge Reader ACAP

Build ACAPs GitHub Super-Linter

Image of a water level gauge

This repository contains the source code to build a small example ACAP version 3 application that reads an analog gauge using video analytics with OpenCV and exposes the value through a built-in OPC UA (open62541) server.

Architectural overview

The exposed value is in percent.

Note

Even if this application would fit right into your usecase, its purpose is above all to serve as an example and boilerplate rather than being ready for production.

Example Use Cases

The following examples assume that you have a SCADA (Supervisory Control And Data Acquisition) system or a PLC (Programmable Logic Controller) system with OPC UA as the communication protocol and you want to take advantage of the Axis device capabilities to enrich or complement your operations.

Analog gauges are common in the industry, and it is often impossible to add digital sensors due to regulations or warranty restrictions. However, having a human operator monitor these gauges (which is what is done today) is inconvenient and error-prone. Instead, we can use an IP camera with very basic video analysis to automatically capture the digital reading and feed it into the industrial system. Automating the capture of digital values from analog gauges opens up a multitude of possibilities.

For example:

  • shutdown or start a PLC process if a gauge reading exceeds or falls below a specified threshold
  • generate alarms when the gauge reading goes outside a predefined range
  • display real-time gauge values within the SCADA server's operational interface
  • maintain historical logs of gauge values to track changes over time

Warning

Please note that any analytic process can never be 100% accurate and the system designer has to account for this.

Build

The build process uses the ACAP SDK build container and Docker.

The Docker commands are integrated in the Makefile, so if you have Docker and make on your computer all you need to do is:

make dockerbuild

or perhaps build in parallel:

make -j dockerbuild

If you do have Docker but no make on your system:

# 32-bit ARM, e.g. ARTPEC-6- and ARTPEC-7-based devices
DOCKER_BUILDKIT=1 docker build --build-arg ARCH=armv7hf -o type=local,dest=. .
# 64-bit ARM, e.g. ARTPEC-8-based devices
DOCKER_BUILDKIT=1 docker build --build-arg ARCH=aarch64 -o type=local,dest=. .

Debug

If you would like the application to store the images from each step in the video analysis to disk for debugging, set the DEBUG_WRITE variable for the build:

DEBUG_WRITE=y make -j dockerbuild

or

# 32-bit ARM, e.g. ARTPEC-6- and ARTPEC-7-based devices
DOCKER_BUILDKIT=1 docker build --build-arg DEBUG_WRITE=y --build-arg ARCH=armv7hf -o type=local,dest=. .
# 64-bit ARM, e.g. ARTPEC-8-based devices
DOCKER_BUILDKIT=1 docker build --build-arg DEBUG_WRITE=y --build-arg ARCH=aarch64 -o type=local,dest=. .

Setup

Manual installation and configuration

Upload the ACAP application file (the file with the .eap extension for the camera's architecture) through the camera's web UI: Apps->Add app

When installed, start the application.

Web UI Screenshot

Open the application's settings page in the web interface (available when the application is running) by clicking the Open button.

Web UI Screenshot

In the settings page, simply click in the image to set up the calibration points in the following order:

  1. Center of the gauge
  2. Minimum value of the gauge
  3. Maximum value of the gauge

The calibration points can also, along with the OPC UA Server port (default is 4840) and clockwise/counterclockwise (default is clockwise), be set directly through the application's parameter settings, found in the three vertical dots menu:

Web UI Screenshot

Web UI Screenshot

Scripted installation and configuration

Use the camera's applications/upload.cgi to upload the ACAP application file (the file with the .eap extension for the camera's architecture):

curl -k --anyauth -u root:<password> \
    -F packfil=@OPC_UA_Gauge_Reader_<version>_<architecture>.eap \
    https://<camera hostname/ip>/axis-cgi/applications/upload.cgi

To start (or stop/restart/remove) the application, you can make a call like this:

curl -k --anyauth -u root:<password> \
    'https://<camera hostname/ip>/axis-cgi/applications/control.cgi?package=opcuagaugereader&action=start'

Use the camera's param.cgi to set the center/min/max points, as well as clockwise/counterclockwise and the OPC UA server port number.

The call

curl -k --anyauth -u root:<password> \
    'https://<camera hostname/ip>/axis-cgi/param.cgi?action=list&group=opcuagaugereader'

will list the current settings:

root.Opcuagaugereader.centerX=479
root.Opcuagaugereader.centerY=355
root.Opcuagaugereader.clockwise=1
root.Opcuagaugereader.maxX=678
root.Opcuagaugereader.maxY=165
root.Opcuagaugereader.minX=283
root.Opcuagaugereader.minY=167
root.Opcuagaugereader.port=4840

If you want to set the OPC UA server port to e.g. 4842:

curl -k --anyauth -u root:<password> \
    'https://<camera hostname/ip>/axis-cgi/param.cgi?action=update&opcuagaugereader.port=4842'

Usage

Attach an OPC UA client to the port set in ACAP. The client will then be able to read the value (and its timestamp) from the application's OPC UA server.

Note

The application will also log the gauge value in the camera's syslog.

License

Apache 2.0

opc-ua-gaugereader-acap's People

Contributors

joakimr-axis avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

opc-ua-gaugereader-acap's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

This repository currently has no open or pending branches.

Detected dependencies

dockerfile
Dockerfile
  • axisecp/acap-sdk 3.5-armv7hf-ubuntu20.04
github-actions
.github/workflows/build.yml
  • actions/checkout v3
.github/workflows/super-linter.yml
  • actions/checkout v3
  • github/super-linter v4

  • Check this box to trigger a request for Renovate to run again on this repository

I want to monitor multiple gauges, but currently the ACAP only supports one (1)

Describe the feature

Currently, the ACAP will only monitor one (1) gauge. It would be nice, and very possible, to monitor more than one gauge.

The application code is structured to support any number of gauges: there is a class for a gauge so we would just have to create a new instance of the class for every new gauge. The same goes for the OPC UA server part, where we would only add a new node for each gauge.

The obstacle is the configuration of the gauge min/center/max points. The current implementation focuses on simplicity and to be as intuitive as possible. Furthermore, the purpose of the whole ACAP is to serve as an example/boilerplate and not a feature complete product. But from a parameter handling perspective, the ACAP can dynamically add parameters, so on that side it would be possible to without too much trouble add the possibility to handle more gauges. The culprit would be the manual configuration done in the web UI, and how the user should interact with it to set the configuration points for the different gauges (and add/remove them) in a convenient way.

Added value

In use cases with more than one gauge, the added value would of course be huge.

Workaround using current codebase

ACAP's are identified by their names. With the current codebase, building the code with different names would allow installing more than one instance of the ACAP (with different names only) and run them on separate OPC UA server ports. One instance for every gauge that is to be monitored. Since most use cases will probably have a need of <10 gauges, it is not that bad as a workaround.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.