(1) StandardCamera.TestStartEndForm fixed (exclamation), (2) Simulate mode for camera with sample.bmp.

This commit is contained in:
Milan Hanajik 2019-09-21 15:08:39 +02:00
parent 688580c29f
commit 4fc427d875
6 changed files with 120 additions and 74 deletions

View File

@ -470,19 +470,22 @@ namespace TBF.BenchControl.DataEntry.StandardCamera
private void endTextBox24_TextChanged(object sender, EventArgs e) { UpdateExclamation(23); } private void endTextBox24_TextChanged(object sender, EventArgs e) { UpdateExclamation(23); }
/// ///
void UpdateExclamation(int uiCtrlPos) /// uiCtrlPos = 0 .. TextBoxesCount-1 void UpdateExclamation(int uiCtrlPos) /// uiCtrlPos = 0 .. TextBoxesCount-1
{
if ((mode == Tst.End) || (mode == Tst.Both))
{ {
try try
{ {
double startVolumeLtr = Utils.ParseUDouble(startTextBoxes[uiCtrlPos].Text) * regReaders[phys2wm[uiCtrlPos] - 1].LtrsPerPulse; 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 endVolumeLtr = Utils.ParseUDouble(endTextBoxes[uiCtrlPos].Text) * regReaders[phys2wm[uiCtrlPos] - 1].LtrsPerPulse;
double err = 100.0 * (endVolumeLtr - startVolumeLtr - refVolume) / refVolume; double err = 100.0 * (endVolumeLtr - startVolumeLtr - refVolume) / refVolume;
exclamations[uiCtrlPos].Visible = (err < warningLimLo) || (err > warningLimHi); exclamations[uiCtrlPos].Visible = (err < warningLimLo) || (warningLimHi < err);
} }
catch catch
{ {
exclamations[uiCtrlPos].Visible = false; exclamations[uiCtrlPos].Visible = false;
} }
} }
}
private void startTextBox1_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox1); } private void startTextBox1_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox1); }

View File

@ -32,9 +32,9 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
this.GetType().Namespace.Substring(17), this.GetType().Namespace.Substring(17),
CameraCfg.Name, CameraCfg.Name,
CameraCfg.HardwareAddress, CameraCfg.HardwareAddress,
ipAddress == null ? "not detected" : ipAddress.ToString(), CameraCfg.DebugLevel == DebugMode.Simulate ? "simulated" : ((ipAddress == null) ? "not detected" : ipAddress.ToString()),
string.IsNullOrEmpty(cpuSerialNr) ? "not detected" : cpuSerialNr, CameraCfg.DebugLevel == DebugMode.Simulate ? "simulated" : (string.IsNullOrEmpty(cpuSerialNr) ? "not detected" : cpuSerialNr),
string.IsNullOrEmpty(sdCardVer) ? "not detected" : sdCardVer); CameraCfg.DebugLevel == DebugMode.Simulate ? "simulated" : (string.IsNullOrEmpty(sdCardVer) ? "not detected" : sdCardVer));
} }
@ -161,13 +161,16 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
{ {
cameraIdx = GetCameraIdx(); 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 /// Detect a camera
bool cameraDetected = DetectCamera(CameraCfg.HardwareAddress % 100, ref ipAddress, true, bool cameraDetected = DetectCamera(CameraCfg.HardwareAddress % 100, ref ipAddress, true,
out cpuHardware, out cpuRevision, out cpuSerialNr, out sdCardVer); out cpuHardware, out cpuRevision, out cpuSerialNr, out sdCardVer);
if (CameraCfg.DebugLevel == DebugMode.AutoDetect) if (CameraCfg.DebugLevel == DebugMode.AutoDetect)
{ {
CameraCfg.DebugLevel = cameraDetected ? DebugMode.DetectedOn : DebugMode.DetectedOff; CameraCfg.DebugLevel = cameraDetected ? DebugMode.DetectedOn : DebugMode.DetectedOff;
@ -218,6 +221,8 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
} }
public void StopDevice() public void StopDevice()
{
if ((CameraCfg.DebugLevel != DebugMode.Simulate) && (CameraCfg.DebugLevel != DebugMode.DetectedOff))
{ {
running = false; running = false;
@ -230,9 +235,12 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
Telnet.Dispose(); Telnet.Dispose();
Telnet = null; Telnet = null;
} }
}
} }
public void StopDevice2() public void StopDevice2()
{
if ((CameraCfg.DebugLevel != DebugMode.Simulate) && (CameraCfg.DebugLevel != DebugMode.DetectedOff))
{ {
if (scpThread != null) scpThread.Join(50); if (scpThread != null) scpThread.Join(50);
if (rtpListenerThread != null) rtpListenerThread.Join(50); if (rtpListenerThread != null) rtpListenerThread.Join(50);
@ -249,9 +257,12 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
msrmntUdpClient.Close(); msrmntUdpClient.Close();
msrmntUdpClient = null; msrmntUdpClient = null;
} }
}
} }
public void RunDeviceBefore() public void RunDeviceBefore()
{
if ((CameraCfg.DebugLevel != DebugMode.Simulate) && (CameraCfg.DebugLevel != DebugMode.DetectedOff))
{ {
if (sha1sumResponse != null && !sha1sumResponseProcessed) if (sha1sumResponse != null && !sha1sumResponseProcessed)
{ {
@ -260,6 +271,7 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
sha1sumResponseProcessed = true; sha1sumResponseProcessed = true;
} }
}
} }
public void RunDeviceAfter() { } public void RunDeviceAfter() { }

