| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 | 
							- using Aitex.Common.Util;
 
- using Aitex.Core.RT.Log;
 
- using Aitex.Core.Util;
 
- using MECF.Framework.Common.ToolLayout;
 
- using System;
 
- using System.Collections.Generic;
 
- using System.IO;
 
- using System.Linq;
 
- using System.Reflection;
 
- using System.Text;
 
- using System.Threading.Tasks;
 
- namespace MECF.Framework.Common.Persistent.Reservoirs
 
- {
 
-     public class ReplenPersistentManager : Singleton<ReplenPersistentManager>
 
-     {
 
-         #region 内部变量
 
-         private Dictionary<string, Dictionary<string, ReplenPersistentValue>> _persistentValueDic = new Dictionary<string, Dictionary<string, ReplenPersistentValue>>();
 
-         private Dictionary<string, Dictionary<string, string>> _persistentValuePathDic = new Dictionary<string, Dictionary<string, string>>();
 
-         private int _replenNum = 0;
 
-         #endregion
 
-         /// <summary>
 
-         /// 初始化
 
-         /// </summary>
 
-         public void Initialize()
 
-         {
 
-             try
 
-             {
 
-                 List<string> installedModules = ReservoirItemManager.Instance.InstalledModules;
 
-                 foreach (string module in installedModules)
 
-                 {
 
-                     ReservoirItem reservoirItem = ReservoirItemManager.Instance.GetReservoirItem(module);
 
-                     if (reservoirItem.ChemReplenType == "" || reservoirItem.ChemReplenPumps == 0)
 
-                     {
 
-                         continue;
 
-                     }
 
-                     else
 
-                     {
 
-                         _persistentValueDic[module] = new Dictionary<string, ReplenPersistentValue>();
 
-                         _persistentValuePathDic[module] = new Dictionary<string, string>();
 
-                         _replenNum = reservoirItem.ChemReplenPumps;
 
-                         string foldStr = $"{PathManager.GetCfgDir()}Persistent\\Reservoirs\\{module}DosingSystem";
 
-                         if (!Directory.Exists(foldStr))
 
-                         {
 
-                             Directory.CreateDirectory(foldStr);
 
-                         }
 
-                         for (int i = 0; i < _replenNum; i++)
 
-                         {
 
-                             string replenName = "Replen"+(i+1).ToString();
 
-                             string str = $"{foldStr}\\{replenName}Persistent.xml";
 
-                             _persistentValuePathDic[module][replenName] = str;
 
-                             if (File.Exists(str))
 
-                             {
 
-                                 ReplenPersistentValue replenPersistentValue = CustomXmlSerializer.Deserialize<ReplenPersistentValue>(new FileInfo(str));
 
-                                 if (replenPersistentValue != null)
 
-                                 {
 
-                                     _persistentValueDic[module][replenName] = replenPersistentValue;
 
-                                 }
 
-                             }
 
-                             else
 
-                             {
 
-                                 ReplenPersistentValue persistentValue = new ReplenPersistentValue();
 
-                                 persistentValue.ReplenPumpFactor = 1;
 
-                                 persistentValue.ReplenName = replenName;
 
-                                 persistentValue.AutoDosingStartAmpHour = 0;
 
-                                 persistentValue.AutoDosingStartTime = DateTime.MinValue;
 
-                                 persistentValue.IsDosingRunning = false;
 
-                                 persistentValue.CurrentDosingVolume = 0;
 
-                                 persistentValue.TargetDosingVolume = 0;
 
-                                 persistentValue.RemainDosingVolume = 0;
 
-                                 persistentValue.OperatingMode = "Manual";
 
-                                 _persistentValueDic[module][replenName] = persistentValue;
 
-                                 UpdatePersistentValue(module, replenName);
 
-                             }
 
-                         }
 
-                     }
 
-            
 
-                 }
 
-             }
 
-             catch (Exception ex)
 
-             {
 
-                 LOG.WriteLog(eEvent.ERR_RESERVOIR, "System", "Load ReplenPersistent xml exception");
 
-             }
 
-         }
 
-         /// <summary>
 
-         /// 获取Replen Persistent数值
 
-         /// </summary>
 
-         /// <returns></returns>
 
-         public ReplenPersistentValue GetReplenPersistentValue(string module, string replenName)
 
-         {
 
-             if (_persistentValueDic.ContainsKey(module) && _persistentValueDic[module].ContainsKey(replenName))
 
-             {
 
-                 return _persistentValueDic[module][replenName];
 
-             }
 
-             else
 
-             {
 
-                 return null;
 
-             }
 
-         }
 
-         /// <summary>
 
-         /// 更新PersistentValue
 
-         /// </summary>
 
-         /// <returns></returns>
 
-         public void UpdatePersistentValue(string module, string replenName)
 
-         {
 
-             if (_persistentValueDic.ContainsKey(module) && _persistentValueDic[module].ContainsKey(replenName))
 
-             {
 
-                 try
 
-                 {
 
-                     CustomXmlSerializer.Serialize(_persistentValueDic[module][replenName], _persistentValuePathDic[module][replenName]);
 
-                 }
 
-                 catch (Exception ex)
 
-                 {
 
-                     LOG.WriteLog(eEvent.ERR_RESERVOIR, module, "Update ReplenPersistent xml file excepetion");
 
-                 }
 
-             }
 
-             else
 
-             {
 
-                 LOG.WriteLog(eEvent.ERR_RESERVOIR, module, "Update ReplenPersistent xml file excepetion");
 
-             }
 
-         }
 
-     }
 
- }
 
 
  |