public static bool SystemExit(bool shutDown, bool isOk = true) { try { Globals.AppCfg.Shutdown = isOk; Globals.AppCfg.SaveDefaultSysConfigFile();//保存当前应用配置 if (X_Axis != null && X_Axis.Enabled) { X_Axis.AxisAotoEscapeLimit(); } if (Y_Axis != null && Y_Axis.Enabled) { Y_Axis.AxisAotoEscapeLimit(); } if (T_Axis != null && T_Axis.Enabled) { T_Axis.AxisAotoEscapeLimit(); } if (Z_Axis != null && Z_Axis.Enabled) { Z_Axis.AxisAotoEscapeLimit(); Z_Axis.AxisGoHomeWork(true); //Z轴回位操作 ReportCmdKeyProgress(CmdKey.S0407); //Z轴回零成功 } if (SPD != null && SPD.IsInit) { SPD.StopSpd(); ReportCmdKeyProgress(CmdKey.S0607); } HwProvider.UnInitHardwareDriver(); //关闭所有硬件 ReportCmdKeyProgress(CmdKey.S0023); //判定是否需要延迟断电 backWorker.CancelAsync(); LogHelper.CloseLogerConnect(); } catch { } if (shutDown) { ProcessCmd.SetSystemShutdown(); } else { //ProcessCmd.ShowWindowDesk();//显示Window桌面 //ProcessCmd.ShowLogicalDriver();//显示硬盘 //ProcessCmd.UsedTaskMgrForm();//使用任务管理器 //ProcessCmd.SetSystytemLoadShell(true);//设置系统默认加载路径并注销系统 } Application.Exit(); return(true); }
public static bool SystemInit() { try { if (SystemInitCheckStatus()) { bool flag = true; ReportCmdKeyProgress(CmdKey.S0100); //开始系统初始化 if (!InitAxisSystemParam()) //重新进行系统初始化 { flag = false; ReportCmdKeyProgress(CmdKey.S0013); } else { ReportCmdKeyProgress(CmdKey.S0012); } Globals.LedCmd.Cmd = Globals.DevData.InitLedCmd.Cmd; X_Axis.AxisAotoEscapeLimit(); Y_Axis.AxisAotoEscapeLimit(); Z_Axis.AxisAotoEscapeLimit(); T_Axis.AxisAotoEscapeLimit(); if (Z_Axis.AxisGoHomeWork(true)) { ReportCmdKeyProgress(CmdKey.S0407); } else { ReportCmdKeyProgress(CmdKey.S0408); flag &= false; } flag &= X_Axis.AxisGoHomeWork(); flag &= Y_Axis.AxisGoHomeWork(); flag &= T_Axis.AxisGoHomeWork(); if (!WaitAxisMoveDone(500))//延迟20S判断 { ReportCmdKeyProgress(CmdKey.S0096); return(false); } ReportCmdKeyProgress(CmdKey.S0108); flag &= X_Axis.SetPrePosition(X_Axis.Param.StartPos); flag &= Y_Axis.SetPrePosition(Y_Axis.Param.StartPos); flag &= T_Axis.SetPrePosition(T_Axis.Param.StartPos); ReportCmdKeyProgress(CmdKey.S0109); flag &= X_Axis.SetLimitSwitch(true); flag &= Y_Axis.SetLimitSwitch(true); flag &= T_Axis.SetLimitSwitch(true); flag &= X_Axis.SetSoftPLimit(X_Axis.Param.SoftPlimit); flag &= X_Axis.SetSoftNLimit(X_Axis.Param.SoftNlimit); flag &= Y_Axis.SetSoftPLimit(Y_Axis.Param.SoftPlimit); flag &= Y_Axis.SetSoftNLimit(Y_Axis.Param.SoftNlimit); flag &= T_Axis.SetSoftPLimit(T_Axis.Param.SoftPlimit); flag &= T_Axis.SetSoftNLimit(T_Axis.Param.SoftNlimit); if (flag) { Globals.LedCmd.Cmd = Globals.DevData.IdleLedCmd.Cmd; ReportCmdKeyProgress(CmdKey.S0101); } else { ReportCmdKeyProgress(CmdKey.S0102); } return(flag); } else { return(false); } } catch { ReportCmdKeyProgress(CmdKey.S0098); return(false); } }
private static void RunSynProgram() { try { do { switch (Globals.AppFunState) { case SysFunState.Load: { Globals.Load = SystemLoad(); if (Globals.Load) { if (Globals.AutoInit) { Globals.AppFunState = SysFunState.SysInit; //判断是否直接进行系统初始化操作 } else { Globals.AppFunState = SysFunState.IDIE; //空闲操作 } } else { Globals.AppFunState = SysFunState.IDIE; //空闲操作 } } break; case SysFunState.SysInit: //系统初始化 { Globals.IsInit = SystemInit(); Globals.AppFunState = SysFunState.IDIE; //空闲操作 } break; case SysFunState.TouchTesting: //测高 { if (Globals.IsInit) { ReportWorkingProgress(ProcessCmd.CsTestingStartCmd); if (TouchTestingHeight()) { ReportWorkingProgress(ProcessCmd.CsTestingEndCmd); } else { ReportWorkingProgress(ProcessCmd.CsTestingErrCmd); } Globals.Testing = false; Z_Axis.AxisGoHomeWork(true); //恢复系统默认回零模式 X_Axis.AxisJogAbsWork(X_Axis.Param.StartPos); Y_Axis.AxisJogAbsWork(Y_Axis.Param.StartPos); WaitAxisMoveDone(); } else { ReportCmdKeyProgress(CmdKey.H0000); } Globals.AppFunState = SysFunState.IDIE; //空闲操作 Globals.LedCmd.Cmd = Globals.DevData.IdleLedCmd.Cmd; } break; case SysFunState.NoTouchTesting: //测高 { if (Globals.Paused) //如果当前在暂停中进行非接触式测高 { Globals.AppFunState = SysFunState.Cutting; Globals.Paused = false; } else { Globals.AppFunState = SysFunState.IDIE; //空闲操作 } } break; case SysFunState.Cutting: { if (Globals.Load && Globals.IsInit) { Globals.CutStop = false; if (Globals.Cutting) { ReportCmdKeyProgress(CmdKey.P0101); ReportWorkingProgress(ProcessCmd.CutContinuesCmd); } else { ReportCmdKeyProgress(CmdKey.P0100); ReportWorkingProgress(ProcessCmd.CutStartCmd); } Globals.Cutting = true; if (RunGroupCut(Globals.Group)) { Globals.AppFunState = SysFunState.CutStop; //空闲操作 } else { if (Globals.CutStop) //停止划切 { Globals.AppFunState = SysFunState.CutStop; break; } if (Globals.Line.Pause) //暂停 { Globals.Paused = true; Globals.AppFunState = SysFunState.CutPause; Globals.LedCmd.Cmd = Globals.DevData.PauseLedCmd.Cmd; if (Globals.DevData.CutPauseCloseWater) //关闭切割水 { Common.DO[DoDefine.CUT_WATER] = false; } break; } } } else { Common.ReportCmdKeyProgress(CmdKey.S0090); Globals.AppFunState = SysFunState.CutStop; //空闲操作 } } break; case SysFunState.Emergency: //紧急停止 { //if (Globals.Cutting) //{ // ReportWorkingProgress(ProcessCmd.CutSopCmd);//划切终止 //} if (EmergencyStop()) { Globals.AppFunState = SysFunState.IDIE; //空闲操作 } else { ReportCmdKeyProgress(CmdKey.S0097); Globals.AppFunState = SysFunState.IDIE; //空闲操作 } } break; case SysFunState.CutStop: { ReportWorkingProgress(ProcessCmd.CutSopCmd); Globals.Group.AddBladeCutedPieces(); //添加已划切片数 Globals.Group.ClearAllChannelInfo(); //清除对准信息 Globals.Cutting = false; Globals.Paused = false; Globals.CutStop = false; Globals.LedCmd.Cmd = Globals.DevData.StopLedCmd.Cmd; if (Globals.DevData.CutStopCloseWater) //关闭切割水 { Common.DO[DoDefine.CUT_WATER] = false; } if (Globals.DevData.CutStopUnloadVacuum) //打开真空开关 { Common.DO[DoDefine.WORK_AIR] = false; } if (Globals.DevData.BuzzerUsed) //打开蜂鸣器 { DO[DoDefine.BUZZER] = true; } if (Globals.Group.Complate) //正常切割完成 { Globals.BldData.SaveBladeDataFile(Globals.AppCfg.BladeFileFullName); //保存当前文档 ReportCmdKeyProgress(CmdKey.P0103); } else { ReportCmdKeyProgress(CmdKey.P0104); } Globals.AppFunState = SysFunState.IDIE; //空闲操作 } break; case SysFunState.AutoFocus: { if (Globals.Load && Globals.IsInit) { AutoFocus(Capture, 40, 32); } Globals.AppFunState = SysFunState.IDIE; //空闲操作 } break; case SysFunState.HomeAutoFocus: { if (Globals.Load && Globals.IsInit) { Z_Axis.AxisGoHomeWork(true); AutoFocus(Capture, 40, 32); } Globals.AppFunState = SysFunState.IDIE; //空闲操作 } break; case SysFunState.CutPause: { //崩边检测 //继续划切 //if() 退出划切 if (Globals.CutStop) { Globals.AppFunState = SysFunState.CutStop; //空闲操作 } else { if (!Globals.Paused) //暂停取消 { Globals.AppFunState = SysFunState.Cutting; //继续划切 } } } break; default: // SyStatus.IDIE: 其他操作 { //操作 } break; } if (Globals.EMG) //如果需要紧急停止 { Globals.AppFunState = SysFunState.Emergency; //空闲操作 } else { if (Globals.Load) { SystemCheckStatus(); } } Thread.Sleep(100); } while (!backWorker.CancellationPending); } catch (Exception ex) { LogHelper.WriteDebugException(ex); if (Globals.Load) { Globals.EMG = true; Globals.AppFunState = SysFunState.Emergency; backWorker.RunWorkerAsync(); } } }