public void OnIncomingData(string data) { gotData_ = true; double[] resultCsv = null; resultCsv = DataStream.ExtractCsvFromLine(data); ToggleInvalidDataAlert("", false); if (resultCsv != null && resultCsv.Length > 0) { TreeNode root = treeView.Nodes[0]; double lastTime = stopwatch_.ElapsedMilliseconds / 1000.0; foreach (var series in ChartManager.Inst.GetSeriesManagersList()) { try { switch (series.DataType) { case SeriesManager.Type.BYTES_RATE: ulong newBytesCount = bytesInCounter.GetRawCounter(); bytesInRateCounter.SetCounter(newBytesCount - bytesInRateCounter.PrevCount); bytesInRateCounter.PrevCount = newBytesCount; addPointToSeries("Bytes Rate", lastTime, bytesInRateCounter.GetRawCounter()); break; case SeriesManager.Type.SETPOINT: addPointToSeries(series.NameId, lastTime, series.Setpoint); break; case SeriesManager.Type.INCOMING_DATA: // fill tree view node with series name and data value root.Nodes[series.DataIndex].Nodes[0].Text = series.NameId; root.Nodes[series.DataIndex].Nodes[0].Nodes[0].Text = resultCsv[series.DataIndex].ToString(); addPointToSeries(series.NameId, lastTime, resultCsv[series.DataIndex]); break; default: ToggleInvalidDataAlert("INVALID DATA", true); break; } } catch (ObjectDisposedException exp) { ToggleInvalidDataAlert("Error: " + exp.Data.ToString(), true); return; } } } else { ToggleInvalidDataAlert("INVALID DATA", true); } }