Comments (6)
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.
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.
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.
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.
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.
This is what the tag options looks like now:
So far I've only tested with opcua.
from fuxa.
Hi,
Great, I will test it as soon as possible
from fuxa.
Related Issues (20)
- [BUG] The background coloring for the output value does not work HOT 1
- [BUG] ModBus RTU InputRegister Addressing misfire HOT 1
- [FEATURE] Automatic alignment or automatic standardization in svg editor
- Security [POSSIBLE ISSUE] HOT 2
- [FEATURE] Manual resizing, by numerical values, of the width and height of a graphic object placed on the svg editor HOT 1
- [FEATURE]support Snap7 protocol in Nodejs 16 or 18 HOT 3
- [BUG] After undo action, zoom with shortkey(shift + wheel) will broken HOT 2
- [BUG] Scripting tag system functions not working properly HOT 4
- [QUESTION OR FEATURE] Mapped Tag value to a string HOT 1
- [BUG] Cannot remote control device using FUXA HOT 3
- [BUG] HOT 2
- [FEATURE] Alarm view without folding
- [FEATURE] About window size self-adaption HOT 6
- [QUESTION] How exactly the Authetication via Token works?
- [FEATURE] "Input value" element - Write on lost focus HOT 3
- [BUG]I While using the same view, the names of the points change by themselves. HOT 4
- damping of mqtt values HOT 1
- scaling formula HOT 1
- [BUG] NodeJs Version Compatibility HOT 2
- [FEATURE] Optimize client dist js for view only pages HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fuxa.