Esempio n. 1
0
        public PingResult Add(string name, double value, double index = -1)
        {
            bool found = false;

            foreach (PingResult p in _collection)
            {
                if (p.name == name)
                {
                    found = true;
                    if (index > -1)
                    {
                        p.Points.Add(new DataPoint(index, value));
                    }
                    else
                    {
                        p.value = value; // p.value*.99+value*.01;
                    }
                }
            }
            if (!found)
            {
                PingResult temp = new PingResult(name, value, _mainWindow);
                _collection.Add(temp);
                return(temp);
            }
            return(null);
        }
Esempio n. 2
0
 public void EnableDisableSeries(PingResult p, bool enable)
 {
     if (enable)
     {
         if (!Plot1.Series.Contains(p.Line))
         {
             Plot1.Series.Add(p.Line);
         }
         p.Line.ItemsSource = p.Points;
     }
     else
     {
         Plot1.Series.Remove(p.Line);
     }
     Plot1.InvalidatePlot(true);
 }
Esempio n. 3
0
        private void CallBack(IAsyncResult res)
        {
            IPEndPoint RemoteIpEndPoint = new IPEndPoint(IPAddress.Any, 4444);

            byte[] received = Client.EndReceive(res, ref RemoteIpEndPoint);
            string s        = Encoding.ASCII.GetString(received);

            Console.WriteLine(s);

            if (!s.Contains("garbage"))
            {
                string[] lines = s.Split('\n');
                foreach (var line in lines)
                {
                    string[] split = line.Split(':');
                    if (split.Length > 1)
                    {
                        MainWindow.disp.BeginInvoke(DispatcherPriority.Normal,
                                                    new Action(() => {
                            double d        = 0;
                            d               = Double.Parse(split[1] /*.Replace('.', ',')*/);
                            PingResult temp = pingResults.Add(split[0], d);
                            if (temp != null)
                            {
                                Plot1.Series.Add(temp.Line);
                                temp.Line.ItemsSource = temp.Points;
                            }
                            Plot1.InvalidatePlot(true);
                        }));
                    }
                }
            }

            if (continous)
            {
                Client.BeginReceive(new AsyncCallback(CallBack), null);
            }
        }