private int?CalcForcedEveryNthCycle(PlotType plotType, int[] projects, PlotParameters parameters, string trace) { if (plotType != PlotType.VoltageCapacity && plotType != PlotType.DifferentialVoltage && plotType != PlotType.DifferentialCapacity) { return(null); } var maxCycles = parameters?.MaxCycles ?? 0; if (maxCycles <= 0) { return(null); } var maxCyclesPerProject = Math.Max(maxCycles / projects.Length - 1, 1); var forcedEveryNthCycle = projects.Max(pid => { var cycles = _projectDataRepository.GetCycles(pid, trace).Count; if (!string.IsNullOrEmpty(parameters?.CustomCycleFilter)) { var rangeFilter = new IndexRangeFilter(parameters.CustomCycleFilter).RangesItems; cycles = rangeFilter.Count; var result = cycles / maxCyclesPerProject; if (cycles % maxCyclesPerProject != 0) { result += 1; } return(result); } else { var fromCycle = Math.Max(parameters?.FromCycle ?? 1, 1); var toCycle = Math.Min(parameters?.ToCycle ?? cycles, cycles); cycles = toCycle - fromCycle + 1; var result = cycles / maxCyclesPerProject; if (cycles % maxCyclesPerProject != 0) { result += 1; } return(result); } }); if (forcedEveryNthCycle < 2) { return(null); } if (parameters?.EveryNthCycle != null && parameters.EveryNthCycle.Value >= forcedEveryNthCycle) { return(null); } return(forcedEveryNthCycle); }
private int?CalcForcedEveryNthCycle(bool projectsSumCyclesGreaterThanMax, int[] projects, PlotParameters parameters, string trace) { if (!projectsSumCyclesGreaterThanMax || IsCalcEveryNthCycleForcedDisabled) { return(null); } var maxCycles = parameters?.MaxCycles ?? 0; if (maxCycles <= 0) { return(null); } var maxCyclesPerProject = Math.Max(maxCycles / projects.Length - 1, 1); var forcedEveryNthCycle = projects.Max(pid => { int cycles = ProjectDataRepository.GetCycles(pid, trace).Count; if (parameters != null && string.IsNullOrEmpty(parameters.CustomCycleFilter)) { int fromCycle = Math.Max(parameters.FromCycle ?? 1, 1); int toCycle = Math.Min(parameters.ToCycle ?? cycles, cycles); cycles = toCycle - fromCycle + 1; int result = cycles / maxCyclesPerProject; if (cycles % maxCyclesPerProject != 0) { result += 1; } return(result); } else { if (parameters != null) { var rangeFilter = new IndexRangeFilter(parameters.CustomCycleFilter).RangesItems; cycles = rangeFilter.Count; } int result = cycles / maxCyclesPerProject; if (cycles % maxCyclesPerProject != 0) { result += 1; } return(result); } }); if (forcedEveryNthCycle < 2) { return(null); } if (parameters?.EveryNthCycle != null && parameters.EveryNthCycle.Value >= forcedEveryNthCycle) { return(null); } return(forcedEveryNthCycle); }