frangoteam / FUXA

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

bitmask #954

Open yoabau opened 1 year ago

yoabau commented 1 year ago

Hello everyone,

Thank you @IonuDragomir1 for your comment. It really helped me understanding the bitmask feature. The feature actually works as query of bit as defined her. After selecting the required bit to monitor, the shape can return a color based on status (0=False or True=1) of one of the bits. Reusing your example I managed to get this result: 2023-10-26_13h14_50

@unocelli As you can see "shape_10" returns green color since bit 0 and 1 are both True. But I was expecting the function to return decimal value based on bit 0 and 1 regardless the status of bit 2 to 31 such as: bit 0 bit 1 bit 2-31 value(dec)
0 0 x 0
1 0 x 1
0 1 x 2
1 1 x 3

But it doesn't, and instead it seems to only check whether one of the bit has value 1=True?

Originally posted by @yoabau in https://github.com/frangoteam/FUXA/discussions/295#discussioncomment-7392022

unocelli commented 1 year ago

Hi, I think there are different interpretations of bitmask management and in any case it is not possible to satisfy everyone. The bitmask is intended to be associated with the value of the the bit (1/0) and not with the value masked with the bitmask.

yoabau commented 1 year ago

Hi @unocelli ,

Thank you for your reply. Let me develop some arguments to convince you that it is not a question of interpretation:

  1. If I understand your explanation correctly, FUXA bitmask feature leads to more confusion :
    • Why is the returned value an integer without bitmask and just a bool (0 or 1) when one or more bitmask activated?
    • Why is the returned value not a bool when no bitmask is activated?
    • What logic operand is used in above example above "shape_10" to return a bool? bit0 AND bit1, bit0 OR bit1, bit0 XOR bit1.
myTag Logic Operand myBitMask Result
16#00 ??? 16#0F 16#00
16#01 ??? 16#0F 16#01
16#02 ??? 16#0F 16#01
16#12 ??? 16#0F 16#01
16#12 ??? 16#F0 16#01
16#12 ??? 16#00 16#12
  1. To compare with Windows calculator in "programmer" mode and enter the following:
myTag Logic Operand myBitMask Result
16#12 AND 16#0F 16#02
16#12 AND 16#F0 16#10

image

  1. To compare to commercial HMI/SCADA system, programmers can use bitmask to display different result based on the value masked with the bitmask. E.g using the same case tested on Siemens WinCC Unified: image When selecting the option "multiple bits", you can associate a color with bit number 231... 20 Here: 20 = WHITE, 21 = GREEN, 22 = RED whatever the bit activated between 23 and 231 which corresponds to:
myTag Logic Operand myBitMask Result
16#01 AND 16#07 16#1 - WHITE
16#02 AND 16#07 16#2 - GREEN
16#04 AND 16#07 16#4 - RED
... AND ... ...
16#12 AND 16#07 16#2 - GREEN
  1. To compare with Excel, the built-ins BITAND will return the same results as Windows and Siemens. But according to FUXA's bitmask function 16#32 AND 16#07 = 16#1; which is wrong.

Conclusion: If FUXA aims to be an industrial web HMIs, SCADA, it needs to comply, at least, with industry standards such as IEC61131. Bitmask is actually a topic covered by IEC (free sample here)

IonuDragomir1 commented 1 year ago

Hi,

I have encountered the same problem when using multiple bits on bitmask. For the same object (motor, pump, etc.) cannot set a color for each selected bit from bitmask. Please see my post #865.


@yoabau, regarding questions you put on point 1: 1.1 When no bit is selected on bitmask it's ok to get the numerical value of a tag. For example, it's useful to change the color of a pump when its current is between 2 and 10 A. When one or more bit(s) is selected on bitmask, the user can use either the boolean or numerical value of selected tag. It's true that when a single bit is selected, should be available only the bool value. But it can be easily selected. 1.2 When no bit is selected, the user gets tag's value and depending on it, the objected can be customized. 1.3 That's a very good question. When a single bit is selected, bitmask works as expected. The problem appears when multiple bits are selected as I wrote on #865.

@unocelli, bitmask for only one selected bit work perfectly. My opinion is that when selecting multiple bits on bitmask, 2 behaviors (B1 and B2) should be available.

B1: image If the checkbox next to dropdown list is checked, the user should be able to select the logical operation to be made between the selected bits. Also, the + button should be disabled because the logical operation returns only one result so there's no reason to add another result for the same tag.

B2 image If the checkbox next to dropdown list is not checked, next to each mask value should be a dropdown list which contains all the bitmask's selected bits. Then for each bit can be assigned a bool value.

Selecting multiple bits from a WORD or DWORD tag is often used in SCADA systems. Assigning a value to entire WORD or DWORD tag, when selecting multiple bits, is not always a solution because it could constantly change.