Intento de copiar SCL desde XML parcialmente

This commit is contained in:
Miguel 2025-04-19 03:23:14 +02:00
parent 4a30e6d9fd
commit 2d9fd4e80a
9 changed files with 4056 additions and 860 deletions

View File

@ -60,7 +60,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "1A",
@ -80,7 +81,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "2B",
@ -147,7 +149,8 @@
]
}
}
]
],
"language": "LAD"
},
{
"id": "3C",
@ -217,7 +220,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "4D",
@ -448,7 +452,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "5E",
@ -464,15 +469,15 @@
},
"negated_pins": {},
"inputs": {
"en": {
"type": "powerrail"
},
"in": {
"uid": "21",
"scope": "LiteralConstant",
"type": "constant",
"datatype": "Int",
"value": 0
},
"en": {
"type": "powerrail"
}
},
"outputs": {
@ -486,7 +491,8 @@
]
}
}
]
],
"language": "LAD"
},
{
"id": "6F",
@ -519,6 +525,12 @@
"template_values": {},
"negated_pins": {},
"inputs": {
"s": {
"type": "connection",
"source_instruction_type": "Contact",
"source_instruction_uid": "24",
"source_pin": "out"
},
"tv": {
"uid": "23",
"scope": "TypedConstant",
@ -526,12 +538,6 @@
"datatype": "TypedConstant",
"value": "S5T#2S"
},
"s": {
"type": "connection",
"source_instruction_type": "Contact",
"source_instruction_uid": "24",
"source_pin": "out"
},
"en": {
"type": "connection",
"source_instruction_uid": "24",
@ -541,7 +547,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "80",
@ -589,7 +596,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "91",
@ -648,18 +656,18 @@
},
"negated_pins": {},
"inputs": {
"en": {
"type": "connection",
"source_instruction_type": "Contact",
"source_instruction_uid": "25",
"source_pin": "out"
},
"in": {
"uid": "23",
"scope": "LiteralConstant",
"type": "constant",
"datatype": "Int",
"value": 19
},
"en": {
"type": "connection",
"source_instruction_type": "Contact",
"source_instruction_uid": "25",
"source_pin": "out"
}
},
"outputs": {
@ -673,7 +681,8 @@
]
}
}
]
],
"language": "LAD"
},
{
"id": "A2",
@ -789,7 +798,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "B3",
@ -839,7 +849,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "C4",
@ -1000,7 +1011,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "D5",
@ -1116,7 +1128,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "E6",
@ -1348,7 +1361,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "F7",
@ -1381,6 +1395,12 @@
"template_values": {},
"negated_pins": {},
"inputs": {
"s": {
"type": "connection",
"source_instruction_type": "Contact",
"source_instruction_uid": "25",
"source_pin": "out"
},
"tv": {
"uid": "22",
"scope": "TypedConstant",
@ -1388,12 +1408,6 @@
"datatype": "TypedConstant",
"value": "S5T#1S"
},
"s": {
"type": "connection",
"source_instruction_type": "Contact",
"source_instruction_uid": "25",
"source_pin": "out"
},
"en": {
"type": "connection",
"source_instruction_uid": "25",
@ -1425,7 +1439,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "108",
@ -1498,7 +1513,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "119",
@ -1571,7 +1587,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "12A",
@ -1613,7 +1630,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "13B",
@ -1686,7 +1704,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "14C",
@ -1706,7 +1725,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "15D",
@ -1728,7 +1748,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "16E",
@ -1748,7 +1769,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "17F",
@ -1790,7 +1812,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "190",
@ -1810,7 +1833,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "1A1",
@ -1904,7 +1928,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "1B2",
@ -2013,7 +2038,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "1C3",
@ -2107,7 +2133,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "1D4",
@ -2201,7 +2228,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "1E5",
@ -2243,7 +2271,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "1F6",
@ -2263,7 +2292,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "207",
@ -2283,7 +2313,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "218",
@ -2303,7 +2334,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "229",
@ -2323,7 +2355,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "23A",
@ -2345,7 +2378,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "24B",
@ -2365,7 +2399,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "25C",
@ -2385,7 +2420,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "26D",
@ -2405,7 +2441,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "27E",
@ -2425,7 +2462,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "28F",
@ -2445,7 +2483,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "2A0",
@ -2465,7 +2504,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "2B1",
@ -2511,7 +2551,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "2C2",
@ -2531,7 +2572,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "2D3",
@ -2551,7 +2593,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "2E4",
@ -2593,7 +2636,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "2F5",
@ -2613,7 +2657,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "306",
@ -2633,7 +2678,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "317",
@ -2653,7 +2699,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "328",
@ -2673,7 +2720,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "339",
@ -2693,7 +2741,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "34A",
@ -2726,6 +2775,12 @@
"template_values": {},
"negated_pins": {},
"inputs": {
"s": {
"type": "connection",
"source_instruction_type": "Contact",
"source_instruction_uid": "24",
"source_pin": "out"
},
"tv": {
"uid": "22",
"scope": "TypedConstant",
@ -2733,12 +2788,6 @@
"datatype": "TypedConstant",
"value": "S5T#2S"
},
"s": {
"type": "connection",
"source_instruction_type": "Contact",
"source_instruction_uid": "24",
"source_pin": "out"
},
"en": {
"type": "connection",
"source_instruction_uid": "24",
@ -2748,7 +2797,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "35B",
@ -2824,6 +2874,12 @@
"template_values": {},
"negated_pins": {},
"inputs": {
"s": {
"type": "connection",
"source_instruction_type": "O",
"source_instruction_uid": "28",
"source_pin": "out"
},
"tv": {
"uid": "24",
"scope": "TypedConstant",
@ -2831,12 +2887,6 @@
"datatype": "TypedConstant",
"value": "S5T#2S"
},
"s": {
"type": "connection",
"source_instruction_type": "O",
"source_instruction_uid": "28",
"source_pin": "out"
},
"en": {
"type": "connection",
"source_instruction_uid": "28",
@ -2868,7 +2918,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "36C",
@ -2916,7 +2967,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "37D",
@ -2992,6 +3044,12 @@
"template_values": {},
"negated_pins": {},
"inputs": {
"s": {
"type": "connection",
"source_instruction_type": "O",
"source_instruction_uid": "29",
"source_pin": "out"
},
"tv": {
"uid": "24",
"scope": "TypedConstant",
@ -2999,12 +3057,6 @@
"datatype": "TypedConstant",
"value": "S5T#2S"
},
"s": {
"type": "connection",
"source_instruction_type": "O",
"source_instruction_uid": "29",
"source_pin": "out"
},
"en": {
"type": "connection",
"source_instruction_uid": "29",
@ -3058,7 +3110,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "38E",
@ -3106,7 +3159,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "39F",
@ -3182,6 +3236,12 @@
"template_values": {},
"negated_pins": {},
"inputs": {
"s": {
"type": "connection",
"source_instruction_type": "O",
"source_instruction_uid": "28",
"source_pin": "out"
},
"tv": {
"uid": "24",
"scope": "TypedConstant",
@ -3189,12 +3249,6 @@
"datatype": "TypedConstant",
"value": "S5T#2S"
},
"s": {
"type": "connection",
"source_instruction_type": "O",
"source_instruction_uid": "28",
"source_pin": "out"
},
"en": {
"type": "connection",
"source_instruction_uid": "28",
@ -3226,7 +3280,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "3B0",
@ -3274,7 +3329,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "3C1",
@ -3350,6 +3406,12 @@
"template_values": {},
"negated_pins": {},
"inputs": {
"s": {
"type": "connection",
"source_instruction_type": "O",
"source_instruction_uid": "28",
"source_pin": "out"
},
"tv": {
"uid": "24",
"scope": "TypedConstant",
@ -3357,12 +3419,6 @@
"datatype": "TypedConstant",
"value": "S5T#2S"
},
"s": {
"type": "connection",
"source_instruction_type": "O",
"source_instruction_uid": "28",
"source_pin": "out"
},
"en": {
"type": "connection",
"source_instruction_uid": "28",
@ -3394,7 +3450,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "3D2",
@ -3442,7 +3499,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "3E3",
@ -3490,7 +3548,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "3F4",
@ -3534,7 +3593,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "405",
@ -3554,7 +3614,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "416",
@ -3574,7 +3635,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "427",
@ -3594,7 +3656,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "438",
@ -3702,7 +3765,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "449",
@ -3722,7 +3786,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "45A",
@ -3964,7 +4029,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "46B",
@ -4008,7 +4074,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "47C",
@ -4028,7 +4095,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
}
]
}

View File

@ -61,7 +61,8 @@
"outputs": {},
"scl": "Clock_Signal();"
}
]
],
"language": "LAD"
},
{
"id": "1A",
@ -82,7 +83,8 @@
"outputs": {},
"scl": "BlenderCtrl_MachineInit();"
}
]
],
"language": "LAD"
},
{
"id": "2B",
@ -151,7 +153,8 @@
},
"scl": "IF \"AUX FALSE\" THEN\n \"Block_Move_Err\" := BLKMOV(SRCBLK := \"HMI_PID\".\"PPM303\", DSTBLK => \"Filler_Head_Variables\".\"FillerHead\"); // ADVERTENCIA: BLKMOV usado directamente, probablemente no compile!\nEND_IF;"
}
]
],
"language": "LAD"
},
{
"id": "3C",
@ -225,7 +228,8 @@
"outputs": {},
"scl": "\"gEmergencyPressed\" := NOT \"gIN_VoltageOk\" AND \"M19000\";\n\"M19000\" := \"gIN_VoltageOk\"; // N_TRIG(\"gIN_VoltageOk\")"
}
]
],
"language": "LAD"
},
{
"id": "4D",
@ -466,7 +470,8 @@
"outputs": {},
"scl": "\"gBlenderSuppliesOk\" := ((\"gIN_LinePressCO2Ok\" OR (\"gWorkshopTest\" AND (NOT \"gWorkshop_Co2_Presence\")) AND (NOT \"gWorkshop_CIP_Signals\")) AND \"HMI_Digital\".\"_PAL_S11\".\"Filtered\") OR (\"gIN_LinePressCO2Ok\" OR (\"gWorkshopTest\" AND (NOT \"gWorkshop_Co2_Presence\")) AND (NOT \"gWorkshop_CIP_Signals\")) AND (NOT \"Disable_Bit\") AND \"gIN_VoltageOk\";"
}
]
],
"language": "LAD"
},
{
"id": "5E",
@ -482,15 +487,15 @@
},
"negated_pins": {},
"inputs": {
"en": {
"type": "powerrail"
},
"in": {
"uid": "21",
"scope": "LiteralConstant",
"type": "constant",
"datatype": "Int",
"value": 0
},
"en": {
"type": "powerrail"
}
},
"outputs": {
@ -505,7 +510,8 @@
},
"scl": "\"HMI_Variables_Status\".\"Procedures\".\"BlenderStateNum\" := 0;"
}
]
],
"language": "LAD"
},
{
"id": "6F",
@ -539,6 +545,12 @@
"template_values": {},
"negated_pins": {},
"inputs": {
"s": {
"type": "connection",
"source_instruction_type": "Contact",
"source_instruction_uid": "24",
"source_pin": "out"
},
"tv": {
"uid": "23",
"scope": "TypedConstant",
@ -546,12 +558,6 @@
"datatype": "TypedConstant",
"value": "S5T#2S"
},
"s": {
"type": "connection",
"source_instruction_type": "Contact",
"source_instruction_uid": "24",
"source_pin": "out"
},
"en": {
"type": "connection",
"source_instruction_uid": "24",
@ -561,7 +567,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "80",
@ -611,7 +618,8 @@
"outputs": {},
"scl": "\"gBlenderProdMode\" := \"HMI_Variables_Status\".\"System\".\"Blender_Prod_CIP\";"
}
]
],
"language": "LAD"
},
{
"id": "91",
@ -672,18 +680,18 @@
},
"negated_pins": {},
"inputs": {
"en": {
"type": "connection",
"source_instruction_type": "Contact",
"source_instruction_uid": "25",
"source_pin": "out"
},
"in": {
"uid": "23",
"scope": "LiteralConstant",
"type": "constant",
"datatype": "Int",
"value": 19
},
"en": {
"type": "connection",
"source_instruction_type": "Contact",
"source_instruction_uid": "25",
"source_pin": "out"
}
},
"outputs": {
@ -698,7 +706,8 @@
},
"scl": "IF (NOT \"HMI_Variables_Status\".\"System\".\"Blender_Prod_CIP\") THEN\n \"HMI_Variables_Status\".\"Procedures\".\"BlenderStateNum\" := 19;\nEND_IF;"
}
]
],
"language": "LAD"
},
{
"id": "A2",
@ -730,7 +739,7 @@
{
"instruction_uid": "27",
"uid": "27",
"type": "RCoil",
"type": "RCoil_scl",
"template_values": {},
"negated_pins": {},
"inputs": {
@ -747,12 +756,13 @@
"name": "\"HMI_Variables_Status\".\"Meters\".\"QTM3012_PRD_Fault\""
}
},
"outputs": {}
"outputs": {},
"scl": "IF (NOT \"AUX FALSE\") THEN\n \"HMI_Variables_Status\".\"Meters\".\"QTM3012_PRD_Fault\" := FALSE;\nEND_IF;"
},
{
"instruction_uid": "28",
"uid": "28",
"type": "RCoil",
"type": "RCoil_scl",
"template_values": {},
"negated_pins": {},
"inputs": {
@ -769,12 +779,13 @@
"name": "\"gmPDS2000_Error_Fault\""
}
},
"outputs": {}
"outputs": {},
"scl": "IF (NOT \"AUX FALSE\") THEN\n \"gmPDS2000_Error_Fault\" := FALSE;\nEND_IF;"
},
{
"instruction_uid": "29",
"uid": "29",
"type": "RCoil",
"type": "RCoil_scl",
"template_values": {},
"negated_pins": {},
"inputs": {
@ -791,12 +802,13 @@
"name": "\"HMI_Variables_Status\".\"Meters\".\"QTM3012_PRD_Run\""
}
},
"outputs": {}
"outputs": {},
"scl": "IF (NOT \"AUX FALSE\") THEN\n \"HMI_Variables_Status\".\"Meters\".\"QTM3012_PRD_Run\" := FALSE;\nEND_IF;"
},
{
"instruction_uid": "30",
"uid": "30",
"type": "RCoil",
"type": "RCoil_scl",
"template_values": {},
"negated_pins": {},
"inputs": {
@ -813,9 +825,11 @@
"name": "\"gNoFreezeProductMeter\""
}
},
"outputs": {}
"outputs": {},
"scl": "IF (NOT \"AUX FALSE\") THEN\n \"gNoFreezeProductMeter\" := FALSE;\nEND_IF;"
}
]
],
"language": "LAD"
},
{
"id": "B3",
@ -867,7 +881,8 @@
"outputs": {},
"scl": "\"System_RunOut_Variables\".\"ProdPipeRunOutFillerBott\" := (NOT \"System_RunOut_Variables\".\"ProdPipeRunOutWaterCount\");"
}
]
],
"language": "LAD"
},
{
"id": "C4",
@ -1035,7 +1050,8 @@
"outputs": {},
"scl": "\"gStillWaterByPassEn\" := ((\"HMI_Blender_Parameters\".\"Processor_Options\".\"Blender_OPT\".\"_StillWaterByPass\" OR (\"HMI_Blender_Parameters\".\"Processor_Options\".\"Blender_OPT\".\"_ByPassDeair\" AND (NOT \"HMI_Blender_Parameters\".\"Processor_Options\".\"Blender_OPT\".\"_Deaireation\"))) AND \"Blender_Variables_Pers\".\"gWaterRecipe\") AND (NOT \"Blender_Variables_Pers\".\"gCarboStillRecipe\");"
}
]
],
"language": "LAD"
},
{
"id": "D5",
@ -1156,7 +1172,8 @@
"outputs": {},
"scl": "\"gBlendFiStillWaterByPass\" := ((\"HMI_Blender_Parameters\".\"Processor_Options\".\"Blender_OPT\".\"_BlendFillSystem\" AND \"HMI_Blender_Parameters\".\"Processor_Options\".\"Blender_OPT\".\"_StillWaterByPass\") AND \"Blender_Variables_Pers\".\"gWaterRecipe\") AND (NOT \"Blender_Variables_Pers\".\"gCarboStillRecipe\");"
}
]
],
"language": "LAD"
},
{
"id": "E6",
@ -1398,7 +1415,8 @@
"outputs": {},
"scl": "\"gHVP301_Open\" := ((\"gSyrupRoomEn\" AND (NOT \"gIN_HVP301_Aux\")) AND (NOT \"HMI_Blender_Parameters\".\"Processor_Options\".\"Blender_OPT\".\"_FastChangeOverEnabled\") AND \"Procedure_Variables\".\"FTP302Line_Preparation\".\"Done\") AND (NOT \"Procedure_Variables\".\"Syr_RunOut\".\"Done\") OR ((((\"gSyrupRoomEn\" AND (NOT \"gIN_HVP301_Aux\")) AND \"gBlenderCIPMode\") AND \"gIN_CIP_CIPRunning\") AND \"Procedure_Variables\".\"Blender_Run\".\"Running\");"
}
]
],
"language": "LAD"
},
{
"id": "F7",
@ -1432,6 +1450,12 @@
"template_values": {},
"negated_pins": {},
"inputs": {
"s": {
"type": "connection",
"source_instruction_type": "Contact",
"source_instruction_uid": "25",
"source_pin": "out"
},
"tv": {
"uid": "22",
"scope": "TypedConstant",
@ -1439,12 +1463,6 @@
"datatype": "TypedConstant",
"value": "S5T#1S"
},
"s": {
"type": "connection",
"source_instruction_type": "Contact",
"source_instruction_uid": "25",
"source_pin": "out"
},
"en": {
"type": "connection",
"source_instruction_uid": "25",
@ -1476,7 +1494,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "108",
@ -1552,7 +1571,8 @@
"outputs": {},
"scl": "IF \"HMI_Blender_Parameters\".\"Processor_Options\".\"Blender_OPT\".\"_MeterType\" = 6 THEN\n Maselli_PA_Control();\nEND_IF;"
}
]
],
"language": "LAD"
},
{
"id": "119",
@ -1628,7 +1648,8 @@
"outputs": {},
"scl": "IF \"HMI_Blender_Parameters\".\"Processor_Options\".\"Blender_OPT\".\"_MeterType\" = 5 THEN\n mPDS_PA_Control();\nEND_IF;"
}
]
],
"language": "LAD"
},
{
"id": "12A",
@ -1672,7 +1693,8 @@
"outputs": {},
"scl": "IF \"HMI_Blender_Parameters\".\"Processor_Options\".\"Blender_OPT\".\"_SyrBrixMeter\" THEN\n mPDS_SYR_PA_Control();\nEND_IF;"
}
]
],
"language": "LAD"
},
{
"id": "13B",
@ -1748,7 +1770,8 @@
"outputs": {},
"scl": "IF \"HMI_Blender_Parameters\".\"Processor_Options\".\"Blender_OPT\".\"_MeterType\" = 3 THEN\n GetProdBrixCO2_Anal_Inpt();\nEND_IF;"
}
]
],
"language": "LAD"
},
{
"id": "14C",
@ -1769,7 +1792,8 @@
"outputs": {},
"scl": "ProductQuality();"
}
]
],
"language": "LAD"
},
{
"id": "15D",
@ -1792,7 +1816,8 @@
"outputs": {},
"scl": "\"Input_Data\"();"
}
]
],
"language": "LAD"
},
{
"id": "16E",
@ -1813,7 +1838,8 @@
"outputs": {},
"scl": "SelCheckBrixSource();"
}
]
],
"language": "LAD"
},
{
"id": "17F",
@ -1857,7 +1883,8 @@
"outputs": {},
"scl": "IF \"HMI_Blender_Parameters\".\"Processor_Options\".\"Blender_OPT\".\"_InverterRecirPumpPPM306\" THEN\n CTRLCoolingSystem();\nEND_IF;"
}
]
],
"language": "LAD"
},
{
"id": "190",
@ -1878,7 +1905,8 @@
"outputs": {},
"scl": "TankLevel();"
}
]
],
"language": "LAD"
},
{
"id": "1A1",
@ -1977,7 +2005,8 @@
"outputs": {},
"scl": "\"gProductionONS\" := (\"gBlenderProdMode\" AND NOT \"M19001\") AND (NOT \"mDelayPowerOnTmr\");"
}
]
],
"language": "LAD"
},
{
"id": "1B2",
@ -2091,7 +2120,8 @@
"outputs": {},
"scl": "IF (\"gProductionONS\" OR \"Procedure_Variables\".\"Blender_Rinse\".\"ONS_Done\") AND (NOT \"Blender_Variables_Pers\".\"gBlenderStarted\") THEN\n BlenderCtrl_ProdModeInit();\nEND_IF;"
}
]
],
"language": "LAD"
},
{
"id": "1C3",
@ -2190,7 +2220,8 @@
"outputs": {},
"scl": "\"gRinseONS\" := (\"HMI_Variables_Status\".\"System\".\"Blender_Prod_CIP\" AND NOT \"M19002\") AND (NOT \"mDelayPowerOnTmr\");"
}
]
],
"language": "LAD"
},
{
"id": "1D4",
@ -2289,7 +2320,8 @@
"outputs": {},
"scl": "\"gCIPONS\" := (\"gBlenderCIPMode\" AND NOT \"M19003\") AND (NOT \"mDelayPowerOnTmr\");"
}
]
],
"language": "LAD"
},
{
"id": "1E5",
@ -2333,7 +2365,8 @@
"outputs": {},
"scl": "IF \"gCIPONS\" THEN\n BlenderCtrl_CIPModeInit();\nEND_IF;"
}
]
],
"language": "LAD"
},
{
"id": "1F6",
@ -2354,7 +2387,8 @@
"outputs": {},
"scl": "BlenderCtrl_ResetSPWord();"
}
]
],
"language": "LAD"
},
{
"id": "207",
@ -2375,7 +2409,8 @@
"outputs": {},
"scl": "BlenderRun__Control();"
}
]
],
"language": "LAD"
},
{
"id": "218",
@ -2396,7 +2431,8 @@
"outputs": {},
"scl": "Prod_Tank_PressCtrl();"
}
]
],
"language": "LAD"
},
{
"id": "229",
@ -2417,7 +2453,8 @@
"outputs": {},
"scl": "Baialage();"
}
]
],
"language": "LAD"
},
{
"id": "23A",
@ -2440,7 +2477,8 @@
"outputs": {},
"scl": "\"FirstProduction_Data\"();"
}
]
],
"language": "LAD"
},
{
"id": "24B",
@ -2461,7 +2499,8 @@
"outputs": {},
"scl": "CIPMain();"
}
]
],
"language": "LAD"
},
{
"id": "25C",
@ -2482,7 +2521,8 @@
"outputs": {},
"scl": "BlenderRinse();"
}
]
],
"language": "LAD"
},
{
"id": "26D",
@ -2503,7 +2543,8 @@
"outputs": {},
"scl": "Safeties();"
}
]
],
"language": "LAD"
},
{
"id": "27E",
@ -2524,7 +2565,8 @@
"outputs": {},
"scl": "Instrument_Scanner();"
}
]
],
"language": "LAD"
},
{
"id": "28F",
@ -2545,7 +2587,8 @@
"outputs": {},
"scl": "VacuumCtrl();"
}
]
],
"language": "LAD"
},
{
"id": "2A0",
@ -2566,7 +2609,8 @@
"outputs": {},
"scl": "SyrupRoomCtrl();"
}
]
],
"language": "LAD"
},
{
"id": "2B1",
@ -2614,7 +2658,8 @@
"outputs": {},
"scl": "IF (NOT \"mDelayPowerOnTmr\") THEN\n \"Blender_Procedure Data\"();\nEND_IF;"
}
]
],
"language": "LAD"
},
{
"id": "2C2",
@ -2635,7 +2680,8 @@
"outputs": {},
"scl": "Pneumatic_Valve_Ctrl();"
}
]
],
"language": "LAD"
},
{
"id": "2D3",
@ -2656,7 +2702,8 @@
"outputs": {},
"scl": "PumpsControl();"
}
]
],
"language": "LAD"
},
{
"id": "2E4",
@ -2700,7 +2747,8 @@
"outputs": {},
"scl": "IF \"HMI_Blender_Parameters\".\"Processor_Options\".\"Blender_OPT\".\"_Report\" THEN\n ProdReportManager();\nEND_IF;"
}
]
],
"language": "LAD"
},
{
"id": "2F5",
@ -2721,7 +2769,8 @@
"outputs": {},
"scl": "Output();"
}
]
],
"language": "LAD"
},
{
"id": "306",
@ -2742,7 +2791,8 @@
"outputs": {},
"scl": "SLIM_Block();"
}
]
],
"language": "LAD"
},
{
"id": "317",
@ -2763,7 +2813,8 @@
"outputs": {},
"scl": "Interlocking_Panel_1();"
}
]
],
"language": "LAD"
},
{
"id": "328",
@ -2784,7 +2835,8 @@
"outputs": {},
"scl": "FillerControl();"
}
]
],
"language": "LAD"
},
{
"id": "339",
@ -2805,7 +2857,8 @@
"outputs": {},
"scl": "BlenderCtrl_UpdatePWord();"
}
]
],
"language": "LAD"
},
{
"id": "34A",
@ -2839,6 +2892,12 @@
"template_values": {},
"negated_pins": {},
"inputs": {
"s": {
"type": "connection",
"source_instruction_type": "Contact",
"source_instruction_uid": "24",
"source_pin": "out"
},
"tv": {
"uid": "22",
"scope": "TypedConstant",
@ -2846,12 +2905,6 @@
"datatype": "TypedConstant",
"value": "S5T#2S"
},
"s": {
"type": "connection",
"source_instruction_type": "Contact",
"source_instruction_uid": "24",
"source_pin": "out"
},
"en": {
"type": "connection",
"source_instruction_uid": "24",
@ -2861,7 +2914,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "35B",
@ -2940,6 +2994,12 @@
"template_values": {},
"negated_pins": {},
"inputs": {
"s": {
"type": "connection",
"source_instruction_type": "O",
"source_instruction_uid": "28",
"source_pin": "out"
},
"tv": {
"uid": "24",
"scope": "TypedConstant",
@ -2947,12 +3007,6 @@
"datatype": "TypedConstant",
"value": "S5T#2S"
},
"s": {
"type": "connection",
"source_instruction_type": "O",
"source_instruction_uid": "28",
"source_pin": "out"
},
"en": {
"type": "connection",
"source_instruction_uid": "28",
@ -2984,7 +3038,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "36C",
@ -3014,7 +3069,7 @@
{
"instruction_uid": "24",
"uid": "24",
"type": "RCoil",
"type": "RCoil_scl",
"template_values": {},
"negated_pins": {},
"inputs": {
@ -3031,9 +3086,11 @@
"name": "\"gFTN301_ResetTot\""
}
},
"outputs": {}
"outputs": {},
"scl": "IF \"gFTN301_ResetTot\" THEN\n \"gFTN301_ResetTot\" := FALSE;\nEND_IF;"
}
]
],
"language": "LAD"
},
{
"id": "37D",
@ -3112,6 +3169,12 @@
"template_values": {},
"negated_pins": {},
"inputs": {
"s": {
"type": "connection",
"source_instruction_type": "O",
"source_instruction_uid": "29",
"source_pin": "out"
},
"tv": {
"uid": "24",
"scope": "TypedConstant",
@ -3119,12 +3182,6 @@
"datatype": "TypedConstant",
"value": "S5T#2S"
},
"s": {
"type": "connection",
"source_instruction_type": "O",
"source_instruction_uid": "29",
"source_pin": "out"
},
"en": {
"type": "connection",
"source_instruction_uid": "29",
@ -3178,7 +3235,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "38E",
@ -3208,7 +3266,7 @@
{
"instruction_uid": "24",
"uid": "24",
"type": "RCoil",
"type": "RCoil_scl",
"template_values": {},
"negated_pins": {},
"inputs": {
@ -3225,9 +3283,11 @@
"name": "\"gFTP302_ResetTot\""
}
},
"outputs": {}
"outputs": {},
"scl": "IF \"gFTP302_ResetTot\" THEN\n \"gFTP302_ResetTot\" := FALSE;\nEND_IF;"
}
]
],
"language": "LAD"
},
{
"id": "39F",
@ -3306,6 +3366,12 @@
"template_values": {},
"negated_pins": {},
"inputs": {
"s": {
"type": "connection",
"source_instruction_type": "O",
"source_instruction_uid": "28",
"source_pin": "out"
},
"tv": {
"uid": "24",
"scope": "TypedConstant",
@ -3313,12 +3379,6 @@
"datatype": "TypedConstant",
"value": "S5T#2S"
},
"s": {
"type": "connection",
"source_instruction_type": "O",
"source_instruction_uid": "28",
"source_pin": "out"
},
"en": {
"type": "connection",
"source_instruction_uid": "28",
@ -3350,7 +3410,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "3B0",
@ -3380,7 +3441,7 @@
{
"instruction_uid": "24",
"uid": "24",
"type": "RCoil",
"type": "RCoil_scl",
"template_values": {},
"negated_pins": {},
"inputs": {
@ -3397,9 +3458,11 @@
"name": "\"gFTM303_ResetTot\""
}
},
"outputs": {}
"outputs": {},
"scl": "IF \"gFTM303_ResetTot\" THEN\n \"gFTM303_ResetTot\" := FALSE;\nEND_IF;"
}
]
],
"language": "LAD"
},
{
"id": "3C1",
@ -3478,6 +3541,12 @@
"template_values": {},
"negated_pins": {},
"inputs": {
"s": {
"type": "connection",
"source_instruction_type": "O",
"source_instruction_uid": "28",
"source_pin": "out"
},
"tv": {
"uid": "24",
"scope": "TypedConstant",
@ -3485,12 +3554,6 @@
"datatype": "TypedConstant",
"value": "S5T#2S"
},
"s": {
"type": "connection",
"source_instruction_type": "O",
"source_instruction_uid": "28",
"source_pin": "out"
},
"en": {
"type": "connection",
"source_instruction_uid": "28",
@ -3522,7 +3585,8 @@
},
"outputs": {}
}
]
],
"language": "LAD"
},
{
"id": "3D2",
@ -3552,7 +3616,7 @@
{
"instruction_uid": "24",
"uid": "24",
"type": "RCoil",
"type": "RCoil_scl",
"template_values": {},
"negated_pins": {},
"inputs": {
@ -3569,9 +3633,11 @@
"name": "\"gProductMFMResetTot\""
}
},
"outputs": {}
"outputs": {},
"scl": "IF \"gProductMFMResetTot\" THEN\n \"gProductMFMResetTot\" := FALSE;\nEND_IF;"
}
]
],
"language": "LAD"
},
{
"id": "3E3",
@ -3601,7 +3667,7 @@
{
"instruction_uid": "24",
"uid": "24",
"type": "RCoil",
"type": "RCoil_scl",
"template_values": {},
"negated_pins": {},
"inputs": {
@ -3618,9 +3684,11 @@
"name": "\"gBlendResetTotalizer\""
}
},
"outputs": {}
"outputs": {},
"scl": "IF \"gBlendResetTotalizer\" THEN\n \"gBlendResetTotalizer\" := FALSE;\nEND_IF;"
}
]
],
"language": "LAD"
},
{
"id": "3F4",
@ -3666,7 +3734,8 @@
"outputs": {},
"scl": "IF (NOT \"HMI_Blender_Parameters\".\"Processor_Options\".\"Blender_OPT\".\"_Simulation\") THEN\n BlenderCtrl_MFM_Command();\nEND_IF;"
}
]
],
"language": "LAD"
},
{
"id": "405",
@ -3687,7 +3756,8 @@
"outputs": {},
"scl": "CPU_DP_Global_Diag();"
}
]
],
"language": "LAD"
},
{
"id": "416",
@ -3708,7 +3778,8 @@
"outputs": {},
"scl": "Profibus_Network();"
}
]
],
"language": "LAD"
},
{
"id": "427",
@ -3729,7 +3800,8 @@
"outputs": {},
"scl": "ModValveFault();"
}
]
],
"language": "LAD"
},
{
"id": "438",
@ -3843,7 +3915,8 @@
"outputs": {},
"scl": "\"HMI_Variables_Cmd\".\"Commands_From_HMI\".\"F7_DeviceControl\".\"Light\" := \"HMI_Variables_Cmd\".\"Commands_From_HMI\".\"F7_DeviceControl\".\"Command\" AND \"HMI_Variables_Cmd\".\"Commands_From_HMI\".\"F7_DeviceControl\".\"Enable\";"
}
]
],
"language": "LAD"
},
{
"id": "449",
@ -3864,7 +3937,8 @@
"outputs": {},
"scl": "BlenderCtrl_ManualActive();"
}
]
],
"language": "LAD"
},
{
"id": "45A",
@ -4094,7 +4168,7 @@
{
"instruction_uid": "43",
"uid": "43",
"type": "SCoil",
"type": "SCoil_scl",
"template_values": {},
"negated_pins": {},
"inputs": {
@ -4111,9 +4185,11 @@
"name": "\"HMI_Variables_Cmd\".\"Recipe\".\"Edit\""
}
},
"outputs": {}
"outputs": {},
"scl": "IF \"mAux_FP_M700_1\" THEN\n \"HMI_Variables_Cmd\".\"Recipe\".\"Edit\" := TRUE;\nEND_IF;"
}
]
],
"language": "LAD"
},
{
"id": "46B",
@ -4159,7 +4235,8 @@
"outputs": {},
"scl": "IF \"AUX TRUE\" THEN\n \"RecipeManagement_Data\"();\nEND_IF;"
}
]
],
"language": "LAD"
},
{
"id": "47C",
@ -4180,7 +4257,8 @@
"outputs": {},
"scl": "RecipeCalculation();"
}
]
],
"language": "LAD"
}
]
}

