ProcessVariable extends ReadonlyProcessVariable
This commit is contained in:
147
src/Scienta.java
147
src/Scienta.java
@@ -8,11 +8,15 @@ 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;
|
||||
@@ -38,7 +42,7 @@ public class Scienta extends AreaDetector {
|
||||
public Scienta(final String name, final String channelPrefix) {
|
||||
this(name, channelPrefix + ":cam1", channelPrefix + ":image1");
|
||||
}
|
||||
|
||||
|
||||
public Scienta(String name, String channelCtrl, String channelData) {
|
||||
super(name, channelCtrl, channelData);
|
||||
this.channelCtrl = channelCtrl;
|
||||
@@ -132,6 +136,27 @@ 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, ch.psi.pshell.epics.Scienta.AcquisitionMode.Fixed.toString());
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doInitialize() throws IOException, InterruptedException {
|
||||
super.doInitialize();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doUpdate() throws IOException, InterruptedException {
|
||||
super.doUpdate();
|
||||
@@ -190,7 +215,6 @@ public class Scienta extends AreaDetector {
|
||||
}
|
||||
|
||||
public enum EnergyMode {
|
||||
|
||||
Binding,
|
||||
Kinetic
|
||||
}
|
||||
@@ -278,6 +302,64 @@ public class Scienta extends AreaDetector {
|
||||
public void zeroSupplies() throws IOException, InterruptedException {
|
||||
writeCtrl("ZERO_SUPPLIES", 1);
|
||||
}
|
||||
|
||||
public Writable getPassEnergyDev(){
|
||||
return (Writable) (Object value) -> {
|
||||
setPassEnergy(Integer.valueOf(String.valueOf(value)));
|
||||
};
|
||||
}
|
||||
|
||||
public Writable getElementSetDev(){
|
||||
return (Writable) (Object value) -> {
|
||||
setElementSet(ElementSet.valueOf(String.valueOf(value)));
|
||||
};
|
||||
}
|
||||
|
||||
public Writable getDetectorModeDev(){
|
||||
return (Writable) (Object value) -> {
|
||||
setDetectorMode(DetectorMode.valueOf(String.valueOf(value)));
|
||||
};
|
||||
}
|
||||
|
||||
public Writable getLensModeDev(){
|
||||
return (Writable) (Object value) -> {
|
||||
setLensMode(LensMode.valueOf(String.valueOf(value)));
|
||||
};
|
||||
}
|
||||
|
||||
public Writable getAcquisitionModeDev(){
|
||||
return (Writable) (Object value) -> {
|
||||
setAcquisitionMode(AcquisitionMode.valueOf(String.valueOf(value)));
|
||||
};
|
||||
}
|
||||
|
||||
public Writable getEnergyModeDev(){
|
||||
return (Writable) (Object value) -> {
|
||||
setEnergyMode(EnergyMode.valueOf(String.valueOf(value)));
|
||||
};
|
||||
}
|
||||
|
||||
public Writable getRangeDev(){
|
||||
return (Writable) (Object value) -> {
|
||||
Integer[] range = (Integer[]) value;
|
||||
int[] roi = getROI();
|
||||
if ((range[0]!=null) && (range[1]!=null)){
|
||||
int from = Math.min(range[0], range[1]);
|
||||
int to = Math.max(range[0], range[1]);
|
||||
roi[0]=from;
|
||||
roi[2]=(to-from);
|
||||
}
|
||||
if ((range[2]!=null) && (range[3]!=null)){
|
||||
int from = Math.min(range[2], range[3]);
|
||||
int to = Math.max(range[2], range[3]);
|
||||
roi[1]=from;
|
||||
roi[3]=(to-from);
|
||||
}
|
||||
setROI(roi);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Progress
|
||||
//Disconnected operations
|
||||
@@ -414,52 +496,45 @@ public class Scienta extends AreaDetector {
|
||||
|
||||
public List<Double> getChannelRange() throws IOException, InterruptedException {
|
||||
ArrayList<Double> ret = new ArrayList<>();
|
||||
switch (getAcquisitionMode()) {
|
||||
case Fixed:
|
||||
double eCenter = centerEnergy.getValue();
|
||||
int ePass = getPassEnergy();
|
||||
double xe = 0.04464;
|
||||
double xn = 0.04464;
|
||||
ret.add(eCenter - xe * ePass);
|
||||
ret.add(eCenter + xn * ePass);
|
||||
break;
|
||||
default:
|
||||
try {
|
||||
if (isSimulated()){
|
||||
ret.add(100.0);
|
||||
ret.add(200.0);
|
||||
} else {
|
||||
ret.add(lowEnergy.getValue());
|
||||
ret.add(highEnergy.getValue());
|
||||
break;
|
||||
|
||||
}
|
||||
ret.add(highEnergy.getValue());
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ret.add(Double.NaN);
|
||||
ret.add(Double.NaN);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public List<Double> getSliceRange() throws IOException, InterruptedException {
|
||||
ArrayList<Double> ret = new ArrayList<>();
|
||||
//ret.add(sliceBegin.getValue());
|
||||
//ret.add(sliceEnd.getValue());
|
||||
try {
|
||||
switch (getLensMode()) {
|
||||
//TODO:
|
||||
/*
|
||||
case Angular45:
|
||||
ret.add(-28.148);
|
||||
ret.add(27.649);
|
||||
break;
|
||||
case Angular60:
|
||||
ret.add(-34.736);
|
||||
ret.add(34.119);
|
||||
break;
|
||||
*/
|
||||
case Transmission:
|
||||
default:
|
||||
ret.add(-2.332);
|
||||
ret.add(2.291);
|
||||
break;
|
||||
if (isSimulated()){
|
||||
ret.add(200.0);
|
||||
ret.add(400.0);
|
||||
} else {
|
||||
switch (getLensMode()) {
|
||||
case DA30_01:
|
||||
case DA30_08:
|
||||
ret.add(lowThetaY.getValue());
|
||||
ret.add(highThetaY.getValue());
|
||||
break;
|
||||
default:
|
||||
ret.add(lowThetaX.getValue());
|
||||
ret.add(highThetaX.getValue());
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ret.add(Double.NaN);
|
||||
ret.add(Double.NaN);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user