소스 검색

1 revise reservoir retrun flow vlave
2 add platingcell device releated

chenzk 1 일 전
부모
커밋
dcaa79e82b

+ 1 - 0
Framework/Common/Common.csproj

@@ -207,6 +207,7 @@
     <Compile Include="CommonData\Metal\CompactMembranMetalDeviceData.cs" />
     <Compile Include="CommonData\Metal\MetalLotTrackData.cs" />
     <Compile Include="CommonData\Metal\StandardHotMetalDeviceData.cs" />
+    <Compile Include="CommonData\PlatingCell\PlatingCellData.cs" />
     <Compile Include="CommonData\PowerSupplier\PowerSupplierData.cs" />
     <Compile Include="CommonData\PowerSupplier\PowerSupplierEnumData.cs" />
     <Compile Include="CommonData\PowerSupplier\PowerSupplierStepPeriodData.cs" />

+ 44 - 0
Framework/Common/CommonData/PlatingCell/PlatingCellData.cs

@@ -0,0 +1,44 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MECF.Framework.Common.CommonData.PlatingCell
+{
+    public class PlatingCellData : NotifiableItem
+    {
+        #region 内部变量
+        private bool _isHeadTilt;
+        private bool _isHeadVertical;
+        private double _clamShellDistance;
+        private double _clamShellCylinderPressure;
+        private double _overFlowLevel;
+        private string _overFlowStatus;
+        
+        private bool _clamShellClose;
+        private bool _headTilt;
+        private bool _isDataInitialized;
+        #endregion
+
+        #region 属性
+        public bool IsHeadTilt { get { return _isHeadTilt; } set { _isHeadTilt = value; InvokePropertyChanged(nameof(IsHeadTilt)); } }
+        public bool IsHeadVertical { get { return _isHeadVertical; } set { _isHeadVertical = value; InvokePropertyChanged(nameof(IsHeadVertical)); } }
+
+        public double ClamShellDistance { get { return _clamShellDistance; } set { _clamShellDistance = value; InvokePropertyChanged(nameof(ClamShellDistance)); } }
+
+        public double ClamShellCylinderPressure { get { return _clamShellCylinderPressure; } set { _clamShellCylinderPressure = value; InvokePropertyChanged(nameof(ClamShellCylinderPressure)); } }
+
+        public double OverFlowLevel { get { return _overFlowLevel; } set { _overFlowLevel = value; InvokePropertyChanged(nameof(OverFlowLevel)); } }
+
+        public string OverFlowStatus { get { return _overFlowStatus; } set { _overFlowStatus = value; InvokePropertyChanged(nameof(OverFlowStatus)); } }
+
+        public bool ClamShellClose { get { return _clamShellClose; } set { _clamShellClose = value; InvokePropertyChanged(nameof(ClamShellClose)); } }
+
+        public bool HeadTilt { get { return _headTilt; } set { _headTilt = value; InvokePropertyChanged(nameof(HeadTilt)); } }
+        public bool IsDataInitialized { get { return _isDataInitialized; } set { _isDataInitialized = value; InvokePropertyChanged(nameof(IsDataInitialized)); } }
+        #endregion
+
+
+    }
+}

+ 10 - 0
PunkHPX8_Core/RtState.cs

@@ -158,4 +158,14 @@ namespace PunkHPX8_Core
         Initialized,
         Idle,
     }
+    public enum PlatingCellState
+    {
+        Unknown,
+        Disable,
+        Error,
+        Init,
+        Initializing,
+        Initialized,
+        Idle,
+    }
 }

+ 0 - 4
PunkHPX8_RT/Config/Devices/Beckhoffcfg - plctask.xml

@@ -237,7 +237,6 @@
 		<!--Reservoir1 outputs Start-->
 		<Output Name="c_RES1_AN_PUMP_ENABLE" Address="MAIN.RES1_2_DO_16CHANNEL_EL2809_N201_1" Type="Digital" Invert="false" DataType="bool"/>
 		<Output Name="c_RES1_CA_PUMP_ENABLE" Address="MAIN.RES1_2_DO_16CHANNEL_EL2809_N201_3" Type="Digital" Invert="false" DataType="bool"/>
-		<!--这个信号编的,待修正--> <Output Name="c_RES1_RETURN_VALVE_ENABLE" Address="MAIN.RES1_2_DO_16CHANNEL_EL2809_N201_5" Type="Digital" Invert="false" DataType="bool"/>
 		<Output Name="c_RES1_AN_PUMP_SPEED" Address="MAIN.RES1_2_AO_8CHANNEL_0_10V_EL4008_N204_1" Scaling="0=0,100=32767" Type="Analog" DataType="int"/>
 		<Output Name="c_RES1_CA_PUMP_SPEED" Address="MAIN.RES1_2_AO_4CHANNEL_4_20mA_EL4024_N205_1" Scaling="0=0,100=32767" Type="Analog" DataType="int"/>
 		<Output Name="c_RES1_RETURN_VALVE_OPENING" Address="MAIN.RES1_2_AO_4CHANNEL_4_20mA_EL4024_N205_3" Scaling="0=0,100=32767" Type="Analog" DataType="int"/>
@@ -252,7 +251,6 @@
 		<!--Reservoir2 outputs Start-->
 		<Output Name="c_RES2_AN_PUMP_ENABLE" Address="MAIN.RES1_2_DO_16CHANNEL_EL2809_N201_2" Type="Digital" Invert="false" DataType="bool"/>
 		<Output Name="c_RES2_CA_PUMP_ENABLE" Address="MAIN.RES1_2_DO_16CHANNEL_EL2809_N201_4" Type="Digital" Invert="false" DataType="bool"/>
-		<!--这个信号编的,待修正--><Output Name="c_RES2_RETURN_VALVE_ENABLE" Address="" Type="Digital" Invert="false" DataType="bool"/>
 		<Output Name="c_RES2_AN_PUMP_SPEED" Address="MAIN.RES1_2_AO_8CHANNEL_0_10V_EL4008_N204_2" Scaling="0=0,100=32767" Type="Analog" DataType="int"/>
 		<Output Name="c_RES2_CA_PUMP_SPEED" Address="MAIN.RES1_2_AO_4CHANNEL_4_20mA_EL4024_N205_2" Scaling="0=0,100=32767" Type="Analog" DataType="int"/>
 		<Output Name="c_RES2_RETURN_VALVE_OPENING" Address="MAIN.RES1_2_AO_4CHANNEL_4_20mA_EL4024_N205_4" Scaling="0=0,100=32767" Type="Analog" DataType="int"/>
@@ -267,7 +265,6 @@
 		<!--Reservoir3 outputs Start-->
 		<Output Name="c_RES3_AN_PUMP_ENABLE" Address="MAIN.RES3_4_DO_16CHANNEL_EL2809_N231_1" Type="Digital" Invert="false" DataType="bool"/>
 		<Output Name="c_RES3_CA_PUMP_ENABLE" Address="MAIN.RES3_4_DO_16CHANNEL_EL2809_N231_3" Type="Digital" Invert="false" DataType="bool"/>
