private void UpdateGraph() { if (points > 0) { CeGraphicalEvent newGraph = new CeGraphicalEvent(); newGraph.PumpsValues.Pump1.XAxes = graph.PumpsValues.Pump1.XAxes.Take(indexGraph).ToList(); newGraph.PumpsValues.Pump1.YAxes = graph.PumpsValues.Pump1.YAxes.Take(indexGraph).ToList(); newGraph.PumpsValues.Pump2.XAxes = graph.PumpsValues.Pump2.XAxes.Take(indexGraph).ToList(); newGraph.PumpsValues.Pump2.YAxes = graph.PumpsValues.Pump2.YAxes.Take(indexGraph).ToList(); newGraph.PumpsValues.Pump3.XAxes = graph.PumpsValues.Pump3.XAxes.Take(indexGraph).ToList(); newGraph.PumpsValues.Pump3.YAxes = graph.PumpsValues.Pump3.YAxes.Take(indexGraph).ToList(); endpoint.Publish(newGraph).ConfigureAwait(false); } }
internal void UpdatePumpsValues(object sender, CeGraphicalEvent e) { App.Current.Dispatcher.Invoke((System.Action) delegate { var temp = new SeriesCollection(); LineSeries1 = new LineSeries { Name = "P1", Title = "Pump1", Values = e.PumpsValues.Pump1.YAxes.AsChartValues(), Stroke = Brushes.Khaki, Visibility = Visibility.Visible }; temp.Add(LineSeries1); LineSeries2 = new LineSeries { Name = "P2", Title = "Pump2", Values = e.PumpsValues.Pump2.YAxes.AsChartValues(), Stroke = Brushes.DarkSalmon, Visibility = Visibility.Visible }; temp.Add(LineSeries2); LineSeries3 = new LineSeries { Name = "P3", Title = "Pump3", Values = e.PumpsValues.Pump3.YAxes.AsChartValues(), Stroke = Brushes.LightGreen, Visibility = Visibility.Visible }; temp.Add(LineSeries3); PumpSeriesY = temp; }); }
private void UpdateGraph() { if (points > 0) { CeGraphicalEvent newGraph = new CeGraphicalEvent(); newGraph.PumpsValues.Pump1.XAxes = graph.PumpsValues.Pump1.XAxes.Take(indexGraph).ToList(); newGraph.PumpsValues.Pump1.YAxes = graph.PumpsValues.Pump1.YAxes.Take(indexGraph).ToList(); newGraph.PumpsValues.Pump2.XAxes = graph.PumpsValues.Pump2.XAxes.Take(indexGraph).ToList(); newGraph.PumpsValues.Pump2.YAxes = graph.PumpsValues.Pump2.YAxes.Take(indexGraph).ToList(); newGraph.PumpsValues.Pump3.XAxes = graph.PumpsValues.Pump3.XAxes.Take(indexGraph).ToList(); newGraph.PumpsValues.Pump3.YAxes = graph.PumpsValues.Pump3.YAxes.Take(indexGraph).ToList(); var json = JsonTool.Serialize <CeGraphicalEvent>(newGraph); PubSubMessage ev = new PubSubMessage() { ContentType = ContentType.CE_HISTORY_GRAPH, Content = json, Sender = Sender.CE }; pubsub.SendMessage(ev).ConfigureAwait(false); } }
public Task Handle(CeGraphicalEvent message, IMessageHandlerContext context) { ceUpdatePumpsValues.Invoke(this, message); return(Task.CompletedTask); }
private void DoWorkNew() { Thread.Sleep(10000); graph = new CeGraphicalEvent(); graph.PumpsValues = new Core.Common.ServiceBus.Events.CeGraph(); while (endFlag) { try { if (points <= 0 || points > 3) { continue; } CheckState(); if (hourIndexChanged == 3600) { hourIndex++; } if (seconds == 10800 || seconds == 0 || pointUpdateOccures) { SimulatorProxy invoker = new SimulatorProxy(); invoker.SimulatorSettings(false); indexGraph = indexUpdate = 0; Calculations(); if (seconds == 10800) { seconds = 0; } } if (points > 0 && commands != null && graph != null) { if (!simulation) { SimulatorProxy invoker = new SimulatorProxy(); invoker.SimulatorSettings(true); simulation = true; } if (seconds % 45 == 0) { if (indexUpdate < 24) { Command(); } indexUpdate++; if (indexGraph < 24) { UpdateGraph(); } indexGraph++; if (indexGraph == 23) { SimulatorProxy invoker = new SimulatorProxy(); invoker.SimulatorSettings(false); } } } Thread.Sleep(TimeSpan.FromSeconds(1)); seconds += 1; hourIndexChanged += 1; } catch (Exception e) { Console.WriteLine(e.Message); } } }
private void Update(CeForecast forecastResult, List <double> weather) { CeUpdateEvent update = new CeUpdateEvent(); update.Income = new List <double>(); for (int i = 0; i < weather.Count; i++) { double integralIncome = 0; for (int j = 0; j < 4; j++) { integralIncome += weather[i] / 4; update.Income.Add(integralIncome); } } update.Times = GetTimes(); update.FluidLevel = new List <float>(); foreach (var item in forecastResult.Results) { update.FluidLevel.Add(item.StartFluidLevel); update.FluidLevel.Add(item.EndFluidLevel); } update.Hours = new List <PumpsHours>(); update.Flows = new List <PumpsFlows>(); graph = new CeGraphicalEvent(); graph.PumpsValues = new Core.Common.ServiceBus.Events.CeGraph(); List <List <long> > list = new List <List <long> >(); for (int i = 0; i < points; i++) { var macList = new List <long>(); long cumm = 0; var hours = new PumpsHours(); var flows = new PumpsFlows(); foreach (var item in forecastResult.Results) { if (item.Pumps[i] == 1) { hours.Hours.Add(item.Times[i]); flows.Flows.Add(item.Flows[i]); cumm += (long)(item.Times[i]); } else { hours.Hours.Add(0); flows.Flows.Add(0); } macList.Add(cumm); } update.Hours.Add(hours); update.Flows.Add(flows); list.Add(macList); } pubsub.SendMessage(new Core.Common.PubSub.PubSubMessage() { ContentType = Core.Common.PubSub.ContentType.CE_UPDATE, Content = JsonTool.Serialize <CeUpdateEvent>(update), Sender = Core.Common.PubSub.Sender.CE }).GetAwaiter().GetResult(); if (points == 1) { graph.PumpsValues.Pump1.XAxes = update.Times.ConvertAll(x => DateTime.Parse(x)); graph.PumpsValues.Pump1.YAxes = list[0]; } if (points == 2) { graph.PumpsValues.Pump1.XAxes = update.Times.ConvertAll(x => DateTime.Parse(x)); graph.PumpsValues.Pump1.YAxes = list[0]; graph.PumpsValues.Pump2.XAxes = update.Times.ConvertAll(x => DateTime.Parse(x)); graph.PumpsValues.Pump2.YAxes = list[1]; } if (points == 3) { graph.PumpsValues.Pump1.XAxes = update.Times.ConvertAll(x => DateTime.Parse(x)); graph.PumpsValues.Pump1.YAxes = list[0]; graph.PumpsValues.Pump2.XAxes = update.Times.ConvertAll(x => DateTime.Parse(x)); graph.PumpsValues.Pump2.YAxes = list[1]; graph.PumpsValues.Pump3.XAxes = update.Times.ConvertAll(x => DateTime.Parse(x)); graph.PumpsValues.Pump3.YAxes = list[2]; } }