| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252 | 
							- using System;
 
- using System.Collections.Generic;
 
- using System.Linq;
 
- using System.Runtime.Serialization;
 
- 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.OperationCenter;
 
- using Aitex.Core.RT.SCCore;
 
- using Aitex.Core.RT.Tolerance;
 
- namespace MECF.Framework.Common.Device.Bases
 
- {
 
-     public abstract class HeaterBase : BaseDevice, IDevice
 
-     {
 
-         public virtual bool IsPowerOn { get; set; }
 
-         public virtual float TempSetPoint { get; set; }
 
-         public virtual float TempFeedback { get; set; }
 
-         public virtual AITHeaterData DeviceData { get; set; }
 
-         private float _currentWarningRange;
 
-         private float _currentAlarmRange;
 
-         protected SCConfigItem _scEnableAlarm;
 
-         protected SCConfigItem _scAlarmTime;
 
-         protected SCConfigItem _scAlarmRange;
 
-         protected SCConfigItem _scWarningTime;
 
-         protected SCConfigItem _scWarningRange;
 
-         protected ToleranceChecker _toleranceAlarmChecker = new ToleranceChecker();
 
-         protected ToleranceChecker _toleranceWarningChecker = new ToleranceChecker();
 
-         protected double _currentFineTuningValue;
 
-         protected SCConfigItem _scFineTuningEnable;
 
-         protected SCConfigItem _scFineTuningValue;
 
-         public virtual double FineTuningValue
 
-         {
 
-             get
 
-             {
 
-                 if (_scFineTuningEnable == null || !_scFineTuningEnable.BoolValue)
 
-                     return 1;
 
-                 if (_currentFineTuningValue != 0)
 
-                     return 1 + _currentFineTuningValue / 100;
 
-                 return _scFineTuningValue != null ? 1 + _scFineTuningValue.DoubleValue / 100 : 1;
 
-             }
 
-         }
 
-         public virtual bool EnableAlarm
 
-         {
 
-             get
 
-             {
 
-                 if (_scEnableAlarm != null)
 
-                     return _scEnableAlarm.BoolValue;
 
-                 return false;
 
-             }
 
-         }
 
-         public virtual double AlarmTime
 
-         {
 
-             get
 
-             {
 
-                 if (_scAlarmTime != null)
 
-                     return _scAlarmTime.DoubleValue;
 
-                 return 0;
 
-             }
 
-         }
 
-         public virtual double AlarmRange
 
-         {
 
-             get
 
-             {
 
-                 if (_currentAlarmRange > 0)
 
-                     return _currentAlarmRange;
 
-                 if (_scAlarmRange != null)
 
-                     return _scAlarmRange.DoubleValue;
 
-                 return 0;
 
-             }
 
-         }
 
-         public virtual double WarningTime
 
-         {
 
-             get
 
-             {
 
-                 if (_scWarningTime != null)
 
-                     return _scWarningTime.DoubleValue;
 
-                 return 0;
 
-             }
 
-         }
 
-         public virtual double WarningRange
 
-         {
 
-             get
 
-             {
 
-                 if (_currentWarningRange > 0)
 
-                     return _currentWarningRange;
 
-                 if (_scWarningRange != null)
 
-                     return _scWarningRange.DoubleValue;
 
-                 return 0;
 
-             }
 
-         }
 
-         protected HeaterBase() : base()
 
-         {
 
-         }
 
-         protected HeaterBase(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");
 
-                 _scAlarmTime = ParseScNode("scAlarmTime", node, ioModule, $"{Module}.{Name}.AlarmTime");
 
-                 _scAlarmRange = ParseScNode("scAlarmRange", node, ioModule, $"{Module}.{Name}.AlarmRange");
 
-                 _scWarningTime = ParseScNode("scWarningTime", node, ioModule, $"{Module}.{Name}.WarningTime");
 
-                 _scWarningRange = ParseScNode("scWarningRange", node, ioModule, $"{Module}.{Name}.WarningRange");
 
-                 _scFineTuningValue = ParseScNode("scFineTuningValue", node, ioModule, $"{Module}.FineTuning.{Name}");
 
-                 _scFineTuningEnable = ParseScNode("scFineTuningEnable", node, ioModule, $"{Module}.FineTuning.IsEnable");
 
-             }
 
-         }
 
-         public virtual bool Initialize()
 
-         {
 
-             DATA.Subscribe($"{Module}.{Name}.DeviceData", () => DeviceData);
 
-             DATA.Subscribe($"{Module}.{Name}.TempFeedback", () => TempFeedback);
 
-             DATA.Subscribe($"{Module}.{Name}.TempSetPoint", () => DeviceData.SetPoint);
 
-             //DATA.Subscribe($"{Module}.{Name}.IsPowerOn", () => IsPowerOn);
 
-             OP.Subscribe($"{Module}.{Name}.SetPowerOn", (function, args) =>
 
-             {
 
-                 SetPowerOnOff(true);
 
-                 return true;
 
-             });
 
-             OP.Subscribe($"{Module}.{Name}.SetPowerOff", (function, args) =>
 
-             {
 
-                 SetPowerOnOff(false);
 
-                 return true;
 
-             });
 
-             OP.Subscribe($"{Module}.{Name}.SetPowerOnOff", (function, args) =>
 
-             {
 
-                 bool.TryParse(args[0].ToString(), out bool isOn);
 
-                 SetPowerOnOff(isOn);
 
-                 return true;
 
-             });
 
-             OP.Subscribe($"{Module}.{Name}.SetTemperature", (function, args) =>
 
-             {
 
-                 SetTemperature(Convert.ToSingle(args[0]));
 
-                 return true;
 
-             });
 
-             //for recipe
 
-             OP.Subscribe($"{Module}.{Name}.SetTolerance", (out string reason, int time, object[] param) =>
 
-             {
 
-                 reason = string.Empty;
 
-                 var warning = Convert.ToSingle(param[0]);
 
-                 var alarm = Convert.ToSingle(param[1]);
 
-                 SetTolerance((float)warning, (float)alarm);
 
-                 return true;
 
-             });
 
-             //for recipe
 
-             OP.Subscribe($"{Module}.{Name}.SetFineTuning", (out string reason, int time, object[] param) =>
 
-             {
 
-                 reason = string.Empty;
 
-                 SetFineTuning(Convert.ToSingle(param[0]));
 
-                 return true;
 
-             });
 
-             return true;
 
-         }
 
-         public virtual void SetFineTuning(float fineTuning)
 
-         {
 
-             _currentFineTuningValue = fineTuning;
 
-         }
 
-         public virtual void SetTolerance(float warning, float alarm)
 
-         {
 
-             _currentWarningRange = warning;
 
-             _currentAlarmRange = alarm;
 
-             _toleranceAlarmChecker.Reset(AlarmTime);
 
-             _toleranceWarningChecker.Reset(WarningTime);
 
-         }
 
-         public virtual void CheckTolerance()
 
-         {
 
-             if (!EnableAlarm || TempSetPoint == 0)
 
-                 return;
 
-             _toleranceAlarmChecker.Monitor(TempFeedback, (TempSetPoint * (1 - AlarmRange / 100)), (TempSetPoint * (1 + AlarmRange / 100)), AlarmTime);
 
-             _toleranceWarningChecker.Monitor(TempFeedback, (TempSetPoint * (1 - WarningRange / 100)), (TempSetPoint * (1 + WarningRange / 100)), WarningTime);
 
-         }
 
-         public virtual bool CheckToleranceAlarm()
 
-         {
 
-             if (!EnableAlarm)
 
-                 return false;
 
-             return _toleranceAlarmChecker.Result;
 
-         }
 
-         public virtual bool CheckToleranceWarning()
 
-         {
 
-             if (!EnableAlarm)
 
-                 return false;
 
-             return _toleranceWarningChecker.Result;
 
-         }
 
-         public virtual void SetPowerOnOff(bool isOn)
 
-         {
 
-         }
 
-         public virtual void SetTemperature(float temperature)
 
-         {
 
-         }
 
-         public virtual void Terminate()
 
-         {
 
-         }
 
-         public virtual void Monitor()
 
-         {
 
-             CheckTolerance();
 
-         }
 
-         public virtual void Reset()
 
-         {
 
-             _toleranceAlarmChecker.Reset(AlarmTime);
 
-             _toleranceWarningChecker.Reset(WarningTime);
 
-         }
 
-         public virtual void SetEnable(bool isEnable)
 
-         {
 
-         }
 
-     }
 
- }
 
 
  |