Fixed re-initialization and continuous/single shot selection
This commit is contained in:
2
pom.xml
2
pom.xml
@@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>ch.psi</groupId>
|
||||
<artifactId>prosilica</artifactId>
|
||||
<version>1.0.2</version>
|
||||
<version>1.0.3</version>
|
||||
<packaging>jar</packaging>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
|
||||
@@ -115,7 +115,7 @@ public class Prosilica extends SourceBase implements EmbeddedCameraSource {
|
||||
if (hasCamera(uid)){
|
||||
openCamera(uid);
|
||||
writePars();
|
||||
start();
|
||||
start();
|
||||
setState(State.Ready);
|
||||
getLogger().info("Successfully restarted camera");
|
||||
}
|
||||
@@ -195,6 +195,7 @@ public class Prosilica extends SourceBase implements EmbeddedCameraSource {
|
||||
writePars();
|
||||
setState(State.Ready);
|
||||
camera.initialize();
|
||||
start();
|
||||
} catch (IOException ex) {
|
||||
getLogger().warning("Error opening the camera: " + ex.getMessage());
|
||||
throw ex;
|
||||
@@ -204,10 +205,15 @@ public class Prosilica extends SourceBase implements EmbeddedCameraSource {
|
||||
@Override
|
||||
protected void doSetMonitored(boolean value) {
|
||||
try {
|
||||
setTimeout(-1);
|
||||
if (value) {
|
||||
start();
|
||||
writeParameter("AcquisitionMode", "Continuous");
|
||||
if (Pv.CommandRun(handle, "AcquisitionStart") != Pv.tError.eSuccess) {
|
||||
throw new IOException("Error starting acquisition");
|
||||
}
|
||||
setTimeout(10000);
|
||||
} else {
|
||||
stop();
|
||||
writeParameter("AcquisitionMode", "SingleFrame");
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
getLogger().log(Level.WARNING, null, ex);
|
||||
@@ -223,10 +229,6 @@ public class Prosilica extends SourceBase implements EmbeddedCameraSource {
|
||||
synchronized(instances){
|
||||
instances.remove(this);
|
||||
}
|
||||
try {
|
||||
stop();
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
try {
|
||||
closeCamera();
|
||||
} catch (Exception ex) {
|
||||
@@ -306,16 +308,26 @@ public class Prosilica extends SourceBase implements EmbeddedCameraSource {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (Pv.CommandRun(handle, "AcquisitionStart") != Pv.tError.eSuccess) {
|
||||
throw new IOException("Error startic acquisition");
|
||||
doSetMonitored(isMonitored());
|
||||
started = true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void doUpdate() throws IOException, InterruptedException {
|
||||
if ("SingleFrame".equals(readParameter("AcquisitionMode"))){
|
||||
if (Pv.CommandRun(handle, "AcquisitionStart") != Pv.tError.eSuccess) {
|
||||
throw new IOException("Error starting acquisition");
|
||||
}
|
||||
}
|
||||
started = true;
|
||||
setTimeout(10000);
|
||||
}
|
||||
|
||||
public void stop() throws IOException {
|
||||
assertInitialized();
|
||||
doStop();
|
||||
}
|
||||
|
||||
protected void doStop() throws IOException {
|
||||
setTimeout(-1);
|
||||
started = false;
|
||||
if (isStreaming()) {
|
||||
@@ -323,7 +335,7 @@ public class Prosilica extends SourceBase implements EmbeddedCameraSource {
|
||||
Pv.CaptureQueueClear(handle);
|
||||
Pv.CaptureEnd(handle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isStarted() {
|
||||
return started;
|
||||
@@ -448,7 +460,7 @@ public class Prosilica extends SourceBase implements EmbeddedCameraSource {
|
||||
if (handle != null) {
|
||||
getLogger().info("Close camera " + String.valueOf(this.currentUid));
|
||||
try {
|
||||
stop();
|
||||
doStop();
|
||||
} catch (Exception ex) {
|
||||
getLogger().log(Level.WARNING, null, ex);
|
||||
}
|
||||
@@ -921,12 +933,15 @@ public class Prosilica extends SourceBase implements EmbeddedCameraSource {
|
||||
String acquisitionMode;
|
||||
switch (value) {
|
||||
case Continuous:
|
||||
Prosilica.this.setMonitored(true);
|
||||
acquisitionMode = "Continuous";
|
||||
break;
|
||||
case Single:
|
||||
Prosilica.this.setMonitored(false);
|
||||
acquisitionMode = "SingleFrame";
|
||||
break;
|
||||
case Multiple:
|
||||
Prosilica.this.setMonitored(false);
|
||||
acquisitionMode = "MultiFrame";
|
||||
break;
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user