Giter VIP home page Giter VIP logo

Comments (6)

unocelli avatar unocelli commented on August 26, 2024

Hi Greg, the script to directly convert the value received via script is a feature that has been missing for so long, it would be great if you could do a PR with this feature.
I have a question, converting the input value also needs to convert the output value in the opposite way, right?

from fuxa.

greg9504 avatar greg9504 commented on August 26, 2024

I have a question, converting the input value also needs to convert the output value in the opposite way, right?

That short answer is that it could be. It would probably be good to allow the option. Just to make sure we are referring to the same thing:
You mean applying a script to the value AFTER it is returned from the device (the script would be applied in the device.polling/__updateVarsValue)?

Polling receive value from device -> script(value) -> tagValueCompose(scriptOutput) -> fuxa

I didn't require it for my current use case, but I can add it there.

Greg

from fuxa.

greg9504 avatar greg9504 commented on August 26, 2024

Oh to do that, I think we need to allow two scripts per tag. Input scale script and output scale script.... or we could require that each script has two input parameters. One parameter is the value, the other is an indication of read/write.

from fuxa.

unocelli avatar unocelli commented on August 26, 2024

Yes, I think that is better the first option (two scripts per tag), have the possibility to bind a script for read and a other script for write.

from fuxa.

greg9504 avatar greg9504 commented on August 26, 2024

OK I've got a bit further, it did end up touching a lot of code. So further testing is needed. Because the scripts are async, I had to await the result. The scripts are applied in device-utils.js tagValueCompose/tagRawCalculator. I chose to make those async. But this meant changes in every plugin to deal with that. Perhaps it would be better to do callScaleScript(...).then in tagValueCompose/tagRawCalculator. That way they would not need to be marked async, and the changes I made in the plugins to handle async tagValueCompose/tagRawCalculator would not be needed.

The script must have the first parameter named "value" of type value. You can add additional parameters to the script, values for those parameters must be filled in in the tag options dialog. This way the same script could be used for many tags, with the parameters used to differentiate. You can use the same script for read/write with different parameters. Parameters are passed to the script as strings, so if you want to use them as numbers a conversion is necessary.

image

This is what the tag options looks like now:
image

So far I've only tested with opcua.

from fuxa.

unocelli avatar unocelli commented on August 26, 2024

Hi,
Great, I will test it as soon as possible

from fuxa.

Related Issues (20)

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.