Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example code for Alarms and Events #378

Closed
awadekaustubh opened this issue Sep 26, 2017 · 8 comments
Closed

Example code for Alarms and Events #378

awadekaustubh opened this issue Sep 26, 2017 · 8 comments

Comments

@awadekaustubh
Copy link

awadekaustubh commented Sep 26, 2017

Could you share an example for subscribing alarms, events?

Thanks.


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@erossignon
Copy link
Member

unit tests are a good place to start.

@mviikki16
Copy link

unit tests are a good place to start.

Are the unit tests in a separate repository? Could you please share a link to them?
Thank you.

@erossignon
Copy link
Member

What is the A&E scenario you're trying to implement ? Client ? Server ? what type of alarm ?

@erossignon
Copy link
Member

For example , you could refer to this example if you want to implement an NonExclusiveDeviationAlarm inside a server

@mviikki16
Copy link

Thank you. The scenario is indeed of a server with a few variables and alarms. The source I found was node-opcua/packages/node-opcua-samples/bin/demo_server_with_alarm.js which depends on the function "construct_demo_alarm_in_address_space".

Perhaps the ideal example would be if the sample server would also contain an alarm for one of its variables.

@srep2512
Copy link

srep2512 commented Nov 7, 2019

Hey @erossignon , I know it is an old Issue. I've tried to implement the example of the test scenario and the event is triggered.

The only problem is that my client (UAExpert) is getting an Unexpected EventType warning.
It would be great if you could give me a hint to define the EventType correctly, so that the client could print an readable output

const server = new opcua.OPCUAServer({    
    port: 4334, // the port of the listening socket of the server
    resourcePath: "/UA/MyLittleServer", // this path will be added to the endpoint resource name
    buildInfo : {
        productName: "DemoAlarmServer",
        buildNumber: "1",
        buildDate: new Date(2016,9,27)
    }
});

function post_initialize() {
    function construct_my_address_space(server) {
        as = new opcua.AddressSpace()
        const addressSpace = server.engine.addressSpace;
        const data = {};

        
        opcua.construct_demo_alarm_in_address_space(data,addressSpace);

        let time  = 1;
        function simulate_variation() {
            const value = (1.0 + Math.sin(time/360*10))/2.0;
            data.tankLevel.setValueFromSource({dataType: "Double",value:value});

            data.tankLevel2.setValueFromSource({dataType: "Double",value:value});

            time +=1;
        }
        setInterval(simulate_variation,200);
        simulate_variation();


    }
    construct_my_address_space(server);

    server.start(function() {
        console.log("Server is now listening ... ( press CTRL+C to stop)");
        console.log("port ", server.endpoints[0].port);
        const endpointUrl = server.endpoints[0].endpointDescriptions()[0].endpointUrl;
        console.log(" the primary server endpoint url is ", endpointUrl );
    });
}
server.initialize(post_initialize);

opcua

@mtbeck
Copy link

mtbeck commented Apr 8, 2020

Is there a server example for using alarm condition type OffNormal?

@erossignon erossignon added Sponsors welcomed We welcome GitHub sponsors https://github.com/sponsors/node-opcua and removed Sponsors welcomed We welcome GitHub sponsors https://github.com/sponsors/node-opcua labels Dec 11, 2020
@stale
Copy link

stale bot commented Jan 3, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Jan 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants