commit fa6b7573c742f22eaa77d778ff911c0a42df6a05 Author: Miguel Date: Sun Apr 21 10:22:36 2024 +0200 new file: CopyPaste.py new file: DB SIPA Supervision.db new file: DB_SIPA_Supervision_Excel.xlsx new file: DB_Structure.csv new file: DB_Structure.xlsx new file: DB_Structure.xml new file: DB_to_Excel.py new file: ExpandDB.py new file: ExportData.py new file: __pycache__/ExpandDB.cpython-310.pyc new file: __pycache__/ExportData.cpython-310.pyc new file: db_definitions.json new file: udt_definitions.json diff --git a/CopyPaste.py b/CopyPaste.py new file mode 100644 index 0000000..9265593 --- /dev/null +++ b/CopyPaste.py @@ -0,0 +1,28 @@ +def calculate_offsets(db_struct, current_offset=0): + """ + Recursively calculate byte offsets for each field in the DB structure, + applying general alignment rules except inside arrays. + """ + if isinstance(db_struct, dict): + for key, value in db_struct.items(): + if isinstance(value, dict) and 'type' in value: + is_array_element = value.get('is_array_element', False) + type_name = value['type'] + size = type_sizes.get(type_name, 1) + + if 'String' in type_name: + match = re.match(r'String\[(\d+)\]', type_name) + if match: + size = int(match.group(1)) + 2 # String length + 2 for the null terminator and length prefix + + if not is_array_element and current_offset % 2 != 0: + current_offset += 1 # Align to the next even offset if it's not an array element + + value['offset'] = current_offset + current_offset += size + + # Recursively handle nested structures + if isinstance(value, dict): + current_offset = calculate_offsets(value, current_offset) + + return current_offset diff --git a/DB SIPA Supervision.db b/DB SIPA Supervision.db new file mode 100644 index 0000000..9c8a32b --- /dev/null +++ b/DB SIPA Supervision.db @@ -0,0 +1,250 @@ +TYPE "UDT SIPA SV Main" +VERSION : 0.1 + STRUCT + N1 : DInt; // .DB_IOT.USERLEVEL + N2 : String[81]; // .DB_IOT.USERNAME + N3 : String[81]; // .DB_IOT.NOME_RICETTA + N4 : Int; // .DB_IOT.NEXT_MAINT_CYCLES + N5 : Struct // .DB_IOT.NEXT_MAINT_ITEM + V1 : String[254]; + V2 : String[254]; + V3 : String[254]; + V4 : String[254]; + V5 : String[8]; + END_STRUCT; + N6 : Array[1..3] of Real; // .DB_IOT.ELECTRIC_VOLTAGE_PHASE_D + N7 : Array[1..3] of Real; // .DB_IOT.ELECTRIC_CURRENT_PHASE_D + N8 : Real; // .DB_IOT.ELECTRIC_POWER_D + N9 : Real; // .DB_IOT.ELECTRIC_POWER_FACTOR_D + N10 : Real; // .DB_IOT.ELECTRIC_POWER_HOUR_D + N11 : Real; // .DB_IOT.ELECTRIC_POWER_WH + END_STRUCT; + +END_TYPE + +TYPE "UDT SIPA SV Section" +VERSION : 0.1 + STRUCT + N1 : DInt; // .DB_IOT.STATO_MACCHINA + N2 : DInt; // .DB_IOT.ALLARME_FERMO + N3 : DInt; // .DB_IOT.WARNING_ATTIVO (che compromette produzione) + N4 : Int; // .DB_IOT.STATO_OPERATIVO (Semaforo) + N5 : Int; // .DB_IOT.MODO_OPERATIVO (Prod,Simula,Man, ecc) + N6 : DInt; // .DB_IOT.ALARM_STOP_NO + N7 : Struct // .DB_IOT.COUNTER + V1 : DInt; // PIECES_TOT + V2 : DInt; // PIECES_OK + V3 : DInt; // PIECES_KO_1 + V4 : DInt; // PIECES_KO_2 + V5 : DInt; // PIECES_KO_3 + V6 : DInt; // PIECES_KO_4 + V7 : DInt; // PIECES_KO_5 + V8 : DInt; // PIECES_KO_6 + V9 : DInt; // PIECES_KO_7 + V10 : DInt; // PIECES_KO_8 + V11 : DInt; // PIECES_KO_9 + V12 : DInt; // PIECES_KO_10 + V13 : DInt; // T_ALARM_HOURS + V14 : DInt; // T_DRY_CYCLE_HOURS + V15 : DInt; // T_POWERED_HOURS + V16 : DInt; // T_PRODUCT_100_HOURS + V17 : DInt; // T_PRODUCT_0_HOURS + V18 : DInt; // T_STOP_HOURS + V19 : Int; // T_ALARM_MINUTES + V20 : Int; // T_DRY_CYCLE_MINUTES + V21 : Int; // T_POWERED_MINUTES + V22 : Int; // T_PRODUCT_100_MINUTES + V23 : Int; // T_PRODUCT_0_MINUTES + V24 : Int; // T_STOP_MINUTES + END_STRUCT; + END_STRUCT; + +END_TYPE + +DATA_BLOCK "DB SIPA Supervision" +{ S7_Optimized_Access := 'FALSE' } +VERSION : 0.1 +NON_RETAIN + STRUCT + MAIN : "UDT SIPA SV Main"; + SECT1 : "UDT SIPA SV Section"; + SECT2 : "UDT SIPA SV Section"; + SECT3 : "UDT SIPA SV Section"; + SECT4 : "UDT SIPA SV Section"; + SECT5 : "UDT SIPA SV Section"; + END_STRUCT; + + +BEGIN + MAIN.N1 := 9; + MAIN.N2 := 'superuser '; + MAIN.N3 := '0,4 L Petaloid Base'; + MAIN.N4 := 0; + MAIN.N5.V1 := 'testo da inserire'; + MAIN.N5.V2 := ''; + MAIN.N5.V3 := ''; + MAIN.N5.V4 := ''; + MAIN.N5.V5 := ''; + MAIN.N6[1] := 0.0; + MAIN.N6[2] := 0.0; + MAIN.N6[3] := 0.0; + MAIN.N7[1] := 0.0; + MAIN.N7[2] := 0.0; + MAIN.N7[3] := 0.0; + MAIN.N8 := 0.0; + MAIN.N9 := 0.0; + MAIN.N10 := 0.0; + MAIN.N11 := 0.0; + SECT1.N1 := 2; + SECT1.N2 := 0; + SECT1.N3 := 0; + SECT1.N4 := 3; + SECT1.N5 := 2; + SECT1.N6 := 0; + SECT1.N7.V1 := 0; + SECT1.N7.V2 := 0; + SECT1.N7.V3 := 0; + SECT1.N7.V4 := 0; + SECT1.N7.V5 := 0; + SECT1.N7.V6 := 0; + SECT1.N7.V7 := 0; + SECT1.N7.V8 := 0; + SECT1.N7.V9 := 0; + SECT1.N7.V10 := 0; + SECT1.N7.V11 := 0; + SECT1.N7.V12 := 0; + SECT1.N7.V13 := 0; + SECT1.N7.V14 := 0; + SECT1.N7.V15 := 0; + SECT1.N7.V16 := 0; + SECT1.N7.V17 := 0; + SECT1.N7.V18 := 0; + SECT1.N7.V19 := 0; + SECT1.N7.V20 := 0; + SECT1.N7.V21 := 0; + SECT1.N7.V22 := 0; + SECT1.N7.V23 := 0; + SECT1.N7.V24 := 0; + SECT2.N1 := 0; + SECT2.N2 := 0; + SECT2.N3 := 0; + SECT2.N4 := 0; + SECT2.N5 := 0; + SECT2.N6 := 0; + SECT2.N7.V1 := 0; + SECT2.N7.V2 := 0; + SECT2.N7.V3 := 0; + SECT2.N7.V4 := 0; + SECT2.N7.V5 := 0; + SECT2.N7.V6 := 0; + SECT2.N7.V7 := 0; + SECT2.N7.V8 := 0; + SECT2.N7.V9 := 0; + SECT2.N7.V10 := 0; + SECT2.N7.V11 := 0; + SECT2.N7.V12 := 0; + SECT2.N7.V13 := 0; + SECT2.N7.V14 := 0; + SECT2.N7.V15 := 0; + SECT2.N7.V16 := 0; + SECT2.N7.V17 := 0; + SECT2.N7.V18 := 0; + SECT2.N7.V19 := 0; + SECT2.N7.V20 := 0; + SECT2.N7.V21 := 0; + SECT2.N7.V22 := 0; + SECT2.N7.V23 := 0; + SECT2.N7.V24 := 0; + SECT3.N1 := 0; + SECT3.N2 := 0; + SECT3.N3 := 0; + SECT3.N4 := 0; + SECT3.N5 := 0; + SECT3.N6 := 0; + SECT3.N7.V1 := 0; + SECT3.N7.V2 := 0; + SECT3.N7.V3 := 0; + SECT3.N7.V4 := 0; + SECT3.N7.V5 := 0; + SECT3.N7.V6 := 0; + SECT3.N7.V7 := 0; + SECT3.N7.V8 := 0; + SECT3.N7.V9 := 0; + SECT3.N7.V10 := 0; + SECT3.N7.V11 := 0; + SECT3.N7.V12 := 0; + SECT3.N7.V13 := 0; + SECT3.N7.V14 := 0; + SECT3.N7.V15 := 0; + SECT3.N7.V16 := 0; + SECT3.N7.V17 := 0; + SECT3.N7.V18 := 0; + SECT3.N7.V19 := 0; + SECT3.N7.V20 := 0; + SECT3.N7.V21 := 0; + SECT3.N7.V22 := 0; + SECT3.N7.V23 := 0; + SECT3.N7.V24 := 0; + SECT4.N1 := 0; + SECT4.N2 := 0; + SECT4.N3 := 0; + SECT4.N4 := 0; + SECT4.N5 := 0; + SECT4.N6 := 0; + SECT4.N7.V1 := 0; + SECT4.N7.V2 := 0; + SECT4.N7.V3 := 0; + SECT4.N7.V4 := 0; + SECT4.N7.V5 := 0; + SECT4.N7.V6 := 0; + SECT4.N7.V7 := 0; + SECT4.N7.V8 := 0; + SECT4.N7.V9 := 0; + SECT4.N7.V10 := 0; + SECT4.N7.V11 := 0; + SECT4.N7.V12 := 0; + SECT4.N7.V13 := 0; + SECT4.N7.V14 := 0; + SECT4.N7.V15 := 0; + SECT4.N7.V16 := 0; + SECT4.N7.V17 := 0; + SECT4.N7.V18 := 0; + SECT4.N7.V19 := 0; + SECT4.N7.V20 := 0; + SECT4.N7.V21 := 0; + SECT4.N7.V22 := 0; + SECT4.N7.V23 := 0; + SECT4.N7.V24 := 0; + SECT5.N1 := 0; + SECT5.N2 := 0; + SECT5.N3 := 0; + SECT5.N4 := 0; + SECT5.N5 := 0; + SECT5.N6 := 0; + SECT5.N7.V1 := 0; + SECT5.N7.V2 := 0; + SECT5.N7.V3 := 0; + SECT5.N7.V4 := 0; + SECT5.N7.V5 := 0; + SECT5.N7.V6 := 0; + SECT5.N7.V7 := 0; + SECT5.N7.V8 := 0; + SECT5.N7.V9 := 0; + SECT5.N7.V10 := 0; + SECT5.N7.V11 := 0; + SECT5.N7.V12 := 0; + SECT5.N7.V13 := 0; + SECT5.N7.V14 := 0; + SECT5.N7.V15 := 0; + SECT5.N7.V16 := 0; + SECT5.N7.V17 := 0; + SECT5.N7.V18 := 0; + SECT5.N7.V19 := 0; + SECT5.N7.V20 := 0; + SECT5.N7.V21 := 0; + SECT5.N7.V22 := 0; + SECT5.N7.V23 := 0; + SECT5.N7.V24 := 0; + +END_DATA_BLOCK + diff --git a/DB_SIPA_Supervision_Excel.xlsx b/DB_SIPA_Supervision_Excel.xlsx new file mode 100644 index 0000000..48e46d6 Binary files /dev/null and b/DB_SIPA_Supervision_Excel.xlsx differ diff --git a/DB_Structure.csv b/DB_Structure.csv new file mode 100644 index 0000000..dd2f1e0 --- /dev/null +++ b/DB_Structure.csv @@ -0,0 +1,176 @@ +Nombre,Tipo,Offset,Comentario +MAIN,"""UDT SIPA SV Main""",0, +MAIN.N1,DInt,0,.DB_IOT.USERLEVEL +MAIN.N2,String[81],4,.DB_IOT.USERNAME +MAIN.N3,String[81],88,.DB_IOT.NOME_RICETTA +MAIN.N4,Int,172,.DB_IOT.NEXT_MAINT_CYCLES +MAIN.N5.V1,String[254],174, +MAIN.N5.V2,String[254],430, +MAIN.N5.V3,String[254],686, +MAIN.N5.V4,String[254],942, +MAIN.N5.V5,String[8],1198, +MAIN.N6.type_1,Real,1208,N/A +MAIN.N6.type_2,Real,1212,N/A +MAIN.N6.type_3,Real,1216,N/A +MAIN.N7.type_1,Real,1220,N/A +MAIN.N7.type_2,Real,1224,N/A +MAIN.N7.type_3,Real,1228,N/A +MAIN.N8,Real,1232,.DB_IOT.ELECTRIC_POWER_D +MAIN.N9,Real,1236,.DB_IOT.ELECTRIC_POWER_FACTOR_D +MAIN.N10,Real,1240,.DB_IOT.ELECTRIC_POWER_HOUR_D +MAIN.N11,Real,1244,.DB_IOT.ELECTRIC_POWER_WH +SECT1,"""UDT SIPA SV Section""",1248, +SECT1.N1,DInt,1664,.DB_IOT.STATO_MACCHINA +SECT1.N2,DInt,1668,.DB_IOT.ALLARME_FERMO +SECT1.N3,DInt,1672,.DB_IOT.WARNING_ATTIVO (che compromette produzione) +SECT1.N4,Int,1676,.DB_IOT.STATO_OPERATIVO (Semaforo) +SECT1.N5,Int,1678,".DB_IOT.MODO_OPERATIVO (Prod,Simula,Man, ecc)" +SECT1.N6,DInt,1680,.DB_IOT.ALARM_STOP_NO +SECT1.N7.V1,DInt,1684,PIECES_TOT +SECT1.N7.V2,DInt,1688,PIECES_OK +SECT1.N7.V3,DInt,1692,PIECES_KO_1 +SECT1.N7.V4,DInt,1696,PIECES_KO_2 +SECT1.N7.V5,DInt,1700,PIECES_KO_3 +SECT1.N7.V6,DInt,1704,PIECES_KO_4 +SECT1.N7.V7,DInt,1708,PIECES_KO_5 +SECT1.N7.V8,DInt,1712,PIECES_KO_6 +SECT1.N7.V9,DInt,1716,PIECES_KO_7 +SECT1.N7.V10,DInt,1720,PIECES_KO_8 +SECT1.N7.V11,DInt,1724,PIECES_KO_9 +SECT1.N7.V12,DInt,1728,PIECES_KO_10 +SECT1.N7.V13,DInt,1732,T_ALARM_HOURS +SECT1.N7.V14,DInt,1736,T_DRY_CYCLE_HOURS +SECT1.N7.V15,DInt,1740,T_POWERED_HOURS +SECT1.N7.V16,DInt,1744,T_PRODUCT_100_HOURS +SECT1.N7.V17,DInt,1748,T_PRODUCT_0_HOURS +SECT1.N7.V18,DInt,1752,T_STOP_HOURS +SECT1.N7.V19,Int,1756,T_ALARM_MINUTES +SECT1.N7.V20,Int,1758,T_DRY_CYCLE_MINUTES +SECT1.N7.V21,Int,1760,T_POWERED_MINUTES +SECT1.N7.V22,Int,1762,T_PRODUCT_100_MINUTES +SECT1.N7.V23,Int,1764,T_PRODUCT_0_MINUTES +SECT1.N7.V24,Int,1766,T_STOP_MINUTES +SECT2,"""UDT SIPA SV Section""",1352, +SECT2.N1,DInt,1664,.DB_IOT.STATO_MACCHINA +SECT2.N2,DInt,1668,.DB_IOT.ALLARME_FERMO +SECT2.N3,DInt,1672,.DB_IOT.WARNING_ATTIVO (che compromette produzione) +SECT2.N4,Int,1676,.DB_IOT.STATO_OPERATIVO (Semaforo) +SECT2.N5,Int,1678,".DB_IOT.MODO_OPERATIVO (Prod,Simula,Man, ecc)" +SECT2.N6,DInt,1680,.DB_IOT.ALARM_STOP_NO +SECT2.N7.V1,DInt,1684,PIECES_TOT +SECT2.N7.V2,DInt,1688,PIECES_OK +SECT2.N7.V3,DInt,1692,PIECES_KO_1 +SECT2.N7.V4,DInt,1696,PIECES_KO_2 +SECT2.N7.V5,DInt,1700,PIECES_KO_3 +SECT2.N7.V6,DInt,1704,PIECES_KO_4 +SECT2.N7.V7,DInt,1708,PIECES_KO_5 +SECT2.N7.V8,DInt,1712,PIECES_KO_6 +SECT2.N7.V9,DInt,1716,PIECES_KO_7 +SECT2.N7.V10,DInt,1720,PIECES_KO_8 +SECT2.N7.V11,DInt,1724,PIECES_KO_9 +SECT2.N7.V12,DInt,1728,PIECES_KO_10 +SECT2.N7.V13,DInt,1732,T_ALARM_HOURS +SECT2.N7.V14,DInt,1736,T_DRY_CYCLE_HOURS +SECT2.N7.V15,DInt,1740,T_POWERED_HOURS +SECT2.N7.V16,DInt,1744,T_PRODUCT_100_HOURS +SECT2.N7.V17,DInt,1748,T_PRODUCT_0_HOURS +SECT2.N7.V18,DInt,1752,T_STOP_HOURS +SECT2.N7.V19,Int,1756,T_ALARM_MINUTES +SECT2.N7.V20,Int,1758,T_DRY_CYCLE_MINUTES +SECT2.N7.V21,Int,1760,T_POWERED_MINUTES +SECT2.N7.V22,Int,1762,T_PRODUCT_100_MINUTES +SECT2.N7.V23,Int,1764,T_PRODUCT_0_MINUTES +SECT2.N7.V24,Int,1766,T_STOP_MINUTES +SECT3,"""UDT SIPA SV Section""",1456, +SECT3.N1,DInt,1664,.DB_IOT.STATO_MACCHINA +SECT3.N2,DInt,1668,.DB_IOT.ALLARME_FERMO +SECT3.N3,DInt,1672,.DB_IOT.WARNING_ATTIVO (che compromette produzione) +SECT3.N4,Int,1676,.DB_IOT.STATO_OPERATIVO (Semaforo) +SECT3.N5,Int,1678,".DB_IOT.MODO_OPERATIVO (Prod,Simula,Man, ecc)" +SECT3.N6,DInt,1680,.DB_IOT.ALARM_STOP_NO +SECT3.N7.V1,DInt,1684,PIECES_TOT +SECT3.N7.V2,DInt,1688,PIECES_OK +SECT3.N7.V3,DInt,1692,PIECES_KO_1 +SECT3.N7.V4,DInt,1696,PIECES_KO_2 +SECT3.N7.V5,DInt,1700,PIECES_KO_3 +SECT3.N7.V6,DInt,1704,PIECES_KO_4 +SECT3.N7.V7,DInt,1708,PIECES_KO_5 +SECT3.N7.V8,DInt,1712,PIECES_KO_6 +SECT3.N7.V9,DInt,1716,PIECES_KO_7 +SECT3.N7.V10,DInt,1720,PIECES_KO_8 +SECT3.N7.V11,DInt,1724,PIECES_KO_9 +SECT3.N7.V12,DInt,1728,PIECES_KO_10 +SECT3.N7.V13,DInt,1732,T_ALARM_HOURS +SECT3.N7.V14,DInt,1736,T_DRY_CYCLE_HOURS +SECT3.N7.V15,DInt,1740,T_POWERED_HOURS +SECT3.N7.V16,DInt,1744,T_PRODUCT_100_HOURS +SECT3.N7.V17,DInt,1748,T_PRODUCT_0_HOURS +SECT3.N7.V18,DInt,1752,T_STOP_HOURS +SECT3.N7.V19,Int,1756,T_ALARM_MINUTES +SECT3.N7.V20,Int,1758,T_DRY_CYCLE_MINUTES +SECT3.N7.V21,Int,1760,T_POWERED_MINUTES +SECT3.N7.V22,Int,1762,T_PRODUCT_100_MINUTES +SECT3.N7.V23,Int,1764,T_PRODUCT_0_MINUTES +SECT3.N7.V24,Int,1766,T_STOP_MINUTES +SECT4,"""UDT SIPA SV Section""",1560, +SECT4.N1,DInt,1664,.DB_IOT.STATO_MACCHINA +SECT4.N2,DInt,1668,.DB_IOT.ALLARME_FERMO +SECT4.N3,DInt,1672,.DB_IOT.WARNING_ATTIVO (che compromette produzione) +SECT4.N4,Int,1676,.DB_IOT.STATO_OPERATIVO (Semaforo) +SECT4.N5,Int,1678,".DB_IOT.MODO_OPERATIVO (Prod,Simula,Man, ecc)" +SECT4.N6,DInt,1680,.DB_IOT.ALARM_STOP_NO +SECT4.N7.V1,DInt,1684,PIECES_TOT +SECT4.N7.V2,DInt,1688,PIECES_OK +SECT4.N7.V3,DInt,1692,PIECES_KO_1 +SECT4.N7.V4,DInt,1696,PIECES_KO_2 +SECT4.N7.V5,DInt,1700,PIECES_KO_3 +SECT4.N7.V6,DInt,1704,PIECES_KO_4 +SECT4.N7.V7,DInt,1708,PIECES_KO_5 +SECT4.N7.V8,DInt,1712,PIECES_KO_6 +SECT4.N7.V9,DInt,1716,PIECES_KO_7 +SECT4.N7.V10,DInt,1720,PIECES_KO_8 +SECT4.N7.V11,DInt,1724,PIECES_KO_9 +SECT4.N7.V12,DInt,1728,PIECES_KO_10 +SECT4.N7.V13,DInt,1732,T_ALARM_HOURS +SECT4.N7.V14,DInt,1736,T_DRY_CYCLE_HOURS +SECT4.N7.V15,DInt,1740,T_POWERED_HOURS +SECT4.N7.V16,DInt,1744,T_PRODUCT_100_HOURS +SECT4.N7.V17,DInt,1748,T_PRODUCT_0_HOURS +SECT4.N7.V18,DInt,1752,T_STOP_HOURS +SECT4.N7.V19,Int,1756,T_ALARM_MINUTES +SECT4.N7.V20,Int,1758,T_DRY_CYCLE_MINUTES +SECT4.N7.V21,Int,1760,T_POWERED_MINUTES +SECT4.N7.V22,Int,1762,T_PRODUCT_100_MINUTES +SECT4.N7.V23,Int,1764,T_PRODUCT_0_MINUTES +SECT4.N7.V24,Int,1766,T_STOP_MINUTES +SECT5,"""UDT SIPA SV Section""",1664, +SECT5.N1,DInt,1664,.DB_IOT.STATO_MACCHINA +SECT5.N2,DInt,1668,.DB_IOT.ALLARME_FERMO +SECT5.N3,DInt,1672,.DB_IOT.WARNING_ATTIVO (che compromette produzione) +SECT5.N4,Int,1676,.DB_IOT.STATO_OPERATIVO (Semaforo) +SECT5.N5,Int,1678,".DB_IOT.MODO_OPERATIVO (Prod,Simula,Man, ecc)" +SECT5.N6,DInt,1680,.DB_IOT.ALARM_STOP_NO +SECT5.N7.V1,DInt,1684,PIECES_TOT +SECT5.N7.V2,DInt,1688,PIECES_OK +SECT5.N7.V3,DInt,1692,PIECES_KO_1 +SECT5.N7.V4,DInt,1696,PIECES_KO_2 +SECT5.N7.V5,DInt,1700,PIECES_KO_3 +SECT5.N7.V6,DInt,1704,PIECES_KO_4 +SECT5.N7.V7,DInt,1708,PIECES_KO_5 +SECT5.N7.V8,DInt,1712,PIECES_KO_6 +SECT5.N7.V9,DInt,1716,PIECES_KO_7 +SECT5.N7.V10,DInt,1720,PIECES_KO_8 +SECT5.N7.V11,DInt,1724,PIECES_KO_9 +SECT5.N7.V12,DInt,1728,PIECES_KO_10 +SECT5.N7.V13,DInt,1732,T_ALARM_HOURS +SECT5.N7.V14,DInt,1736,T_DRY_CYCLE_HOURS +SECT5.N7.V15,DInt,1740,T_POWERED_HOURS +SECT5.N7.V16,DInt,1744,T_PRODUCT_100_HOURS +SECT5.N7.V17,DInt,1748,T_PRODUCT_0_HOURS +SECT5.N7.V18,DInt,1752,T_STOP_HOURS +SECT5.N7.V19,Int,1756,T_ALARM_MINUTES +SECT5.N7.V20,Int,1758,T_DRY_CYCLE_MINUTES +SECT5.N7.V21,Int,1760,T_POWERED_MINUTES +SECT5.N7.V22,Int,1762,T_PRODUCT_100_MINUTES +SECT5.N7.V23,Int,1764,T_PRODUCT_0_MINUTES +SECT5.N7.V24,Int,1766,T_STOP_MINUTES diff --git a/DB_Structure.xlsx b/DB_Structure.xlsx new file mode 100644 index 0000000..d93fb48 Binary files /dev/null and b/DB_Structure.xlsx differ diff --git a/DB_Structure.xml b/DB_Structure.xml new file mode 100644 index 0000000..a842c56 --- /dev/null +++ b/DB_Structure.xml @@ -0,0 +1,924 @@ + + + + +
+ "UDT SIPA SV Main" + + + + + DInt + .DB_IOT.USERLEVEL + 0 + + + String[81] + .DB_IOT.USERNAME + 4 + + + String[81] + .DB_IOT.NOME_RICETTA + 88 + + + Int + .DB_IOT.NEXT_MAINT_CYCLES + 172 + + + + String[254] + + 174 + + + String[254] + + 430 + + + String[254] + + 686 + + + String[254] + + 942 + + + String[8] + + 1198 + + + + .DB_IOT.ELECTRIC_VOLTAGE_PHASE_D + + Real + true + 1208 + + + Real + true + 1212 + + + Real + true + 1216 + + + + .DB_IOT.ELECTRIC_CURRENT_PHASE_D + + Real + true + 1220 + + + Real + true + 1224 + + + Real + true + 1228 + + + + Real + .DB_IOT.ELECTRIC_POWER_D + 1232 + + + Real + .DB_IOT.ELECTRIC_POWER_FACTOR_D + 1236 + + + Real + .DB_IOT.ELECTRIC_POWER_HOUR_D + 1240 + + + Real + .DB_IOT.ELECTRIC_POWER_WH + 1244 + + + + 0 +
+ + "UDT SIPA SV Section" + + + + + DInt + .DB_IOT.STATO_MACCHINA + 1664 + + + DInt + .DB_IOT.ALLARME_FERMO + 1668 + + + DInt + .DB_IOT.WARNING_ATTIVO (che compromette produzione) + 1672 + + + Int + .DB_IOT.STATO_OPERATIVO (Semaforo) + 1676 + + + Int + .DB_IOT.MODO_OPERATIVO (Prod,Simula,Man, ecc) + 1678 + + + DInt + .DB_IOT.ALARM_STOP_NO + 1680 + + + + DInt + PIECES_TOT + 1684 + + + DInt + PIECES_OK + 1688 + + + DInt + PIECES_KO_1 + 1692 + + + DInt + PIECES_KO_2 + 1696 + + + DInt + PIECES_KO_3 + 1700 + + + DInt + PIECES_KO_4 + 1704 + + + DInt + PIECES_KO_5 + 1708 + + + DInt + PIECES_KO_6 + 1712 + + + DInt + PIECES_KO_7 + 1716 + + + DInt + PIECES_KO_8 + 1720 + + + DInt + PIECES_KO_9 + 1724 + + + DInt + PIECES_KO_10 + 1728 + + + DInt + T_ALARM_HOURS + 1732 + + + DInt + T_DRY_CYCLE_HOURS + 1736 + + + DInt + T_POWERED_HOURS + 1740 + + + DInt + T_PRODUCT_100_HOURS + 1744 + + + DInt + T_PRODUCT_0_HOURS + 1748 + + + DInt + T_STOP_HOURS + 1752 + + + Int + T_ALARM_MINUTES + 1756 + + + Int + T_DRY_CYCLE_MINUTES + 1758 + + + Int + T_POWERED_MINUTES + 1760 + + + Int + T_PRODUCT_100_MINUTES + 1762 + + + Int + T_PRODUCT_0_MINUTES + 1764 + + + Int + T_STOP_MINUTES + 1766 + + + + + 1248 + + + "UDT SIPA SV Section" + + + + + DInt + .DB_IOT.STATO_MACCHINA + 1664 + + + DInt + .DB_IOT.ALLARME_FERMO + 1668 + + + DInt + .DB_IOT.WARNING_ATTIVO (che compromette produzione) + 1672 + + + Int + .DB_IOT.STATO_OPERATIVO (Semaforo) + 1676 + + + Int + .DB_IOT.MODO_OPERATIVO (Prod,Simula,Man, ecc) + 1678 + + + DInt + .DB_IOT.ALARM_STOP_NO + 1680 + + + + DInt + PIECES_TOT + 1684 + + + DInt + PIECES_OK + 1688 + + + DInt + PIECES_KO_1 + 1692 + + + DInt + PIECES_KO_2 + 1696 + + + DInt + PIECES_KO_3 + 1700 + + + DInt + PIECES_KO_4 + 1704 + + + DInt + PIECES_KO_5 + 1708 + + + DInt + PIECES_KO_6 + 1712 + + + DInt + PIECES_KO_7 + 1716 + + + DInt + PIECES_KO_8 + 1720 + + + DInt + PIECES_KO_9 + 1724 + + + DInt + PIECES_KO_10 + 1728 + + + DInt + T_ALARM_HOURS + 1732 + + + DInt + T_DRY_CYCLE_HOURS + 1736 + + + DInt + T_POWERED_HOURS + 1740 + + + DInt + T_PRODUCT_100_HOURS + 1744 + + + DInt + T_PRODUCT_0_HOURS + 1748 + + + DInt + T_STOP_HOURS + 1752 + + + Int + T_ALARM_MINUTES + 1756 + + + Int + T_DRY_CYCLE_MINUTES + 1758 + + + Int + T_POWERED_MINUTES + 1760 + + + Int + T_PRODUCT_100_MINUTES + 1762 + + + Int + T_PRODUCT_0_MINUTES + 1764 + + + Int + T_STOP_MINUTES + 1766 + + + + + 1352 + + + "UDT SIPA SV Section" + + + + + DInt + .DB_IOT.STATO_MACCHINA + 1664 + + + DInt + .DB_IOT.ALLARME_FERMO + 1668 + + + DInt + .DB_IOT.WARNING_ATTIVO (che compromette produzione) + 1672 + + + Int + .DB_IOT.STATO_OPERATIVO (Semaforo) + 1676 + + + Int + .DB_IOT.MODO_OPERATIVO (Prod,Simula,Man, ecc) + 1678 + + + DInt + .DB_IOT.ALARM_STOP_NO + 1680 + + + + DInt + PIECES_TOT + 1684 + + + DInt + PIECES_OK + 1688 + + + DInt + PIECES_KO_1 + 1692 + + + DInt + PIECES_KO_2 + 1696 + + + DInt + PIECES_KO_3 + 1700 + + + DInt + PIECES_KO_4 + 1704 + + + DInt + PIECES_KO_5 + 1708 + + + DInt + PIECES_KO_6 + 1712 + + + DInt + PIECES_KO_7 + 1716 + + + DInt + PIECES_KO_8 + 1720 + + + DInt + PIECES_KO_9 + 1724 + + + DInt + PIECES_KO_10 + 1728 + + + DInt + T_ALARM_HOURS + 1732 + + + DInt + T_DRY_CYCLE_HOURS + 1736 + + + DInt + T_POWERED_HOURS + 1740 + + + DInt + T_PRODUCT_100_HOURS + 1744 + + + DInt + T_PRODUCT_0_HOURS + 1748 + + + DInt + T_STOP_HOURS + 1752 + + + Int + T_ALARM_MINUTES + 1756 + + + Int + T_DRY_CYCLE_MINUTES + 1758 + + + Int + T_POWERED_MINUTES + 1760 + + + Int + T_PRODUCT_100_MINUTES + 1762 + + + Int + T_PRODUCT_0_MINUTES + 1764 + + + Int + T_STOP_MINUTES + 1766 + + + + + 1456 + + + "UDT SIPA SV Section" + + + + + DInt + .DB_IOT.STATO_MACCHINA + 1664 + + + DInt + .DB_IOT.ALLARME_FERMO + 1668 + + + DInt + .DB_IOT.WARNING_ATTIVO (che compromette produzione) + 1672 + + + Int + .DB_IOT.STATO_OPERATIVO (Semaforo) + 1676 + + + Int + .DB_IOT.MODO_OPERATIVO (Prod,Simula,Man, ecc) + 1678 + + + DInt + .DB_IOT.ALARM_STOP_NO + 1680 + + + + DInt + PIECES_TOT + 1684 + + + DInt + PIECES_OK + 1688 + + + DInt + PIECES_KO_1 + 1692 + + + DInt + PIECES_KO_2 + 1696 + + + DInt + PIECES_KO_3 + 1700 + + + DInt + PIECES_KO_4 + 1704 + + + DInt + PIECES_KO_5 + 1708 + + + DInt + PIECES_KO_6 + 1712 + + + DInt + PIECES_KO_7 + 1716 + + + DInt + PIECES_KO_8 + 1720 + + + DInt + PIECES_KO_9 + 1724 + + + DInt + PIECES_KO_10 + 1728 + + + DInt + T_ALARM_HOURS + 1732 + + + DInt + T_DRY_CYCLE_HOURS + 1736 + + + DInt + T_POWERED_HOURS + 1740 + + + DInt + T_PRODUCT_100_HOURS + 1744 + + + DInt + T_PRODUCT_0_HOURS + 1748 + + + DInt + T_STOP_HOURS + 1752 + + + Int + T_ALARM_MINUTES + 1756 + + + Int + T_DRY_CYCLE_MINUTES + 1758 + + + Int + T_POWERED_MINUTES + 1760 + + + Int + T_PRODUCT_100_MINUTES + 1762 + + + Int + T_PRODUCT_0_MINUTES + 1764 + + + Int + T_STOP_MINUTES + 1766 + + + + + 1560 + + + "UDT SIPA SV Section" + + + + + DInt + .DB_IOT.STATO_MACCHINA + 1664 + + + DInt + .DB_IOT.ALLARME_FERMO + 1668 + + + DInt + .DB_IOT.WARNING_ATTIVO (che compromette produzione) + 1672 + + + Int + .DB_IOT.STATO_OPERATIVO (Semaforo) + 1676 + + + Int + .DB_IOT.MODO_OPERATIVO (Prod,Simula,Man, ecc) + 1678 + + + DInt + .DB_IOT.ALARM_STOP_NO + 1680 + + + + DInt + PIECES_TOT + 1684 + + + DInt + PIECES_OK + 1688 + + + DInt + PIECES_KO_1 + 1692 + + + DInt + PIECES_KO_2 + 1696 + + + DInt + PIECES_KO_3 + 1700 + + + DInt + PIECES_KO_4 + 1704 + + + DInt + PIECES_KO_5 + 1708 + + + DInt + PIECES_KO_6 + 1712 + + + DInt + PIECES_KO_7 + 1716 + + + DInt + PIECES_KO_8 + 1720 + + + DInt + PIECES_KO_9 + 1724 + + + DInt + PIECES_KO_10 + 1728 + + + DInt + T_ALARM_HOURS + 1732 + + + DInt + T_DRY_CYCLE_HOURS + 1736 + + + DInt + T_POWERED_HOURS + 1740 + + + DInt + T_PRODUCT_100_HOURS + 1744 + + + DInt + T_PRODUCT_0_HOURS + 1748 + + + DInt + T_STOP_HOURS + 1752 + + + Int + T_ALARM_MINUTES + 1756 + + + Int + T_DRY_CYCLE_MINUTES + 1758 + + + Int + T_POWERED_MINUTES + 1760 + + + Int + T_PRODUCT_100_MINUTES + 1762 + + + Int + T_PRODUCT_0_MINUTES + 1764 + + + Int + T_STOP_MINUTES + 1766 + + + + + 1664 + +
+
+
\ No newline at end of file diff --git a/DB_to_Excel.py b/DB_to_Excel.py new file mode 100644 index 0000000..334865a --- /dev/null +++ b/DB_to_Excel.py @@ -0,0 +1,172 @@ +import re +import json +import pandas as pd +from ExportData import * +from ExpandDB import * + + +def clean_line(line): + """Clean line from BOM and extra spaces or quotes.""" + # Remove UTF-8 BOM if exists and strip trailing/leading whitespace + line = line.replace("\ufeff", "").strip() + # Standardize TYPE and DATA_BLOCK definitions to ensure they're properly captured + line = re.sub(r'\s*TYPE\s+"?', 'TYPE "', line) + line = re.sub(r'\s*DATA_BLOCK\s+"?', 'DATA_BLOCK "', line) + return line + + +def extract_name(line): + """Extract the name from TYPE or DATA_BLOCK definition line.""" + # Attempt to find a quoted name first + match = re.search(r'(TYPE|DATA_BLOCK)\s+"([^"]+)"', line) + if match: + return match.group(2).strip() # The name is within quotes + + # If no quoted name, find an unquoted name + match = re.search(r"(TYPE|DATA_BLOCK)\s+(\S+)", line) + if match: + return match.group(2).strip() # The name is without quotes + + +def parse_udts(lines): + udt_json = {} + udt_name = None + nested_structs = [] + current_struct = None + is_within_struct = False + + for line in lines: + line = clean_line(line) + if "TYPE" in line and "END_TYPE" not in line: + udt_name = extract_name(line) + udt_json[udt_name] = {} + current_struct = udt_json[udt_name] + print(f"Created UDT: {udt_name}") + elif "END_TYPE" in line: + print(f"Completed UDT: {udt_name}") + udt_name = None + nested_structs = [] + current_struct = None + is_within_struct = False + elif "STRUCT" in line and "END_STRUCT" not in line and udt_name is not None: + struct_name = ( + "Struct" if "STRUCT" == line.strip() else line.split(":")[0].strip() + ) + new_struct = {} + current_struct[struct_name] = new_struct + nested_structs.append(current_struct) + current_struct = new_struct + is_within_struct = True + print(f"Created STRUCT: {struct_name}") + elif "END_STRUCT" in line and udt_name is not None: + current_struct = nested_structs.pop() if nested_structs else None + is_within_struct = bool(nested_structs) + print(f"Closed STRUCT in UDT '{udt_name}'") + elif udt_name and ":" in line and is_within_struct: + parts = line.split(":") + field_name = parts[0].strip() + field_details = parts[1].strip().split("//") + field_type = ( + field_details[0].replace(";", "").strip() + ) # Removing ';' from field type + field_comment = parts[1].split("//")[1].strip() if "//" in parts[1] else "" + if "Struct" in field_type: + new_struct = {} + current_struct[field_name] = new_struct + nested_structs.append(current_struct) + current_struct = new_struct + print(f"Opened inline STRUCT at field '{field_name}'") + else: + current_struct[field_name] = { + "type": field_type, + "comment": field_comment, + } + print( + f"Added field '{field_name}' to STRUCT: Type={field_type}, Comment={field_comment}" + ) + + return udt_json + + +def parse_dbs(lines, udts): + db_json = {} + db_name = None + nested_structs = [] + current_struct = None + is_within_struct = False + + for line in lines: + line = clean_line(line) + if "DATA_BLOCK" in line and "END_DATA_BLOCK" not in line: + db_name = extract_name(line) + db_json[db_name] = {} + current_struct = db_json[db_name] + print(f"Created DATA_BLOCK: {db_name}") + elif "END_DATA_BLOCK" in line: + print(f"Completed DATA_BLOCK: {db_name}") + db_name = None + nested_structs = [] + current_struct = None + is_within_struct = False + elif "STRUCT" in line and "END_STRUCT" not in line and db_name is not None: + struct_name = ( + "Struct" if "STRUCT" == line.strip() else line.split(":")[0].strip() + ) + new_struct = {} + current_struct[struct_name] = new_struct + nested_structs.append(current_struct) + current_struct = new_struct + is_within_struct = True + print(f"Created STRUCT in DB '{db_name}': {struct_name}") + elif "END_STRUCT" in line and db_name is not None: + current_struct = nested_structs.pop() if nested_structs else None + is_within_struct = bool(nested_structs) + print(f"Closed STRUCT in DB '{db_name}'") + elif db_name and ":" in line and is_within_struct: + parts = line.split(":") + field_name = parts[0].strip() + field_details = parts[1].strip().split("//") + field_type = ( + field_details[0].replace(";", "").strip() + ) # Removing ';' from field type + field_comment = parts[1].split("//")[1].strip() if "//" in parts[1] else "" + if "Struct" in field_type: + new_struct = {} + current_struct[field_name] = new_struct + nested_structs.append(current_struct) + current_struct = new_struct + print(f"Opened inline STRUCT at field '{field_name}' in DB '{db_name}'") + else: + current_struct[field_name] = { + "type": field_type, + "comment": field_comment, + } + print( + f"Added field '{field_name}' to STRUCT in DB '{db_name}': Type={field_type}, Comment={field_comment}" + ) + + return db_json + + +if __name__ == "__main__": + file_path = "DB SIPA Supervision.db" + with open(file_path, "r", encoding="utf-8-sig") as file: + lines = file.readlines() + + udt_json = parse_udts(lines) + db_json = parse_dbs(lines, udt_json) + + expand_dbs(udt_json, db_json) # Expand DBs with UDT definitions + + for db_name, db_content in db_json.items(): + calculate_offsets( + db_content + ) # Calculate offsets including special handling for Bool and String + + # Display the expanded DBs as a table + df = display_as_table(db_json) + save_dataframe_to_file(df) # Save the DataFrame to a CSV file + save_dataframe_to_excel(df) # Optionally, save the DataFrame to an Excel file + + # Save JSON data to an XML file + save_json_to_xml(db_json) diff --git a/ExpandDB.py b/ExpandDB.py new file mode 100644 index 0000000..9f4e7e4 --- /dev/null +++ b/ExpandDB.py @@ -0,0 +1,125 @@ +import re +import json +import pandas as pd + +def expand_udt_references(db_struct, udts): + """ + Recursively expand UDT references in the given DB structure using the UDT definitions. + This function specifically expands fields designated as 'type' which reference UDTs. + """ + if isinstance(db_struct, dict): + for key, value in list(db_struct.items()): + if isinstance(value, dict): + # Recurse into dictionaries + expand_udt_references(value, udts) + elif isinstance(value, str) and key == "type": # Only expand 'type' fields + type_name = value.strip( + '"' + ) # Remove quotes which may wrap UDT names with spaces + if type_name in udts: + # Replace the UDT reference with its definition, if it exists + db_struct["fields"] = udts[ + type_name + ].copy() # Assume structure to insert is under 'fields' + print(f"Expanded UDT '{type_name}' at field '{key}' ") + elif isinstance(db_struct, list): + for item in db_struct: + expand_udt_references(item, udts) + + +def handle_array_types(db_struct): + """ + Handle array types once all UDTs are expanded. + This function modifies the structure in place. + """ + if isinstance(db_struct, dict): + for key, value in list(db_struct.items()): + if isinstance(value, dict): + handle_array_types(value) + elif isinstance(value, str): + # Parsing array definitions, e.g., "Array[1..3] of Real" + match = re.match(r"Array\[(\d+)\.\.(\d+)\] of (\w+)", value) + if match: + lower_bound, upper_bound, base_type = ( + int(match.group(1)), + int(match.group(2)), + match.group(3), + ) + # Expand this field into multiple fields + db_struct.pop(key) # Remove the original field + for i in range(lower_bound, upper_bound + 1): + db_struct[f"{key}_{i}"] = {"type": base_type, 'is_array_element': True} + print( + f"Expanded field '{key}' into array fields: {key}_{lower_bound} to {key}_{upper_bound} of type {base_type}" + ) + + +type_sizes = { + "Int": 2, + "DInt": 4, + "Word": 2, + "Real": 4, + "Bool": 2, # We'll adjust this dynamically based on context (1 byte if alone, 1 bit if grouped) + "String": 1, # This will be multiplied by the specified size in brackets [n] +} + + +def calculate_offsets(db_struct, current_offset=0, parent=None): + """ + Recursively calculate byte offsets for each field in the DB structure considering special types. + """ + last_key_was_bool = False + if isinstance(db_struct, dict): + for key, value in list(db_struct.items()): + if isinstance(value, dict): + if "type" in value: + type_name = value["type"] + is_array_element = value.get('is_array_element', False) + size = type_sizes.get( + type_name, 0 + ) # Default to 1 byte if type is not recognized + + if not is_array_element and current_offset % 2 != 0: + current_offset += 1 # Align to the next even offset if it's not an array element + + # Special handling for String types + if "String" in type_name: + match = re.match(r"String\[(\d+)\]", type_name) + if match: + length = int(match.group(1)) + size = length + 2 # Account for null-termination and string length prefix + else: + size = type_sizes.get(type_name, 1) # Default to generic size if not an array + + # Adjusting Bool sizes based on grouping + if type_name == "Bool": + if last_key_was_bool: # This is a grouped bool + size = 0.125 # One bit per Bool if grouped + else: + size = 2 # Bools use a full byte if not grouped + last_key_was_bool = True + else: + last_key_was_bool = False + + value["offset"] = current_offset + current_offset += size + + current_offset = calculate_offsets( + value, current_offset, value + ) # Recurse into nested structs + elif isinstance(db_struct, list): + for item in db_struct: + current_offset = calculate_offsets(item, current_offset, parent) + return current_offset + + +def expand_dbs(udts, dbs): + """ + Expand all UDT references in all DBs and then handle array types. + """ + for db_name, db_content in dbs.items(): + print(f"Expanding DB: {db_name}") + expand_udt_references(db_content, udts) + handle_array_types(db_content) + calculate_offsets(db_content) + print(f"Completed expansion for DB: {db_name}") diff --git a/ExportData.py b/ExportData.py new file mode 100644 index 0000000..a178f54 --- /dev/null +++ b/ExportData.py @@ -0,0 +1,74 @@ +import xmltodict +import pandas as pd + +def save_json_to_xml(json_data, filename="DB_Structure.xml"): + """ + Convert JSON data to XML and save it to a file. + """ + xml_data = xmltodict.unparse({"root": json_data}, pretty=True) + with open(filename, "w") as xml_file: + xml_file.write(xml_data) + print(f"XML data saved to {filename}") + + +def save_dataframe_to_excel(df, filename="DB_Structure.xlsx"): + """ + Save the provided DataFrame to an Excel file. + """ + df.to_excel(filename, index=False) + print(f"Data saved to {filename}") + + +def save_dataframe_to_file(df, filename="DB_Structure.csv"): + """ + Save the provided DataFrame to a CSV file. + """ + df.to_csv(filename, index=False) + print(f"Data saved to {filename}") + + +def collect_data_for_table(db_struct, parent_prefix="", collected_data=[]): + """ + Recursively collect data from the DB structure to display in a tabular format, + omitting 'fields' and 'Struct' in the names. + """ + if isinstance(db_struct, dict): + for key, value in db_struct.items(): + # Skip 'fields' and 'Struct' keys in the name path + if key == 'fields' or key == 'Struct': + next_prefix = parent_prefix # Continue with the current prefix + else: + next_prefix = f"{parent_prefix}.{key}" if parent_prefix else key + + if isinstance(value, dict) and 'type' in value: # Directly a field with 'type' + field_data = { + "Nombre": next_prefix, + "Tipo": value.get('type', 'N/A'), + "Offset": value.get('offset', 'N/A'), + "Comentario": value.get('comment', 'N/A') + } + collected_data.append(field_data) + + # Recursively handle nested dictionaries and lists + if isinstance(value, dict) or isinstance(value, list): + collect_data_for_table(value, next_prefix, collected_data) + elif isinstance(db_struct, list): + for index, item in enumerate(db_struct): + item_prefix = f"{parent_prefix}[{index}]" if parent_prefix else f"[{index}]" + collect_data_for_table(item, item_prefix, collected_data) + + return collected_data + + +def display_as_table(dbs): + """ + Convert collected DB data into a pandas DataFrame and display it. + """ + all_data = [] + for db_name, db_content in dbs.items(): + print(f"Processing DB: {db_name}") + db_data = collect_data_for_table(db_content) + all_data.extend(db_data) + + df = pd.DataFrame(all_data) + return df diff --git a/__pycache__/ExpandDB.cpython-310.pyc b/__pycache__/ExpandDB.cpython-310.pyc new file mode 100644 index 0000000..3d88268 Binary files /dev/null and b/__pycache__/ExpandDB.cpython-310.pyc differ diff --git a/__pycache__/ExportData.cpython-310.pyc b/__pycache__/ExportData.cpython-310.pyc new file mode 100644 index 0000000..3b9b398 Binary files /dev/null and b/__pycache__/ExportData.cpython-310.pyc differ diff --git a/db_definitions.json b/db_definitions.json new file mode 100644 index 0000000..9273b31 --- /dev/null +++ b/db_definitions.json @@ -0,0 +1,30 @@ +{ + "DB SIPA Supervision": { + "root": { + "MAIN": { + "type": "\"UDT SIPA SV Main\";", + "comment": "" + }, + "SECT1": { + "type": "\"UDT SIPA SV Section\";", + "comment": "" + }, + "SECT2": { + "type": "\"UDT SIPA SV Section\";", + "comment": "" + }, + "SECT3": { + "type": "\"UDT SIPA SV Section\";", + "comment": "" + }, + "SECT4": { + "type": "\"UDT SIPA SV Section\";", + "comment": "" + }, + "SECT5": { + "type": "\"UDT SIPA SV Section\";", + "comment": "" + } + } + } +} \ No newline at end of file diff --git a/udt_definitions.json b/udt_definitions.json new file mode 100644 index 0000000..27c3c5c --- /dev/null +++ b/udt_definitions.json @@ -0,0 +1,194 @@ +{ + "UDT SIPA SV Main": { + "root": { + "N1": { + "type": "DInt;", + "comment": ".DB_IOT.USERLEVEL" + }, + "N2": { + "type": "String[81];", + "comment": ".DB_IOT.USERNAME" + }, + "N3": { + "type": "String[81];", + "comment": ".DB_IOT.NOME_RICETTA" + }, + "N4": { + "type": "Int;", + "comment": ".DB_IOT.NEXT_MAINT_CYCLES" + }, + "N5": { + "V1": { + "type": "String[254];", + "comment": "" + }, + "V2": { + "type": "String[254];", + "comment": "" + }, + "V3": { + "type": "String[254];", + "comment": "" + }, + "V4": { + "type": "String[254];", + "comment": "" + }, + "V5": { + "type": "String[8];", + "comment": "" + } + }, + "N6": { + "type": "Array[1..3] of Real;", + "comment": ".DB_IOT.ELECTRIC_VOLTAGE_PHASE_D" + }, + "N7": { + "type": "Array[1..3] of Real;", + "comment": ".DB_IOT.ELECTRIC_CURRENT_PHASE_D" + }, + "N8": { + "type": "Real;", + "comment": ".DB_IOT.ELECTRIC_POWER_D" + }, + "N9": { + "type": "Real;", + "comment": ".DB_IOT.ELECTRIC_POWER_FACTOR_D" + }, + "N10": { + "type": "Real;", + "comment": ".DB_IOT.ELECTRIC_POWER_HOUR_D" + }, + "N11": { + "type": "Real;", + "comment": ".DB_IOT.ELECTRIC_POWER_WH" + } + } + }, + "UDT SIPA SV Section": { + "root": { + "N1": { + "type": "DInt;", + "comment": ".DB_IOT.STATO_MACCHINA" + }, + "N2": { + "type": "DInt;", + "comment": ".DB_IOT.ALLARME_FERMO" + }, + "N3": { + "type": "DInt;", + "comment": ".DB_IOT.WARNING_ATTIVO (che compromette produzione)" + }, + "N4": { + "type": "Int;", + "comment": ".DB_IOT.STATO_OPERATIVO (Semaforo)" + }, + "N5": { + "type": "Int;", + "comment": ".DB_IOT.MODO_OPERATIVO (Prod,Simula,Man, ecc)" + }, + "N6": { + "type": "DInt;", + "comment": ".DB_IOT.ALARM_STOP_NO" + }, + "N7": { + "V1": { + "type": "DInt;", + "comment": "PIECES_TOT" + }, + "V2": { + "type": "DInt;", + "comment": "PIECES_OK" + }, + "V3": { + "type": "DInt;", + "comment": "PIECES_KO_1" + }, + "V4": { + "type": "DInt;", + "comment": "PIECES_KO_2" + }, + "V5": { + "type": "DInt;", + "comment": "PIECES_KO_3" + }, + "V6": { + "type": "DInt;", + "comment": "PIECES_KO_4" + }, + "V7": { + "type": "DInt;", + "comment": "PIECES_KO_5" + }, + "V8": { + "type": "DInt;", + "comment": "PIECES_KO_6" + }, + "V9": { + "type": "DInt;", + "comment": "PIECES_KO_7" + }, + "V10": { + "type": "DInt;", + "comment": "PIECES_KO_8" + }, + "V11": { + "type": "DInt;", + "comment": "PIECES_KO_9" + }, + "V12": { + "type": "DInt;", + "comment": "PIECES_KO_10" + }, + "V13": { + "type": "DInt;", + "comment": "T_ALARM_HOURS" + }, + "V14": { + "type": "DInt;", + "comment": "T_DRY_CYCLE_HOURS" + }, + "V15": { + "type": "DInt;", + "comment": "T_POWERED_HOURS" + }, + "V16": { + "type": "DInt;", + "comment": "T_PRODUCT_100_HOURS" + }, + "V17": { + "type": "DInt;", + "comment": "T_PRODUCT_0_HOURS" + }, + "V18": { + "type": "DInt;", + "comment": "T_STOP_HOURS" + }, + "V19": { + "type": "Int;", + "comment": "T_ALARM_MINUTES" + }, + "V20": { + "type": "Int;", + "comment": "T_DRY_CYCLE_MINUTES" + }, + "V21": { + "type": "Int;", + "comment": "T_POWERED_MINUTES" + }, + "V22": { + "type": "Int;", + "comment": "T_PRODUCT_100_MINUTES" + }, + "V23": { + "type": "Int;", + "comment": "T_PRODUCT_0_MINUTES" + }, + "V24": { + "type": "Int;", + "comment": "T_STOP_MINUTES" + } + } + } + } +} \ No newline at end of file