Offsets funcionando. El problema era el uso de copy en vez de deepcopy al expandir las udt

This commit is contained in:
Miguel 2024-04-22 09:21:25 +02:00
parent ee112f5e77
commit a4bc042b2c
7 changed files with 458 additions and 448 deletions

View File

@ -1,24 +1,19 @@
def handle_array_types(db_struct):
def calculate_offsets(db_struct, current_offset=0, parent=None):
"""
Handle array types once all UDTs are expanded.
This function modifies the structure in place.
Recursively calculate byte offsets for each field in the DB structure considering special types.
"""
last_key_was_bool = False
last_bit_offset = 0 # To track bit offsets within a byte
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}
if "type" in value and not "offset" in value:
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

View File

@ -22,129 +22,129 @@ MAIN.N9,Real,1236,DBD1236,.DB_IOT.ELECTRIC_POWER_FACTOR_D
MAIN.N10,Real,1240,DBD1240,.DB_IOT.ELECTRIC_POWER_HOUR_D
MAIN.N11,Real,1244,DBD1244,.DB_IOT.ELECTRIC_POWER_WH
SECT1,"""UDT SIPA SV Section""",1248,DBX1248.0,
SECT1.N1,DInt,1664,DBD1664,.DB_IOT.STATO_MACCHINA
SECT1.N2,DInt,1668,DBD1668,.DB_IOT.ALLARME_FERMO
SECT1.N3,DInt,1672,DBD1672,.DB_IOT.WARNING_ATTIVO (che compromette produzione)
SECT1.N4,Int,1676,DBW1676,.DB_IOT.STATO_OPERATIVO (Semaforo)
SECT1.N5,Int,1678,DBW1678,".DB_IOT.MODO_OPERATIVO (Prod,Simula,Man, ecc)"
SECT1.N6,DInt,1680,DBD1680,.DB_IOT.ALARM_STOP_NO
SECT1.N7.V1,DInt,1684,DBD1684,PIECES_TOT
SECT1.N7.V2,DInt,1688,DBD1688,PIECES_OK
SECT1.N7.V3,DInt,1692,DBD1692,PIECES_KO_1
SECT1.N7.V4,DInt,1696,DBD1696,PIECES_KO_2
SECT1.N7.V5,DInt,1700,DBD1700,PIECES_KO_3
SECT1.N7.V6,DInt,1704,DBD1704,PIECES_KO_4
SECT1.N7.V7,DInt,1708,DBD1708,PIECES_KO_5
SECT1.N7.V8,DInt,1712,DBD1712,PIECES_KO_6
SECT1.N7.V9,DInt,1716,DBD1716,PIECES_KO_7
SECT1.N7.V10,DInt,1720,DBD1720,PIECES_KO_8
SECT1.N7.V11,DInt,1724,DBD1724,PIECES_KO_9
SECT1.N7.V12,DInt,1728,DBD1728,PIECES_KO_10
SECT1.N7.V13,DInt,1732,DBD1732,T_ALARM_HOURS
SECT1.N7.V14,DInt,1736,DBD1736,T_DRY_CYCLE_HOURS
SECT1.N7.V15,DInt,1740,DBD1740,T_POWERED_HOURS
SECT1.N7.V16,DInt,1744,DBD1744,T_PRODUCT_100_HOURS
SECT1.N7.V17,DInt,1748,DBD1748,T_PRODUCT_0_HOURS
SECT1.N7.V18,DInt,1752,DBD1752,T_STOP_HOURS
SECT1.N7.V19,Int,1756,DBW1756,T_ALARM_MINUTES
SECT1.N7.V20,Int,1758,DBW1758,T_DRY_CYCLE_MINUTES
SECT1.N7.V21,Int,1760,DBW1760,T_POWERED_MINUTES
SECT1.N7.V22,Int,1762,DBW1762,T_PRODUCT_100_MINUTES
SECT1.N7.V23,Int,1764,DBW1764,T_PRODUCT_0_MINUTES
SECT1.N7.V24,Int,1766,DBW1766,T_STOP_MINUTES
SECT1.N1,DInt,1248,DBD1248,.DB_IOT.STATO_MACCHINA
SECT1.N2,DInt,1252,DBD1252,.DB_IOT.ALLARME_FERMO
SECT1.N3,DInt,1256,DBD1256,.DB_IOT.WARNING_ATTIVO (che compromette produzione)
SECT1.N4,Int,1260,DBW1260,.DB_IOT.STATO_OPERATIVO (Semaforo)
SECT1.N5,Int,1262,DBW1262,".DB_IOT.MODO_OPERATIVO (Prod,Simula,Man, ecc)"
SECT1.N6,DInt,1264,DBD1264,.DB_IOT.ALARM_STOP_NO
SECT1.N7.V1,DInt,1268,DBD1268,PIECES_TOT
SECT1.N7.V2,DInt,1272,DBD1272,PIECES_OK
SECT1.N7.V3,DInt,1276,DBD1276,PIECES_KO_1
SECT1.N7.V4,DInt,1280,DBD1280,PIECES_KO_2
SECT1.N7.V5,DInt,1284,DBD1284,PIECES_KO_3
SECT1.N7.V6,DInt,1288,DBD1288,PIECES_KO_4
SECT1.N7.V7,DInt,1292,DBD1292,PIECES_KO_5
SECT1.N7.V8,DInt,1296,DBD1296,PIECES_KO_6
SECT1.N7.V9,DInt,1300,DBD1300,PIECES_KO_7
SECT1.N7.V10,DInt,1304,DBD1304,PIECES_KO_8
SECT1.N7.V11,DInt,1308,DBD1308,PIECES_KO_9
SECT1.N7.V12,DInt,1312,DBD1312,PIECES_KO_10
SECT1.N7.V13,DInt,1316,DBD1316,T_ALARM_HOURS
SECT1.N7.V14,DInt,1320,DBD1320,T_DRY_CYCLE_HOURS
SECT1.N7.V15,DInt,1324,DBD1324,T_POWERED_HOURS
SECT1.N7.V16,DInt,1328,DBD1328,T_PRODUCT_100_HOURS
SECT1.N7.V17,DInt,1332,DBD1332,T_PRODUCT_0_HOURS
SECT1.N7.V18,DInt,1336,DBD1336,T_STOP_HOURS
SECT1.N7.V19,Int,1340,DBW1340,T_ALARM_MINUTES
SECT1.N7.V20,Int,1342,DBW1342,T_DRY_CYCLE_MINUTES
SECT1.N7.V21,Int,1344,DBW1344,T_POWERED_MINUTES
SECT1.N7.V22,Int,1346,DBW1346,T_PRODUCT_100_MINUTES
SECT1.N7.V23,Int,1348,DBW1348,T_PRODUCT_0_MINUTES
SECT1.N7.V24,Int,1350,DBW1350,T_STOP_MINUTES
SECT2,"""UDT SIPA SV Section""",1352,DBX1352.0,
SECT2.N1,DInt,1664,DBD1664,.DB_IOT.STATO_MACCHINA
SECT2.N2,DInt,1668,DBD1668,.DB_IOT.ALLARME_FERMO
SECT2.N3,DInt,1672,DBD1672,.DB_IOT.WARNING_ATTIVO (che compromette produzione)
SECT2.N4,Int,1676,DBW1676,.DB_IOT.STATO_OPERATIVO (Semaforo)
SECT2.N5,Int,1678,DBW1678,".DB_IOT.MODO_OPERATIVO (Prod,Simula,Man, ecc)"
SECT2.N6,DInt,1680,DBD1680,.DB_IOT.ALARM_STOP_NO
SECT2.N7.V1,DInt,1684,DBD1684,PIECES_TOT
SECT2.N7.V2,DInt,1688,DBD1688,PIECES_OK
SECT2.N7.V3,DInt,1692,DBD1692,PIECES_KO_1
SECT2.N7.V4,DInt,1696,DBD1696,PIECES_KO_2
SECT2.N7.V5,DInt,1700,DBD1700,PIECES_KO_3
SECT2.N7.V6,DInt,1704,DBD1704,PIECES_KO_4
SECT2.N7.V7,DInt,1708,DBD1708,PIECES_KO_5
SECT2.N7.V8,DInt,1712,DBD1712,PIECES_KO_6
SECT2.N7.V9,DInt,1716,DBD1716,PIECES_KO_7
SECT2.N7.V10,DInt,1720,DBD1720,PIECES_KO_8
SECT2.N7.V11,DInt,1724,DBD1724,PIECES_KO_9
SECT2.N7.V12,DInt,1728,DBD1728,PIECES_KO_10
SECT2.N7.V13,DInt,1732,DBD1732,T_ALARM_HOURS
SECT2.N7.V14,DInt,1736,DBD1736,T_DRY_CYCLE_HOURS
SECT2.N7.V15,DInt,1740,DBD1740,T_POWERED_HOURS
SECT2.N7.V16,DInt,1744,DBD1744,T_PRODUCT_100_HOURS
SECT2.N7.V17,DInt,1748,DBD1748,T_PRODUCT_0_HOURS
SECT2.N7.V18,DInt,1752,DBD1752,T_STOP_HOURS
SECT2.N7.V19,Int,1756,DBW1756,T_ALARM_MINUTES
SECT2.N7.V20,Int,1758,DBW1758,T_DRY_CYCLE_MINUTES
SECT2.N7.V21,Int,1760,DBW1760,T_POWERED_MINUTES
SECT2.N7.V22,Int,1762,DBW1762,T_PRODUCT_100_MINUTES
SECT2.N7.V23,Int,1764,DBW1764,T_PRODUCT_0_MINUTES
SECT2.N7.V24,Int,1766,DBW1766,T_STOP_MINUTES
SECT2.N1,DInt,1352,DBD1352,.DB_IOT.STATO_MACCHINA
SECT2.N2,DInt,1356,DBD1356,.DB_IOT.ALLARME_FERMO
SECT2.N3,DInt,1360,DBD1360,.DB_IOT.WARNING_ATTIVO (che compromette produzione)
SECT2.N4,Int,1364,DBW1364,.DB_IOT.STATO_OPERATIVO (Semaforo)
SECT2.N5,Int,1366,DBW1366,".DB_IOT.MODO_OPERATIVO (Prod,Simula,Man, ecc)"
SECT2.N6,DInt,1368,DBD1368,.DB_IOT.ALARM_STOP_NO
SECT2.N7.V1,DInt,1372,DBD1372,PIECES_TOT
SECT2.N7.V2,DInt,1376,DBD1376,PIECES_OK
SECT2.N7.V3,DInt,1380,DBD1380,PIECES_KO_1
SECT2.N7.V4,DInt,1384,DBD1384,PIECES_KO_2
SECT2.N7.V5,DInt,1388,DBD1388,PIECES_KO_3
SECT2.N7.V6,DInt,1392,DBD1392,PIECES_KO_4
SECT2.N7.V7,DInt,1396,DBD1396,PIECES_KO_5
SECT2.N7.V8,DInt,1400,DBD1400,PIECES_KO_6
SECT2.N7.V9,DInt,1404,DBD1404,PIECES_KO_7
SECT2.N7.V10,DInt,1408,DBD1408,PIECES_KO_8
SECT2.N7.V11,DInt,1412,DBD1412,PIECES_KO_9
SECT2.N7.V12,DInt,1416,DBD1416,PIECES_KO_10
SECT2.N7.V13,DInt,1420,DBD1420,T_ALARM_HOURS
SECT2.N7.V14,DInt,1424,DBD1424,T_DRY_CYCLE_HOURS
SECT2.N7.V15,DInt,1428,DBD1428,T_POWERED_HOURS
SECT2.N7.V16,DInt,1432,DBD1432,T_PRODUCT_100_HOURS
SECT2.N7.V17,DInt,1436,DBD1436,T_PRODUCT_0_HOURS
SECT2.N7.V18,DInt,1440,DBD1440,T_STOP_HOURS
SECT2.N7.V19,Int,1444,DBW1444,T_ALARM_MINUTES
SECT2.N7.V20,Int,1446,DBW1446,T_DRY_CYCLE_MINUTES
SECT2.N7.V21,Int,1448,DBW1448,T_POWERED_MINUTES
SECT2.N7.V22,Int,1450,DBW1450,T_PRODUCT_100_MINUTES
SECT2.N7.V23,Int,1452,DBW1452,T_PRODUCT_0_MINUTES
SECT2.N7.V24,Int,1454,DBW1454,T_STOP_MINUTES
SECT3,"""UDT SIPA SV Section""",1456,DBX1456.0,
SECT3.N1,DInt,1664,DBD1664,.DB_IOT.STATO_MACCHINA
SECT3.N2,DInt,1668,DBD1668,.DB_IOT.ALLARME_FERMO
SECT3.N3,DInt,1672,DBD1672,.DB_IOT.WARNING_ATTIVO (che compromette produzione)
SECT3.N4,Int,1676,DBW1676,.DB_IOT.STATO_OPERATIVO (Semaforo)
SECT3.N5,Int,1678,DBW1678,".DB_IOT.MODO_OPERATIVO (Prod,Simula,Man, ecc)"
SECT3.N6,DInt,1680,DBD1680,.DB_IOT.ALARM_STOP_NO
SECT3.N7.V1,DInt,1684,DBD1684,PIECES_TOT
SECT3.N7.V2,DInt,1688,DBD1688,PIECES_OK
SECT3.N7.V3,DInt,1692,DBD1692,PIECES_KO_1
SECT3.N7.V4,DInt,1696,DBD1696,PIECES_KO_2
SECT3.N7.V5,DInt,1700,DBD1700,PIECES_KO_3
SECT3.N7.V6,DInt,1704,DBD1704,PIECES_KO_4
SECT3.N7.V7,DInt,1708,DBD1708,PIECES_KO_5
SECT3.N7.V8,DInt,1712,DBD1712,PIECES_KO_6
SECT3.N7.V9,DInt,1716,DBD1716,PIECES_KO_7
SECT3.N7.V10,DInt,1720,DBD1720,PIECES_KO_8
SECT3.N7.V11,DInt,1724,DBD1724,PIECES_KO_9
SECT3.N7.V12,DInt,1728,DBD1728,PIECES_KO_10
SECT3.N7.V13,DInt,1732,DBD1732,T_ALARM_HOURS
SECT3.N7.V14,DInt,1736,DBD1736,T_DRY_CYCLE_HOURS
SECT3.N7.V15,DInt,1740,DBD1740,T_POWERED_HOURS
SECT3.N7.V16,DInt,1744,DBD1744,T_PRODUCT_100_HOURS
SECT3.N7.V17,DInt,1748,DBD1748,T_PRODUCT_0_HOURS
SECT3.N7.V18,DInt,1752,DBD1752,T_STOP_HOURS
SECT3.N7.V19,Int,1756,DBW1756,T_ALARM_MINUTES
SECT3.N7.V20,Int,1758,DBW1758,T_DRY_CYCLE_MINUTES
SECT3.N7.V21,Int,1760,DBW1760,T_POWERED_MINUTES
SECT3.N7.V22,Int,1762,DBW1762,T_PRODUCT_100_MINUTES
SECT3.N7.V23,Int,1764,DBW1764,T_PRODUCT_0_MINUTES
SECT3.N7.V24,Int,1766,DBW1766,T_STOP_MINUTES
SECT3.N1,DInt,1456,DBD1456,.DB_IOT.STATO_MACCHINA
SECT3.N2,DInt,1460,DBD1460,.DB_IOT.ALLARME_FERMO
SECT3.N3,DInt,1464,DBD1464,.DB_IOT.WARNING_ATTIVO (che compromette produzione)
SECT3.N4,Int,1468,DBW1468,.DB_IOT.STATO_OPERATIVO (Semaforo)
SECT3.N5,Int,1470,DBW1470,".DB_IOT.MODO_OPERATIVO (Prod,Simula,Man, ecc)"
SECT3.N6,DInt,1472,DBD1472,.DB_IOT.ALARM_STOP_NO
SECT3.N7.V1,DInt,1476,DBD1476,PIECES_TOT
SECT3.N7.V2,DInt,1480,DBD1480,PIECES_OK
SECT3.N7.V3,DInt,1484,DBD1484,PIECES_KO_1
SECT3.N7.V4,DInt,1488,DBD1488,PIECES_KO_2
SECT3.N7.V5,DInt,1492,DBD1492,PIECES_KO_3
SECT3.N7.V6,DInt,1496,DBD1496,PIECES_KO_4
SECT3.N7.V7,DInt,1500,DBD1500,PIECES_KO_5
SECT3.N7.V8,DInt,1504,DBD1504,PIECES_KO_6
SECT3.N7.V9,DInt,1508,DBD1508,PIECES_KO_7
SECT3.N7.V10,DInt,1512,DBD1512,PIECES_KO_8
SECT3.N7.V11,DInt,1516,DBD1516,PIECES_KO_9
SECT3.N7.V12,DInt,1520,DBD1520,PIECES_KO_10
SECT3.N7.V13,DInt,1524,DBD1524,T_ALARM_HOURS
SECT3.N7.V14,DInt,1528,DBD1528,T_DRY_CYCLE_HOURS
SECT3.N7.V15,DInt,1532,DBD1532,T_POWERED_HOURS
SECT3.N7.V16,DInt,1536,DBD1536,T_PRODUCT_100_HOURS
SECT3.N7.V17,DInt,1540,DBD1540,T_PRODUCT_0_HOURS
SECT3.N7.V18,DInt,1544,DBD1544,T_STOP_HOURS
SECT3.N7.V19,Int,1548,DBW1548,T_ALARM_MINUTES
SECT3.N7.V20,Int,1550,DBW1550,T_DRY_CYCLE_MINUTES
SECT3.N7.V21,Int,1552,DBW1552,T_POWERED_MINUTES
SECT3.N7.V22,Int,1554,DBW1554,T_PRODUCT_100_MINUTES
SECT3.N7.V23,Int,1556,DBW1556,T_PRODUCT_0_MINUTES
SECT3.N7.V24,Int,1558,DBW1558,T_STOP_MINUTES
SECT4,"""UDT SIPA SV Section""",1560,DBX1560.0,
SECT4.N1,DInt,1664,DBD1664,.DB_IOT.STATO_MACCHINA
SECT4.N2,DInt,1668,DBD1668,.DB_IOT.ALLARME_FERMO
SECT4.N3,DInt,1672,DBD1672,.DB_IOT.WARNING_ATTIVO (che compromette produzione)
SECT4.N4,Int,1676,DBW1676,.DB_IOT.STATO_OPERATIVO (Semaforo)
SECT4.N5,Int,1678,DBW1678,".DB_IOT.MODO_OPERATIVO (Prod,Simula,Man, ecc)"
SECT4.N6,DInt,1680,DBD1680,.DB_IOT.ALARM_STOP_NO
SECT4.N7.V1,DInt,1684,DBD1684,PIECES_TOT
SECT4.N7.V2,DInt,1688,DBD1688,PIECES_OK
SECT4.N7.V3,DInt,1692,DBD1692,PIECES_KO_1
SECT4.N7.V4,DInt,1696,DBD1696,PIECES_KO_2
SECT4.N7.V5,DInt,1700,DBD1700,PIECES_KO_3
SECT4.N7.V6,DInt,1704,DBD1704,PIECES_KO_4
SECT4.N7.V7,DInt,1708,DBD1708,PIECES_KO_5
SECT4.N7.V8,DInt,1712,DBD1712,PIECES_KO_6
SECT4.N7.V9,DInt,1716,DBD1716,PIECES_KO_7
SECT4.N7.V10,DInt,1720,DBD1720,PIECES_KO_8
SECT4.N7.V11,DInt,1724,DBD1724,PIECES_KO_9
SECT4.N7.V12,DInt,1728,DBD1728,PIECES_KO_10
SECT4.N7.V13,DInt,1732,DBD1732,T_ALARM_HOURS
SECT4.N7.V14,DInt,1736,DBD1736,T_DRY_CYCLE_HOURS
SECT4.N7.V15,DInt,1740,DBD1740,T_POWERED_HOURS
SECT4.N7.V16,DInt,1744,DBD1744,T_PRODUCT_100_HOURS
SECT4.N7.V17,DInt,1748,DBD1748,T_PRODUCT_0_HOURS
SECT4.N7.V18,DInt,1752,DBD1752,T_STOP_HOURS
SECT4.N7.V19,Int,1756,DBW1756,T_ALARM_MINUTES
SECT4.N7.V20,Int,1758,DBW1758,T_DRY_CYCLE_MINUTES
SECT4.N7.V21,Int,1760,DBW1760,T_POWERED_MINUTES
SECT4.N7.V22,Int,1762,DBW1762,T_PRODUCT_100_MINUTES
SECT4.N7.V23,Int,1764,DBW1764,T_PRODUCT_0_MINUTES
SECT4.N7.V24,Int,1766,DBW1766,T_STOP_MINUTES
SECT4.N1,DInt,1560,DBD1560,.DB_IOT.STATO_MACCHINA
SECT4.N2,DInt,1564,DBD1564,.DB_IOT.ALLARME_FERMO
SECT4.N3,DInt,1568,DBD1568,.DB_IOT.WARNING_ATTIVO (che compromette produzione)
SECT4.N4,Int,1572,DBW1572,.DB_IOT.STATO_OPERATIVO (Semaforo)
SECT4.N5,Int,1574,DBW1574,".DB_IOT.MODO_OPERATIVO (Prod,Simula,Man, ecc)"
SECT4.N6,DInt,1576,DBD1576,.DB_IOT.ALARM_STOP_NO
SECT4.N7.V1,DInt,1580,DBD1580,PIECES_TOT
SECT4.N7.V2,DInt,1584,DBD1584,PIECES_OK
SECT4.N7.V3,DInt,1588,DBD1588,PIECES_KO_1
SECT4.N7.V4,DInt,1592,DBD1592,PIECES_KO_2
SECT4.N7.V5,DInt,1596,DBD1596,PIECES_KO_3
SECT4.N7.V6,DInt,1600,DBD1600,PIECES_KO_4
SECT4.N7.V7,DInt,1604,DBD1604,PIECES_KO_5
SECT4.N7.V8,DInt,1608,DBD1608,PIECES_KO_6
SECT4.N7.V9,DInt,1612,DBD1612,PIECES_KO_7
SECT4.N7.V10,DInt,1616,DBD1616,PIECES_KO_8
SECT4.N7.V11,DInt,1620,DBD1620,PIECES_KO_9
SECT4.N7.V12,DInt,1624,DBD1624,PIECES_KO_10
SECT4.N7.V13,DInt,1628,DBD1628,T_ALARM_HOURS
SECT4.N7.V14,DInt,1632,DBD1632,T_DRY_CYCLE_HOURS
SECT4.N7.V15,DInt,1636,DBD1636,T_POWERED_HOURS
SECT4.N7.V16,DInt,1640,DBD1640,T_PRODUCT_100_HOURS
SECT4.N7.V17,DInt,1644,DBD1644,T_PRODUCT_0_HOURS
SECT4.N7.V18,DInt,1648,DBD1648,T_STOP_HOURS
SECT4.N7.V19,Int,1652,DBW1652,T_ALARM_MINUTES
SECT4.N7.V20,Int,1654,DBW1654,T_DRY_CYCLE_MINUTES
SECT4.N7.V21,Int,1656,DBW1656,T_POWERED_MINUTES
SECT4.N7.V22,Int,1658,DBW1658,T_PRODUCT_100_MINUTES
SECT4.N7.V23,Int,1660,DBW1660,T_PRODUCT_0_MINUTES
SECT4.N7.V24,Int,1662,DBW1662,T_STOP_MINUTES
SECT5,"""UDT SIPA SV Section""",1664,DBX1664.0,
SECT5.N1,DInt,1664,DBD1664,.DB_IOT.STATO_MACCHINA
SECT5.N2,DInt,1668,DBD1668,.DB_IOT.ALLARME_FERMO

