public AnalyticStatisticsItem Get(PsaParametersSet set, DateTime sourceDataCaptureDateTime) { AnalyticStatisticsItem result = new AnalyticStatisticsItem( AnalyticRuleType.EngineStartUndervoltage, info.Engine.Family.Type, info.Engine.Type); IList <double> rpmLine = set.GetParameterOfType(PsaParameterType.EngineRpm).GetDoubles(); IList <double> voltagesLine = set.GetParameterOfType(PsaParameterType.BatteryVoltage).GetDoubles(); EngineStartupDetector detector = new EngineStartupDetector(rpmLine); if (!detector.EngineStartupDetected()) { return(result); // empty, will be assimilated and disappear } IList <int> startupPoints = detector.GetEngineStartupPointIndexes(); // we will have as many statistical values as there is startup points foreach (int startupPointIndex in startupPoints) { StartupUndervoltageExtractor extractor = new StartupUndervoltageExtractor(startupPointIndex, voltagesLine); double startupUndervoltage = extractor.Extract(); if (!double.IsNaN(startupUndervoltage)) { result.Values.Add(new AnalyticStatisticsValue( startupUndervoltage, info.Vin, set.Id, sourceDataCaptureDateTime)); } } return(result); }
public void TestUndervoltageExtraction() { IList <double> voltages = new List <double>() { 14.1, 14.1, 14.1, 14.1, 14.1, 14.1, 14.1, 14.1, 14.1, 14.1, 14.1, 14.1, 14.1, 14.1, 13.6, 13.6, 13.5, 13.4, 12.5, 12.5, 12.4, 12.4, 10.3, 12.2, 12.3, 12.8, 13.5, 13.9, 14.1, 14.0, 14.1, 14.1, 14.1, 14.1, 14.1, 14.1, 14.1, 14.1, 14.1, 14.1, 14.2, 14.1, 14.2, 14.1, 14.1, 14.1, 14.2, 14.2, 14.2, 14.2, 14.2, 14.2, 14.2, 14.2, 14.1, 14.1, 14.2, 14.1, 14.2, 14.2, 14.1, 14.2, 14.1, 14.2, 14.1, 14.1, 12.6, 12.6, 12.6, 12.6, 12.6, 13.9, 14.1, 12.6, 12.6, 12.6, 12.5, 11.4, 12.3, 12.6, 13.2, 14.1, 14.0, 14.1, 14.2, 14.2, 14.2, 14.2, 14.2, 14.2, 14.2, 14.2, 14.2, 14.1, 14.2, 14.1, 14.1, 14.1, 14.1, 14.1 }; int startIndex = 22; // has 22, 70 and 76 StartupUndervoltageExtractor extractor = new StartupUndervoltageExtractor(startIndex, voltages); Assert.IsTrue(extractor.Extract() == 10.3); }