-		<!--这个信号编的,待修正--> <Output Name="c_RES3_4_RETURN_VALVE_ENABLE" Address="" Type="Digital" Invert="false" DataType="bool"/>
 		<Output Name="c_RES3_AN_PUMP_SPEED" Address="MAIN.RES3_4_AO_8CHANNEL_0_10V_EL4008_N234_1" Scaling="0=0,100=32767" Type="Analog" DataType="int"/>
 		<Output Name="c_RES3_CA_PUMP_SPEED" Address="MAIN.RES3_4_AO_4CHANNEL_4_20mA_EL4024_N235_1" Scaling="0=0,100=32767" Type="Analog" DataType="int"/>
 		<Output Name="c_RES3_RETURN_VALVE_OPENING" Address="MAIN.RES3_4_AO_4CHANNEL_4_20mA_EL4024_N235_3" Scaling="0=0,100=32767" Type="Analog" DataType="int"/>
@@ -282,7 +279,6 @@
 		<!--Reservoir4 outputs Start-->
 		<Output Name="c_RES4_AN_PUMP_ENABLE" Address="MAIN.RES3_4_DO_16CHANNEL_EL2809_N231_2" Type="Digital" Invert="false" DataType="bool"/>
 		<Output Name="c_RES4_CA_PUMP_ENABLE" Address="MAIN.RES3_4_DO_16CHANNEL_EL2809_N231_4" Type="Digital" Invert="false" DataType="bool"/>
-		<!--这个信号编的,待修正--><Output Name="c_RES4_RETURN_VALVE_ENABLE" Address="" Type="Digital" Invert="false" DataType="bool"/>
 		<Output Name="c_RES4_AN_PUMP_SPEED" Address="MAIN.RES3_4_AO_8CHANNEL_0_10V_EL4008_N234_2" Scaling="0=0,100=32767" Type="Analog" DataType="int"/>
 		<Output Name="c_RES4_CA_PUMP_SPEED" Address="MAIN.RES3_4_AO_4CHANNEL_4_20mA_EL4024_N235_2" Scaling="0=0,100=32767" Type="Analog" DataType="int"/>
 		<Output Name="c_RES4_RETURN_VALVE_OPENING" Address="MAIN.RES3_4_AO_4CHANNEL_4_20mA_EL4024_N235_4" Scaling="0=0,100=32767" Type="Analog" DataType="int"/>

+ 0 - 4
PunkHPX8_RT/Config/Devices/Beckhoffcfg.xml

@@ -222,7 +222,6 @@
 		<!--Reservoir1 output Start-->
 		<Output Name="c_RES1_AN_PUMP_ENABLE" Address="Task 2.Inputs.RES1_DO_16CHANNEL_EL2809_N201_1" Type="Digital" Invert="false" DataType="bool"/>
 		<Output Name="c_RES1_CA_PUMP_ENABLE" Address="Task 2.Inputs.RES1_DO_16CHANNEL_EL2809_N201_3" Type="Digital" Invert="false" DataType="bool"/>
-		<!--这个信号编的,待修正--><Output Name="c_RES1_RETURN_VALVE_ENABLE" Address="Task 2.Inputs.RES1_DO_16CHANNEL_EL2809_N201_5" Type="Digital" Invert="false" DataType="bool"/>
 		<Output Name="c_RES1_AN_PUMP_SPEED" Address="Task 2.Inputs.RES1_2_AO_8CHANNEL_0_10V_EL4008_N204_1" Scaling="0=0,100=32767" Type="Analog" DataType="int"/>
 		<Output Name="c_RES1_CA_PUMP_SPEED" Address="Task 2.Inputs.RES1_2_AO_4CHANNEL_4_20mA_EL4024_N205_1" Scaling="0=0,100=32767" Type="Analog" DataType="int"/>
 		<Output Name="c_RES1_RETURN_VALVE_OPENING" Address="Task 2.Inputs.RES1_2_AO_4CHANNEL_4_20mA_EL4024_N205_3" Scaling="0=0,100=32767" Type="Analog" DataType="int"/>
@@ -237,7 +236,6 @@
 		<!--Reservoir2 outputs Start-->
 		<Output Name="c_RES2_AN_PUMP_ENABLE" Address="MAIN.RES1_2_DO_16CHANNEL_EL2809_N201_2" Type="Digital" Invert="false" DataType="bool"/>
 		<Output Name="c_RES2_CA_PUMP_ENABLE" Address="MAIN.RES1_2_DO_16CHANNEL_EL2809_N201_4" Type="Digital" Invert="false" DataType="bool"/>
-		<!--这个信号编的,待修正--><Output Name="c_RES2_RETURN_VALVE_ENABLE" Address="" Type="Digital" Invert="false" DataType="bool"/>
 		<Output Name="c_RES2_AN_PUMP_SPEED" Address="MAIN.RES1_2_AO_8CHANNEL_0_10V_EL4008_N204_2" Scaling="0=0,100=32767" Type="Analog" DataType="int"/>
 		<Output Name="c_RES2_CA_PUMP_SPEED" Address="MAIN.RES1_2_AO_4CHANNEL_4_20mA_EL4024_N205_2" Scaling="0=0,100=32767" Type="Analog" DataType="int"/>
 		<Output Name="c_RES2_RETURN_VALVE_OPENING" Address="MAIN.RES1_2_AO_4CHANNEL_4_20mA_EL4024_N205_4" Scaling="0=0,100=32767" Type="Analog" DataType="int"/>
@@ -252,7 +250,6 @@
 		<!--Reservoir3 outputs Start-->
 		<Output Name="c_RES3_AN_PUMP_ENABLE" Address="MAIN.RES3_4_DO_16CHANNEL_EL2809_N231_1" Type="Digital" Invert="false" DataType="bool"/>
 		<Output Name="c_RES3_CA_PUMP_ENABLE" Address="MAIN.RES3_4_DO_16CHANNEL_EL2809_N231_3" Type="Digital" Invert="false" DataType="bool"/>
-		<!--这个信号编的,待修正--> <Output Name="c_RES3_4_RETURN_VALVE_ENABLE" Address="" Type="Digital" Invert="false" DataType="bool"/>
 		<Output Name="c_RES3_AN_PUMP_SPEED" Address="MAIN.RES3_4_AO_8CHANNEL_0_10V_EL4008_N234_1" Scaling="0=0,100=32767" Type="Analog" DataType="int"/>
 		<Output Name="c_RES3_CA_PUMP_SPEED" Address="MAIN.RES3_4_AO_4CHANNEL_4_20mA_EL4024_N235_1" Scaling="0=0,100=32767" Type="Analog" DataType="int"/>
 		<Output Name="c_RES3_RETURN_VALVE_OPENING" Address="MAIN.RES3_4_AO_4CHANNEL_4_20mA_EL4024_N235_3" Scaling="0=0,100=32767" Type="Analog" DataType="int"/>
@@ -267,7 +264,6 @@
 		<!--Reservoir4 outputs Start-->
 		<Output Name="c_RES4_AN_PUMP_ENABLE" Address="MAIN.RES3_4_DO_16CHANNEL_EL2809_N231_2" Type="Digital" Invert="false" DataType="bool"/>
 		<Output Name="c_RES4_CA_PUMP_ENABLE" Address="MAIN.RES3_4_DO_16CHANNEL_EL2809_N231_4" Type="Digital" Invert="false" DataType="bool"/>
