123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244 |
- using System;
- using System.Xml;
- using Aitex.Core.Common.DeviceData;
- using Aitex.Core.RT.Event;
- using Aitex.Core.RT.IOCore;
- using Aitex.Core.RT.SCCore;
- using Aitex.Core.RT.Tolerance;
- using Aitex.Platform;
- namespace Aitex.Core.RT.Device.Unit
- {
- public class IoPressureControl : BaseDevice, IDevice
- {
- private bool _enableTolerance;
- public bool EnableTolerance
- {
- get
- {
- return _enableTolerance;
- }
- set
- {
- if (_enableTolerance != value)
- {
- EV.PostMessage(Module, EventEnum.GeneralInfo, value ? "Start monitor pressure stability" : "Stop monitor pressure stability");
- if (value)
- {
- _tolerance.Reset(_scAlarmTime.Value);
- }
- }
- _enableTolerance = value;
- }
- }
-
- public bool IsIndependentControl
- {
- get
- {
- if (_scIsIndependentControl != null)
- return _scIsIndependentControl.Value;
- return false;
- }
- }
- public bool IsTvInstalled
- {
- get
- {
- if (_scTvInstalled != null)
- return _scTvInstalled.Value;
- return false;
- }
- }
- public bool IsBoostPumpInstalled
- {
- get
- {
- if (_scIsBoostPumpInstalled != null)
- return _scIsBoostPumpInstalled.Value;
- return false;
- }
- }
- public bool EnableBoostControl
- {
- get
- {
- return _diLogicProcessGasFlowing == null || _diLogicProcessGasFlowing.Value;
- }
- }
- private IoThrottleValve _tv;
- private IoPressureMeter _pressureMeter;
- private IoBoostPump _boost;
- private double _pressureSetPoint;
- private ToleranceChecker _tolerance = new ToleranceChecker();
- private SCItem<double> _scAlarmRange = null;
- private SCItem<double> _scAlarmTime = null;
- private SCItem<bool> _scIsIndependentControl = null;
- private SCItem<bool> _scIsBoostPumpInstalled = null;
- private SCItem<bool> _scTvInstalled = null;
- private DIAccessor _diLogicProcessGasFlowing;
- public IoPressureControl(string module, XmlElement node)
- {
- base.Module = module;
- base.Name = node.GetAttribute("id");
- base.Display = node.GetAttribute("display");
- base.DeviceID = node.GetAttribute("schematicId");
- _diLogicProcessGasFlowing = ParseDiNode("diLogicProcessGasFlowing", node);
- _scAlarmRange = ParseScNodeDouble("scGasFlowPressureAlarmRange", node);
- _scAlarmTime = ParseScNodeDouble("scGasFlowPressureAlarmTime", node);
- _scIsIndependentControl = ParseScNodeBool("scIsIndependentControl", node);
- _scIsBoostPumpInstalled = ParseScNodeBool("scIsBoostPumpInstalled", node);
- _scTvInstalled = ParseScNodeBool("scTvInstalled", node);
- _tv = ParseDeviceNode<IoThrottleValve>("tv", node);
- _pressureMeter = ParseDeviceNode<IoPressureMeter>("pressureMeter", node);
- _boost = ParseDeviceNode<IoBoostPump>("boost", node);
- }
- public bool Initialize()
- {
- DEVICE.Register(String.Format("{0}.{1}", Name, AITPressureControlOperation.SetTVPressure), (out string reason, int time, object[] param) =>
- {
- double target = Convert.ToDouble((string)param[0]);
- if (!IsTvInstalled)
- {
- reason = string.Format("Throttle valve not config");
- return true;
- }
- if (_tv.PressureMode == PressureCtrlMode.TVPositionCtrl)
- {
- reason = "Throttle valve is in positon conrol mode, can not set pressure";
- return false;
- }
- _tv.PressureSetpoint = (float)target;
- reason = string.Format("TV pressure set to {0} mtorr", target);
- return true;
- });
- DEVICE.Register(String.Format("{0}.{1}", Name, AITPressureControlOperation.SetTVPosition), (out string reason, int time, object[] param) =>
- {
- double target = Convert.ToDouble((string)param[0]);
- if (!IsTvInstalled)
- {
- reason = string.Format("Throttle valve not config");
- return true;
- }
- if (_tv.PressureMode == PressureCtrlMode.TVPressureCtrl)
- {
- reason = "Throttle valve is in pressure conrol mode, can not set position";
- return false;
- }
- _tv.PositionSetpoint = (float)target;
- reason = string.Format("TV position set to {0}", target);
- return true;
- });
- DEVICE.Register(String.Format("{0}.{1}", Name, AITPressureControlOperation.SetTVMode), (out string reason, int time, object[] param) =>
- {
- reason = string.Empty;
- if (!IsTvInstalled)
- {
- reason = string.Format("Throttle valve not config");
- return true;
- }
- _tv.PressureMode = (PressureCtrlMode)Enum.Parse(typeof(PressureCtrlMode), (string)param[0], true);
-
- reason = string.Format("TV mode set to {0}", _tv.PressureMode);
- return true;
- });
- DEVICE.Register(String.Format("{0}.{1}", Name, AITPressureControlOperation.SetBoostPressure), (out string reason, int time, object[] param) =>
- {
- if (!IsBoostPumpInstalled)
- {
- reason = string.Format("boost pump not set up");
- return false;
- }
-
- double setpoint = Convert.ToDouble((string)param[0]);
- if (!_boost.SetPressure(setpoint, out reason))
- {
- return false;
- }
- _pressureSetPoint = setpoint;
- reason = string.Format("Boost pump pressure set to {0} mTorr", setpoint);
- return true;
- });
- DEVICE.Register(String.Format("{0}.{1}", Name, AITPressureControlOperation.SetChamberPressure), (out string reason, int time, object[] param) =>
- {
- double setpoint = Convert.ToDouble((string)param[0]);
- _pressureSetPoint = setpoint;
- reason = string.Format("Chamber pressure set to {0} mTorr", setpoint);
- return true;
- });
- return true;
- }
- public void Terminate()
- {
- }
- public void Monitor()
- {
- CheckTolerance();
- if (_boost != null && IsBoostPumpInstalled)
- {
- _boost.SetEnable((IsIndependentControl && EnableBoostControl) ? (int) BoostPumpEnable.Enable : (int) BoostPumpEnable.Disable);
- }
- }
- public void CheckTolerance()
- {
- if (!EnableTolerance)
- return;
- if (_tv!=null && IsTvInstalled && _tv.PressureMode == PressureCtrlMode.TVPositionCtrl)
- return;
- _tolerance.Monitor(_pressureMeter.Value, _pressureSetPoint - Math.Abs(_scAlarmRange.Value), _pressureSetPoint + Math.Abs(_scAlarmRange.Value), _scAlarmTime.Value);
- if (_tolerance.Trig)
- {
- EV.PostMessage(Module, EventEnum.ProcessPressureToleranceAlarm, Module, Display,
- String.Format("Out of range in {0} seconds", _scAlarmTime.Value.ToString("0")));
- }
- }
- public void Reset()
- {
- _tolerance.Reset(_scAlarmTime.Value);
- }
- }
- }
|