RoI detection fixed : parses the command line response, returns Event.RoiDetectionPassed or Event.RoiDetectionFailed.
This commit is contained in:
parent
08acc5778a
commit
8e058cebbb
@ -272,7 +272,7 @@ namespace TBF.BenchControl.Cameras.IdcCamera
|
||||
else if (Idc100.IdcState == IdcState.DetectionFailed)
|
||||
{
|
||||
log.WarnFormat("{0}: {1} - DetectionFailed", cameraNr, currentOp);
|
||||
return Event.DetectionFailed;
|
||||
return Event.RoiDetectionFailed;
|
||||
}
|
||||
else return Event.Error;
|
||||
|
||||
|
||||
@ -156,7 +156,8 @@ namespace TBF.BenchControl
|
||||
CameraBusy,
|
||||
CameraOpCompleted,
|
||||
CameraOpFailed,
|
||||
DetectionFailed,
|
||||
RoiDetectionPassed,
|
||||
RoiDetectionFailed,
|
||||
|
||||
/// Generic
|
||||
Error, /// Many ops.: Fatal error occurred
|
||||
|
||||
@ -10,12 +10,15 @@ namespace TBF.BenchControl.Network.Camera.RoI
|
||||
|
||||
bool roiDetectionCommandSent;
|
||||
|
||||
string response;
|
||||
bool passed;
|
||||
bool failed;
|
||||
|
||||
Boxes.IntBox oroiX;
|
||||
Boxes.IntBox oroiY;
|
||||
Boxes.IntBox oroiWid;
|
||||
Boxes.IntBox oroiHgh;
|
||||
|
||||
string response;
|
||||
|
||||
|
||||
/// <summary>
|
||||
@ -36,16 +39,14 @@ namespace TBF.BenchControl.Network.Camera.RoI
|
||||
this.oroiWid = oroiWid;
|
||||
this.oroiHgh = oroiHgh;
|
||||
|
||||
roiDetectionCommandSent = false;
|
||||
response = null;
|
||||
passed = false;
|
||||
failed = false;
|
||||
|
||||
telnet.promptReceivedHandler += delegate(object sndr, PromptReceivedEventArgs args)
|
||||
{
|
||||
if (Program.MainWnd.InvokeRequired)
|
||||
{
|
||||
Program.MainWnd.Invoke(new Telnet.TelnetClient.PromptReceivedEventHandler(OnPromptReceived), sndr, args);
|
||||
}
|
||||
else
|
||||
{
|
||||
OnPromptReceived(sndr, args);
|
||||
}
|
||||
OnPromptReceived(sndr, args);
|
||||
};
|
||||
}
|
||||
|
||||
@ -66,6 +67,8 @@ namespace TBF.BenchControl.Network.Camera.RoI
|
||||
if (telnet.State == TelnetClient.TelnetState.Inactive)
|
||||
{
|
||||
response = null;
|
||||
passed = false;
|
||||
failed = false;
|
||||
telnet.Enqueue(new Telnet.Command(Telnet.CmdAction.CLEAR_RESPONSE));
|
||||
telnet.Enqueue(new Telnet.Command(Telnet.CmdAction.SEND_COMMAND, command));
|
||||
roiDetectionCommandSent = true;
|
||||
@ -73,13 +76,49 @@ namespace TBF.BenchControl.Network.Camera.RoI
|
||||
|
||||
return Event.Busy;
|
||||
}
|
||||
else if (response == null)
|
||||
else if (passed)
|
||||
{
|
||||
return Event.Busy;
|
||||
return Event.RoiDetectionPassed;
|
||||
}
|
||||
else if (failed)
|
||||
{
|
||||
return Event.RoiDetectionFailed;
|
||||
}
|
||||
else if (response != null)
|
||||
{
|
||||
int from = response.IndexOf('[');
|
||||
int to = response.IndexOf(']');
|
||||
if (!response.Contains("RESULT=0\r\n") || from < 0 || to < 0 || to < from)
|
||||
{
|
||||
failed = true;
|
||||
return Event.RoiDetectionFailed;
|
||||
}
|
||||
else
|
||||
{
|
||||
string oroiStr = response.Substring(from + 1, to - from - 1);
|
||||
string[] terms = oroiStr.Split(new char[] { ',' });
|
||||
int x, y, w, h;
|
||||
if (terms.Length != 5 || !int.TryParse(terms[0], out x) || !int.TryParse(terms[1], out y)
|
||||
|| !int.TryParse(terms[2], out w) || !int.TryParse(terms[3], out h))
|
||||
{
|
||||
failed = true;
|
||||
return Event.RoiDetectionFailed;
|
||||
}
|
||||
else
|
||||
{
|
||||
oroiX.Val = x;
|
||||
oroiY.Val = y;
|
||||
oroiWid.Val = w;
|
||||
oroiHgh.Val = h;
|
||||
|
||||
passed = true;
|
||||
return Event.RoiDetectionPassed;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return Event.Done;
|
||||
return Event.Busy;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -117,7 +117,7 @@ namespace TBF.BenchControl.TestMethods.CameraRoiDetection
|
||||
Bridge.OnActivity(this, Strings.Camera_error);
|
||||
goto stopTest;
|
||||
}
|
||||
else if (e.Contains(Event.DetectionFailed))
|
||||
else if (e.Contains(Event.RoiDetectionFailed))
|
||||
{
|
||||
retVal = Event.Error;
|
||||
Bridge.OnActivity(this, Strings.Detection_failed);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user