-		<!--这个信号编的,待修正--><Output Name="c_RES4_RETURN_VALVE_ENABLE" Address="" Type="Digital" Invert="false" DataType="bool"/>
 		<Output Name="c_RES4_AN_PUMP_SPEED" Address="MAIN.RES3_4_AO_8CHANNEL_0_10V_EL4008_N234_2" Scaling="0=0,100=32767" Type="Analog" DataType="int"/>
 		<Output Name="c_RES4_CA_PUMP_SPEED" Address="MAIN.RES3_4_AO_4CHANNEL_4_20mA_EL4024_N235_2" Scaling="0=0,100=32767" Type="Analog" DataType="int"/>
 		<Output Name="c_RES4_RETURN_VALVE_OPENING" Address="MAIN.RES3_4_AO_4CHANNEL_4_20mA_EL4024_N235_4" Scaling="0=0,100=32767" Type="Analog" DataType="int"/>

+ 0 - 1
PunkHPX8_RT/Config/Devices/ModuleIOCfg.xml

@@ -144,7 +144,6 @@
 		
 		<IO Name="Reservoir1.AnPumpEnable" IOName="c_RES1_AN_PUMP_ENABLE"/> 
 		<IO Name="Reservoir1.CaPumpEnable" IOName="c_RES1_CA_PUMP_ENABLE"/> 
-		<IO Name="Reservoir1.ReturnValveEnable" IOName="c_RES1_RETURN_VALVE_ENABLE"/> 
 		<IO Name="Reservoir1.AnPumpSpeed" IOName="c_RES1_AN_PUMP_SPEED"/> 
 		<IO Name="Reservoir1.CaPumpSpeed" IOName="c_RES1_CA_PUMP_SPEED"/> 
 		<IO Name="Reservoir1.ReturnValveOpening" IOName="c_RES1_RETURN_VALVE_OPENING"/> 

+ 154 - 202
PunkHPX8_RT/Devices/PlatingCell/PlatingCellDevice.cs

@@ -2,16 +2,24 @@
 using Aitex.Core.RT.Device;
 using Aitex.Core.RT.Log;
 using Aitex.Core.RT.OperationCenter;
+using Aitex.Core.RT.SCCore;
 using Aitex.Core.Util;
+using MECF.Framework.Common.Beckhoff.ModuleIO;
+using MECF.Framework.Common.CommonData.PlatingCell;
+using MECF.Framework.Common.CommonData.Reservoir;
+using MECF.Framework.Common.IOCore;
 using MECF.Framework.Common.Persistent.Reservoirs;
 using MECF.Framework.Common.ToolLayout;
 using PunkHPX8_Core;
 using PunkHPX8_RT.Devices.LinMot;
 using PunkHPX8_RT.Devices.PowerSupplier;
+using PunkHPX8_RT.Devices.Reservoir;
 using PunkHPX8_RT.Modules;
+using PunkHPX8_RT.Modules.PlatingCell;
 using System;
 using System.Collections.Generic;
 using System.Linq;
+using System.Reflection;
 using System.Text;
 using System.Threading.Tasks;
 
@@ -25,9 +33,23 @@ namespace PunkHPX8_RT.Devices.PlatingCell
         private const string MANUAL = "Manual";
         private const string STRATUS = "Stratus";
         private const string DISABLED = "Disabled";
+        
+        
+        private const string IS_HEAD_TILT = "IsHeadTilt";
+        private const string IS_HEAD_VERTICAL = "IsHeadVertical";
+        private const string CLAMSHELL_DISTANCE = "ClamShellDistance";
+        private const string CLAMSHELL_CYLINDER_PRESSURE = "ClamShellCylinderPressure";
+        private const string OVERFLOW_LEVEL = "OverFlowLevel";
+        private const string CLAMSHELL_CLOSE = "ClamShellClose";
+        private const string HEAD_TILT = "HeadTilt";
+
+
         #endregion
 
         #region 内部变量
+        /// 变量是否初始化字典
+        /// </summary>
+        private Dictionary<string, bool> _variableInitializeDic = new Dictionary<string, bool>();
         /// <summary>
         /// 操作当前状态
         /// </summary>
@@ -36,18 +58,7 @@ namespace PunkHPX8_RT.Devices.PlatingCell
         /// 持久化数据
         /// </summary>
         protected PlatingCellPersistentValue _persistentValue;
-        /// <summary>
-        /// A面PowerSupplier
-        /// </summary>
-        protected CellPowerSupplier _sideAPowerSupplier;
-        /// <summary>
-        /// B面PowerSupplier
-        /// </summary>
-        protected CellPowerSupplier _sideBPowerSupplier;
-        /// <summary>
-        /// Linmot
-        /// </summary>
-        protected LinMotAxis _linmotAxis;
+
         /// <summary>
         /// PlatingCell项
         /// </summary>
@@ -73,14 +84,6 @@ namespace PunkHPX8_RT.Devices.PlatingCell
         /// </summary>
         public string EngineerMode { get { return _persistentValue.RecipeOperatingMode; } }
         /// <summary>
-        /// A面PowerSupplier
-        /// </summary>
-        public CellPowerSupplier SideAPowerSupplier { get { return _sideAPowerSupplier; } }
-        /// <summary>
-        /// B面PowerSupplier
-        /// </summary>
-        public CellPowerSupplier SideBPowerSupplier { get { return _sideBPowerSupplier; } }
-        /// <summary>
         /// 是否为Auto
         /// </summary>
         public bool IsAuto { get { return _persistentValue != null ? _persistentValue.OperatingMode == AUTO : false; } }
@@ -88,16 +91,17 @@ namespace PunkHPX8_RT.Devices.PlatingCell
         /// 是否为Auto
         /// </summary>
         public bool IsManual { get { return _persistentValue != null ? _persistentValue.OperatingMode == MANUAL : false; } }
-        /// <summary>
-        /// linmot motor on 
-        /// </summary>
-        public bool IsLinmotMotorOn { get { return _linmotAxis != null ? _linmotAxis.IsMotorOn : false; } }
+        #endregion
 
+        #region 共享变量
         /// <summary>
-        /// Linmot当前位置
+        /// 数据
         /// </summary>
-        public double LinmotPosition { get { return _linmotAxis != null ? _linmotAxis.CurrentPosition : 0; } }
+        protected PlatingCellData _platingCellData = new PlatingCellData();
+
         #endregion
+
+
         /// <summary>
         /// 构造函数
         /// </summary>
@@ -115,6 +119,7 @@ namespace PunkHPX8_RT.Devices.PlatingCell
             InitializeParameter();
             SubscribeData();
             InitializeOperation();
+            SubscribeValueAction();
             return true;
         }
         /// <summary>
@@ -138,158 +143,107 @@ namespace PunkHPX8_RT.Devices.PlatingCell
             _platingCellItem = PlatingCellItemManager.Instance.GetPlatingCellItem(Module);
             if (_platingCellItem != null)
             {
-                _sideAPowerSupplier = DEVICE.GetDevice<CellPowerSupplier>(_platingCellItem.PlatingPowerSupplyAID);
-                _sideBPowerSupplier = DEVICE.GetDevice<CellPowerSupplier>(_platingCellItem.PlatingPowerSupplyBID);
-                _linmotAxis = DEVICE.GetDevice<LinMotAxis>(_platingCellItem.LinmotID);
+
             }
         }
