frangoteam / FUXA

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

[FEATURE] Add bool value support in actions #1261

Open YUHAI0 opened 3 days ago

YUHAI0 commented 3 days ago

In production environment, we have some tag value that is bool, we need to build some actions to thoese tags, for example when one tag change to true, then the control trun to clockwise.

LordNetro commented 2 days ago

Hi YUHAI0,

I think you can achieve that by going to the control properties of the element you want to control and creating an action:

image
YUHAI0 commented 2 days ago

In my version of FUXA, I don't see the Mask value option in actions, even I chose a boolean tag, what version do you use ? @LordNetro image

LordNetro commented 1 day ago

@YUHAI0 I use 1.1.19 but if you click on 1/0 it should change to Mask Value.

image

image

Anyways, if you put Min: 0 Max: 0 for false and Min: 1 Max: 1 for true it should work perfectly. Screenshot 2024-07-04 095846

YUHAI0 commented 1 day ago

@LordNetro , ok I have see that. But unfortunately it still didn't solve my problem. In fact my tag value like string, it is "true" or "false", not 1 or 0.

LordNetro commented 1 day ago

@YUHAI0 is there any particular reason of why are you using a string to control that? couldn't you use a boolean instead? (with a boolean, the 1 or 0 works like a charm).

YUHAI0 commented 1 day ago

@LordNetro If I use 1 or 0, I must use something like rule engine to convert my device data "true"/"false" into 1/0, If fuxa support string value compare in action, it will be easier.

LordNetro commented 1 day ago

@YUHAI0 I see... so the only work around and easy fix for now I would say that is a little script that constantly reads that variable and parses it to an internal boolean, it almost doesn't reduce the performance.

With an script like this one, scheduled to perform every X seconds it would work quite good.

if ($getTag('your_device_var_id') === "true") {
  $setTag('your_internal_boolean_id', true);
} else if ($getTag('your_device_var_id') === "false") {
  $setTag('your_internal_boolean_id', false);
}