Example #1
0
        private void ReadSettings(bool readAllCards)
        {
            Log.Debug(this.Name + " initiating a SettingsRead");

            SettingsReadAction settingsReadAction = new SettingsReadAction();

            // If readAllCards is true, then explicitly set ChangedSmartCards to null
            // in order to force a read of ALL smart cards, not just 'changed' ones.
            settingsReadAction.ChangedSmartCards = readAllCards ? null : _changedSmartCards;

            Master.ExecuterService.ExecuteNow(settingsReadAction, true);

            InitialReadSettingsNeeded = false;

            Master.ExecuterService.HeartBeat();
        }
 public SettingsReadOperation(SettingsReadAction settingsReadAction) : base(settingsReadAction)
 {
     Init();
 }
Example #3
0
        /// <summary>
        /// Determines if some specific action needs to be performed based
        /// on the event passed to it. (Some events require a specific
        /// followup action to be executed.)
        /// </summary>
        /// <param name="dsEvent"></param>
        /// <returns></returns>
        internal DockingStationAction GetFollowupAction(DockingStationEvent dsEvent)
        {
            // A SettingsUpdate is ALWAYS followed by a SettingsRead.
            if (dsEvent is SettingsUpdateEvent)
            {
                // If the SettingsUpdate was Scheduled, we want to inject a CylinderPressureReset before the SettingsRead.
                if (dsEvent.Trigger == TriggerType.Scheduled)
                {
                    Log.Trace("EventProcessor returning CylinderPressureReset as followup to SettingsUpdate");
                    CylinderPressureResetAction cylPressureResetAction = new CylinderPressureResetAction();

                    // These values will be propogated to a followup SettingsRead.
                    cylPressureResetAction.PostUpdate    = true;
                    cylPressureResetAction.SettingsRefId = ((SettingsUpdateEvent)dsEvent).DockingStation.RefId;

                    return(cylPressureResetAction);
                }

                Log.Trace("EventProcessor returning SettingsRead as followup to SettingsUpdate");
                SettingsReadAction settingsReadAction = new SettingsReadAction();
                // Set the refId to indicate that this Read is occurring due to an Update that was just performed.
                settingsReadAction.PostUpdate    = true;
                settingsReadAction.SettingsRefId = ((SettingsUpdateEvent)dsEvent).DockingStation.RefId;

                // Explicitly set the ChangedSmartCards to all falses so that no smart cards are read.
                settingsReadAction.ChangedSmartCards = new bool[Configuration.DockingStation.NumGasPorts];

                return(settingsReadAction);
            }

            if (dsEvent is CylinderPressureResetEvent)
            {
                Log.Trace("EventProcessor returning SettingsRead as followup to CylinderPressureReset");
                SettingsReadAction settingsReadAction = new SettingsReadAction();

                // Copy the PostUpdate and SettingsRefId so it can be determined if the SettingsRead is
                // being run due to a SettingsUpdate that would have occurred before the CylinderPressureReset.
                settingsReadAction.PostUpdate    = ((CylinderPressureResetEvent)dsEvent).PostUpdate;
                settingsReadAction.SettingsRefId = ((CylinderPressureResetEvent)dsEvent).SettingsRefId;

                // Explicitly set the ChangedSmartCards to null so all positions are read similar to startup.
                settingsReadAction.ChangedSmartCards = null;

                return(settingsReadAction);
            }

            // After downloading datalog, we clear it.
            if (dsEvent is InstrumentDatalogDownloadEvent)
            {
                InstrumentDatalogDownloadEvent datalogEvent = (InstrumentDatalogDownloadEvent)dsEvent;

                // D2G: Only clear the log if there is something to clear, or corruption was detected.
                if (datalogEvent.InstrumentSessions.Count > 0 || datalogEvent.Errors.Count > 0)
                {
                    Log.Trace("EventProcessor returning InstrumentHygieneClearAction as followup to InstrumentHygieneDownloadEvent");
                    return(new InstrumentDatalogClearAction());
                }
                else
                {
                    Log.Debug("NO DATALOG TO CLEAR");
                    return(null);
                }
            }

            // After downloading alarm events, we clear them.
            if (dsEvent is InstrumentAlarmEventsDownloadEvent)
            {
                InstrumentAlarmEventsDownloadEvent alarmsEvent = (InstrumentAlarmEventsDownloadEvent)dsEvent;

                // D2G: Only clear the log if there is something to clear, or corruption was detected.
                if (alarmsEvent.AlarmEvents.Length > 0 || alarmsEvent.Errors.Count > 0)
                {
                    Log.Trace("EventProcessor returning InstrumentAlarmEventsClearAction as followup to InstrumentAlarmEventsDownloadEvent");
                    return(new InstrumentAlarmEventsClearAction());
                }
                else
                {
                    Log.Debug("NO ALARM EVENTS TO CLEAR");
                    return(null);
                }
            }

            // After downloading alarm events, we clear them.
            if (dsEvent is InstrumentManualOperationsDownloadEvent)
            {
                InstrumentManualOperationsDownloadEvent manualOpsEvent = (InstrumentManualOperationsDownloadEvent)dsEvent;

                // D2G: Only clear the log if there is something to clear, or corruption was detected.
                if (manualOpsEvent.GasResponses.Count > 0 || manualOpsEvent.Errors.Count > 0)
                {
                    Log.Trace("EventProcessor returning InstrumentManualOperationsDownloadAction as followup to InstrumentManualOperationsDownloadEvent");
                    return(new InstrumentManualOperationsClearAction());
                }
                else
                {
                    Log.Debug("NO MANUAL GAS OPERATIONS TO CLEAR");
                    return(null);
                }
            }

            if (dsEvent is InstrumentFirmwareUpgradeEvent)
            {
                if (((InstrumentFirmwareUpgradeEvent)dsEvent).UpgradeFailure)
                {
                    Log.Trace("EventProcessor returning NothingAction as followup to InstrumentFirmwareUpgradeEvent due to an upgrade failure");

                    // Setting this to true will cause the docking station to go
                    // into its UpgradingInstrumentError state.
                    Master.Instance.SwitchService.InstrumentUpgradeError = true;

                    // Return an action just to prevent further processing (there's no use
                    // next letting the scheduler figure out what needs to be done next since
                    // we know we're about to into the UpgradingInstrumentError state.)
                    return(new NothingAction());
                }
            }

            //Suresh 06-FEB-2012 INS-2622
            //Check whether instrument is in critical error.
            if (dsEvent is InstrumentDiagnosticEvent)
            {
                InstrumentDiagnosticEvent diagnosticEvent = (InstrumentDiagnosticEvent)dsEvent;

                if (diagnosticEvent.InstrumentInCriticalError == true)
                {
                    Log.Trace("EventProcessor returning NothingAction as followup to InstrumentDiagnosticEvent due to instrument having a critical error");
                    Master.Instance.SwitchService.Instrument.InstrumentInCriticalError = true;
                    // INS-8446 RHP v7.6 - Set the SwitchService's InstrumentCriticalErrorCode to display the critical error code on LCD
                    Log.Trace("EventProcessor identfied InstrumentDiagnosticEvent having a critical error code of " + diagnosticEvent.InstrumentCriticalErrorCode);
                    Master.Instance.SwitchService.Instrument.InstrumentCriticalErrorCode = diagnosticEvent.InstrumentCriticalErrorCode;
                    return(new NothingAction());
                }
            }
            return(null);
        }