示例#1
0
        private void DoCheckInitCompleted()
        {
            try
            {
                _workcell.DisplayTitleMessage("Initializing system...");
                Log.Info(this, "{0}, system initialization started", LoggerCategory.SystemInitializationStarted);

                while (true)
                {
                    if (_disposed)
                    {
                        return;
                    }
                    try
                    {
                        bool exit = true;
                        // If all processes are initialized, then exit and stop machine. (Except Non-idle process such MonitorProcess).
                        foreach (ActiveProcess p in this.ActiveProcess.Values)
                        {
                            ActiveProcessHST clp = (ActiveProcessHST)p;
                            if (clp.IsStateInitialized == false && !clp.IsNonIdleProcess)
                            {
                                exit = false;
                            }
                        }
                        if (_isInit & exit)
                        {
                            break;
                        }
                    }
                    catch (Exception ex)
                    {
                        // Do nothing
                    }
                }
                Stop();
                Log.Info(this, "{0}, System initialization ended", LoggerCategory.SystemInitializationEnded);

                _lastActiveRunMode       = OperationMode.Auto; // Reset last active mode to Auto
                _isInit                  = false;
                _workcell.IsMachineHomed = true;
                _workcell.DisplayTitleMessage("System Initialized");
                if (OnInit != null)
                {
                    OnInit(this, null);
                }

                // Auto run
                if (_autoRunAfterInit)
                {
                    Start();
                }
            }
            catch (Exception ex)
            {
                Notify.PopUpError("Exception in DoCheckInitCompleted", ex);
            }
        }
示例#2
0
        protected override QState StateError(IQEvent qEvent)
        {
            LogStateInfo(_processName, System.Reflection.MethodBase.GetCurrentMethod().Name, qEvent);

            if (qEvent.IsSignal(QSignals.Entry))
            {
                _isErrorstate = true;
                string str = this.ToString();
                str = str.Substring(str.LastIndexOf(".") + 1);
                str = str.Remove(str.LastIndexOf("-"));
                str = str + ": " + this.currentException.Source;
                _workcell.DisplayTitleMessage("Error Occurred (" + str + ")");
            }
            if (qEvent.IsSignal(QSignals.Exit))
            {
                _isErrorstate = false;
                string str = this.ToString();
                str = str.Substring(str.LastIndexOf(".") + 1);
                str = str.Remove(str.LastIndexOf("-"));
                str = str + ": " + this.currentException.Source;
                _workcell.DisplayTitleMessage("Error Cleared (" + str + ")");

                // Log alarm cleared.
                string errMsg = this.GetErrorLogFormatString();
                Log.Error(this, "{0} Message:{1}", LoggerCategory.AlarmCleared, errMsg);
            }
            if (qEvent.IsSignal(base.SigStateJob))
            {
                // Format to CLU error format.
                this.errorMessageHST.Format();

                this.DefaultErrorHandler();

                // Change state UDT.
                _workcell.ARAMSState.ChangeState(ARAMSStateHST.ARAMSSubstateCodes.UDT_UnscheduledDownTime);

                // Log alarm occured
                string errMsg = this.GetErrorLogFormatString();
                Log.Error(this, "{0} Message:{1}", LoggerCategory.AlarmOccured, errMsg);

                string [] maintenance_msg = this.GetMaintenanceLogFormatString();
                Log.Maintenance(this, "{0}, {1}", maintenance_msg[0], maintenance_msg[1]);
                return(null);
            }
            if (!qEvent.IsSignal(Active.SigResume))
            {
                return(this.statePaused);
            }
            System.Threading.Thread.Sleep(500);
            _workcell.OffAlarm = false;
            switch (base.errorMessage.ButtonSelected)
            {
            case ErrorButton.Abort:
                this._workcell.MainProcess.Abort();
                break;

            case ErrorButton.Retry:
            {
                base.targetState = base.stateHistory;
                base.TransitionToWithoutJob(base.targetState);
                QEvent event2 = new QEvent(base.SigStateJob);
                event2.EventObject = base.errorMessage.ButtonSelected;
                this.errorMessage  = null;
                base.PostFIFO(event2);
                break;
            }

            case ErrorButton.Stop:
                this._workcell.MainProcess.Stop();

                for (int i = 0; i < ServiceManager.ErrorHandler.ErrorList.Count; i++)
                {
                    IErrorMessage currentMessage = ServiceManager.ErrorHandler.ErrorList[i] as IErrorMessage;
                    ServiceManager.ErrorHandler.UnRegisterMessage(currentMessage);
                }
                break;

            case ErrorButton.NoButton:
                //TY: Treat NoButton as Retry
                Console.Beep();
                base.targetState = base.stateHistory;
                base.TransitionToWithoutJob(base.targetState);
                QEvent event4 = new QEvent(base.SigStateJob);
                event4.EventObject = base.errorMessage.ButtonSelected;
                this.errorMessage  = null;
                base.PostFIFO(event4);
                break;

            default:
            {
                base.targetState = base.stateHistory;
                base.TransitionToWithoutJob(base.targetState);
                QEvent event3 = new QEvent(base.SigRecover);
                event3.EventObject = base.errorMessage.ButtonSelected;
                base.PostFIFO(event3);
                break;
            }
            }
            return(null);
        }