View File

@ -27,374 +27,339 @@ END_VAR
BEGIN
// Network 1: Clock Generation
// Network 1: Clock Generation (Original Language: LAD)
Clock_Signal();
// Network 2: Machine Init
// Network 2: Machine Init (Original Language: LAD)
BlenderCtrl_MachineInit();
// Network 3: Filler Head
// Network 3: Filler Head (Original Language: LAD)
// RLO: "AUX FALSE"
IF "AUX FALSE" THEN
"Block_Move_Err" := BLKMOV(SRCBLK := "HMI_PID"."PPM303", DSTBLK => "Filler_Head_Variables"."FillerHead"); // ADVERTENCIA: BLKMOV usado directamente, probablemente no compile!
END_IF;
// Network 4: Emergency Pressed
// Network 4: Emergency Pressed (Original Language: LAD)
// RLO: "gIN_VoltageOk"
// Logic moved to Coil 26
"gEmergencyPressed" := NOT "gIN_VoltageOk" AND "M19000";
"M19000" := "gIN_VoltageOk"; // N_TRIG("gIN_VoltageOk")
// Network 5: Air and CO2 pressure ok and auxiliary ok
// Network 5: Air and CO2 pressure ok and auxiliary ok (Original Language: LAD)
// RLO: "gIN_LinePressCO2Ok"
// RLO: "gWorkshopTest"
// RLO: "gWorkshopTest" AND (NOT "gWorkshop_Co2_Presence")
// RLO: ("gWorkshopTest" AND (NOT "gWorkshop_Co2_Presence")) AND (NOT "gWorkshop_CIP_Signals")
// RLO: ("gIN_LinePressCO2Ok" OR ("gWorkshopTest" AND (NOT "gWorkshop_Co2_Presence")) AND (NOT "gWorkshop_CIP_Signals")) AND "HMI_Digital"."_PAL_S11"."Filtered"
// RLO: ("gIN_LinePressCO2Ok" OR ("gWorkshopTest" AND (NOT "gWorkshop_Co2_Presence")) AND (NOT "gWorkshop_CIP_Signals")) AND (NOT "Disable_Bit")
// RLO: (("gIN_LinePressCO2Ok" OR ("gWorkshopTest" AND (NOT "gWorkshop_Co2_Presence")) AND (NOT "gWorkshop_CIP_Signals")) AND "HMI_Digital"."_PAL_S11"."Filtered") OR ("gIN_LinePressCO2Ok" OR ("gWorkshopTest" AND (NOT "gWorkshop_Co2_Presence")) AND (NOT "gWorkshop_CIP_Signals")) AND (NOT "Disable_Bit") AND "gIN_VoltageOk"
"gBlenderSuppliesOk" := (("gIN_LinePressCO2Ok" OR ("gWorkshopTest" AND (NOT "gWorkshop_Co2_Presence")) AND (NOT "gWorkshop_CIP_Signals")) AND "HMI_Digital"."_PAL_S11"."Filtered") OR ("gIN_LinePressCO2Ok" OR ("gWorkshopTest" AND (NOT "gWorkshop_Co2_Presence")) AND (NOT "gWorkshop_CIP_Signals")) AND (NOT "Disable_Bit") AND "gIN_VoltageOk";
// Network 6: Blender State Num
// Network 6: Blender State Num (Original Language: LAD)
"HMI_Variables_Status"."Procedures"."BlenderStateNum" := 0;
// Network 7: Delay Power On
// Network 7: Delay Power On (Original Language: LAD)
// RLO: "FirstScan"
// Network did not produce printable SCL code.
// Network 8: Production Mode
// Network 8: Production Mode (Original Language: LAD)
// RLO: "HMI_Variables_Status"."System"."Blender_Prod_CIP"
"gBlenderProdMode" := "HMI_Variables_Status"."System"."Blender_Prod_CIP";
// Network 9: CIp Mode
// Network 9: CIp Mode (Original Language: LAD)
// RLO: (NOT "HMI_Variables_Status"."System"."Blender_Prod_CIP")
"gBlenderCIPMode" := (NOT "HMI_Variables_Status"."System"."Blender_Prod_CIP");
IF (NOT "HMI_Variables_Status"."System"."Blender_Prod_CIP") THEN
"HMI_Variables_Status"."Procedures"."BlenderStateNum" := 19;
END_IF;
// Network 10: Error Faults
// Network 10: Error Faults (Original Language: LAD)
// RLO: (NOT "AUX FALSE")
IF (NOT "AUX FALSE") THEN
"HMI_Variables_Status"."Meters"."QTM3012_PRD_Fault" := FALSE;
END_IF;
IF (NOT "AUX FALSE") THEN
"gmPDS2000_Error_Fault" := FALSE;
END_IF;
IF (NOT "AUX FALSE") THEN
"HMI_Variables_Status"."Meters"."QTM3012_PRD_Run" := FALSE;
END_IF;
IF (NOT "AUX FALSE") THEN
"gNoFreezeProductMeter" := FALSE;
END_IF;
// Network 11: Filler Bottle Count Used to push Product
// Network 11: Filler Bottle Count Used to push Product (Original Language: LAD)
// RLO: (NOT "System_RunOut_Variables"."ProdPipeRunOutWaterCount")
"System_RunOut_Variables"."ProdPipeRunOutFillerBott" := (NOT "System_RunOut_Variables"."ProdPipeRunOutWaterCount");
// Network 12: Water Bypass Enable
// Network 12: Water Bypass Enable (Original Language: LAD)
// RLO: "HMI_Blender_Parameters"."Processor_Options"."Blender_OPT"."_StillWaterByPass"
// RLO: "HMI_Blender_Parameters"."Processor_Options"."Blender_OPT"."_ByPassDeair"
// RLO: "HMI_Blender_Parameters"."Processor_Options"."Blender_OPT"."_ByPassDeair" AND (NOT "HMI_Blender_Parameters"."Processor_Options"."Blender_OPT"."_Deaireation")
// RLO: ("HMI_Blender_Parameters"."Processor_Options"."Blender_OPT"."_StillWaterByPass" OR ("HMI_Blender_Parameters"."Processor_Options"."Blender_OPT"."_ByPassDeair" AND (NOT "HMI_Blender_Parameters"."Processor_Options"."Blender_OPT"."_Deaireation"))) AND "Blender_Variables_Pers"."gWaterRecipe"
// RLO: (("HMI_Blender_Parameters"."Processor_Options"."Blender_OPT"."_StillWaterByPass" OR ("HMI_Blender_Parameters"."Processor_Options"."Blender_OPT"."_ByPassDeair" AND (NOT "HMI_Blender_Parameters"."Processor_Options"."Blender_OPT"."_Deaireation"))) AND "Blender_Variables_Pers"."gWaterRecipe") AND (NOT "Blender_Variables_Pers"."gCarboStillRecipe")
"gStillWaterByPassEn" := (("HMI_Blender_Parameters"."Processor_Options"."Blender_OPT"."_StillWaterByPass" OR ("HMI_Blender_Parameters"."Processor_Options"."Blender_OPT"."_ByPassDeair" AND (NOT "HMI_Blender_Parameters"."Processor_Options"."Blender_OPT"."_Deaireation"))) AND "Blender_Variables_Pers"."gWaterRecipe") AND (NOT "Blender_Variables_Pers"."gCarboStillRecipe");
// Network 13: Still Water Bypass
// Network 13: Still Water Bypass (Original Language: LAD)
// RLO: "HMI_Blender_Parameters"."Processor_Options"."Blender_OPT"."_BlendFillSystem"
// RLO: "HMI_Blender_Parameters"."Processor_Options"."Blender_OPT"."_BlendFillSystem" AND "HMI_Blender_Parameters"."Processor_Options"."Blender_OPT"."_StillWaterByPass"
// RLO: ("HMI_Blender_Parameters"."Processor_Options"."Blender_OPT"."_BlendFillSystem" AND "HMI_Blender_Parameters"."Processor_Options"."Blender_OPT"."_StillWaterByPass") AND "Blender_Variables_Pers"."gWaterRecipe"
// RLO: (("HMI_Blender_Parameters"."Processor_Options"."Blender_OPT"."_BlendFillSystem" AND "HMI_Blender_Parameters"."Processor_Options"."Blender_OPT"."_StillWaterByPass") AND "Blender_Variables_Pers"."gWaterRecipe") AND (NOT "Blender_Variables_Pers"."gCarboStillRecipe")
"gBlendFiStillWaterByPass" := (("HMI_Blender_Parameters"."Processor_Options"."Blender_OPT"."_BlendFillSystem" AND "HMI_Blender_Parameters"."Processor_Options"."Blender_OPT"."_StillWaterByPass") AND "Blender_Variables_Pers"."gWaterRecipe") AND (NOT "Blender_Variables_Pers"."gCarboStillRecipe");
// Network 14: Manual Syrup Drain Valve Open - Operator Alarm
// Network 14: Manual Syrup Drain Valve Open - Operator Alarm (Original Language: LAD)
// RLO: "gSyrupRoomEn"
// RLO: "gSyrupRoomEn" AND (NOT "gIN_HVP301_Aux")
// RLO: ("gSyrupRoomEn" AND (NOT "gIN_HVP301_Aux")) AND (NOT "HMI_Blender_Parameters"."Processor_Options"."Blender_OPT"."_FastChangeOverEnabled")
// RLO: ("gSyrupRoomEn" AND (NOT "gIN_HVP301_Aux")) AND (NOT "HMI_Blender_Parameters"."Processor_Options"."Blender_OPT"."_FastChangeOverEnabled") AND "Procedure_Variables"."FTP302Line_Preparation"."Done"
// RLO: (("gSyrupRoomEn" AND (NOT "gIN_HVP301_Aux")) AND (NOT "HMI_Blender_Parameters"."Processor_Options"."Blender_OPT"."_FastChangeOverEnabled") AND "Procedure_Variables"."FTP302Line_Preparation"."Done") AND (NOT "Procedure_Variables"."Syr_RunOut"."Done")
// RLO: ("gSyrupRoomEn" AND (NOT "gIN_HVP301_Aux")) AND "gBlenderCIPMode"
// RLO: (("gSyrupRoomEn" AND (NOT "gIN_HVP301_Aux")) AND "gBlenderCIPMode") AND "gIN_CIP_CIPRunning"
// RLO: ((("gSyrupRoomEn" AND (NOT "gIN_HVP301_Aux")) AND "gBlenderCIPMode") AND "gIN_CIP_CIPRunning") AND "Procedure_Variables"."Blender_Run"."Running"
"gHVP301_Open" := (("gSyrupRoomEn" AND (NOT "gIN_HVP301_Aux")) AND (NOT "HMI_Blender_Parameters"."Processor_Options"."Blender_OPT"."_FastChangeOverEnabled") AND "Procedure_Variables"."FTP302Line_Preparation"."Done") AND (NOT "Procedure_Variables"."Syr_RunOut"."Done") OR (((("gSyrupRoomEn" AND (NOT "gIN_HVP301_Aux")) AND "gBlenderCIPMode") AND "gIN_CIP_CIPRunning") AND "Procedure_Variables"."Blender_Run"."Running");
// Network 15: Manual Syrup Drain Valve Open - Operator Alarm
// Network 15: Manual Syrup Drain Valve Open - Operator Alarm (Original Language: LAD)
// RLO: "gIN_HVM302_Aux"
// Network did not produce printable SCL code.
// Network 16: Maselli Control
// Network 16: Maselli Control (Original Language: LAD)
// RLO: "HMI_Blender_Parameters"."Processor_Options"."Blender_OPT"."_BrixMeter"
IF "HMI_Blender_Parameters"."Processor_Options"."Blender_OPT"."_MeterType" = 6 THEN
Maselli_PA_Control();
END_IF;
// Network 17: mPDS Control
// Network 17: mPDS Control (Original Language: LAD)
// RLO: "HMI_Blender_Parameters"."Processor_Options"."Blender_OPT"."_BrixMeter"
IF "HMI_Blender_Parameters"."Processor_Options"."Blender_OPT"."_MeterType" = 5 THEN
mPDS_PA_Control();
END_IF;
// Network 18: mPDS Syrup Control
// Network 18: mPDS Syrup Control (Original Language: LAD)
// RLO: "HMI_Blender_Parameters"."Processor_Options"."Blender_OPT"."_SyrBrixMeter"
IF "HMI_Blender_Parameters"."Processor_Options"."Blender_OPT"."_SyrBrixMeter" THEN
mPDS_SYR_PA_Control();
END_IF;
// Network 19: Co2 Analog Input
// Network 19: Co2 Analog Input (Original Language: LAD)
// GetProdBrixCO2_FromAnalogIn
// CALL "GetProdBrixCO2_FromAn"
// NOP 0
// RLO: "HMI_Blender_Parameters"."Processor_Options"."Blender_OPT"."_BrixMeter"
IF "HMI_Blender_Parameters"."Processor_Options"."Blender_OPT"."_MeterType" = 3 THEN
GetProdBrixCO2_Anal_Inpt();
END_IF;
// Network 20: Quality
// Network 20: Quality (Original Language: LAD)
ProductQuality();
// Network 21: Input Data
// Network 21: Input Data (Original Language: LAD)
"Input_Data"();
// Network 22: Sel Brix Source Check
// Network 22: Sel Brix Source Check (Original Language: LAD)
SelCheckBrixSource();
// Network 23: Check Water Cooling System Temperature
// Network 23: Check Water Cooling System Temperature (Original Language: LAD)
// RLO: "HMI_Blender_Parameters"."Processor_Options"."Blender_OPT"."_InverterRecirPumpPPM306"
IF "HMI_Blender_Parameters"."Processor_Options"."Blender_OPT"."_InverterRecirPumpPPM306" THEN
CTRLCoolingSystem();
END_IF;
// Network 24: Tank Level
// Network 24: Tank Level (Original Language: LAD)
TankLevel();
// Network 25: Production ONS
// Network 25: Production ONS (Original Language: LAD)
// RLO: "gBlenderProdMode"
// PBox Logic moved to consumer Coil
// RLO: ("gBlenderProdMode" AND NOT "M19001") AND (NOT "mDelayPowerOnTmr")
"gProductionONS" := ("gBlenderProdMode" AND NOT "M19001") AND (NOT "mDelayPowerOnTmr");
// Network 26: Blender Prod Mode Init
// Network 26: Blender Prod Mode Init (Original Language: LAD)
// RLO: "gProductionONS"
// RLO: "Procedure_Variables"."Blender_Rinse"."ONS_Done"
// RLO: ("gProductionONS" OR "Procedure_Variables"."Blender_Rinse"."ONS_Done") AND (NOT "Blender_Variables_Pers"."gBlenderStarted")
IF ("gProductionONS" OR "Procedure_Variables"."Blender_Rinse"."ONS_Done") AND (NOT "Blender_Variables_Pers"."gBlenderStarted") THEN
BlenderCtrl_ProdModeInit();
END_IF;
// Network 27: Rinse ONS
// Network 27: Rinse ONS (Original Language: LAD)
// RLO: "HMI_Variables_Status"."System"."Blender_Prod_CIP"
// PBox Logic moved to consumer Coil
// RLO: ("HMI_Variables_Status"."System"."Blender_Prod_CIP" AND NOT "M19002") AND (NOT "mDelayPowerOnTmr")
"gRinseONS" := ("HMI_Variables_Status"."System"."Blender_Prod_CIP" AND NOT "M19002") AND (NOT "mDelayPowerOnTmr");
// Network 28: CIP ONS
// Network 28: CIP ONS (Original Language: LAD)
// RLO: "gBlenderCIPMode"
// PBox Logic moved to consumer Coil
// RLO: ("gBlenderCIPMode" AND NOT "M19003") AND (NOT "mDelayPowerOnTmr")
"gCIPONS" := ("gBlenderCIPMode" AND NOT "M19003") AND (NOT "mDelayPowerOnTmr");
// Network 29: CIp Mode Init
// Network 29: CIp Mode Init (Original Language: LAD)
// RLO: "gCIPONS"
IF "gCIPONS" THEN
BlenderCtrl_CIPModeInit();
END_IF;
// Network 30: Reset SPWords
// Network 30: Reset SPWords (Original Language: LAD)
BlenderCtrl_ResetSPWord();
// Network 31: Blender Run Control
// Network 31: Blender Run Control (Original Language: LAD)
BlenderRun__Control();
// Network 32: Tank Pressure Control
// Network 32: Tank Pressure Control (Original Language: LAD)
Prod_Tank_PressCtrl();
// Network 33: Balaiage
// Network 33: Balaiage (Original Language: LAD)
Baialage();
// Network 34: First Production
// Network 34: First Production (Original Language: LAD)
"FirstProduction_Data"();
// Network 35: CIP MAIN Calling
// Network 35: CIP MAIN Calling (Original Language: LAD)
CIPMain();
// Network 36: Blender Rinse
// Network 36: Blender Rinse (Original Language: LAD)
BlenderRinse();
// Network 37: Safeties
// Network 37: Safeties (Original Language: LAD)
Safeties();
// Network 38: Instrument Scanner
// Network 38: Instrument Scanner (Original Language: LAD)
Instrument_Scanner();
// Network 39: Vacuum Control
// Network 39: Vacuum Control (Original Language: LAD)
VacuumCtrl();
// Network 40: Syrup Room Control
// Network 40: Syrup Room Control (Original Language: LAD)
SyrupRoomCtrl();
// Network 41: Blend Procedure Data
// Network 41: Blend Procedure Data (Original Language: LAD)
// RLO: (NOT "mDelayPowerOnTmr")
IF (NOT "mDelayPowerOnTmr") THEN
"Blender_Procedure Data"();
END_IF;
// Network 42: Pneumatic Valve Control
// Network 42: Pneumatic Valve Control (Original Language: LAD)
Pneumatic_Valve_Ctrl();
// Network 43: Pumps Control
// Network 43: Pumps Control (Original Language: LAD)
PumpsControl();
// Network 44: Prod Report Manager
// Network 44: Prod Report Manager (Original Language: LAD)
// RLO: "HMI_Blender_Parameters"."Processor_Options"."Blender_OPT"."_Report"
IF "HMI_Blender_Parameters"."Processor_Options"."Blender_OPT"."_Report" THEN
ProdReportManager();
END_IF;
// Network 45: Outputs
// Network 45: Outputs (Original Language: LAD)
Output();
// Network 46: SLIM BLOCK
// Network 46: SLIM BLOCK (Original Language: LAD)
SLIM_Block();
// Network 47: Interlocking Panel 1
// Network 47: Interlocking Panel 1 (Original Language: LAD)
Interlocking_Panel_1();
// Network 48: Filler Control
// Network 48: Filler Control (Original Language: LAD)
FillerControl();
// Network 49: Blender Ctrl Update PWORD
// Network 49: Blender Ctrl Update PWORD (Original Language: LAD)
BlenderCtrl_UpdatePWord();
// Network 50: ResetTotalizer
// Network 50: ResetTotalizer (Original Language: LAD)
// RLO: "gBlendResetTotalizer"
// Network did not produce printable SCL code.
// Network 51: ResetWaterTot
// Network 51: ResetWaterTot (Original Language: LAD)
// RLO: "gFTN301_ResetTot"
// RLO: "mResetTotalizerTmr"
// Network did not produce printable SCL code.
// Network 52: Water VFM Reset Totalizer
// Network 52: Water VFM Reset Totalizer (Original Language: LAD)
// RLO: "gFTN301_ResetTot"
IF "gFTN301_ResetTot" THEN
"gFTN301_ResetTot" := FALSE;
END_IF;
// Network 53: ResetCO2Tot
// Network 53: ResetCO2Tot (Original Language: LAD)
// RLO: "gFTP302_ResetTot"
// RLO: "mResetTotalizerTmr"
// Network did not produce printable SCL code.
// Network 54: Syrup MFM Reset Totalizer
// Network 54: Syrup MFM Reset Totalizer (Original Language: LAD)
// RLO: "gFTP302_ResetTot"
IF "gFTP302_ResetTot" THEN
"gFTP302_ResetTot" := FALSE;
END_IF;
// Network 55: ResetProductTot
// Network 55: ResetProductTot (Original Language: LAD)
// RLO: "gFTM303_ResetTot"
// RLO: "mResetTotalizerTmr"
// Network did not produce printable SCL code.
// Network 56: CO2 MFM Reset Tot
// Network 56: CO2 MFM Reset Tot (Original Language: LAD)
// RLO: "gFTM303_ResetTot"
IF "gFTM303_ResetTot" THEN
"gFTM303_ResetTot" := FALSE;
END_IF;
// Network 57: ResetCO2Tot
// Network 57: ResetCO2Tot (Original Language: LAD)
// RLO: "gProductMFMResetTot"
// RLO: "mResetTotalizerTmr"
// Network did not produce printable SCL code.
// Network 58: Reset Totalizer
// Network 58: Reset Totalizer (Original Language: LAD)
// RLO: "gProductMFMResetTot"
IF "gProductMFMResetTot" THEN
"gProductMFMResetTot" := FALSE;
END_IF;
// Network 59: Reset Totalizer
// Network 59: Reset Totalizer (Original Language: LAD)
// RLO: "gBlendResetTotalizer"
IF "gBlendResetTotalizer" THEN
"gBlendResetTotalizer" := FALSE;
END_IF;
// Network 60: Blender Ctrl Command
// Network 60: Blender Ctrl Command (Original Language: LAD)
// RLO: (NOT "HMI_Blender_Parameters"."Processor_Options"."Blender_OPT"."_Simulation")
IF (NOT "HMI_Blender_Parameters"."Processor_Options"."Blender_OPT"."_Simulation") THEN
BlenderCtrl_MFM_Command();
END_IF;
// Network 61: DP Global Diag
// Network 61: DP Global Diag (Original Language: LAD)
CPU_DP_Global_Diag();
// Network 62: Profibus
// Network 62: Profibus (Original Language: LAD)
Profibus_Network();
// Network 63: Valve Fault
// Network 63: Valve Fault (Original Language: LAD)
ModValveFault();
// Network 64: All Auto
// Network 64: All Auto (Original Language: LAD)
// RLO: "HMI_Variables_Cmd"."Commands_From_HMI"."F7_DeviceControl"."Command"
// RLO: "HMI_Variables_Cmd"."Commands_From_HMI"."F7_DeviceControl"."Command" AND "HMI_Variables_Cmd"."Commands_From_HMI"."F7_DeviceControl"."Enable"
// NBox Logic moved to consumer Coil
IF NOT ("HMI_Variables_Cmd"."Commands_From_HMI"."F7_DeviceControl"."Command" AND "HMI_Variables_Cmd"."Commands_From_HMI"."F7_DeviceControl"."Enable") AND "M19011" THEN
BlenderCtrl_All_Auto();
END_IF;
"HMI_Variables_Cmd"."Commands_From_HMI"."F7_DeviceControl"."Light" := "HMI_Variables_Cmd"."Commands_From_HMI"."F7_DeviceControl"."Command" AND "HMI_Variables_Cmd"."Commands_From_HMI"."F7_DeviceControl"."Enable";
// Network 65: Ctrl HMI Manual Active
// Network 65: Ctrl HMI Manual Active (Original Language: LAD)
BlenderCtrl_ManualActive();
// Network 66: Mod Copy Recipe
// Network 66: Mod Copy Recipe (Original Language: LAD)
// RLO: "HMI_Variables_Cmd"."Recipe"."Main_Page"
// RLO: "HMI_Variables_Cmd"."Recipe"."Main_Page" AND (NOT "mFP_Recip_Main_Page")
"mAux_FP_M700_1" := "HMI_Variables_Cmd"."Recipe"."Main_Page" AND (NOT "mFP_Recip_Main_Page");
"mFP_Recip_Main_Page" := "HMI_Variables_Cmd"."Recipe"."Main_Page";
// RLO: "HMI_Variables_Cmd"."Recipe"."Main_Page"
// RLO: "HMI_Variables_Cmd"."Recipe"."Main_Page" AND "HMI_Variables_Cmd"."Recipe"."Edit"
// RLO: "mAux_FP_M700_1"
IF "mAux_FP_M700_1" THEN
"HMI_Variables_Cmd"."Recipe"."Edit" := TRUE;
END_IF;
// Network 67: to HMI - Recipe Management
// Network 67: to HMI - Recipe Management (Original Language: LAD)
// RLO: "AUX TRUE"
IF "AUX TRUE" THEN
"RecipeManagement_Data"();
END_IF;
// Network 68: Recipe Calculation
// Network 68: Recipe Calculation (Original Language: LAD)
RecipeCalculation();

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -27,22 +27,40 @@ END_VAR
BEGIN
// Network 1: Filler Head
// Network 1: Manual Syrup Drain Valve Open - Operator Alarm (Original Language: LAD)
// RLO: "AUX FALSE"
IF "AUX FALSE" THEN
"Block_Move_Err" := BLKMOV(SRCBLK := "HMI_PID"."PPM303", DSTBLK => "Filler_Head_Variables"."FillerHead"); // ADVERTENCIA: BLKMOV usado directamente, probablemente no compile!
END_IF;
"gHVP301_Open" := (("gSyrupRoomEn" AND (NOT "gIN_HVP301_Aux")) AND (NOT "HMI_Blender_Parameters"."Processor_Options"."Blender_OPT"."_FastChangeOverEnabled") AND "Procedure_Variables"."FTP302Line_Preparation"."Done") AND (NOT "Procedure_Variables"."Syr_RunOut"."Done") OR (((("gSyrupRoomEn" AND (NOT "gIN_HVP301_Aux")) AND "gBlenderCIPMode") AND "gIN_CIP_CIPRunning") AND "Procedure_Variables"."Blender_Run"."Running");
// Network 2: Error Faults
// Network 2: Manual Syrup Drain Valve Open - Operator Alarm (Original Language: LAD)
// RLO: (NOT "AUX FALSE")
IF (NOT "AUX FALSE") THEN
"HMI_Variables_Status"."Meters"."QTM3012_PRD_Fault" := TRUE;
END_IF;
"gmPDS2000_Error_Fault" := (NOT "AUX FALSE");
IF (NOT "AUX FALSE") THEN
"HMI_Variables_Status"."Meters"."QTM3012_PRD_Run" := FALSE;
// Network did not produce printable SCL code.
// Network 3: ResetTotalizer (Original Language: LAD)
// Network did not produce printable SCL code.
// Network 4: ResetWaterTot (Original Language: LAD)
// Network did not produce printable SCL code.
// Network 5: ResetCO2Tot (Original Language: LAD)
// Network did not produce printable SCL code.
// Network 6: ResetProductTot (Original Language: LAD)
// Network did not produce printable SCL code.
// Network 7: ResetCO2Tot (Original Language: LAD)
// Network did not produce printable SCL code.
// Network 8: Mod Copy Recipe (Original Language: LAD)
"mAux_FP_M700_1" := "HMI_Variables_Cmd"."Recipe"."Main_Page" AND (NOT "mFP_Recip_Main_Page");
"mFP_Recip_Main_Page" := "HMI_Variables_Cmd"."Recipe"."Main_Page";
IF "mAux_FP_M700_1" THEN
"HMI_Variables_Cmd"."Recipe"."Edit" := TRUE;
END_IF;
END_FUNCTION_BLOCK

