Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
JavaScript: How to write to multiple outputs
#4
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) {
  Branderuit = '{"tag":"OutputTag1", "value":1}';
  Branderaan = '{"tag":"OutputTag2", "value":0}';
  result = [Branderuit, Branderaan];
} else if (BranderModus == 2) {
  Branderuit = '{"tag":"OutputTag1", "value":0}';
  Branderaan = '{"tag":"OutputTag2", "value":0}';
  result = [Branderuit, Branderaan];
} else if (BranderModus == 3) {
  Branderuit = '{"tag":"OutputTag1", "value":0}';
  Branderaan = '{"tag":"OutputTag2", "value":1}';
  result = [Branderuit, Branderaan];
} else {
  result = null;  // return null if you don't want to send a value to output variable
}

I don't know why it happens. I have checked your script. It works fine. You have to post more information about this issue.
Reply


Messages In This Thread
RE: JavaScript: How to write to multiple outputs - by iliaslamprou - 04-12-2023, 12:15 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)