private void RefreshProductOuthouse() { switch(_workStatus) { case MachineWorkStatus.MACHINE_IDLE: { _TimeElapse = 0; //计时清零 _workStatus = MachineWorkStatus.PRODUCT_OUT_PREPARE; break; } case MachineWorkStatus.PRODUCT_OUT_PREPARE: { _TimeElapse += (int)(MotionTimerInterval * SimClockRate); int CellMoveMax = _TimeElapse / _CellMoveTime; //最多能移动格数 if (Math.Abs(_TargetCoord.L - _CurrentCoord.L) < CellMoveMax) { _CurrentCoord.L = _TargetCoord.L; int CellMoveColumnMax = CellMoveMax - Math.Abs(_TargetCoord.L - _CurrentCoord.L); if (Math.Abs(_TargetCoord.C - _CurrentCoord.C) < CellMoveColumnMax) { _CurrentCoord.C = _TargetCoord.C; _workStatus = MachineWorkStatus.PRODUCT_OUT_LOADED; _TimeElapse = 0; //计时清零 } else { _TimeElapse -= (int)(CellMoveMax * MotionTimerInterval * SimClockRate); if (_TargetCoord.C > _CurrentCoord.C) { _CurrentCoord.C += CellMoveColumnMax; } else { _CurrentCoord.C -= CellMoveColumnMax; } } } else { _TimeElapse -= (int)(CellMoveMax * MotionTimerInterval * SimClockRate); if (_TargetCoord.L > _CurrentCoord.L) { _CurrentCoord.L += CellMoveMax; } else { _CurrentCoord.L -= CellMoveMax; } } break; } case MachineWorkStatus.PRODUCT_OUT_LOADED: { _TimeElapse += (int)(MotionTimerInterval * SimClockRate); if (_TimeElapse >= _LoadTime) { _workStatus = MachineWorkStatus.PRODUCT_OUTCOMING; _TimeElapse = 0; //计时器清零 } break; } case MachineWorkStatus.PRODUCT_OUTCOMING: { CellPos targetPos = new CellPos(); targetPos.L = 1; targetPos.C = 50; _TimeElapse += (int)(MotionTimerInterval * SimClockRate); int CellMoveMax = _TimeElapse / _CellMoveTime; //最多能移动格数 //先移动到目标层,再移动到目标列 if (Math.Abs(targetPos.L - _CurrentCoord.L) < CellMoveMax) { _CurrentCoord.L = targetPos.L; int CellMoveColumnMax = CellMoveMax - Math.Abs(targetPos.L - _CurrentCoord.L); if (Math.Abs(targetPos.C - _CurrentCoord.C) < CellMoveColumnMax) { _CurrentCoord.C = targetPos.C; _workStatus = MachineWorkStatus.PRODUCT_OUT_UNLOADED; _TimeElapse = 0; //计时清零 } else { _TimeElapse -= (int)(CellMoveMax * MotionTimerInterval * SimClockRate); if (targetPos.C > _CurrentCoord.C) { _CurrentCoord.C += CellMoveColumnMax; } else { _CurrentCoord.C -= CellMoveColumnMax; } } } else { _TimeElapse -= (int)(CellMoveMax * MotionTimerInterval * SimClockRate); if (targetPos.L > _CurrentCoord.L) { _CurrentCoord.L += CellMoveMax; } else { _CurrentCoord.L -= CellMoveMax; } } break; } case MachineWorkStatus.PRODUCT_OUT_UNLOADED: { _TimeElapse += (int)(MotionTimerInterval * SimClockRate); if(_TimeElapse>= _UnloadTime) { _workStatus = MachineWorkStatus.PRODUCT_OUTHOUSE_OK; _TimeElapse = 0; } break; } case MachineWorkStatus.PRODUCT_OUTHOUSE_OK: { _workStatus = MachineWorkStatus.MACHINE_IDLE; _CurrentCmd = 0; _TimeElapse = 0; break; } } }
public void RefreshTaskDisp(int MachineIndex, CellPos targetPos, string taskDes) { this.Invoke(new delegateRefreshUI(ThreadUIRefreshTaskDisp), MachineIndex,taskDes); this.Invoke(new delegateRefreshUI(ThreadUIRefreshTargetCell), MachineIndex,targetPos.L.ToString() + "," + targetPos.R.ToString() + "," + targetPos.C.ToString()); }