loc ok
This commit is contained in:
@@ -91,19 +91,29 @@ def make_ain_din_matrix(cfg: object, id: int) -> list:
|
||||
list contains data fields similar to `make_matrix`, adjusted for LOC data.
|
||||
"""
|
||||
UnitName, ToolNameID, ToolData = get_data(cfg, id)
|
||||
node_channels, node_types, node_ains, node_dins = get_nodes_type(cfg, ToolNameID, UnitName)
|
||||
righe = ToolData.splitlines()
|
||||
matrice_valori = []
|
||||
pattern = r'(?:\d{4}/\d{2}/\d{2}|\d{2}/\d{2}/\d{4}) \d{2}:\d{2}:\d{2}(;[^;]+)+'
|
||||
for riga in [riga for riga in righe if re.match(pattern, riga)]:
|
||||
timestamp, battery_voltage, unit_temperature, analog_input1, analog_input2, digital_input1, digital_input2 = riga.split(';')
|
||||
event_date, event_time = timestamp.split(' ')
|
||||
valori = [analog_input1, analog_input2, digital_input1, digital_input2]
|
||||
matrice_valori.append([UnitName, ToolNameID, 1, date_check.conforma_data(event_date), event_time, battery_voltage, unit_temperature] + valori + ([None] * (19 - len(valori))))
|
||||
|
||||
pattern = r'^(?:\d{4}\/\d{2}\/\d{2}|\d{2}\/\d{2}\/\d{4}) \d{2}:\d{2}:\d{2}(?:;\d+\.\d+){2}(?:;\d+){4}$'
|
||||
if node_ains or node_dins:
|
||||
for riga in [riga for riga in righe if re.match(pattern, riga)]:
|
||||
timestamp, batlevel, temperature, analog_input1, analog_input2, digital_input1, digital_input2 = riga.split(';')
|
||||
EventDate, EventTime = timestamp.split(' ')
|
||||
if any(node_dins):
|
||||
for node_num, digital_act in enumerate([digital_input1, digital_input2], start=1):
|
||||
matrice_valori.append([UnitName, ToolNameID, node_num, date_check.conforma_data(EventDate), EventTime, batlevel, temperature] + [digital_act] + ([None] * (19 - 1)))
|
||||
else:
|
||||
logger.info(f"Nessun Ingresso digitale per {UnitName} {ToolNameID}")
|
||||
if any(node_ains):
|
||||
for node_num, analog_act in enumerate([analog_input1, analog_input2], start=1):
|
||||
matrice_valori.append([UnitName, ToolNameID, node_num, date_check.conforma_data(EventDate), EventTime, batlevel, temperature] + [analog_act] + ([None] * (19 - 1)))
|
||||
else:
|
||||
logger.info(f"Nessun Ingresso analogico per {UnitName} {ToolNameID}")
|
||||
return matrice_valori
|
||||
|
||||
def make_channels_matrix(cfg: object, id: int) -> list:
|
||||
UnitName, ToolNameID, ToolData = get_data(cfg, id)
|
||||
node_channels, node_types, node_ains, node_dins = get_nodes_type(cfg, ToolNameID, UnitName)
|
||||
righe = ToolData.splitlines()
|
||||
matrice_valori = []
|
||||
for riga in [riga for riga in righe if ';|;' in riga]:
|
||||
@@ -111,7 +121,6 @@ def make_channels_matrix(cfg: object, id: int) -> list:
|
||||
EventDate, EventTime = timestamp.split(' ')
|
||||
valori_splitted = [valore for valore in rilevazioni.split(';') if valore != '|']
|
||||
valori_iter = iter(valori_splitted)
|
||||
node_channels, node_types, node_ains, node_dins = get_nodes_type(cfg, ToolNameID, UnitName)
|
||||
|
||||
valori_nodi = [list(islice(valori_iter, channels)) for channels in node_channels]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user