|
@@ -0,0 +1,192 @@
|
|
|
+using Aitex.Core.RT.Fsm;
|
|
|
+using Aitex.Core.Utilities;
|
|
|
+using MECF.Framework.Common.Equipment;
|
|
|
+using MECF.Framework.RT.ModuleLibrary.VceModules;
|
|
|
+using System;
|
|
|
+using System.Collections.Generic;
|
|
|
+using System.Linq;
|
|
|
+using System.Text;
|
|
|
+using System.Threading.Tasks;
|
|
|
+using Venus_RT.Devices.VCE;
|
|
|
+
|
|
|
+namespace Venus_RT.Modules.VCE
|
|
|
+{
|
|
|
+ #region 状态和消息
|
|
|
+ public enum VceSTATE
|
|
|
+ {
|
|
|
+ Init,
|
|
|
+ Idle,
|
|
|
+ Error,
|
|
|
+ Homing,
|
|
|
+ DoorOpenning,
|
|
|
+ DoorClosing,
|
|
|
+ Loading,
|
|
|
+ UnLoading,
|
|
|
+ Mapping,
|
|
|
+ Goting,
|
|
|
+ Resetting,
|
|
|
+ Unknown
|
|
|
+ }
|
|
|
+
|
|
|
+ public enum VceMSG
|
|
|
+ {
|
|
|
+ Home,
|
|
|
+ Error,
|
|
|
+ DoorOpen,
|
|
|
+ DoorClose,
|
|
|
+ Map,
|
|
|
+ Load,
|
|
|
+ UnLoad,
|
|
|
+ Reset,
|
|
|
+ Goto,
|
|
|
+ Abort
|
|
|
+ }
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ public class VceEntity : Entity, IEntity
|
|
|
+ {
|
|
|
+ private ModuleName _modulename;
|
|
|
+ private readonly VceModuleBase _vce;
|
|
|
+
|
|
|
+ public VceEntity(ModuleName moduleName)
|
|
|
+ {
|
|
|
+ _modulename = moduleName;
|
|
|
+ _vce = new HongHuVce(25, moduleName);
|
|
|
+ InitFsmMap();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ private void InitFsmMap()
|
|
|
+ {
|
|
|
+ fsm = new StateMachine<VceEntity>(_modulename.ToString(), (int)VceSTATE.Unknown, 50);
|
|
|
+ fsm.EnableRepeatedMsg(true);
|
|
|
+
|
|
|
+ AnyStateTransition(VceMSG.Error, fnError, VceSTATE.Error);
|
|
|
+ AnyStateTransition(VceMSG.Abort, fnAbort, VceSTATE.Idle);
|
|
|
+
|
|
|
+ Transition(VceSTATE.Init, VceMSG.Home, fnStartHome, VceSTATE.Homing);
|
|
|
+ Transition(VceSTATE.Idle, VceMSG.Home, fnStartHome, VceSTATE.Homing);
|
|
|
+ Transition(VceSTATE.Error, VceMSG.Home, fnStartHome, VceSTATE.Homing);
|
|
|
+ Transition(VceSTATE.Homing, FSM_MSG.TIMER, fnHomeTimeout, VceSTATE.Idle);
|
|
|
+
|
|
|
+
|
|
|
+ Transition(VceSTATE.Idle, VceMSG.DoorOpen, fnStartOpenDoor, VceSTATE.DoorOpenning);
|
|
|
+ Transition(VceSTATE.DoorOpenning, FSM_MSG.TIMER, fnOpenDoorTimeout, VceSTATE.Idle);
|
|
|
+
|
|
|
+ Transition(VceSTATE.Idle, VceMSG.DoorClose, fnStartCloseDoor, VceSTATE.DoorClosing);
|
|
|
+ Transition(VceSTATE.DoorClosing, FSM_MSG.TIMER, fnCloseDoorTimeout, VceSTATE.Idle);
|
|
|
+
|
|
|
+
|
|
|
+ Transition(VceSTATE.Idle, VceMSG.Map, fnStartMapping, VceSTATE.Mapping);
|
|
|
+ Transition(VceSTATE.Mapping, FSM_MSG.TIMER, fnMappingTimeout, VceSTATE.Idle);
|
|
|
+
|
|
|
+
|
|
|
+ Transition(VceSTATE.Idle, VceMSG.Load, fnStartLoading, VceSTATE.Loading);
|
|
|
+ Transition(VceSTATE.Loading, FSM_MSG.TIMER, fnLoadingTimeout, VceSTATE.Idle);
|
|
|
+
|
|
|
+
|
|
|
+ Transition(VceSTATE.Idle, VceMSG.UnLoad, fnStartUnLoading, VceSTATE.UnLoading);
|
|
|
+ Transition(VceSTATE.UnLoading, FSM_MSG.TIMER, fnUnLoadingTimeout, VceSTATE.Idle);
|
|
|
+
|
|
|
+
|
|
|
+ Transition(VceSTATE.Idle, VceMSG.Goto, fnStartGoto, VceSTATE.Goting);
|
|
|
+ Transition(VceSTATE.Goting, FSM_MSG.TIMER, fnGotingTimeout, VceSTATE.Idle);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ EnumLoop<VceSTATE>.ForEach((item) => { fsm.MapState((int)item, item.ToString()); });
|
|
|
+
|
|
|
+ EnumLoop<VceMSG>.ForEach((item) => { fsm.MapMessage((int)item, item.ToString()); });
|
|
|
+
|
|
|
+ Running = true;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private bool fnAbort(object[] param)
|
|
|
+ {
|
|
|
+ throw new NotImplementedException();
|
|
|
+ }
|
|
|
+
|
|
|
+ private bool fnStartGoto(object[] param)
|
|
|
+ {
|
|
|
+ return _vce.Goto(Convert.ToInt32(param[0]));
|
|
|
+ }
|
|
|
+
|
|
|
+ private bool fnGotingTimeout(object[] param)
|
|
|
+ {
|
|
|
+ throw new NotImplementedException();
|
|
|
+ }
|
|
|
+
|
|
|
+ private bool fnError(object[] param)
|
|
|
+ {
|
|
|
+ throw new NotImplementedException();
|
|
|
+ }
|
|
|
+
|
|
|
+ private bool fnStartHome(object[] param)
|
|
|
+ {
|
|
|
+ return _vce.HomeALL();
|
|
|
+ }
|
|
|
+
|
|
|
+ private bool fnHomeTimeout(object[] param)
|
|
|
+ {
|
|
|
+ throw new NotImplementedException();
|
|
|
+ }
|
|
|
+
|
|
|
+ private bool fnStartOpenDoor(object[] param)
|
|
|
+ {
|
|
|
+ return _vce.OpenDoor();
|
|
|
+ }
|
|
|
+
|
|
|
+ private bool fnOpenDoorTimeout(object[] param)
|
|
|
+ {
|
|
|
+ throw new NotImplementedException();
|
|
|
+ }
|
|
|
+
|
|
|
+ private bool fnStartCloseDoor(object[] param)
|
|
|
+ {
|
|
|
+ return _vce.CloseDoor();
|
|
|
+ }
|
|
|
+
|
|
|
+ private bool fnCloseDoorTimeout(object[] param)
|
|
|
+ {
|
|
|
+ throw new NotImplementedException();
|
|
|
+ }
|
|
|
+
|
|
|
+ private bool fnStartMapping(object[] param)
|
|
|
+ {
|
|
|
+ return _vce.Map();
|
|
|
+ }
|
|
|
+
|
|
|
+ private bool fnMappingTimeout(object[] param)
|
|
|
+ {
|
|
|
+ throw new NotImplementedException();
|
|
|
+ }
|
|
|
+
|
|
|
+ private bool fnStartLoading(object[] param)
|
|
|
+ {
|
|
|
+ return _vce.Load();
|
|
|
+ }
|
|
|
+
|
|
|
+ private bool fnLoadingTimeout(object[] param)
|
|
|
+ {
|
|
|
+ throw new NotImplementedException();
|
|
|
+ }
|
|
|
+
|
|
|
+ private bool fnStartUnLoading(object[] param)
|
|
|
+ {
|
|
|
+ return _vce.UnLoad();
|
|
|
+ }
|
|
|
+
|
|
|
+ private bool fnUnLoadingTimeout(object[] param)
|
|
|
+ {
|
|
|
+ throw new NotImplementedException();
|
|
|
+ }
|
|
|
+
|
|
|
+ public bool Check(int msg, out string reason, params object[] args)
|
|
|
+ {
|
|
|
+ throw new NotImplementedException();
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|