I am trying to write a simple UDP-to-Chart application (for Windows forms) that will receive raw data from ethernet and put it in a certain way in a diagram. Here is what I have so far: a form with two diagrams, a stream for receiving UDP packets:
public void serverThread()
{
UdpClient udpClient = new UdpClient(Convert.ToInt16(tbEthPort.Text));
while (_serverWork)
{
try
{
IPEndPoint RemoteIpEndPoint = new IPEndPoint(IPAddress.Any, Convert.ToInt16(tbEthPort.Text));
Byte[] receiveBytes = udpClient.Receive(ref RemoteIpEndPoint);
if (receiveBytes.Length > 0)
for (i = 0; i < receiveBytes.Length; i++)
{
bigDataIn[i] = receiveBytes[i];
}
and draw a second graph (which shows the entire contents of the package in a certain way):
if (graphicOn)
{
for (i = 0; i < 32; i++)
{
graphicData[i + (graphicStep * 32)] = bigDataIn[i * 32 + graphicChan];
}
graphicStep++;
if (graphicStep == 32) graphicStep = 0;
try
{
Invoke(new Action(() => { chartGraphic.Series["DataGraphic"].Points.DataBindXY(graphicEnum, graphicData);
}));
}
catch
{
}
}
and a main thread with a timer to draw the first chart.
private void tmrHisto_Tick(object sender, EventArgs e)
{
int[] slice = new int[32];
for (int i = 0; i < 32; i++)
slice[i] = bigDataIn[i + 32 * histogramArrayStep];
histogramArrayStep++;
if (histogramArrayStep == 32) histogramArrayStep = 0;
chartHistogram.Series["DataHistogram"].Points.Clear();
for (int i = 0; i < HISTO_XMAX; i++)
{
chartHistogram.Series["DataHistogram"].Points.AddXY(i, slice[i]);
}
}
, , , . Invoke chartGraphic. ( 20 ) WireShark - . , 50 150 , .
, - . ?