1 Nombre Tipo Offset Dirección PLC Comentario
22 MAIN.N10 Real 1240 DBD1240 .DB_IOT.ELECTRIC_POWER_HOUR_D
23 MAIN.N11 Real 1244 DBD1244 .DB_IOT.ELECTRIC_POWER_WH
24 SECT1 "UDT SIPA SV Section" 1248 DBX1248.0
25 SECT1.N1 DInt 1664 1248 DBD1664 DBD1248 .DB_IOT.STATO_MACCHINA
26 SECT1.N2 DInt 1668 1252 DBD1668 DBD1252 .DB_IOT.ALLARME_FERMO
27 SECT1.N3 DInt 1672 1256 DBD1672 DBD1256 .DB_IOT.WARNING_ATTIVO (che compromette produzione)
28 SECT1.N4 Int 1676 1260 DBW1676 DBW1260 .DB_IOT.STATO_OPERATIVO (Semaforo)
29 SECT1.N5 Int 1678 1262 DBW1678 DBW1262 .DB_IOT.MODO_OPERATIVO (Prod,Simula,Man, ecc)
30 SECT1.N6 DInt 1680 1264 DBD1680 DBD1264 .DB_IOT.ALARM_STOP_NO
31 SECT1.N7.V1 DInt 1684 1268 DBD1684 DBD1268 PIECES_TOT
32 SECT1.N7.V2 DInt 1688 1272 DBD1688 DBD1272 PIECES_OK
33 SECT1.N7.V3 DInt 1692 1276 DBD1692 DBD1276 PIECES_KO_1
34 SECT1.N7.V4 DInt 1696 1280 DBD1696 DBD1280 PIECES_KO_2
35 SECT1.N7.V5 DInt 1700 1284 DBD1700 DBD1284 PIECES_KO_3
36 SECT1.N7.V6 DInt 1704 1288 DBD1704 DBD1288 PIECES_KO_4
37 SECT1.N7.V7 DInt 1708 1292 DBD1708 DBD1292 PIECES_KO_5
38 SECT1.N7.V8 DInt 1712 1296 DBD1712 DBD1296 PIECES_KO_6
39 SECT1.N7.V9 DInt 1716 1300 DBD1716 DBD1300 PIECES_KO_7
40 SECT1.N7.V10 DInt 1720 1304 DBD1720 DBD1304 PIECES_KO_8
41 SECT1.N7.V11 DInt 1724 1308 DBD1724 DBD1308 PIECES_KO_9
42 SECT1.N7.V12 DInt 1728 1312 DBD1728 DBD1312 PIECES_KO_10
43 SECT1.N7.V13 DInt 1732 1316 DBD1732 DBD1316 T_ALARM_HOURS
44 SECT1.N7.V14 DInt 1736 1320 DBD1736 DBD1320 T_DRY_CYCLE_HOURS
45 SECT1.N7.V15 DInt 1740 1324 DBD1740 DBD1324 T_POWERED_HOURS
46 SECT1.N7.V16 DInt 1744 1328 DBD1744 DBD1328 T_PRODUCT_100_HOURS
47 SECT1.N7.V17 DInt 1748 1332 DBD1748 DBD1332 T_PRODUCT_0_HOURS
48 SECT1.N7.V18 DInt 1752 1336 DBD1752 DBD1336 T_STOP_HOURS
49 SECT1.N7.V19 Int 1756 1340 DBW1756 DBW1340 T_ALARM_MINUTES
50 SECT1.N7.V20 Int 1758 1342 DBW1758 DBW1342 T_DRY_CYCLE_MINUTES
51 SECT1.N7.V21 Int 1760 1344 DBW1760 DBW1344 T_POWERED_MINUTES
52 SECT1.N7.V22 Int 1762 1346 DBW1762 DBW1346 T_PRODUCT_100_MINUTES
53 SECT1.N7.V23 Int 1764 1348 DBW1764 DBW1348 T_PRODUCT_0_MINUTES
54 SECT1.N7.V24 Int 1766 1350 DBW1766 DBW1350 T_STOP_MINUTES
55 SECT2 "UDT SIPA SV Section" 1352 DBX1352.0
56 SECT2.N1 DInt 1664 1352 DBD1664 DBD1352 .DB_IOT.STATO_MACCHINA
57 SECT2.N2 DInt 1668 1356 DBD1668 DBD1356 .DB_IOT.ALLARME_FERMO
58 SECT2.N3 DInt 1672 1360 DBD1672 DBD1360 .DB_IOT.WARNING_ATTIVO (che compromette produzione)
59 SECT2.N4 Int 1676 1364 DBW1676 DBW1364 .DB_IOT.STATO_OPERATIVO (Semaforo)
60 SECT2.N5 Int 1678 1366 DBW1678 DBW1366 .DB_IOT.MODO_OPERATIVO (Prod,Simula,Man, ecc)
61 SECT2.N6 DInt 1680 1368 DBD1680 DBD1368 .DB_IOT.ALARM_STOP_NO
62 SECT2.N7.V1 DInt 1684 1372 DBD1684 DBD1372 PIECES_TOT
63 SECT2.N7.V2 DInt 1688 1376 DBD1688 DBD1376 PIECES_OK
64 SECT2.N7.V3 DInt 1692 1380 DBD1692 DBD1380 PIECES_KO_1
65 SECT2.N7.V4 DInt 1696 1384 DBD1696 DBD1384 PIECES_KO_2
66 SECT2.N7.V5 DInt 1700 1388 DBD1700 DBD1388 PIECES_KO_3
67 SECT2.N7.V6 DInt 1704 1392 DBD1704 DBD1392 PIECES_KO_4
68 SECT2.N7.V7 DInt 1708 1396 DBD1708 DBD1396 PIECES_KO_5
69 SECT2.N7.V8 DInt 1712 1400 DBD1712 DBD1400 PIECES_KO_6
70 SECT2.N7.V9 DInt 1716 1404 DBD1716 DBD1404 PIECES_KO_7
71 SECT2.N7.V10 DInt 1720 1408 DBD1720 DBD1408 PIECES_KO_8
72 SECT2.N7.V11 DInt 1724 1412 DBD1724 DBD1412 PIECES_KO_9
73 SECT2.N7.V12 DInt 1728 1416 DBD1728 DBD1416 PIECES_KO_10
74 SECT2.N7.V13 DInt 1732 1420 DBD1732 DBD1420 T_ALARM_HOURS
75 SECT2.N7.V14 DInt 1736 1424 DBD1736 DBD1424 T_DRY_CYCLE_HOURS
76 SECT2.N7.V15 DInt 1740 1428 DBD1740 DBD1428 T_POWERED_HOURS
77 SECT2.N7.V16 DInt 1744 1432 DBD1744 DBD1432 T_PRODUCT_100_HOURS
78 SECT2.N7.V17 DInt 1748 1436 DBD1748 DBD1436 T_PRODUCT_0_HOURS
79 SECT2.N7.V18 DInt 1752 1440 DBD1752 DBD1440 T_STOP_HOURS
80 SECT2.N7.V19 Int 1756 1444 DBW1756 DBW1444 T_ALARM_MINUTES
81 SECT2.N7.V20 Int 1758 1446 DBW1758 DBW1446 T_DRY_CYCLE_MINUTES
82 SECT2.N7.V21 Int 1760 1448 DBW1760 DBW1448 T_POWERED_MINUTES
83 SECT2.N7.V22 Int 1762 1450 DBW1762 DBW1450 T_PRODUCT_100_MINUTES
84 SECT2.N7.V23 Int 1764 1452 DBW1764 DBW1452 T_PRODUCT_0_MINUTES
85 SECT2.N7.V24 Int 1766 1454 DBW1766 DBW1454 T_STOP_MINUTES
86 SECT3 "UDT SIPA SV Section" 1456 DBX1456.0
87 SECT3.N1 DInt 1664 1456 DBD1664 DBD1456 .DB_IOT.STATO_MACCHINA
88 SECT3.N2 DInt 1668 1460 DBD1668 DBD1460 .DB_IOT.ALLARME_FERMO
89 SECT3.N3 DInt 1672 1464 DBD1672 DBD1464 .DB_IOT.WARNING_ATTIVO (che compromette produzione)
90 SECT3.N4 Int 1676 1468 DBW1676 DBW1468 .DB_IOT.STATO_OPERATIVO (Semaforo)
91 SECT3.N5 Int 1678 1470 DBW1678 DBW1470 .DB_IOT.MODO_OPERATIVO (Prod,Simula,Man, ecc)
92 SECT3.N6 DInt 1680 1472 DBD1680 DBD1472 .DB_IOT.ALARM_STOP_NO
93 SECT3.N7.V1 DInt 1684 1476 DBD1684 DBD1476 PIECES_TOT
94 SECT3.N7.V2 DInt 1688 1480 DBD1688 DBD1480 PIECES_OK
95 SECT3.N7.V3 DInt 1692 1484 DBD1692 DBD1484 PIECES_KO_1
96 SECT3.N7.V4 DInt 1696 1488 DBD1696 DBD1488 PIECES_KO_2
97 SECT3.N7.V5 DInt 1700 1492 DBD1700 DBD1492 PIECES_KO_3
98 SECT3.N7.V6 DInt 1704 1496 DBD1704 DBD1496 PIECES_KO_4
99 SECT3.N7.V7 DInt 1708 1500 DBD1708 DBD1500 PIECES_KO_5
100 SECT3.N7.V8 DInt 1712 1504 DBD1712 DBD1504 PIECES_KO_6
101 SECT3.N7.V9 DInt 1716 1508 DBD1716 DBD1508 PIECES_KO_7
102 SECT3.N7.V10 DInt 1720 1512 DBD1720 DBD1512 PIECES_KO_8
103 SECT3.N7.V11 DInt 1724 1516 DBD1724 DBD1516 PIECES_KO_9
104 SECT3.N7.V12 DInt 1728 1520 DBD1728 DBD1520 PIECES_KO_10
105 SECT3.N7.V13 DInt 1732 1524 DBD1732 DBD1524 T_ALARM_HOURS
106 SECT3.N7.V14 DInt 1736 1528 DBD1736 DBD1528 T_DRY_CYCLE_HOURS
107 SECT3.N7.V15 DInt 1740 1532 DBD1740 DBD1532 T_POWERED_HOURS
108 SECT3.N7.V16 DInt 1744 1536 DBD1744 DBD1536 T_PRODUCT_100_HOURS
109 SECT3.N7.V17 DInt 1748 1540 DBD1748 DBD1540 T_PRODUCT_0_HOURS
110 SECT3.N7.V18 DInt 1752 1544 DBD1752 DBD1544 T_STOP_HOURS
111 SECT3.N7.V19 Int 1756 1548 DBW1756 DBW1548 T_ALARM_MINUTES
112 SECT3.N7.V20 Int 1758 1550 DBW1758 DBW1550 T_DRY_CYCLE_MINUTES
113 SECT3.N7.V21 Int 1760 1552 DBW1760 DBW1552 T_POWERED_MINUTES
114 SECT3.N7.V22 Int 1762 1554 DBW1762 DBW1554 T_PRODUCT_100_MINUTES
115 SECT3.N7.V23 Int 1764 1556 DBW1764 DBW1556 T_PRODUCT_0_MINUTES
116 SECT3.N7.V24 Int 1766 1558 DBW1766 DBW1558 T_STOP_MINUTES
117 SECT4 "UDT SIPA SV Section" 1560 DBX1560.0
118 SECT4.N1 DInt 1664 1560 DBD1664 DBD1560 .DB_IOT.STATO_MACCHINA
119 SECT4.N2 DInt 1668 1564 DBD1668 DBD1564 .DB_IOT.ALLARME_FERMO
120 SECT4.N3 DInt 1672 1568 DBD1672 DBD1568 .DB_IOT.WARNING_ATTIVO (che compromette produzione)
121 SECT4.N4 Int 1676 1572 DBW1676 DBW1572 .DB_IOT.STATO_OPERATIVO (Semaforo)
122 SECT4.N5 Int 1678 1574 DBW1678 DBW1574 .DB_IOT.MODO_OPERATIVO (Prod,Simula,Man, ecc)
123 SECT4.N6 DInt 1680 1576 DBD1680 DBD1576 .DB_IOT.ALARM_STOP_NO
124 SECT4.N7.V1 DInt 1684 1580 DBD1684 DBD1580 PIECES_TOT
125 SECT4.N7.V2 DInt 1688 1584 DBD1688 DBD1584 PIECES_OK
126 SECT4.N7.V3 DInt 1692 1588 DBD1692 DBD1588 PIECES_KO_1
127 SECT4.N7.V4 DInt 1696 1592 DBD1696 DBD1592 PIECES_KO_2
128 SECT4.N7.V5 DInt 1700 1596 DBD1700 DBD1596 PIECES_KO_3
129 SECT4.N7.V6 DInt 1704 1600 DBD1704 DBD1600 PIECES_KO_4
130 SECT4.N7.V7 DInt 1708 1604 DBD1708 DBD1604 PIECES_KO_5
131 SECT4.N7.V8 DInt 1712 1608 DBD1712 DBD1608 PIECES_KO_6
132 SECT4.N7.V9 DInt 1716 1612 DBD1716 DBD1612 PIECES_KO_7
133 SECT4.N7.V10 DInt 1720 1616 DBD1720 DBD1616 PIECES_KO_8
134 SECT4.N7.V11 DInt 1724 1620 DBD1724 DBD1620 PIECES_KO_9
135 SECT4.N7.V12 DInt 1728 1624 DBD1728 DBD1624 PIECES_KO_10
136 SECT4.N7.V13 DInt 1732 1628 DBD1732 DBD1628 T_ALARM_HOURS
137 SECT4.N7.V14 DInt 1736 1632 DBD1736 DBD1632 T_DRY_CYCLE_HOURS
138 SECT4.N7.V15 DInt 1740 1636 DBD1740 DBD1636 T_POWERED_HOURS
139 SECT4.N7.V16 DInt 1744 1640 DBD1744 DBD1640 T_PRODUCT_100_HOURS
140 SECT4.N7.V17 DInt 1748 1644 DBD1748 DBD1644 T_PRODUCT_0_HOURS
141 SECT4.N7.V18 DInt 1752 1648 DBD1752 DBD1648 T_STOP_HOURS
142 SECT4.N7.V19 Int 1756 1652 DBW1756 DBW1652 T_ALARM_MINUTES
143 SECT4.N7.V20 Int 1758 1654 DBW1758 DBW1654 T_DRY_CYCLE_MINUTES
144 SECT4.N7.V21 Int 1760 1656 DBW1760 DBW1656 T_POWERED_MINUTES
145 SECT4.N7.V22 Int 1762 1658 DBW1762 DBW1658 T_PRODUCT_100_MINUTES
146 SECT4.N7.V23 Int 1764 1660 DBW1764 DBW1660 T_PRODUCT_0_MINUTES
147 SECT4.N7.V24 Int 1766 1662 DBW1766 DBW1662 T_STOP_MINUTES
148 SECT5 "UDT SIPA SV Section" 1664 DBX1664.0
149 SECT5.N1 DInt 1664 DBD1664 .DB_IOT.STATO_MACCHINA
150 SECT5.N2 DInt 1668 DBD1668 .DB_IOT.ALLARME_FERMO

