|
@@ -1,12 +1,18 @@
|
|
-using Aitex.Core.RT.Device;
|
|
|
|
|
|
+using Aitex.Core.RT.DataCenter;
|
|
|
|
+using Aitex.Core.RT.Device;
|
|
using Aitex.Core.RT.Log;
|
|
using Aitex.Core.RT.Log;
|
|
using Aitex.Core.RT.OperationCenter;
|
|
using Aitex.Core.RT.OperationCenter;
|
|
using Aitex.Core.Util;
|
|
using Aitex.Core.Util;
|
|
|
|
+using MECF.Framework.Common.CommonData.Reservoir;
|
|
|
|
+using MECF.Framework.Common.IOCore;
|
|
using MECF.Framework.Common.Persistent.Reservoirs;
|
|
using MECF.Framework.Common.Persistent.Reservoirs;
|
|
|
|
+using MECF.Framework.Common.TwinCat;
|
|
|
|
+using MECF.Framework.Common.Utilities;
|
|
using PunkHPX8_RT.Modules;
|
|
using PunkHPX8_RT.Modules;
|
|
using System;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Linq;
|
|
|
|
+using System.Reflection;
|
|
using System.Text;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
@@ -18,6 +24,29 @@ namespace PunkHPX8_RT.Devices.Reservoir
|
|
private const string AUTO = "Auto";
|
|
private const string AUTO = "Auto";
|
|
private const string MANUAL = "Manual";
|
|
private const string MANUAL = "Manual";
|
|
private const string DISABLE = "Disable";
|
|
private const string DISABLE = "Disable";
|
|
|
|
+
|
|
|
|
+ private const string CA_PUMP_RUNNING="CaPumpRunning";
|
|
|
|
+ private const string AN_TOWER_HIGH="AnTowerHigh";
|
|
|
|
+ private const string AN_TOWER_LOW="AnTowerLow";
|
|
|
|
+ private const string CA_LEVEL="CaLevel";
|
|
|
|
+ private const string CA_WATER_LEVEL="CaWaterLevel";
|
|
|
|
+ private const string AN_FLOW="AnFlow";
|
|
|
|
+ private const string AN_PUMP_ENABLE="AnPumpEnable";
|
|
|
|
+ private const string AN_PUMP_SPEED="AnPumpSpeed";
|
|
|
|
+ private const string CA_FLOW="CaFlow";
|
|
|
|
+ private const string CA_PUMP_ENABLE="CaPumpEnable";
|
|
|
|
+ private const string CA_PUMP_SPEED="CaPumpSpeed";
|
|
|
|
+ private const string RETURN_VALVE_OPENING="ReturnValveOpening";
|
|
|
|
+ private const string RETURN_VALVE="ReturnValve";
|
|
|
|
+ private const string RETURN_VALVE_PERCENT="ReturnValvePercent";
|
|
|
|
+ private const string CA_DI_REPLEN="CaDiReplen";
|
|
|
|
+ private const string AN_DI_REPLEN="AnDiReplen";
|
|
|
|
+ private const string SAMPLE_OUT="SampleOut";
|
|
|
|
+ private const string DEGAS_ENABLE="DegasEnable";
|
|
|
|
+ private const string HED_FLOW="HedFlow";
|
|
|
|
+ private const string HED_FLOW_ENABLE="HedFlowEnable";
|
|
|
|
+ private const string PH_FLOW_VALVE="PhFlowValve";
|
|
|
|
+ private const string PH_VALUE="PhValue";
|
|
#endregion
|
|
#endregion
|
|
|
|
|
|
#region 内部变量
|
|
#region 内部变量
|
|
@@ -25,6 +54,15 @@ namespace PunkHPX8_RT.Devices.Reservoir
|
|
/// Prewet 持久性数值对象
|
|
/// Prewet 持久性数值对象
|
|
/// </summary>
|
|
/// </summary>
|
|
private ReservoirsPersistentValue _persistentValue;
|
|
private ReservoirsPersistentValue _persistentValue;
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 变量是否初始化字典
|
|
|
|
+ /// </summary>
|
|
|
|
+ private Dictionary<string, bool> _variableInitializeDic = new Dictionary<string, bool>();
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 数据
|
|
|
|
+ /// </summary>
|
|
|
|
+ private ReservoirData _reservoirData = new ReservoirData();
|
|
/// <summary>
|
|
/// <summary>
|
|
/// 定时器
|
|
/// 定时器
|
|
/// </summary>
|
|
/// </summary>
|
|
@@ -44,6 +82,11 @@ namespace PunkHPX8_RT.Devices.Reservoir
|
|
/// 是否自动
|
|
/// 是否自动
|
|
/// </summary>
|
|
/// </summary>
|
|
public bool IsAuto { get { return _persistentValue.OperatingMode == AUTO; } }
|
|
public bool IsAuto { get { return _persistentValue.OperatingMode == AUTO; } }
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 数据
|
|
|
|
+ /// </summary>
|
|
|
|
+ public ReservoirData ReservoirData { get { return _reservoirData; } }
|
|
#endregion
|
|
#endregion
|
|
/// <summary>
|
|
/// <summary>
|
|
/// 构造函数
|
|
/// 构造函数
|
|
@@ -90,6 +133,7 @@ namespace PunkHPX8_RT.Devices.Reservoir
|
|
/// </summary>
|
|
/// </summary>
|
|
private void SubscribeData()
|
|
private void SubscribeData()
|
|
{
|
|
{
|
|
|
|
+ DATA.Subscribe($"{Module}.ReservoirData", () => _reservoirData, SubscriptionAttribute.FLAG.IgnoreSaveDB);
|
|
|
|
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <summary>
|
|
@@ -108,7 +152,47 @@ namespace PunkHPX8_RT.Devices.Reservoir
|
|
/// </summary>
|
|
/// </summary>
|
|
protected virtual void SubscribeValueAction()
|
|
protected virtual void SubscribeValueAction()
|
|
{
|
|
{
|
|
-
|
|
|
|
|
|
+ BeckhoffIoSubscribeUpdateVariable(CA_PUMP_RUNNING);
|
|
|
|
+ BeckhoffIoSubscribeUpdateVariable(AN_TOWER_HIGH);
|
|
|
|
+ BeckhoffIoSubscribeUpdateVariable(AN_TOWER_LOW);
|
|
|
|
+ BeckhoffIoSubscribeUpdateVariable(CA_LEVEL);
|
|
|
|
+ BeckhoffIoSubscribeUpdateVariable(CA_WATER_LEVEL);
|
|
|
|
+ BeckhoffIoSubscribeUpdateVariable(CA_PUMP_ENABLE);
|
|
|
|
+ BeckhoffIoSubscribeUpdateVariable(CA_PUMP_SPEED);
|
|
|
|
+ BeckhoffIoSubscribeUpdateVariable(CA_DI_REPLEN);
|
|
|
|
+ BeckhoffIoSubscribeUpdateVariable(RETURN_VALVE);
|
|
|
|
+ BeckhoffIoSubscribeUpdateVariable(RETURN_VALVE_OPENING);
|
|
|
|
+ BeckhoffIoSubscribeUpdateVariable(RETURN_VALVE_PERCENT);
|
|
|
|
+ }
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 订阅IO变量
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="variable"></param>
|
|
|
|
+ private void BeckhoffIoSubscribeUpdateVariable(string variable)
|
|
|
|
+ {
|
|
|
|
+ _variableInitializeDic[variable] = false;
|
|
|
|
+ IOModuleManager.Instance.SubscribeModuleVariable(Module, variable, UpdateVariableValue);
|
|
|
|
+ }
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 更新变量数值
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="variable"></param>
|
|
|
|
+ /// <param name="value"></param>
|
|
|
|
+ private void UpdateVariableValue(string variable, object value)
|
|
|
|
+ {
|
|
|
|
+ if (!_reservoirData.IsDataInitialized)
|
|
|
|
+ {
|
|
|
|
+ _reservoirData.IsDataInitialized = true;
|
|
|
|
+ }
|
|
|
|
+ PropertyInfo property = _reservoirData.GetType().GetProperty(variable);
|
|
|
|
+ if (property != null)
|
|
|
|
+ {
|
|
|
|
+ property.SetValue(_reservoirData, value);
|
|
|
|
+ }
|
|
|
|
+ if (_variableInitializeDic.ContainsKey(variable) && !_variableInitializeDic[variable])
|
|
|
|
+ {
|
|
|
|
+ _variableInitializeDic[variable] = true;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <summary>
|
|
/// 定时器
|
|
/// 定时器
|