| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286 | 
							- 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.Log;
 
- using Aitex.Core.RT.OperationCenter;
 
- using Aitex.Core.RT.SCCore;
 
- using Aitex.Core.RT.Tolerance;
 
- using Aitex.Core.Util;
 
- using Aitex.Core.Utilities;
 
- using MECF.Framework.Common.Event;
 
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.MFCs;
 
- using System;
 
- using System.Collections.Generic;
 
- using System.Xml;
 
- namespace FurnaceRT.Equipments.PMs.Devices
 
- {
 
-     public class IoMFM : BaseDevice, IDevice
 
-     {
 
-         public string Unit
 
-         {
 
-             get; set;
 
-         }
 
-         public double Scale
 
-         {
 
-             get
 
-             {
 
-                 if (_scN2Scale == null)
 
-                     return 0;
 
-                 return _scN2Scale.DoubleValue;
 
-             }
 
-         }
 
-         public double FeedBack
 
-         {
 
-             get
 
-             {
 
-                 if (_aiFlow != null)
 
-                 {
 
-                     return _isFloatAioType ? _aiFlow.FloatValue : _aiFlow.Value;
 
-                 }
 
-                 return 0;
 
-             }
 
-         }
 
-         public double Setpoint
 
-         {
 
-             get
 
-             {
 
-                 if (_aoFlow != null)
 
-                 {
 
-                     return _isFloatAioType ? _aoFlow.FloatValue : _aoFlow.Value;
 
-                 }
 
-                 return _setpoint;
 
-             }
 
-         }
 
-         public bool EnableAlarm
 
-         {
 
-             get
 
-             {
 
-                 if (_scEnableAlarm != null)
 
-                     return _scEnableAlarm.BoolValue;
 
-                 return false;
 
-             }
 
-         }
 
-         private AITWaterFlowMeterData DeviceData
 
-         {
 
-             get
 
-             {
 
-                 AITWaterFlowMeterData data = new AITWaterFlowMeterData()
 
-                 {
 
-                     DeviceName = Name,
 
-                     DeviceSchematicId = DeviceID,
 
-                     DisplayName = DisplayName,
 
-                     FeedBack = FeedBack < 0 ? 0 : FeedBack,
 
-                     SetPoint = Setpoint < 0 ? 0 : Setpoint,
 
-                     AlarmWatchTable = AlarmWatchTable,
 
-                     Unit = Unit,
 
-                     Scale = Scale,
 
-                     UniqueName = $"{Module}.{Name}",
 
-                 };
 
-                 return data;
 
-             }
 
-         }
 
-         public string DisplayName
 
-         {
 
-             get
 
-             {
 
-                 if (_scGasName != null)
 
-                     return _scGasName.StringValue;
 
-                 return Display;
 
-             }
 
-         }
 
-         public string AlarmWatchTable
 
-         {
 
-             get;
 
-             set;
 
-         }
 
-         private float _setpoint;
 
-         private double _phyScale;
 
-         private ToleranceChecker _toleranceCheckerWarning = new ToleranceChecker();
 
-         private ToleranceChecker _toleranceCheckerAlarm = new ToleranceChecker();
 
-         private AIAccessor _aiFlow;
 
-         private AOAccessor _aoFlow;
 
-         private AIAccessor _aiCheck;
 
-         protected SCConfigItem _scGasName;
 
-         private SCConfigItem _scN2Scale;
 
-         private SCConfigItem _scEnableAlarm;
 
-         //tolerance check
 
-         private float _alarmJudgmentRange;
 
-         private float _warningJudgmentRange;
 
-         private float _alarmJudgmentTime;
 
-         private float _warningJudgmentTime;
 
-         private float _toleranceJudgmentDelayTime;
 
-         private DeviceTimer _toleranceJudgmentDelayTimer = new DeviceTimer();
 
-         private int _toleranceAlarmEventId;
 
-         private int _toleranceWarningEventId;
 
-         public AlarmEventItem AlarmToleranceWarning { get; set; }
 
-         public AlarmEventItem AlarmToleranceAlarm { get; set; }
 
-         private bool _isFloatAioType = false;
 
-         public IoMFM(string module, XmlElement node, string ioModule = "")
 
-         {
 
-             Unit = node.GetAttribute("unit");
 
-             base.Module = string.IsNullOrEmpty(node.GetAttribute("module")) ? module : node.GetAttribute("module");
 
-             base.Name = node.GetAttribute("id");
 
-             base.Display = node.GetAttribute("display");
 
-             base.DeviceID = node.GetAttribute("schematicId");
 
-             int.TryParse(node.GetAttribute("toleranceAlarmEventId"), out _toleranceAlarmEventId);
 
-             int.TryParse(node.GetAttribute("toleranceWarningEventId"), out _toleranceWarningEventId);
 
-             _aiFlow = ParseAiNode("aiFlow", node, ioModule);
 
-             _aoFlow = ParseAoNode("aoFlow", node, ioModule);
 
-             _isFloatAioType = !string.IsNullOrEmpty(node.GetAttribute("aioType")) && (node.GetAttribute("aioType") == "float");
 
-             string scBasePath = node.GetAttribute("scBasePath");
 
-             if (string.IsNullOrEmpty(scBasePath))
 
-                 scBasePath = $"{Module}.{Name}";
 
-             else
 
-             {
 
-                 scBasePath = scBasePath.Replace("{module}", Module);
 
-             }
 
-             _scGasName = SC.GetConfigItem($"{scBasePath}.{Name}.Name");
 
-             _scN2Scale = ParseScNode("scN2Scale", node, ioModule, $"{scBasePath}.{Name}.N2Scale");
 
-             _scEnableAlarm = ParseScNode("scEnableAlarm", node, ioModule, $"{scBasePath}.{Name}.EnableAlarm");
 
-             if (SC.ContainsItem($"{scBasePath}.{Name}.FlowUnit"))
 
-                 Unit = SC.GetStringValue($"{scBasePath}.{Name}.FlowUnit");
 
-         }
 
-         public bool Initialize()
 
-         {
 
-             DATA.Subscribe($"{Module}.{Name}.DeviceData", () => DeviceData);
 
-             DATA.Subscribe($"{Module}.{Name}.Feedback", () => FeedBack);
 
-             DATA.Subscribe($"{Module}.{Name}._setpoint", () => Setpoint);
 
-             OP.Subscribe($"{Module}.{Name}.SetParameters", SetParameters);
 
-             OP.Subscribe($"{Module}.{Name}.SetMfmValue", SetMfmValue);
 
-             //_phyScale = SC.GetValue<double>($"{Module}.MFM.{Name}.PhyScale");
 
-             //AlarmToleranceWarning = SubscribeAlarm($"{Module}.{Name}.ToleranceWarning", "", ResetWarningChecker, EventLevel.Warning);
 
-             //AlarmToleranceAlarm = SubscribeAlarm($"{Module}.{Name}.ToleranceAlarm", "", ResetAlarmChecker);
 
-             //AlarmToleranceWarning.Id = _toleranceWarningEventId;
 
-             //AlarmToleranceAlarm.Id = _toleranceAlarmEventId;
 
-             return true;
 
-         }
 
-         public void Monitor()
 
-         {
 
-             MonitorTolerance();
 
-         }
 
-         public bool ResetWarningChecker()
 
-         {
 
-             _toleranceCheckerWarning?.Reset(_warningJudgmentTime);
 
-             return true;
 
-         }
 
-         public bool ResetAlarmChecker()
 
-         {
 
-             _toleranceCheckerAlarm?.Reset(_alarmJudgmentTime);
 
-             return true;
 
-         }
 
-         public void Reset()
 
-         {
 
-             //AlarmToleranceWarning.Reset();
 
-             //AlarmToleranceAlarm.Reset();
 
-         }
 
-         public void Terminate()
 
-         {
 
-         }
 
-         private bool SetParameters(out string reason, int time, object[] param)
 
-         {
 
-             reason = string.Empty;
 
-             var paras = param[0].ToString().Split(';');//flow;alarmTable
 
-             if (System.Text.RegularExpressions.Regex.Match(paras[0].ToString(), @"[a-zA-Z]").Success)
 
-             {
 
-                 var table = paras[0].ToString().Split(':')[0];
 
-                 if (SC.ContainsItem($"{Module}.RecipeEditParameter.FlowSetting.{Name}.{table}"))
 
-                     _setpoint = (float)SC.GetValue<double>($"{Module}.RecipeEditParameter.FlowSetting.{Name}.{table}");
 
-             }
 
-             else
 
-             {
 
-                 float.TryParse(param[0].ToString(), out _setpoint);
 
-                 _setpoint = (float)Converter.Logic2Phy(_setpoint, 0, Scale, 0, _phyScale);
 
-             }
 
-             if (paras.Length >= 2)
 
-             {
 
-                 var alarmWatchTable = paras[1].ToString();
 
-                 if (SC.ContainsItem($"{Module}.RecipeEditParameter.AlarmWatchTable.FlowAlarmWatch.Table{alarmWatchTable}.DelayTime"))
 
-                 {
 
-                     var scPath = $"{Module}.RecipeEditParameter.AlarmWatchTable.PressureAlarmWatch.Table{alarmWatchTable}";
 
-                     _toleranceJudgmentDelayTime = (float)SC.GetValue<double>($"{scPath}.DelayTime");
 
-                     _alarmJudgmentRange = (float)SC.GetValue<double>($"{scPath}.AlarmJudgment");
 
-                     _warningJudgmentRange = (float)SC.GetValue<double>($"{scPath}.WarningJudgment");
 
-                     _alarmJudgmentTime = (float)SC.GetValue<double>($"{scPath}.AlarmJudgmentTime");
 
-                     _warningJudgmentTime = (float)SC.GetValue<double>($"{scPath}.WarningJudgmentTime");
 
-                     _toleranceJudgmentDelayTimer.Start(0);
 
-                 }
 
-                 else
 
-                 {
 
-                     _toleranceJudgmentDelayTime = 0;
 
-                     _alarmJudgmentRange = 0;
 
-                     _warningJudgmentRange = 0;
 
-                     _alarmJudgmentTime = 0;
 
-                     _warningJudgmentTime = 0;
 
-                     _toleranceJudgmentDelayTimer.Stop();
 
-                 }
 
-                 ResetWarningChecker();
 
-                 ResetAlarmChecker();
 
-             }
 
-             return true;
 
-         }
 
-         private bool SetMfmValue(out string reason, int time, object[] param)
 
-         {
 
-             reason = string.Empty;
 
-             var paras = param[0].ToString().Split(';');     // setpoint;alarmWatchTable
 
-             float.TryParse(paras[0].ToString(), out _setpoint);
 
-             _aoFlow.FloatValue = _setpoint;
 
-             return true;
 
-         }
 
-         private void MonitorTolerance()
 
-         {
 
-             
 
-         }
 
-     }
 
- }
 
 
  |