Browse Source

add reservoir/platingcell persistent releated

chenzk 3 days ago
parent
commit
19158728c5

+ 14 - 6
PunkHPX8_RT/Devices/PlatingCell/PlatingCellDevice.cs

@@ -20,6 +20,7 @@ using PunkHPX8_RT.Devices.Reservoir;
 using PunkHPX8_RT.Devices.VpwMain;
 using PunkHPX8_RT.Modules;
 using PunkHPX8_RT.Modules.PlatingCell;
+using PunkHPX8_RT.Modules.Reservoir;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -428,7 +429,7 @@ namespace PunkHPX8_RT.Devices.PlatingCell
                 string preOperation = _persistentValue.OperatingMode;
                 if (platingCellEntity.IsBusy)
                 {
-                    LOG.WriteLog(eEvent.ERR_METAL, Module, $"{Module} is Busy, can't switch to Disabled mode");
+                    LOG.WriteLog(eEvent.ERR_PLATINGCELL, Module, $"{Module} is Busy, can't switch to Disabled mode");
                     return false;
                 }
                 //if (SchedulerMetalTimeManager.Instance.Contained(Module))
@@ -439,7 +440,7 @@ namespace PunkHPX8_RT.Devices.PlatingCell
                 platingCellEntity.EnterInit();
                 _persistentValue.OperatingMode = currentOperation;
 
-                LOG.WriteLog(eEvent.INFO_METAL, Module, $"Operating mode is switched from {preOperation} to {currentOperation}");
+                LOG.WriteLog(eEvent.INFO_PLATINGCELL, Module, $"Operating mode is switched from {preOperation} to {currentOperation}");
             }
             PlatingCellPersistentManager.Instance.UpdatePersistentValue(Module);
             return true;
@@ -459,7 +460,7 @@ namespace PunkHPX8_RT.Devices.PlatingCell
                 string preOperation = _persistentValue.OperatingMode;
                 if (platingCellEntity.IsBusy)
                 {
-                    LOG.WriteLog(eEvent.ERR_METAL, Module, $"{Module} is Busy, can't switch to Manual mode");
+                    LOG.WriteLog(eEvent.ERR_PLATINGCELL, Module, $"{Module} is Busy, can't switch to Manual mode");
                     return false;
                 }
                 //if (SchedulerMetalTimeManager.Instance.Contained(Module))
@@ -470,7 +471,7 @@ namespace PunkHPX8_RT.Devices.PlatingCell
                 platingCellEntity.EnterInit();
                 _persistentValue.OperatingMode = currentOperation;
 
-                LOG.WriteLog(eEvent.INFO_METAL, Module, $"Operating mode is switched from {preOperation} to {currentOperation}");
+                LOG.WriteLog(eEvent.INFO_PLATINGCELL, Module, $"Operating mode is switched from {preOperation} to {currentOperation}");
             }
 
             PlatingCellPersistentManager.Instance.UpdatePersistentValue(Module);
@@ -485,19 +486,26 @@ namespace PunkHPX8_RT.Devices.PlatingCell
         public bool AutoOperation(string cmd, object[] args)
         {
             string currentOperation = "Auto";
+            ReservoirEntity reservoirEntity = Singleton<RouteManager>.Instance.GetModule<ReservoirEntity>(_reservoirName);
+            if (reservoirEntity!=null  &&  reservoirEntity.PersistentValue.OperatingMode!="Auto")
+            {
+                LOG.WriteLog(eEvent.ERR_PLATINGCELL, Module, $"{_reservoirName} not in Auto mode, can't switch to Auto mode");
+                return false;
+            }
             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");
+                    LOG.WriteLog(eEvent.ERR_PLATINGCELL, Module, $"{Module} is Busy, can't switch to Auto 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_PLATINGCELL, Module, $"Operating mode is switched from {preOperation} to {currentOperation}");
             }
             PlatingCellPersistentManager.Instance.UpdatePersistentValue(Module);
             return true;

+ 1 - 0
PunkHPX8_RT/Devices/Reservoir/ReservoirDevice.cs

@@ -787,6 +787,7 @@ namespace PunkHPX8_RT.Devices.Reservoir
             LOG.WriteLog(eEvent.INFO_RESERVOIR, Module, $"Operating mode is switched from {preOperation} to {currentOperation}");
             
             ReservoirsPersistentManager.Instance.UpdatePersistentValue(Module);
+            _platingCellDevice.ManualOperation("", null); //切manual 把对应的platingcell 也切换成manual
             return true;
         }
         /// <summary>

+ 4 - 0
PunkHPX8_RT/Modules/Reservoir/ReservoirEntity.cs

@@ -124,6 +124,10 @@ namespace PunkHPX8_RT.Modules.Reservoir
         /// </summary>
         public ResRecipe CurrentRecipe { get { return LoadCurrentRecipe(); } }
         /// <summary>
+        /// 当前persistent
+        /// </summary>
+        public ReservoirsPersistentValue PersistentValue { get { return _persistentValue; } }
+        /// <summary>
         /// 用量
         /// </summary>
         public ReservoirUsage ReservoirUsage { get { return ReservoirUsageManager.Instance.GetReservoirUsage(Module.ToString()); } }