state1() { InitializeMotor(); state++; }
state2() {
if (innerSwitch != ON) {
SendCommand(EnumCommand_SlidingMotorBackward);
timeout = MILLISECOND(10000);
state++; // 滑板电机向内运动, 直至触及最内开关。
}
else
state += 2;
}
state3() {
if ((--timeout) == 0) { //note: some C compliers do not support (--timeout) ==
SendCommand(EnumCommand_SlidingMotorStop)
systemErrorCode = EnumErrorCode_InnerSwitch;
state = 0; // 10 s 超时错误,
}
else {
if (innerSwitch == ON) {
SendCommand(EnumCommand _SlidingMotorStop)
timeout = MILLISECOND(200); // 200ms电机停止时间
state++;
}
}
}
state4() { if ((--timeout) == 0) state++; } //等待电机完全停止
state5() {
SendCommand(EnumCommand_SlidingMotorForward);
timeout = MILLISECOND(2000);
state++;
} // 滑板电机向外运动,脱离inner switch
state6() {
if ((--timeout) == 0) {
SendCommand(EnumCommand_SlidingMotorStop)
systemErrorCode = EnumErrorCode_InnerSwitch;
state = 0; // 2 s 超时错误,
}
else {
if (innerSwitch == OFF) {
SendCommand(EnumCommand_SlidingMotorStop)
timeout = MILLISECOND(200); // 200ms电机停止时间
state++;
}
}
}
state7() { state4(); }
state8() { LaserOn(); state++; retryCounter = 3;} //打开激光器
state9() {
SendCommand(FocusUp);
state++;
timeout = MILLISECOND(2000);
} //光头上举,检测聚焦过零 3 次,判断cd 是否存在
state10() {
if (FocusCrossZero) {
systemStatus.Disc = EnumStatus_DiscExist;
SendCommand(EnumCommand_AutoFocusOn); //有cd, 打开自动聚焦。
state = 0; //本任务结束。
playProcess.state = 1; //启动 play 任务
}
else if ((--timeout) == 0) {
SendCommand(EnumCommand_ FocusClose); //光头聚焦复位
if ((--retryCounter) == 0) {
systemStatus.Disc = EnumStatus_Nodisc; //无盘
displayProcess.state = EnumDisplayState_NoDisc; //显示闪烁的无盘
LaserOff();
state = 0; //任务停止
}
else
state--; //再试
}
}
stateStop() {
SendCommand(EnumCommand_SlidingMotorStop);
SendCommand(EnumCommand_FocusClose);
state = 0;
}