View File

@ -7,9 +7,11 @@ import traceback
from collections import defaultdict
# --- Namespaces ---
# Se añade el namespace 'st' para Structured Text
ns = {
"iface": "http://www.siemens.com/automation/Openness/SW/Interface/v5",
"flg": "http://www.siemens.com/automation/Openness/SW/NetworkSource/FlgNet/v4",
"st": "http://www.siemens.com/automation/Openness/SW/NetworkSource/StructuredText/v3" # <--- Added SCL namespace
}
@ -141,6 +143,95 @@ def parse_call(call_element):
if instance_scope: call_data["instance_scope"] = instance_scope
return call_data
# EN x1_to_json.py, junto a otras funciones auxiliares
def reconstruct_scl_from_tokens(st_node):
"""
Intenta reconstruir una cadena SCL a partir de los elementos hijos
de un nodo <StructuredText>. Es una aproximación y puede no ser perfecta.
"""
if st_node is None:
return "// Error: StructuredText node not found.\n"
scl_parts = []
# Obtener todos los elementos hijos directos en orden
children = st_node.xpath("./st:*", namespaces=ns)
for elem in children:
tag = etree.QName(elem.tag).localname
if tag == "Token":
scl_parts.append(elem.get("Text", ""))
elif tag == "Blank":
scl_parts.append(" " * int(elem.get("Num", 1)))
elif tag == "NewLine":
# Añadir un salto de línea real. strip() al final de la línea actual
# para evitar espacios extra antes del salto.
scl_parts.append("\n")
elif tag == "Access":
# Reconstruir acceso (simplificado)
symbol_parts = []
# Buscar componentes y puntos dentro del símbolo de este acceso
symbol_children = elem.xpath(".//st:Component | .//st:Token[@Text='.']", namespaces=ns)
for sym_child in symbol_children:
sym_tag = etree.QName(sym_child.tag).localname
if sym_tag == "Component":
comp_name = sym_child.get("Name", "_ERR_")
# Comprobar si necesita comillas (podríamos necesitar parsear BooleanAttribute)
# Simplificación: Añadir comillas si el nombre original parece tenerlas (o siempre para DBs?)
# Aquí usamos el nombre tal cual viene en el XML por ahora
# Si el XML tiene <BooleanAttribute Name="HasQuotes">true</BooleanAttribute> podríamos usarlo
has_quotes_elem = sym_child.xpath("../st:BooleanAttribute[@Name='HasQuotes']/text()", namespaces=ns)
has_quotes = has_quotes_elem and has_quotes_elem[0].lower() == 'true'
# Reconstrucción básica: poner comillas si HasQuotes es true o si es el primer componente (posible DB)
# Esto es heurístico y puede fallar.
# if has_quotes or (len(symbol_parts) == 0 and '.' not in comp_name): # Asumir primer componente es DB
# symbol_parts.append(f'"{comp_name}"')
# else:
# symbol_parts.append(comp_name)
# Versión más simple: usar nombre tal cual del XML
symbol_parts.append(comp_name)
elif sym_tag == "Token": # Solo nos interesa el punto aquí
symbol_parts.append(".")
access_str = "".join(symbol_parts)
# Manejar llamadas a funciones/FB dentro de Access Scope="Call"
if elem.get("Scope") == "Call":
instruction_elem = elem.xpath("./st:Instruction", namespaces=ns)
if instruction_elem:
instr_name = instruction_elem[0].get("Name", "_UNKNOWN_CALL_")
# Reconstrucción básica de parámetros (muy simplificada)
# Necesitaría parsear Parameters, Tokens '(', ')', ':=', '=>', etc.
# Por ahora, solo añadimos el nombre y paréntesis vacíos
access_str = f"{instr_name}()" # Placeholder muy básico
scl_parts.append(access_str)
elif tag == "Comment" or tag == "LineComment":
# Añadir comentarios
comment_text = elem.text if elem.text else ""
if tag == "Comment" and "\n" in comment_text: # Comentario multi-línea
scl_parts.append(f"(*{comment_text}*)")
else: # Comentario de una línea
scl_parts.append(f"// {comment_text}")
else:
# Ignorar otros tipos de nodos por ahora o añadir manejo específico
pass
# Unir todas las partes, limpiar espacios extra alrededor de saltos de línea
full_scl = "".join(scl_parts)
# Limpieza básica de formato
lines = [line.rstrip() for line in full_scl.split('\n')]
# Re-ensamblar, asegurando que líneas vacías (solo espacios previos) se mantengan
cleaned_scl = "\n".join(lines)
# Eliminar múltiples líneas vacías consecutivas (opcional)
# import re
# cleaned_scl = re.sub(r'\n\s*\n', '\n\n', cleaned_scl)
return cleaned_scl.strip() # Quitar espacios/saltos al inicio/final
# --- Función parse_network con XPath corregido para Title/Comment ---
# --- Función parse_network MODIFICADA (maneja multi-destino en Wire) ---
def parse_network(network_element):
@ -308,136 +399,6 @@ def parse_network(network_element):
# 6. Ordenar y Devolver (sin cambios)
network_logic_final = [all_logic_steps[uid] for uid in sorted_uids_for_en if uid in all_logic_steps]
return {"id": network_id, "title": network_title, "comment": network_comment, "logic": network_logic_final}
"""
Parsea una red, extrae lógica y añade conexiones EN implícitas.
"""
if network_element is None:
return {"id": "ERROR", "title": "Invalid Network Element", "comment": "", "logic": [], "error": "Input element was None"}
network_id = network_element.get("ID")
# --- CORRECCIÓN XPath para Title y Comment ---
# Usar local-name() como en la versión original que funcionaba para esto
title_element = network_element.xpath(
".//*[local-name()='MultilingualText'][@CompositionName='Title']" # Busca en cualquier nivel descendiente
)
network_title = get_multilingual_text(title_element[0]) if title_element else f"Network {network_id}"
comment_element = network_element.xpath(
"./*[local-name()='ObjectList']/*[local-name()='MultilingualText'][@CompositionName='Comment']" # Busca directamente bajo ObjectList
)
network_comment = get_multilingual_text(comment_element[0]) if comment_element else ""
# --- FIN CORRECCIÓN XPath ---
flgnet_list = network_element.xpath(".//flg:FlgNet", namespaces=ns)
if not flgnet_list:
return {"id": network_id, "title": network_title, "comment": network_comment, "logic": [], "error": "FlgNet not found"}
flgnet = flgnet_list[0]
# 1. Parsear Access, Parts y Calls (usando parse_call corregido)
access_map = {acc_info["uid"]: acc_info for acc in flgnet.xpath(".//flg:Access", namespaces=ns) if (acc_info := parse_access(acc)) and acc_info['type'] != 'unknown'}
parts_and_calls_map = {}
instruction_elements = flgnet.xpath(".//flg:Part | .//flg:Call", namespaces=ns)
for element in instruction_elements:
parsed_info = None
if element.tag == etree.QName(ns["flg"], "Part"): parsed_info = parse_part(element)
elif element.tag == etree.QName(ns["flg"], "Call"): parsed_info = parse_call(element) # Usa la versión con fix DB
if parsed_info and "uid" in parsed_info: parts_and_calls_map[parsed_info["uid"]] = parsed_info
else: print(f"Advertencia: Se ignoró un Part/Call inválido en la red {network_id}")
# 2. Parsear Wires (sin cambios)
wire_connections = defaultdict(list); source_connections = defaultdict(list); eno_outputs = defaultdict(list)
flg_ns_uri = ns["flg"]
for wire in flgnet.xpath(".//flg:Wire", namespaces=ns):
source_uid, source_pin, dest_uid, dest_pin = None, None, None, None
children = wire.getchildren();
if len(children) < 2: continue
source_elem, dest_elem = children[0], children[1]
if source_elem.tag == etree.QName(flg_ns_uri, "Powerrail"): source_uid, source_pin = "POWERRAIL", "out"
elif source_elem.tag == etree.QName(flg_ns_uri, "IdentCon"): source_uid, source_pin = source_elem.get("UId"), "value"
elif source_elem.tag == etree.QName(flg_ns_uri, "NameCon"): source_uid, source_pin = source_elem.get("UId"), source_elem.get("Name")
if dest_elem.tag == etree.QName(flg_ns_uri, "IdentCon"): dest_uid, dest_pin = dest_elem.get("UId"), "value"
elif dest_elem.tag == etree.QName(flg_ns_uri, "NameCon"): dest_uid, dest_pin = dest_elem.get("UId"), dest_elem.get("Name")
if source_uid is not None and source_pin is not None and dest_uid is not None and dest_pin is not None:
dest_key = (dest_uid, dest_pin); source_info = (source_uid, source_pin)
if source_info not in wire_connections[dest_key]: wire_connections[dest_key].append(source_info)
source_key = (source_uid, source_pin); dest_info = (dest_uid, dest_pin)
if dest_info not in source_connections[source_key]: source_connections[source_key].append(dest_info)
if source_pin == "eno" and source_uid in parts_and_calls_map:
if dest_info not in eno_outputs[source_uid]: eno_outputs[source_uid].append(dest_info)
# 3. Construcción Lógica Inicial (sin cambios)
all_logic_steps = {}
functional_block_types = ['Move', 'Add', 'Sub', 'Mul', 'Div', 'Mod', 'Convert', 'Call', 'Se', 'Sd', 'BLKMOV']
rlo_generators = ['Contact', 'O', 'Eq', 'Ne', 'Gt', 'Lt', 'Ge', 'Le', 'And', 'Xor', 'PBox', 'NBox']
for instruction_uid, instruction_info in parts_and_calls_map.items():
instruction_repr = {"instruction_uid": instruction_uid, **instruction_info}; instruction_repr["inputs"] = {}; instruction_repr["outputs"] = {}
possible_input_pins = set(['en', 'in', 'in1', 'in2', 'in3', 'in4', 's', 'r', 'clk', 'cu', 'cd', 'ld', 'pv', 'tv', 'bit', 'operand', 'pre', 'SRCBLK'])
for dest_pin_name in possible_input_pins:
dest_key = (instruction_uid, dest_pin_name)
if dest_key in wire_connections:
sources_list = wire_connections[dest_key]; input_sources_repr = []
for source_uid, source_pin in sources_list:
if source_uid == "POWERRAIL": input_sources_repr.append({"type": "powerrail"})
elif source_uid in access_map: input_sources_repr.append(access_map[source_uid])
elif source_uid in parts_and_calls_map: input_sources_repr.append({"type": "connection", "source_instruction_type": parts_and_calls_map[source_uid]["type"], "source_instruction_uid": source_uid, "source_pin": source_pin})
else: input_sources_repr.append({"type": "unknown_source", "uid": source_uid})
if len(input_sources_repr) == 1: instruction_repr["inputs"][dest_pin_name] = input_sources_repr[0]
elif len(input_sources_repr) > 1: instruction_repr["inputs"][dest_pin_name] = input_sources_repr
possible_output_pins = set(['out', 'out1', 'Q', 'eno', 'RET_VAL', 'DSTBLK', 'q', 'rt', 'rtbcd', 'cv', 'cvbcd'])
for source_pin_name in possible_output_pins:
source_key = (instruction_uid, source_pin_name)
if source_key in source_connections:
for dest_uid, dest_pin in source_connections[source_key]:
if dest_uid in access_map:
if source_pin_name not in instruction_repr["outputs"]: instruction_repr["outputs"][source_pin_name] = []
if access_map[dest_uid] not in instruction_repr["outputs"][source_pin_name]: instruction_repr["outputs"][source_pin_name].append(access_map[dest_uid])
all_logic_steps[instruction_uid] = instruction_repr
# 4. Inferencia EN (sin cambios)
processed_blocks_en_inference = set(); something_changed = True; inference_passes = 0; max_inference_passes = len(all_logic_steps) + 5
try: sorted_uids_for_en = sorted(all_logic_steps.keys(), key=lambda x: int(x) if x.isdigit() else float('inf'))
except ValueError: sorted_uids_for_en = sorted(all_logic_steps.keys())
ordered_logic_list_for_en = [all_logic_steps[uid] for uid in sorted_uids_for_en if uid in all_logic_steps]
while something_changed and inference_passes < max_inference_passes:
something_changed = False; inference_passes += 1
for i, instruction in enumerate(ordered_logic_list_for_en):
part_uid = instruction["instruction_uid"]; part_type_original = instruction["type"].replace('_scl', '').replace('_error', '')
if (part_type_original in functional_block_types and "en" not in instruction["inputs"] and part_uid not in processed_blocks_en_inference):
inferred_en_source = None
if i > 0:
for j in range(i - 1, -1, -1):
prev_instr = ordered_logic_list_for_en[j]; prev_uid = prev_instr["instruction_uid"]; prev_type_original = prev_instr["type"].replace('_scl', '').replace('_error', '')
if prev_type_original in rlo_generators: inferred_en_source = {"type": "connection", "source_instruction_uid": prev_uid, "source_instruction_type": prev_type_original, "source_pin": "out"}; break
elif prev_type_original in functional_block_types:
source_key_eno = (prev_uid, "eno")
if source_key_eno in source_connections: inferred_en_source = {"type": "connection", "source_instruction_uid": prev_uid, "source_instruction_type": prev_type_original, "source_pin": "eno"}; break
else: continue
elif prev_type_original in ['Coil', 'SCoil', 'RCoil', 'SetCoil', 'ResetCoil', 'SdCoil']: break
if inferred_en_source: all_logic_steps[part_uid]["inputs"]["en"] = inferred_en_source; processed_blocks_en_inference.add(part_uid); something_changed = True
# 5. Añadir lógica ENO interesante (sin cambios)
for source_instr_uid, eno_destinations in eno_outputs.items():
if source_instr_uid not in all_logic_steps: continue
interesting_eno_logic = []
for dest_uid, dest_pin in eno_destinations:
is_direct_en_connection = False
if dest_uid in parts_and_calls_map and dest_pin == 'en':
try:
source_idx = sorted_uids_for_en.index(source_instr_uid); dest_idx = sorted_uids_for_en.index(dest_uid)
if dest_idx == source_idx + 1 and parts_and_calls_map[dest_uid]['type'] in functional_block_types: is_direct_en_connection = True
except ValueError: pass
if not is_direct_en_connection:
target_info = {"target_pin": dest_pin}
if dest_uid in parts_and_calls_map: target_info.update({"target_type": "instruction", "target_uid": dest_uid, "target_name": parts_and_calls_map[dest_uid].get("name", parts_and_calls_map[dest_uid].get("type"))})
elif dest_uid in access_map: target_info.update({"target_type": "operand", "target_details": access_map[dest_uid]})
else: target_info.update({"target_type": "unknown", "target_uid": dest_uid})
interesting_eno_logic.append(target_info)
if interesting_eno_logic: all_logic_steps[source_instr_uid]["eno_logic"] = interesting_eno_logic
# 6. Ordenar y Devolver (sin cambios)
network_logic_final = [all_logic_steps[uid] for uid in sorted_uids_for_en if uid in all_logic_steps]
return {"id": network_id, "title": network_title, "comment": network_comment, "logic": network_logic_final}
# --- Función Principal convert_xml_to_json (sin cambios en su flujo general) ---
def convert_xml_to_json(xml_filepath, json_filepath):
@ -494,20 +455,110 @@ def convert_xml_to_json(xml_filepath, json_filepath):
if not result["interface"]: print("Advertencia: Interface sin secciones iface:Section válidas.")
else: print("Advertencia: No se encontró <Interface> dentro de <AttributeList>.")
if not result["interface"]: print("Advertencia: No se pudo extraer información de la interfaz.")
print("Paso 5: Extrayendo y PROCESANDO lógica de redes (CompileUnits)...")
networks_processed_count = 0
result["networks"] = [] # Initialize networks list here
object_list_node = the_block.xpath("./*[local-name()='ObjectList']")
if object_list_node:
compile_units = object_list_node[0].xpath("./*[local-name()='SW.Blocks.CompileUnit']")
print(f"Paso 5: Se encontraron {len(compile_units)} elementos SW.Blocks.CompileUnit.")
for network_elem in compile_units:
networks_processed_count += 1
parsed_network = parse_network(network_elem) # Llamada a la función de parseo de red
if parsed_network and parsed_network.get("error") is None: result["networks"].append(parsed_network)
elif parsed_network: print(f"Error: Falló parseo red ID={parsed_network.get('id')}: {parsed_network.get('error')}")
else: print(f"Error Fatal: parse_network devolvió None para CompileUnit ID={network_elem.get('ID')}.")
if networks_processed_count == 0: print("Advertencia: ObjectList sin SW.Blocks.CompileUnit.")
else: print("Advertencia: No se encontró ObjectList para el bloque.")
network_id = network_elem.get("ID")
if not network_id:
print(" Advertencia: Se encontró CompileUnit sin ID. Saltando.")
continue
# --- Detectar lenguaje de la red ---
attribute_list = network_elem.xpath("./*[local-name()='AttributeList']")
programming_language = "LAD" # Default a LAD si no se especifica
network_source_node = None # Nodo <NetworkSource>
if attribute_list:
lang_node = attribute_list[0].xpath("./*[local-name()='ProgrammingLanguage']/text()")
if lang_node:
programming_language = lang_node[0].strip()
# Obtener el nodo NetworkSource para pasarlo a los parsers
network_source_list = attribute_list[0].xpath("./*[local-name()='NetworkSource']")
if network_source_list:
network_source_node = network_source_list[0]
print(f" - Procesando Red ID={network_id}, Lenguaje={programming_language}")
# --- Extraer título y comentario (común) ---
title_element = network_elem.xpath(
".//*[local-name()='MultilingualText'][@CompositionName='Title']"
)
network_title = get_multilingual_text(title_element[0]) if title_element else f"Network {network_id}"
comment_element = network_elem.xpath(
"./*[local-name()='ObjectList']/*[local-name()='MultilingualText'][@CompositionName='Comment']"
)
network_comment = get_multilingual_text(comment_element[0]) if comment_element else ""
# --- Procesar según el lenguaje ---
parsed_network_data = None
if programming_language == "SCL":
structured_text_node = network_source_node.xpath("./st:StructuredText", namespaces=ns) if network_source_node is not None else None
reconstructed_scl = f"// SCL extraction failed for Network {network_id}: StructuredText node not found.\n"
if structured_text_node:
print(f" Reconstruyendo SCL desde tokens para red {network_id}...")
reconstructed_scl = reconstruct_scl_from_tokens(structured_text_node[0])
# print(f" ... SCL reconstruido (parcial):\n{reconstructed_scl[:200]}...") # Preview opcional
else:
print(f" Advertencia: No se encontró nodo <StructuredText> para red SCL {network_id}.")
parsed_network_data = {
"id": network_id,
"title": network_title,
"comment": network_comment,
"language": "SCL",
"logic": [{
"instruction_uid": f"SCL_{network_id}", # UID inventado
"type": "RAW_SCL_CHUNK",
"scl": reconstructed_scl
}]
}
elif programming_language in ["LAD", "FBD"]:
# Para LAD/FBD, llamar a parse_network (que espera FlgNet dentro de NetworkSource)
# parse_network ya maneja su propio título/comentario si es necesario, pero podemos pasar los extraídos
# Nota: parse_network espera el *CompileUnit* element, no el NetworkSource
parsed_network_data = parse_network(network_elem)
if parsed_network_data:
parsed_network_data["language"] = programming_language # Asegurar que el lenguaje se guarda
if parsed_network_data.get("error"):
print(f" Error al parsear red {programming_language} ID={network_id}: {parsed_network_data['error']}")
# parsed_network_data = None # Descomentar para omitir redes con error
else:
print(f" Error: parse_network devolvió None para red {programming_language} ID={network_id}")
else:
# Manejar otros lenguajes o casos inesperados
print(f" Advertencia: Lenguaje no soportado '{programming_language}' en red ID={network_id}. Creando placeholder.")
parsed_network_data = {
"id": network_id,
"title": network_title,
"comment": network_comment,
"language": programming_language,
"logic": [{"instruction_uid": f"UNS_{network_id}", "type": "UNSUPPORTED_LANG", "scl": f"// Network {network_id} uses unsupported language: {programming_language}\n"}]
}
# Añadir la red procesada (si es válida) al resultado
if parsed_network_data:
result["networks"].append(parsed_network_data)
# --- Fin del bucle for network_elem ---
if networks_processed_count == 0:
print("Advertencia: ObjectList no contenía elementos SW.Blocks.CompileUnit.")
else:
print("Advertencia: No se encontró ObjectList para el bloque.")
print("Paso 6: Escribiendo el resultado en el archivo JSON...")
if not result["interface"]: print("ADVERTENCIA FINAL: 'interface' está vacía.")
if not result["networks"]: print("ADVERTENCIA FINAL: 'networks' está vacía.")

