diff --git a/TestBenchFramework/BenchControl/Cameras/IdcCamera/IdcCamera.cs b/TestBenchFramework/BenchControl/Cameras/IdcCamera/IdcCamera.cs index ebab1e41f..c5c5f54bd 100644 --- a/TestBenchFramework/BenchControl/Cameras/IdcCamera/IdcCamera.cs +++ b/TestBenchFramework/BenchControl/Cameras/IdcCamera/IdcCamera.cs @@ -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; diff --git a/TestBenchFramework/BenchControl/Events.cs b/TestBenchFramework/BenchControl/Events.cs index 498821138..4b2106e65 100644 --- a/TestBenchFramework/BenchControl/Events.cs +++ b/TestBenchFramework/BenchControl/Events.cs @@ -156,7 +156,8 @@ namespace TBF.BenchControl CameraBusy, CameraOpCompleted, CameraOpFailed, - DetectionFailed, + RoiDetectionPassed, + RoiDetectionFailed, /// Generic Error, /// Many ops.: Fatal error occurred diff --git a/TestBenchFramework/BenchControl/Network/Camera/RoI/RoiDetectionOp.cs b/TestBenchFramework/BenchControl/Network/Camera/RoI/RoiDetectionOp.cs index 3bcbe77db..2283adf7a 100644 --- a/TestBenchFramework/BenchControl/Network/Camera/RoI/RoiDetectionOp.cs +++ b/TestBenchFramework/BenchControl/Network/Camera/RoI/RoiDetectionOp.cs @@ -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; /// @@ -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; } } diff --git a/TestBenchFramework/BenchControl/TestMethods/CameraRoiDetection/RoiDetectionSeq.cs b/TestBenchFramework/BenchControl/TestMethods/CameraRoiDetection/RoiDetectionSeq.cs index 921780c3e..60b10c3c6 100644 --- a/TestBenchFramework/BenchControl/TestMethods/CameraRoiDetection/RoiDetectionSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/CameraRoiDetection/RoiDetectionSeq.cs @@ -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);