12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- using Aitex.Core.RT.DataCenter;
- using Aitex.Core.RT.Device;
- using Aitex.Core.RT.Routine;
- using Aitex.Core.RT.SCCore;
- using MECF.Framework.Common.Equipment;
- using CyberX8_Core;
- using CyberX8_RT.Devices.PUF;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace CyberX8_RT.Modules.PUF
- {
- public class PufCalibrateRoutine : ModuleRoutineBase, IRoutine
- {
- #region 常量
- private const string CHUCKA_RELEASE = "ChuckARelease";
- private const double STANDARD = 100;
- #endregion
- private enum PufCalibrateStep
- {
- VacuumOff,
- SaveConfig,
- End
- }
- #region 内部变量
- private PufVacuum _vacuum;
- private PufDistanceSensor _distanceSensor;
- private int _timeOut = 6000;
- private double _offset1;
- private double _offset2;
- #endregion
- public PufCalibrateRoutine(ModuleName module) : base(module)
- {
- _vacuum = DEVICE.GetDevice<PufVacuum>($"{module.ToString()}.Vacuum");
- _distanceSensor = DEVICE.GetDevice<PufDistanceSensor>($"{module.ToString()}.DistanceSensor");
- Name = "Vacuum";
- }
- public void Abort()
- {
- Runner.Stop("Manual Abort");
- }
- public RState Monitor()
- {
- Runner.Run(PufCalibrateStep.VacuumOff, VacuumAOff, _timeOut)
- .Run(PufCalibrateStep.SaveConfig, SaveConfig, NullFun, _timeOut)
- .End(PufCalibrateStep.End,NullFun);
- return Runner.Status;
- }
- private bool VacuumAOff()
- {
- return _vacuum.VacuumAOff();
- }
- private bool SaveConfig()
- {
- _distanceSensor.SaveConfig(_offset1, _offset2);
- return true;
- }
- public RState Start(params object[] objs)
- {
- if(objs == null || objs.Length == 0)
- {
- return RState.Failed;
- }
- _offset1 = STANDARD - (double)objs[1];
- _offset2=STANDARD- (double)objs[2];
- Runner.Start(Module, Name);
- return RState.Running;
- }
- }
- }
|