using DTS.Common.Enums.Sensors; using DTS.Common.Interface.DASFactory.Diagnostics; namespace DTS.DASLib.Service { /// /// This class holds the results from one channel's diagnostics. These results are arbitrary on /// thier own but can be checked against the hardware specifications or settings for the sensor on the /// corresponding channel to provide pre-recording checks or diagnostic feedback about how the channel is /// set up. For example this DiagnosticsResult will provide the acutal voltage that is being applied to /// sensor for excitation, and this can be verified correct or incorrect based on what the sensor /// actually needs for excitation. The sensor specific values can be found in the corresponding DASChannel /// () object in the ConfigData object for the IDASCommunication where this channel lives, /// but they must be put there by a call to ConfigureService.Configure(...). /// public class DiagnosticsResult : IDiagnosticResult { /// /// Which DASChannel from which this diagnostics is returning. /// public int DASChannelNumber { get; set; } /// /// The event number that this diagnostics is relevant for. /// public int EventNumber { get; set; } /// /// The firmware calculates a scale factory for the channel's input. The hardware will /// deliver raw, unprocessed data upon download, but to diagnos this data to /// reflect real world votages it must be scaled based on the DAS unit's factory /// diagnostics as well as results from this diagnose. The samples that /// will be downloaded will be straight from the A to D Converter so this scale /// factor is MANDATORY and must be used at the software level to scale the data /// to the real sensed voltages and engineering units. /// public double ScalefactorMilliVoltsPerADC { get; set; } = 1; public double ScalefactorEngineeringUnitsPerADC { get; set; } = 1; /// /// The factory excitation value (mandatory) /// public double ExpectedExcitationMilliVolts { get; set; } /// /// gets what will probably be the datazerolevel adc for the channel /// /// /// public short GetExpectedDataZeroLevelADC(ZeroMethodType zeroMethod) { switch (zeroMethod) { case ZeroMethodType.None: return ZeroMVInADC; default: // if FinalOffsetADC is NOT null, offset has been measured after calibration // and that's the amount is what we should use if (FinalOffsetADC != null) { return (short)FinalOffsetADC; } // OK, FinalOffsetADC was null so we need to check MeasuredOffsetMilliVolts // if it's NOT null, that's what we'll use if (MeasuredOffsetMilliVolts != null) { return (short)((double)MeasuredOffsetMilliVolts / ScalefactorMilliVoltsPerADC); } // both of them are null so the only thing we can do is return 0 return 0; } } /// /// Excitation voltage provided to sensor as measured by the firmware during /// calibration. When read from event attributes, a value of 0.0 might actually /// mean null (i.e. was not measured). /// public double? MeasuredExcitationMilliVolts { get; set; } /// /// flag to indicate whether MeasuredExcitationMilliVolts was negative when it was initially read /// 14233 Negative Excitation Reported by TDAS hardware not showing in Diagnostics /// this was created to relate to legacy TDC/TDAS broken sensor/wire warnings carried through /// the excitation reading /// public bool NegativeExcitation { get; set; } /// /// What is the sensor's offset reading from the 0 level? This is measured by firmware /// during the calibration. When read from event attributes, a value of 0.0 might actually /// mean null (i.e. was not measured). /// public double? MeasuredOffsetMilliVolts { get; set; } public double? MeasuredInternalOffsetMilliVolts { get; set; } /// /// What is the sensor's offset reading from the 0 level? This is measured by firmware /// during the calibration. When read from event attributes, a value of 0.0 might actually /// mean null (i.e. was not measured). /// public double? MeasuredOffsetEngineeringUnits { get; set; } /// /// when a channel is autozero'd (remove offset) /// this is the devation from 0 (from RW Auto zero is checking for +/- 5% from 0 in counts.) /// private double? _autoZeroPercentDeviation; public double? AutoZeroPercentDeviation { get => _autoZeroPercentDeviation; set => _autoZeroPercentDeviation = null != value ? (double?)System.Math.Abs((double)value) : null; } /// /// If the .Calibrate method was called with the "RemoveOffset" boolean variable set /// to TRUE then the firmware will attempt to remove the offset of the sensor, moving it's base /// reading back to 0. This value is how much offset is present after removing the offset. While the /// offset my not be compeletely removed it may have been reduced to fall within the high and low /// limits for acceptable offsets for the sensor. See to find /// these sensor specific values. When read from event attributes, a value of 0.0 might actually /// mean null (i.e. was not measured). /// public short? FinalOffsetADC { get; set; } public int? RemovedOffsetADC { get; set; } public int? RemovedInternalOffsetADC { get; set; } /// /// FullScaleSignal to Noise ratio as a percentage. When read from event attributes, a value of 0.0 might actually /// mean null (i.e. was not measured). /// public double? NoisePercentFullScale { get; set; } public bool ShuntDeflectionFailed { get; set; } public bool CalSignalCheckFailed { get; set; } /// /// If an emulated shunt test is performed the measured shunt deflection in mV detected /// during the test will be here. /// .PerformShuntCheck /// When read from event attributes, a value of 0.0 might actually mean null /// (i.e. was not measured). /// public double? MeasuredShuntDeflectionMv { get; set; } public double? MeasuredCalSignalMv { get; set; } public double? TargetCalSignalMv { get; set; } public double? MeasuredDurationMS { get; set; } public double? MeasuredDelayMS { get; set; } public bool? SquibFirePassed { get; set; } public bool? SquibDurationPassed { get; set; } public bool? SquibDelayPassed { get; set; } public double[] SquibFireCurrentData { get; set; } public double[] SquibFireVoltageData { get; set; } public double[] SquibFireTimeAxis { get; set; } public double SquibThreshold { get; set; } public double SquibVoltageScaler { get; set; } public double SquibCurrentScaler { get; set; } public double? TargetGain { get; set; } public double? MeasuredGain { get; set; } public double? QueriedGain { get; set; } /// /// If an emulated shunt test is performed the target shunt deflection in mV will be here. /// CalibrateActions.PerformShuntCheck When read from event attributes, a value of 0.0 might actually /// mean null (i.e. was not measured). /// public double? TargetShuntDeflectionMv { get; set; } /// /// If the bridge resistance of the sensor was measured, the measured resistance in /// ohms will be here. /// When read from event attributes, a value of 0.0 might actually mean null /// (i.e. was not measured). /// public double? BridgeResistance { get; set; } public short ZeroMVInADC { get; set; } = 0; /// /// WindowAverageADC is the average ADC over the averaging window specified for the channel /// short.MinValue indicates an unitialized or invalid value /// public short WindowAverageADC { get; set; } = short.MinValue; public bool DigitalInputActiveState { get; set; } } }