View File

@ -50,10 +50,13 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
grabImageCommandSent = false; grabImageCommandSent = false;
transferringGrabbedImage = false; transferringGrabbedImage = false;
if (camera.DebugLevel == DebugMode.Normal || camera.DebugLevel == DebugMode.DetectedOn)
{
telnet.promptReceivedHandler += delegate(object sndr, PromptReceivedEventArgs a) telnet.promptReceivedHandler += delegate(object sndr, PromptReceivedEventArgs a)
{ {
OnPromptReceived(sndr, a); OnPromptReceived(sndr, a);
}; };
}
} }
void OnPromptReceived(object sndr, PromptReceivedEventArgs a) void OnPromptReceived(object sndr, PromptReceivedEventArgs a)
@ -65,33 +68,58 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
public void Start() public void Start()
{ {
if (camera.CameraCfg.DebugLevel == Config.Entities.DebugMode.Simulate) return;
grabImageCommandSent = false; grabImageCommandSent = false;
transferringGrabbedImage = 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() public Event Run()
{ {
if (camera.CameraCfg.DebugLevel == Config.Entities.DebugMode.Simulate) return Event.None; if ((imgFileNames == null) || (imgFileNames.Length < 1) || (imgFileNames[0] == null))
if (imgFileNames.Length < 1 || imgFileNames[0] == null)
{ {
///
/// No images to be grabbed => Done
///
return Event.GrabPassed;
}
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; return Event.GrabPassed;
} }
else if (!grabImageCommandSent) 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)) if (camera.Running && (telnet.State == TelnetClient.TelnetState.Inactive))
{ {
// ///
// State variables /// State variables
// ///
response = null; response = null;
// ///
// Prepare command /// Prepare a command
// ///
int rotation = 0; int rotation = 0;
if (imageRotation == ImageRotation.Deg90) if (imageRotation == ImageRotation.Deg90)
rotation = 90; rotation = 90;
@ -119,6 +147,9 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
} }
else if (grabPassed) else if (grabPassed)
{ {
///
/// Normal operation, grab passed => transfer/transferring the image
///
if (transferringGrabbedImage) if (transferringGrabbedImage)
{ {
/// Grab passed and image transfer is in progress /// Grab passed and image transfer is in progress
@ -138,11 +169,16 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
} }
else if (grabFailed) else if (grabFailed)
{ {
/// Grab failed, there in no image to transfer ///
/// Normal operation, grab failed => there in no image to transfer
///
return Event.GrabFailed; return Event.GrabFailed;
} }
else if (response != null) else if (response != null)
{ {
///
/// Normal operation
///
if (response.Contains("completed")) if (response.Contains("completed"))
{ {
grabPassed = true; grabPassed = true;

View File

@ -127,17 +127,11 @@ namespace TBF.BenchControl.Network.Camera.RoiForFixedStart
public IOperation GrabImageOp(string imageFileName) public IOperation GrabImageOp(string imageFileName)
{ {
if (NetCamera != null) return GrabImageOp(imageFileName, roiCfg.BlackAndWhite, roiCfg.LowResolution, roiCfg.ImageRotation);
{
/// 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;
} }
public IOperation GrabImageOp(string imageFileName, bool blackAndWhite, public IOperation GrabImageOp(string imageFileName,
bool lowResolution, Config.Entities.ImageRotation imageRotation) bool blackAndWhite, bool lowResolution, Config.Entities.ImageRotation imageRotation)
{ {
if (NetCamera != null) if (NetCamera != null)
{ {

BIN
TBF/Pictures/sample.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 900 KiB

View File

@ -3362,6 +3362,7 @@
<Content Include="Pictures\reversed_dir_right.jpg"> <Content Include="Pictures\reversed_dir_right.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content> </Content>
<Content Include="Pictures\sample.bmp" />
<Content Include="Resources\empty.png" /> <Content Include="Resources\empty.png" />
<Content Include="Resources\switch-off.png" /> <Content Include="Resources\switch-off.png" />
<Content Include="Resources\switch-on.png" /> <Content Include="Resources\switch-on.png" />