2using System.Collections.Generic;
28 public class CombinationResult
30 private readonly List<double> _responseTimesMs =
new List<double>();
32 internal CombinationResult(
TestPattern pattern,
int payloadLength)
57 public int Naks {
get;
internal set; }
73 public double MinResponseTimeMs => _responseTimesMs.Count == 0 ? 0.0 : _responseTimesMs.Min();
76 public double MaxResponseTimeMs => _responseTimesMs.Count == 0 ? 0.0 : _responseTimesMs.Max();
81 internal void RecordResponseTime(
double milliseconds) => _responseTimesMs.Add(milliseconds);
87 public class BaudRateResult
89 private readonly List<CombinationResult> _combinations =
new List<CombinationResult>();
91 internal BaudRateResult(
int baudRate)
125 public int PacketsSent => _combinations.Sum(combination => combination.PacketsSent);
128 public int PacketsReceived => _combinations.Sum(combination => combination.PacketsReceived);
131 public int Timeouts => _combinations.Sum(combination => combination.Timeouts);
134 public int IntegrityErrors => _combinations.Sum(combination => combination.IntegrityErrors);
137 public int Naks => _combinations.Sum(combination => combination.Naks);
140 public int PatternMismatches => _combinations.Sum(combination => combination.PatternMismatches);
151 _combinations.Count == 0 ? 0.0 : _combinations.Max(combination => combination.MaxResponseTimeMs);
159 if (received == 0)
return 0.0;
161 double weighted = _combinations.Sum(combination =>
162 combination.AverageResponseTimeMs * combination.PacketsReceived);
163 return weighted / received;
206 internal const double MaximumReplyDelayMs = 200.0;
209 internal const double MarginalReplyDelayMs = 150.0;
214 _combinations.Add(combination);
222 public class LineQualityReport
224 private readonly List<BaudRateResult> _baudRates =
new List<BaudRateResult>();
226 internal LineQualityReport(
TestProfile profile,
string connection,
byte address)
253 public IReadOnlyList<BaudRateResult>
BaudRates => _baudRates;
269 .Select(result => (
int?)result.BaudRate)
270 .DefaultIfEmpty(
null)
281 var assessed = _baudRates
301 _baudRates.Add(result);
Results for every combination exercised at a single baud rate.
int Failures
Gets the total number of failures of any kind at this rate.
double AverageResponseTimeMs
Gets the mean response time across every successful exchange at this rate.
LineQualityVerdict Verdict
Gets the assessment for this baud rate, per section 6.1 of the test procedure.
IReadOnlyList< CombinationResult > Combinations
Gets the per-combination results.
string FailureReason
Gets the reason the rate failed before any packets could be measured, or null.
bool WasTested
Gets a value indicating whether any packets were sent at this rate.
int PatternMismatches
Gets the total number of pattern mismatches at this rate.
double MaxResponseTimeMs
Gets the longest response time observed at this rate, in milliseconds.
int Naks
Gets the total number of NAK replies at this rate.
int PacketsSent
Gets the total number of echo requests sent at this rate.
int PacketsReceived
Gets the total number of correct echoes received at this rate.
int IntegrityErrors
Gets the total number of integrity failures at this rate.
double DetectionLimitPercent
Gets the smallest packet loss rate this run could have ruled out, as a percentage.
int Timeouts
Gets the total number of timeouts at this rate.
int BaudRate
Gets the baud rate these results describe.
string SkipReason
Gets the reason the rate was not exercised because the responder cannot do it, or null.
double SuccessRatePercent
Gets the proportion of requests that produced a correct echo, as a percentage.
Results for a single pattern and payload size at one baud rate.
int Failures
Gets the total number of failures of any kind.
double SuccessRatePercent
Gets the proportion of requests that produced a correct echo, as a percentage.
int PacketsReceived
Gets the number of correct echoes received.
double AverageResponseTimeMs
Gets the mean observed response time, or zero when nothing was received.
int Timeouts
Gets the number of requests that drew no reply within the timeout.
int PacketsSent
Gets the number of echo requests sent.
int PayloadLength
Gets the payload length exercised.
TestPattern Pattern
Gets the pattern exercised.
double MaxResponseTimeMs
Gets the longest observed response time, or zero when nothing was received.
int IntegrityErrors
Gets the number of replies that arrived but failed their integrity check.
int Naks
Gets the number of replies that were a NAK.
double MinResponseTimeMs
Gets the shortest observed response time, or zero when nothing was received.
int PatternMismatches
Gets the number of replies that passed their integrity check but did not carry the expected sequence ...
Constants and helpers for the OSDP Line Quality Test Procedure.
static double DetectionLimitPercent(int packetsSent)
Calculates the smallest packet loss rate a run of the given size can rule out, as a percentage,...
static int IterationsPerCombination(TestProfile profile)
Returns the number of iterations a profile runs for each pattern and size combination.
DateTime CompletedUtc
Gets when the run finished.
int? RecommendedBaudRate
Gets the highest baud rate that passed, or null when none did.
string Connection
Gets a description of the connection tested.
byte Address
Gets the responder address that was tested.
TestProfile Profile
Gets the profile the run used.
IReadOnlyList< BaudRateResult > BaudRates
Gets the per-baud-rate results, in the order they were exercised.
LineQualityVerdict OverallVerdict
Gets the overall verdict: the best result achieved at any rate.
TimeSpan Duration
Gets how long the run took.
DateTime StartedUtc
Gets when the run started.
int IterationsPerCombination
Gets the number of iterations run for each pattern and payload combination.
TestPattern
Test pattern identifiers defined by the OSDP Line Quality Test Procedure, section 3....
TestProfile
Test profiles from section 3.10 of the Line Quality Test Procedure.
LineQualityVerdict
The overall assessment of a baud rate or of a whole test run.
@ Marginal
Usable, but with at least one failure or a response time approaching the limit.
@ Pass
No failures of any kind, and every response comfortably inside the reply window.
@ Untested
The rate was not exercised, usually because the responder refused to switch to it.
@ Fail
Not usable at this rate.