public IActionResult GetPlot([FromBody] PlotRequest plotRequest) { if (plotRequest.HybridSystemRequest.Type != ModuleType.Multiple) { return(BadRequest()); } var result = plotRequest .FailureRates .Select(failureRate => GetPlotResponse(plotRequest, failureRate)).ToList(); var originalRequest = HybridToSystemRequest(plotRequest.HybridSystemRequest, _ => _); var originalSystem = (MultipleModuleSystem)originalRequest.ToSystem(); var originalGraph = new SystemStateGraph(originalSystem, false); var originalPlotData = originalGraph.GetProbability(plotRequest.FromTime, plotRequest.ToTime, plotRequest.Step); result.Add(new PlotResponse { FailureRate = -1, ModuleName = plotRequest.ModuleName, PlotData = originalPlotData }); return(Ok(result)); }
private static PlotResponse GetPlotResponse(PlotRequest plotRequest, double failureRate) { var systemRequest = HybridToSystemRequest(plotRequest.HybridSystemRequest, single => { if (single.ModuleName == plotRequest.ModuleName) { single.FailureRate = Math.Round(failureRate, 7, MidpointRounding.AwayFromZero); } return(single); }); var system = (MultipleModuleSystem)systemRequest.ToSystem(); var graph = new SystemStateGraph(system, false); var plotData = graph.GetProbability(plotRequest.FromTime, plotRequest.ToTime, plotRequest.Step); return(new PlotResponse { FailureRate = Math.Round(failureRate, 7, MidpointRounding.AwayFromZero), ModuleName = plotRequest.ModuleName, PlotData = plotData }); }