Corregido error de indices de arrays en parsing SCL
This commit is contained in:
parent
0ddee2e14a
commit
57ca21ec76
|
@ -1,81 +0,0 @@
|
||||||
{
|
|
||||||
"block_name": "FC General Lamp",
|
|
||||||
"block_number": 172,
|
|
||||||
"language": "LAD",
|
|
||||||
"block_type": "FC",
|
|
||||||
"block_comment": "",
|
|
||||||
"interface": {
|
|
||||||
"Return": [
|
|
||||||
{
|
|
||||||
"name": "Ret_Val",
|
|
||||||
"datatype": "Void",
|
|
||||||
"remanence": "NonRetain",
|
|
||||||
"accessibility": "Public",
|
|
||||||
"start_value": null,
|
|
||||||
"comment": null,
|
|
||||||
"children": [],
|
|
||||||
"array_elements": {}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"networks": [
|
|
||||||
{
|
|
||||||
"id": "4",
|
|
||||||
"title": "Lamp Alarm - Q.E. - Light Green",
|
|
||||||
"comment": "",
|
|
||||||
"language": "LAD",
|
|
||||||
"logic": [],
|
|
||||||
"error": "FlgNet not found inside NetworkSource or CompileUnit"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "B",
|
|
||||||
"title": "Lamp Alarm - Q.E. - Light Red",
|
|
||||||
"comment": "",
|
|
||||||
"language": "LAD",
|
|
||||||
"logic": [],
|
|
||||||
"error": "FlgNet not found inside NetworkSource or CompileUnit"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "12",
|
|
||||||
"title": "Lamp Alarm - Q.E. - Buzzer",
|
|
||||||
"comment": "",
|
|
||||||
"language": "LAD",
|
|
||||||
"logic": [],
|
|
||||||
"error": "FlgNet not found inside NetworkSource or CompileUnit"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "19",
|
|
||||||
"title": "Lamp Alarm - Q.E. - Light Blue",
|
|
||||||
"comment": "",
|
|
||||||
"language": "LAD",
|
|
||||||
"logic": [],
|
|
||||||
"error": "FlgNet not found inside NetworkSource or CompileUnit"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "20",
|
|
||||||
"title": "Lamp - Alarm Presence",
|
|
||||||
"comment": "",
|
|
||||||
"language": "LAD",
|
|
||||||
"logic": [],
|
|
||||||
"error": "FlgNet not found inside NetworkSource or CompileUnit"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "27",
|
|
||||||
"title": "Light Signal Phased Stop Machine",
|
|
||||||
"comment": "",
|
|
||||||
"language": "LAD",
|
|
||||||
"logic": [],
|
|
||||||
"error": "FlgNet not found inside NetworkSource or CompileUnit"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "2E",
|
|
||||||
"title": "",
|
|
||||||
"comment": "",
|
|
||||||
"language": "LAD",
|
|
||||||
"logic": [],
|
|
||||||
"error": "FlgNet not found inside NetworkSource or CompileUnit"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source_xml_mod_time": 1749751920.2702959,
|
|
||||||
"source_xml_size": 39346
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,81 +0,0 @@
|
||||||
{
|
|
||||||
"block_name": "FC General Lamp",
|
|
||||||
"block_number": 172,
|
|
||||||
"language": "LAD",
|
|
||||||
"block_type": "FC",
|
|
||||||
"block_comment": "",
|
|
||||||
"interface": {
|
|
||||||
"Return": [
|
|
||||||
{
|
|
||||||
"name": "Ret_Val",
|
|
||||||
"datatype": "Void",
|
|
||||||
"remanence": "NonRetain",
|
|
||||||
"accessibility": "Public",
|
|
||||||
"start_value": null,
|
|
||||||
"comment": null,
|
|
||||||
"children": [],
|
|
||||||
"array_elements": {}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"networks": [
|
|
||||||
{
|
|
||||||
"id": "4",
|
|
||||||
"title": "Lamp Alarm - Q.E. - Light Green",
|
|
||||||
"comment": "",
|
|
||||||
"language": "LAD",
|
|
||||||
"logic": [],
|
|
||||||
"error": "FlgNet not found inside NetworkSource or CompileUnit"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "B",
|
|
||||||
"title": "Lamp Alarm - Q.E. - Light Red",
|
|
||||||
"comment": "",
|
|
||||||
"language": "LAD",
|
|
||||||
"logic": [],
|
|
||||||
"error": "FlgNet not found inside NetworkSource or CompileUnit"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "12",
|
|
||||||
"title": "Lamp Alarm - Q.E. - Buzzer",
|
|
||||||
"comment": "",
|
|
||||||
"language": "LAD",
|
|
||||||
"logic": [],
|
|
||||||
"error": "FlgNet not found inside NetworkSource or CompileUnit"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "19",
|
|
||||||
"title": "Lamp Alarm - Q.E. - Light Blue",
|
|
||||||
"comment": "",
|
|
||||||
"language": "LAD",
|
|
||||||
"logic": [],
|
|
||||||
"error": "FlgNet not found inside NetworkSource or CompileUnit"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "20",
|
|
||||||
"title": "Lamp - Alarm Presence",
|
|
||||||
"comment": "",
|
|
||||||
"language": "LAD",
|
|
||||||
"logic": [],
|
|
||||||
"error": "FlgNet not found inside NetworkSource or CompileUnit"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "27",
|
|
||||||
"title": "Light Signal Phased Stop Machine",
|
|
||||||
"comment": "",
|
|
||||||
"language": "LAD",
|
|
||||||
"logic": [],
|
|
||||||
"error": "FlgNet not found inside NetworkSource or CompileUnit"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "2E",
|
|
||||||
"title": "",
|
|
||||||
"comment": "",
|
|
||||||
"language": "LAD",
|
|
||||||
"logic": [],
|
|
||||||
"error": "FlgNet not found inside NetworkSource or CompileUnit"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source_xml_mod_time": 1749751920.2702959,
|
|
||||||
"source_xml_size": 39346
|
|
||||||
}
|
|
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
|
@ -1,455 +0,0 @@
|
||||||
// Block Type: FC
|
|
||||||
// Block Name (Original): FC Ttop Motor M31010
|
|
||||||
// Block Number: 327
|
|
||||||
// Original Network Languages: LAD, SCL
|
|
||||||
|
|
||||||
FUNCTION "FC_Ttop_Motor_M31010" : Void
|
|
||||||
{ S7_Optimized_Access := 'TRUE' }
|
|
||||||
VERSION : 0.1
|
|
||||||
|
|
||||||
VAR_INOUT
|
|
||||||
Motor : STRUCT
|
|
||||||
RCP_Speed_Fix_01 : Int;
|
|
||||||
RCP_Speed_Fix_02 : Int;
|
|
||||||
RCP_Speed_Fix_03 : Int;
|
|
||||||
RCP_Speed_Fix_04 : Int;
|
|
||||||
RCP_Speed_Fix_05 : Int;
|
|
||||||
RCP_Speed_Sync_01 : Int;
|
|
||||||
RCP_Speed_Sync_02 : Int;
|
|
||||||
RCP_Speed_Sync_03 : Int;
|
|
||||||
RCP_Speed_Sync_04 : Int;
|
|
||||||
RCP_Speed_Sync_05 : Int;
|
|
||||||
RCP_Timer_01 : Int;
|
|
||||||
RCP_Timer_02 : Int;
|
|
||||||
RCP_Timer_03 : Int;
|
|
||||||
RCP_Timer_04 : Int;
|
|
||||||
RCP_Timer_05 : Int;
|
|
||||||
RCP_Speed_Fix_01_mBar : Int;
|
|
||||||
RCP_Speed_Fix_02_mBar : Int;
|
|
||||||
RCP_Speed_Fix_03_mBar : Int;
|
|
||||||
RCP_Speed_Fix_04_mBar : Int;
|
|
||||||
RCP_Speed_Fix_05_mBar : Int;
|
|
||||||
RCP_ACC_Ramp : Int;
|
|
||||||
RCP_DEC_Ramp : Int;
|
|
||||||
RCP_W044 : Int;
|
|
||||||
RCP_W046 : Int;
|
|
||||||
RCP_W048 : Int;
|
|
||||||
CFG_VFD : Bool;
|
|
||||||
CFG_DP : Bool;
|
|
||||||
CFG_Analog_Speed : Bool;
|
|
||||||
CFG_EN_BWD : Bool;
|
|
||||||
CFG_Reverse : Bool;
|
|
||||||
CFG_Motor_N_Sel : Bool;
|
|
||||||
CFG_PN : Bool;
|
|
||||||
CFG_X050_7 : Bool;
|
|
||||||
CFG_TH_CTR_Single : Bool;
|
|
||||||
CFG_SW_CTR_Single : Bool;
|
|
||||||
CFG_TRIP_CTR_Single : Bool;
|
|
||||||
CFG_Speed_User : Bool;
|
|
||||||
CFG_mBar : Bool;
|
|
||||||
CFG_SW_CTR_OnOff : Bool;
|
|
||||||
CFG_Plug_CTR_Single : Bool;
|
|
||||||
CFG_X051_7 : Bool;
|
|
||||||
CFG_Min_Speed_Hz : Int;
|
|
||||||
CFG_Max_Speed_Hz : Int;
|
|
||||||
CFG_mBar_Type : Byte;
|
|
||||||
CFG_B57 : Byte;
|
|
||||||
CFG_Max_mBar : Int;
|
|
||||||
CFG_EOLO_Zone : Bool;
|
|
||||||
CFG_TableTop_Zone : Bool;
|
|
||||||
CFG_Pack_Zone : Bool;
|
|
||||||
CFG_VIS_Sp_User_Step200 : Bool;
|
|
||||||
CFG_X060_4 : Bool;
|
|
||||||
CFG_X060_5 : Bool;
|
|
||||||
CFG_X060_6 : Bool;
|
|
||||||
CFG_X060_7 : Bool;
|
|
||||||
CFG_MPrew : Int;
|
|
||||||
CFG_MNext : Int;
|
|
||||||
CFG_DBExternal1 : Int;
|
|
||||||
CFG_DBExternal2 : Int;
|
|
||||||
CFG_Vis_Fix_00 : Bool;
|
|
||||||
CFG_VIS_Fix_01 : Bool;
|
|
||||||
CFG_VIS_Fix_02 : Bool;
|
|
||||||
CFG_VIS_Fix_03 : Bool;
|
|
||||||
CFG_VIS_Fix_04 : Bool;
|
|
||||||
CFG_VIS_Fix_05 : Bool;
|
|
||||||
CFG_VIS_Fix_06 : Bool;
|
|
||||||
CFG_VIS_Fix_07 : Bool;
|
|
||||||
CFG_VIS_Sync_00 : Bool;
|
|
||||||
CFG_VIS_Sync_01 : Bool;
|
|
||||||
CFG_VIS_Sync_02 : Bool;
|
|
||||||
CFG_VIS_Sync_03 : Bool;
|
|
||||||
CFG_VIS_Sync_04 : Bool;
|
|
||||||
CFG_VIS_Sync_05 : Bool;
|
|
||||||
CFG_VIS_Sync_06 : Bool;
|
|
||||||
CFG_VIS_Sync_07 : Bool;
|
|
||||||
CFG_VIS_Timer_00 : Bool;
|
|
||||||
CFG_VIS_Timer_01 : Bool;
|
|
||||||
CFG_VIS_Timer_02 : Bool;
|
|
||||||
CFG_VIS_Timer_03 : Bool;
|
|
||||||
CFG_VIS_Timer_04 : Bool;
|
|
||||||
CFG_VIS_Timer_05 : Bool;
|
|
||||||
CFG_VIS_Timer_06 : Bool;
|
|
||||||
CFG_VIS_Timer_07 : Bool;
|
|
||||||
CFG_VIS_SA : Bool;
|
|
||||||
CFG_VIS_SB : Bool;
|
|
||||||
CFG_VIS_SC : Bool;
|
|
||||||
CFG_VIS_SD : Bool;
|
|
||||||
CFG_VIS_BA : Bool;
|
|
||||||
CFG_VIS_BB : Bool;
|
|
||||||
CFG_VIS_EXTA : Bool;
|
|
||||||
CFG_VIS_EXTB : Bool;
|
|
||||||
CFG_VIS_SW : Bool;
|
|
||||||
CFG_VIS_TH : Bool;
|
|
||||||
CFG_VIS_TRIP : Bool;
|
|
||||||
CFG_VIS_PAW : Bool;
|
|
||||||
CFG_VIS_RUN_FWD : Bool;
|
|
||||||
CFG_VIS_RUN_BWD : Bool;
|
|
||||||
CFG_VIS_Kspeed : Bool;
|
|
||||||
CFG_VIS_PLUG : Bool;
|
|
||||||
CFG_VIS_PB_Auto : Bool;
|
|
||||||
CFG_VIS_PB_Man : Bool;
|
|
||||||
CFG_VIS_PB_Jog : Bool;
|
|
||||||
CFG_VIS_PB_Stop : Bool;
|
|
||||||
CFG_VIS_PB_Reverse : Bool;
|
|
||||||
CFG_VIS_PB_sp_05 : Bool;
|
|
||||||
CFG_VIS_PB_sp_06 : Bool;
|
|
||||||
CFG_VIS_ManSpeed : Bool;
|
|
||||||
CFG_VIS_ACT_Torque : Bool;
|
|
||||||
CFG_VIS_ACC_Ramp : Bool;
|
|
||||||
CFG_VIS_DEC_Ramp : Bool;
|
|
||||||
CFG_VIS_X76_3 : Bool;
|
|
||||||
CFG_VIS_X76_4 : Bool;
|
|
||||||
CFG_VIS_X76_5 : Bool;
|
|
||||||
CFG_VIS_X76_6 : Bool;
|
|
||||||
CFG_VIS_X76 : Bool;
|
|
||||||
CFG_B77 : Byte;
|
|
||||||
CFG_W078 : Int;
|
|
||||||
CFG_Add_Signal_SA : UInt;
|
|
||||||
CFG_Add_Signal_SB : UInt;
|
|
||||||
CFG_Add_Signal_SC : UInt;
|
|
||||||
CFG_Add_Signal_SD : UInt;
|
|
||||||
CFG_Add_Signal_BA : UInt;
|
|
||||||
CFG_Add_Signal_BB : UInt;
|
|
||||||
CFG_Add_Signal_EXTA : UInt;
|
|
||||||
CFG_Add_Signal_EXTB : UInt;
|
|
||||||
CFG_Add_Signal_SW : UInt;
|
|
||||||
CFG_Add_Signal_TH : UInt;
|
|
||||||
CFG_Add_Signal_TRIP : UInt;
|
|
||||||
CFG_Add_Signal_PAW : Int;
|
|
||||||
CFG_Add_Signal_RUN_FWD : UInt;
|
|
||||||
CFG_Add_Signal_RUN_BWD : UInt;
|
|
||||||
CFG_Add_Signal_mBar : Int;
|
|
||||||
CFG_Add_Signal_PLUG : Int;
|
|
||||||
CFG_Add_Signal_SP02 : Int;
|
|
||||||
CFG_DB_Machine : Int;
|
|
||||||
CFG_DB_NextMotor : Int;
|
|
||||||
CFG_W118 : Int;
|
|
||||||
CFG_Stop_Empty : Bool;
|
|
||||||
CFG_Stop_Full : Bool;
|
|
||||||
CFG_Stop_STBY : Bool;
|
|
||||||
CFG_Pressurization : Bool;
|
|
||||||
CFG_EOLO_Press_Speed : Int;
|
|
||||||
Spare_124 : Array[124..145] of Byte;
|
|
||||||
CFG_Motor_N : DInt;
|
|
||||||
CFG_Phylosopy_N : Int;
|
|
||||||
CFG_Motor_HW_IO : "HW_IO";
|
|
||||||
CFG_Node_N : Int;
|
|
||||||
CFG_Inverter_Type : Int;
|
|
||||||
CFG_W158 : Int;
|
|
||||||
CFG_Kspeed_User50Hz : Int;
|
|
||||||
CFG_Min_Speed_User : Int;
|
|
||||||
CFG_Max_Speed_User : Int;
|
|
||||||
CFG_W166 : Int;
|
|
||||||
CFG_W168 : Int;
|
|
||||||
CFG_EN_mBar_FCT : Bool;
|
|
||||||
CFG_EN_mBar_FilterALM : Bool;
|
|
||||||
CFG_Isteresi_mBar : Int;
|
|
||||||
CFG_Gain_Mbar : Int;
|
|
||||||
CFG_Max_Speed_FilterALM : Int;
|
|
||||||
CFG_W178 : Int;
|
|
||||||
CFG_T_Gain : STRUCT
|
|
||||||
S : Bool;
|
|
||||||
Q : Bool;
|
|
||||||
TW : Int;
|
|
||||||
ST : Int;
|
|
||||||
ACT : Int;
|
|
||||||
W008 : Int;
|
|
||||||
END_STRUCT;
|
|
||||||
|
|
||||||
CFG_T_FilterALM : STRUCT
|
|
||||||
S : Bool;
|
|
||||||
Q : Bool;
|
|
||||||
TW : Int;
|
|
||||||
ST : Int;
|
|
||||||
ACT : Int;
|
|
||||||
W008 : Int;
|
|
||||||
END_STRUCT;
|
|
||||||
|
|
||||||
IN_PB_Start : Bool;
|
|
||||||
IN_PB_Stop : Bool;
|
|
||||||
IN_PB_Reset : Bool;
|
|
||||||
IN_PB_Silence : Bool;
|
|
||||||
IN_X200_4 : Bool;
|
|
||||||
IN_X200_5 : Bool;
|
|
||||||
IN_X200_6 : Bool;
|
|
||||||
IN_X200_7 : Bool;
|
|
||||||
IN_KG_PowerON : Bool;
|
|
||||||
IN_SW_ManAuto : Bool;
|
|
||||||
IN_Cycle_ON : Bool;
|
|
||||||
IN_X201_3 : Bool;
|
|
||||||
IN_X201_4 : Bool;
|
|
||||||
IN_X201_5 : Bool;
|
|
||||||
IN_X201_6 : Bool;
|
|
||||||
IN_X201_7 : Bool;
|
|
||||||
IN_SW_HMI_Auto : Bool;
|
|
||||||
IN_SW_HMI_Man : Bool;
|
|
||||||
IN_SW_HMI_Jog : Bool;
|
|
||||||
IN_SW_HMI_Stop : Bool;
|
|
||||||
IN_SW_HMI_Reverse : Bool;
|
|
||||||
IN_SW_HMI_sp_05 : Bool;
|
|
||||||
IN_SW_HMI_sp_06 : Bool;
|
|
||||||
IN_SW_HMI_ManSpeed : Bool;
|
|
||||||
IN_SW_HMI_sp_08 : Bool;
|
|
||||||
IN_SW_HMI_VVFix1 : Bool;
|
|
||||||
IN_SW_HMI_VVFix2 : Bool;
|
|
||||||
IN_SW_HMI_VVFix3 : Bool;
|
|
||||||
IN_SW_HMI_VVFix4 : Bool;
|
|
||||||
IN_SW_HMI_VVFix5 : Bool;
|
|
||||||
IN_SW_HMI_sp_14 : Bool;
|
|
||||||
IN_SW_HMI_sp_15 : Bool;
|
|
||||||
IN_HMI_ManSpeed : Int;
|
|
||||||
IN_Signal_SA : Bool;
|
|
||||||
IN_Signal_SB : Bool;
|
|
||||||
IN_Signal_SC : Bool;
|
|
||||||
IN_Signal_SD : Bool;
|
|
||||||
IN_Signal_BA : Bool;
|
|
||||||
IN_Signal_BB : Bool;
|
|
||||||
IN_Signal_EXTA : Bool;
|
|
||||||
IN_Signal_EXTB : Bool;
|
|
||||||
IN_Signal_SW : Bool;
|
|
||||||
IN_Signal_TH : Bool;
|
|
||||||
IN_Signal_TRIP : Bool;
|
|
||||||
IN_Signal_RUN_FWD : Bool;
|
|
||||||
IN_Signal_RUN_BWD : Bool;
|
|
||||||
IN_Signal_sp_05 : Bool;
|
|
||||||
IN_Signal_sp_06 : Bool;
|
|
||||||
IN_Signal_PLUG : Bool;
|
|
||||||
IN_Signal_sp_08 : Int;
|
|
||||||
IN_Signal_PEW_mBar : Int;
|
|
||||||
IN_Signal_mBar : Int;
|
|
||||||
IN_Motor_DI : "Struct";
|
|
||||||
IN_W216 : Int;
|
|
||||||
IN_W218 : Int;
|
|
||||||
IN_Line_Empty : Bool;
|
|
||||||
IN_Line_Full : Bool;
|
|
||||||
IN_Line_StandBy : Bool;
|
|
||||||
Spare_222 : Array[222..249] of Byte;
|
|
||||||
OUT_VFD_Run_FWD : Bool;
|
|
||||||
OUT_VFD_Run_BWD : Bool;
|
|
||||||
OUT_VFD_Reverse : Bool;
|
|
||||||
OUT_VFD_Qstop : Bool;
|
|
||||||
OUT_VFD_Reset : Bool;
|
|
||||||
OUT_X250_5 : Bool;
|
|
||||||
OUT_X250_6 : Bool;
|
|
||||||
OUT_EnergySavingON : Bool;
|
|
||||||
OUT_VFD_REQ_Speed_Hz : Int;
|
|
||||||
OUT_VFD_REQ_Speed_User : Int;
|
|
||||||
OUT_VFD_ACT_Sync_Speed : Int;
|
|
||||||
OUT_VFD_REQ_Speed_mBar : Int;
|
|
||||||
OUT_Motor_DO : "Struct";
|
|
||||||
OUT_W262 : Int;
|
|
||||||
OUT_W264 : Int;
|
|
||||||
OUT_W266 : Int;
|
|
||||||
OUT_W268 : Int;
|
|
||||||
STATUS_VFD_Run_FWD : Bool;
|
|
||||||
STATUS_VFD_Run_BWD : Bool;
|
|
||||||
STATUS_VFD_Trip : Bool;
|
|
||||||
STATUS_VFD_Warning : Bool;
|
|
||||||
STATUS_Ready : Bool;
|
|
||||||
STATUS_VFD_Ready : Bool;
|
|
||||||
STATUS_VFD_Coasting : Bool;
|
|
||||||
STATUS_X270_7 : Bool;
|
|
||||||
STATUS_VFD_ACT_Speed_Hz : Int;
|
|
||||||
STATUS_VFD_ACT_Speed_Use : Int;
|
|
||||||
STATUS_VFD_ACT_Torque : Int;
|
|
||||||
STATUS_MainFault_MovigearADV : Byte;
|
|
||||||
STATUS_Subfault_MovigearADV : Byte;
|
|
||||||
STATUS_W280 : Int;
|
|
||||||
STATUS_W282 : Int;
|
|
||||||
STATUS_PWR_OFF : Bool;
|
|
||||||
STATUS_CYCLE_OFF : Bool;
|
|
||||||
STATUS_ALARM : Bool;
|
|
||||||
STATUS_AUTO : Bool;
|
|
||||||
STATUS_MAN : Bool;
|
|
||||||
STATUS_JOG : Bool;
|
|
||||||
STATUS_STOP : Bool;
|
|
||||||
STATUS_X284_7 : Bool;
|
|
||||||
STATUS_X285_0 : Bool;
|
|
||||||
STATUS_X285_1 : Bool;
|
|
||||||
STATUS_X285_2 : Bool;
|
|
||||||
STATUS_X285_3 : Bool;
|
|
||||||
STATUS_X285_4 : Bool;
|
|
||||||
STATUS_X285_5 : Bool;
|
|
||||||
STATUS_X285_6 : Bool;
|
|
||||||
STATUS_X285_7 : Bool;
|
|
||||||
STATUS_NOTRUN : Bool;
|
|
||||||
STATUS_RUN : Bool;
|
|
||||||
STATUS_X286_2 : Bool;
|
|
||||||
STATUS_X286_3 : Bool;
|
|
||||||
STATUS_X286_4 : Bool;
|
|
||||||
STATUS_X286_5 : Bool;
|
|
||||||
STATUS_X286_6 : Bool;
|
|
||||||
STATUS_X286_7 : Bool;
|
|
||||||
Spare_288 : Array[288..289] of Byte;
|
|
||||||
Alarm_09 : Bool;
|
|
||||||
Alarm_10 : Bool;
|
|
||||||
Alarm_11 : Bool;
|
|
||||||
Alarm_12 : Bool;
|
|
||||||
Alarm_13 : Bool;
|
|
||||||
Alarm_14 : Bool;
|
|
||||||
Alarm_15 : Bool;
|
|
||||||
Alarm_16 : Bool;
|
|
||||||
Alarm_01 : Bool;
|
|
||||||
Alarm_02 : Bool;
|
|
||||||
Alarm_03 : Bool;
|
|
||||||
Alarm_04 : Bool;
|
|
||||||
Alarm_05 : Bool;
|
|
||||||
Alarm_06 : Bool;
|
|
||||||
Alarm_07 : Bool;
|
|
||||||
Alarm_08 : Bool;
|
|
||||||
Spare_292 : Array[292..299] of Byte;
|
|
||||||
M_Power_ON : Bool;
|
|
||||||
M_Cycle_ON_AUTO : Bool;
|
|
||||||
M_Cycle_ON_MAN : Bool;
|
|
||||||
M_W302 : Int;
|
|
||||||
M_W304 : Int;
|
|
||||||
M_W306 : Int;
|
|
||||||
M_W308 : Int;
|
|
||||||
M_Delay_Cycle_ON_Auto : STRUCT
|
|
||||||
S : Bool;
|
|
||||||
Q : Bool;
|
|
||||||
TW : Int;
|
|
||||||
ST : Int;
|
|
||||||
ACT : Int;
|
|
||||||
W008 : Int;
|
|
||||||
END_STRUCT;
|
|
||||||
|
|
||||||
Spare_320 : Array[320..349] of Byte;
|
|
||||||
REQ_EN_Run : Bool;
|
|
||||||
REQ_Start_FWD : Bool;
|
|
||||||
REQ_Start_BWD : Bool;
|
|
||||||
REQ_QStop : Bool;
|
|
||||||
REQ_X350_4 : Bool;
|
|
||||||
REQ_X350_5 : Bool;
|
|
||||||
REQ_X350_6 : Bool;
|
|
||||||
REQ_X350_7 : Bool;
|
|
||||||
REQ_X351_0 : Bool;
|
|
||||||
REQ_X351_1 : Bool;
|
|
||||||
REQ_X351_2 : Bool;
|
|
||||||
REQ_X351_3 : Bool;
|
|
||||||
REQ_X351_4 : Bool;
|
|
||||||
REQ_X351_5 : Bool;
|
|
||||||
REQ_X351_6 : Bool;
|
|
||||||
REQ_X351_7 : Bool;
|
|
||||||
REQ_W352 : Int;
|
|
||||||
REQ_Master_Speed_Sync : Int;
|
|
||||||
REQ_W356 : Int;
|
|
||||||
REQ_Speed_Fix_00_NU : Bool;
|
|
||||||
REQ_Speed_Fix_01 : Bool;
|
|
||||||
REQ_Speed_Fix_02 : Bool;
|
|
||||||
REQ_Speed_Fix_03 : Bool;
|
|
||||||
REQ_Speed_Fix_04 : Bool;
|
|
||||||
REQ_Speed_Fix_05 : Bool;
|
|
||||||
REQ_Speed_Fix_06_NU : Bool;
|
|
||||||
REQ_Speed_Fix_07_NU : Bool;
|
|
||||||
REQ_Speed_Sync_00_NU : Bool;
|
|
||||||
REQ_Speed_Sync_01 : Bool;
|
|
||||||
REQ_Speed_Sync_02 : Bool;
|
|
||||||
REQ_Speed_Sync_03 : Bool;
|
|
||||||
REQ_Speed_Sync_04 : Bool;
|
|
||||||
REQ_Speed_Sync_05 : Bool;
|
|
||||||
REQ_Speed_Sync_06_NU : Bool;
|
|
||||||
REQ_Speed_Sync_07_NU : Bool;
|
|
||||||
REQ_T01 : STRUCT
|
|
||||||
S : Bool;
|
|
||||||
Q : Bool;
|
|
||||||
TW : Int;
|
|
||||||
ST : Int;
|
|
||||||
ACT : Int;
|
|
||||||
W008 : Int;
|
|
||||||
END_STRUCT;
|
|
||||||
|
|
||||||
REQ_T02 : STRUCT
|
|
||||||
S : Bool;
|
|
||||||
Q : Bool;
|
|
||||||
TW : Int;
|
|
||||||
ST : Int;
|
|
||||||
ACT : Int;
|
|
||||||
W008 : Int;
|
|
||||||
END_STRUCT;
|
|
||||||
|
|
||||||
REQ_T03 : STRUCT
|
|
||||||
S : Bool;
|
|
||||||
Q : Bool;
|
|
||||||
TW : Int;
|
|
||||||
ST : Int;
|
|
||||||
ACT : Int;
|
|
||||||
W008 : Int;
|
|
||||||
END_STRUCT;
|
|
||||||
|
|
||||||
REQ_T04 : STRUCT
|
|
||||||
S : Bool;
|
|
||||||
Q : Bool;
|
|
||||||
TW : Int;
|
|
||||||
ST : Int;
|
|
||||||
ACT : Int;
|
|
||||||
W008 : Int;
|
|
||||||
END_STRUCT;
|
|
||||||
|
|
||||||
REQ_T05 : STRUCT
|
|
||||||
S : Bool;
|
|
||||||
Q : Bool;
|
|
||||||
TW : Int;
|
|
||||||
ST : Int;
|
|
||||||
ACT : Int;
|
|
||||||
W008 : Int;
|
|
||||||
END_STRUCT;
|
|
||||||
|
|
||||||
END_STRUCT;
|
|
||||||
|
|
||||||
END_VAR
|
|
||||||
|
|
||||||
VAR_TEMP
|
|
||||||
RetVal : Int;
|
|
||||||
MotorNumber : Int;
|
|
||||||
DBNumber : Int;
|
|
||||||
END_VAR
|
|
||||||
|
|
||||||
BEGIN
|
|
||||||
|
|
||||||
// Network 1: INIT Configuration (Original Language: SCL)
|
|
||||||
|
|
||||||
// SCL extraction failed: StructuredText node not found.
|
|
||||||
|
|
||||||
// Network 2: (Original Language: LAD)
|
|
||||||
|
|
||||||
// Network 2 has no logic elements.
|
|
||||||
|
|
||||||
// Network 3: EN run (Original Language: LAD)
|
|
||||||
|
|
||||||
"Motor"."REQ_EN_Run" := "M0.1";
|
|
||||||
|
|
||||||
// Network 4: REQ Auto RUN (Original Language: LAD)
|
|
||||||
|
|
||||||
"Motor"."REQ_Start_FWD" := TRUE;
|
|
||||||
|
|
||||||
// Network 5: Request Speed Fix 01 (Original Language: LAD)
|
|
||||||
|
|
||||||
"Motor"."REQ_Speed_Fix_01" := "M0.1";
|
|
||||||
|
|
||||||
// Network 6: INIT Configuration (Original Language: SCL)
|
|
||||||
|
|
||||||
// SCL extraction failed: StructuredText node not found.
|
|
||||||
|
|
||||||
END_FUNCTION
|
|
Binary file not shown.
|
@ -6,6 +6,7 @@ import re
|
||||||
# Importar desde las utilidades del parser
|
# Importar desde las utilidades del parser
|
||||||
from .parser_utils import ns, get_multilingual_text
|
from .parser_utils import ns, get_multilingual_text
|
||||||
|
|
||||||
|
|
||||||
def reconstruct_scl_from_tokens(st_node):
|
def reconstruct_scl_from_tokens(st_node):
|
||||||
"""
|
"""
|
||||||
Reconstruye SCL desde <StructuredText>, mejorando el manejo de
|
Reconstruye SCL desde <StructuredText>, mejorando el manejo de
|
||||||
|
@ -15,10 +16,21 @@ def reconstruct_scl_from_tokens(st_node):
|
||||||
return "// Error: StructuredText node not found.\n"
|
return "// Error: StructuredText node not found.\n"
|
||||||
|
|
||||||
scl_parts = []
|
scl_parts = []
|
||||||
# Usar st:* para obtener todos los elementos hijos dentro del namespace st
|
# Usar st:* para obtener todos los elementos hijos, primero con namespace, luego sin namespace
|
||||||
children = st_node.xpath("./st:*", namespaces=ns)
|
children = st_node.xpath("./st:*", namespaces=ns)
|
||||||
|
if not children:
|
||||||
|
# Si no se encuentran con namespace, buscar sin namespace
|
||||||
|
children = st_node.xpath("./*")
|
||||||
|
|
||||||
|
# Set to track elements that have been processed as part of array access
|
||||||
|
processed_elements = set()
|
||||||
|
|
||||||
for elem in children:
|
for elem in children:
|
||||||
|
# Skip elements that have already been processed
|
||||||
|
elem_id = elem.get("UId")
|
||||||
|
if elem_id and elem_id in processed_elements:
|
||||||
|
continue
|
||||||
|
|
||||||
tag = etree.QName(elem.tag).localname
|
tag = etree.QName(elem.tag).localname
|
||||||
|
|
||||||
if tag == "Token":
|
if tag == "Token":
|
||||||
|
@ -27,9 +39,9 @@ def reconstruct_scl_from_tokens(st_node):
|
||||||
# Añadir espacios solo si es necesario o más de uno
|
# Añadir espacios solo si es necesario o más de uno
|
||||||
num_spaces = int(elem.get("Num", 1))
|
num_spaces = int(elem.get("Num", 1))
|
||||||
if not scl_parts or not scl_parts[-1].endswith(" "):
|
if not scl_parts or not scl_parts[-1].endswith(" "):
|
||||||
scl_parts.append(" " * num_spaces)
|
scl_parts.append(" " * num_spaces)
|
||||||
elif num_spaces > 1:
|
elif num_spaces > 1:
|
||||||
scl_parts.append(" " * (num_spaces -1))
|
scl_parts.append(" " * (num_spaces - 1))
|
||||||
|
|
||||||
elif tag == "NewLine":
|
elif tag == "NewLine":
|
||||||
# Quitar espacios finales antes del salto de línea
|
# Quitar espacios finales antes del salto de línea
|
||||||
|
@ -38,129 +50,391 @@ def reconstruct_scl_from_tokens(st_node):
|
||||||
scl_parts.append("\n")
|
scl_parts.append("\n")
|
||||||
elif tag == "Access":
|
elif tag == "Access":
|
||||||
scope = elem.get("Scope")
|
scope = elem.get("Scope")
|
||||||
access_str = f"/*_ERR_Scope_{scope}_*/" # Placeholder
|
access_str = f"/*_ERR_Scope_{scope}_*/" # Placeholder
|
||||||
|
|
||||||
# --- Variables ---
|
# --- Variables ---
|
||||||
if scope in [
|
if scope in [
|
||||||
"GlobalVariable", "LocalVariable", "TempVariable", "InOutVariable",
|
"GlobalVariable",
|
||||||
"InputVariable", "OutputVariable", "ConstantVariable",
|
"LocalVariable",
|
||||||
"GlobalConstant", "LocalConstant" # Añadir constantes simbólicas
|
"TempVariable",
|
||||||
]:
|
"InOutVariable",
|
||||||
|
"InputVariable",
|
||||||
|
"OutputVariable",
|
||||||
|
"ConstantVariable",
|
||||||
|
"GlobalConstant",
|
||||||
|
"LocalConstant", # Añadir constantes simbólicas
|
||||||
|
]:
|
||||||
|
# Buscar Symbol tanto con namespace st: como sin namespace
|
||||||
symbol_elem = elem.xpath("./st:Symbol", namespaces=ns)
|
symbol_elem = elem.xpath("./st:Symbol", namespaces=ns)
|
||||||
|
if not symbol_elem:
|
||||||
|
symbol_elem = elem.xpath("./Symbol")
|
||||||
|
|
||||||
if symbol_elem:
|
if symbol_elem:
|
||||||
|
# Buscar Components tanto con namespace st: como sin namespace
|
||||||
components = symbol_elem[0].xpath("./st:Component", namespaces=ns)
|
components = symbol_elem[0].xpath("./st:Component", namespaces=ns)
|
||||||
|
if not components:
|
||||||
|
components = symbol_elem[0].xpath("./Component")
|
||||||
symbol_text_parts = []
|
symbol_text_parts = []
|
||||||
for i, comp in enumerate(components):
|
for i, comp in enumerate(components):
|
||||||
name = comp.get("Name", "_ERR_COMP_")
|
name = comp.get("Name", "_ERR_COMP_")
|
||||||
if i > 0: symbol_text_parts.append(".")
|
if i > 0:
|
||||||
|
symbol_text_parts.append(".")
|
||||||
|
|
||||||
# Check for HasQuotes attribute (adjust namespace if needed)
|
# Check for HasQuotes attribute (adjust namespace if needed)
|
||||||
# El atributo está en el Component o en el Access padre? Probar ambos
|
# El atributo está en el Component o en el Access padre? Probar ambos
|
||||||
has_quotes_comp = comp.get("HasQuotes", "false").lower() == "true" # Check directly on Component
|
has_quotes_comp = (
|
||||||
|
comp.get("HasQuotes", "false").lower() == "true"
|
||||||
|
) # Check directly on Component
|
||||||
has_quotes_access = False
|
has_quotes_access = False
|
||||||
access_parent = comp.xpath("ancestor::st:Access[1]", namespaces=ns) # Get immediate Access parent
|
|
||||||
|
# Buscar BooleanAttribute tanto con namespace como sin namespace
|
||||||
|
access_parent = comp.xpath(
|
||||||
|
"ancestor::st:Access[1]", namespaces=ns
|
||||||
|
) # Get immediate Access parent with namespace
|
||||||
|
if not access_parent:
|
||||||
|
access_parent = comp.xpath(
|
||||||
|
"ancestor::Access[1]"
|
||||||
|
) # Get immediate Access parent without namespace
|
||||||
|
|
||||||
if access_parent:
|
if access_parent:
|
||||||
has_quotes_attr = access_parent[0].xpath("./st:BooleanAttribute[@Name='HasQuotes']/text()", namespaces=ns)
|
has_quotes_attr = access_parent[0].xpath(
|
||||||
has_quotes_access = has_quotes_attr and has_quotes_attr[0].lower() == 'true'
|
"./st:BooleanAttribute[@Name='HasQuotes']/text()",
|
||||||
|
namespaces=ns,
|
||||||
|
)
|
||||||
|
if not has_quotes_attr:
|
||||||
|
has_quotes_attr = access_parent[0].xpath(
|
||||||
|
"./BooleanAttribute[@Name='HasQuotes']/text()"
|
||||||
|
)
|
||||||
|
has_quotes_access = (
|
||||||
|
has_quotes_attr and has_quotes_attr[0].lower() == "true"
|
||||||
|
)
|
||||||
|
|
||||||
has_quotes = has_quotes_comp or has_quotes_access
|
has_quotes = has_quotes_comp or has_quotes_access
|
||||||
is_temp = name.startswith("#")
|
is_temp = name.startswith("#")
|
||||||
|
|
||||||
# Apply quotes based on HasQuotes or if it's the first component and not temp
|
# Apply quotes based on HasQuotes or if it's the first component and not temp
|
||||||
if has_quotes or (i == 0 and not is_temp and '"' not in name): # Avoid double quotes
|
if has_quotes or (
|
||||||
|
i == 0 and not is_temp and '"' not in name
|
||||||
|
): # Avoid double quotes
|
||||||
symbol_text_parts.append(f'"{name}"')
|
symbol_text_parts.append(f'"{name}"')
|
||||||
else:
|
else:
|
||||||
symbol_text_parts.append(name)
|
symbol_text_parts.append(name)
|
||||||
|
|
||||||
# --- Array Index Access ---
|
# --- Array Index Access ---
|
||||||
index_access_nodes = comp.xpath("./st:Access", namespaces=ns)
|
# Verificar si este componente tiene hijos que indican acceso de array
|
||||||
if index_access_nodes:
|
# Buscar estructura: <Token Text="["/> <Access.../> <Token Text="]"/>
|
||||||
# Llamada recursiva para cada índice
|
children = comp.xpath("./*") # Todos los hijos directos
|
||||||
indices_text = [reconstruct_scl_from_tokens(idx_node) for idx_node in index_access_nodes]
|
|
||||||
# Limpiar saltos de línea dentro de los corchetes
|
if len(children) >= 3:
|
||||||
indices_cleaned = [idx.replace('\n', '').strip() for idx in indices_text]
|
# Verificar patrón: primer hijo es Token "[", último es Token "]"
|
||||||
symbol_text_parts.append(f"[{','.join(indices_cleaned)}]")
|
first_child = children[0]
|
||||||
|
last_child = children[-1]
|
||||||
|
first_is_open_bracket = (
|
||||||
|
etree.QName(first_child.tag).localname == "Token"
|
||||||
|
and first_child.get("Text") == "["
|
||||||
|
)
|
||||||
|
last_is_close_bracket = (
|
||||||
|
etree.QName(last_child.tag).localname == "Token"
|
||||||
|
and last_child.get("Text") == "]"
|
||||||
|
)
|
||||||
|
|
||||||
|
if first_is_open_bracket and last_is_close_bracket:
|
||||||
|
# Hay acceso de array - procesar los elementos entre los corchetes
|
||||||
|
indices_parts = []
|
||||||
|
|
||||||
|
# Mark the bracket tokens and middle elements as processed
|
||||||
|
first_uid = first_child.get("UId")
|
||||||
|
last_uid = last_child.get("UId")
|
||||||
|
if first_uid:
|
||||||
|
processed_elements.add(first_uid)
|
||||||
|
if last_uid:
|
||||||
|
processed_elements.add(last_uid)
|
||||||
|
|
||||||
|
for middle_child in children[
|
||||||
|
1:-1
|
||||||
|
]: # Todo excepto primer y último hijo
|
||||||
|
middle_uid = middle_child.get("UId")
|
||||||
|
if middle_uid:
|
||||||
|
processed_elements.add(middle_uid)
|
||||||
|
|
||||||
|
child_tag = etree.QName(middle_child.tag).localname
|
||||||
|
if child_tag == "Access":
|
||||||
|
# Procesar el Access para obtener el índice
|
||||||
|
scope = middle_child.get("Scope")
|
||||||
|
if scope == "LiteralConstant":
|
||||||
|
# Buscar el valor de la constante - tanto con namespace como sin namespace
|
||||||
|
constant_elem = middle_child.xpath(
|
||||||
|
"./st:Constant", namespaces=ns
|
||||||
|
)
|
||||||
|
if not constant_elem:
|
||||||
|
constant_elem = middle_child.xpath(
|
||||||
|
"./Constant"
|
||||||
|
)
|
||||||
|
|
||||||
|
if constant_elem:
|
||||||
|
# Buscar ConstantValue tanto con namespace como sin namespace
|
||||||
|
val_nodes = constant_elem[0].xpath(
|
||||||
|
"./st:ConstantValue", namespaces=ns
|
||||||
|
)
|
||||||
|
if not val_nodes:
|
||||||
|
val_nodes = constant_elem[0].xpath(
|
||||||
|
"./ConstantValue"
|
||||||
|
)
|
||||||
|
|
||||||
|
if val_nodes and val_nodes[0].text:
|
||||||
|
indices_parts.append(
|
||||||
|
val_nodes[0].text.strip()
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
# Para otros tipos de acceso, usar la función recursiva
|
||||||
|
idx_result = reconstruct_scl_from_tokens(
|
||||||
|
middle_child
|
||||||
|
)
|
||||||
|
if idx_result and idx_result.strip():
|
||||||
|
indices_parts.append(idx_result.strip())
|
||||||
|
elif child_tag == "Token":
|
||||||
|
# Token de separación (como ",")
|
||||||
|
token_text = middle_child.get("Text", "")
|
||||||
|
if token_text.strip():
|
||||||
|
indices_parts.append(token_text)
|
||||||
|
|
||||||
|
if indices_parts:
|
||||||
|
symbol_text_parts.append(
|
||||||
|
f"[{','.join(indices_parts)}]"
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
# No es acceso de array, buscar Access anidados de la forma tradicional
|
||||||
|
index_access_nodes = comp.xpath(
|
||||||
|
"./st:Access", namespaces=ns
|
||||||
|
)
|
||||||
|
if not index_access_nodes:
|
||||||
|
index_access_nodes = comp.xpath("./Access")
|
||||||
|
|
||||||
|
if index_access_nodes:
|
||||||
|
indices_text = [
|
||||||
|
reconstruct_scl_from_tokens(idx_node)
|
||||||
|
for idx_node in index_access_nodes
|
||||||
|
]
|
||||||
|
indices_cleaned = [
|
||||||
|
idx.replace("\n", "").strip()
|
||||||
|
for idx in indices_text
|
||||||
|
]
|
||||||
|
symbol_text_parts.append(
|
||||||
|
f"[{','.join(indices_cleaned)}]"
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
# Menos de 3 hijos, usar búsqueda tradicional de Access
|
||||||
|
index_access_nodes = comp.xpath(
|
||||||
|
"./st:Access", namespaces=ns
|
||||||
|
)
|
||||||
|
if not index_access_nodes:
|
||||||
|
index_access_nodes = comp.xpath("./Access")
|
||||||
|
|
||||||
|
if index_access_nodes:
|
||||||
|
indices_text = [
|
||||||
|
reconstruct_scl_from_tokens(idx_node)
|
||||||
|
for idx_node in index_access_nodes
|
||||||
|
]
|
||||||
|
indices_cleaned = [
|
||||||
|
idx.replace("\n", "").strip()
|
||||||
|
for idx in indices_text
|
||||||
|
]
|
||||||
|
symbol_text_parts.append(
|
||||||
|
f"[{','.join(indices_cleaned)}]"
|
||||||
|
)
|
||||||
|
|
||||||
access_str = "".join(symbol_text_parts)
|
access_str = "".join(symbol_text_parts)
|
||||||
else:
|
else:
|
||||||
access_str = f"/*_ERR_NO_SYMBOL_IN_{scope}_*/"
|
access_str = f"/*_ERR_NO_SYMBOL_IN_{scope}_*/"
|
||||||
|
|
||||||
# --- Constantes Literales ---
|
# --- Constantes Literales ---
|
||||||
elif scope == "LiteralConstant":
|
elif scope == "LiteralConstant":
|
||||||
|
# Buscar nodos Constant tanto con namespace st: como sin namespace
|
||||||
constant_elem = elem.xpath("./st:Constant", namespaces=ns)
|
constant_elem = elem.xpath("./st:Constant", namespaces=ns)
|
||||||
|
if not constant_elem:
|
||||||
|
# Si no se encuentran con namespace, buscar sin namespace
|
||||||
|
constant_elem = elem.xpath("./Constant")
|
||||||
|
|
||||||
if constant_elem:
|
if constant_elem:
|
||||||
val_elem = constant_elem[0].xpath("./st:ConstantValue/text()", namespaces=ns)
|
# Buscar ConstantValue tanto con namespace como sin namespace
|
||||||
type_elem = constant_elem[0].xpath("./st:ConstantType/text()", namespaces=ns)
|
val_elem = constant_elem[0].xpath(
|
||||||
const_type = type_elem[0].strip().lower() if type_elem and type_elem[0] is not None else ""
|
"./st:ConstantValue/text()", namespaces=ns
|
||||||
const_val = val_elem[0].strip() if val_elem and val_elem[0] is not None else "_ERR_CONSTVAL_"
|
)
|
||||||
|
if not val_elem:
|
||||||
|
val_elem = constant_elem[0].xpath("./ConstantValue/text()")
|
||||||
|
|
||||||
|
# Si no hay texto directo, buscar el texto del nodo ConstantValue
|
||||||
|
if not val_elem:
|
||||||
|
val_nodes = constant_elem[0].xpath("./ConstantValue")
|
||||||
|
if val_nodes and val_nodes[0].text:
|
||||||
|
val_elem = [val_nodes[0].text]
|
||||||
|
|
||||||
|
# Buscar ConstantType tanto con namespace como sin namespace
|
||||||
|
type_elem = constant_elem[0].xpath(
|
||||||
|
"./st:ConstantType/text()", namespaces=ns
|
||||||
|
)
|
||||||
|
if not type_elem:
|
||||||
|
type_elem = constant_elem[0].xpath("./ConstantType/text()")
|
||||||
|
|
||||||
|
const_val = (
|
||||||
|
val_elem[0].strip()
|
||||||
|
if val_elem and val_elem[0] is not None
|
||||||
|
else "_ERR_CONSTVAL_"
|
||||||
|
)
|
||||||
|
const_type = (
|
||||||
|
type_elem[0].strip().lower()
|
||||||
|
if type_elem and type_elem[0] is not None
|
||||||
|
else ""
|
||||||
|
)
|
||||||
|
|
||||||
|
# Si no hay tipo explícito, inferir de acuerdo al valor
|
||||||
|
if not const_type:
|
||||||
|
if const_val.lower() in ["true", "false"]:
|
||||||
|
const_type = "bool"
|
||||||
|
elif const_val.startswith("'") and const_val.endswith("'"):
|
||||||
|
const_type = "string"
|
||||||
|
elif const_val.isdigit() or (
|
||||||
|
const_val.startswith("-") and const_val[1:].isdigit()
|
||||||
|
):
|
||||||
|
const_type = "int"
|
||||||
|
elif "." in const_val:
|
||||||
|
const_type = "real"
|
||||||
|
else:
|
||||||
|
const_type = "" # Sin tipo específico, usar valor directo
|
||||||
|
|
||||||
# Formatear según tipo
|
# Formatear según tipo
|
||||||
if const_type == "bool": access_str = const_val.upper()
|
if const_type == "bool":
|
||||||
elif const_type.lower() == "string":
|
access_str = const_val.upper()
|
||||||
replaced_val = const_val.replace("'", "''")
|
elif const_type.lower() == "string":
|
||||||
access_str = f"'{replaced_val}'"
|
if not (const_val.startswith("'") and const_val.endswith("'")):
|
||||||
elif const_type.lower() == "char":
|
replaced_val = const_val.replace("'", "''")
|
||||||
replaced_val = const_val.replace("'", "''")
|
access_str = f"'{replaced_val}'"
|
||||||
access_str = f"'{replaced_val}'"
|
else:
|
||||||
elif const_type == "wstring":
|
access_str = const_val
|
||||||
|
elif const_type.lower() == "char":
|
||||||
|
if not (const_val.startswith("'") and const_val.endswith("'")):
|
||||||
|
replaced_val = const_val.replace("'", "''")
|
||||||
|
access_str = f"'{replaced_val}'"
|
||||||
|
else:
|
||||||
|
access_str = const_val
|
||||||
|
elif const_type == "wstring":
|
||||||
replaced_val = const_val.replace("'", "''")
|
replaced_val = const_val.replace("'", "''")
|
||||||
access_str = f"WSTRING#'{replaced_val}'"
|
access_str = f"WSTRING#'{replaced_val}'"
|
||||||
elif const_type == "wchar":
|
elif const_type == "wchar":
|
||||||
replaced_val = const_val.replace("'", "''")
|
replaced_val = const_val.replace("'", "''")
|
||||||
access_str = f"WCHAR#'{replaced_val}'"
|
access_str = f"WCHAR#'{replaced_val}'"
|
||||||
elif const_type == "time": access_str = f"T#{const_val}"
|
elif const_type == "time":
|
||||||
elif const_type == "ltime": access_str = f"LT#{const_val}"
|
access_str = (
|
||||||
elif const_type == "s5time": access_str = f"S5T#{const_val}"
|
f"T#{const_val}"
|
||||||
elif const_type == "date": access_str = f"D#{const_val}"
|
if not const_val.startswith("T#")
|
||||||
elif const_type == "dtl": access_str = f"DTL#{const_val}"
|
else const_val
|
||||||
elif const_type == "dt": access_str = f"DT#{const_val}"
|
)
|
||||||
elif const_type == "tod": access_str = f"TOD#{const_val}"
|
elif const_type == "ltime":
|
||||||
elif const_type in ["int", "dint", "sint", "usint", "uint", "udint", "real", "lreal", "word", "dword", "byte"]:
|
access_str = (
|
||||||
# Añadir .0 para reales si no tienen decimal
|
f"LT#{const_val}"
|
||||||
if const_type in ["real", "lreal"] and '.' not in const_val and 'e' not in const_val.lower():
|
if not const_val.startswith("LT#")
|
||||||
access_str = f"{const_val}.0"
|
else const_val
|
||||||
else:
|
)
|
||||||
access_str = const_val
|
elif const_type == "s5time":
|
||||||
else: # Otros tipos (LWORD, etc.) o desconocidos
|
access_str = (
|
||||||
|
f"S5T#{const_val}"
|
||||||
|
if not const_val.startswith("S5T#")
|
||||||
|
else const_val
|
||||||
|
)
|
||||||
|
elif const_type == "date":
|
||||||
|
access_str = (
|
||||||
|
f"D#{const_val}"
|
||||||
|
if not const_val.startswith("D#")
|
||||||
|
else const_val
|
||||||
|
)
|
||||||
|
elif const_type == "dtl":
|
||||||
|
access_str = (
|
||||||
|
f"DTL#{const_val}"
|
||||||
|
if not const_val.startswith("DTL#")
|
||||||
|
else const_val
|
||||||
|
)
|
||||||
|
elif const_type == "dt":
|
||||||
|
access_str = (
|
||||||
|
f"DT#{const_val}"
|
||||||
|
if not const_val.startswith("DT#")
|
||||||
|
else const_val
|
||||||
|
)
|
||||||
|
elif const_type == "tod":
|
||||||
|
access_str = (
|
||||||
|
f"TOD#{const_val}"
|
||||||
|
if not const_val.startswith("TOD#")
|
||||||
|
else const_val
|
||||||
|
)
|
||||||
|
elif const_type in [
|
||||||
|
"int",
|
||||||
|
"dint",
|
||||||
|
"sint",
|
||||||
|
"usint",
|
||||||
|
"uint",
|
||||||
|
"udint",
|
||||||
|
"real",
|
||||||
|
"lreal",
|
||||||
|
"word",
|
||||||
|
"dword",
|
||||||
|
"byte",
|
||||||
|
]:
|
||||||
|
# Añadir .0 para reales si no tienen decimal
|
||||||
|
if (
|
||||||
|
const_type in ["real", "lreal"]
|
||||||
|
and "." not in const_val
|
||||||
|
and "e" not in const_val.lower()
|
||||||
|
):
|
||||||
|
access_str = f"{const_val}.0"
|
||||||
|
else:
|
||||||
|
access_str = const_val
|
||||||
|
else: # Otros tipos o sin tipo específico - usar valor directo
|
||||||
access_str = const_val
|
access_str = const_val
|
||||||
else:
|
else:
|
||||||
access_str = "/*_ERR_NOCONST_*/"
|
access_str = "/*_ERR_NOCONST_*/"
|
||||||
|
|
||||||
# --- Llamadas a Funciones/Bloques (Scope=Call) ---
|
# --- Llamadas a Funciones/Bloques (Scope=Call) ---
|
||||||
elif scope == "Call":
|
elif scope == "Call":
|
||||||
call_info_node = elem.xpath("./st:CallInfo", namespaces=ns)
|
call_info_node = elem.xpath("./st:CallInfo", namespaces=ns)
|
||||||
if call_info_node:
|
if call_info_node:
|
||||||
ci = call_info_node[0]
|
ci = call_info_node[0]
|
||||||
call_name = ci.get("Name", "_ERR_CALLNAME_")
|
call_name = ci.get("Name", "_ERR_CALLNAME_")
|
||||||
call_type = ci.get("BlockType") # FB, FC, etc.
|
call_type = ci.get("BlockType") # FB, FC, etc.
|
||||||
|
|
||||||
# Parámetros (están como Access o Token dentro de CallInfo/Parameter)
|
# Parámetros (están como Access o Token dentro de CallInfo/Parameter)
|
||||||
params = ci.xpath("./st:Parameter", namespaces=ns)
|
params = ci.xpath("./st:Parameter", namespaces=ns)
|
||||||
param_parts = []
|
param_parts = []
|
||||||
for p in params:
|
for p in params:
|
||||||
p_name = p.get("Name", "_ERR_PARAMNAME_")
|
p_name = p.get("Name", "_ERR_PARAMNAME_")
|
||||||
# El valor del parámetro está dentro del nodo Parameter
|
# El valor del parámetro está dentro del nodo Parameter
|
||||||
p_value_node = p.xpath("./st:Access | ./st:Token", namespaces=ns) # Buscar Access o Token
|
p_value_node = p.xpath(
|
||||||
p_value_scl = ""
|
"./st:Access | ./st:Token", namespaces=ns
|
||||||
if p_value_node:
|
) # Buscar Access o Token
|
||||||
p_value_scl = reconstruct_scl_from_tokens(p) # Parsear el contenido del parámetro
|
p_value_scl = ""
|
||||||
p_value_scl = p_value_scl.replace('\n', '').strip() # Limpiar SCL resultante
|
if p_value_node:
|
||||||
param_parts.append(f"{p_name} := {p_value_scl}")
|
p_value_scl = reconstruct_scl_from_tokens(
|
||||||
|
p
|
||||||
|
) # Parsear el contenido del parámetro
|
||||||
|
p_value_scl = p_value_scl.replace(
|
||||||
|
"\n", ""
|
||||||
|
).strip() # Limpiar SCL resultante
|
||||||
|
param_parts.append(f"{p_name} := {p_value_scl}")
|
||||||
|
|
||||||
# Manejar FB vs FC
|
# Manejar FB vs FC
|
||||||
if call_type == "FB":
|
if call_type == "FB":
|
||||||
instance_node = ci.xpath("./st:Instance/st:Component/@Name", namespaces=ns)
|
instance_node = ci.xpath(
|
||||||
if instance_node:
|
"./st:Instance/st:Component/@Name", namespaces=ns
|
||||||
instance_name = f'"{instance_node[0]}"'
|
)
|
||||||
access_str = f"{instance_name}({', '.join(param_parts)})"
|
if instance_node:
|
||||||
else: # FB sin instancia? Podría ser STAT
|
instance_name = f'"{instance_node[0]}"'
|
||||||
access_str = f'"{call_name}"({", ".join(param_parts)}) (* FB sin instancia explícita? *)'
|
access_str = f"{instance_name}({', '.join(param_parts)})"
|
||||||
elif call_type == "FC":
|
else: # FB sin instancia? Podría ser STAT
|
||||||
access_str = f'"{call_name}"({", ".join(param_parts)})'
|
access_str = f'"{call_name}"({", ".join(param_parts)}) (* FB sin instancia explícita? *)'
|
||||||
else: # Otros tipos de llamada
|
elif call_type == "FC":
|
||||||
access_str = f'"{call_name}"({", ".join(param_parts)}) (* Tipo: {call_type} *)'
|
access_str = f'"{call_name}"({", ".join(param_parts)})'
|
||||||
else:
|
else: # Otros tipos de llamada
|
||||||
access_str = "/*_ERR_NO_CALLINFO_*/"
|
access_str = f'"{call_name}"({", ".join(param_parts)}) (* Tipo: {call_type} *)'
|
||||||
|
else:
|
||||||
|
access_str = "/*_ERR_NO_CALLINFO_*/"
|
||||||
|
|
||||||
# Añadir más scopes si son necesarios (e.g., Address, Label, Reference)
|
# Añadir más scopes si son necesarios (e.g., Address, Label, Reference)
|
||||||
|
|
||||||
|
@ -180,7 +454,7 @@ def reconstruct_scl_from_tokens(st_node):
|
||||||
# --- Re-indentación Simple ---
|
# --- Re-indentación Simple ---
|
||||||
output_lines = []
|
output_lines = []
|
||||||
indent_level = 0
|
indent_level = 0
|
||||||
indent_str = " " # Dos espacios
|
indent_str = " " # Dos espacios
|
||||||
for line in full_scl.splitlines():
|
for line in full_scl.splitlines():
|
||||||
trimmed_line = line.strip()
|
trimmed_line = line.strip()
|
||||||
if not trimmed_line:
|
if not trimmed_line:
|
||||||
|
@ -189,8 +463,9 @@ def reconstruct_scl_from_tokens(st_node):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Reducir indentación ANTES de imprimir para END, ELSE, etc.
|
# Reducir indentación ANTES de imprimir para END, ELSE, etc.
|
||||||
if trimmed_line.upper().startswith(("END_", "UNTIL", "}")) or \
|
if trimmed_line.upper().startswith(
|
||||||
trimmed_line.upper() in ["ELSE", "ELSIF"]:
|
("END_", "UNTIL", "}")
|
||||||
|
) or trimmed_line.upper() in ["ELSE", "ELSIF"]:
|
||||||
indent_level = max(0, indent_level - 1)
|
indent_level = max(0, indent_level - 1)
|
||||||
|
|
||||||
output_lines.append(indent_str * indent_level + trimmed_line)
|
output_lines.append(indent_str * indent_level + trimmed_line)
|
||||||
|
@ -199,12 +474,16 @@ def reconstruct_scl_from_tokens(st_node):
|
||||||
# Ser más específico con las palabras clave que aumentan indentación
|
# Ser más específico con las palabras clave que aumentan indentación
|
||||||
# Usar .upper() para ignorar mayúsculas/minúsculas
|
# Usar .upper() para ignorar mayúsculas/minúsculas
|
||||||
line_upper = trimmed_line.upper()
|
line_upper = trimmed_line.upper()
|
||||||
if line_upper.endswith(("THEN", "DO", "OF", "{")) or \
|
if (
|
||||||
line_upper.startswith(("IF ", "FOR ", "WHILE ", "CASE ", "REPEAT", "STRUCT")) or \
|
line_upper.endswith(("THEN", "DO", "OF", "{"))
|
||||||
line_upper == "ELSE":
|
or line_upper.startswith(
|
||||||
# Excepción: No indentar después de ELSE IF
|
("IF ", "FOR ", "WHILE ", "CASE ", "REPEAT", "STRUCT")
|
||||||
if not (line_upper == "ELSE" and "IF" in output_lines[-1].upper()):
|
)
|
||||||
indent_level += 1
|
or line_upper == "ELSE"
|
||||||
|
):
|
||||||
|
# Excepción: No indentar después de ELSE IF
|
||||||
|
if not (line_upper == "ELSE" and "IF" in output_lines[-1].upper()):
|
||||||
|
indent_level += 1
|
||||||
|
|
||||||
return "\n".join(output_lines)
|
return "\n".join(output_lines)
|
||||||
|
|
||||||
|
@ -221,7 +500,9 @@ def parse_scl_network(network_element):
|
||||||
title_elem = network_element.xpath(
|
title_elem = network_element.xpath(
|
||||||
"./ObjectList/MultilingualText[@CompositionName='Title']", namespaces=ns
|
"./ObjectList/MultilingualText[@CompositionName='Title']", namespaces=ns
|
||||||
)
|
)
|
||||||
network_title = get_multilingual_text(title_elem[0]) if title_elem else f"Network {network_id}"
|
network_title = (
|
||||||
|
get_multilingual_text(title_elem[0]) if title_elem else f"Network {network_id}"
|
||||||
|
)
|
||||||
|
|
||||||
comment_elem = network_element.xpath(
|
comment_elem = network_element.xpath(
|
||||||
"./ObjectList/MultilingualText[@CompositionName='Comment']", namespaces=ns
|
"./ObjectList/MultilingualText[@CompositionName='Comment']", namespaces=ns
|
||||||
|
@ -255,10 +536,11 @@ def parse_scl_network(network_element):
|
||||||
}
|
}
|
||||||
return parsed_network_data
|
return parsed_network_data
|
||||||
|
|
||||||
|
|
||||||
# --- Función de Información del Parser ---
|
# --- Función de Información del Parser ---
|
||||||
def get_parser_info():
|
def get_parser_info():
|
||||||
"""Devuelve la información para este parser."""
|
"""Devuelve la información para este parser."""
|
||||||
return {
|
return {
|
||||||
'language': ['SCL'], # Lista de lenguajes soportados
|
"language": ["SCL"], # Lista de lenguajes soportados
|
||||||
'parser_func': parse_scl_network # Función a llamar
|
"parser_func": parse_scl_network, # Función a llamar
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,5 +40,17 @@
|
||||||
"short_description": "3: Limpiar archivos json y md generados por (1)",
|
"short_description": "3: Limpiar archivos json y md generados por (1)",
|
||||||
"long_description": "",
|
"long_description": "",
|
||||||
"hidden": false
|
"hidden": false
|
||||||
|
},
|
||||||
|
"debug_array_parsing.py": {
|
||||||
|
"display_name": "debug_array_parsing",
|
||||||
|
"short_description": "Sin descripción corta.",
|
||||||
|
"long_description": "",
|
||||||
|
"hidden": false
|
||||||
|
},
|
||||||
|
"test_conversion.py": {
|
||||||
|
"display_name": "test_conversion",
|
||||||
|
"short_description": "Sin descripción corta.",
|
||||||
|
"long_description": "",
|
||||||
|
"hidden": false
|
||||||
}
|
}
|
||||||
}
|
}
|
14935
data/log.txt
14935
data/log.txt
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue