|
@@ -68,10 +68,20 @@ class Variable(RowClass):
|
68
|
68
|
|
69
|
69
|
@staticmethod
|
70
|
70
|
def getall_values_of_type(type: VariableType) -> dict:
|
71
|
|
- return dict([
|
72
|
|
- (row['address'], row['value'])
|
|
71
|
+ return Variable.getall_values_of_type_since(type, 0)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+ @staticmethod
|
|
75
|
+ def getall_values_of_type_since(type: VariableType, since: int) -> dict:
|
|
76
|
+ floatcast = lambda x: round(float(x)/10, 2)
|
|
77
|
+ cast_fct = floatcast if type.slabel == 'F' else lambda x: x
|
|
78
|
+
|
|
79
|
+ offset = 10000 if (type.slabel == 'D') else 0
|
|
80
|
+ return dict([
|
|
81
|
+ (row['address'], cast_fct(row['value']))
|
73
|
82
|
for row in sql(
|
74
|
|
- """SELECT var.address, val.value FROM variable var
|
|
83
|
+ """SELECT (var.address + {}) as address, val.value
|
|
84
|
+ FROM variable var
|
75
|
85
|
LEFT JOIN var_value val ON
|
76
|
86
|
var.type = val.type
|
77
|
87
|
AND var.address = val.address
|
|
@@ -79,11 +89,13 @@ class Variable(RowClass):
|
79
|
89
|
WHERE
|
80
|
90
|
var.type = '{}'
|
81
|
91
|
AND var.address >= {}
|
82
|
|
- AND var.address <= {}""".format(
|
83
|
|
- type, type.start_address, type.end_address))
|
|
92
|
+ AND var.address <= {}
|
|
93
|
+ AND var.last_update > {}""".format(
|
|
94
|
+ offset, type, type.start_address, type.end_address, since))
|
84
|
95
|
])
|
85
|
96
|
|
86
|
97
|
|
|
98
|
+
|
87
|
99
|
def modbus_update(self):
|
88
|
100
|
if self.type == 'A':
|
89
|
101
|
pass
|