diff --git a/TBF/BenchControl/DataEntry/StandardCamera/TestStartEndForm.cs b/TBF/BenchControl/DataEntry/StandardCamera/TestStartEndForm.cs index ed79e71e9..59ce34d32 100644 --- a/TBF/BenchControl/DataEntry/StandardCamera/TestStartEndForm.cs +++ b/TBF/BenchControl/DataEntry/StandardCamera/TestStartEndForm.cs @@ -471,17 +471,20 @@ namespace TBF.BenchControl.DataEntry.StandardCamera /// void UpdateExclamation(int uiCtrlPos) /// uiCtrlPos = 0 .. TextBoxesCount-1 { - try - { - double startVolumeLtr = Utils.ParseUDouble(startTextBoxes[uiCtrlPos].Text) * regReaders[phys2wm[uiCtrlPos] - 1].LtrsPerPulse; - double endVolumeLtr = Utils.ParseUDouble(endTextBoxes[uiCtrlPos].Text) * regReaders[phys2wm[uiCtrlPos] - 1].LtrsPerPulse; - double err = 100.0 * (endVolumeLtr - startVolumeLtr - refVolume) / refVolume; - exclamations[uiCtrlPos].Visible = (err < warningLimLo) || (err > warningLimHi); - } - catch - { - exclamations[uiCtrlPos].Visible = false; - } + if ((mode == Tst.End) || (mode == Tst.Both)) + { + try + { + double startVolumeLtr = Utils.ParseUDouble(startTextBoxes[uiCtrlPos].Text) * regReaders[phys2wm[uiCtrlPos] - 1].LtrsPerPulse; + double endVolumeLtr = Utils.ParseUDouble(endTextBoxes[uiCtrlPos].Text) * regReaders[phys2wm[uiCtrlPos] - 1].LtrsPerPulse; + double err = 100.0 * (endVolumeLtr - startVolumeLtr - refVolume) / refVolume; + exclamations[uiCtrlPos].Visible = (err < warningLimLo) || (warningLimHi < err); + } + catch + { + exclamations[uiCtrlPos].Visible = false; + } + } } diff --git a/TBF/BenchControl/Network/Camera/CLP1611/Camera.cs b/TBF/BenchControl/Network/Camera/CLP1611/Camera.cs index 0fa132c64..311b9122a 100644 --- a/TBF/BenchControl/Network/Camera/CLP1611/Camera.cs +++ b/TBF/BenchControl/Network/Camera/CLP1611/Camera.cs @@ -32,9 +32,9 @@ namespace TBF.BenchControl.Network.Camera.CLP1611 this.GetType().Namespace.Substring(17), CameraCfg.Name, CameraCfg.HardwareAddress, - ipAddress == null ? "not detected" : ipAddress.ToString(), - string.IsNullOrEmpty(cpuSerialNr) ? "not detected" : cpuSerialNr, - string.IsNullOrEmpty(sdCardVer) ? "not detected" : sdCardVer); + CameraCfg.DebugLevel == DebugMode.Simulate ? "simulated" : ((ipAddress == null) ? "not detected" : ipAddress.ToString()), + CameraCfg.DebugLevel == DebugMode.Simulate ? "simulated" : (string.IsNullOrEmpty(cpuSerialNr) ? "not detected" : cpuSerialNr), + CameraCfg.DebugLevel == DebugMode.Simulate ? "simulated" : (string.IsNullOrEmpty(sdCardVer) ? "not detected" : sdCardVer)); } @@ -161,13 +161,16 @@ namespace TBF.BenchControl.Network.Camera.CLP1611 { cameraIdx = GetCameraIdx(); - if (CameraCfg.DebugLevel == DebugMode.Simulate) return; + if (CameraCfg.DebugLevel == DebugMode.Simulate) + { + UiBridge.Bridge.OnCameraInfo(this.cameraIdx, string.Format("{0} s/n {1} si simulated", Name, CameraCfg.HardwareAddress)); + return; + } /// Detect a camera bool cameraDetected = DetectCamera(CameraCfg.HardwareAddress % 100, ref ipAddress, true, out cpuHardware, out cpuRevision, out cpuSerialNr, out sdCardVer); - if (CameraCfg.DebugLevel == DebugMode.AutoDetect) { CameraCfg.DebugLevel = cameraDetected ? DebugMode.DetectedOn : DebugMode.DetectedOff; @@ -219,46 +222,55 @@ namespace TBF.BenchControl.Network.Camera.CLP1611 public void StopDevice() { - running = false; + if ((CameraCfg.DebugLevel != DebugMode.Simulate) && (CameraCfg.DebugLevel != DebugMode.DetectedOff)) + { + running = false; - stopScpThreadFlag = true; - stopRtpListenerFlag = true; - stopMsrmntListenerFlag = true; + stopScpThreadFlag = true; + stopRtpListenerFlag = true; + stopMsrmntListenerFlag = true; - if (Telnet != null) - { - Telnet.Dispose(); - Telnet = null; - } + if (Telnet != null) + { + Telnet.Dispose(); + Telnet = null; + } + } } public void StopDevice2() { - if (scpThread != null) scpThread.Join(50); - if (rtpListenerThread != null) rtpListenerThread.Join(50); - if (msrmntListenerThread != null) msrmntListenerThread.Join(50); + if ((CameraCfg.DebugLevel != DebugMode.Simulate) && (CameraCfg.DebugLevel != DebugMode.DetectedOff)) + { + if (scpThread != null) scpThread.Join(50); + if (rtpListenerThread != null) rtpListenerThread.Join(50); + if (msrmntListenerThread != null) msrmntListenerThread.Join(50); - if (rtpUdpClient != null) - { - rtpUdpClient.Close(); - rtpUdpClient = null; - } + if (rtpUdpClient != null) + { + rtpUdpClient.Close(); + rtpUdpClient = null; + } - if (msrmntUdpClient != null) - { - msrmntUdpClient.Close(); - msrmntUdpClient = null; - } + if (msrmntUdpClient != null) + { + msrmntUdpClient.Close(); + msrmntUdpClient = null; + } + } } public void RunDeviceBefore() { - if (sha1sumResponse != null && !sha1sumResponseProcessed) - { - scpThread = new Thread(new ThreadStart(ScpWorker)); - scpThread.Start(); - - sha1sumResponseProcessed = true; + if ((CameraCfg.DebugLevel != DebugMode.Simulate) && (CameraCfg.DebugLevel != DebugMode.DetectedOff)) + { + if (sha1sumResponse != null && !sha1sumResponseProcessed) + { + scpThread = new Thread(new ThreadStart(ScpWorker)); + scpThread.Start(); + + sha1sumResponseProcessed = true; + } } } public void RunDeviceAfter() { } diff --git a/TBF/BenchControl/Network/Camera/CLP1611/GrabImagesOp.cs b/TBF/BenchControl/Network/Camera/CLP1611/GrabImagesOp.cs index 168441732..4c39f8b47 100644 --- a/TBF/BenchControl/Network/Camera/CLP1611/GrabImagesOp.cs +++ b/TBF/BenchControl/Network/Camera/CLP1611/GrabImagesOp.cs @@ -50,10 +50,13 @@ namespace TBF.BenchControl.Network.Camera.CLP1611 grabImageCommandSent = false; transferringGrabbedImage = false; - telnet.promptReceivedHandler += delegate(object sndr, PromptReceivedEventArgs a) - { - OnPromptReceived(sndr, a); - }; + if (camera.DebugLevel == DebugMode.Normal || camera.DebugLevel == DebugMode.DetectedOn) + { + telnet.promptReceivedHandler += delegate(object sndr, PromptReceivedEventArgs a) + { + OnPromptReceived(sndr, a); + }; + } } void OnPromptReceived(object sndr, PromptReceivedEventArgs a) @@ -65,33 +68,58 @@ namespace TBF.BenchControl.Network.Camera.CLP1611 public void Start() { - if (camera.CameraCfg.DebugLevel == Config.Entities.DebugMode.Simulate) return; - grabImageCommandSent = false; transferringGrabbedImage = false; - if (File.Exists(imgFileNames[0])) File.Delete(imgFileNames[0]); + + if ((imgFileNames != null) && (imgFileNames.Length > 0) && File.Exists(imgFileNames[0])) + { + /// + /// An image specified, (1) delete previous image, (2) check if this is a simulation + /// + File.Delete(imgFileNames[0]); + + if (camera.CameraCfg.DebugLevel == Config.Entities.DebugMode.Simulate || camera.CameraCfg.DebugLevel == Config.Entities.DebugMode.DetectedOff) + { + /// + /// Camera is in simulation mode => create a simulated image + /// + File.Copy(string.Format("{0}\\Pictures\\sample.jpg", Program.ExecutableDir), imgFileNames[0]); + } + } } public Event Run() { - if (camera.CameraCfg.DebugLevel == Config.Entities.DebugMode.Simulate) return Event.None; - - if (imgFileNames.Length < 1 || imgFileNames[0] == null) + if ((imgFileNames == null) || (imgFileNames.Length < 1) || (imgFileNames[0] == null)) { - return Event.GrabPassed; + /// + /// No images to be grabbed => Done + /// + return Event.GrabPassed; } - else if (!grabImageCommandSent) + else if (camera.CameraCfg.DebugLevel == Config.Entities.DebugMode.Simulate || + camera.CameraCfg.DebugLevel == Config.Entities.DebugMode.DetectedOff) + { + /// + /// Camera is in simulation mode => create a simulated image and complete + /// + return Event.GrabPassed; + } + else if (!grabImageCommandSent) { + /// + /// Normal operation, no command sent yet => (1) wait until telnet state = Inactive, (2) send a command + /// if (camera.Running && (telnet.State == TelnetClient.TelnetState.Inactive)) { - // - // State variables - // + /// + /// State variables + /// response = null; - // - // Prepare command - // + /// + /// Prepare a command + /// int rotation = 0; if (imageRotation == ImageRotation.Deg90) rotation = 90; @@ -119,7 +147,10 @@ namespace TBF.BenchControl.Network.Camera.CLP1611 } else if (grabPassed) { - if (transferringGrabbedImage) + /// + /// Normal operation, grab passed => transfer/transferring the image + /// + if (transferringGrabbedImage) { /// Grab passed and image transfer is in progress return Event.GrabPassed; @@ -138,12 +169,17 @@ namespace TBF.BenchControl.Network.Camera.CLP1611 } else if (grabFailed) { - /// Grab failed, there in no image to transfer + /// + /// Normal operation, grab failed => there in no image to transfer + /// return Event.GrabFailed; } else if (response != null) { - if (response.Contains("completed")) + /// + /// Normal operation + /// + if (response.Contains("completed")) { grabPassed = true; diff --git a/TBF/BenchControl/Network/Camera/RoiForFixedStart/Roi.cs b/TBF/BenchControl/Network/Camera/RoiForFixedStart/Roi.cs index 6038ae5fc..393ffde79 100644 --- a/TBF/BenchControl/Network/Camera/RoiForFixedStart/Roi.cs +++ b/TBF/BenchControl/Network/Camera/RoiForFixedStart/Roi.cs @@ -127,17 +127,11 @@ namespace TBF.BenchControl.Network.Camera.RoiForFixedStart public IOperation GrabImageOp(string imageFileName) { - if (NetCamera != null) - { - /// TODO: Implement support for sharing one camera by multiple ROI-s - return NetCamera.GrabImagesOp(new string[] { imageFileName }, roiCfg.BlackAndWhite, roiCfg.LowResolution, roiCfg.ImageRotation); - } - else - return null; + return GrabImageOp(imageFileName, roiCfg.BlackAndWhite, roiCfg.LowResolution, roiCfg.ImageRotation); } - public IOperation GrabImageOp(string imageFileName, bool blackAndWhite, - bool lowResolution, Config.Entities.ImageRotation imageRotation) + public IOperation GrabImageOp(string imageFileName, + bool blackAndWhite, bool lowResolution, Config.Entities.ImageRotation imageRotation) { if (NetCamera != null) { diff --git a/TBF/Pictures/sample.bmp b/TBF/Pictures/sample.bmp new file mode 100644 index 000000000..e535bdd33 Binary files /dev/null and b/TBF/Pictures/sample.bmp differ diff --git a/TBF/TBF.csproj b/TBF/TBF.csproj index cc2485f4f..8a753a302 100644 --- a/TBF/TBF.csproj +++ b/TBF/TBF.csproj @@ -3362,6 +3362,7 @@ Always +