|
|
@@ -34,6 +34,7 @@ namespace PunkHPX8_RT.Modules.PlatingCell
|
|
|
|
|
|
#region 内部变量
|
|
|
private PlatingCellVerticalInitializeRoutine _initializeRoutine;
|
|
|
+ private PlatingCellVerticalPositionRoutine _positionRoutine;
|
|
|
#endregion
|
|
|
|
|
|
#region 属性
|
|
|
@@ -110,21 +111,29 @@ namespace PunkHPX8_RT.Modules.PlatingCell
|
|
|
private void InitializeRoutine()
|
|
|
{
|
|
|
_initializeRoutine = new PlatingCellVerticalInitializeRoutine(Module.ToString());
|
|
|
+ _positionRoutine=new PlatingCellVerticalPositionRoutine(Module.ToString());
|
|
|
}
|
|
|
|
|
|
/// 初始化状态机
|
|
|
/// </summary>
|
|
|
private void InitialFsm()
|
|
|
{
|
|
|
- fsm = new StateMachine<PlatingCellVerticalEntity>(Module.ToString(), (int)PlatingCellVerticalState.Init, 100);
|
|
|
+ fsm = new StateMachine<PlatingCellVerticalEntity>(Module.ToString(), (int)PlatingCellVerticalState.Idle, 100);
|
|
|
fsm.EnableRepeatedMsg(true);
|
|
|
|
|
|
AnyStateTransition(VerticalMsg.Initialize, InitializeAll, PlatingCellVerticalState.Initializing);
|
|
|
Transition(PlatingCellVerticalState.Initializing, FSM_MSG.TIMER, InitializeAllMonitor, PlatingCellVerticalState.Idle);
|
|
|
+ Transition(PlatingCellVerticalState.Initializing, VerticalMsg.Abort, HomeAbort, PlatingCellVerticalState.Init);
|
|
|
AnyStateTransition(VerticalMsg.Error, NullFunc, PlatingCellVerticalState.Error);
|
|
|
//Enter Init
|
|
|
Transition(PlatingCellVerticalState.Idle, VerticalMsg.Init, NullFunc, PlatingCellVerticalState.Init);
|
|
|
|
|
|
+ //Position
|
|
|
+ Transition(PlatingCellVerticalState.Idle,VerticalMsg.Position,Position,PlatingCellVerticalState.Positioning);
|
|
|
+ Transition(PlatingCellVerticalState.Positioning, VerticalMsg.Position, NullFunc, PlatingCellVerticalState.Positioning);
|
|
|
+ Transition(PlatingCellVerticalState.Positioning, FSM_MSG.TIMER, PositionMonitor, PlatingCellVerticalState.Idle);
|
|
|
+ Transition(PlatingCellVerticalState.Positioning, VerticalMsg.Abort, PositionAbort, PlatingCellVerticalState.Idle);
|
|
|
+
|
|
|
EnumLoop<PlatingCellVerticalState>.ForEach((item) => { fsm.MapState((int)item, item.ToString()); });
|
|
|
|
|
|
EnumLoop<VerticalMsg>.ForEach((item) => { fsm.MapMessage((int)item, item.ToString()); });
|
|
|
@@ -158,7 +167,56 @@ namespace PunkHPX8_RT.Modules.PlatingCell
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
+ /// <summary>
|
|
|
+ /// 中止Home
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="param"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ private bool HomeAbort(object[] param)
|
|
|
+ {
|
|
|
+ _initializeRoutine.Abort();
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ #endregion
|
|
|
|
|
|
+ #region Position
|
|
|
+ /// <summary>
|
|
|
+ /// Position
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ private bool Position(object[] param)
|
|
|
+ {
|
|
|
+ return _positionRoutine.Start(param) == RState.Running;
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ /// Position 监控
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="param"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ private bool PositionMonitor(object[] param)
|
|
|
+ {
|
|
|
+ RState rsstate = _positionRoutine.Monitor();
|
|
|
+ if (rsstate == RState.End)
|
|
|
+ {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ else if (rsstate == RState.Failed || rsstate == RState.Timeout)
|
|
|
+ {
|
|
|
+ PostMsg(VerticalMsg.Error);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ /// 中止
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="param"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ private bool PositionAbort(object[] param)
|
|
|
+ {
|
|
|
+ _positionRoutine.Abort();
|
|
|
+ return true; ;
|
|
|
+ }
|
|
|
#endregion
|
|
|
|
|
|
|