View File

@ -156,32 +156,73 @@ def generate_scl(processed_json_filepath, output_scl_filepath):
for i, network in enumerate(data.get('networks', [])):
network_title = network.get('title', f'Network {network.get("id")}')
network_comment = network.get('comment', '')
scl_output.append(f" // Network {i+1}: {network_title}")
# Obtener lenguaje original de la red, default a LAD si no está
network_lang = network.get('language', 'LAD')
scl_output.append(f" // Network {i+1}: {network_title} (Original Language: {network_lang})")
if network_comment:
# Añadir comentario de red indentado
for line in network_comment.splitlines():
scl_output.append(f" // {line}")
scl_output.append("") # Línea en blanco antes del código de la red
network_has_code = False
# Iterar sobre la 'logica' de la red
for instruction in network.get('logic', []):
instruction_type = instruction.get("type", "")
scl_code = instruction.get('scl')
if scl_code:
network_has_code = True
# Indentar y añadir el código SCL de la instrucción
# Quitar comentarios "// RLO updated..." o "// Comparison..."
# ya que el código SCL resultante es la representación final.
# Mantener comentarios de PBox por claridad.
is_rlo_update_comment = scl_code.strip().startswith("// RLO updated")
is_comparison_comment = scl_code.strip().startswith("// Comparison")
is_logic_o_comment = scl_code.strip().startswith("// Logic O")
if not (is_rlo_update_comment or is_comparison_comment or is_logic_o_comment) or "PBox" in scl_code :
for line in scl_code.splitlines():
scl_output.append(f" {line}") # Indentación de 2 espacios
# --- INICIO: Manejar RAW_SCL_CHUNK y otros tipos ---
if instruction_type == "RAW_SCL_CHUNK" and scl_code:
network_has_code = True
# Imprimir el SCL reconstruido directamente
for line in scl_code.splitlines():
scl_output.append(f" {line}") # Añadir indentación
elif instruction_type == "UNSUPPORTED_LANG" and scl_code:
network_has_code = True
# Imprimir comentario para lenguajes no soportados
for line in scl_code.splitlines():
scl_output.append(f" {line}")
elif instruction_type.endswith("_scl") and scl_code:
# Código SCL generado por x2_process.py para LAD/FBD
if instruction.get("grouped", False): # Ignorar si fue agrupado
continue
# Lógica mejorada para omitir comentarios internos si no aportan
lines = scl_code.splitlines()
is_internal_comment_only = (len(lines) == 1 and
(lines[0].strip().startswith("// RLO") or
lines[0].strip().startswith("// Comparison") or
lines[0].strip().startswith("// Logic O") or
lines[0].strip().startswith("// Logic included in grouped IF") or # Usar GROUPED_COMMENT si lo importas
lines[0].strip().startswith("// P_TRIG") or
lines[0].strip().startswith("// N_TRIG") ))
if not is_internal_comment_only:
network_has_code = True
for line in lines:
clean_line = line.strip()
# Omitir comentarios autogenerados específicos
if not (clean_line.startswith("// RLO:") or \
clean_line.startswith("// Comparison") or \
clean_line.startswith("// Logic O") or \
clean_line == "// Logic included in grouped IF" or \
clean_line.startswith("// P_TRIG(") or \
clean_line.startswith("// N_TRIG(")):
scl_output.append(f" {line}") # Indentación
# Ignorar instrucciones no procesadas (sin _scl) o con error
# elif "_error" in instruction_type:
# scl_output.append(f" // Error processing instruction {instruction.get('instruction_uid')}: {scl_code}")
# network_has_code = True
# --- FIN: Manejar RAW_SCL_CHUNK y otros tipos ---
if network_has_code:
scl_output.append("") # Añadir línea en blanco después del código de la red
scl_output.append("") # Añadir línea en blanco después del código de la red si hubo algo
else:
# Añadir comentario si la red estaba vacía o no generó código imprimible
scl_output.append(f" // Network did not produce printable SCL code.")
scl_output.append("")
scl_output.append("END_FUNCTION_BLOCK")