frangoteam / FUXA

Web-based Process Visualization (SCADA/HMI/Dashboard) software
https://frangoteam.org
MIT License
2.77k stars 814 forks source link

The possibility of including the "post" method in the webapi plugin #650

Closed JefersonBigheti closed 1 year ago

JefersonBigheti commented 1 year ago

First of all congratulations for the excellent project. I would like to know if there is a possibility to include the "post" method in the webapi plugin.

unocelli commented 1 year ago

Hi, thank you for your appreciation. we have the feature planned but our resources are currently limited.

there is a functionality to configure via a environment variable DEVICES the webapi get to read tag properties and post to write values

tayfunonbasioglu commented 1 year ago

The post method or a webhook-like method can make a lot of work easier. I will eagerly await this.

tayfunonbasioglu commented 1 year ago

image

JefersonBigheti commented 1 year ago

I'm having trouble implementing it. Would you have an example of how to implement post using your suggestion "environment variable DEVICES"

unocelli commented 1 year ago

The tags must be in an array (flat structure) as you can see in the following example

var tags = [
    {
        id: 'tempA',     // UUID
        name: 'tempA',
        value: 0,
        type: 'number'  // number|boolean|string,`
    },
    {
        id: 'tempB',    // UUID
        name: 'tempB',
        value: 0,
        type: 'number'  // number|boolean|string,`
    }
]
apiApp.get('/api/tags', function (req, res) {       
    res.json(tags);
});

apiApp.post('/api/tags', function (req, res) {
    if (req.body && Array.isArray(req.body)) {
        for(let i = 0; i < req.body.length; i++) {
            for (let y = 0; y < tags.length; y++) {
                if (req.body[i].id === tags[y].id) {
                    tags[y].value = parseFloat(req.body[i].value);
                    y = tags.length;
                }
            }
        }
    }
    res.end();
});
JefersonBigheti commented 1 year ago

The example shown worked very well. Thanks a lot for the help!

RajatDas2020 commented 2 months ago

Hi actually I have a opcua client running in fuxa. From a standalone opcua server I am able to get the opcua variables in fuxa. Now these opcua variables I want to expose to the application layer (upper layer) so that the application can read write the opcua variables. can you kindly guide me how to do that ?

unocelli commented 2 months ago

@RajatDas2020 Hi, I will use mqtt, install a broker (mosquitto) and export the opcua values

henjoe commented 2 weeks ago

Hi @unocelli I am trying to use this application but seems like the WebAPI properties only works on GET ? image

Am I missing something here? or the Post method already removed?