/// <summary>Determines if any enabled sensors are currently in alarm.</summary> /// <param name="returnEvent">The event should only be provided for the final PostBump (PurgeAfterBump) check as sensors will be put into bump fault.</param> /// <remarks>INS-6723, INS-1735</remarks> private bool IsInstrumentInAlarm(Instrument instrument, InstrumentBumpTestEvent returnEvent) { bool instrumentInAlarm = false; const string funcMsg = "IsInstrumentInAlarm: "; foreach (InstalledComponent ic in instrument.InstalledComponents) { if (!(ic.Component is Sensor)) { continue; } Sensor sensor = (Sensor)ic.Component; if (sensor.IsBumpEnabled(GasEndPoints) == false) // why do we check this? - JMP, 8/2015 { Log.Debug(String.Format("{0}Sensor in position={1} is not bump enabled", funcMsg, ic.Position)); continue; } if (sensor.Enabled == false) { Log.Debug(String.Format("{0}Sensor in position={1} is not enabled", funcMsg, ic.Position)); continue; } // If sensor is in a cal/zero-failure state, then it's not reading gas. if (SensorGasResponse.IsFailedCalibrationStatus(sensor.CalibrationStatus)) { Log.Debug(String.Format("{0}Sensor in position={1} has {2} status", funcMsg, ic.Position, sensor.CalibrationStatus)); continue; } if (IsSensorInAlarm(sensor, ic.Position) == true) { // This method is only intended to be called once when returnEvent is not null, // and only for the PostBump (PurgeAfterBump) purge. if (returnEvent != null) { SensorGasResponse sgr = GetSensorGasResponse(returnEvent, sensor); // If instrument is still in alarm after purge is finishes, then we are setting the // sensor's bump fault flag. if (sgr != null && sgr.Status == Status.Passed) { Log.Debug(String.Format("{0}Setting sensor to FAILED", funcMsg)); sgr.Status = Status.Failed; _instrumentController.SetSensorBumpFault(ic.Position, true); } } instrumentInAlarm = true; } } Log.Debug(String.Format("{0}returned {1}", funcMsg, instrumentInAlarm ? "IN ALARM" : "NOT in alarm")); return(instrumentInAlarm); }
public void ShouldPassMx6InstrumentWithDefaultSensors() { //This test is not passing currentlly because of improper gasendpoints. //Arrange InstrumentBumpTestAction action = Helper.GetBumpTestAction(DeviceType.MX6, new List <string> { "G0001", "G0002", "G0020" }); Configuration.DockingStation = action.DockingStation; //Act InstrumentBumpTestOperation operation = new InstrumentBumpTestOperation(action); InstrumentBumpTestEvent returnEvent = operation.Execute() as InstrumentBumpTestEvent; //Assert that all default sensors passed bump test Xunit.Assert.NotNull(returnEvent); Xunit.Assert.True(returnEvent.GasResponses[0].Passed); Xunit.Assert.True(returnEvent.GasResponses[1].Passed); Xunit.Assert.True(returnEvent.GasResponses[2].Passed); Xunit.Assert.True(returnEvent.GasResponses[3].Passed); }
/// <summary> /// Executes an instrument bump test operation. /// </summary> /// <returns>The completed event for this bump test.</returns> /// <exception cref="FailedBumpTestException"> /// If anything extraordinary happened during the bump test. /// </exception> public DockingStationEvent Execute() { //Clear if any flags before initiating calibration once again Pump.IsBadPumpTubing = false; // iNetDS Master.Instance.SwitchService.BadPumpTubingDetectedDuringCal = false; // iNetDS Master.Instance.SwitchService.BadPumpTubingDetectedDuringBump = false; // iNetDS Stopwatch operationStopwatch = Log.TimingBegin("INSTRUMENT BUMP TEST"); // iNetDS _returnEvent = new InstrumentBumpTestEvent(this); _returnEvent.DockedInstrument = this.Instrument; // TODO _returnEvent.DockingStation = this.DockingStation; // TODO //_detailsBuilder = new DetailsBuilder(EventDetails); // _detailsBuilder = new DetailsBuilder(InstrumentHelper.EventDetails); // IDS //Throw Exception if Instrument is undocked if (!Master.Instance.ControllerWrapper.IsDocked()) { throw new InstrumentNotDockedException(); } _returnEvent.Trigger = Trigger; _returnEvent.IsSensorFailureModeEnabled = IsSensorFailureModeEnabled; // DSW-1034 RHP Tango TODO IDS _returnEvent.IsSCSensorFailureModeEnabled = IsSCSensorFailureModeEnabled; // DSW-1068 RHP v9.5 TODO IDS Log.Debug(string.Format("{0}.Execute {1}", Name, _returnEvent.DockedInstrument.SerialNumber)); // Add the detail header. //_detailsBuilder.Add("", "DETAILS_BUMP_TEST_HEADER", string.Empty); // IDS //_detailsBuilder.AddNewLine(); // IDS //_detailsBuilder.Add(" ", "DETAILS_INSTRUMENT_BUMPTHRESHOLD", this.BumpThreshold); // IDS //_detailsBuilder.Add(" ", "DETAILS_INSTRUMENT_BUMPTIMEOUT", this.BumpTimeout); // IDS _returnEvent.DockedInstrument.InstalledComponents = InstrumentController.SortSensorsByBumpOrder(_returnEvent.DockedInstrument.InstalledComponents); // #region LogDebug Log.Debug("Candidate gases..."); int pointCount = 0; foreach (GasEndPoint gasEndPoint in GasEndPoints) { string msg = "GasEndPoint #" + ++pointCount; Log.Debug(msg); Cylinder cyl = gasEndPoint.Cylinder; msg = "...Pos " + gasEndPoint.Position + ", FactID=" + cyl.FactoryId + ", Part=" + cyl.PartNumber + ", Fresh=" + cyl.IsFreshAir + ", ZeroAir=" + cyl.IsZeroAir + ", Pressure=" + cyl.Pressure.ToString(); if (gasEndPoint.Cylinder.Volume != DomainModelConstant.NullInt) { msg += ", Vol=" + gasEndPoint.Cylinder.Volume; } Log.Debug(msg); msg = "......"; foreach (GasConcentration gasCon in cyl.GasConcentrations) { msg += "[" + gasCon.Type.Code + " "; msg += (gasCon.Concentration == DomainModelConstant.NullDouble) ? "fresh" : gasCon.Concentration.ToString(); msg += "]"; } Log.Debug(msg); } Log.Debug("Going to BUMP sensors in following ORDER..."); int bumpOrder = 1; foreach (InstalledComponent ic in _returnEvent.DockedInstrument.InstalledComponents) { if (!(ic.Component is Sensor)) { continue; // It its not a sensor, ignore it. } Log.Debug("...#" + bumpOrder++ + ", Position " + ic.Position + ", UID=" + ic.Component.Uid + ", " + ic.Component.Type.Code); } #endregion // Open the serial port connection needed to communicate with the instrument. try { Stopwatch pingStopwatch = Log.TimingBegin("BUMP - PING"); _instrumentController.Initialize(); // Add a new line and section to the details. //_detailsBuilder.AddNewLine(); Log.TimingEnd("BUMP - PING", pingStopwatch); // See if there are any already failed sensors - go to calibration if there are. // TODO move this section for IDS prior to initiating Bump Test, probably something similar to iNetDS Scheduler // Load the BumpTimout and BumpThreshold from the database needed to perform the bump. LoadBumpLimits(); // TODO update for IDS, LOAD THESE INTO INSTRUMETN ACTION BEFORE BUMP TEST BumpInstrument(); // Need to determine the next time this instrument will be bumped. // Put this date into the event so it can be uploaded to iNet, and also // update the global next date that's held in the switch service. _returnEvent.NextUtcScheduledDate = Master.Instance.SwitchService.NextUtcBumpDate = Master.Instance.Scheduler.GetNextGasOperationDate(_returnEvent); } finally { _instrumentController.Dispose(); } Log.TimingEnd("INSTRUMENT BUMP TEST", operationStopwatch); // IDS Updates Sensor's Bump Test Status on Cached Instrument - TODO TO BE HANDLED IN EVENT PROCESSOR FOR IDS. // Send back the results. return(_returnEvent); }