| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 | 
							- using Aitex.Core.RT.Log;
 
- using System;
 
- using System.Collections.Generic;
 
- using System.Diagnostics;
 
- using System.Linq;
 
- using System.Text;
 
- using System.Threading.Tasks;
 
- using Venus_Core;
 
- namespace Aitex.Core.RT.Tolerance
 
- {
 
-     public class RecipeToleranceChecker
 
-     {
 
-         Stopwatch _stopwatch;
 
-         List<ToleranceObject> _toleranceObjects;
 
-         string _Module;
 
-         public RecipeToleranceChecker(string module)
 
-         {
 
-             _stopwatch = new Stopwatch();
 
-             _Module = module;
 
-         }
 
-         public void Start( List<ToleranceObject> toleranceObjects)
 
-         {
 
-             _stopwatch.Start();
 
-             _toleranceObjects = toleranceObjects;
 
-         }
 
-         public void Monitor(params double[] feedBacks)
 
-         {
 
-             for (int i = 0; i < _toleranceObjects.Count; i++)
 
-             {
 
-                 if (_stopwatch.ElapsedMilliseconds > _toleranceObjects[i].DelayTime)
 
-                 {
 
-                     if ((feedBacks[i] < _toleranceObjects[i].WarningMin || feedBacks[i] > _toleranceObjects[i].WarningMax && _toleranceObjects[i].WarningFlag == false))
 
-                     {
 
-                         _toleranceObjects[i].WarningFlag = true;
 
-                         LOG.Write(eEvent.WARN_PM_TOLERANCE, _Module, $"{_toleranceObjects[i].Name}:Currnt Value:{feedBacks[i]},Over Range {_toleranceObjects[i].WarningMin}-{_toleranceObjects[i].WarningMax}");
 
-                     }
 
-                     if ((feedBacks[i] < _toleranceObjects[i].AlarmMin || feedBacks[i] > _toleranceObjects[i].AlarmMax) && _toleranceObjects[i].AlarmFlag == false && _toleranceObjects[i].WarningFlag == true)
 
-                     {
 
-                         _toleranceObjects[i].AlarmFlag = true;
 
-                         LOG.Write(eEvent.ERR_PM_TOLERANCE, _Module, $"{_toleranceObjects[i].Name}:Currnt Value:{feedBacks[i]},Over Range {_toleranceObjects[i].AlarmMin}-{_toleranceObjects[i].AlarmMax}");
 
-                     }
 
-                 }
 
-             }
 
-         }
 
-         public void End()
 
-         {
 
-             _stopwatch.Stop();
 
-         }
 
-     }
 
-     public class ToleranceObject
 
-     {
 
-         public string Name { get; set; }
 
-         public int SetPoint { get; set; }
 
-         public int WarningScale { get; set; }
 
-         public int AlarmScale { get; set; }
 
-         public bool WarningFlag { get; set; }
 
-         public bool AlarmFlag { get; set; }
 
-         public int DelayTime { get; set; }
 
-         public int WarningMax { get; set; }
 
-         public int WarningMin { get; set; }
 
-         public int AlarmMax { get; set; }
 
-         public int AlarmMin { get; set; }
 
-         public ToleranceObject(string name, int setPoint, int warningScale, int alarmScale, int delayTime, ToleranceMode toleranceMode)
 
-         {
 
-             Name = name;
 
-             SetPoint = setPoint;
 
-            
 
-             DelayTime = delayTime;
 
-             if (toleranceMode == ToleranceMode.Percent)
 
-             {
 
-                 WarningScale = SetPoint * warningScale / 100;
 
-                 AlarmScale = SetPoint * alarmScale / 100;
 
-             }
 
-             else
 
-             {
 
-                 WarningScale = warningScale;
 
-                 AlarmScale = alarmScale;
 
-             }
 
-             WarningMax = setPoint + WarningScale;
 
-             WarningMin = setPoint - WarningScale;
 
-             AlarmMax = setPoint + AlarmScale;
 
-             AlarmMin = setPoint - AlarmScale;
 
-         }
 
-     }
 
- }
 
 
  |