Exemple #1
0
 public static bool RunSpd(int speed, int waitTime = -1)
 {
     if (SPD != null)
     {
         if (!Globals.DebugMode)
         {
             if (!DI[DiDefine.MAIN_AIR])
             {
                 Common.ReportCmdKeyProgress(CmdKey.S0613);
                 return(false);
             }
             if (!DI[DiDefine.MAIN_WATER])
             {
                 Common.ReportCmdKeyProgress(CmdKey.S0614);
                 return(false);
             }
             if (DO[DoDefine.SPD_LOCK])
             {
                 Common.ReportCmdKeyProgress(CmdKey.S0615);
             }
             if (Globals.DevData.DoorProtectUsed)
             {
                 DO[DoDefine.CUT_DOOR] = true; //关闭舱门锁
                 Thread.Sleep(500);
                 if (!DI[DiDefine.CUT_DOOR])   //判断舱门状态
                 {
                     return(false);
                 }
             }
             if (waitTime != -1)
             {
                 int i = 30;
                 Common.ReportCmdKeyProgress(CmdKey.S0608);
                 do
                 {
                     i--;
                     SPD.RunSpd(speed);
                     Thread.Sleep(1000);
                 } while (!SPD.SpeedStabled && i > 0);//开启转动主轴
                 if (!Globals.SpdStable)
                 {
                     if (ProgressSpdEventChanged != null)
                     {
                         ProgressSpdEventChanged(ProcessCmd.SpdWaitCmd, 0);
                     }
                     for (float t = 0; t < waitTime; t++)
                     {
                         Thread.Sleep(1000);//暂停延迟时间
                         if (ProgressSpdEventChanged != null)
                         {
                             float v = t / waitTime * 100;
                             ProgressSpdEventChanged(ProcessCmd.SpdWaitReportCmd, v);
                         }
                     }
                     if (ProgressSpdEventChanged != null)
                     {
                         ProgressSpdEventChanged(ProcessCmd.SpdWaitReadyCmd, 100);
                     }
                     Globals.SpdStable = true;
                 }
                 Common.ReportCmdKeyProgress(CmdKey.S0609);
                 return(true);
             }
             else
             {
                 return(SPD.RunSpd(speed));
             }
         }
         else
         {
             ReportCmdKeyProgress(CmdKey.S0620);
             return(true);
         }
     }
     else
     {
         return(false);
     }
 }