Link dwell time to number of frames (frames = dt/40ms)
This commit is contained in:
@@ -6,12 +6,14 @@ import ch.psi.pshell.device.CameraImageDescriptor;
|
||||
import ch.psi.pshell.device.MatrixCalibration;
|
||||
import ch.psi.pshell.device.Device;
|
||||
import ch.psi.pshell.device.DeviceAdapter;
|
||||
import ch.psi.pshell.device.DeviceListener;
|
||||
import ch.psi.pshell.device.Readable.ReadableCalibratedArray;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import ch.psi.pshell.epics.*;
|
||||
import ch.psi.utils.State;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@@ -123,6 +125,39 @@ public class Scienta extends AreaDetector {
|
||||
stats[3] = new Stats("CountsR4", 4);
|
||||
stats[4] = new Stats("Counts", 5);
|
||||
addChildren(stats);
|
||||
|
||||
stepTime.addListener(new DeviceAdapter() {
|
||||
@Override
|
||||
public void onValueChanged(Device device, Object value, Object former) {
|
||||
int time_ms = (int) (((Double) value) * 1000);
|
||||
Integer num_frames = time_ms / 40;
|
||||
if (num_frames != frames.take()){
|
||||
frames.writeAsync(num_frames);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onValueChanging(Device device, Object value, Object former) throws Exception {
|
||||
//Value must be multiple of 40ms
|
||||
int val_ms = (int) (((Double) value) * 1000);
|
||||
if ((val_ms % 40) != 0){
|
||||
throw new IOException("Value must be multiple of 40ms");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
frames.addListener(new DeviceAdapter() {
|
||||
@Override
|
||||
public void onValueChanged(Device device, Object value, Object former) {
|
||||
int num_frames = (Integer)value;
|
||||
int time_ms = num_frames * 40;
|
||||
Double time = ((double)time_ms) / 1000.0;
|
||||
if (time != stepTime.take()){
|
||||
stepTime.writeAsync(time);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public class ScientaSpectrum extends ChannelDoubleArray implements ReadableCalibratedArray<double[]> {
|
||||
|
||||
@@ -43,6 +43,10 @@ public final class ScientaPanel extends DevicePanel {
|
||||
} else if (origin == valueHigh) {
|
||||
getDevice().getHighEnergy().writeAsync(value);
|
||||
} else if (origin == valueTime) {
|
||||
int val_ms = (int) (((Double) value) * 1000);
|
||||
if ((val_ms % 40) != 0){
|
||||
throw new IOException("Value must be multiple of 40ms");
|
||||
}
|
||||
getDevice().getStepTime().writeAsync(value);
|
||||
} else if (origin == valueSize) {
|
||||
getDevice().getStepSize().writeAsync(value);
|
||||
|
||||
Reference in New Issue
Block a user