| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393 | 
							- using System;
 
- using System.Collections.Generic;
 
- using System.Linq;
 
- using System.Net.Configuration;
 
- using System.Text;
 
- using System.Threading.Tasks;
 
- using System.Xml;
 
- using Aitex.Core.Common.DeviceData;
 
- using Aitex.Core.RT.DataCenter;
 
- using Aitex.Core.RT.Device;
 
- using Aitex.Core.RT.Event;
 
- using Aitex.Core.RT.IOCore;
 
- using Aitex.Core.RT.OperationCenter;
 
- using Aitex.Core.RT.SCCore;
 
- using Aitex.Core.RT.Tolerance;
 
- using Aitex.Core.Util;
 
- namespace MECF.Framework.Common.Device.Bases
 
- {
 
-     public abstract class ThrottleValveBase : BaseDevice, IDevice
 
-     {
 
-         public virtual PressureCtrlMode Mode { get; set; }
 
-        
 
-         public virtual float PositionFeedback { get; set; }
 
-         
 
-         public virtual float PressureFeedback { get; set; }
 
-  
 
-         public virtual float PressureSetPoint { get; set; }
 
-  
 
-         public virtual float PositionSetPoint { get; set; }
 
-         public virtual AITThrottleValveData DeviceData { get; set; }
 
-         public uint MaxValuePressure = 100;
 
-         public float PressureParam = 0.1f;
 
-         public uint MaxValuePosi = 5000;
 
-         public float PosiParam = 0.1f;
 
-         protected double _currentPressureFineTuningValue;
 
-         protected double _currentPositionFineTuningValue;
 
-         protected SCConfigItem _scFineTuningEnable;
 
-         protected SCConfigItem _scPressureFineTuningValue;
 
-         protected SCConfigItem _scPositionFineTuningValue;
 
-         private float _currentPressureWarningRange;
 
-         private float _currentPressureAlarmRange;
 
-         private float _currentPositionWarningRange;
 
-         private float _currentPositionAlarmRange;
 
-         protected SCConfigItem _scEnableAlarm;
 
-         protected SCConfigItem _scPressureAlarmTime;
 
-         protected SCConfigItem _scPressureAlarmRange;
 
-         protected SCConfigItem _scPressureWarningTime;
 
-         protected SCConfigItem _scPressureWarningRange;
 
-         protected SCConfigItem _scPositionAlarmTime;
 
-         protected SCConfigItem _scPositionAlarmRange;
 
-         protected SCConfigItem _scPositionWarningTime;
 
-         protected SCConfigItem _scPositionWarningRange;
 
-         protected ToleranceChecker _tolerancePressureAlarmChecker = new ToleranceChecker();
 
-         protected ToleranceChecker _tolerancePressureWarningChecker = new ToleranceChecker();
 
-         protected ToleranceChecker _tolerancePositionAlarmChecker = new ToleranceChecker();
 
-         protected ToleranceChecker _tolerancePositionWarningChecker = new ToleranceChecker();
 
-         public virtual double PressureFineTuningValue
 
-         {
 
-             get
 
-             {
 
-                 if (_scFineTuningEnable == null || !_scFineTuningEnable.BoolValue)
 
-                     return 1;
 
-                 if (_currentPressureFineTuningValue != 0)
 
-                     return 1 + _currentPressureFineTuningValue / 100;
 
-                 return _scPressureFineTuningValue != null ? 1 + _scPressureFineTuningValue.DoubleValue / 100 : 1;
 
-             }
 
-         }
 
-         public virtual double PositionFineTuningValue
 
-         {
 
-             get
 
-             {
 
-                 if (_scFineTuningEnable == null || !_scFineTuningEnable.BoolValue)
 
-                     return 1;
 
-                 if (_currentPositionFineTuningValue != 0)
 
-                     return 1 + _currentPositionFineTuningValue / 100;
 
-                 return _scPositionFineTuningValue != null ? 1 + _scPositionFineTuningValue.DoubleValue / 100 : 1;
 
-             }
 
-         }
 
-         public virtual bool EnableAlarm
 
-         {
 
-             get
 
-             {
 
-                 if (_scEnableAlarm != null)
 
-                     return _scEnableAlarm.BoolValue;
 
-                 return false;
 
-             }
 
-         }
 
-         public virtual double PressureAlarmTime
 
-         {
 
-             get
 
-             {
 
-                 if (_scPressureAlarmTime != null)
 
-                     return _scPressureAlarmTime.DoubleValue;
 
-                 return 0;
 
-             }
 
-         }
 
-         public virtual double PressureAlarmRange
 
-         {
 
-             get
 
-             {
 
-                 if (_currentPressureAlarmRange > 0)
 
-                     return _currentPressureAlarmRange;
 
-                 if (_scPressureAlarmRange != null)
 
-                     return _scPressureAlarmRange.DoubleValue;
 
-                 return 0;
 
-             }
 
-         }
 
-         public virtual double PressureWarningTime
 
-         {
 
-             get
 
-             {
 
-                 if (_scPressureWarningTime != null)
 
-                     return _scPressureWarningTime.DoubleValue;
 
-                 return 0;
 
-             }
 
-         }
 
-         public virtual double PressureWarningRange
 
-         {
 
-             get
 
-             {
 
-                 if (_currentPressureWarningRange > 0)
 
-                     return _currentPressureWarningRange;
 
-                 if (_scPressureWarningRange != null)
 
-                     return _scPressureWarningRange.DoubleValue;
 
-                 return 0;
 
-             }
 
-         }
 
-         public virtual double PositionAlarmTime
 
-         {
 
-             get
 
-             {
 
-                 if (_scPositionAlarmTime != null)
 
-                     return _scPositionAlarmTime.DoubleValue;
 
-                 return 0;
 
-             }
 
-         }
 
-         public virtual double PositionAlarmRange
 
-         {
 
-             get
 
-             {
 
-                 if (_currentPositionAlarmRange > 0)
 
-                     return _currentPositionAlarmRange;
 
-                 if (_scPositionAlarmRange != null)
 
-                     return _scPositionAlarmRange.DoubleValue;
 
-                 return 0;
 
-             }
 
-         }
 
-         public virtual double PositionWarningTime
 
-         {
 
-             get
 
-             {
 
-                 if (_scPositionWarningTime != null)
 
-                     return _scPositionWarningTime.DoubleValue;
 
-                 return 0;
 
-             }
 
-         }
 
-         public virtual double PositionWarningRange
 
-         {
 
-             get
 
-             {
 
-                 if (_currentPositionWarningRange > 0)
 
-                     return _currentPositionWarningRange;
 
-                 if (_scPositionWarningRange != null)
 
-                     return _scPositionWarningRange.DoubleValue;
 
-                 return 0;
 
-             }
 
-         }
 
-         protected ThrottleValveBase() : base()
 
-         {
 
-         }
 
-         protected ThrottleValveBase(string module, string name, XmlElement node = null, string ioModule = "") : base(module, name, name, name)
 
-         {
 
-             if (node != null)
 
-             {
 
-                 _scEnableAlarm = ParseScNode("scEnableAlarm", node, ioModule, $"{Module}.{Name}.EnableAlarm");
 
-                 _scPressureAlarmTime = ParseScNode("scPressureAlarmTime", node, ioModule, $"{Module}.{Name}.PressureAlarmTime");
 
-                 _scPressureAlarmRange = ParseScNode("scPressureAlarmRange", node, ioModule, $"{Module}.{Name}.PressureAlarmRange");
 
-                 _scPressureWarningTime = ParseScNode("scPressureWarningTime", node, ioModule, $"{Module}.{Name}.PressureWarningTime");
 
-                 _scPressureWarningRange = ParseScNode("scPressureWarningRange", node, ioModule, $"{Module}.{Name}.PressureWarningRange");
 
-                 _scPositionAlarmTime = ParseScNode("scPositionAlarmTime", node, ioModule, $"{Module}.{Name}.PositionAlarmTime");
 
-                 _scPositionAlarmRange = ParseScNode("scPositionAlarmRange", node, ioModule, $"{Module}.{Name}.PositionAlarmRange");
 
-                 _scPositionWarningTime = ParseScNode("scPositionWarningTime", node, ioModule, $"{Module}.{Name}.PositionWarningTime");
 
-                 _scPositionWarningRange = ParseScNode("scPositionWarningRange", node, ioModule, $"{Module}.{Name}.PositionWarningRange");
 
-                 _scPressureFineTuningValue = ParseScNode("scPressureFineTuningValue", node, ioModule, $"{Module}.FineTuning.{Name}Pressure");
 
-                 _scPositionFineTuningValue = ParseScNode("scPositionFineTuningValue", node, ioModule, $"{Module}.FineTuning.{Name}Position");
 
-                 _scFineTuningEnable = ParseScNode("scFineTuningEnable", node, ioModule, $"{Module}.FineTuning.IsEnable");
 
-             }
 
-         }
 
-         public virtual bool Initialize()
 
-         {
 
-             DATA.Subscribe($"{Module}.{Name}.DeviceData", () => DeviceData);
 
-             DATA.Subscribe($"{Module}.{Name}.ControlMode", () => (int)Mode);
 
-             DATA.Subscribe($"{Module}.{Name}.PositionFeedback", () => PositionFeedback);
 
-             DATA.Subscribe($"{Module}.{Name}.PressureFeedback", () => PressureFeedback);
 
-             DATA.Subscribe($"{Module}.{Name}.PositionSetPoint", () => PositionSetPoint);
 
-             DATA.Subscribe($"{Module}.{Name}.PressureSetPoint", () => PressureSetPoint);
 
-             OP.Subscribe($"{Module}.{Name}.SetPressure", (function, args) =>
 
-             {
 
-                 SetPressure(Convert.ToSingle(args[0]));
 
-                 return true;
 
-             });
 
-             OP.Subscribe($"{Module}.{Name}.SetPosition", (function, args) =>
 
-             {
 
-                 SetPosition(Convert.ToSingle(args[0]));
 
-                 return true;
 
-             });
 
-             OP.Subscribe($"{Module}.{Name}.SetOpen", (function, args) =>
 
-             {
 
-                 SetOpen( );
 
-                 return true;
 
-             });
 
-             OP.Subscribe($"{Module}.{Name}.SetClose", (function, args) =>
 
-             {
 
-                 SetClose( );
 
-                 return true;
 
-             });
 
-             OP.Subscribe($"{Module}.{Name}.SetMode", (function, args) =>
 
-             {
 
-                 if (!Enum.TryParse((string)args[0], out PressureCtrlMode mode))
 
-                 {
 
-                     EV.PostWarningLog(Module, $"Argument {args[0]}not valid");
 
-                     return false;
 
-                 }
 
-                 SetControlMode(mode);
 
-                 return true;
 
-             });
 
-             //for recipe
 
-             OP.Subscribe($"{Module}.{Name}.SetFineTuning", (out string reason, int time, object[] param) =>
 
-             {
 
-                 reason = string.Empty;
 
-                 SetFineTuning(Convert.ToSingle(param[0]), Convert.ToSingle(param[1]));
 
-                 return true;
 
-             });
 
-             //for recipe
 
-             OP.Subscribe($"{Module}.{Name}.SetTolerance", (out string reason, int time, object[] param) =>
 
-             {
 
-                 reason = string.Empty;
 
-                 var pressureWarning = Convert.ToSingle(param[0]);
 
-                 var pressureAlarm = Convert.ToSingle(param[1]);
 
-                 var positionWarning = Convert.ToSingle(param[2]);
 
-                 var positionAlarm = Convert.ToSingle(param[3]);
 
-                 SetTolerance((float)pressureWarning, (float)pressureAlarm, (float)positionWarning, (float)positionAlarm);
 
-                 return true;
 
-             });
 
-             return true;
 
-         }
 
-         public virtual void SetFineTuning(float pressureFineTuning, float positionFineTuning)
 
-         {
 
-             _currentPressureFineTuningValue = pressureFineTuning;
 
-             _currentPositionFineTuningValue = positionFineTuning;
 
-         }
 
-         public virtual void SetTolerance(float pressureWarning, float pressureAlarm, float positionWarning, float positionAlarm)
 
-         {
 
-             _currentPressureWarningRange = pressureWarning;
 
-             _currentPressureAlarmRange = pressureAlarm;
 
-             _tolerancePressureAlarmChecker.Reset(PressureAlarmTime);
 
-             _tolerancePressureWarningChecker.Reset(PressureWarningTime);
 
-             _currentPositionWarningRange = positionWarning;
 
-             _currentPositionAlarmRange = positionAlarm;
 
-             _tolerancePositionAlarmChecker.Reset(PositionAlarmTime);
 
-             _tolerancePositionWarningChecker.Reset(PositionWarningTime);
 
-         }
 
-         public virtual void CheckTolerance()
 
-         {
 
-             if (!EnableAlarm)
 
-                 return;
 
-             if(Mode == PressureCtrlMode.TVPressureCtrl && PressureSetPoint > 0)
 
-             {
 
-                 _tolerancePressureAlarmChecker.Monitor(PressureFeedback, (PressureSetPoint * (1 - PressureAlarmRange / 100)), (PressureSetPoint * (1 + PressureAlarmRange / 100)), PressureAlarmTime);
 
-                 _tolerancePressureWarningChecker.Monitor(PressureFeedback, (PressureSetPoint * (1 - PressureWarningRange / 100)), (PressureSetPoint * (1 + PressureWarningRange / 100)), PressureWarningTime);
 
-             }
 
-             if (Mode == PressureCtrlMode.TVPositionCtrl && PositionSetPoint > 0)
 
-             {
 
-                 _tolerancePressureAlarmChecker.Monitor(PositionFeedback, (PositionSetPoint * (1 - PositionAlarmRange / 100)), (PositionSetPoint * (1 + PositionAlarmRange / 100)), PositionAlarmTime);
 
-                 _tolerancePressureWarningChecker.Monitor(PositionFeedback, (PositionSetPoint * (1 - PositionWarningRange / 100)), (PositionSetPoint * (1 + PositionWarningRange / 100)), PositionWarningTime);
 
-             }
 
-         }
 
-         public virtual bool CheckPressureToleranceAlarm()
 
-         {
 
-             if (!EnableAlarm)
 
-                 return false;
 
-             return _tolerancePressureAlarmChecker.Result;
 
-         }
 
-         public virtual bool CheckPressureToleranceWarning()
 
-         {
 
-             if (!EnableAlarm)
 
-                 return false;
 
-             return _tolerancePressureWarningChecker.Result;
 
-         }
 
-         public virtual bool CheckPositionToleranceAlarm()
 
-         {
 
-             if (!EnableAlarm)
 
-                 return false;
 
-             return _tolerancePositionAlarmChecker.Result;
 
-         }
 
-         public virtual bool CheckPositionToleranceWarning()
 
-         {
 
-             if (!EnableAlarm)
 
-                 return false;
 
-             return _tolerancePositionWarningChecker.Result;
 
-         }
 
-         public virtual void SetClose()
 
-         {
 
-             throw new NotImplementedException();
 
-         }
 
-         public virtual void SetOpen()
 
-         {
 
-             throw new NotImplementedException();
 
-         }
 
-         public virtual void SetControlMode(PressureCtrlMode mode)
 
-         {
 
-              
 
-         }
 
-         public virtual void SetPressure(float isOn)
 
-         {
 
-              
 
-         }
 
-         public virtual void SetPosition(float position)
 
-         {
 
-         }
 
-         public virtual void Terminate()
 
-         {
 
-         }
 
-         public virtual void Monitor()
 
-         {
 
-             CheckTolerance();
 
-         }
 
-         public virtual void Reset()
 
-         {
 
-         }
 
-     }
 
- }
 
 
  |