123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- using Aitex.Core.RT.Device;
- using Aitex.Core.RT.Log;
- using Aitex.Core.RT.Routine;
- using Aitex.Core.RT.SCCore;
- using CyberX8_Core;
- using CyberX8_RT.Devices.Metal;
- using MECF.Framework.Common.RecipeCenter;
- using MECF.Framework.Common.Routine;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace CyberX8_RT.Modules.Metal
- {
- public class CurrentShortTestRoutine : RoutineBase, IRoutine
- {
- private enum CurrentShortStep
- {
- SetSideACurrent,
- SetSideAWait,
- CheckSideA,
- SetSideBCurrent,
- SetSideBWait,
- CheckSideB,
- End
- }
- #region 常量
- private const string SIDE_A = "SideA";
- /// <summary>
- /// 1A
- /// </summary>
- private const double CURRENT_1A = 1;
- #endregion
- #region 内部变量
- /// <summary>
- /// S&H 设备
- /// </summary>
- private MetalCellDevice _device;
- /// <summary>
- ///
- /// </summary>
- private double _shortTestThreshold = 0.1;
- #endregion
- /// <summary>
- /// 构造函数
- /// </summary>
- /// <param name="module"></param>
- public CurrentShortTestRoutine(string module) : base(module)
- {
- }
- /// <summary>
- /// 中止
- /// </summary>
- public void Abort()
- {
- Runner.Stop("Manual Abort");
- }
- /// <summary>ru
- /// 监控
- /// </summary>
- /// <returns></returns>
- public RState Monitor()
- {
- Runner.Run(CurrentShortStep.SetSideACurrent, SetSideACurrent, _delay_1ms)
- .WaitWithStopCondition(CurrentShortStep.SetSideAWait,()=> { return _device.SideAPowerSupplier.Status == RState.End; }
- ,()=>{ return _device.SideAPowerSupplier.Status == RState.Failed; },_delay_5s)
- .Wait(CurrentShortStep.CheckSideA, () => CheckCurrent(_device.SideAPowerSupplier.PowerSupplierData.Current), _delay_1s)
- .Run(CurrentShortStep.SetSideBCurrent, SetSideBCurrent, _delay_1ms)
- .WaitWithStopCondition(CurrentShortStep.SetSideBWait, () => { return _device.SideBPowerSupplier.Status == RState.End; }
- , () => { return _device.SideBPowerSupplier.Status == RState.Failed; }, _delay_5s)
- .Wait(CurrentShortStep.CheckSideB, () => CheckCurrent(_device.SideBPowerSupplier.PowerSupplierData.Current), _delay_1s)
- .End(CurrentShortStep.End, ClosePower, _delay_1ms);
- return Runner.Status;
- }
- /// <summary>
- /// 设置A电流
- /// </summary>
- /// <returns></returns>
- private bool SetSideACurrent()
- {
- return _device.SideAPowerSupplier.SetCurrentAndOutput(CURRENT_1A);
- }
- /// <summary>
- /// 检验电流
- /// </summary>
- /// <param name="current"></param>
- /// <returns></returns>
- private bool CheckCurrent(double current)
- {
- return current >= _shortTestThreshold;
- }
- /// <summary>
- /// 设置B电流
- /// </summary>
- /// <returns></returns>
- private bool SetSideBCurrent()
- {
- return _device.SideBPowerSupplier.SetCurrentAndOutput(CURRENT_1A);
- }
- /// <summary>
- /// 关闭电源
- /// </summary>
- /// <returns></returns>
- private bool ClosePower()
- {
- _device.SideAPowerSupplier.DisableOperation("", null);
- _device.SideBPowerSupplier.DisableOperation("", null);
- return true;
- }
- /// <summary>
- /// 启动
- /// </summary>
- /// <param name="objs"></param>
- /// <returns></returns>
- public RState Start(params object[] objs)
- {
- _device = DEVICE.GetDevice<MetalCellDevice>(Module);
- _shortTestThreshold = SC.GetValue<double>("Metal.ShortTestThreshold");
- return Runner.Start(Module, "Start Current Short Test");
- }
- }
- }
|