03-25-2023, 06:31 PM
(This post was last modified: 03-27-2023, 10:04 PM by iliaslamprou.)
Is there any way to send values to multiple outputs using a Java Script?
JavaScript: How to write to multiple outputs
|
03-25-2023, 06:31 PM
(This post was last modified: 03-27-2023, 10:04 PM by iliaslamprou.)
Is there any way to send values to multiple outputs using a Java Script?
03-25-2023, 06:44 PM
Hi,
You have to include the messages for each ouput tag inside an array like the example below: [{"tag":"outputTag1","value":'+ value1+'},{"tag":"outputTag2","value":'+ value2+'}]
the better way is to create a json message for each tag first and store them to variables like the example below //... code result1 = '{"tag":"outputTag1", "value":'+ value1+ '}; //..code result2 = '{"tag":"outputTag2", "value":'+ value2+ '}; //..code result3 = '{"tag":"outputTag3", "value":'+ value3+ '}; result = [result1, result2, result2] This is a completed example. Create three tags: inputTag - V0 (Script runner tag) outputTag1 -V1 outputTag2 - V2 Code: //--- Copy values from Virtuino Variables to JavaScript variables
04-11-2023, 10:48 AM
Hi,
I'm trying to convert a selector switch to multiple Modbus outputs. I can see that the javascript seems to work when I compile, however, the data is not sent to the Modbus Logo. This is my code. The outputs themselves do work towards the Modbus Logo. see also attached screenshot. Code: //--- Copy values from Virtuino Variables to JavaScript variables
04-12-2023, 12:15 AM
Hi, you can check if it works using the emulator first. Just replace the modbus with the emulator output variables
This correction is better in case the input value is not in range 1..3 Code: if (BranderModus == 1) { I don't know why it happens. I have checked your script. It works fine. You have to post more information about this issue.
04-13-2023, 05:33 AM
The code indeed works.
I had to close the software and reopen it. |
« Next Oldest | Next Newest »
|