-
-        /// <summary>
-        /// 订阅数据
-        /// </summary>
-        private void SubscribeData()
+        protected virtual void SubscribeValueAction()
         {
-            DATA.Subscribe($"{Module}.{PERSISTENT_VALUE}", () => _persistentValue, SubscriptionAttribute.FLAG.IgnoreSaveDB);
-            DATA.Subscribe($"{Module}.SideAPowerSupplierData", () => _sideAPowerSupplier.PowerSupplierData, SubscriptionAttribute.FLAG.IgnoreSaveDB);
-            DATA.Subscribe($"{Module}.SideBPowerSupplierData", () => _sideBPowerSupplier.PowerSupplierData, SubscriptionAttribute.FLAG.IgnoreSaveDB);
-            DATA.Subscribe($"{Module}.SideAPowerSupplier.ID", () => _sideAPowerSupplier.Module, SubscriptionAttribute.FLAG.IgnoreSaveDB);
-            DATA.Subscribe($"{Module}.SideAPowerSupplier.IsConnected", () => _sideAPowerSupplier.IsConnected, SubscriptionAttribute.FLAG.IgnoreSaveDB);
-            DATA.Subscribe($"{Module}.SideAPowerSupplier.Voltage", () => _sideAPowerSupplier.PowerSupplierData.Voltage, SubscriptionAttribute.FLAG.IgnoreSaveDB);
-            DATA.Subscribe($"{Module}.SideAPowerSupplier.Current", () => _sideAPowerSupplier.PowerSupplierData.Current, SubscriptionAttribute.FLAG.IgnoreSaveDB);
-            DATA.Subscribe($"{Module}.SideAPowerSupplier.SetPoint", () => _sideAPowerSupplier.PowerSupplierData.SetPoint, SubscriptionAttribute.FLAG.IgnoreSaveDB);
-            DATA.Subscribe($"{Module}.SideAPowerSupplier.RunModel", () => _sideAPowerSupplier.PowerSupplierData.PowerRunModelContent, SubscriptionAttribute.FLAG.IgnoreSaveDB);
-            DATA.Subscribe($"{Module}.SideAPowerSupplier.PowerControl", () => _sideAPowerSupplier.PowerSupplierData.PowerControlContent, SubscriptionAttribute.FLAG.IgnoreSaveDB);
-            DATA.Subscribe($"{Module}.SideAPowerSupplier.PowerStatus", () => _sideAPowerSupplier.PowerSupplierData.PowerStatusContent, SubscriptionAttribute.FLAG.IgnoreSaveDB);
-            DATA.Subscribe($"{Module}.SideAPowerSupplier.Enable", () => _sideBPowerSupplier.PowerSupplierData.Enabled, SubscriptionAttribute.FLAG.IgnoreSaveDB);
-            DATA.Subscribe($"{Module}.SideBPowerSupplier.ID", () => _sideBPowerSupplier.Module, SubscriptionAttribute.FLAG.IgnoreSaveDB);
-            DATA.Subscribe($"{Module}.SideBPowerSupplier.IsConnected", () => _sideAPowerSupplier.IsConnected, SubscriptionAttribute.FLAG.IgnoreSaveDB);
-            DATA.Subscribe($"{Module}.SideBPowerSupplier.Voltage", () => _sideBPowerSupplier.PowerSupplierData.Voltage, SubscriptionAttribute.FLAG.IgnoreSaveDB);
-            DATA.Subscribe($"{Module}.SideBPowerSupplier.Current", () => _sideBPowerSupplier.PowerSupplierData.Current, SubscriptionAttribute.FLAG.IgnoreSaveDB);
-            DATA.Subscribe($"{Module}.SideBPowerSupplier.SetPoint", () => _sideBPowerSupplier.PowerSupplierData.SetPoint, SubscriptionAttribute.FLAG.IgnoreSaveDB);
-            DATA.Subscribe($"{Module}.SideBPowerSupplier.RunModel", () => _sideBPowerSupplier.PowerSupplierData.PowerRunModelContent, SubscriptionAttribute.FLAG.IgnoreSaveDB);
-            DATA.Subscribe($"{Module}.SideBPowerSupplier.PowerControl", () => _sideBPowerSupplier.PowerSupplierData.PowerControlContent, SubscriptionAttribute.FLAG.IgnoreSaveDB);
-            DATA.Subscribe($"{Module}.SideBPowerSupplier.PowerStatus", () => _sideBPowerSupplier.PowerSupplierData.PowerStatusContent, SubscriptionAttribute.FLAG.IgnoreSaveDB);
-            DATA.Subscribe($"{Module}.SideBPowerSupplier.Enable", () => _sideBPowerSupplier.PowerSupplierData.Enabled, SubscriptionAttribute.FLAG.IgnoreSaveDB);
-            DATA.Subscribe($"{Module}.Linmot.ID", () => _linmotAxis.Module, SubscriptionAttribute.FLAG.IgnoreSaveDB);
-            DATA.Subscribe($"{Module}.Linmot.IsMotorOn", () => _linmotAxis.IsMotorOn, SubscriptionAttribute.FLAG.IgnoreSaveDB);
-            DATA.Subscribe($"{Module}.Linmot.IsError", () => _linmotAxis.IsError, SubscriptionAttribute.FLAG.IgnoreSaveDB);
-            DATA.Subscribe($"{Module}.Linmot.IsSwitchOn", () => _linmotAxis.IsSwitchOn, SubscriptionAttribute.FLAG.IgnoreSaveDB);
-            DATA.Subscribe($"{Module}.Linmot.CurveSpeed", () => _linmotAxis.CurveSpeed, SubscriptionAttribute.FLAG.IgnoreSaveDB);
-            DATA.Subscribe($"{Module}.Linmot.ErrorCode", () => _linmotAxis.ErrorCode, SubscriptionAttribute.FLAG.IgnoreSaveDB);
-            DATA.Subscribe($"{Module}.Linmot.CurrentPosition", () => _linmotAxis.CurrentPosition, SubscriptionAttribute.FLAG.IgnoreSaveDB);
+            IoSubscribeUpdateVariable(IS_HEAD_TILT);
+            IoSubscribeUpdateVariable(IS_HEAD_VERTICAL);
+            IoSubscribeUpdateVariable(CLAMSHELL_DISTANCE);
+            IoSubscribeUpdateVariable(CLAMSHELL_CYLINDER_PRESSURE);
+            IoSubscribeUpdateVariable(OVERFLOW_LEVEL);
+            IoSubscribeUpdateVariable(CLAMSHELL_CLOSE);
+            IoSubscribeUpdateVariable(HEAD_TILT);
+   
         }
+
         /// <summary>
-        /// 初始化操作
+        /// 订阅IO变量
         /// </summary>
