|
@@ -2,19 +2,23 @@
|
|
|
using Aitex.Core.RT.Device;
|
|
|
using Aitex.Core.RT.Log;
|
|
|
using Aitex.Core.RT.OperationCenter;
|
|
|
+using Aitex.Core.RT.Routine;
|
|
|
using Aitex.Core.RT.SCCore;
|
|
|
using Aitex.Core.Util;
|
|
|
+using MECF.Framework.Common.Algorithm;
|
|
|
using MECF.Framework.Common.Beckhoff.ModuleIO;
|
|
|
using MECF.Framework.Common.CommonData.Prewet;
|
|
|
using MECF.Framework.Common.CommonData.Vpw;
|
|
|
using MECF.Framework.Common.IOCore;
|
|
|
using MECF.Framework.Common.Persistent.Prewet;
|
|
|
using MECF.Framework.Common.Persistent.VpwMain;
|
|
|
+using PunkHPX8_Core;
|
|
|
using PunkHPX8_RT.Modules;
|
|
|
using PunkHPX8_RT.Modules.VpwMain;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
|
+using System.Net.NetworkInformation;
|
|
|
using System.Reflection;
|
|
|
using System.Text;
|
|
|
using System.Threading.Tasks;
|
|
@@ -50,6 +54,13 @@ namespace PunkHPX8_RT.Devices.VpwMain
|
|
|
private const string DEGAS_PUMP_PRESSURE = "DegasPumpPressure";
|
|
|
#endregion
|
|
|
|
|
|
+ private enum VPWOperation
|
|
|
+ {
|
|
|
+ None,
|
|
|
+ PumpEnable,
|
|
|
+ PumpDisable
|
|
|
+ }
|
|
|
+
|
|
|
#region 内部变量
|
|
|
/// <summary>
|
|
|
/// 变量是否初始化字典
|
|
@@ -63,6 +74,15 @@ namespace PunkHPX8_RT.Devices.VpwMain
|
|
|
/// 持久性数值
|
|
|
/// </summary>
|
|
|
private VpwMainPersistentValue _vpwMainPersistentValue;
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// Pump Enable routine
|
|
|
+ /// </summary>
|
|
|
+ private BoosterPumpEnableRoutine _boosterPumpEnableRoutine;
|
|
|
+ /// <summary>
|
|
|
+ /// Pump Disable routine
|
|
|
+ /// </summary>
|
|
|
+ private BoosterPumpDisableRoutine _boosterPumpDisableRoutine;
|
|
|
/// <summary>
|
|
|
/// 上一次Booster泵速
|
|
|
/// </summary>
|
|
@@ -71,8 +91,34 @@ namespace PunkHPX8_RT.Devices.VpwMain
|
|
|
/// 定时器任务
|
|
|
/// </summary>
|
|
|
private PeriodicJob _periodicJob;
|
|
|
-
|
|
|
+ /// <summary>
|
|
|
+ /// 是否数据完成初台化
|
|
|
+ /// </summary>
|
|
|
private bool _isDataInitialized;
|
|
|
+ /// <summary>
|
|
|
+ /// pdi控制中的p
|
|
|
+ /// </summary>
|
|
|
+ private double _pumpKp;
|
|
|
+ /// <summary>
|
|
|
+ /// pdi控制中的i
|
|
|
+ /// </summary>
|
|
|
+ private double _pumpKi;
|
|
|
+ /// <summary>
|
|
|
+ /// pdi控制中的d
|
|
|
+ /// </summary>
|
|
|
+ private double _pumpKd;
|
|
|
+ /// <summary>
|
|
|
+ /// 操作当前状态
|
|
|
+ /// </summary>
|
|
|
+ private RState _status;
|
|
|
+ /// <summary>
|
|
|
+ /// 当前操作
|
|
|
+ /// </summary>
|
|
|
+ private VPWOperation _currentOperation;
|
|
|
+ /// <summary>
|
|
|
+ /// 启动自动调泵速
|
|
|
+ /// </summary>
|
|
|
+ private bool _isStartAutoSpeed;
|
|
|
#endregion
|
|
|
|
|
|
#region 属性
|
|
@@ -124,7 +170,8 @@ namespace PunkHPX8_RT.Devices.VpwMain
|
|
|
/// </summary>
|
|
|
private void InitializeRoutine()
|
|
|
{
|
|
|
-
|
|
|
+ _boosterPumpEnableRoutine = new BoosterPumpEnableRoutine(Module, this);
|
|
|
+ _boosterPumpDisableRoutine = new BoosterPumpDisableRoutine(Module, this);
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 订阅
|
|
@@ -218,19 +265,20 @@ namespace PunkHPX8_RT.Devices.VpwMain
|
|
|
OP.Subscribe($"{Module}.VacuumPumpDisable", (cmd, para) => { return VacuumPumpDisable(); });
|
|
|
OP.Subscribe($"{Module}.VacuumPumpSpeedEnable", (cmd, para) => { return VacuumSpeedEnable(); });
|
|
|
OP.Subscribe($"{Module}.VacuumPumpSpeedDisable", (cmd, para) => { return VacuumSpeedDisable(); });
|
|
|
- OP.Subscribe($"{Module}.VacuumPumpSpeed", (cmd, para) => { return BoosterPumpSpeedKeyDownOperation(cmd, para); });
|
|
|
+ OP.Subscribe($"{Module}.VacuumPumpSpeed", (cmd, para) => { return WriteVacuumSpeedOperation(cmd, para); });
|
|
|
OP.Subscribe($"{Module}.DegasPumpEnable", (cmd, para) => { return DegasPumpEnable(); });
|
|
|
OP.Subscribe($"{Module}.DegasPumpDisable", (cmd, para) => { return DegasPumpDisable(); });
|
|
|
OP.Subscribe($"{Module}.DegasAdjustOn", (cmd, para) => { return DegasAdjustOn(); });
|
|
|
OP.Subscribe($"{Module}.DegasAdjustOff", (cmd, para) => { return DegasAdjustOff(); });
|
|
|
OP.Subscribe($"{Module}.DiwDegasValveOn", (cmd, para) => { return DiwDegasValveOn(); });
|
|
|
OP.Subscribe($"{Module}.DiwDegasValveOff", (cmd, para) => { return DiwDegasValveOff(); });
|
|
|
- OP.Subscribe($"{Module}.BoosterPumpEnable", (cmd, para) => { return BoosterPumpEnable(); });
|
|
|
- OP.Subscribe($"{Module}.BoosterPumpDisable", (cmd, para) => { return BoosterPumpDisable(); });
|
|
|
- OP.Subscribe($"{Module}.BoosterPumpSpeed", (cmd, para) => {
|
|
|
- short speed = short.Parse(para[0].ToString());
|
|
|
- return BoosterPumpSpeed(speed);
|
|
|
- });
|
|
|
+ OP.Subscribe($"{Module}.DiwEnable", (cmd, para) => { return DiwEnable(); });
|
|
|
+ OP.Subscribe($"{Module}.DiwDisable", (cmd, para) => { return DiwDisable(); });
|
|
|
+ OP.Subscribe($"{Module}.DiwProcessOn", (cmd, para) => { return DiwProcessOn(); });
|
|
|
+ OP.Subscribe($"{Module}.DiwProcessOff", (cmd, para) => { return DiwProcessOff(); });
|
|
|
+ OP.Subscribe($"{Module}.BoosterPumpEnable", BoosterPumpEnableOperation);
|
|
|
+ OP.Subscribe($"{Module}.BoosterPumpDisable", BoosterPumpDisableOperation);
|
|
|
+ OP.Subscribe($"{Module}.BoosterPumpSpeed", BoosterPumpSpeedKeyDownOperation);
|
|
|
|
|
|
OP.Subscribe($"{Module}.ChamberUp", (cmd, para) => { return ChamberUp(); });
|
|
|
OP.Subscribe($"{Module}.ChamberDown", (cmd, para) => { return ChamberDown(); });
|
|
@@ -298,6 +346,24 @@ namespace PunkHPX8_RT.Devices.VpwMain
|
|
|
{
|
|
|
return WriteVariableValue(VACUUM_PUMP_SPEED_ENABLE, false);
|
|
|
}
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 写入Vacuum速度
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="speed"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ private bool WriteVacuumSpeedOperation(string cmd, object[] param)
|
|
|
+ {
|
|
|
+ if (short.TryParse(param[0].ToString(), out var speed))
|
|
|
+ {
|
|
|
+ return WriteVariableValue(VACUUM_PUMP_SPEED, speed);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ LOG.WriteLog(eEvent.ERR_VPWMAIN, Module, $"Write VacuumSpeed {param[0]} is not short");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
/// <summary>
|
|
|
/// 写入速度
|
|
|
/// </summary>
|
|
@@ -362,6 +428,41 @@ namespace PunkHPX8_RT.Devices.VpwMain
|
|
|
|
|
|
#region Booster Pump
|
|
|
/// <summary>
|
|
|
+ /// Pump Enable操作
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="cmd"></param>
|
|
|
+ /// <param name="param"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public bool BoosterPumpEnableOperation(string cmd, object[] param)
|
|
|
+ {
|
|
|
+ if (_status == RState.Running)
|
|
|
+ {
|
|
|
+ LOG.WriteLog(eEvent.ERR_PREWET, Module.ToString(), $"{Module} current execute {_currentOperation},cannot Pump enable");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ _status = _boosterPumpEnableRoutine.Start();
|
|
|
+ _currentOperation = VPWOperation.PumpEnable;
|
|
|
+ return _status == RState.Running;
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ /// pump disable 操作
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="cmd"></param>
|
|
|
+ /// <param name="param"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public bool BoosterPumpDisableOperation(string cmd, object[] param)
|
|
|
+ {
|
|
|
+ if (_status == RState.Running)
|
|
|
+ {
|
|
|
+ LOG.WriteLog(eEvent.ERR_PREWET, Module.ToString(), $"{Module} current execute {_currentOperation},cannot Pump disable");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ _status = _boosterPumpDisableRoutine.Start();
|
|
|
+ _currentOperation = VPWOperation.PumpDisable;
|
|
|
+ return _status == RState.Running;
|
|
|
+ //return PumpDisable();
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
/// Booster Pump enable
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
@@ -382,9 +483,9 @@ namespace PunkHPX8_RT.Devices.VpwMain
|
|
|
/// </summary>
|
|
|
/// <param name="speed"></param>
|
|
|
/// <returns></returns>
|
|
|
- public bool BoosterPumpSpeed(short speed)
|
|
|
+ public bool BoosterPumpSpeed(short speed=0)
|
|
|
{
|
|
|
- return WriteVariableValue(BOOSTER_PUMP_SPEED, speed);
|
|
|
+ return WriteVariableValue(BOOSTER_PUMP_SPEED, speed == 0 ? _lastBoosterPumpSpeed : speed);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -407,7 +508,7 @@ namespace PunkHPX8_RT.Devices.VpwMain
|
|
|
{
|
|
|
_vpwMainPersistentValue.Speed = speed;
|
|
|
_lastBoosterPumpSpeed = speed;
|
|
|
- PrewetPersistentManager.Instance.UpdatePersistentValue(Module);
|
|
|
+ VpwMainPersistentManager.Instance.UpdatePersistentValue(Module);
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
@@ -575,6 +676,42 @@ namespace PunkHPX8_RT.Devices.VpwMain
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
+ #region DIW
|
|
|
+ /// <summary>
|
|
|
+ /// DIW Enable
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ public bool DiwEnable()
|
|
|
+ {
|
|
|
+ return WriteVariableValue(DIW_ENABLE, true);
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ /// DIW Disable
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ public bool DiwDisable()
|
|
|
+ {
|
|
|
+ return WriteVariableValue(DIW_ENABLE, false);
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ /// DIW Process On
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ public bool DiwProcessOn()
|
|
|
+ {
|
|
|
+ return WriteVariableValue(DIW_PROCESS, true);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// DIW Process On
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ public bool DiwProcessOff()
|
|
|
+ {
|
|
|
+ return WriteVariableValue(DIW_PROCESS, false);
|
|
|
+ }
|
|
|
+ #endregion
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 写变量
|
|
|
/// </summary>
|
|
@@ -600,8 +737,81 @@ namespace PunkHPX8_RT.Devices.VpwMain
|
|
|
_commonData.BoosterPumpPressureData.MaxError = SC.GetValue<double>($"VPWMain.PumpPressure.Error_Max");
|
|
|
_commonData.BoosterPumpPressureData.MaxWarning = SC.GetValue<double>($"VPWMain.PumpPressure.Warning_Max");
|
|
|
_commonData.PressureTarget = SC.GetValue<double>($"VPWMain.PressureTarget");
|
|
|
+ if (_status == RState.Running)
|
|
|
+ {
|
|
|
+ IRoutine routine = GetCurrentRoutine();
|
|
|
+ if (routine != null)
|
|
|
+ {
|
|
|
+ RState rsState = routine.Monitor();
|
|
|
+ if (rsState == RState.Failed || rsState == RState.Timeout)
|
|
|
+ {
|
|
|
+ _status = RState.Failed;
|
|
|
+ _currentOperation = VPWOperation.None;
|
|
|
+ LOG.WriteLog(eEvent.ERR_VPWMAIN, Module.ToString(), $"{_currentOperation} error");
|
|
|
+ _isStartAutoSpeed = false;
|
|
|
+ }
|
|
|
+ else if (rsState == RState.End)
|
|
|
+ {
|
|
|
+ if (_currentOperation == VPWOperation.PumpEnable)
|
|
|
+ {
|
|
|
+ _isStartAutoSpeed = true;
|
|
|
+ }
|
|
|
+ else if (_currentOperation == VPWOperation.PumpDisable)
|
|
|
+ {
|
|
|
+ _isStartAutoSpeed = false;
|
|
|
+ }
|
|
|
+ _status = RState.End;
|
|
|
+ _currentOperation = VPWOperation.None;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (_isStartAutoSpeed)
|
|
|
+ {
|
|
|
+ AdjustPumpSpeed();
|
|
|
+ }
|
|
|
return true;
|
|
|
}
|
|
|
+ /// <summary>
|
|
|
+ /// 调速
|
|
|
+ /// </summary>
|
|
|
+ public void AdjustPumpSpeed()
|
|
|
+ {
|
|
|
+ //Speed Auto模式同时pump enbled,根据kdi调整泵速
|
|
|
+ if (_commonData.BoosterPumpSpeedAuto && _commonData.BoosterPumpEnable)
|
|
|
+ {
|
|
|
+ _pumpKp = SC.GetValue<double>($"VPWMain.PumpKp");
|
|
|
+ _pumpKd = SC.GetValue<double>($"VPWMain.PumpKd");
|
|
|
+ _pumpKi = SC.GetValue<double>($"VPWMain.PumpKi");
|
|
|
+ double limit = SC.GetValue<double>("VPWMain.PrewetTargetLimit");
|
|
|
+ double downLimit = SC.GetValue<double>("VPWMain.PrewetDownTargetLimit");
|
|
|
+ double minSpeedDelta = SC.GetValue<double>("VPWMain.MinSpeedDelta");
|
|
|
+ short speed = PdiAlgorithm.Instance.CalculateSpeed(_pumpKp, _pumpKi, _pumpKd, _commonData.PressureTarget,
|
|
|
+ _commonData.BoosterPumpPressureData.Value, _lastBoosterPumpSpeed, limit, downLimit, minSpeedDelta);
|
|
|
+ //short speed = PdiAlgorithm.Instance.CalculateSpeed(PrewetPumpData.PressureTarget, PrewetPumpData.PumpPressureData.Value,
|
|
|
+ // _lastPumpSpeed, limit, downLimit);
|
|
|
+ if (Math.Abs(speed - _lastBoosterPumpSpeed) >= 1)
|
|
|
+ {
|
|
|
+ _lastBoosterPumpSpeed = speed;
|
|
|
+ BoosterPumpSpeed(speed);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ /// 当前Routine;
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ private IRoutine GetCurrentRoutine()
|
|
|
+ {
|
|
|
+ switch (_currentOperation)
|
|
|
+ {
|
|
|
+ case VPWOperation.PumpEnable:
|
|
|
+ return _boosterPumpEnableRoutine;
|
|
|
+ case VPWOperation.PumpDisable:
|
|
|
+ return _boosterPumpDisableRoutine;
|
|
|
+ default:
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
/// <summary>
|
|
|
/// 监控
|