| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- using SHJX.Service.Control.Common.Assets;
- using SHJX.Service.Control.Execute.TitrationController;
- namespace SHJX.Service.Control.LiquidHandler.Handler.NormalLiquidHandler
- {
- public class Titration1PotassiumPermanganateNormalLiquidHandler : INormalLiquid
- {
- public bool Execute(Action<object> callBack = null, params object[] args)
- {
- LiquidVolume liquidVolume = DataManagerInstance.GetLiquidVolume(EquipmentNames.Titration1PotassiumPermanganate);
- if (liquidVolume is null)
- {
- throw new ArgumentException($"{EquipmentNames.Titration1PotassiumPermanganate}查询Volume为空");
- }
- if (!liquidVolume.Enable)
- {
- return true;
- }
- #region 逻辑状态机
- bool locker;
- do
- {
- StateMachine state = DataManagerInstance.QueryStateMachine(StateMachineName.POTASSIUM1PERMANGANATE_LOCK);
- locker = state.Status > 0;
- } while (locker);
- #endregion
- LiquidAmount liquidAmount = DataManagerInstance.GetLiquidAmount(EquipmentNames.Titration1PotassiumPermanganate);
- if (liquidAmount is null)
- {
- throw new ArgumentException($"{EquipmentNames.Titration1PotassiumPermanganate}查询Amount为空");
- }
- CameraValue explosion1 = DataManagerInstance.GetCameraValue();
- TitrationValue titrationValue = args[1].ToString().BeIn(TaskTypeName.CALIBRATION_ZH, TaskTypeName.BLANK_ZH)
- ? DataManagerInstance.GetTitrationValue("Blank")
- : DataManagerInstance.GetTitrationValue("Sample");
- TitrationArg arg = new()
- {
- RangeValue = titrationValue.RangeValue,
- BeforeWaitTime = titrationValue.BeforeWaitTime,
- ArriveCheckCount = titrationValue.ArriveCheckCount,
- LiquidAmount = liquidAmount.Amount,
- IntervalTime = titrationValue.IntervalTime,
- PumpCapacity = liquidAmount.Capacity,
- LiquidConvertRatio = liquidAmount.ConvertRatio,
- WhetherQuicklyTitration = Convert.ToBoolean(args[0]),
- QuicklyTitrationValue = titrationValue.QuicklyTitrationValue,
- BatchName="",
- TaskName="",
- explosion = explosion1
- };
- arg.MaxDropVolume = args[1].ToString() switch
- {
- TaskTypeName.CALIBRATION_ZH => titrationValue.CalibrationMaxDropVolume,
- _ => titrationValue.NormalMaxDropVolume,
- };
- double amount = 0.0;
- DataManagerInstance.IncreaseLock(StateMachineName.POTASSIUM1PERMANGANATE_LOCK);
- TitrationExecute.Start(arg, ref amount);
- DataManagerInstance.DecreaseLock(StateMachineName.POTASSIUM1PERMANGANATE_LOCK);
- callBack?.Invoke(amount);
- //Todo:这里做液体扣减
- DataManagerInstance.DecreaseLiquidTotal("PotassiumPermanganate", amount);
- DataManagerInstance.DecreaseLiquidReserve("PotassiumPermanganate");
- return true;
- }
- }
- }
|