-        protected virtual void InitializeOperation()
+        /// <param name="variable"></param>
+        protected void IoSubscribeUpdateVariable(string variable)
         {
-            OP.Subscribe($"{Module}.DisabledAction", DisabledOperation);
-            OP.Subscribe($"{Module}.ManualAction", ManualOperation);
-            OP.Subscribe($"{Module}.AutoAction", AutoOperation);
-            OP.Subscribe($"{Module}.EngineeringModeAction", EngineeringModeOperation);
-            OP.Subscribe($"{Module}.ProductionModeAction", ProductionModeOperation);
-            OP.Subscribe($"{Module}.SetPlatingCellWaferSize", (cmd, args) => { return SetPlatingCellWaferSize(cmd, args); });
+            _variableInitializeDic[variable] = false;
+            IOModuleManager.Instance.SubscribeModuleVariable(Module, variable, UpdateVariableValue);
         }
         /// <summary>
-        /// 开始Curve
+        /// 更新变量数值
         /// </summary>
-        /// <param name="speed"></param>
-        /// <returns></returns>
-        public bool StartCurveMotion(int speed)
+        /// <param name="variable"></param>
+        /// <param name="value"></param>
+        private void UpdateVariableValue(string variable, object value)
         {
-            if (_linmotAxis != null)
+            if (!_platingCellData.IsDataInitialized)
             {
-                return _linmotAxis.StartCurve(speed);
+                _platingCellData.IsDataInitialized = true;
             }
-            else
+            PropertyInfo property = _platingCellData.GetType().GetProperty(variable);
+            if (property != null)
             {
-                LOG.WriteLog(eEvent.ERR_METAL, Module, "linmot is null");
-                return false;
+                property.SetValue(_platingCellData, value);
             }
-        }
-
-        /// <summary>
-        /// 开始Curve
-        /// </summary>
-        /// <param name="speed"></param>
-        /// <returns></returns>
-        public bool ChangeCurveSpeedMotion(int speed)
-        {
-            if (_linmotAxis != null)
+            if (_variableInitializeDic.ContainsKey(variable) && !_variableInitializeDic[variable])
             {
-                return _linmotAxis.ChangeCurveSpeed(speed);
-            }
-            else
-            {
-                LOG.WriteLog(eEvent.ERR_METAL, Module, "linmot is null");
-                return false;
+                _variableInitializeDic[variable] = true;
             }
         }
         /// <summary>
-        /// ResetLinmot
+        /// 写变量
         /// </summary>
+        /// <param name="variable"></param>
+        /// <param name="value"></param>
         /// <returns></returns>
-        public bool ResetLinmot()
+        protected bool WriteVariableValue(string variable, object value)
         {
-            if (_linmotAxis != null)
-            {
-                return _linmotAxis.ResetOperation("", false);
-            }
-            else
-            {
-                LOG.WriteLog(eEvent.ERR_METAL, Module, "linmot is null");
-                return false;
-            }
+            string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{variable}");
+            return IOModuleManager.Instance.WriteIoValue(ioName, value);
         }
         /// <summary>
-        /// 检验Linmot Routine状态是否为结束状态
+        /// 订阅数据
         /// </summary>
-        /// <returns></returns>
-        public bool CheckLinmotRoutineEnd()
+        private void SubscribeData()
         {
-            if (_linmotAxis != null)
-            {
-                return _linmotAxis.Status == RState.End;
-            }
-            else
-            {
-                LOG.WriteLog(eEvent.ERR_METAL, Module, "linmot is null");
-                return false;
-            }
+            DATA.Subscribe($"{Module}.{PERSISTENT_VALUE}", () => _persistentValue, SubscriptionAttribute.FLAG.IgnoreSaveDB);
+        
+           
         }
         /// <summary>
-        /// 检验Linmot Routine状态是否为错误状态
+        /// 初始化操作
         /// </summary>
-        /// <returns></returns>
-        public bool CheckLinmotRoutineError()
+        protected virtual void InitializeOperation()
         {
-            if (_linmotAxis != null)
-            {
-                return _linmotAxis.Status == RState.Failed || _linmotAxis.Status == RState.Timeout;
-            }
-            else
-            {
-                return false;
-            }
+            OP.Subscribe($"{Module}.DisabledAction", DisabledOperation);
+            OP.Subscribe($"{Module}.ManualAction", ManualOperation);
+            OP.Subscribe($"{Module}.AutoAction", AutoOperation);
+            OP.Subscribe($"{Module}.EngineeringModeAction", EngineeringModeOperation);
+            OP.Subscribe($"{Module}.ProductionModeAction", ProductionModeOperation);
+            OP.Subscribe($"{Module}.SetPlatingCellWaferSize", (cmd, args) => { return SetPlatingCellWaferSize(cmd, args); });
+            
+            OP.Subscribe($"{Module}.ClamShellClose", (cmd, para) => { return ClamShellClose(); });
+            OP.Subscribe($"{Module}.ClamShellOpen", (cmd, para) => { return ClamShellOpen(); });
+            OP.Subscribe($"{Module}.HeadtTilt", (cmd, para) => { return HeadtTiltAction(); });
+            OP.Subscribe($"{Module}.HeadVertical", (cmd, para) => { return HeadtVerticalAction(); });
+
+      
         }
-        /// <summary>
-        /// 停止Linmot
-        /// </summary>
-        /// <returns></returns>
-        public bool StopLinmot()
+        #region Operation
+        public bool ClamShellClose()
         {
-            if (_linmotAxis != null)
-            {
-                return _linmotAxis.StopOperation("", null);
-            }
-            else
-            {
-                LOG.WriteLog(eEvent.ERR_METAL, Module, "linmot is null");
-                return false;
-            }
+            return WriteVariableValue(CLAMSHELL_CLOSE, true);
+        }
+        public bool ClamShellOpen()
+        {
+            return WriteVariableValue(CLAMSHELL_CLOSE, false);
+        }
+        public bool HeadtTiltAction()
+        {
+            return WriteVariableValue(HEAD_TILT, true);
+        }
+        public bool HeadtVerticalAction()
+        {
+            return WriteVariableValue(HEAD_TILT, false);
         }
-
-        #region Operation
         /// <summary>
         /// DisabledAction
         /// </summary>
@@ -298,28 +252,27 @@ namespace PunkHPX8_RT.Devices.PlatingCell
         /// <returns></returns>
         public bool DisabledOperation(string cmd, object[] args)
         {
-            //string currentOperation = "Disabled";
-            //MetalEntity metalEntity = Singleton<RouteManager>.Instance.GetModule<MetalEntity>(Module);
-            //if (metalEntity != null && _persistentValue != null && _persistentValue.OperatingMode != currentOperation)
-            //{
-            //    string preOperation = _persistentValue.OperatingMode;
-            //    if (metalEntity.IsBusy)
-            //    {
-            //        LOG.WriteLog(eEvent.ERR_METAL, Module, $"{Module} is Busy, can't switch to Disabled mode");
-            //        return false;
-            //    }
-            //    if (SchedulerMetalTimeManager.Instance.Contained(Module))
-            //    {
-            //        LOG.WriteLog(eEvent.ERR_METAL, Module, $"{Module} is in scheduler, can't switch to Disabled mode");
-            //        return false;
-            //    }
-            //    metalEntity.EnterInit();
-            //    _persistentValue.OperatingMode = currentOperation;
-
-            //    LOG.WriteLog(eEvent.INFO_METAL, Module, $"Operating mode is switched from {preOperation} to {currentOperation}");
-            //}
+            string currentOperation = "Disabled";
+            PlatingCellEntity platingCellEntity = Singleton<RouteManager>.Instance.GetModule<PlatingCellEntity>(Module);
+            if (platingCellEntity != null && _persistentValue != null && _persistentValue.OperatingMode != currentOperation)
+            {
+                string preOperation = _persistentValue.OperatingMode;
+                if (platingCellEntity.IsBusy)
+                {
+                    LOG.WriteLog(eEvent.ERR_METAL, Module, $"{Module} is Busy, can't switch to Disabled mode");
+                    return false;
+                }
+                //if (SchedulerMetalTimeManager.Instance.Contained(Module))
+                //{
+                //    LOG.WriteLog(eEvent.ERR_METAL, Module, $"{Module} is in scheduler, can't switch to Disabled mode");
+                //    return false;
+                //}
+                platingCellEntity.EnterInit();
+                _persistentValue.OperatingMode = currentOperation;
 
-            //MetalPersistentManager.Instance.UpdatePersistentValue(Module);
+                LOG.WriteLog(eEvent.INFO_METAL, Module, $"Operating mode is switched from {preOperation} to {currentOperation}");
+            }
+            PlatingCellPersistentManager.Instance.UpdatePersistentValue(Module);
             return true;
         }
         /// <summary>
@@ -330,28 +283,28 @@ namespace PunkHPX8_RT.Devices.PlatingCell
         /// <returns></returns>
         public bool ManualOperation(string cmd, object[] args)
         {
-            //string currentOperation = "Manual";
-            //MetalEntity metalEntity = Singleton<RouteManager>.Instance.GetModule<MetalEntity>(Module);
-            //if (metalEntity != null && _persistentValue != null && _persistentValue.OperatingMode != currentOperation)
-            //{
-            //    string preOperation = _persistentValue.OperatingMode;
-            //    if (metalEntity.IsBusy)
-            //    {
-            //        LOG.WriteLog(eEvent.ERR_METAL, Module, $"{Module} is Busy, can't switch to Manual mode");
-            //        return false;
-            //    }
-            //    if (SchedulerMetalTimeManager.Instance.Contained(Module))
-            //    {
-            //        LOG.WriteLog(eEvent.ERR_METAL, Module, $"{Module} is in scheduler, can't switch to Manual mode");
-            //        return false;
-            //    }
-            //    metalEntity.EnterInit();
-            //    _persistentValue.OperatingMode = currentOperation;
+            string currentOperation = "Manual";
+            PlatingCellEntity platingCellEntity = Singleton<RouteManager>.Instance.GetModule<PlatingCellEntity>(Module);
+            if (platingCellEntity != null && _persistentValue != null && _persistentValue.OperatingMode != currentOperation)
+            {
+                string preOperation = _persistentValue.OperatingMode;
+                if (platingCellEntity.IsBusy)
+                {
+                    LOG.WriteLog(eEvent.ERR_METAL, Module, $"{Module} is Busy, can't switch to Manual mode");
+                    return false;
+                }
+                //if (SchedulerMetalTimeManager.Instance.Contained(Module))
+                //{
+                //    LOG.WriteLog(eEvent.ERR_METAL, Module, $"{Module} is in scheduler, can't switch to Manual mode");
+                //    return false;
+                //}
+                platingCellEntity.EnterInit();
+                _persistentValue.OperatingMode = currentOperation;
 
-            //    LOG.WriteLog(eEvent.INFO_METAL, Module, $"Operating mode is switched from {preOperation} to {currentOperation}");
-            //}
+                LOG.WriteLog(eEvent.INFO_METAL, Module, $"Operating mode is switched from {preOperation} to {currentOperation}");
+            }
 
-            //MetalPersistentManager.Instance.UpdatePersistentValue(Module);
+            PlatingCellPersistentManager.Instance.UpdatePersistentValue(Module);
             return true;
         }
         /// <summary>
@@ -362,23 +315,22 @@ namespace PunkHPX8_RT.Devices.PlatingCell
         /// <returns></returns>
         public bool AutoOperation(string cmd, object[] args)
         {
-            //string currentOperation = "Auto";
-            //MetalEntity metalEntity = Singleton<RouteManager>.Instance.GetModule<MetalEntity>(Module);
-            //if (metalEntity != null && _persistentValue != null && _persistentValue.OperatingMode != currentOperation)
-            //{
-            //    string preOperation = _persistentValue.OperatingMode;
-            //    if (metalEntity.IsBusy)
-            //    {
-            //        LOG.WriteLog(eEvent.ERR_METAL, Module, $"{Module} is Busy, can't switch to Auto mode");
-            //        return false;
-            //    }
-            //    metalEntity.EnterInit();
-            //    _persistentValue.OperatingMode = currentOperation;
-
-            //    LOG.WriteLog(eEvent.INFO_METAL, Module, $"Operating mode is switched from {preOperation} to {currentOperation}");
-            //}
+            string currentOperation = "Auto";
+            PlatingCellEntity platingCellEntity = Singleton<RouteManager>.Instance.GetModule<PlatingCellEntity>(Module);
+            if (platingCellEntity != null && _persistentValue != null && _persistentValue.OperatingMode != currentOperation)
+            {
+                string preOperation = _persistentValue.OperatingMode;
+                if (platingCellEntity.IsBusy)
+                {
+                    LOG.WriteLog(eEvent.ERR_METAL, Module, $"{Module} is Busy, can't switch to Auto mode");
+                    return false;
+                }
+                platingCellEntity.EnterInit();
+                _persistentValue.OperatingMode = currentOperation;
 
-            //MetalPersistentManager.Instance.UpdatePersistentValue(Module);
+                LOG.WriteLog(eEvent.INFO_METAL, Module, $"Operating mode is switched from {preOperation} to {currentOperation}");
+            }
+            PlatingCellPersistentManager.Instance.UpdatePersistentValue(Module);
             return true;
         }
         /// <summary>

+ 15 - 20
PunkHPX8_RT/Devices/Reservoir/ReservoirDevice.cs

@@ -61,8 +61,6 @@ namespace PunkHPX8_RT.Devices.Reservoir
         protected const string CA_PUMP_ENABLE="CaPumpEnable";
         protected const string CA_PUMP_SPEED="CaPumpSpeed";
         protected const string RETURN_VALVE_OPENING="ReturnValveOpening";
-        protected const string RETURN_VALVE= "ReturnValveEnable";
-        protected const string RETURN_VALVE_PERCENT="ReturnValvePercent";
         protected const string CA_DI_REPLEN="CaDiReplen";
         protected const string AN_DI_REPLEN="AnDiReplen";
         protected const string SAMPLE_OUT="SampleOut";
@@ -336,9 +334,7 @@ namespace PunkHPX8_RT.Devices.Reservoir
             IoSubscribeUpdateVariable(CA_PUMP_ENABLE);
             IoSubscribeUpdateVariable(CA_PUMP_SPEED);
             IoSubscribeUpdateVariable(CA_DI_REPLEN);
