public void DownloadManualOperationsWithoutData() { // arrange InstrumentManualOperationsDownloadAction action = Helper.GetManualOperationsDownloadAction(DeviceType.MX4); InitializeForTest(action); InstrumentManualOperationsDownloadOperation manualOpDownloadOperation = new InstrumentManualOperationsDownloadOperation(action); InstrumentManualOperationsDownloadEvent manualOpDownloadEvent = (InstrumentManualOperationsDownloadEvent)manualOpDownloadOperation.Execute(); Assert.True(manualOpDownloadEvent.GasResponses.Count == 0); }
public void ThrowArgumentOutOfRangeException() { // arrange InstrumentManualOperationsDownloadAction action = Helper.GetManualOperationsDownloadAction(DeviceType.MX6); InitializeForTest(action); DateTime sessionTime = DateTime.Now; instrumentController.Setup(x => x.GetManualGasOperations()) .Throws(new ArgumentOutOfRangeException()); InstrumentManualOperationsDownloadOperation manualOpDownloadOperation = new InstrumentManualOperationsDownloadOperation(action); InstrumentManualOperationsDownloadEvent manualOpDownloadEvent = (InstrumentManualOperationsDownloadEvent)manualOpDownloadOperation.Execute(); Assert.True(manualOpDownloadEvent.Errors.Count > 0); }
public void DownloadManualOperationsData() { // arrange InstrumentManualOperationsDownloadAction action = Helper.GetManualOperationsDownloadAction(DeviceType.MX6); InitializeForTest(action); DateTime cylExpirationDate = DateTime.Now.AddMonths(8); instrumentController.Setup(x => x.GetManualGasOperations()) .Returns(new SensorGasResponse[] { new SensorGasResponse() }); InstrumentManualOperationsDownloadOperation manualOpDownloadOperation = new InstrumentManualOperationsDownloadOperation(action); InstrumentManualOperationsDownloadEvent manualOpDownloadEvent = (InstrumentManualOperationsDownloadEvent)manualOpDownloadOperation.Execute(); Assert.True(manualOpDownloadEvent.GasResponses.Count == 1); }
public void GetInstrumentManualOperationsClearActionAsFollowUpActionForInstrumentManualOperationsDownloadToClearErrors() { // arrange InstrumentManualOperationsDownloadAction action = new InstrumentManualOperationsDownloadAction(); InstrumentManualOperationsDownloadOperation operation = new InstrumentManualOperationsDownloadOperation(action); InstrumentManualOperationsDownloadEvent dsEvent = new InstrumentManualOperationsDownloadEvent(operation); dsEvent.Errors.Add(new DockingStationError("Test Error!")); Initialize(); CreateMasterForTest(); // act nextAction = scheduler.GetNextAction(dsEvent); // assert Xunit.Assert.True(nextAction is InstrumentManualOperationsClearAction); }
public void GetInstrumentManualOperationsClearActionAsFollowUpActionForInstrumentManualOperationsDownloadToClearGasReponses() { // arrange InstrumentManualOperationsDownloadAction action = new InstrumentManualOperationsDownloadAction(); InstrumentManualOperationsDownloadOperation operation = new InstrumentManualOperationsDownloadOperation(action); InstrumentManualOperationsDownloadEvent dsEvent = new InstrumentManualOperationsDownloadEvent(operation); dsEvent.GasResponses.Add(new SensorGasResponse()); Initialize(); CreateMasterForTest(); // act nextAction = scheduler.GetNextAction(dsEvent); // assert Xunit.Assert.True(nextAction is InstrumentManualOperationsClearAction); }
/// <summary> /// Executes an instrument read settings operation. /// </summary> /// <returns>Docking station event</returns> public DockingStationEvent Execute() { Stopwatch stopwatch = Log.TimingBegin("MANUAL OPERATIONS DOWNLOAD"); InstrumentManualOperationsDownloadEvent downloadEvent = new InstrumentManualOperationsDownloadEvent(this); downloadEvent.DockedInstrument = (ISC.iNet.DS.DomainModel.Instrument)Master.Instance.SwitchService.Instrument.Clone(); downloadEvent.DockingStation = Master.Instance.ControllerWrapper.GetDockingStation(); using (InstrumentController instrumentController = Master.Instance.SwitchService.InstrumentController) { instrumentController.Initialize(InstrumentController.Mode.Batch); Log.Debug("MANUAL GAS OPERATIONS: Downloading"); // INS-3145 - Due to a bug in GBPro, a manual gas operation is sometimes logged // with an invalid sensor resolution (decimal places = 255). When this happens, // the instrument driver will throw an ArgumentOutOfRangeException. If we // catch one, we need to tell iNet. We don't rethrow the exception, to prevent // the docking station from going "unavailable" and instead just treat it // as if the log was empty. This allows the corrupt log to be cleared. try { downloadEvent.GasResponses = new List <SensorGasResponse>(instrumentController.GetManualGasOperations()); } catch (ArgumentOutOfRangeException aoore) { Log.Error(aoore); downloadEvent.Errors.Add(new DockingStationError("Corrupt manual gas operations log encountered.", DockingStationErrorLevel.Warning, downloadEvent.DockedInstrument.SerialNumber)); } Log.Debug("MANUAL GAS OPERATIONS: " + downloadEvent.GasResponses.Count + " downloaded."); } // end-using Log.TimingEnd("MANUAL OPERATIONS DOWNLOAD", stopwatch); return(downloadEvent); // Return the populated event. }
/// <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); }