Binary file not shown.

View File

@ -158,183 +158,183 @@
<N1>
<type>DInt</type>
<comment>.DB_IOT.STATO_MACCHINA</comment>
<offset>1664</offset>
<plc_address>DBD1664</plc_address>
<offset>1248</offset>
<plc_address>DBD1248</plc_address>
</N1>
<N2>
<type>DInt</type>
<comment>.DB_IOT.ALLARME_FERMO</comment>
<offset>1668</offset>
<plc_address>DBD1668</plc_address>
<offset>1252</offset>
<plc_address>DBD1252</plc_address>
</N2>
<N3>
<type>DInt</type>
<comment>.DB_IOT.WARNING_ATTIVO (che compromette produzione)</comment>
<offset>1672</offset>
<plc_address>DBD1672</plc_address>
<offset>1256</offset>
<plc_address>DBD1256</plc_address>
</N3>
<N4>
<type>Int</type>
<comment>.DB_IOT.STATO_OPERATIVO (Semaforo)</comment>
<offset>1676</offset>
<plc_address>DBW1676</plc_address>
<offset>1260</offset>
<plc_address>DBW1260</plc_address>
</N4>
<N5>
<type>Int</type>
<comment>.DB_IOT.MODO_OPERATIVO (Prod,Simula,Man, ecc)</comment>
<offset>1678</offset>
<plc_address>DBW1678</plc_address>
<offset>1262</offset>
<plc_address>DBW1262</plc_address>
</N5>
<N6>
<type>DInt</type>
<comment>.DB_IOT.ALARM_STOP_NO</comment>
<offset>1680</offset>
<plc_address>DBD1680</plc_address>
<offset>1264</offset>
<plc_address>DBD1264</plc_address>
</N6>
<N7>
<V1>
<type>DInt</type>
<comment>PIECES_TOT</comment>
<offset>1684</offset>
<plc_address>DBD1684</plc_address>
<offset>1268</offset>
<plc_address>DBD1268</plc_address>
</V1>
<V2>
<type>DInt</type>
<comment>PIECES_OK</comment>
<offset>1688</offset>
<plc_address>DBD1688</plc_address>
<offset>1272</offset>
<plc_address>DBD1272</plc_address>
</V2>
<V3>
<type>DInt</type>
<comment>PIECES_KO_1</comment>
<offset>1692</offset>
<plc_address>DBD1692</plc_address>
<offset>1276</offset>
<plc_address>DBD1276</plc_address>
</V3>
<V4>
<type>DInt</type>
<comment>PIECES_KO_2</comment>
<offset>1696</offset>
<plc_address>DBD1696</plc_address>
<offset>1280</offset>
<plc_address>DBD1280</plc_address>
</V4>
<V5>
<type>DInt</type>
<comment>PIECES_KO_3</comment>
<offset>1700</offset>
<plc_address>DBD1700</plc_address>
<offset>1284</offset>
<plc_address>DBD1284</plc_address>
</V5>
<V6>
<type>DInt</type>
<comment>PIECES_KO_4</comment>
<offset>1704</offset>
<plc_address>DBD1704</plc_address>
<offset>1288</offset>
<plc_address>DBD1288</plc_address>
</V6>
<V7>
<type>DInt</type>
<comment>PIECES_KO_5</comment>
<offset>1708</offset>
<plc_address>DBD1708</plc_address>
<offset>1292</offset>
<plc_address>DBD1292</plc_address>
</V7>
<V8>
<type>DInt</type>
<comment>PIECES_KO_6</comment>
<offset>1712</offset>
<plc_address>DBD1712</plc_address>
<offset>1296</offset>
<plc_address>DBD1296</plc_address>
</V8>
<V9>
<type>DInt</type>
<comment>PIECES_KO_7</comment>
<offset>1716</offset>
<plc_address>DBD1716</plc_address>
<offset>1300</offset>
<plc_address>DBD1300</plc_address>
</V9>
<V10>
<type>DInt</type>
<comment>PIECES_KO_8</comment>
<offset>1720</offset>
<plc_address>DBD1720</plc_address>
<offset>1304</offset>
<plc_address>DBD1304</plc_address>
</V10>
<V11>
<type>DInt</type>
<comment>PIECES_KO_9</comment>
<offset>1724</offset>
<plc_address>DBD1724</plc_address>
<offset>1308</offset>
<plc_address>DBD1308</plc_address>
</V11>
<V12>
<type>DInt</type>
<comment>PIECES_KO_10</comment>
<offset>1728</offset>
<plc_address>DBD1728</plc_address>
<offset>1312</offset>
<plc_address>DBD1312</plc_address>
</V12>
<V13>
<type>DInt</type>
<comment>T_ALARM_HOURS</comment>
<offset>1732</offset>
<plc_address>DBD1732</plc_address>
<offset>1316</offset>
<plc_address>DBD1316</plc_address>
</V13>
<V14>
<type>DInt</type>
<comment>T_DRY_CYCLE_HOURS</comment>
<offset>1736</offset>
<plc_address>DBD1736</plc_address>
<offset>1320</offset>
<plc_address>DBD1320</plc_address>
</V14>
<V15>
<type>DInt</type>
<comment>T_POWERED_HOURS</comment>
<offset>1740</offset>
<plc_address>DBD1740</plc_address>
<offset>1324</offset>
<plc_address>DBD1324</plc_address>
</V15>
<V16>
<type>DInt</type>
<comment>T_PRODUCT_100_HOURS</comment>
<offset>1744</offset>
<plc_address>DBD1744</plc_address>
<offset>1328</offset>
<plc_address>DBD1328</plc_address>
</V16>
<V17>
<type>DInt</type>
<comment>T_PRODUCT_0_HOURS</comment>
<offset>1748</offset>
<plc_address>DBD1748</plc_address>
<offset>1332</offset>
<plc_address>DBD1332</plc_address>
</V17>
<V18>
<type>DInt</type>
<comment>T_STOP_HOURS</comment>
<offset>1752</offset>
<plc_address>DBD1752</plc_address>
<offset>1336</offset>
<plc_address>DBD1336</plc_address>
</V18>
<V19>
<type>Int</type>
<comment>T_ALARM_MINUTES</comment>
<offset>1756</offset>
<plc_address>DBW1756</plc_address>
<offset>1340</offset>
<plc_address>DBW1340</plc_address>
</V19>
<V20>
<type>Int</type>
<comment>T_DRY_CYCLE_MINUTES</comment>
<offset>1758</offset>
<plc_address>DBW1758</plc_address>
<offset>1342</offset>
<plc_address>DBW1342</plc_address>
</V20>
<V21>
<type>Int</type>
<comment>T_POWERED_MINUTES</comment>
<offset>1760</offset>
<plc_address>DBW1760</plc_address>
<offset>1344</offset>
<plc_address>DBW1344</plc_address>
</V21>
<V22>
<type>Int</type>
<comment>T_PRODUCT_100_MINUTES</comment>
<offset>1762</offset>
<plc_address>DBW1762</plc_address>
<offset>1346</offset>
<plc_address>DBW1346</plc_address>
</V22>
<V23>
<type>Int</type>
<comment>T_PRODUCT_0_MINUTES</comment>
<offset>1764</offset>
<plc_address>DBW1764</plc_address>
<offset>1348</offset>
<plc_address>DBW1348</plc_address>
</V23>
<V24>
<type>Int</type>
<comment>T_STOP_MINUTES</comment>
<offset>1766</offset>
<plc_address>DBW1766</plc_address>
<offset>1350</offset>
<plc_address>DBW1350</plc_address>
</V24>
</N7>
</Struct>
@ -350,183 +350,183 @@
<N1>
<type>DInt</type>
<comment>.DB_IOT.STATO_MACCHINA</comment>
<offset>1664</offset>
<plc_address>DBD1664</plc_address>
<offset>1352</offset>
<plc_address>DBD1352</plc_address>
</N1>
<N2>
<type>DInt</type>
<comment>.DB_IOT.ALLARME_FERMO</comment>
<offset>1668</offset>
<plc_address>DBD1668</plc_address>
<offset>1356</offset>
<plc_address>DBD1356</plc_address>
</N2>
<N3>
<type>DInt</type>
<comment>.DB_IOT.WARNING_ATTIVO (che compromette produzione)</comment>
<offset>1672</offset>
<plc_address>DBD1672</plc_address>
<offset>1360</offset>
<plc_address>DBD1360</plc_address>
</N3>
<N4>
<type>Int</type>
<comment>.DB_IOT.STATO_OPERATIVO (Semaforo)</comment>
<offset>1676</offset>
<plc_address>DBW1676</plc_address>
<offset>1364</offset>
<plc_address>DBW1364</plc_address>
</N4>
<N5>
<type>Int</type>
<comment>.DB_IOT.MODO_OPERATIVO (Prod,Simula,Man, ecc)</comment>
<offset>1678</offset>
<plc_address>DBW1678</plc_address>
<offset>1366</offset>
<plc_address>DBW1366</plc_address>
</N5>
<N6>
<type>DInt</type>
<comment>.DB_IOT.ALARM_STOP_NO</comment>
<offset>1680</offset>
<plc_address>DBD1680</plc_address>
<offset>1368</offset>
<plc_address>DBD1368</plc_address>
</N6>
<N7>
<V1>
<type>DInt</type>
<comment>PIECES_TOT</comment>
<offset>1684</offset>
<plc_address>DBD1684</plc_address>
<offset>1372</offset>
<plc_address>DBD1372</plc_address>
</V1>
<V2>
<type>DInt</type>
<comment>PIECES_OK</comment>
<offset>1688</offset>
<plc_address>DBD1688</plc_address>
<offset>1376</offset>
<plc_address>DBD1376</plc_address>
</V2>
<V3>
<type>DInt</type>
<comment>PIECES_KO_1</comment>
<offset>1692</offset>
<plc_address>DBD1692</plc_address>
<offset>1380</offset>
<plc_address>DBD1380</plc_address>
</V3>
<V4>
<type>DInt</type>
<comment>PIECES_KO_2</comment>
<offset>1696</offset>
<plc_address>DBD1696</plc_address>
<offset>1384</offset>
<plc_address>DBD1384</plc_address>
</V4>
<V5>
<type>DInt</type>
<comment>PIECES_KO_3</comment>
<offset>1700</offset>
<plc_address>DBD1700</plc_address>
<offset>1388</offset>
<plc_address>DBD1388</plc_address>
</V5>
<V6>
<type>DInt</type>
<comment>PIECES_KO_4</comment>
<offset>1704</offset>
<plc_address>DBD1704</plc_address>
<offset>1392</offset>
<plc_address>DBD1392</plc_address>
</V6>
<V7>
<type>DInt</type>
<comment>PIECES_KO_5</comment>
<offset>1708</offset>
<plc_address>DBD1708</plc_address>
<offset>1396</offset>
<plc_address>DBD1396</plc_address>
</V7>
<V8>
<type>DInt</type>
<comment>PIECES_KO_6</comment>
<offset>1712</offset>
<plc_address>DBD1712</plc_address>
<offset>1400</offset>
<plc_address>DBD1400</plc_address>
</V8>
<V9>
<type>DInt</type>
<comment>PIECES_KO_7</comment>
<offset>1716</offset>
<plc_address>DBD1716</plc_address>
<offset>1404</offset>
<plc_address>DBD1404</plc_address>
</V9>
<V10>
<type>DInt</type>
<comment>PIECES_KO_8</comment>
<offset>1720</offset>
<plc_address>DBD1720</plc_address>
<offset>1408</offset>
<plc_address>DBD1408</plc_address>
</V10>
<V11>
<type>DInt</type>
<comment>PIECES_KO_9</comment>
<offset>1724</offset>
<plc_address>DBD1724</plc_address>
<offset>1412</offset>
<plc_address>DBD1412</plc_address>
</V11>
<V12>
<type>DInt</type>
<comment>PIECES_KO_10</comment>
<offset>1728</offset>
<plc_address>DBD1728</plc_address>
<offset>1416</offset>
<plc_address>DBD1416</plc_address>
</V12>
<V13>
<type>DInt</type>
<comment>T_ALARM_HOURS</comment>
<offset>1732</offset>
<plc_address>DBD1732</plc_address>
<offset>1420</offset>
<plc_address>DBD1420</plc_address>
</V13>
<V14>
<type>DInt</type>
<comment>T_DRY_CYCLE_HOURS</comment>
<offset>1736</offset>
<plc_address>DBD1736</plc_address>
<offset>1424</offset>
<plc_address>DBD1424</plc_address>
</V14>
<V15>
<type>DInt</type>
<comment>T_POWERED_HOURS</comment>
<offset>1740</offset>
<plc_address>DBD1740</plc_address>
<offset>1428</offset>
<plc_address>DBD1428</plc_address>
</V15>
<V16>
<type>DInt</type>
<comment>T_PRODUCT_100_HOURS</comment>
<offset>1744</offset>
<plc_address>DBD1744</plc_address>
<offset>1432</offset>
<plc_address>DBD1432</plc_address>
</V16>
<V17>
<type>DInt</type>
<comment>T_PRODUCT_0_HOURS</comment>
<offset>1748</offset>
<plc_address>DBD1748</plc_address>
<offset>1436</offset>
<plc_address>DBD1436</plc_address>
</V17>
<V18>
<type>DInt</type>
<comment>T_STOP_HOURS</comment>
<offset>1752</offset>
<plc_address>DBD1752</plc_address>
<offset>1440</offset>
<plc_address>DBD1440</plc_address>
</V18>
<V19>
<type>Int</type>
<comment>T_ALARM_MINUTES</comment>
<offset>1756</offset>
<plc_address>DBW1756</plc_address>
<offset>1444</offset>
<plc_address>DBW1444</plc_address>
</V19>
<V20>
<type>Int</type>
<comment>T_DRY_CYCLE_MINUTES</comment>
<offset>1758</offset>
<plc_address>DBW1758</plc_address>
<offset>1446</offset>
<plc_address>DBW1446</plc_address>
</V20>
<V21>
<type>Int</type>
<comment>T_POWERED_MINUTES</comment>
<offset>1760</offset>
<plc_address>DBW1760</plc_address>
<offset>1448</offset>
<plc_address>DBW1448</plc_address>
</V21>
<V22>
<type>Int</type>
<comment>T_PRODUCT_100_MINUTES</comment>
<offset>1762</offset>
<plc_address>DBW1762</plc_address>
<offset>1450</offset>
<plc_address>DBW1450</plc_address>
</V22>
<V23>
<type>Int</type>
<comment>T_PRODUCT_0_MINUTES</comment>
<offset>1764</offset>
<plc_address>DBW1764</plc_address>
<offset>1452</offset>
<plc_address>DBW1452</plc_address>
</V23>
<V24>
<type>Int</type>
<comment>T_STOP_MINUTES</comment>
<offset>1766</offset>
<plc_address>DBW1766</plc_address>
<offset>1454</offset>
<plc_address>DBW1454</plc_address>
</V24>
</N7>
</Struct>
@ -542,183 +542,183 @@
<N1>
<type>DInt</type>
<comment>.DB_IOT.STATO_MACCHINA</comment>
<offset>1664</offset>
<plc_address>DBD1664</plc_address>
<offset>1456</offset>
<plc_address>DBD1456</plc_address>
</N1>
<N2>
<type>DInt</type>
<comment>.DB_IOT.ALLARME_FERMO</comment>
<offset>1668</offset>
<plc_address>DBD1668</plc_address>
<offset>1460</offset>
<plc_address>DBD1460</plc_address>
</N2>
<N3>
<type>DInt</type>
<comment>.DB_IOT.WARNING_ATTIVO (che compromette produzione)</comment>
<offset>1672</offset>
<plc_address>DBD1672</plc_address>
<offset>1464</offset>
<plc_address>DBD1464</plc_address>
</N3>
<N4>
<type>Int</type>
<comment>.DB_IOT.STATO_OPERATIVO (Semaforo)</comment>
<offset>1676</offset>
<plc_address>DBW1676</plc_address>
<offset>1468</offset>
<plc_address>DBW1468</plc_address>
</N4>
<N5>
<type>Int</type>
<comment>.DB_IOT.MODO_OPERATIVO (Prod,Simula,Man, ecc)</comment>
<offset>1678</offset>
<plc_address>DBW1678</plc_address>
<offset>1470</offset>
<plc_address>DBW1470</plc_address>
</N5>
<N6>
<type>DInt</type>
<comment>.DB_IOT.ALARM_STOP_NO</comment>
<offset>1680</offset>
<plc_address>DBD1680</plc_address>
<offset>1472</offset>
<plc_address>DBD1472</plc_address>
</N6>
<N7>
<V1>
<type>DInt</type>
<comment>PIECES_TOT</comment>
<offset>1684</offset>
<plc_address>DBD1684</plc_address>
<offset>1476</offset>
<plc_address>DBD1476</plc_address>
</V1>
<V2>
<type>DInt</type>
<comment>PIECES_OK</comment>
<offset>1688</offset>
<plc_address>DBD1688</plc_address>
<offset>1480</offset>
<plc_address>DBD1480</plc_address>
</V2>
<V3>
<type>DInt</type>
<comment>PIECES_KO_1</comment>
<offset>1692</offset>
<plc_address>DBD1692</plc_address>
<offset>1484</offset>
<plc_address>DBD1484</plc_address>
</V3>
<V4>
<type>DInt</type>
<comment>PIECES_KO_2</comment>
<offset>1696</offset>
<plc_address>DBD1696</plc_address>
<offset>1488</offset>
<plc_address>DBD1488</plc_address>
</V4>
<V5>
<type>DInt</type>
<comment>PIECES_KO_3</comment>
<offset>1700</offset>
<plc_address>DBD1700</plc_address>
<offset>1492</offset>
<plc_address>DBD1492</plc_address>
</V5>
<V6>
<type>DInt</type>
<comment>PIECES_KO_4</comment>
<offset>1704</offset>
<plc_address>DBD1704</plc_address>
<offset>1496</offset>
<plc_address>DBD1496</plc_address>
</V6>
<V7>
<type>DInt</type>
<comment>PIECES_KO_5</comment>
<offset>1708</offset>
<plc_address>DBD1708</plc_address>
<offset>1500</offset>
<plc_address>DBD1500</plc_address>
</V7>
<V8>
<type>DInt</type>
<comment>PIECES_KO_6</comment>
<offset>1712</offset>
<plc_address>DBD1712</plc_address>
<offset>1504</offset>
<plc_address>DBD1504</plc_address>
</V8>
<V9>
<type>DInt</type>
<comment>PIECES_KO_7</comment>
<offset>1716</offset>
<plc_address>DBD1716</plc_address>
<offset>1508</offset>
<plc_address>DBD1508</plc_address>
</V9>
<V10>
<type>DInt</type>
<comment>PIECES_KO_8</comment>
<offset>1720</offset>
<plc_address>DBD1720</plc_address>
<offset>1512</offset>
<plc_address>DBD1512</plc_address>
</V10>
<V11>
<type>DInt</type>
<comment>PIECES_KO_9</comment>
<offset>1724</offset>
<plc_address>DBD1724</plc_address>
<offset>1516</offset>
<plc_address>DBD1516</plc_address>
</V11>
<V12>
<type>DInt</type>
<comment>PIECES_KO_10</comment>
<offset>1728</offset>
<plc_address>DBD1728</plc_address>
<offset>1520</offset>
<plc_address>DBD1520</plc_address>
</V12>
<V13>
<type>DInt</type>
<comment>T_ALARM_HOURS</comment>
<offset>1732</offset>
<plc_address>DBD1732</plc_address>
<offset>1524</offset>
<plc_address>DBD1524</plc_address>
</V13>
<V14>
<type>DInt</type>
<comment>T_DRY_CYCLE_HOURS</comment>
<offset>1736</offset>
<plc_address>DBD1736</plc_address>
<offset>1528</offset>
<plc_address>DBD1528</plc_address>
</V14>
<V15>
<type>DInt</type>
<comment>T_POWERED_HOURS</comment>
<offset>1740</offset>
<plc_address>DBD1740</plc_address>
<offset>1532</offset>
<plc_address>DBD1532</plc_address>
</V15>
<V16>
<type>DInt</type>
<comment>T_PRODUCT_100_HOURS</comment>
<offset>1744</offset>
<plc_address>DBD1744</plc_address>
<offset>1536</offset>
<plc_address>DBD1536</plc_address>
</V16>
<V17>
<type>DInt</type>
<comment>T_PRODUCT_0_HOURS</comment>
<offset>1748</offset>
<plc_address>DBD1748</plc_address>
<offset>1540</offset>
<plc_address>DBD1540</plc_address>
</V17>
<V18>
<type>DInt</type>
<comment>T_STOP_HOURS</comment>
<offset>1752</offset>
<plc_address>DBD1752</plc_address>
<offset>1544</offset>
<plc_address>DBD1544</plc_address>
</V18>
<V19>
<type>Int</type>
<comment>T_ALARM_MINUTES</comment>
<offset>1756</offset>
<plc_address>DBW1756</plc_address>
<offset>1548</offset>
<plc_address>DBW1548</plc_address>
</V19>
<V20>
<type>Int</type>
<comment>T_DRY_CYCLE_MINUTES</comment>
<offset>1758</offset>
<plc_address>DBW1758</plc_address>
<offset>1550</offset>
<plc_address>DBW1550</plc_address>
</V20>
<V21>
<type>Int</type>
<comment>T_POWERED_MINUTES</comment>
<offset>1760</offset>
<plc_address>DBW1760</plc_address>
<offset>1552</offset>
<plc_address>DBW1552</plc_address>
</V21>
<V22>
<type>Int</type>
<comment>T_PRODUCT_100_MINUTES</comment>
<offset>1762</offset>
<plc_address>DBW1762</plc_address>
<offset>1554</offset>
<plc_address>DBW1554</plc_address>
</V22>
<V23>
<type>Int</type>
<comment>T_PRODUCT_0_MINUTES</comment>
<offset>1764</offset>
<plc_address>DBW1764</plc_address>
<offset>1556</offset>
<plc_address>DBW1556</plc_address>
</V23>
<V24>
<type>Int</type>
<comment>T_STOP_MINUTES</comment>
<offset>1766</offset>
<plc_address>DBW1766</plc_address>
<offset>1558</offset>
<plc_address>DBW1558</plc_address>
</V24>
</N7>
</Struct>
@ -734,183 +734,183 @@
<N1>
<type>DInt</type>
<comment>.DB_IOT.STATO_MACCHINA</comment>
<offset>1664</offset>
<plc_address>DBD1664</plc_address>
<offset>1560</offset>
<plc_address>DBD1560</plc_address>
</N1>
<N2>
<type>DInt</type>
<comment>.DB_IOT.ALLARME_FERMO</comment>
<offset>1668</offset>
<plc_address>DBD1668</plc_address>
<offset>1564</offset>
<plc_address>DBD1564</plc_address>
</N2>
<N3>
<type>DInt</type>
<comment>.DB_IOT.WARNING_ATTIVO (che compromette produzione)</comment>
<offset>1672</offset>
<plc_address>DBD1672</plc_address>
<offset>1568</offset>
<plc_address>DBD1568</plc_address>
</N3>
<N4>
<type>Int</type>
<comment>.DB_IOT.STATO_OPERATIVO (Semaforo)</comment>
<offset>1676</offset>
<plc_address>DBW1676</plc_address>
<offset>1572</offset>
<plc_address>DBW1572</plc_address>
</N4>
<N5>
<type>Int</type>
<comment>.DB_IOT.MODO_OPERATIVO (Prod,Simula,Man, ecc)</comment>
<offset>1678</offset>
<plc_address>DBW1678</plc_address>
<offset>1574</offset>
<plc_address>DBW1574</plc_address>
</N5>
<N6>
<type>DInt</type>
<comment>.DB_IOT.ALARM_STOP_NO</comment>
<offset>1680</offset>
<plc_address>DBD1680</plc_address>
<offset>1576</offset>
<plc_address>DBD1576</plc_address>
</N6>
<N7>
<V1>
<type>DInt</type>
<comment>PIECES_TOT</comment>
<offset>1684</offset>
<plc_address>DBD1684</plc_address>
<offset>1580</offset>
<plc_address>DBD1580</plc_address>
</V1>
<V2>
<type>DInt</type>
<comment>PIECES_OK</comment>
<offset>1688</offset>
<plc_address>DBD1688</plc_address>
<offset>1584</offset>
<plc_address>DBD1584</plc_address>
</V2>
<V3>
<type>DInt</type>
<comment>PIECES_KO_1</comment>
<offset>1692</offset>
<plc_address>DBD1692</plc_address>
<offset>1588</offset>
<plc_address>DBD1588</plc_address>
</V3>
<V4>
<type>DInt</type>
<comment>PIECES_KO_2</comment>
<offset>1696</offset>
<plc_address>DBD1696</plc_address>
<offset>1592</offset>
<plc_address>DBD1592</plc_address>
</V4>
<V5>
<type>DInt</type>
<comment>PIECES_KO_3</comment>
<offset>1700</offset>
<plc_address>DBD1700</plc_address>
<offset>1596</offset>
<plc_address>DBD1596</plc_address>
</V5>
<V6>
<type>DInt</type>
<comment>PIECES_KO_4</comment>
<offset>1704</offset>
<plc_address>DBD1704</plc_address>
<offset>1600</offset>
<plc_address>DBD1600</plc_address>
</V6>
<V7>
<type>DInt</type>
<comment>PIECES_KO_5</comment>
<offset>1708</offset>
<plc_address>DBD1708</plc_address>
<offset>1604</offset>
<plc_address>DBD1604</plc_address>
</V7>
<V8>
<type>DInt</type>
<comment>PIECES_KO_6</comment>
<offset>1712</offset>
<plc_address>DBD1712</plc_address>
<offset>1608</offset>
<plc_address>DBD1608</plc_address>
</V8>
<V9>
<type>DInt</type>
<comment>PIECES_KO_7</comment>
<offset>1716</offset>
<plc_address>DBD1716</plc_address>
<offset>1612</offset>
<plc_address>DBD1612</plc_address>
</V9>
<V10>
<type>DInt</type>
<comment>PIECES_KO_8</comment>
<offset>1720</offset>
<plc_address>DBD1720</plc_address>
<offset>1616</offset>
<plc_address>DBD1616</plc_address>
</V10>
<V11>
<type>DInt</type>
<comment>PIECES_KO_9</comment>
<offset>1724</offset>
<plc_address>DBD1724</plc_address>
<offset>1620</offset>
<plc_address>DBD1620</plc_address>
</V11>
<V12>
<type>DInt</type>
<comment>PIECES_KO_10</comment>
<offset>1728</offset>
<plc_address>DBD1728</plc_address>
<offset>1624</offset>
<plc_address>DBD1624</plc_address>
</V12>
<V13>
<type>DInt</type>
<comment>T_ALARM_HOURS</comment>
<offset>1732</offset>
<plc_address>DBD1732</plc_address>
<offset>1628</offset>
<plc_address>DBD1628</plc_address>
</V13>
<V14>
<type>DInt</type>
<comment>T_DRY_CYCLE_HOURS</comment>
<offset>1736</offset>
<plc_address>DBD1736</plc_address>
<offset>1632</offset>
<plc_address>DBD1632</plc_address>
</V14>
<V15>
<type>DInt</type>
<comment>T_POWERED_HOURS</comment>
<offset>1740</offset>
<plc_address>DBD1740</plc_address>
<offset>1636</offset>
<plc_address>DBD1636</plc_address>
</V15>
<V16>
<type>DInt</type>
<comment>T_PRODUCT_100_HOURS</comment>
<offset>1744</offset>
<plc_address>DBD1744</plc_address>
<offset>1640</offset>
<plc_address>DBD1640</plc_address>
</V16>
<V17>
<type>DInt</type>
<comment>T_PRODUCT_0_HOURS</comment>
<offset>1748</offset>
<plc_address>DBD1748</plc_address>
<offset>1644</offset>
<plc_address>DBD1644</plc_address>
</V17>
<V18>
<type>DInt</type>
<comment>T_STOP_HOURS</comment>
<offset>1752</offset>
<plc_address>DBD1752</plc_address>
<offset>1648</offset>
<plc_address>DBD1648</plc_address>
</V18>
<V19>
<type>Int</type>
<comment>T_ALARM_MINUTES</comment>
<offset>1756</offset>
<plc_address>DBW1756</plc_address>
<offset>1652</offset>
<plc_address>DBW1652</plc_address>
</V19>
<V20>
<type>Int</type>
<comment>T_DRY_CYCLE_MINUTES</comment>
<offset>1758</offset>
<plc_address>DBW1758</plc_address>
<offset>1654</offset>
<plc_address>DBW1654</plc_address>
</V20>
<V21>
<type>Int</type>
<comment>T_POWERED_MINUTES</comment>
<offset>1760</offset>
<plc_address>DBW1760</plc_address>
<offset>1656</offset>
<plc_address>DBW1656</plc_address>
</V21>
<V22>
<type>Int</type>
<comment>T_PRODUCT_100_MINUTES</comment>
<offset>1762</offset>
<plc_address>DBW1762</plc_address>
<offset>1658</offset>
<plc_address>DBW1658</plc_address>
</V22>
<V23>
<type>Int</type>
<comment>T_PRODUCT_0_MINUTES</comment>
<offset>1764</offset>
<plc_address>DBW1764</plc_address>
<offset>1660</offset>
<plc_address>DBW1660</plc_address>
</V23>
<V24>
<type>Int</type>
<comment>T_STOP_MINUTES</comment>
<offset>1766</offset>
<plc_address>DBW1766</plc_address>
<offset>1662</offset>
<plc_address>DBW1662</plc_address>
</V24>
</N7>
</Struct>

