void Start_Button_Click(object sender, RoutedEventArgs e) { trans_fpga = 0; trans_cpu = 0; baseDateCpu = new DateTime(0); baseDateFpga = new DateTime(0); resumebutton.IsEnabled = true; stopbutton.IsEnabled = true; started = true; FpgaValues.Clear(); CpuValues.Clear(); cpuQueue = new Queue <Data>(dataHandler.GetCpuResults()); fpgaQueue = new Queue <Data>(dataHandler.GetFpgaResults()); timerCpu = new DispatcherTimer(); timerCpu.Interval = TimeSpan.FromMilliseconds(1); timerFPGA = new DispatcherTimer(); timerFPGA.Interval = TimeSpan.FromMilliseconds(1); timerCpu.Tick += timerCpu_Tick; timerCpu.Start(); timerFPGA.Tick += timerFPGA_Tick; //Console.WriteLine("Today is"); string accur = DataHandler.GetAccuracy(); //Console.WriteLine("got here"); //Console.WriteLine(accur); string[] result = accur.Split('\\'); accuracy.Text = result[0]; timerFPGA.Start(); }
void timerCpu_Tick(object sender, EventArgs e) { if (cpuQueue.Count == 0) { timerCpu.Stop(); } timerCpu.Stop(); try { trans_cpu++; Data dataPoint = cpuQueue.Dequeue(); fairprice_cpu.Text = dataPoint.FairPrice.ToString(); stock_cpu.Text = dataPoint.ExpandedData.Stock_Id.ToString(); time_cpu.Text = dataPoint.Time.ToString(); //Console.WriteLine(dataPoint.Time); transaction_cpu.Text = trans_cpu.ToString(); expiry_cpu.Text = dataPoint.ExpandedData.Expiry.ToString(); callput_cpu.Text = dataPoint.ExpandedData.Call_Put.ToString(); //Plot point //Console.WriteLine(dataPoint.TimeDiff); timerCpu.Interval = dataPoint.TimeDiff; DateTime newTime = baseDateCpu.Add(dataPoint.Time); DateModel dtpoint = new DateModel { DateTime = newTime, Value = trans_cpu }; CpuValues.Add(dtpoint); timerCpu.Start(); } catch { timerCpu.Stop(); } }
public static void UpdateGraphs(int index, double value) { //Debug.WriteLine("UpdateGraphs: " + index + " | " + value); switch (index) { case 0: GpuValues.Add(new MeasureModel { DateTime = DateTime.Now, Value = value }); if (GpuValues.Count > 10) { GpuValues.RemoveAt(0); } break; case 1: CpuValues.Add(new MeasureModel { DateTime = DateTime.Now, Value = value }); if (CpuValues.Count > 10) { CpuValues.RemoveAt(0); } break; case 2: MemValues.Add(new MeasureModel { DateTime = DateTime.Now, Value = value }); if (MemValues.Count > 10) { MemValues.RemoveAt(0); } break; case 3: DiskValues.Add(new MeasureModel { DateTime = DateTime.Now, Value = value }); if (DiskValues.Count > 10) { DiskValues.RemoveAt(0); } break; case 4: NetValues.Add(new MeasureModel { DateTime = DateTime.Now, Value = value }); if (NetValues.Count > 10) { NetValues.RemoveAt(0); } break; default: Debug.WriteLine("Invalid Index " + index); break; } //SetAxisLimits(DateTime.Now); //lets only use the last 150 values }