Scienta test mode
This commit is contained in:
229
src/Scienta.java
229
src/Scienta.java
@@ -1,25 +1,14 @@
|
||||
|
||||
import ch.psi.jcae.ChannelException;
|
||||
import ch.psi.pshell.device.AccessType;
|
||||
import ch.psi.pshell.device.ArrayCalibration;
|
||||
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 ch.psi.pshell.device.Writable;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import ch.psi.pshell.epics.*;
|
||||
import static ch.psi.pshell.epics.Scienta.PASS_ENERGY_VALUES;
|
||||
import ch.psi.utils.Arr;
|
||||
import ch.psi.utils.Convert;
|
||||
import ch.psi.utils.State;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* Implementation of Scienta spectrometer analyser.
|
||||
@@ -31,8 +20,9 @@ public class Scienta extends AreaDetector {
|
||||
final ControlledVariable lowEnergy, centerEnergy, highEnergy, stepSize, lowThetaY, centerThetaY, highThetaY, stepSizeThetaY, centerThetaX;
|
||||
final ControlledVariable excitationEnergy;
|
||||
final GenericArray data;
|
||||
final ChannelInteger totalSteps, currentStep, exposuresComplete, acquisitionMode;
|
||||
final ChannelString lensMode, passEnergy, estTime, detectorState;
|
||||
final ChannelInteger totalSteps, currentStep, exposuresComplete;
|
||||
final DiscretePositioner lensMode, acquisitionMode, energyMode, detectorMode, elementSet, passEnergy;
|
||||
final ChannelString estTime, detectorState;
|
||||
final ChannelByteArray status;
|
||||
final ChannelInteger slices, slicesReadback, channels, channelsReadback;
|
||||
final Stats[] stats;
|
||||
@@ -81,9 +71,13 @@ public class Scienta extends AreaDetector {
|
||||
ThetaXCount = new ChannelInteger(name + " Theta count", channelCtrl + ":SLICE_COUNT_RBV", false);
|
||||
ThetaXCount.setAccessType(AccessType.Read);
|
||||
|
||||
passEnergy = new ChannelString(name + " pass energy", channelCtrl + ":PASS_ENERGY", false);
|
||||
lensMode = new ChannelString(name + " lens mode", channelCtrl + ":LENS_MODE", false);
|
||||
acquisitionMode = new ChannelInteger(name + " acquisition mode", channelCtrl + ":ACQ_MODE", false);
|
||||
passEnergy = new DiscretePositioner(name + " pass energy", channelCtrl + ":PASS_ENERGY", channelCtrl + ":PASS_ENERGY_RBV");
|
||||
lensMode = new DiscretePositioner(name + " lens mode", channelCtrl + ":LENS_MODE", channelCtrl + ":LENS_MODE_RBV");
|
||||
acquisitionMode = new DiscretePositioner(name + " acquisition mode", channelCtrl + ":ACQ_MODE", channelCtrl + ":ACQ_MODE_RBV");
|
||||
energyMode = new DiscretePositioner(name + " energy mode", channelCtrl + ":ENERGY_MODE", channelCtrl + ":ENERGY_MODE_RBV");
|
||||
detectorMode = new DiscretePositioner(name + " detector mode", channelCtrl + ":DETECTOR_MODE", channelCtrl + ":DETECTOR_MODE_RBV");
|
||||
elementSet = new DiscretePositioner(name + " element set", channelCtrl + ":ELEMENT_SET_RBV", channelCtrl + ":ELEMENT_SET_RBV");
|
||||
elementSet.setAccessType(AccessType.Read);
|
||||
|
||||
slices = new ChannelInteger(name + " slices", channelCtrl + ":SLICES", false);
|
||||
slicesReadback = new ChannelInteger(name + " slices rbv", channelCtrl + ":SLICES_RBV", false);
|
||||
@@ -106,14 +100,23 @@ public class Scienta extends AreaDetector {
|
||||
estTime.setAccessType(AccessType.Read);
|
||||
detectorState= new ChannelString(name + " detector state", channelCtrl + ":DetectorState_RBV", false);
|
||||
detectorState.setAccessType(AccessType.Read);
|
||||
status= new ChannelByteArray(name + " status", channelCtrl + ":StatusMessage_RBV");
|
||||
status= new ChannelByteArray(name + " status", channelCtrl + ":StatusMessage_RBV", -1, false){
|
||||
protected void onReadout(Object value){
|
||||
this.setCache((value==null)?"":new String((byte[])value));
|
||||
}
|
||||
//protected Object convertFromRead(byte[] value){
|
||||
// return (value==null) ? "" : new String((byte[])value);
|
||||
//}
|
||||
|
||||
};
|
||||
status.setAccessType(AccessType.Read);
|
||||
|
||||
monitoredChildren = new Device[]{acquire,
|
||||
lowEnergy,centerEnergy,highEnergy,energyWidth,energyCount,
|
||||
lowThetaY, centerThetaY, highThetaY, stepSizeThetaY, ThetaYWidth,ThetaYCount,
|
||||
lowThetaX, centerThetaX, highThetaX, stepSizeThetaX, ThetaXWidth,ThetaXCount,
|
||||
stepSize,totalSteps,currentStep, exposuresComplete, passEnergy, lensMode,acquisitionMode,
|
||||
stepSize,totalSteps,currentStep, exposuresComplete, passEnergy,
|
||||
lensMode, acquisitionMode, energyMode, detectorMode, elementSet,
|
||||
slices, slicesReadback, channels, channelsReadback, excitationEnergy,
|
||||
estTime, detectorState, status
|
||||
};
|
||||
@@ -141,17 +144,12 @@ public class Scienta extends AreaDetector {
|
||||
@Override
|
||||
protected void doSetSimulated() {
|
||||
super.doSetSimulated();
|
||||
setCache(passEnergy, String.valueOf(PASS_ENERGY_VALUES[0]));
|
||||
setCache(lensMode, LensMode.Transmission.toString());
|
||||
setCache(acquisitionMode, 0);
|
||||
|
||||
setSimulatedValue("ENERGY_MODE", EnergyMode.Binding.toString());
|
||||
setSimulatedValue("DETECTOR_MODE", DetectorMode.ADC.toString());
|
||||
setSimulatedValue("ELEMENT_SET", ElementSet.High_Pass_XPS.toString());
|
||||
setSimulatedValue("ACQ_MODE", AcquisitionMode.Fixed.toString());
|
||||
setSimulatedValue("LENS_MODE", LensMode.Transmission.toString());
|
||||
setSimulatedValue("PASS_ENERGY", String.valueOf(PASS_ENERGY_VALUES[0]));
|
||||
setSimulatedValue("ELEMENT_SET_RBV", ElementSet.High_Pass_XPS);
|
||||
setCache(passEnergy, "2");
|
||||
setCache(lensMode, "Transmission");
|
||||
setCache(acquisitionMode, "Fixed");
|
||||
setCache(energyMode, "Binding");
|
||||
setCache(detectorMode, "ADC");
|
||||
setCache(elementSet, "High_Pass_XPS");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -200,169 +198,86 @@ public class Scienta extends AreaDetector {
|
||||
}
|
||||
|
||||
//Modes
|
||||
public enum AcquisitionMode {
|
||||
Fixed,
|
||||
Swept_Energy,
|
||||
Swept_ThetaY,
|
||||
Swept_Energy_ThetaY
|
||||
|
||||
public void setAcquisitionMode(String mode) throws IOException, InterruptedException { //acquisitionMode.write(String.valueOf(mode).replaceAll("_", " "));
|
||||
acquisitionMode.write(mode);
|
||||
}
|
||||
|
||||
public void setAcquisitionMode(AcquisitionMode mode) throws IOException, InterruptedException {
|
||||
//acquisitionMode.write(String.valueOf(mode).replaceAll("_", " "));
|
||||
acquisitionMode.write(Arr.getIndex(AcquisitionMode.values(), (mode==null) ? 0 : mode));
|
||||
public String getAcquisitionMode() throws IOException, InterruptedException {
|
||||
return acquisitionMode.getValue();
|
||||
}
|
||||
|
||||
public AcquisitionMode getAcquisitionMode() throws IOException, InterruptedException {
|
||||
//String val = acquisitionMode.getValue();
|
||||
//return (AcquisitionMode) convertCtrlEnum(val, AcquisitionMode.class);
|
||||
try{
|
||||
int val = acquisitionMode.getValue();
|
||||
return AcquisitionMode.values()[val];
|
||||
} catch (Exception ex){
|
||||
return null;
|
||||
}
|
||||
public void setEnergyMode(String mode) throws IOException, InterruptedException {
|
||||
energyMode.write(mode);
|
||||
}
|
||||
|
||||
public enum EnergyMode {
|
||||
Binding,
|
||||
Kinetic
|
||||
public String getEnergyMode() throws IOException, InterruptedException {
|
||||
return energyMode.getValue();
|
||||
}
|
||||
|
||||
public void setEnergyMode(EnergyMode mode) throws IOException, InterruptedException {
|
||||
writeCtrlEnum("ENERGY_MODE", String.valueOf(mode));
|
||||
public void setLensMode(String mode) throws IOException, InterruptedException {
|
||||
lensMode.write(mode);
|
||||
}
|
||||
|
||||
public EnergyMode getEnergyMode() throws IOException, InterruptedException {
|
||||
return (EnergyMode) readCtrlEnum("ENERGY_MODE", EnergyMode.class);
|
||||
}
|
||||
|
||||
public enum LensMode {
|
||||
A14L_01,
|
||||
A14L_08,
|
||||
A30L_01,
|
||||
A30L_08,
|
||||
DA14L_01,
|
||||
DA14L_08,
|
||||
DA30L_01,
|
||||
DA30L_08,
|
||||
Transmission,
|
||||
Transmission_XPS
|
||||
public String getLensMode() throws IOException, InterruptedException {
|
||||
return lensMode.getValue();
|
||||
}
|
||||
|
||||
public enum LensModeTest {
|
||||
A14_01,
|
||||
A14_08,
|
||||
A30_01,
|
||||
A30_08,
|
||||
A7_08,
|
||||
DA14_01,
|
||||
DA14_08,
|
||||
DA30_01,
|
||||
DA30_08,
|
||||
DA7_08,
|
||||
Transmission,
|
||||
Transmission_XPS
|
||||
public String[] getLensModes() throws IOException, InterruptedException {
|
||||
return lensMode.getPositions();
|
||||
}
|
||||
|
||||
public Class getLensModeClass(){
|
||||
return test ? LensModeTest.class : LensMode.class;
|
||||
|
||||
public void setDetectorMode(String mode) throws IOException, InterruptedException {
|
||||
detectorMode.write(mode);
|
||||
}
|
||||
|
||||
public void setLensMode(Object mode) throws IOException, InterruptedException {
|
||||
//writeCtrlEnum("LENS_MODE", String.valueOf(mode));
|
||||
String m = mode.toString();
|
||||
lensMode.write(m.equals("Transmission_XPS") ? "Transmission XPS" : m);
|
||||
public String getDetectorMode() throws IOException, InterruptedException {
|
||||
return detectorMode.getValue();
|
||||
}
|
||||
|
||||
public Object getLensMode() throws IOException, InterruptedException {
|
||||
//return (LensMode) readCtrlEnum("LENS_MODE", LensMode.class);
|
||||
String val = lensMode.getValue();
|
||||
return convertCtrlEnum(val, LensMode.class);
|
||||
}
|
||||
|
||||
public enum DetectorMode {
|
||||
Pulse,
|
||||
ADC
|
||||
}
|
||||
|
||||
public void setDetectorMode(DetectorMode mode) throws IOException, InterruptedException {
|
||||
writeCtrlEnum("DETECTOR_MODE", String.valueOf(mode));
|
||||
}
|
||||
|
||||
public DetectorMode getDetectorMode() throws IOException, InterruptedException {
|
||||
return (DetectorMode) readCtrlEnum("DETECTOR_MODE", DetectorMode.class);
|
||||
}
|
||||
|
||||
public enum ElementSet {
|
||||
High_Pass_XPS,
|
||||
Low_Pass_UPS
|
||||
}
|
||||
|
||||
public void setElementSet(ElementSet mode) throws IOException, InterruptedException {
|
||||
public void setElementSet(String mode) throws IOException, InterruptedException {
|
||||
throw new IOException("Read-only value");
|
||||
//writeCtrlEnum("ELEMENT_SET", String.valueOf(mode));
|
||||
}
|
||||
|
||||
public ElementSet getElementSet() throws IOException, InterruptedException {
|
||||
return readCtrl("ELEMENT_SET_RBV", String.class).equals("High Pass (XPS)") ? ElementSet.High_Pass_XPS : ElementSet.Low_Pass_UPS;
|
||||
public String getElementSet() throws IOException, InterruptedException {
|
||||
return elementSet.getValue();
|
||||
}
|
||||
|
||||
public static final int[] PASS_ENERGY_VALUES = new int[]{1, 2, 5, 10, 20};
|
||||
|
||||
|
||||
public void setPassEnergy(int energy) throws IOException, InterruptedException {
|
||||
//writeCtrl("PASS_ENERGY", String.valueOf(energy));
|
||||
passEnergy.write(String.valueOf(energy));
|
||||
|
||||
setPassEnergy(String.valueOf(energy));
|
||||
}
|
||||
|
||||
public int getPassEnergy() throws IOException, InterruptedException {
|
||||
//String ret = (String) readCtrl("PASS_ENERGY", String.class);
|
||||
String ret = passEnergy.getValue();
|
||||
try {
|
||||
return Integer.valueOf(ret);
|
||||
} catch (Exception ex) {
|
||||
throw new DeviceInvalidParameterException("Pass Energy", ret);
|
||||
}
|
||||
public void setPassEnergy(String energy) throws IOException, InterruptedException {
|
||||
passEnergy.write(energy);
|
||||
}
|
||||
|
||||
public void zeroSupplies() throws IOException, InterruptedException {
|
||||
writeCtrl("ZERO_SUPPLIES", 1);
|
||||
public String getPassEnergy() throws IOException, InterruptedException {
|
||||
return passEnergy.getValue();
|
||||
}
|
||||
|
||||
public Writable getPassEnergyDev(){
|
||||
return (Writable) (Object value) -> {
|
||||
setPassEnergy(Integer.valueOf(String.valueOf(value)));
|
||||
};
|
||||
public DiscretePositioner getPassEnergyDev(){
|
||||
return passEnergy;
|
||||
}
|
||||
|
||||
public Writable getElementSetDev(){
|
||||
return (Writable) (Object value) -> {
|
||||
setElementSet(ElementSet.valueOf(String.valueOf(value)));
|
||||
};
|
||||
public DiscretePositioner getElementSetDev(){
|
||||
return elementSet;
|
||||
}
|
||||
|
||||
public Writable getDetectorModeDev(){
|
||||
return (Writable) (Object value) -> {
|
||||
setDetectorMode(DetectorMode.valueOf(String.valueOf(value)));
|
||||
};
|
||||
public DiscretePositioner getDetectorModeDev(){
|
||||
return detectorMode;
|
||||
}
|
||||
|
||||
public Writable getLensModeDev(){
|
||||
return (Writable) (Object value) -> {
|
||||
setLensMode(String.valueOf(value));
|
||||
};
|
||||
public DiscretePositioner getLensModeDev(){
|
||||
return lensMode;
|
||||
}
|
||||
|
||||
public Writable getAcquisitionModeDev(){
|
||||
return (Writable) (Object value) -> {
|
||||
setAcquisitionMode(AcquisitionMode.valueOf(String.valueOf(value)));
|
||||
};
|
||||
public DiscretePositioner getAcquisitionModeDev(){
|
||||
return acquisitionMode;
|
||||
}
|
||||
|
||||
public Writable getEnergyModeDev(){
|
||||
return (Writable) (Object value) -> {
|
||||
setEnergyMode(EnergyMode.valueOf(String.valueOf(value)));
|
||||
};
|
||||
public DiscretePositioner getEnergyModeDev(){
|
||||
return energyMode;
|
||||
}
|
||||
|
||||
public Writable getRangeDev(){
|
||||
@@ -385,6 +300,9 @@ public class Scienta extends AreaDetector {
|
||||
};
|
||||
}
|
||||
|
||||
public void zeroSupplies() throws IOException, InterruptedException {
|
||||
writeCtrl("ZERO_SUPPLIES", 1);
|
||||
}
|
||||
|
||||
|
||||
//Progress
|
||||
@@ -518,7 +436,8 @@ public class Scienta extends AreaDetector {
|
||||
|
||||
public ControlledVariable getExcitationEnergy() {
|
||||
return excitationEnergy;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public List<Double> getChannelRange() throws IOException, InterruptedException {
|
||||
ArrayList<Double> ret = new ArrayList<>();
|
||||
@@ -544,7 +463,7 @@ public class Scienta extends AreaDetector {
|
||||
ret.add(200.0);
|
||||
ret.add(400.0);
|
||||
} else {
|
||||
String lens=getLensMode().toString();
|
||||
String lens=getLensMode();
|
||||
if (lens.startsWith("D")){
|
||||
ret.add(lowThetaY.getReadback().getValue());
|
||||
ret.add(highThetaY.getReadback().getValue());
|
||||
|
||||
Reference in New Issue
Block a user