|
@@ -1,6 +1,9 @@
|
|
|
using Aitex.Core.RT.Device;
|
|
|
using Aitex.Core.RT.Log;
|
|
|
+using Aitex.Core.RT.OperationCenter;
|
|
|
+using Aitex.Core.Util;
|
|
|
using MECF.Framework.Common.Persistent.Reservoirs;
|
|
|
+using PunkHPX8_RT.Modules;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
@@ -22,6 +25,10 @@ namespace PunkHPX8_RT.Devices.Reservoir
|
|
|
/// Prewet 持久性数值对象
|
|
|
/// </summary>
|
|
|
private ReservoirsPersistentValue _persistentValue;
|
|
|
+ /// <summary>
|
|
|
+ /// 定时器
|
|
|
+ /// </summary>
|
|
|
+ private PeriodicJob _periodicJob;
|
|
|
#endregion
|
|
|
|
|
|
#region 属性
|
|
@@ -53,12 +60,17 @@ namespace PunkHPX8_RT.Devices.Reservoir
|
|
|
public bool Initialize()
|
|
|
{
|
|
|
InitializeParameter();
|
|
|
+ InitializeRoutine();
|
|
|
+ SubscribeData();
|
|
|
+ InitializeOperation();
|
|
|
+ SubscribeValueAction();
|
|
|
+ _periodicJob = new PeriodicJob(200, OnTimer, $"{Module}.Timer", true, true);
|
|
|
return true;
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 初始化参数
|
|
|
/// </summary>
|
|
|
- public void InitializeParameter()
|
|
|
+ private void InitializeParameter()
|
|
|
{
|
|
|
_persistentValue = ReservoirsPersistentManager.Instance.GetReservoirsPersistentValue(Module.ToString());
|
|
|
if (_persistentValue == null)
|
|
@@ -66,7 +78,134 @@ namespace PunkHPX8_RT.Devices.Reservoir
|
|
|
LOG.WriteLog(eEvent.ERR_RESERVOIR, Module.ToString(), "Persistent Value Object is not exist");
|
|
|
}
|
|
|
}
|
|
|
+ /// <summary>
|
|
|
+ /// 初始化Routine
|
|
|
+ /// </summary>
|
|
|
+ private void InitializeRoutine()
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ /// 订阅数据
|
|
|
+ /// </summary>
|
|
|
+ private void SubscribeData()
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ /// 初始化Operation
|
|
|
+ /// </summary>
|
|
|
+ private void InitializeOperation()
|
|
|
+ {
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ /// 订阅变量数值发生变化
|
|
|
+ /// </summary>
|
|
|
+ protected virtual void SubscribeValueAction()
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ /// 定时器
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ protected virtual bool OnTimer()
|
|
|
+ {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ #region Mode switch
|
|
|
+ /// <summary>
|
|
|
+ /// DisabledAction
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="cmd"></param>
|
|
|
+ /// <param name="param"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ private bool DisabledOperation(string cmd, object[] args)
|
|
|
+ {
|
|
|
+ string currentOperation = "Disabled";
|
|
|
+ string preOperation = _persistentValue.OperatingMode;
|
|
|
+ _persistentValue.OperatingMode = currentOperation;
|
|
|
+
|
|
|
+ LOG.WriteLog(eEvent.INFO_RESERVOIR, Module, $"Operating mode is switched from {preOperation} to {currentOperation}");
|
|
|
+
|
|
|
+ ReservoirsPersistentManager.Instance.UpdatePersistentValue(Module);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ /// ManualAction
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="cmd"></param>
|
|
|
+ /// <param name="param"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ private bool ManualOperation(string cmd, object[] args)
|
|
|
+ {
|
|
|
+ string currentOperation = "Manual";
|
|
|
+ string preOperation = _persistentValue.OperatingMode;
|
|
|
+
|
|
|
+ _persistentValue.OperatingMode = currentOperation;
|
|
|
|
|
|
+ LOG.WriteLog(eEvent.INFO_RESERVOIR, Module, $"Operating mode is switched from {preOperation} to {currentOperation}");
|
|
|
+
|
|
|
+ ReservoirsPersistentManager.Instance.UpdatePersistentValue(Module);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ /// AutoAction
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="cmd"></param>
|
|
|
+ /// <param name="param"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ private bool AutoOperation(string cmd, object[] args)
|
|
|
+ {
|
|
|
+ string currentOperation = "Auto";
|
|
|
+ string preOperation = _persistentValue.OperatingMode;
|
|
|
+
|
|
|
+ _persistentValue.OperatingMode = currentOperation;
|
|
|
+
|
|
|
+ LOG.WriteLog(eEvent.INFO_RESERVOIR, Module, $"Operating mode is switched from {preOperation} to {currentOperation}");
|
|
|
+
|
|
|
+ ReservoirsPersistentManager.Instance.UpdatePersistentValue(Module);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ /// EngineeringModeAction
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="cmd"></param>
|
|
|
+ /// <param name="param"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ private bool EngineeringModeOperation(string cmd, object[] args)
|
|
|
+ {
|
|
|
+ string currentRecipeOperation = "Engineering";
|
|
|
+ if (_persistentValue != null)
|
|
|
+ {
|
|
|
+ _persistentValue.RecipeOperatingMode = currentRecipeOperation;
|
|
|
+ }
|
|
|
+ ReservoirsPersistentManager.Instance.UpdatePersistentValue(Module);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ /// ProductionAction
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="cmd"></param>
|
|
|
+ /// <param name="param"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ private bool ProductionModeOperation(string cmd, object[] args)
|
|
|
+ {
|
|
|
+ string currentRecipeOperation = "Production";
|
|
|
+ if (_persistentValue != null)
|
|
|
+ {
|
|
|
+ _persistentValue.RecipeOperatingMode = currentRecipeOperation;
|
|
|
+ }
|
|
|
+ ReservoirsPersistentManager.Instance.UpdatePersistentValue(Module);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ #endregion
|
|
|
|
|
|
/// <summary>
|
|
|
/// 监控
|