View File

@ -158,11 +158,6 @@ if __name__ == "__main__":
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

View File

@ -1,6 +1,15 @@
import re
import json
import pandas as pd
import pprint
from copy import deepcopy
def debug_print_db_struct(db_struct):
pprint.pprint(
db_struct, width=80, indent=2
) # Ajusta el parámetro 'width' según necesidad
def expand_udt_references(db_struct, udts):
"""
@ -17,11 +26,9 @@ def expand_udt_references(db_struct, udts):
'"'
) # 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}' ")
# Replace the UDT reference with its deeply copied definition
db_struct["fields"] = deepcopy(udts[type_name])
print(f"Expanded UDT '{type_name}' at field '{key}'")
elif isinstance(db_struct, list):
for item in db_struct:
expand_udt_references(item, udts)
@ -38,21 +45,27 @@ def handle_array_types(db_struct):
# Recursively process nested dictionaries
handle_array_types(value)
if isinstance(value, dict) and 'type' in value:
match = re.match(r"Array\[(\d+)\.\.(\d+)\] of (\w+)", value['type'])
if isinstance(value, dict) and "type" in value:
match = re.match(r"Array\[(\d+)\.\.(\d+)\] of (\w+)", value["type"])
if match:
lower_bound, upper_bound, base_type = int(match.group(1)), int(match.group(2)), match.group(3)
comment = value.get('comment', '')
lower_bound, upper_bound, base_type = (
int(match.group(1)),
int(match.group(2)),
match.group(3),
)
comment = value.get("comment", "")
# Instead of popping the original key, initialize a sub-dictionary
value['Array'] = {} # Initialize a sub-dictionary for array elements
value["Array"] = (
{}
) # Initialize a sub-dictionary for array elements
for i in range(lower_bound, upper_bound + 1):
element_key = f"[{i}]"
value['Array'][element_key] = {
'type': base_type,
'comment': comment,
'is_array_element': True
value["Array"][element_key] = {
"type": base_type,
"comment": comment,
"is_array_element": True,
}
# Optionally, modify or remove the original type designation if necessary
@ -63,9 +76,6 @@ def handle_array_types(db_struct):
handle_array_types(value)
type_sizes = {
"Int": 2,
"DInt": 4,
@ -80,9 +90,7 @@ def calculate_plc_address(type_name, byte_offset, bit_offset=None):
"""
Calculate the PLC address notation based on byte size, byte offset and bit offset.
"""
byte_size = type_sizes.get(
type_name, 0
)
byte_size = type_sizes.get(type_name, 0)
if type_name == "Bool":
if bit_offset is not None:
return f"DBX{byte_offset}.{bit_offset}" # Address for single bits
@ -95,63 +103,74 @@ def calculate_plc_address(type_name, byte_offset, bit_offset=None):
return f"DBX{byte_offset}.0" # Default to bit address for types longer than 4 bytes (e.g., strings)
def calculate_offsets(db_struct, current_offset=0, parent=None):
def calculate_offsets(db_struct, current_offset=0):
"""
Recursively calculate byte offsets for each field in the DB structure considering special types.
"""
is_array_element = False
last_key_was_bool = False
last_bit_offset = 0 # To track bit offsets within a byte
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
for key, value in db_struct.items():
# Skip 'fields' and 'Struct' keys in the name path
#
if (
isinstance(value, dict) and "type" in value
): # Directly a field with 'type'
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
last_bit_offset = 0
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
)
last_bit_offset = 0
plc_address = value.get('plc_address', False)
if plc_address is not False:
print("Address Already Calcolated!")
plc_address = calculate_plc_address(
type_name, current_offset, last_bit_offset
)
plc_address = calculate_plc_address(type_name, current_offset, last_bit_offset)
# Special handling for String types
if "String" in type_name:
match = re.match(r"String\[(\d+)\]", type_name)
last_bit_offset = 0
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
last_bit_offset += 1 # One bit per Bool if grouped
else:
size = 2 # Bools use a full byte if not grouped
last_bit_offset = 0
last_key_was_bool = True
# Special handling for String types
if "String" in type_name:
match = re.match(r"String\[(\d+)\]", type_name)
last_bit_offset = 0
if match:
length = int(match.group(1))
size = (
length + 2
) # Account for null-termination and string length prefix
else:
last_key_was_bool = False
size = type_sizes.get(
type_name, 1
) # Default to generic size if not an array
value["offset"] = current_offset
value['plc_address'] = plc_address # Store the calculated PLC address
current_offset += size
# Adjusting Bool sizes based on grouping
if type_name == "Bool":
if last_key_was_bool: # This is a grouped bool
last_bit_offset += 1 # One bit per Bool if grouped
else:
size = 2 # Bools use a full byte if not grouped
last_bit_offset = 0
last_key_was_bool = True
else:
last_key_was_bool = False
current_offset = calculate_offsets(
value, current_offset, value
) # Recurse into nested structs
value["offset"] = current_offset
value["plc_address"] = plc_address # Store the calculated PLC address
print(f"Offset '{current_offset}' at field '{key}' ")
current_offset += size
# Recursively handle nested dictionaries and lists
if isinstance(value, dict) or isinstance(value, list):
current_offset = calculate_offsets(value, current_offset)
elif isinstance(db_struct, list):
for item in db_struct:
current_offset = calculate_offsets(item, current_offset, parent)
for index, item in enumerate(db_struct):
for item in db_struct:
current_offset = calculate_offsets(item, current_offset)
return current_offset
@ -164,4 +183,5 @@ def expand_dbs(udts, dbs):
expand_udt_references(db_content, udts)
handle_array_types(db_content)
calculate_offsets(db_content)
debug_print_db_struct(db_content)
print(f"Completed expansion for DB: {db_name}")

Binary file not shown.