Bug fixes
This commit is contained in:
49
nbactions.xml
Normal file
49
nbactions.xml
Normal file
@@ -0,0 +1,49 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<actions>
|
||||
<action>
|
||||
<actionName>run</actionName>
|
||||
<packagings>
|
||||
<packaging>jar</packaging>
|
||||
</packagings>
|
||||
<goals>
|
||||
<goal>process-classes</goal>
|
||||
<goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
|
||||
</goals>
|
||||
<properties>
|
||||
<exec.args>-classpath %classpath ch.psi.pshell.ui.App -dlaf</exec.args>
|
||||
<exec.executable>java</exec.executable>
|
||||
<exec.workingdir>../../pshell</exec.workingdir>
|
||||
</properties>
|
||||
</action>
|
||||
<action>
|
||||
<actionName>debug</actionName>
|
||||
<packagings>
|
||||
<packaging>jar</packaging>
|
||||
</packagings>
|
||||
<goals>
|
||||
<goal>process-classes</goal>
|
||||
<goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
|
||||
</goals>
|
||||
<properties>
|
||||
<exec.args>-Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} -classpath %classpath ch.psi.pshell.ui.App -dlaf</exec.args>
|
||||
<exec.executable>java</exec.executable>
|
||||
<jpda.listen>true</jpda.listen>
|
||||
<exec.workingdir>../../pshell</exec.workingdir>
|
||||
</properties>
|
||||
</action>
|
||||
<action>
|
||||
<actionName>profile</actionName>
|
||||
<packagings>
|
||||
<packaging>jar</packaging>
|
||||
</packagings>
|
||||
<goals>
|
||||
<goal>process-classes</goal>
|
||||
<goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
|
||||
</goals>
|
||||
<properties>
|
||||
<exec.args>-classpath %classpath ch.psi.pshell.ui.App -dlaf</exec.args>
|
||||
<exec.executable>java</exec.executable>
|
||||
<exec.workingdir>../../pshell</exec.workingdir>
|
||||
</properties>
|
||||
</action>
|
||||
</actions>
|
||||
@@ -10,6 +10,7 @@ import ch.psi.pshell.device.ReadonlyRegisterBase;
|
||||
import ch.psi.pshell.imaging.Source.EmbeddedCameraSource;
|
||||
import ch.psi.pshell.imaging.SourceBase;
|
||||
import ch.psi.pshell.imaging.Renderer;
|
||||
import ch.psi.pshell.imaging.Utils;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
@@ -75,7 +76,6 @@ public class Prosilica extends SourceBase implements EmbeddedCameraSource {
|
||||
}
|
||||
}
|
||||
}
|
||||
setMonitored(true);
|
||||
}
|
||||
|
||||
void writePars() throws IOException {
|
||||
@@ -149,13 +149,25 @@ public class Prosilica extends SourceBase implements EmbeddedCameraSource {
|
||||
setState(State.Ready);
|
||||
writePars();
|
||||
camera.initialize();
|
||||
start();
|
||||
} catch (IOException ex) {
|
||||
getLogger().warning("Error opening the camera: " + ex.getMessage());
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doSetMonitored(boolean value) {
|
||||
try {
|
||||
if (value) {
|
||||
start();
|
||||
} else {
|
||||
stop();
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
getLogger().log(Level.WARNING, null, ex);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doClose() throws IOException {
|
||||
try {
|
||||
@@ -196,6 +208,8 @@ public class Prosilica extends SourceBase implements EmbeddedCameraSource {
|
||||
pushImage(null);
|
||||
Thread.sleep(1);
|
||||
cameraTimeout = false;
|
||||
camera.initialize();
|
||||
|
||||
this.format = null;
|
||||
Pv.tUint32 width = new Pv.tUint32();
|
||||
Pv.tUint32 height = new Pv.tUint32();
|
||||
@@ -213,8 +227,10 @@ public class Prosilica extends SourceBase implements EmbeddedCameraSource {
|
||||
switch (this.format) {
|
||||
case "Mono8":
|
||||
imageType = BufferedImage.TYPE_BYTE_GRAY;
|
||||
break;
|
||||
case "Mono16":
|
||||
imageType = BufferedImage.TYPE_USHORT_GRAY;
|
||||
break;
|
||||
default:
|
||||
imageType = BufferedImage.TYPE_3BYTE_BGR;
|
||||
}
|
||||
@@ -250,7 +266,6 @@ public class Prosilica extends SourceBase implements EmbeddedCameraSource {
|
||||
public void stop() throws IOException {
|
||||
assertInitialized();
|
||||
started = false;
|
||||
currentFrame = null;
|
||||
if (isStreaming()) {
|
||||
Pv.CommandRun(handle, "AcquisitionStop");
|
||||
Pv.CaptureQueueClear(handle);
|
||||
@@ -495,7 +510,6 @@ public class Prosilica extends SourceBase implements EmbeddedCameraSource {
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//Frame event callback
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
volatile Pv.tFrame currentFrame;
|
||||
final Pv.FrameListener frameListener = new Pv.FrameListener() {
|
||||
@Override
|
||||
public void onFrameEvent(Pv.tFrame frame) {
|
||||
@@ -503,10 +517,8 @@ public class Prosilica extends SourceBase implements EmbeddedCameraSource {
|
||||
if (started && (frame.Status != Pv.tError.eCancelled)) {
|
||||
BufferedImage img = getImageFromBuffer();
|
||||
if (convertFrameToImage(frame, img)) {
|
||||
currentFrame = frame;
|
||||
pushImage(img);
|
||||
} else {
|
||||
currentFrame = null;
|
||||
pushImage(null);
|
||||
}
|
||||
Pv.CaptureQueueFrame(handle, frame, this);
|
||||
@@ -578,24 +590,39 @@ public class Prosilica extends SourceBase implements EmbeddedCameraSource {
|
||||
return Prosilica.this.isStarted();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doInitialize() throws IOException, InterruptedException {
|
||||
super.doInitialize();
|
||||
colorMode = null;
|
||||
dataType = null;
|
||||
data.initialize();
|
||||
}
|
||||
|
||||
class ProsilicaData extends ReadonlyRegisterBase implements ReadonlyRegisterArray {
|
||||
|
||||
@Override
|
||||
protected Object doRead() throws IOException, InterruptedException {
|
||||
if (currentFrame != null) {
|
||||
if (currentFrame.ImageBuffer.hasArray()) {
|
||||
return currentFrame.ImageBuffer.array();
|
||||
synchronized (Prosilica.this) {
|
||||
BufferedImage image = getImage();
|
||||
if (image != null){
|
||||
if (image.getType() != BufferedImage.TYPE_BYTE_GRAY){
|
||||
image = Utils.grayscale(image);
|
||||
}
|
||||
byte[] data = ((java.awt.image.DataBufferByte) image.getRaster().getDataBuffer()).getData();
|
||||
byte[] ret = new byte[data.length];
|
||||
System.arraycopy(data, 0, ret, 0, data.length);
|
||||
return ret;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
if (currentFrame != null) {
|
||||
return (int) currentFrame.ImageSize;
|
||||
if ((imageBuffer == null) || (imageBuffer.length == 0)) {
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
return imageBuffer[0].getWidth() * imageBuffer[0].getHeight();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -663,35 +690,53 @@ public class Prosilica extends SourceBase implements EmbeddedCameraSource {
|
||||
return (Integer) readParameter("GainValue");
|
||||
}
|
||||
|
||||
Camera.DataType dataType;
|
||||
|
||||
@Override
|
||||
public void setDataType(DataType type) throws IOException, InterruptedException {
|
||||
setPixelFormat(getColorMode(), type);
|
||||
public void setDataType(Camera.DataType type) throws IOException, InterruptedException {
|
||||
dataType = type;
|
||||
setPixelFormat();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataType getDataType() throws IOException, InterruptedException {
|
||||
public Camera.DataType getDataType() throws IOException, InterruptedException {
|
||||
//TODO: Color mode is linked to EPICS.
|
||||
if (dataType!=null){
|
||||
return dataType;
|
||||
}
|
||||
switch ((String) readParameter("PixelFormat")) {
|
||||
case "Mono8":
|
||||
case "Bayer8":
|
||||
return DataType.UInt8;
|
||||
return Camera.DataType.UInt8;
|
||||
case "Mono16":
|
||||
case "Bayer16":
|
||||
return DataType.UInt16;
|
||||
return Camera.DataType.UInt16;
|
||||
case "Rgb24":
|
||||
case "Brg24":
|
||||
return DataType.Int24;
|
||||
return Camera.DataType.UInt24;
|
||||
case "Rgba32":
|
||||
case "Brga32":
|
||||
return DataType.Int32;
|
||||
return Camera.DataType.UInt32;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
void setPixelFormat(ColorMode mode, DataType type) throws IOException {
|
||||
void setPixelFormat() throws IOException, InterruptedException {
|
||||
String pixelFormat = null;
|
||||
switch (mode) {
|
||||
if (colorMode == null) {
|
||||
colorMode = getColorMode();
|
||||
if (colorMode == null) {
|
||||
throw new IOException("Invalid color mode");
|
||||
}
|
||||
}
|
||||
if (dataType == null) {
|
||||
dataType = getDataType();
|
||||
if (dataType == null) {
|
||||
throw new IOException("Invalid data type");
|
||||
}
|
||||
}
|
||||
switch (colorMode) {
|
||||
case Mono:
|
||||
pixelFormat = "Mono";
|
||||
break;
|
||||
@@ -705,7 +750,7 @@ public class Prosilica extends SourceBase implements EmbeddedCameraSource {
|
||||
pixelFormat = "Bayer";
|
||||
break;
|
||||
}
|
||||
switch (type.getSize()) {
|
||||
switch (dataType.getSize()) {
|
||||
case 1:
|
||||
pixelFormat += "8";
|
||||
break;
|
||||
@@ -722,26 +767,32 @@ public class Prosilica extends SourceBase implements EmbeddedCameraSource {
|
||||
writeParameter("PixelFormat", pixelFormat);
|
||||
}
|
||||
|
||||
Camera.ColorMode colorMode;
|
||||
|
||||
@Override
|
||||
public void setColorMode(ColorMode mode) throws IOException, InterruptedException {
|
||||
setPixelFormat(mode, getDataType());
|
||||
public void setColorMode(Camera.ColorMode mode) throws IOException, InterruptedException {
|
||||
colorMode = mode;
|
||||
setPixelFormat();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ColorMode getColorMode() throws IOException, InterruptedException {
|
||||
public Camera.ColorMode getColorMode() throws IOException, InterruptedException {
|
||||
if (colorMode!=null){
|
||||
return colorMode;
|
||||
}
|
||||
switch ((String) readParameter("PixelFormat")) {
|
||||
case "Mono8":
|
||||
case "Mono16":
|
||||
return ColorMode.Mono;
|
||||
return Camera.ColorMode.Mono;
|
||||
case "Rgb24":
|
||||
case "Rgba32":
|
||||
return ColorMode.RGB1;
|
||||
return Camera.ColorMode.RGB1;
|
||||
case "Brga24":
|
||||
case "Brga32":
|
||||
return ColorMode.RGB2;
|
||||
return Camera.ColorMode.RGB2;
|
||||
case "Bayer8":
|
||||
case "Bayer16":
|
||||
return ColorMode.RGB3;
|
||||
return Camera.ColorMode.RGB3;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
@@ -798,7 +849,7 @@ public class Prosilica extends SourceBase implements EmbeddedCameraSource {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGrabMode(GrabMode value) throws IOException, InterruptedException {
|
||||
public void setGrabMode(Camera.GrabMode value) throws IOException, InterruptedException {
|
||||
String acquisitionMode;
|
||||
switch (value) {
|
||||
case Continuous:
|
||||
@@ -817,14 +868,14 @@ public class Prosilica extends SourceBase implements EmbeddedCameraSource {
|
||||
}
|
||||
|
||||
@Override
|
||||
public GrabMode getGrabMode() throws IOException, InterruptedException {
|
||||
public Camera.GrabMode getGrabMode() throws IOException, InterruptedException {
|
||||
switch ((String) readParameter("AcquisitionMode")) {
|
||||
case "Continuous":
|
||||
return GrabMode.Continuous;
|
||||
return Camera.GrabMode.Continuous;
|
||||
case "SingleFrame":
|
||||
return GrabMode.Single;
|
||||
return Camera.GrabMode.Single;
|
||||
case "MultiFrame":
|
||||
return GrabMode.Multiple;
|
||||
return Camera.GrabMode.Multiple;
|
||||
case "Recorder":
|
||||
default:
|
||||
return null;
|
||||
@@ -832,7 +883,7 @@ public class Prosilica extends SourceBase implements EmbeddedCameraSource {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTriggerMode(TriggerMode value) throws IOException, InterruptedException {
|
||||
public void setTriggerMode(Camera.TriggerMode value) throws IOException, InterruptedException {
|
||||
String triggerMode = null;
|
||||
switch (value) {
|
||||
case Free_Run:
|
||||
@@ -852,16 +903,16 @@ public class Prosilica extends SourceBase implements EmbeddedCameraSource {
|
||||
}
|
||||
|
||||
@Override
|
||||
public TriggerMode getTriggerMode() throws IOException, InterruptedException {
|
||||
public Camera.TriggerMode getTriggerMode() throws IOException, InterruptedException {
|
||||
switch ((String) readParameter("FrameStartTriggerMode")) {
|
||||
case "Freerun":
|
||||
return TriggerMode.Free_Run;
|
||||
return Camera.TriggerMode.Free_Run;
|
||||
case "SyncIn1":
|
||||
return TriggerMode.External;
|
||||
return Camera.TriggerMode.External;
|
||||
case "Software":
|
||||
return TriggerMode.Software;
|
||||
return Camera.TriggerMode.Software;
|
||||
case "FixedRate":
|
||||
return TriggerMode.Fixed_Rate;
|
||||
return Camera.TriggerMode.Fixed_Rate;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user