RecipeToleranceChecker.cs 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. //using System;
  2. //using System.Collections.Generic;
  3. //using System.Diagnostics;
  4. //using System.Linq;
  5. //using System.Text;
  6. //using System.Threading.Tasks;
  7. //namespace CyberX8_Core
  8. //{
  9. // public class RecipeToleranceChecker
  10. // {
  11. // Stopwatch _stopwatch;
  12. // ToleranceMode _toleranceMode;
  13. // List<ToleranceObject> _toleranceObjects;
  14. // public RecipeToleranceChecker()
  15. // {
  16. // _stopwatch = new Stopwatch();
  17. // }
  18. // public void Start(ToleranceMode toleranceMode, List<ToleranceObject> toleranceObjects)
  19. // {
  20. // _stopwatch.Start();
  21. // _toleranceMode = toleranceMode;
  22. // _toleranceObjects = toleranceObjects;
  23. // _toleranceObjects.ForEach(_toleranceObject =>
  24. // {
  25. // if (_toleranceMode == ToleranceMode.Percent)
  26. // {
  27. // _toleranceObject.WarningScale = _toleranceObject.SetPoint * _toleranceObject.WarningScale / 100;
  28. // _toleranceObject.AlarmScale = _toleranceObject.SetPoint * _toleranceObject.AlarmScale / 100;
  29. // }
  30. // });
  31. // }
  32. // public void Monitor(params int[] feedBacks)
  33. // {
  34. // for (int i = 0; i < _toleranceObjects.Count; i++)
  35. // {
  36. // if (_stopwatch.ElapsedMilliseconds > _toleranceObjects[i].DelayTime)
  37. // {
  38. // if ((feedBacks[i] < _toleranceObjects[i].SetPoint - _toleranceObjects[i].WarningScale || feedBacks[i] > _toleranceObjects[i].SetPoint + _toleranceObjects[i].WarningScale) && _toleranceObjects[i].WarningFlag == false)
  39. // {
  40. // _toleranceObjects[i].WarningFlag = true;
  41. // }
  42. // }
  43. // }
  44. // for (int i = 0; i < _toleranceObjects.Count; i++)
  45. // {
  46. // if (_stopwatch.ElapsedMilliseconds > _toleranceObjects[i].DelayTime)
  47. // {
  48. // if ((feedBacks[i] < _toleranceObjects[i].SetPoint - _toleranceObjects[i].AlarmScale || feedBacks[i] > _toleranceObjects[i].SetPoint + _toleranceObjects[i].AlarmScale) && _toleranceObjects[i].AlarmFlag == false)
  49. // {
  50. // _toleranceObjects[i].AlarmFlag = true;
  51. // }
  52. // }
  53. // }
  54. // }
  55. // public void End()
  56. // {
  57. // _stopwatch.Stop();
  58. // }
  59. // }
  60. // public class ToleranceObject
  61. // {
  62. // public string Name { get; set; }
  63. // public int SetPoint { get; set; }
  64. // public int WarningScale { get; set; }
  65. // public int AlarmScale { get; set; }
  66. // public bool WarningFlag { get; set; }
  67. // public bool AlarmFlag { get; set; }
  68. // public int DelayTime { get; set; }
  69. // public ToleranceObject(string name, int setPoint, int warningScale, int alarmScale, int delayTime)
  70. // {
  71. // Name = name;
  72. // SetPoint = setPoint;
  73. // WarningScale = warningScale;
  74. // AlarmScale = alarmScale;
  75. // DelayTime = delayTime;
  76. // }
  77. // }
  78. //}