@@ -139,7 +139,6 @@ class InfosG3(Infos):
|
|||||||
i = elms # abort the loop
|
i = elms # abort the loop
|
||||||
|
|
||||||
elif data_type == 0x41: # 'A' -> Nop ??
|
elif data_type == 0x41: # 'A' -> Nop ??
|
||||||
# result = struct.unpack_from('!l', buf, ind)[0]
|
|
||||||
ind += 0
|
ind += 0
|
||||||
i += 1
|
i += 1
|
||||||
continue
|
continue
|
||||||
@@ -171,17 +170,17 @@ class InfosG3(Infos):
|
|||||||
" not supported")
|
" not supported")
|
||||||
return
|
return
|
||||||
|
|
||||||
keys, level, unit, must_incr = self._key_obj(info_id)
|
yield from self.__store_result(addr, result, info_id, node_id)
|
||||||
|
|
||||||
if keys:
|
|
||||||
name, update = self.update_db(keys, must_incr, result)
|
|
||||||
yield keys[0], update
|
|
||||||
else:
|
|
||||||
update = False
|
|
||||||
name = str(f'info-id.0x{addr:x}')
|
|
||||||
|
|
||||||
if update:
|
|
||||||
self.tracer.log(level, f'[{node_id}] GEN3: {name} :'
|
|
||||||
f' {result}{unit}')
|
|
||||||
|
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
|
def __store_result(self, addr, result, info_id, node_id):
|
||||||
|
keys, level, unit, must_incr = self._key_obj(info_id)
|
||||||
|
if keys:
|
||||||
|
name, update = self.update_db(keys, must_incr, result)
|
||||||
|
yield keys[0], update
|
||||||
|
else:
|
||||||
|
update = False
|
||||||
|
name = str(f'info-id.0x{addr:x}')
|
||||||
|
if update:
|
||||||
|
self.tracer.log(level, f'[{node_id}] GEN3: {name} :'
|
||||||
|
f' {result}{unit}')
|
||||||
|
|||||||
@@ -118,15 +118,7 @@ class InfosG3P(Infos):
|
|||||||
if not isinstance(row, dict):
|
if not isinstance(row, dict):
|
||||||
continue
|
continue
|
||||||
info_id = row['reg']
|
info_id = row['reg']
|
||||||
fmt = row['fmt']
|
result = self.__get_value(buf, addr, row)
|
||||||
res = struct.unpack_from(fmt, buf, addr)
|
|
||||||
result = res[0]
|
|
||||||
if isinstance(result, (bytearray, bytes)):
|
|
||||||
result = result.decode().split('\x00')[0]
|
|
||||||
if 'eval' in row:
|
|
||||||
result = eval(row['eval'])
|
|
||||||
if 'ratio' in row:
|
|
||||||
result = round(result * row['ratio'], 2)
|
|
||||||
|
|
||||||
keys, level, unit, must_incr = self._key_obj(info_id)
|
keys, level, unit, must_incr = self._key_obj(info_id)
|
||||||
|
|
||||||
@@ -140,3 +132,16 @@ class InfosG3P(Infos):
|
|||||||
if update:
|
if update:
|
||||||
self.tracer.log(level, f'[{node_id}] GEN3PLUS: {name}'
|
self.tracer.log(level, f'[{node_id}] GEN3PLUS: {name}'
|
||||||
f' : {result}{unit}')
|
f' : {result}{unit}')
|
||||||
|
|
||||||
|
def __get_value(self, buf, idx, row):
|
||||||
|
'''Get a value from buf and interpret as in row'''
|
||||||
|
fmt = row['fmt']
|
||||||
|
res = struct.unpack_from(fmt, buf, idx)
|
||||||
|
result = res[0]
|
||||||
|
if isinstance(result, (bytearray, bytes)):
|
||||||
|
result = result.decode().split('\x00')[0]
|
||||||
|
if 'eval' in row:
|
||||||
|
result = eval(row['eval'])
|
||||||
|
if 'ratio' in row:
|
||||||
|
result = round(result * row['ratio'], 2)
|
||||||
|
return result
|
||||||
|
|||||||
Reference in New Issue
Block a user