evol 3
This commit is contained in:
@@ -25,6 +25,7 @@ class Config:
|
||||
|
||||
# LOADER setting
|
||||
self.elablog = c.get("csvelab", "logFilename")
|
||||
self.max_threads = c.getint("csvelab", "max_threads")
|
||||
|
||||
# DB setting
|
||||
self.dbhost = c.get("db", "hostname")
|
||||
@@ -35,7 +36,7 @@ class Config:
|
||||
self.dbschema = c.get("db", "dbSchema")
|
||||
self.dbusertable = c.get("db", "userTableName")
|
||||
self.dbrectable = c.get("db", "recTableName")
|
||||
self.dbdataraw = c.get("db", "rawTableName")
|
||||
self.dbrawdata = c.get("db", "rawTableName")
|
||||
|
||||
# unit setting
|
||||
self.units_name = [part for part in c.get("unit", "Names").split('|')]
|
||||
|
||||
32
utils/database/loader.py
Normal file
32
utils/database/loader.py
Normal file
@@ -0,0 +1,32 @@
|
||||
#!.venv/bin/python
|
||||
from utils.database.connection import connetti_db
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
def load_data(cfg, matrice_valori):
|
||||
sql_insert_RAWDATA = f'''
|
||||
INSERT IGNORE INTO {cfg.dbname}.{cfg.dbrawdata} (
|
||||
`UnitName`,`ToolNameID`,`NodeNum`,`EventDate`,`EventTime`,`BatLevel`,`Temperature`,
|
||||
`Val0`,`Val1`,`Val2`,`Val3`,`Val4`,`Val5`,`Val6`,`Val7`,
|
||||
`Val8`,`Val9`,`ValA`,`ValB`,`ValC`,`ValD`,`ValE`,`ValF`,
|
||||
`BatLevelModule`,`TemperatureModule`, `RssiModule`
|
||||
)
|
||||
VALUES (
|
||||
%s, %s, %s, %s, %s, %s, %s,
|
||||
%s, %s, %s, %s, %s, %s, %s, %s,
|
||||
%s, %s, %s, %s, %s, %s, %s, %s,
|
||||
%s, %s, %s
|
||||
)
|
||||
'''
|
||||
with connetti_db(cfg) as conn:
|
||||
cur = conn.cursor()
|
||||
try:
|
||||
cur.executemany(sql_insert_RAWDATA, matrice_valori)
|
||||
conn.commit()
|
||||
except Exception as e:
|
||||
conn.rollback()
|
||||
print(f'Error: {e}')
|
||||
finally:
|
||||
cur.close()
|
||||
conn.close()
|
||||
3
utils/parsers/cr1000x_cr1000x.py
Normal file
3
utils/parsers/cr1000x_cr1000x.py
Normal file
@@ -0,0 +1,3 @@
|
||||
def chi_sono(unit, tool):
|
||||
print(f'{__name__}: {unit} - {tool}')
|
||||
return f'{__name__}: {unit} - {tool}'
|
||||
3
utils/parsers/d2w_d2w.py
Normal file
3
utils/parsers/d2w_d2w.py
Normal file
@@ -0,0 +1,3 @@
|
||||
def chi_sono(unit, tool):
|
||||
print(f'{__name__}: {unit} - {tool}')
|
||||
return f'{__name__}: {unit} - {tool}'
|
||||
28
utils/parsers/data_preparation.py
Normal file
28
utils/parsers/data_preparation.py
Normal file
@@ -0,0 +1,28 @@
|
||||
#!.venv/bin/python
|
||||
from utils.database.connection import connetti_db
|
||||
import utils.timestamp.date_check as date_check
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
def get_data(cfg, id):
|
||||
with connetti_db(cfg) as conn:
|
||||
cur = conn.cursor()
|
||||
cur.execute(f'select unit_name, tool_name, tool_data from {cfg.dbname}.{cfg.dbrectable} where id = {id}')
|
||||
unit_name, tool_name, tool_data = cur.fetchone()
|
||||
cur.close()
|
||||
conn.close()
|
||||
return unit_name, tool_name, tool_data
|
||||
|
||||
def make_matrix(cfg, id):
|
||||
UnitName, ToolNameID, ToolData = get_data(cfg, id)
|
||||
righe = ToolData.splitlines()
|
||||
matrice_valori = []
|
||||
for riga in [riga for riga in righe if ';|;' in riga]:
|
||||
timestamp, batlevel, temperature, rilevazioni = riga.split(';',3)
|
||||
EventDate, EventTime = timestamp.split(' ')
|
||||
valori_nodi = rilevazioni.lstrip('|;').rstrip(';').split(';|;') # Toglie '|;' iniziali, toglie eventuali ';' finali, dividi per ';|;'
|
||||
for num_nodo, valori_nodo in enumerate(valori_nodi, start=1):
|
||||
valori = valori_nodo.split(';')
|
||||
matrice_valori.append([UnitName, ToolNameID, num_nodo, date_check.conforma_data(EventDate), EventTime, batlevel, temperature] + valori + ([None] * (19 - len(valori))))
|
||||
return matrice_valori
|
||||
3
utils/parsers/g201_g201.py
Normal file
3
utils/parsers/g201_g201.py
Normal file
@@ -0,0 +1,3 @@
|
||||
def chi_sono(unit, tool):
|
||||
print(f'{__name__}: {unit} - {tool}')
|
||||
return f'{__name__}: {unit} - {tool}'
|
||||
3
utils/parsers/g301_g301.py
Normal file
3
utils/parsers/g301_g301.py
Normal file
@@ -0,0 +1,3 @@
|
||||
def chi_sono(unit, tool):
|
||||
print(f'{__name__}: {unit} - {tool}')
|
||||
return f'{__name__}: {unit} - {tool}'
|
||||
3
utils/parsers/g801_iptm.py
Normal file
3
utils/parsers/g801_iptm.py
Normal file
@@ -0,0 +1,3 @@
|
||||
def chi_sono(unit, tool):
|
||||
print(f'{__name__}: {unit} - {tool}')
|
||||
return f'{__name__}: {unit} - {tool}'
|
||||
5
utils/parsers/g801_loc.py
Normal file
5
utils/parsers/g801_loc.py
Normal file
@@ -0,0 +1,5 @@
|
||||
import time
|
||||
def chi_sono(unit, tool):
|
||||
print(f'{__name__}: {unit} - {tool}')
|
||||
time.sleep(20)
|
||||
return f'{__name__}: {unit} - {tool}'
|
||||
@@ -1,3 +1,10 @@
|
||||
def chi_sono(unit, tool):
|
||||
print(f'g801_mums: {unit} - {tool}')
|
||||
return f'g801_mums: {unit} - {tool}'
|
||||
#!.venv/bin/python
|
||||
from utils.database.loader import load_data
|
||||
from utils.parsers.data_preparation import make_matrix
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
def main_loader(cfg, id):
|
||||
matrice_valori = make_matrix(cfg, id)
|
||||
load_data(cfg, matrice_valori)
|
||||
5
utils/parsers/g801_musa.py
Normal file
5
utils/parsers/g801_musa.py
Normal file
@@ -0,0 +1,5 @@
|
||||
import time
|
||||
def chi_sono(unit, tool):
|
||||
print(f'{__name__}: {unit} - {tool}')
|
||||
time.sleep(20)
|
||||
return f'{__name__}: {unit} - {tool}'
|
||||
@@ -1,3 +1,5 @@
|
||||
import time
|
||||
def chi_sono(unit, tool):
|
||||
print(f'g801_mux: {unit} - {tool}')
|
||||
return f'g801_mux: {unit} - {tool}'
|
||||
print(f'{__name__}: {unit} - {tool}')
|
||||
time.sleep(20)
|
||||
return f'{__name__}: {unit} - {tool}'
|
||||
5
utils/parsers/g802_dsas.py
Normal file
5
utils/parsers/g802_dsas.py
Normal file
@@ -0,0 +1,5 @@
|
||||
import time
|
||||
def chi_sono(unit, tool):
|
||||
print(f'{__name__}: {unit} - {tool}')
|
||||
time.sleep(20)
|
||||
return f'{__name__}: {unit} - {tool}'
|
||||
5
utils/parsers/g802_gd.py
Normal file
5
utils/parsers/g802_gd.py
Normal file
@@ -0,0 +1,5 @@
|
||||
import time
|
||||
def chi_sono(unit, tool):
|
||||
print(f'{__name__}: {unit} - {tool}')
|
||||
time.sleep(20)
|
||||
return f'{__name__}: {unit} - {tool}'
|
||||
5
utils/parsers/g802_loc.py
Normal file
5
utils/parsers/g802_loc.py
Normal file
@@ -0,0 +1,5 @@
|
||||
import time
|
||||
def chi_sono(unit, tool):
|
||||
print(f'{__name__}: {unit} - {tool}')
|
||||
time.sleep(20)
|
||||
return f'{__name__}: {unit} - {tool}'
|
||||
5
utils/parsers/g802_modb.py
Normal file
5
utils/parsers/g802_modb.py
Normal file
@@ -0,0 +1,5 @@
|
||||
import time
|
||||
def chi_sono(unit, tool):
|
||||
print(f'{__name__}: {unit} - {tool}')
|
||||
time.sleep(20)
|
||||
return f'{__name__}: {unit} - {tool}'
|
||||
5
utils/parsers/g802_mums.py
Normal file
5
utils/parsers/g802_mums.py
Normal file
@@ -0,0 +1,5 @@
|
||||
import time
|
||||
def chi_sono(unit, tool):
|
||||
print(f'{__name__}: {unit} - {tool}')
|
||||
time.sleep(20)
|
||||
return f'{__name__}: {unit} - {tool}'
|
||||
5
utils/parsers/g802_mux.py
Normal file
5
utils/parsers/g802_mux.py
Normal file
@@ -0,0 +1,5 @@
|
||||
import time
|
||||
def chi_sono(unit, tool):
|
||||
print(f'{__name__}: {unit} - {tool}')
|
||||
time.sleep(20)
|
||||
return f'{__name__}: {unit} - {tool}'
|
||||
5
utils/parsers/gs1_gs1.py
Normal file
5
utils/parsers/gs1_gs1.py
Normal file
@@ -0,0 +1,5 @@
|
||||
import time
|
||||
def chi_sono(unit, tool):
|
||||
print(f'{__name__}: {unit} - {tool}')
|
||||
time.sleep(20)
|
||||
return f'{__name__}: {unit} - {tool}'
|
||||
5
utils/parsers/tlp_loc.py
Normal file
5
utils/parsers/tlp_loc.py
Normal file
@@ -0,0 +1,5 @@
|
||||
import time
|
||||
def chi_sono(unit, tool):
|
||||
print(f'{__name__}: {unit} - {tool}')
|
||||
time.sleep(20)
|
||||
return f'{__name__}: {unit} - {tool}'
|
||||
5
utils/parsers/tlp_tlp.py
Normal file
5
utils/parsers/tlp_tlp.py
Normal file
@@ -0,0 +1,5 @@
|
||||
import time
|
||||
def chi_sono(unit, tool):
|
||||
print(f'{__name__}: {unit} - {tool}')
|
||||
time.sleep(20)
|
||||
return f'{__name__}: {unit} - {tool}'
|
||||
Reference in New Issue
Block a user