fix type variable assignation
This commit is contained in:
parent
a745519b4f
commit
a2d3b15138
2 changed files with 7 additions and 4 deletions
|
|
@ -77,7 +77,8 @@ class Variable(RowClass):
|
|||
def getall_values_of_type_since(type: VariableType, since: int) -> dict:
|
||||
floatcast = lambda x: round(float(x) / 10, 2)
|
||||
cast_fct = floatcast if type.slabel == 'A' else lambda x: x
|
||||
type.__dict__.update({'since': since})
|
||||
params = type.__dict__.copy()
|
||||
params.update({'since': since})
|
||||
|
||||
return {
|
||||
row['address']: cast_fct(row['value'])
|
||||
|
|
@ -94,7 +95,7 @@ class Variable(RowClass):
|
|||
AND var.address >= :start_address
|
||||
AND var.address <= :end_address
|
||||
AND var.last_update > :since""",
|
||||
type.__dict__)
|
||||
params)
|
||||
|
||||
if row['address'] and row['value']
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,12 +40,14 @@ class VariableValue(RowClass):
|
|||
pass
|
||||
|
||||
try:
|
||||
params = self.__dict__.copy()
|
||||
params.update({'type': str(params['type'])})
|
||||
DB.sql(
|
||||
"""INSERT INTO var_value
|
||||
(type, address, value)
|
||||
VALUES
|
||||
(:type, :address, :value)""",
|
||||
self.__dict__
|
||||
params
|
||||
)
|
||||
return True
|
||||
except Exception as e:
|
||||
|
|
@ -78,7 +80,7 @@ class VariableValue(RowClass):
|
|||
AND time <= :time
|
||||
ORDER BY time DESC
|
||||
LIMIT 1""", {
|
||||
'type':type, 'address':address, 'time':int(time.strftime('%s'))+1
|
||||
'type':str(type), 'address':address, 'time':int(time.strftime('%s'))+1
|
||||
}))
|
||||
return VariableValue(**dict(row))
|
||||
except StopIteration as e:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue