Browse Source

update ReservoirCellHomeRoutine

chenkui 2 weeks ago
parent
commit
b20562da35

+ 1 - 1
PunkHPX8_RT/Config/Devices/PowerSupplierCfg-Simulator.xml

@@ -15,7 +15,7 @@
   <PowerSupplierDeviceConfig Name="Power2" IpAddress="127.0.0.1" Port="821" Type="0" SendTimeout="2000" RecvTimeout="2000"> 
     <Device Name="Power2-1" Address="1"  VoltageUnitSetScale ="1000" UnitSetScale="1000000" UnitScale="1000000" VoltageUnitScale="10000"/>
   </PowerSupplierDeviceConfig>
-  <PowerSupplierDeviceConfig Name="Power3" IpAddress="192.168.0.200" Port="20" Type="0" SendTimeout="2000" RecvTimeout="2000"> 
+  <PowerSupplierDeviceConfig Name="Power3" IpAddress="127.0.0.1" Port="822" Type="0" SendTimeout="2000" RecvTimeout="2000"> 
     <Device Name="Power3-1" Address="1"  
 			VoltageUnitSetScale ="1000"
 			VoltageUnitScale="100"

+ 23 - 0
PunkHPX8_RT/Modules/ModuleMatcherManager.cs

@@ -95,6 +95,29 @@ namespace PunkHPX8_RT.Modules
             }
         }
         /// <summary>
+        /// 是否为配对第一个
+        /// </summary>
+        /// <param name="module"></param>
+        /// <returns></returns>
+        public bool IsMatcherFirst(string module)
+        {
+            switch (module)
+            {
+                case "PlatingCell1":
+                case "PlatingCell3":
+                case "PlatingCell5":
+                case "PlatingCell7":
+                case "PlatingCell9":
+                case "PlatingCell11":
+                    return true;
+                case "VPW1":
+                case "VPW3":
+                    return true;
+                default:
+                    return false;
+            }
+        }
+        /// <summary>
         /// 获取垂直电机的Mathcer集合
         /// </summary>
         /// <param name="vertical"></param>

+ 1 - 1
PunkHPX8_RT/Modules/PlatingCell/PlatingCellEntity.cs

@@ -260,7 +260,7 @@ namespace PunkHPX8_RT.Modules.PlatingCell
         /// </summary>
         private void InitialFsm()
         {
-            fsm = new StateMachine<PlatingCellEntity>(Module.ToString(), (int)PlatingCellState.Idle, 100);
+            fsm = new StateMachine<PlatingCellEntity>(Module.ToString(), (int)PlatingCellState.Init, 100);
             fsm.EnableRepeatedMsg(true);
 
             AnyStateTransition(PlatingCellMsg.Error, NullFunc, PlatingCellState.Error);

+ 58 - 16
PunkHPX8_RT/Modules/ReservoirCellHomeRoutine.cs

@@ -11,6 +11,7 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using System.Windows.Markup;
 
 namespace PunkHPX8_RT.Modules
 {
@@ -20,11 +21,14 @@ namespace PunkHPX8_RT.Modules
         {
             ReservoirHome,
             ReservoirHomeWait,
+            WaitMatcherIdle,
             CellHome,
             End,
         }
         #region 内部变量
         private ReservoirEntity _reservoirEntity;
+        private PlatingCellEntity _platingCellEntity;
+        private string _matcher = "";
         #endregion
         /// <summary>
         /// 构造函数
@@ -48,6 +52,7 @@ namespace PunkHPX8_RT.Modules
         {
             Runner.RunIf(ReservoirStep.ReservoirHome, _reservoirEntity.IsAuto, ReservoirHome, _delay_1ms)
                 .WaitWithStopConditionIf(ReservoirStep.ReservoirHomeWait,_reservoirEntity.IsAuto,() => { return _reservoirEntity.IsIdle; }, () => { return _reservoirEntity.State != ReservoirState.Initializing && !_reservoirEntity.IsIdle; })
+                .Wait(ReservoirStep.WaitMatcherIdle,ChechMatcherIdle,_delay_2m)
                 .Run(ReservoirStep.CellHome, MetalsHome, _delay_1ms)
                 .End(ReservoirStep.End, NullFun, _delay_1ms);
             return Runner.Status;
@@ -62,30 +67,67 @@ namespace PunkHPX8_RT.Modules
             return reservoirInvoke==(int)ReservoirMsg.Initialize;
         }
         /// <summary>
-        /// Metal Home
+        /// 检验匹配另一个是否完成Idle
         /// </summary>
         /// <returns></returns>
-        private bool MetalsHome()
+        private bool ChechMatcherIdle()
         {
             ReservoirItem reservoirItem = ReservoirItemManager.Instance.GetReservoirItem(Module.ToString());
-            if (reservoirItem != null)
+            if (reservoirItem == null)
+            {
+                return false;
+            }
+            List<PlatingCellItem> platingCellItems = reservoirItem.PlatingCells;
+            if (platingCellItems == null || platingCellItems.Count == 0)
             {
-                List<PlatingCellItem> platingCellItems = reservoirItem.PlatingCells;
-                if (platingCellItems != null && platingCellItems.Count > 0)
+                return false;
+            }
+            foreach (PlatingCellItem item in platingCellItems)
+            {
+                if (!item.Installed)
                 {
-                    foreach (PlatingCellItem item in platingCellItems)
-                    {
-                        if (item.Installed)
-                        {
-                            PlatingCellEntity moduleEntity = Singleton<RouteManager>.Instance.GetModule<PlatingCellEntity>(item.ModuleName);
-                            if (moduleEntity.IsAuto)
-                            {
-                                moduleEntity.Invoke("HomeAll");
-                            }
-                        }
-                    }
+                    continue;
                 }
+                _platingCellEntity= Singleton<RouteManager>.Instance.GetModule<PlatingCellEntity>(item.ModuleName);
+                _matcher=ModuleMatcherManager.Instance.GetMatcherByModule(item.ModuleName);
+                break;
+            }
+            if (string.IsNullOrEmpty(_matcher))
+            {
+                return false;
+            }
+
+            if (ModuleMatcherManager.Instance.IsMatcherFirst(_platingCellEntity.Module.ToString()))
+            {
+                return true;
+            }
+
+            PlatingCellEntity matherEntity = Singleton<RouteManager>.Instance.GetModule<PlatingCellEntity>(_matcher);
+            if(matherEntity == null)
+            {
+                return true;
             }
+            if (matherEntity.IsDisable)
+            {
+                return true;
+            }
+            if (!matherEntity.IsAuto)
+            {
+                return true;
+            }
+            if (matherEntity.IsError)
+            {
+                return true;
+            }
+            return matherEntity.IsIdle;
+        }
+        /// <summary>
+        /// Metal Home
+        /// </summary>
+        /// <returns></returns>
+        private bool MetalsHome()
+        {
+            _platingCellEntity.Invoke("HomeAll");
             return true;
         }
         /// <summary>

+ 0 - 11
PunkHPX8_RT/Modules/RouteManager.cs

@@ -713,17 +713,6 @@ namespace PunkHPX8_RT.Modules
             {
                 item.Start();
             }
-
-            foreach (string item in keys)
-            {
-                if (Enum.TryParse(item, out ModuleName moduleName))
-                {
-                    if (ModuleHelper.IsReservoir(moduleName))
-                    {
-                        IModuleEntity moduleEntity = _moduleEntitiesDic[item];
-                    }
-                }
-            }
             _homeStopWatch.Restart();
             _jobCycle.RemoveAllJob();
             return true;