Titration1PotassiumPermanganateNormalLiquidHandler.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. using SHJX.Service.Control.Common.Assets;
  2. using SHJX.Service.Control.Execute.TitrationController;
  3. namespace SHJX.Service.Control.LiquidHandler.Handler.NormalLiquidHandler
  4. {
  5. public class Titration1PotassiumPermanganateNormalLiquidHandler : INormalLiquid
  6. {
  7. public bool Execute(Action<object> callBack = null, params object[] args)
  8. {
  9. LiquidVolume liquidVolume = DataManagerInstance.GetLiquidVolume(EquipmentNames.Titration1PotassiumPermanganate);
  10. if (liquidVolume is null)
  11. {
  12. throw new ArgumentException($"{EquipmentNames.Titration1PotassiumPermanganate}查询Volume为空");
  13. }
  14. if (!liquidVolume.Enable)
  15. {
  16. return true;
  17. }
  18. #region 逻辑状态机
  19. bool locker;
  20. do
  21. {
  22. StateMachine state = DataManagerInstance.QueryStateMachine(StateMachineName.POTASSIUM1PERMANGANATE_LOCK);
  23. locker = state.Status > 0;
  24. } while (locker);
  25. #endregion
  26. LiquidAmount liquidAmount = DataManagerInstance.GetLiquidAmount(EquipmentNames.Titration1PotassiumPermanganate);
  27. if (liquidAmount is null)
  28. {
  29. throw new ArgumentException($"{EquipmentNames.Titration1PotassiumPermanganate}查询Amount为空");
  30. }
  31. CameraValue explosion1 = DataManagerInstance.GetCameraValue();
  32. TitrationValue titrationValue = args[1].ToString().BeIn(TaskTypeName.CALIBRATION_ZH, TaskTypeName.BLANK_ZH)
  33. ? DataManagerInstance.GetTitrationValue("Blank")
  34. : DataManagerInstance.GetTitrationValue("Sample");
  35. TitrationArg arg = new()
  36. {
  37. RangeValue = titrationValue.RangeValue,
  38. BeforeWaitTime = titrationValue.BeforeWaitTime,
  39. ArriveCheckCount = titrationValue.ArriveCheckCount,
  40. LiquidAmount = liquidAmount.Amount,
  41. IntervalTime = titrationValue.IntervalTime,
  42. PumpCapacity = liquidAmount.Capacity,
  43. LiquidConvertRatio = liquidAmount.ConvertRatio,
  44. WhetherQuicklyTitration = Convert.ToBoolean(args[0]),
  45. QuicklyTitrationValue = titrationValue.QuicklyTitrationValue,
  46. BatchName="",
  47. TaskName="",
  48. explosion = explosion1
  49. };
  50. arg.MaxDropVolume = args[1].ToString() switch
  51. {
  52. TaskTypeName.CALIBRATION_ZH => titrationValue.CalibrationMaxDropVolume,
  53. _ => titrationValue.NormalMaxDropVolume,
  54. };
  55. double amount = 0.0;
  56. DataManagerInstance.IncreaseLock(StateMachineName.POTASSIUM1PERMANGANATE_LOCK);
  57. TitrationExecute.Start(arg, ref amount);
  58. DataManagerInstance.DecreaseLock(StateMachineName.POTASSIUM1PERMANGANATE_LOCK);
  59. callBack?.Invoke(amount);
  60. //Todo:这里做液体扣减
  61. DataManagerInstance.DecreaseLiquidTotal("PotassiumPermanganate", amount);
  62. DataManagerInstance.DecreaseLiquidReserve("PotassiumPermanganate");
  63. return true;
  64. }
  65. }
  66. }