Funcionando con IF basicos

This commit is contained in:
Miguel 2025-04-15 18:15:39 +02:00
parent 06b2698ada
commit 185bcdd733
2 changed files with 0 additions and 422 deletions

View File

@ -1,422 +0,0 @@
class BlenderCtrl__Main:
def __init__(self):
# Initialize variables for BlenderCtrl__Main (FC2000)
# Temp variables
self.All_Auto_RETVAL = 0 # Int
self.Reset_SP_Word_RETVAL = 0 # Int
self.mResetWaterTot = False # Bool
self.mResetSyrupTot = False # Bool
self.mResetCO2Tot = False # Bool
self.mResetProductTot = False # Bool
self.Block_Move_Err = 0 # Int
# Common system variables
self.AUX_FALSE = False
self.Clock_10ms = False
self.Clock_100ms = False
self.Clock_1s = False
self.Clock_Counter = 0
self.MachineState = 0
self.SystemError = False
self.MachineInitialized = False
# HMI and control variables
self.HMI_PID = None
self.Filler_Head_Variables = None
self.gIN_VoltageOk = False
self.M19000 = False
self.gEmergencyPressed = False
# System state indicators
self.Air_Pressure_OK = False
self.CO2_Pressure_OK = False
self.System_Pressure_OK = False
self.Temperature_Current = 0.0
self.Temperature_Max = 0.0
self.Temperature_Alarm = False
self.Tank_Level = 0.0
self.Tank_Level_Min = 0.0
self.Tank_Level_Low = False
# Mode controls
self.Reset_Command = False
self.Reset_Complete = False
self.Totalizer_Value = 0
self.HMI_Manual_Mode_Requested = False
self.System_In_Manual_Mode = False
self.System_In_Auto_Mode = False
self.Production_Mode = False
self.CIP_Mode = False
def run(self):
# Network 1: Clock Generation
self.Clock_Signal()
# Network 2: Machine Init
self.BlenderCtrl_MachineInit()
# Network 3: Filler Head
# Procesamiento de variables de cabezal de llenado
if self.AUX_FALSE:
# Implementación del BLKMOV para cabezal
self.Filler_Head_Variables.FillerHead = self.HMI_PID.PPM303
self.Block_Move_Err = self.resultado_operacion
# Network 4: Emergency Pressed
# Control de parada de emergencia
if self.gIN_VoltageOk and not self.M19000:
self.gEmergencyPressed = True
# Network 5: Air and CO2 pressure ok and auxiliary ok
# Verificación de presión de CO2 y aire
if self.Air_Pressure_OK and self.CO2_Pressure_OK:
self.System_Pressure_OK = True
# Network 6: Blender State Num
# Control del estado del mezclador
if self.System_Pressure_OK:
if self.Production_Mode:
self.MachineState = 1 # Production state
elif self.CIP_Mode:
self.MachineState = 2 # CIP state
else:
self.MachineState = 0 # Idle state
# Network 7: Delay Power On
# Retardo al encendido para estabilización
if self.Clock_1s:
self.Power_On_Delay_Counter += 1
if self.Power_On_Delay_Counter >= 5: # 5 segundos de retardo
self.System_Ready = True
# Network 8: Production Mode
# Activación del modo de producción
if self.Production_Mode_Request and self.System_Ready and not self.CIP_Mode:
self.Production_Mode = True
self.CIP_Mode = False
# Network 9: CIp Mode
# Activación del modo de limpieza CIP
if self.CIP_Mode_Request and self.System_Ready and not self.Production_Mode:
self.CIP_Mode = True
self.Production_Mode = False
# Network 10: Error Faults
# Gestión de errores del sistema
if self.Error_Detected or self.Safety_Fault:
self.SystemError = True
self.Error_Reset_Required = True
# Network 11: Filler Bottle Count Used to push Product
# Control de conteo de botellas para empujar producto
if self.Bottle_Detected:
self.Bottle_Counter += 1
if (
self.Production_Mode
and self.Bottle_Counter >= self.Min_Bottles_For_Push
):
self.Start_Product_Push = True
# Network 12: Water Bypass Enable
# Habilitación de bypass de agua
if self.Water_Bypass_Request and self.System_In_Manual_Mode:
self.Water_Bypass_Enabled = True
# Network 13: Still Water Bypass
# Control de bypass de agua sin gas
if self.Still_Water_Request and self.Water_Bypass_Enabled:
self.Open_Still_Water_Valve = True
# Network 14: Manual Syrup Drain Valve Open - Operator Alarm
# Alarma de válvula de drenaje de jarabe abierta manualmente
if self.Syrup_Drain_Valve_Open and self.Production_Mode:
self.Syrup_Drain_Open_Alarm = True
self.Operator_Attention_Required = True
# Network 15: Manual Syrup Drain Valve Open - Operator Alarm
# Redundancia para alarma de válvula de drenaje
if self.Syrup_Drain_Open_Alarm:
self.Flash_HMI_Warning()
# Network 16: Maselli Control
# Control del sistema Maselli de medición Brix
self.Maselli_Control()
# Network 17: mPDS Control
# Control del sistema mPDS
self.mPDS_Control()
# Network 18: mPDS Syrup Control
# Control de jarabe mediante mPDS
self.mPDS_Syrup_Control()
# Network 19: Co2 Analog Input
# Lectura de entrada analógica de CO2
self.GetProdBrixCO2_FromAn()
# Network 20: Quality
# Control de calidad del producto
self.Quality_Check()
# Network 21: Input Data
# Procesamiento de datos de entrada
self.Process_Input_Data()
# Network 22: Sel Brix Source Check
# Verificación de fuente Brix seleccionada
if self.Brix_Source_Selected == 1:
self.Use_Maselli_Brix()
elif self.Brix_Source_Selected == 2:
self.Use_mPDS_Brix()
# Network 23: Check Water Cooling System Temperature
# Control de temperatura del sistema de enfriamiento de agua
if self.Temperature_Current > self.Temperature_Max:
self.Temperature_Alarm = True
self.Activate_Cooling()
# Network 24: Tank Level
# Monitoreo de nivel de tanque
if self.Tank_Level < self.Tank_Level_Min:
self.Tank_Level_Low = True
self.Start_Tank_Fill = True
# Network 25: Production ONS
# One-Shot para inicio de producción
if self.Production_Mode and not self.last_Production_Mode:
self.Production_Initialize()
self.Recipe_Load()
self.last_Production_Mode = self.Production_Mode
# Network 26: Blender Prod Mode Init
# Inicialización del modo de producción del mezclador
if self.Production_Mode and not self.Production_Initialized:
self.Blender_Prod_Mode_Init()
self.Production_Initialized = True
# Network 27: Rinse ONS
# One-Shot para enjuague
if self.Rinse_Request and not self.last_Rinse_Request:
self.Start_Rinse_Sequence()
self.last_Rinse_Request = self.Rinse_Request
# Network 28: CIP ONS
# One-Shot para inicio de CIP
if self.CIP_Mode and not self.last_CIP_Mode:
self.CIP_Initialize()
self.last_CIP_Mode = self.CIP_Mode
# Network 29: CIp Mode Init
# Inicialización del modo CIP
if self.CIP_Mode and not self.CIP_Initialized:
self.Blender_CIP_Mode_Init()
self.CIP_Initialized = True
# Network 30: Reset SPWords
# Reseteo de palabras SP
self.Reset_SP_Words()
# Network 31: Blender Run Control
# Control de funcionamiento del mezclador
self.Blender_Run_Control()
# Network 32: Tank Pressure Control
# Control de presión del tanque
self.Tank_Pressure_Control()
# Network 33: Balaiage
# Control de barrido (Balaiage)
self.Balaiage_Control()
# Network 34: First Production
# Control para primera producción
self.First_Production()
# Network 35: CIP MAIN Calling
# Llamada principal al sistema CIP
if self.CIP_Mode:
self.CIP_Main()
# Network 36: Blender Rinse
# Enjuague del mezclador
self.Blender_Rinse()
# Network 37: Safeties
# Control de seguridades
self.Safeties()
# Network 38: Instrument Scanner
# Escáner de instrumentos
self.Instrument_Scanner()
# Network 39: Vacuum Control
# Control de vacío
self.Vacuum_Control()
# Network 40: Syrup Room Control
# Control de sala de jarabes
self.Syrup_Room_Control()
# Network 41: Blend Procedure Data
# Datos de procedimiento de mezcla
self.Blend_Procedure_Data()
# Network 42: Pneumatic Valve Control
# Control de válvulas neumáticas
self.Pneumatic_Valve_Control()
# Network 43: Pumps Control
# Control de bombas
self.Pumps_Control()
# Network 44: Prod Report Manager
# Gestor de informes de producción
self.Prod_Report_Manager()
# Network 45: Outputs
# Control de salidas
self.Manage_Outputs()
# Network 46: SLIM BLOCK
# Bloque SLIM
self.SLIM_Block()
# Network 47: Interlocking Panel 1
# Panel de enclavamiento 1
self.Interlocking_Panel()
# Network 48: Filler Control
# Control de llenadora
self.Filler_Control()
# Network 49: Blender Ctrl Update PWORD
# Actualización de PWORD del controlador de mezcla
self.Blender_Ctrl_Update_PWORD()
# Network 50: ResetTotalizer
# Reseteo del totalizador general
if self.Reset_Command:
self.Totalizer_Value = 0
self.Reset_Complete = True
# Network 51: ResetWaterTot
# Reseteo del totalizador de agua
if self.mResetWaterTot:
self.Water_Totalizer = 0
self.mResetWaterTot = False
# Network 52: Water VFM Reset Totalizer
# Reseteo del totalizador VFM de agua
if self.Reset_Water_VFM_Request:
self.Reset_Water_VFM()
self.Reset_Water_VFM_Request = False
# Network 53: ResetCO2Tot
# Reseteo del totalizador de CO2
if self.mResetCO2Tot:
self.CO2_Totalizer = 0
self.mResetCO2Tot = False
# Network 54: Syrup MFM Reset Totalizer
# Reseteo del totalizador MFM de jarabe
if self.Reset_Syrup_MFM_Request:
self.Reset_Syrup_MFM()
self.Reset_Syrup_MFM_Request = False
# Network 55: ResetProductTot
# Reseteo del totalizador de producto
if self.mResetProductTot:
self.Product_Totalizer = 0
self.mResetProductTot = False
# Network 56: CO2 MFM Reset Tot
# Reseteo del totalizador MFM de CO2
if self.Reset_CO2_MFM_Request:
self.Reset_CO2_MFM()
self.Reset_CO2_MFM_Request = False
# Network 57: ResetCO2Tot
# Duplicado - Reseteo del totalizador de CO2
if self.Reset_CO2_Tot_Request:
self.CO2_Alt_Totalizer = 0
self.Reset_CO2_Tot_Request = False
# Network 58: Reset Totalizer
# Reseteo general de totalizadores
if self.Master_Reset_Request:
self.All_Totalizers_Reset()
self.Master_Reset_Request = False
# Network 59: Reset Totalizer
# Reseteo adicional de totalizadores
if self.Alternative_Reset_Request:
self.Alternative_Totalizers_Reset()
self.Alternative_Reset_Request = False
# Network 60: Blender Ctrl Command
# Comando de control del mezclador
self.Blender_Ctrl_Command()
# Network 61: DP Global Diag
# Diagnóstico global DP
self.DP_Global_Diag()
# Network 62: Profibus
# Gestión de Profibus
self.Profibus_Management()
# Network 63: Valve Fault
# Fallo de válvula
if self.Valve_Error_Detected:
self.Handle_Valve_Fault()
self.SystemError = True
# Network 64: All Auto
# Verificación de modo automático completo
self.All_Auto_RETVAL = self.All_Auto_Check()
# Network 65: Ctrl HMI Manual Active
# Control de HMI en modo manual activo
if self.HMI_Manual_Mode_Requested:
self.System_In_Manual_Mode = True
self.System_In_Auto_Mode = False
# Network 66: Mod Copy Recipe
# Copia de receta
if self.Copy_Recipe_Request:
self.Mod_Copy_Recipe()
self.Copy_Recipe_Complete = True
# Network 67: to HMI - Recipe Management
# Gestión de recetas para HMI
self.Recipe_To_HMI()
# Network 68: Recipe Calculation
# Cálculo de receta
self.Recipe_Calculation()
def Clock_Signal(self):
# Clock generation implementation
# This generates the system timing signals
self.Clock_10ms = not self.Clock_10ms
# Generate 100ms and 1s clock signals
if self.Clock_Counter % 10 == 0:
self.Clock_100ms = not self.Clock_100ms
if self.Clock_Counter % 100 == 0:
self.Clock_1s = not self.Clock_1s
self.Clock_Counter = 0
self.Clock_Counter += 1
def BlenderCtrl_MachineInit(self):
# Initialize blender machine state
if not self.MachineInitialized:
self.MachineState = 0 # IDLE state
self.SystemError = False
self.MachineInitialized = True
self.Production_Mode = False
self.CIP_Mode = False
self.System_In_Auto_Mode = False
self.System_In_Manual_Mode = False

Binary file not shown.