fix status val

This commit is contained in:
2025-08-09 20:14:20 +02:00
parent 3a3b63e360
commit cfb185e029
4 changed files with 25 additions and 21 deletions

View File

@@ -1,11 +1,11 @@
class WorkflowFlags:
CSV_RECEIVED = 0 # 0000
DATA_LOADED = 1 # 0001
DATA_ELABORATED = 2 # 0010
SENT_RAW_DATA = 4 # 0100
SENT_ELAB_DATA = 8 # 1000
DUMMY_ELABORATED = 16 # 10000
START_ELAB = 32 # 100000
START_ELAB = 2 # 0010
DATA_ELABORATED = 4 # 0100
SENT_RAW_DATA = 8 # 1000
SENT_ELAB_DATA = 16 # 10000
DUMMY_ELABORATED = 32 # 100000
# Mappatura flag -> colonna timestamp
FLAG_TO_TIMESTAMP = {

View File

@@ -42,24 +42,28 @@ async def get_tool_info(next_status: int, unit: str, tool: str, pool: object) ->
tuple: A dictionary-like object (aiomysql.DictCursor result) containing the tool information,
or None if no information is found for the given unit and tool.
"""
async with pool.acquire() as conn:
async with conn.cursor(aiomysql.DictCursor) as cur:
await cur.execute(f"""
SELECT {sub_select[next_status]}
FROM matfuncs AS m
INNER JOIN tools AS t ON t.matfunc = m.id
INNER JOIN units AS u ON u.id = t.unit_id
INNER JOIN statustools AS s ON t.statustool_id = s.id
WHERE t.name = '{tool}' AND u.name = '{unit}';
""")
try:
await cur.execute(f"""
SELECT {sub_select[next_status]}
FROM matfuncs AS m
INNER JOIN tools AS t ON t.matfunc = m.id
INNER JOIN units AS u ON u.id = t.unit_id
INNER JOIN statustools AS s ON t.statustool_id = s.id
WHERE t.name = '{tool}' AND u.name = '{unit}';
""")
result = await cur.fetchone()
result = await cur.fetchone()
if not result:
logger.error(f"{unit} - {tool}: Tool info not found.")
return None
else:
return result
if not result:
logger.error(f"{unit} - {tool}: Tool info not found.")
return None
else:
return result
except Exception as e:
logger.error(f"Error: {e}")
async def get_data_as_csv(cfg: dict, id_recv: int, unit: str, tool: str, matlab_timestamp: float, pool: object) -> str: