Processing 'measurement' datagrams implemented.
This commit is contained in:
@@ -295,20 +295,36 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
|
||||
|
||||
void MeasurementUdpListener()
|
||||
{
|
||||
StringBuilder toBeProcessed = new StringBuilder();
|
||||
IPEndPoint ipEndPoint = new IPEndPoint(IPAddress.Any, measurementUdpPortNr);
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
while (true)
|
||||
{
|
||||
IPEndPoint ipEndPoint = new IPEndPoint(IPAddress.Any, measurementUdpPortNr);
|
||||
byte[] byteArray = measurementListener.Receive(ref ipEndPoint);
|
||||
string receivedData = Encoding.ASCII.GetString(byteArray, 0, byteArray.Length);
|
||||
int from = receivedData.IndexOf('[');
|
||||
int to = receivedData.IndexOf(']');
|
||||
int locPulses;
|
||||
if (from >= 0 && to >= 0 && to > from &&
|
||||
int.TryParse(receivedData.Substring(from + 1, to - from - 1), out locPulses))
|
||||
toBeProcessed.Append(Encoding.ASCII.GetString(byteArray, 0, byteArray.Length));
|
||||
|
||||
while (true)
|
||||
{
|
||||
//wmPulses = locPulses;
|
||||
int from = toBeProcessed.ToString().IndexOf('[');
|
||||
if (from < 0) break;
|
||||
|
||||
int len = toBeProcessed.ToString(from + 1, toBeProcessed.Length - from - 1).IndexOf(']');
|
||||
if (len < 0) break;
|
||||
|
||||
string[] pulsesArr = toBeProcessed.ToString(from + 1, len).Split(new char[] { ';' });
|
||||
if (result != null && result.Length + 1 == pulsesArr.Length)
|
||||
{
|
||||
for (int i = 0; i < result.Length; i++)
|
||||
{
|
||||
int val;
|
||||
if (int.TryParse(pulsesArr[i + 1], out val)) result[i] = val;
|
||||
}
|
||||
}
|
||||
|
||||
toBeProcessed.Remove(0, from + len + 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user