123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995 |
- using Aitex.Core.RT.DataCenter;
- using Aitex.Core.RT.Device;
- using Aitex.Core.RT.Event;
- using Aitex.Core.RT.Log;
- using Aitex.Core.RT.OperationCenter;
- using Aitex.Core.RT.Routine;
- using Aitex.Core.RT.SCCore;
- using Aitex.Core.Util;
- using MECF.Framework.Common.Beckhoff.ModuleIO;
- using MECF.Framework.Common.CommonData.SRD;
- using MECF.Framework.Common.Persistent.Prewet;
- using MECF.Framework.Common.Persistent.SRD;
- using MECF.Framework.Common.TwinCat;
- using CyberX8_Core;
- using System.Reflection;
- using CyberX8_RT.Modules.Rinse;
- using CyberX8_RT.Modules;
- using CyberX8_RT.Modules.SRD;
- using CyberX8_RT.Devices.AXIS;
- using MECF.Framework.Common.Persistent.Rinse;
- using System.Security.Principal;
- using MECF.Framework.Common.IOCore;
- using Aitex.Core.Common;
- namespace CyberX8_RT.Devices.SRD
- {
- public class SrdCommonDevice : BaseDevice, IDevice
- {
- /// <summary>
- /// Srd操作枚举
- /// </summary>
- private enum SrdCommonOperation
- {
- None,
- DoorClose,
- DoorOpen,
- ChuckVacuumOn,
- ChuckVacuumOff,
- LiftUpOn,
- LiftUpOff,
- FlippersIn,
- FlippersOut,
- ChuckATMClick
- }
- #region 常量
- private const string FLUID_CONTAINMENT = "FluidContainment";
- private const string VACUUM_VALUE = "VacuumValue";
- private const string WAFER_PRESENCE = "WaferPresence";
- private const string WAFER_PRESENCE_STATUS = "WaferPresenceStatus";
- private const string WATER_PRESSURE = "WaterPressure";
- private const string DOOR_CLOSE="DoorClose";
- private const string DOOR_CLOSED = "DoorClosed";
- private const string DOOR_OPENED = "DoorOpened";
- private const string WATER_ABOVE="WaterAbove";
- private const string WATER_BELOW = "WaterBelow";
- private const string CHUCK_VACUUM="ChuckVacuum";
- private const string EXHAUST_ON="ExhaustOn";
- private const string COMMON_DATA = "CommonData";
- private const string PERSISTENT_VALUE= "PersistentValue";
- private const string CHUCK_ATM_ON = "ChuckATMOn";
- private const string CHUCK_VACUUM_OK = "ChuckVacuumOK";
- private const string WAFER_PRESENT = "WaferPresent";
- private const string LIFT_UP = "LiftUp";
- private const string LIFT_UP_STATUS = "LiftUpStatus";
- private const string FLIPPER1_OUT_100_STATUS = "Flipper1Out100Status";
- private const string FLIPPER2_OUT_100_STATUS = "Flipper2Out100Status";
- private const string FLIPPER3_OUT_100_STATUS = "Flipper3Out100Status";
- private const string FLIPPER1_OUT_150_STATUS = "Flipper1Out150Status";
- private const string FLIPPER2_OUT_150_STATUS = "Flipper2Out150Status";
- private const string FLIPPER3_OUT_150_STATUS = "Flipper3Out150Status";
- private const string FLIPPER1_OUT_200_STATUS = "Flipper1Out200Status";
- private const string FLIPPER2_OUT_200_STATUS = "Flipper2Out200Status";
- private const string FLIPPER3_OUT_200_STATUS = "Flipper3Out200Status";
- private const string FLIPPERS_IN_100 = "FlippersIn100";
- private const string FLIPPERS_IN_150 = "FlippersIn150";
- private const string FLIPPERS_IN_200 = "FlippersIn200";
- private const string WATER_FLOW = "WaterFlow";
- private const string WATER_ON = "WaterOn";
- private const string N2_ON= "N2On";
- #endregion
- #region 内部变量
- /// <summary>
- /// Common数据
- /// </summary>
- private SrdCommonData _commonData = new SrdCommonData();
- /// <summary>
- /// 状态
- /// </summary>
- private RState _status;
- /// <summary>
- /// 当前操作
- /// </summary>
- private SrdCommonOperation _currentOperation;
- /// <summary>
- /// Wafer Presence
- /// </summary>
- private string _waferPresence;
- /// <summary>
- /// Persistent Value对象
- /// </summary>
- private SRDPersistentValue _srdPersistentValue;
- /// <summary>
- /// IsWaferPresence
- /// </summary>
- private bool _isWaferPresence = true;
- /// <summary>
- /// Total Device
- /// </summary>
- private TotalSRDDevice _totalSRDDevice;
- #region Routine
- /// <summary>
- /// Close Routine
- /// </summary>
- private SrdCommonDoorCloseRoutine _doorCloseRoutine;
- /// <summary>
- /// Vacuum Routine
- /// </summary>
- private SrdCommonChuckVacuumRoutine _chuckVacuumRoutine;
- /// <summary>
- /// Lift Up routine
- /// </summary>
- private SrdCommonLiftUpRoutine _liftUpRoutine;
- /// <summary>
- /// Flippers Routine
- /// </summary>
- private SrdCommonFlipperRoutine _flipperRoutine;
- /// <summary>
- /// Chuck ATM Click Routine
- /// </summary>
- private SrdCommonChuckATMRoutine _chuckATMRoutine;
- #endregion
- #endregion
- #region 属性
- /// <summary>
- /// Common数据
- /// </summary>
- public SrdCommonData CommonData
- {
- get { return _commonData; }
- }
- /// <summary>
- /// 状态
- /// </summary>
- public RState Status { get { return _status; } }
- /// <summary>
- /// Wafer Presence
- /// </summary>
- public string WaferPresence
- {
- get { return _waferPresence; }
- }
- /// <summary>
- /// IsWaferPresence
- /// </summary>
- public bool IsWaferPresence
- {
- get { return _isWaferPresence; }
- }
- #endregion
- /// <summary>
- /// 构造函数
- /// </summary>
- /// <param name="moduleName"></param>
- /// <param name="name"></param>
- public SrdCommonDevice(string moduleName) : base(moduleName, "Common", "Common", "Common")
- {
- }
- /// <summary>
- /// 初始化
- /// </summary>
- /// <returns></returns>
- public bool Initialize()
- {
- InitializeRoutine();
- SubscribeData();
- SubscribeValueAction();
- InitializeOperation();
- return true;
- }
- /// <summary>
- /// 初始化Routine
- /// </summary>
- private void InitializeRoutine()
- {
- _doorCloseRoutine = new SrdCommonDoorCloseRoutine(Module);
- _chuckVacuumRoutine = new SrdCommonChuckVacuumRoutine(Module);
- _liftUpRoutine = new SrdCommonLiftUpRoutine(Module);
- _flipperRoutine = new SrdCommonFlipperRoutine(Module);
- _chuckATMRoutine = new SrdCommonChuckATMRoutine(Module);
- }
- /// <summary>
- /// 订阅数据
- /// </summary>
- private void SubscribeData()
- {
- _srdPersistentValue = SRDPersistentManager.Instance.GetModulePersistentValue(Module);
- if(_srdPersistentValue==null)
- {
- LOG.WriteLog(eEvent.ERR_SRD, Module, "Persistent Value Object is not exist");
- }
- DATA.Subscribe($"{Module}.{PERSISTENT_VALUE}", () => _srdPersistentValue, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.{COMMON_DATA}", () => _commonData, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.{WAFER_PRESENCE_STATUS}", () => _waferPresence, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.IsWaferPresence", () => IsWaferPresence, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- }
- /// <summary>
- /// 订阅变量数值发生变化
- /// </summary>
- private void SubscribeValueAction()
- {
- IOModuleManager.Instance.SubscribeModuleVariable(Module, VACUUM_VALUE, UpdateVariableValue);
- IOModuleManager.Instance.SubscribeModuleVariable(Module, WAFER_PRESENCE, UpdateVariableValue);
- IOModuleManager.Instance.SubscribeModuleVariable(Module, DOOR_CLOSE, UpdateVariableValue);
- IOModuleManager.Instance.SubscribeModuleVariable(Module, DOOR_CLOSED, UpdateVariableValue);
- IOModuleManager.Instance.SubscribeModuleVariable(Module, DOOR_OPENED, UpdateVariableValue);
- IOModuleManager.Instance.SubscribeModuleVariable(Module, WATER_ABOVE, UpdateVariableValue);
- IOModuleManager.Instance.SubscribeModuleVariable(Module, WATER_BELOW, UpdateVariableValue);
- IOModuleManager.Instance.SubscribeModuleVariable(Module, CHUCK_VACUUM, UpdateVariableValue);
- IOModuleManager.Instance.SubscribeModuleVariable(Module, EXHAUST_ON, UpdateVariableValue);
- IOModuleManager.Instance.SubscribeModuleVariable(Module, CHUCK_ATM_ON, UpdateVariableValue);
- IOModuleManager.Instance.SubscribeModuleVariable(Module, CHUCK_VACUUM_OK, UpdateVariableValue);
- IOModuleManager.Instance.SubscribeModuleVariable(Module, WAFER_PRESENT, UpdateVariableValue);
- IOModuleManager.Instance.SubscribeModuleVariable(Module, LIFT_UP, UpdateVariableValue);
- IOModuleManager.Instance.SubscribeModuleVariable(Module, LIFT_UP_STATUS, UpdateVariableValue);
- IOModuleManager.Instance.SubscribeModuleVariable(Module, FLIPPER1_OUT_100_STATUS, UpdateVariableValue);
- IOModuleManager.Instance.SubscribeModuleVariable(Module, FLIPPER2_OUT_100_STATUS, UpdateVariableValue);
- IOModuleManager.Instance.SubscribeModuleVariable(Module, FLIPPER3_OUT_100_STATUS, UpdateVariableValue);
- IOModuleManager.Instance.SubscribeModuleVariable(Module, FLIPPER1_OUT_150_STATUS, UpdateVariableValue);
- IOModuleManager.Instance.SubscribeModuleVariable(Module, FLIPPER2_OUT_150_STATUS, UpdateVariableValue);
- IOModuleManager.Instance.SubscribeModuleVariable(Module, FLIPPER3_OUT_150_STATUS, UpdateVariableValue);
- IOModuleManager.Instance.SubscribeModuleVariable(Module, FLIPPER1_OUT_200_STATUS, UpdateVariableValue);
- IOModuleManager.Instance.SubscribeModuleVariable(Module, FLIPPER2_OUT_200_STATUS, UpdateVariableValue);
- IOModuleManager.Instance.SubscribeModuleVariable(Module, FLIPPER3_OUT_200_STATUS, UpdateVariableValue);
- IOModuleManager.Instance.SubscribeModuleVariable(Module, FLIPPERS_IN_100, UpdateVariableValue);
- IOModuleManager.Instance.SubscribeModuleVariable(Module, FLIPPERS_IN_150, UpdateVariableValue);
- IOModuleManager.Instance.SubscribeModuleVariable(Module, FLIPPERS_IN_200, UpdateVariableValue);
- IOModuleManager.Instance.SubscribeModuleVariable(Module, WATER_FLOW, UpdateVariableValue);
- IOModuleManager.Instance.SubscribeModuleVariable(Module, N2_ON, UpdateVariableValue);
- IOModuleManager.Instance.SubscribeModuleVariable(Module, WATER_ON, UpdateVariableValue);
- }
- /// <summary>
- /// 初始化操作
- /// </summary>
- private void InitializeOperation()
- {
- OP.Subscribe($"{Module}.{Name}.DoorClose", DoorCloseAction);
- OP.Subscribe($"{Module}.{Name}.DoorOpen", DoorOpenAction);
- OP.Subscribe($"{Module}.{Name}.WaterOn", WaterOnAction);
- OP.Subscribe($"{Module}.{Name}.WaterOff", WaterOffAction);
- OP.Subscribe($"{Module}.{Name}.ChuckVacuumOn", ChuckVacuumOnAction);
- OP.Subscribe($"{Module}.{Name}.ChuckVacuumOff", ChuckVacuumOffAction);
- OP.Subscribe($"{Module}.{Name}.N2On", N2OnAction);
- OP.Subscribe($"{Module}.{Name}.N2Off", N2OffAction);
- OP.Subscribe($"{Module}.{Name}.LiftUpOn", LiftUpOnAction);
- OP.Subscribe($"{Module}.{Name}.LiftUpOff", LiftUpOffAction);
- OP.Subscribe($"{Module}.{Name}.ChuckATMOn", ChuckATMOnAction);
- OP.Subscribe($"{Module}.{Name}.ChuckATMOff", ChuckATMOffAction);
- OP.Subscribe($"{Module}.{Name}.FlipperIn", FlipperInAction);
- OP.Subscribe($"{Module}.{Name}.FlipperOut", FlipperOutAction);
- OP.Subscribe($"{Module}.KeyDown", KeyDownAction);
- OP.Subscribe($"{Module}.DisabledAction", DisabledOperation);
- OP.Subscribe($"{Module}.ManualAction", ManualOperation);
- OP.Subscribe($"{Module}.AutoAction", AutoOperation);
- OP.Subscribe($"{Module}.EngineeringModeAction", EngineeringModeOperation);
- OP.Subscribe($"{Module}.ProductionModeAction", ProductionModeOperation);
- OP.Subscribe($"{Module}.UpdateIsWaferPresenceAction", UpdateIsWaferPresenceAction);
- }
- /// 更新变量数值
- /// </summary>
- /// <param name="variable"></param>
- /// <param name="value"></param>
- private void UpdateVariableValue(string variable, object value)
- {
- if(!CommonData.IsDataInitialized)
- {
- CommonData.IsDataInitialized = true;
- }
- PropertyInfo property = CommonData.GetType().GetProperty(variable);
- if (property != null)
- {
- property.SetValue(CommonData, value);
- }
- UpdateWaferPresence(variable, value);
- }
- /// <summary>
- /// 更新Wafer Presence
- /// </summary>
- private void UpdateWaferPresence(string variable,object value)
- {
- if (variable == WAFER_PRESENCE&&value is double)
- {
- UpdateWaferPresence((double)value);
- }
- }
- /// <summary>
- /// 更新Wafer Presence
- /// </summary>
- /// <param name="waferPresence"></param>
- private void UpdateWaferPresence(double waferPresence)
- {
- if (_srdPersistentValue != null)
- {
- if (waferPresence > _srdPersistentValue.EmptyThreshold)
- {
- _waferPresence = "Empty";
- }
- else if (waferPresence >= _srdPersistentValue.WellPlacedHighThreshold && waferPresence <= _srdPersistentValue.EmptyThreshold)
- {
- _waferPresence = "PoorlyPlaced";
- }
- else if (waferPresence < _srdPersistentValue.WellPlacedLowThreshold)
- {
- _waferPresence = "PoorlyPlaced";
- }
- else
- {
- _waferPresence = "WellPlaced";
- }
- }
- }
-
- #region Operation
- #region OperationStatus
- /// <summary>
- /// DisabledAction
- /// </summary>
- /// <param name="cmd"></param>
- /// <param name="param"></param>
- /// <returns></returns>
- private bool DisabledOperation(string cmd, object[] args)
- {
- string currentOperation = "Disabled";
- SRDEntity srdEntity = Singleton<RouteManager>.Instance.GetModule<SRDEntity>(Module);
- if (srdEntity != null && _srdPersistentValue != null && _srdPersistentValue.OperatingMode != currentOperation)
- {
- string preOperation = _srdPersistentValue.OperatingMode;
- if (srdEntity.IsBusy)
- {
- LOG.WriteLog(eEvent.ERR_SRD, Module, $"{Module} is Busy, can't change to Disabled mode");
- return false;
- }
- srdEntity.EnterInit();
- SRDPersistentManager.Instance.UpdateOperationModeValue(Module, currentOperation);
- LOG.WriteLog(eEvent.INFO_SRD, Module, $"Operating mode is switched from {preOperation} to {currentOperation}");
- }
- return true;
- }
- /// <summary>
- /// ManualAction
- /// </summary>
- /// <param name="cmd"></param>
- /// <param name="param"></param>
- /// <returns></returns>
- private bool ManualOperation(string cmd, object[] args)
- {
- string currentOperation = "Manual";
- SRDEntity srdEntity = Singleton<RouteManager>.Instance.GetModule<SRDEntity>(Module);
- if (srdEntity != null && _srdPersistentValue != null && _srdPersistentValue.OperatingMode != currentOperation)
- {
- string preOperation = _srdPersistentValue.OperatingMode;
- if (srdEntity.IsBusy)
- {
- LOG.WriteLog(eEvent.ERR_SRD, Module, $"{Module} is Busy, can't change to Manual mode");
- return false;
- }
- srdEntity.EnterInit();
- SRDPersistentManager.Instance.UpdateOperationModeValue(Module, currentOperation);
- LOG.WriteLog(eEvent.INFO_SRD, Module, $"Operating mode is switched from {preOperation} to {currentOperation}");
- }
- return true;
- }
- /// <summary>
- /// AutoAction
- /// </summary>
- /// <param name="cmd"></param>
- /// <param name="param"></param>
- /// <returns></returns>
- private bool AutoOperation(string cmd, object[] args)
- {
- string currentOperation = "Auto";
- SRDEntity srdEntity = Singleton<RouteManager>.Instance.GetModule<SRDEntity>(Module);
- if (srdEntity != null && _srdPersistentValue != null && _srdPersistentValue.OperatingMode != currentOperation)
- {
- string preOperation = _srdPersistentValue.OperatingMode;
- if (srdEntity.IsBusy)
- {
- LOG.WriteLog(eEvent.ERR_SRD, Module, $"{Module} is Busy, can't switch to Auto mode");
- return false;
- }
- srdEntity.EnterInit();
- SRDPersistentManager.Instance.UpdateOperationModeValue(Module, currentOperation);
- LOG.WriteLog(eEvent.INFO_SRD, Module, $"Operating mode is switched from {preOperation} to {currentOperation}");
- }
- return true;
- }
- /// <summary>
- /// EngineeringModeAction
- /// </summary>
- /// <param name="cmd"></param>
- /// <param name="param"></param>
- /// <returns></returns>
- private bool EngineeringModeOperation(string cmd, object[] args)
- {
- string currentRecipeOperation = "Engineering";
- SRDPersistentManager.Instance.UpdateRecipeOperationModeValue(Module, currentRecipeOperation);
- return true;
- }
- /// <summary>
- /// ProductionAction
- /// </summary>
- /// <param name="cmd"></param>
- /// <param name="param"></param>
- /// <returns></returns>
- private bool ProductionModeOperation(string cmd, object[] args)
- {
- string currentRecipeOperation = "Production";
- SRDPersistentManager.Instance.UpdateRecipeOperationModeValue(Module, currentRecipeOperation);
- return true;
- }
- #endregion
- #region keydown
- private bool KeyDownAction(string cmd, object[] args)
- {
- string variableName = args[0].ToString();
- PropertyInfo property = _srdPersistentValue.GetType().GetProperty(variableName);
- if(property!=null)
- {
- property.SetValue(_srdPersistentValue, args[1]);
- }
- SRDPersistentManager.Instance.UpdateModulePersistentValue(Module);
- UpdateWaferPresence(CommonData.WaferPresence);
- return true;
- }
- #endregion
- #region Door
- /// <summary>
- /// Door Close操作
- /// </summary>
- public bool DoorCloseAction(string cmd, object[] args)
- {
- if (!JudgeRunningState(SrdCommonOperation.DoorClose))
- {
- _currentOperation = SrdCommonOperation.DoorClose;
- _status = _doorCloseRoutine.Start(true);
- return _status==RState.Running;
- }
- else
- {
- return false;
- }
- }
- /// <summary>
- /// Door Open操作
- /// </summary>
- public bool DoorOpenAction(string cmd, object[] args)
- {
- if (!JudgeRunningState(SrdCommonOperation.DoorOpen))
- {
- _currentOperation = SrdCommonOperation.DoorOpen;
- _status = _doorCloseRoutine.Start(false);
- return _status==RState.Running;
- }
- else
- {
- return false;
- }
- }
- #endregion
- #region N2 On
- /// <summary>
- /// N2 On
- /// </summary>
- /// <param name="cmd"></param>
- /// <param name="args"></param>
- /// <returns></returns>
- public bool N2OnAction(string cmd, object[] args)
- {
- return N2On();
- }
- /// <summary>
- /// N2 Off
- /// </summary>
- /// <param name="cmd"></param>
- /// <param name="args"></param>
- /// <returns></returns>
- public bool N2OffAction(string cmd, object[] args)
- {
- return N2Off();
- }
- /// <summary>
- /// Exhaust On(不确认信号)
- /// </summary>
- /// <returns></returns>
- public bool N2On()
- {
- string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{N2_ON}");
- return IOModuleManager.Instance.WriteIoValue(ioName, true);
- }
- /// <summary>
- /// Exhaust On(不确认信号)
- /// </summary>
- /// <returns></returns>
- public bool N2Off()
- {
- string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{N2_ON}");
- return IOModuleManager.Instance.WriteIoValue(ioName, false);
- }
- #endregion
- #region Flipper
- /// <summary>
- /// FlipperIn
- /// </summary>
- /// <param name="cmd"></param>
- /// <param name="args"></param>
- /// <returns></returns>
- public bool FlipperInAction(string cmd, object[] args)
- {
- int waferSize = (int)args[0];
- if (!JudgeRunningState(SrdCommonOperation.FlippersIn))
- {
- _currentOperation = SrdCommonOperation.FlippersIn;
- _status = _flipperRoutine.Start(true, waferSize);
- return _status == RState.Running;
- }
- else
- {
- return false;
- }
- }
- /// <summary>
- /// FlipperOut
- /// </summary>
- /// <param name="cmd"></param>
- /// <param name="args"></param>
- /// <returns></returns>
- public bool FlipperOutAction(string cmd, object[] args)
- {
- int waferSize = (int)args[0];
- if (!JudgeRunningState(SrdCommonOperation.FlippersOut))
- {
- _currentOperation = SrdCommonOperation.FlippersOut;
- _status = _flipperRoutine.Start(false, waferSize);
- return _status == RState.Running;
- }
- else
- {
- return false;
- }
- }
- #endregion
- #region Water
- /// <summary>
- /// Water On操作
- /// </summary>
- public bool WaterOnAction(string cmd, object[] args)
- {
- return WaterOn();
- }
- /// <summary>
- /// water Off操作
- /// </summary>
- public bool WaterOffAction(string cmd, object[] args)
- {
- return WaterOff();
- }
- /// <summary>
- /// Water On(不确认信号)
- /// </summary>
- /// <returns></returns>
- public bool WaterOn()
- {
- string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{WATER_ON}");
- return IOModuleManager.Instance.WriteIoValue(ioName, true);
- }
- /// <summary>
- /// Water Off(不确认信号)
- /// </summary>
- /// <returns></returns>
- public bool WaterOff()
- {
- string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{WATER_ON}");
- return IOModuleManager.Instance.WriteIoValue(ioName, false);
- }
- #endregion
- #region Chuck Vacuum
- /// <summary>
- /// Chuck Vacuum操作
- /// </summary>
- public bool ChuckVacuumOnAction(string cmd, object[] args)
- {
- if (!JudgeRunningState(SrdCommonOperation.ChuckVacuumOn))
- {
- _currentOperation = SrdCommonOperation.ChuckVacuumOn;
- _status = _chuckVacuumRoutine.Start(false);
- return _status==RState.Running;
- }
- else
- {
- return false;
- }
- }
- /// <summary>
- /// chuck Vacuum Off操作
- /// </summary>
- public bool ChuckVacuumOffAction(string cmd, object[] args)
- {
- if (!JudgeRunningState(SrdCommonOperation.ChuckVacuumOff))
- {
- _currentOperation = SrdCommonOperation.ChuckVacuumOff;
- _status= _chuckVacuumRoutine.Start(true);
- return _status==RState.Running;
- }
- else
- {
- return false;
- }
- }
- #endregion
- #region LiftUp
- /// <summary>
- /// Lift Up On
- /// </summary>
- /// <param name="cmd"></param>
- /// <param name="args"></param>
- /// <returns></returns>
- public bool LiftUpOnAction(string cmd, object[] args)
- {
- if (!JudgeRunningState(SrdCommonOperation.LiftUpOn))
- {
- _currentOperation = SrdCommonOperation.LiftUpOn;
- _status = _liftUpRoutine.Start(true);
- return _status == RState.Running;
- }
- else
- {
- return false;
- }
- }
- /// <summary>
- /// Lift Up Off
- /// </summary>
- /// <param name="cmd"></param>
- /// <param name="args"></param>
- /// <returns></returns>
- public bool LiftUpOffAction(string cmd, object[] args)
- {
- if (!JudgeRunningState(SrdCommonOperation.LiftUpOff))
- {
- _currentOperation = SrdCommonOperation.LiftUpOff;
- _status = _liftUpRoutine.Start(false);
- return _status == RState.Running;
- }
- else
- {
- return false;
- }
- }
- #endregion
- #region ChuckATM
- /// <summary>
- /// Chuck ATM On
- /// </summary>
- /// <param name="cmd"></param>
- /// <param name="args"></param>
- /// <returns></returns>
- public bool ChuckATMOnAction(string cmd, object[] args)
- {
- if(CommonData.LiftUp || CommonData.LiftUpStatus)
- {
- LOG.WriteLog(eEvent.ERR_SRD, Module, "LiftUp is on, can't chuckATM");
- return false;
- }
- return ChuckATM(true);
- }
- /// <summary>
- /// Chuck ATM Off
- /// </summary>
- /// <param name="cmd"></param>
- /// <param name="args"></param>
- /// <returns></returns>
- public bool ChuckATMOffAction(string cmd, object[] args)
- {
- return ChuckATM(false);
- }
- private bool ChuckATM(bool value)
- {
- string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{CHUCK_ATM_ON}");
- return IOModuleManager.Instance.WriteIoValue(ioName, value);
- }
- /// <summary>
- /// Chuck ATM Routine
- /// </summary>
- /// <param name="cmd"></param>
- /// <param name="args"></param>
- /// <returns></returns>
- public bool ChuckATMAction(string cmd, object[] args)
- {
- if (!JudgeRunningState(SrdCommonOperation.ChuckATMClick))
- {
- _currentOperation = SrdCommonOperation.ChuckATMClick;
- _status = _chuckATMRoutine.Start();
- return _status == RState.Running;
- }
- else
- {
- return false;
- }
- }
- #endregion
- #region Water Above
- /// <summary>
- /// Water Above On操作
- /// </summary>
- public bool WaterAboveOnAction(string cmd, object[] args)
- {
- return WaterAboveOn();
- }
- /// <summary>
- /// water above Off操作
- /// </summary>
- public bool WaterAboveOffAction(string cmd, object[] args)
- {
- return WaterAboveOff();
- }
- /// <summary>
- /// Water Above On(不确认信号)
- /// </summary>
- /// <returns></returns>
- public bool WaterAboveOn()
- {
- string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{WATER_ABOVE}");
- return IOModuleManager.Instance.WriteIoValue(ioName, true);
- }
- /// <summary>
- /// Water Above Off(不确认信号)
- /// </summary>
- /// <returns></returns>
- public bool WaterAboveOff()
- {
- string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{WATER_ABOVE}");
- return IOModuleManager.Instance.WriteIoValue(ioName, false);
- }
- #endregion
- #region Water Below
- /// <summary>
- /// Water Below On操作
- /// </summary>
- public bool WaterBelowOnAction(string cmd, object[] args)
- {
- return WaterBelowOn();
- }
- /// <summary>
- /// water Below Off操作
- /// </summary>
- public bool WaterBelowOffAction(string cmd, object[] args)
- {
- return WaterBelowOff();
- }
- /// <summary>
- /// Water Below On(不确认信号)
- /// </summary>
- /// <returns></returns>
- public bool WaterBelowOn()
- {
- string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{WATER_BELOW}");
- return IOModuleManager.Instance.WriteIoValue(ioName, true);
- }
- /// <summary>
- /// Water Below Off(不确认信号)
- /// </summary>
- /// <returns></returns>
- public bool WaterBelowOff()
- {
- string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{WATER_BELOW}");
- return IOModuleManager.Instance.WriteIoValue(ioName, false);
- }
- #endregion
- /// <summary>
- /// Update IsWaferPresence 标志位
- /// </summary>
- /// <param name="cmd"></param>
- /// <param name="args"></param>
- /// <returns></returns>
- public bool UpdateIsWaferPresenceAction(string cmd, object[] args)
- {
- _isWaferPresence = (bool)args[0];
- return true;
- }
- /// <summary>
- /// 判定运行状态
- /// </summary>
- /// <returns></returns>
- private bool JudgeRunningState(SrdCommonOperation operation)
- {
- if (_status == RState.Running)
- {
- EV.PostAlarmLog($"{Module}", eEvent.ERR_SRD, $"{Module} current execute {_currentOperation},cannot {operation}");
- return true;
- }
- return false;
- }
- /// <summary>
- /// ErrorOperation
- /// </summary>
- public void EnterErrorOperation()
- {
- //关闭风扇
- if (CommonData.N2On)
- {
- bool result = N2OffAction("", null);
- if (!result)
- {
- LOG.WriteLog(eEvent.ERR_SRD, Module, "EnterError: N2 Off is failed");
- }
- }
- //关闭WaterAbove
- if (CommonData.WaterOn)
- {
- bool result = WaterOff();
- if (!result)
- {
- LOG.WriteLog(eEvent.INFO_SRD, Module, "EnterError: Water Off is failed");
- }
- }
-
- //停电机
- JetAxisBase _rotationAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.Rotation");
- if (_rotationAxis != null && _rotationAxis.IsRun) _rotationAxis.StopPositionOperation();
- }
- #endregion
- /// <summary>
- /// Rotation InterLock
- /// </summary>
- /// <returns></returns>
- public bool RotationInterLock()
- {
- if (!CommonData.DoorClosed)
- {
- LOG.WriteLog(eEvent.ERR_SRD, Module, "Door is not closed. Rotation can not position");
- return false;
- }
- //Check Flippers
- if (CommonData.FlippersIn150 || CommonData.FlippersIn200) //|| _srdCommon.CommonData.FlippersIn100
- {
- LOG.WriteLog(eEvent.ERR_SRD, Module, "FlippersIn is on. Rotation can not position");
- return false;
- }
- if (!CommonData.Flipper1Out150Status || !CommonData.Flipper2Out150Status || !CommonData.Flipper3Out150Status
- || !CommonData.Flipper1Out200Status || !CommonData.Flipper2Out200Status || !CommonData.Flipper3Out200Status)
- //|| !_srdCommon.CommonData.Flipper1Out100Status || !_srdCommon.CommonData.Flipper2Out100Status || !_srdCommon.CommonData.Flipper3Out100Status
- {
- LOG.WriteLog(eEvent.ERR_SRD, Module, "Flippers are at In position. Rotation can not position");
- return false;
- }
- return true;
- }
- /// <summary>
- /// 定时器
- /// </summary>
- /// <returns></returns>
- public bool OnTimer()
- {
- if (_status == RState.Running)
- {
- if (_currentOperation != SrdCommonOperation.None)
- {
- IRoutine routine = GetCurrentRoutine(_currentOperation);
- if (routine != null)
- {
- CheckRoutineState(routine, _currentOperation);
- }
- else
- {
- EndOperation();
- }
- }
- }
- //将公有的数据赋值于对象的数值
- if (_totalSRDDevice == null)
- {
- _totalSRDDevice = DEVICE.GetDevice<TotalSRDDevice>("SRD");
- }
- if (_totalSRDDevice != null)
- {
- CommonData.FluidContainment = _totalSRDDevice.FluidContainment;
- CommonData.WaterPressure = _totalSRDDevice.WaterPressure;
- }
- return true;
- }
- /// <summary>
- /// 获取当前操作对应的Routine
- /// </summary>
- /// <param name="currentOperation"></param>
- /// <returns></returns>
- private IRoutine GetCurrentRoutine(SrdCommonOperation currentOperation)
- {
- switch (currentOperation)
- {
- case SrdCommonOperation.DoorClose:
- case SrdCommonOperation.DoorOpen:
- return _doorCloseRoutine;
- case SrdCommonOperation.ChuckVacuumOn:
- case SrdCommonOperation.ChuckVacuumOff:
- return _chuckVacuumRoutine;
- case SrdCommonOperation.LiftUpOn:
- case SrdCommonOperation.LiftUpOff:
- return _liftUpRoutine;
- case SrdCommonOperation.FlippersIn:
- case SrdCommonOperation.FlippersOut:
- return _flipperRoutine;
- case SrdCommonOperation.ChuckATMClick:
- return _chuckATMRoutine;
- default:
- return null;
- }
- }
- /// <summary>
- /// 检验Routine状态
- /// </summary>
- /// <param name="routine"></param>
- /// <param name="currentOperation"></param>
- private void CheckRoutineState(IRoutine routine, SrdCommonOperation currentOperation)
- {
- RState state = routine.Monitor();
- if (state == RState.End)
- {
- EndOperation();
- }
- else if (state == RState.Failed || state == RState.Timeout)
- {
- LOG.WriteLog(eEvent.ERR_SRD, $"{Module}", $"{currentOperation} error");
- EndOperation();
- }
- }
- /// <summary>
- /// 结束操作
- /// </summary>
- private void EndOperation()
- {
- _status = RState.End;
- _currentOperation = SrdCommonOperation.None;
- }
- #region 设备接口
- /// <summary>
- /// 监控
- /// </summary>
- public void Monitor()
- {
- }
- public void Reset()
- {
- }
- public void Terminate()
- {
- }
- #endregion
- }
- }
|