Skip to content

Commit

Permalink
fix variable property as variable bit for MultiDeviceDAQProces
Browse files Browse the repository at this point in the history
  • Loading branch information
clavay authored and trombastic committed Jan 30, 2024
1 parent ff99126 commit eab3f50
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions pyscada/utils/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1772,22 +1772,19 @@ def loop(self):
if len(data) > 0:
# For all variable, find existing bit VP and set the bit value
for l in data:
for d in l:
if d.variable is not None:
for vp in d.variable.variableproperty_set.all():
if (
len(vp.name.split("bit")) == 2
and vp.name.split("bit")[0] == ""
and vp.name.split("bit")[1].isdigit()
and int(vp.name.split("bit")[1])
< vp.variable.get_bits_by_class()
):
bit = (
d.value() >> int(vp.name.split("bit")[1])
) & 1
VariableProperty.objects.update_property(
vp, value=bit
)
for var in l:
for vp in var.variableproperty_set.all():
if (
len(vp.name.split("bit")) == 2
and vp.name.split("bit")[0] == ""
and vp.name.split("bit")[1].isdigit()
and int(vp.name.split("bit")[1])
< vp.variable.get_bits_by_class()
):
bit = (
int(var.prev_value) >> int(vp.name.split("bit")[1])
) & 1
VariableProperty.objects.update_property(vp, value=bit)
return 1, data
return 1, None

Expand Down

0 comments on commit eab3f50

Please sign in to comment.