コード例 #1
0
        public void ExecuteDatalogDownloadAndDownloadDatalogDetailsFromInstrument()
        {
            // arrange
            InstrumentDatalogDownloadAction action = Helper.GetDatalogDownloadAction(DeviceType.MX6);

            InitializeForTest(action);

            instrumentController.Setup(x => x.GetDatalog(out corruptDatalogDetected))
            .Returns(new List <DatalogSession> {
                new DatalogSession()
                {
                    BaseUnitSerialNumber = string.Empty, Comments = string.Empty,
                    RecordingInterval    = 60, SerialNumber = action.Instrument.SerialNumber, SessionNumber = 1, TWATimeBase = 10
                    , User           = string.Empty, Session = DateTime.Now
                    , SensorSessions = new List <DatalogSensorSession>()
                    {
                        new DatalogSensorSession("SENSORTST123", new ComponentType(SensorCode.O2))
                    }
                }
            });

            InstrumentDatalogDownloadOperation datalogDownloadOperation = new InstrumentDatalogDownloadOperation(action);
            InstrumentDatalogDownloadEvent     datalogDownloadEvent     = (InstrumentDatalogDownloadEvent)datalogDownloadOperation.Execute();

            Assert.True(datalogDownloadEvent.InstrumentSessions.Count == 1);
        }
コード例 #2
0
        public void ExecuteDatalogDownload()
        {
            // arrange
            InstrumentDatalogDownloadAction action = Helper.GetDatalogDownloadAction(DeviceType.MX4);

            InitializeForTest(action);

            InstrumentDatalogDownloadOperation datalogDownloadOperation = new InstrumentDatalogDownloadOperation(action);
            InstrumentDatalogDownloadEvent     datalogDownloadEvent     = (InstrumentDatalogDownloadEvent)datalogDownloadOperation.Execute();

            Assert.True(datalogDownloadEvent.InstrumentSessions.Count == 0);
        }
コード例 #3
0
        public void GetInstrumentDatalogClearActionAsFollowUpActionForInstrumentDatalogDownloadToClearErrors()
        {
            // arrange
            InstrumentDatalogDownloadEvent dsEvent = new InstrumentDatalogDownloadEvent();

            dsEvent.Errors.Add(new DockingStationError("Test Error!"));
            Initialize();

            CreateMasterForTest();

            // act
            nextAction = scheduler.GetNextAction(dsEvent);

            // assert
            Xunit.Assert.True(nextAction is InstrumentDatalogClearAction);
        }
コード例 #4
0
        public void GetInstrumentDatalogClearActionAsFollowUpActionForInstrumentDatalogDownloadToClearInstrumentSessions()
        {
            // arrange
            InstrumentDatalogDownloadEvent dsEvent = new InstrumentDatalogDownloadEvent();

            dsEvent.InstrumentSessions.Add(new DatalogSession());
            Initialize();

            CreateMasterForTest();

            // act
            nextAction = scheduler.GetNextAction(dsEvent);

            // assert
            Xunit.Assert.True(nextAction is InstrumentDatalogClearAction);
        }
コード例 #5
0
        public void ExecuteCorruptDatalogDownload()
        {
            // arrange
            InstrumentDatalogDownloadAction action = Helper.GetDatalogDownloadAction(DeviceType.MX6);

            InitializeForTest(action);

            DateTime sessionTime = DateTime.Now;

            instrumentController.Setup(x => x.GetDatalog(out corruptDatalogDetected))
            .Returns(new List <DatalogSession> {
                new DatalogSession()
                {
                    BaseUnitSerialNumber = string.Empty, Comments = string.Empty,
                    RecordingInterval    = 60, SerialNumber = action.Instrument.SerialNumber, SessionNumber = 1, TWATimeBase = 10
                    , User           = string.Empty, Session = sessionTime, CorruptionException = new Exception("Corrupt Datalog Exception")
                    , SensorSessions = new List <DatalogSensorSession>()
                    {
                        new DatalogSensorSession("SENSORTST123", new ComponentType(SensorCode.O2))
                    }
                }
            });

            InstrumentDatalogDownloadOperation datalogDownloadOperation = new InstrumentDatalogDownloadOperation(action);
            InstrumentDatalogDownloadEvent     datalogDownloadEvent     = (InstrumentDatalogDownloadEvent)datalogDownloadOperation.Execute();

            Assert.True(datalogDownloadEvent.InstrumentSessions.Count == 1 &&
                        datalogDownloadEvent.InstrumentSessions[0].BaseUnitSerialNumber == string.Empty &&
                        datalogDownloadEvent.InstrumentSessions[0].Comments == string.Empty &&
                        datalogDownloadEvent.InstrumentSessions[0].RecordingInterval == 60 &&
                        datalogDownloadEvent.InstrumentSessions[0].SerialNumber == action.Instrument.SerialNumber &&
                        datalogDownloadEvent.InstrumentSessions[0].SessionNumber == 1 &&
                        datalogDownloadEvent.InstrumentSessions[0].TWATimeBase == 10 &&
                        datalogDownloadEvent.InstrumentSessions[0].User == string.Empty &&
                        datalogDownloadEvent.InstrumentSessions[0].Session == sessionTime &&
                        datalogDownloadEvent.InstrumentSessions[0].CorruptionException.Message == "Corrupt Datalog Exception");
        }
コード例 #6
0
 private void Init()
 {
     _returnEvent = new InstrumentDatalogDownloadEvent( this );
 }
コード例 #7
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);
        }