-            IoSubscribeUpdateVariable(RETURN_VALVE);
             IoSubscribeUpdateVariable(RETURN_VALVE_OPENING);
-            IoSubscribeUpdateVariable(RETURN_VALVE_PERCENT);
             IoSubscribeUpdateVariable(SAMPLE_OUT);
             IoSubscribeUpdateVariable(CA_ISOLATION);
             IoSubscribeUpdateVariable(AN_ISOLATION);
@@ -374,6 +370,17 @@ namespace PunkHPX8_RT.Devices.Reservoir
                     string caLevelCurve = SC.GetStringValue($"Reservoir.{Module}.CALevelCurve");
                     ReservoirData.CaLevel = LevelCurveManager.Instance.CalculateLevelByWaterLevel(ReservoirData.CaWaterLevel, caLevelCurve);
                 }
+                if (variable == RETURN_VALVE_OPENING)
+                {
+                    if (Convert.ToInt32(value) != 0)
+                    {
+                        ReservoirData.ReturnValveEnable = true;
+                    }
+                    else
+                    {
+                        ReservoirData.ReturnValveEnable = false;
+                    }
+                }
             }
             if (_variableInitializeDic.ContainsKey(variable) && !_variableInitializeDic[variable])
             {
@@ -400,7 +407,7 @@ namespace PunkHPX8_RT.Devices.Reservoir
         protected virtual bool OnTimer()
         {
             CalculateCALevel();
-            AdjustPumpSpeed();
+            AdjustRetrunFlowValve();
             WaterLevelMonitor();
             DireplenMonitor();
             AutoOpenDegasValve();
@@ -437,7 +444,7 @@ namespace PunkHPX8_RT.Devices.Reservoir
         /// <summary>
         /// 自动调节retrun valve 开闭
         /// </summary>
-        public void AdjustPumpSpeed()
+        public void AdjustRetrunFlowValve()
         {
             ReservoirEntity reservoirEntity = Singleton<RouteManager>.Instance.GetModule<ReservoirEntity>(Module);
             if (reservoirEntity != null) 
@@ -881,17 +888,7 @@ namespace PunkHPX8_RT.Devices.Reservoir
         private bool ReturnValveOn(string cmd, object[] args)
         {
             double percent = SC.GetValue<int>("Reservoir.ReturnOpenDefaultPercentage");
-            bool result = ReturnValvePercent(percent);
-            if (result)
-            {
-                //string enableIOName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{RETURN_VALVE}");
-                //return BeckhoffIOManager.Instance.WriteIoValue(enableIOName, true);
-                return WriteVariableValue(RETURN_VALVE, true);
-            }
-            else
-            {
-                return false;
-            }
+            return ReturnValvePercent(percent);
         }
         /// <summary>
         /// Return Valve Off
@@ -901,9 +898,7 @@ namespace PunkHPX8_RT.Devices.Reservoir
         /// <returns></returns>
         public bool ReturnValveOff()
         {
-            //string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{RETURN_VALVE}");
-            //return BeckhoffIOManager.Instance.WriteIoValue(ioName, false);
-            return WriteVariableValue(RETURN_VALVE, false);
+            return ReturnValvePercent(0);
         }
         #endregion
         

+ 286 - 0
PunkHPX8_RT/Modules/PlatingCell/PlatingCellEntity.cs

@@ -0,0 +1,286 @@
+using Aitex.Core.RT.DataCenter;
+using Aitex.Core.RT.Device;
+using Aitex.Core.RT.Fsm;
+using Aitex.Core.RT.Log;
+using Aitex.Core.RT.OperationCenter;
+using Aitex.Core.RT.RecipeCenter;
+using Aitex.Core.Util;
+using Aitex.Core.Utilities;
+using MECF.Framework.Common.Equipment;
+using MECF.Framework.Common.Persistent.Reservoirs;
+using MECF.Framework.Common.ProcessCell;
+using MECF.Framework.Common.RecipeCenter;
+using MECF.Framework.Common.ToolLayout;
+using PunkHPX8_Core;
+using PunkHPX8_RT.Devices.PlatingCell;
+using PunkHPX8_RT.Devices.PowerSupplier;
+using PunkHPX8_RT.Devices.Temperature;
+using PunkHPX8_RT.Modules.Reservoir;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PunkHPX8_RT.Modules.PlatingCell
+{
+    public class PlatingCellEntity : Entity, IEntity, IModuleEntity
+    {
+        public enum PlatingCellMsg
+        {
+            NONE,
+            Error,
+            ResumeError,
+            Initialize,
+            Manual,
+            Auto,
+            CurrentShortTest,
+            CloseFlowValve,
+            OpenFlowValve,
+            RunRecipe,
+            Abort,
+            Init
+        }
+
+        #region 常量
+        private const string STRATUS = "Stratus";
+        private const string AUTO = "Auto";
+        private const string MANUAL = "Manual";
+        private const string DISABLED = "Disabled";
+        private const string ENGINEERING = "Engineering";
+        private const string PRODUCTION = "Production";
+        #endregion
+
+        #region 内部变量
+        /// <summary>
+        /// 持久化数值
+        /// </summary>
+        private PlatingCellPersistentValue _persistentValue;
+        /// <summary>
+        /// 当前recipe
+        /// </summary>
+        private DepRecipe _currentRecipe;
+        #endregion
+        #region 属性
+        /// <summary>
+        /// 模块名称
+        /// </summary>
+        public ModuleName Module { get; private set; }
+        /// <summary>
+        /// 是否Init
+        /// </summary>
+        public bool IsInit
+        {
+            get { return fsm.State == (int)PlatingCellState.Init; }
+        }
+        /// <summary>
+        /// 是否Idle
+        /// </summary>
+        public bool IsIdle
+        {
+            get
+            {
+                return fsm.State == (int)PlatingCellState.Idle;
+            }
+        }
+        /// <summary>
+        /// 是否错误
+        /// </summary>
+        public bool IsError
+        {
+            get { return fsm.State == (int)PlatingCellState.Error; }
+        }
+        /// <summary>
+        /// 正在忙碌
+        /// </summary>
+        public bool IsBusy
+        {
+            get { return fsm.State == (int)PlatingCellState.Initializing; }
+        }
+
+        /// <summary>
+        /// 化学液
+        /// </summary>
+        public string Chemistry
+        {
+            get { return _currentRecipe != null ? _currentRecipe.Chemistry : ""; }
+        }
+        /// <summary>
+        /// 是否禁用
+        /// </summary>
+        public bool IsDisable { get { return _persistentValue == null || _persistentValue.OperatingMode == DISABLED; } }
+
+        /// <summary>
+        /// 自动模式
+        /// </summary>
+        public bool IsAuto { get { return _persistentValue != null && _persistentValue.OperatingMode == AUTO; } }
+        /// <summary>
+        /// 自动模式
+        /// </summary>
+        public bool IsManual { get { return _persistentValue != null && _persistentValue.OperatingMode == MANUAL; } }
+        /// <summary>
+        /// 是否为工程模式
+        /// </summary>
+        public bool IsEngineering { get { return _persistentValue != null && _persistentValue.RecipeOperatingMode == ENGINEERING; } }
+        /// <summary>
+        /// 是否为产品模式
+        /// </summary>
+        public bool IsProduction { get { return _persistentValue != null && _persistentValue.RecipeOperatingMode == PRODUCTION; } }
+        /// <summary>
+        /// 状态机状态
+        /// </summary>
+        public PlatingCellState State { get { return (PlatingCellState)fsm.State; } }
+        /// <summary>
+        /// 是否初始化完成
+        /// </summary>
+        public bool IsInitialized { get { return fsm.State >= (int)PlatingCellState.Initialized; } }
+        /// <summary>
+        /// Reservoir项
+        /// </summary>
+        private ReservoirItem _reservoirItem;
+        #endregion
+
+
+
+        /// <summary>
+        /// 构造函数
+        /// </summary>
+        /// <param name="module"></param>
+        public PlatingCellEntity(ModuleName module)
+        {
+            this.Module = module;
+            InitializeParameter();
+            InitialFsm();
+        }
+        /// <summary>
+        /// 初始化
+        /// </summary>
+        /// <returns></returns>
+        protected override bool Init()
+        {
+            InitializeRoutine();
+            InitializeDATA();
+            InitializeOperation();
+            return true;
+        }
+
+        /// <summary>
+        /// 初始化参数
+        /// </summary>
+        private void InitializeParameter()
+        {
+            _persistentValue = PlatingCellPersistentManager.Instance.GetPlatingCellPersistentValue(Module.ToString());
+            if (_persistentValue == null)
+            {
+                LOG.WriteLog(eEvent.ERR_PLATINGCELL, Module.ToString(), "Persistent Value Object is not exist");
+            }
+        }
+      
+        /// <summary>
+        /// 初始化Routine
+        /// </summary>
+        private void InitializeRoutine()
+        {
+
+        }
+        /// <summary>
+        /// 初始化DATA
+        /// </summary>
+        private void InitializeDATA()
+        {
+            DATA.Subscribe($"{Module}.FsmState", () => ((PlatingCellState)fsm.State).ToString(), SubscriptionAttribute.FLAG.IgnoreSaveDB);
+        }
+        /// <summary>
+        /// 初始化Operation
+        /// </summary>
+        private void InitializeOperation()
+        {
+            OP.Subscribe($"{Module}.InitializeAll", (cmd, args) => { return CheckToPostMessage<PlatingCellState, ReservoirMsg>(eEvent.ERR_RESERVOIR, Module.ToString(), (int)ReservoirMsg.Initialize); });
+        }
+
+        /// 初始化状态机
+        /// </summary>
+        private void InitialFsm()
+        {
+            fsm = new StateMachine<PlatingCellEntity>(Module.ToString(), (int)PlatingCellState.Init, 100);
+            fsm.EnableRepeatedMsg(true);
+
+            AnyStateTransition(ReservoirMsg.Error, NullFunc, PlatingCellState.Error);
+            //Initialized
+            Transition(PlatingCellState.Error, PlatingCellMsg.Initialize, InitializeAll, PlatingCellState.Initializing);
+            Transition(PlatingCellState.Init, PlatingCellMsg.Initialize, InitializeAll, PlatingCellState.Initializing);
+            Transition(PlatingCellState.Idle, PlatingCellMsg.Initialize, InitializeAll, PlatingCellState.Initializing);
+            Transition(PlatingCellState.Initializing, FSM_MSG.TIMER, InitializeAllMonitor, PlatingCellState.Idle);
+
+            //直接进入Idle
+            Transition(PlatingCellState.Initialized, FSM_MSG.TIMER, NullFunc, PlatingCellState.Idle);
+            //Enter Init
+            Transition(PlatingCellState.Idle, ReservoirMsg.Init, NullFunc, PlatingCellState.Init);
+
+            EnumLoop<PlatingCellState>.ForEach((item) => { fsm.MapState((int)item, item.ToString()); });
+
+            EnumLoop<PlatingCellState>.ForEach((item) => { fsm.MapMessage((int)item, item.ToString()); });
+        }
+        #region Initialize All
+        /// <summary>
+        /// 初始化
+        /// </summary>
+        /// <returns></returns>
+        private bool InitializeAll(object[] param)
+        {
+
+            if (_persistentValue == null)
+            {
+                LOG.WriteLog(eEvent.ERR_RESERVOIR, Module.ToString(), "persistent is null");
+                return false;
+            }
+            return true;
+           
+        }
+        /// <summary>
+        /// Initialize 监控
+        /// </summary>
+        /// <param name="param"></param>
+        /// <returns></returns>
+        private bool InitializeAllMonitor(object[] param)
+        {
+            RState ret = RState.Init;
+           
+            if (ret == RState.Failed || ret == RState.Timeout)
+            {
+                PostMsg(ReservoirMsg.Error);
+                return false;
+            }
+            return ret == RState.End;
+        }
+        #endregion
+
+        /// <summary>
+        /// EnterInit
+        /// </summary>
+        public void EnterInit()
+        {
+            if ((PlatingCellState)fsm.State != PlatingCellState.Idle) return;
+            else
+            {
+                CheckToPostMessage<PlatingCellState, PlatingCellMsg>(eEvent.ERR_PLATINGCELL, Module.ToString(), (int)PlatingCellMsg.Init);
+            }
+        }
+  
+         public bool Check(int msg, out string reason, params object[] args)
+        {
+            reason = "";
+            return true;
+        }
+
+        public bool CheckAcked(int msg)
+        {
+            throw new NotImplementedException();
+        }
+
+        public int Invoke(string function, params object[] args)
+        {
+            throw new NotImplementedException();
+        }
+    }
+}

+ 1 - 0
PunkHPX8_RT/PunkHPX8_RT.csproj

@@ -298,6 +298,7 @@
     <Compile Include="Modules\LPs\LoadPortUnDockRoutine.cs" />
     <Compile Include="Modules\ModuleHomeAllRoutine.cs" />
     <Compile Include="Devices\Reservoir\CAPumpOnRoutine.cs" />
+    <Compile Include="Modules\PlatingCell\PlatingCellEntity.cs" />
     <Compile Include="Modules\Reservoir\DIReservoirInitializeRoutine.cs" />
     <Compile Include="Modules\Reservoir\DMReservoirInitializeRoutine.cs" />
     <Compile Include="Modules\Reservoir\HSReservoirInitializeRoutine.cs" />

+ 0 - 2
PunkHPX8_Twincate/PunkHPX8/PlcTest/POUs/MAIN.TcPOU

@@ -369,8 +369,6 @@ VAR
 	RES1_2_DO_16CHANNEL_EL2809_N201_1 AT%Q* :BOOL;
 	//Reservoir1 CaPumpEnable
 	RES1_2_DO_16CHANNEL_EL2809_N201_3 AT%Q* :BOOL;
-	//Reservoir1 ReturnValveEnable
-	RES1_2_DO_16CHANNEL_EL2809_N201_5 AT%Q* :BOOL;
 	//Reservoir1 AnPumpSpeed
 	RES1_2_AO_8CHANNEL_0_10V_EL4008_N204_1  AT%Q* :DINT;
 	//Reservoir1 CaPumpSpeed