Bigger font sizes and clearing mounted sample if puck is removed.
This commit is contained in:
@@ -8,7 +8,7 @@ import ch.psi.pshell.core.Context;
|
||||
import ch.psi.pshell.core.DevicePool;
|
||||
import ch.psi.pshell.core.DevicePoolListener;
|
||||
import ch.psi.pshell.core.JsonSerializer;
|
||||
import ch.psi.pshell.device.Device;
|
||||
import ch.psi.pshell.device.Device;
|
||||
import ch.psi.pshell.device.DeviceAdapter;
|
||||
import ch.psi.pshell.device.DeviceListener;
|
||||
import ch.psi.pshell.device.GenericDevice;
|
||||
@@ -64,14 +64,14 @@ public class Controller {
|
||||
static void createInstance(Panel mainFrame) {
|
||||
instance = new Controller(mainFrame);
|
||||
}
|
||||
|
||||
enum PuckMountMode{
|
||||
|
||||
enum PuckMountMode {
|
||||
Direct,
|
||||
Dialog
|
||||
}
|
||||
|
||||
final PuckMountMode puckMountMode = App.hasArgument("direct") ? PuckMountMode.Direct : PuckMountMode.Dialog;
|
||||
|
||||
|
||||
enum PuckSensorAccess {
|
||||
RaspberryPi,
|
||||
Esera;
|
||||
@@ -127,7 +127,7 @@ public class Controller {
|
||||
|
||||
basePlate.addListener(basePlateListener);
|
||||
roomTemperatureBasePlate = new RoomTemperatureBasePlate();
|
||||
|
||||
|
||||
}
|
||||
|
||||
final DeviceListener basePlateListener = new DeviceAdapter() {
|
||||
@@ -226,6 +226,17 @@ public class Controller {
|
||||
refreshSamplesTable();
|
||||
|
||||
}
|
||||
|
||||
public Sample getMountedSample() throws Exception{
|
||||
currentMountedSample = (String) Context.getInstance().evalLineBackground("get_setting('mounted_sample_position')");
|
||||
Sample sample = basePlate.getSampleByName(currentMountedSample);
|
||||
return sample;
|
||||
}
|
||||
|
||||
public void resetMountedSample() throws Exception{
|
||||
Context.getInstance().evalLineBackground("set_setting('mounted_sample_position', None)");
|
||||
}
|
||||
|
||||
|
||||
public void onStateChange(State state, State former) {
|
||||
if (state == State.Initializing) {
|
||||
@@ -233,9 +244,8 @@ public class Controller {
|
||||
} else if (state == State.Ready) {
|
||||
refreshSamplesTable();
|
||||
try {
|
||||
currentMountedSample = (String) Context.getInstance().evalLineBackground("get_setting('mounted_sample_position')");
|
||||
Sample sample = basePlate.getSampleByName(currentMountedSample);
|
||||
if ((sample == null) && (roomTemperatureBasePlate!=null)){
|
||||
Sample sample = getMountedSample();
|
||||
if ((sample == null) && (roomTemperatureBasePlate != null)) {
|
||||
sample = roomTemperatureBasePlate.getSampleByName(currentMountedSample);
|
||||
roomTemperatureBasePlate.resetLoadedSample();
|
||||
}
|
||||
@@ -263,7 +273,7 @@ public class Controller {
|
||||
refreshSamplesTable();
|
||||
} catch (Exception ex) {
|
||||
Logger.getLogger(Controller.class.getName()).log(Level.WARNING, null, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final DeviceListener hexiposiListener = new DeviceAdapter() {
|
||||
@@ -397,7 +407,7 @@ public class Controller {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public boolean isSelectedPuck(Puck puck) {
|
||||
return ("" + puck.getSegment()).equalsIgnoreCase(getHexiposiPosition());
|
||||
}
|
||||
@@ -419,7 +429,7 @@ public class Controller {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Boolean isRoomTemp() {
|
||||
try {
|
||||
return getMainFrame().eval("is_room_temp()", true).equals(true);
|
||||
@@ -474,25 +484,24 @@ public class Controller {
|
||||
} catch (Exception ex) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Boolean isBeamlineStatusEnabled() {
|
||||
try {
|
||||
return getMainFrame().eval("is_beamline_status_enabled()", true).equals(true);
|
||||
} catch (Exception ex) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Boolean isImagingEnabled() {
|
||||
try {
|
||||
return getMainFrame().eval("is_imaging_enabled()", true).equals(true);
|
||||
} catch (Exception ex) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void imageDetectPucks() throws Context.ContextStateException {
|
||||
imageDetectPucks(null, null, null);
|
||||
}
|
||||
@@ -670,24 +679,24 @@ public class Controller {
|
||||
Device reader = getPuckBarcodeReader();
|
||||
if (reader != null) {
|
||||
final String name = reader.getName();
|
||||
BiFunction errorHandler =(BiFunction) (ret, ex) -> {
|
||||
BiFunction errorHandler = (BiFunction) (ret, ex) -> {
|
||||
if (ex != null) {
|
||||
if (puckReaderOk){
|
||||
Logger.getLogger(Controller.class.getName()).warning("Communication failure: " + name);
|
||||
if (puckReaderOk) {
|
||||
Logger.getLogger(Controller.class.getName()).warning("Communication failure: " + name);
|
||||
}
|
||||
puckLoading = null;
|
||||
puckLoading = null;
|
||||
puckReaderOk = false;
|
||||
} else {
|
||||
if (!puckReaderOk){
|
||||
Logger.getLogger(Controller.class.getName()).warning("Communication resumed: " + name);
|
||||
if (!puckReaderOk) {
|
||||
Logger.getLogger(Controller.class.getName()).warning("Communication resumed: " + name);
|
||||
}
|
||||
puckReaderOk = true;
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
};
|
||||
try {
|
||||
if (puckLoading) {
|
||||
getMainFrame().evalAsync(name + ".enable(); " + name + ".polling = 100" , true).handle(errorHandler);
|
||||
getMainFrame().evalAsync(name + ".enable(); " + name + ".polling = 100", true).handle(errorHandler);
|
||||
currentDetection = basePlate.getDetection();
|
||||
} else if (getState().isInitialized()) {
|
||||
getMainFrame().evalAsync(name + ".polling = 0; " + name + ".disable()", true).handle(errorHandler);
|
||||
@@ -708,14 +717,14 @@ public class Controller {
|
||||
return puckLoading;
|
||||
}
|
||||
|
||||
void playSound(String name){
|
||||
try{
|
||||
void playSound(String name) {
|
||||
try {
|
||||
Audio.playFile(new File(Context.getInstance().getSetup().expandPath("{home}/sounds/" + name + ".wav")), false);
|
||||
} catch (Exception ex){
|
||||
} catch (Exception ex) {
|
||||
Logger.getLogger(Controller.class.getName()).log(Level.FINE, null, ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void onPuckBarcode(String datamatrix) {
|
||||
if (isPuckLoading()) {
|
||||
playSound("scanned");
|
||||
@@ -738,7 +747,7 @@ public class Controller {
|
||||
if (isSelectedPuck(puck)) {
|
||||
boolean detectedPuckInserted = (currentDetection[i] != Puck.Detection.Present) && (detection[i] == Puck.Detection.Present);
|
||||
boolean detectedPuckRemoved = (currentDetection[i] != Puck.Detection.Empty) && (detection[i] == Puck.Detection.Empty);
|
||||
if (detectedPuckInserted) {
|
||||
if (detectedPuckInserted) {
|
||||
onPuckInserted(puck);
|
||||
|
||||
} else if (detectedPuckRemoved) {
|
||||
@@ -751,18 +760,18 @@ public class Controller {
|
||||
currentDetection = detection;
|
||||
}
|
||||
}
|
||||
|
||||
public void onPuckInserted(Puck puck){
|
||||
|
||||
public void onPuckInserted(Puck puck) {
|
||||
playSound("mounted");
|
||||
String datamatrix = getMainFrame().getPuckDatamatrix();
|
||||
onPuckScanned(null);
|
||||
onPuckMounted(puck, datamatrix);
|
||||
onPuckMounted(puck, datamatrix);
|
||||
}
|
||||
|
||||
public void onPuckRemoved(Puck puck){
|
||||
|
||||
public void onPuckRemoved(Puck puck) {
|
||||
playSound("unmounted");
|
||||
onPuckUnmounted(puck);
|
||||
}
|
||||
onPuckUnmounted(puck);
|
||||
}
|
||||
|
||||
void linkPuckDatamatrix(Puck puck, String datamatrix, boolean showMessage) {
|
||||
// if ( ((puck.getId()==null) && (datamatrix!=null)) ||
|
||||
@@ -866,70 +875,81 @@ public class Controller {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void showDialogPuckLoading (){
|
||||
if ((dialogPuckLoading!=null) && (dialogPuckLoading.isVisible())){
|
||||
|
||||
void showDialogPuckLoading() {
|
||||
if ((dialogPuckLoading != null) && (dialogPuckLoading.isVisible())) {
|
||||
return;
|
||||
}
|
||||
dialogPuckLoading = new PuckLoadingDialog(mainFrame.getTopLevel(), false);
|
||||
dialogPuckLoading.setLocationRelativeTo(mainFrame);
|
||||
dialogPuckLoading.setLocationRelativeTo(mainFrame);
|
||||
dialogPuckLoading.setVisible(true);
|
||||
}
|
||||
|
||||
void hideDialogPuckLoading (){
|
||||
if (dialogPuckLoading!=null){
|
||||
|
||||
void hideDialogPuckLoading() {
|
||||
if (dialogPuckLoading != null) {
|
||||
dialogPuckLoading.setVisible(false);
|
||||
dialogPuckLoading.dispose();
|
||||
dialogPuckLoading = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void onPuckLoadingModeChange(boolean puckLoadMode) {
|
||||
if (puckMountMode == PuckMountMode.Dialog){
|
||||
if (puckLoadMode){
|
||||
if (puckMountMode == PuckMountMode.Dialog) {
|
||||
if (puckLoadMode) {
|
||||
showDialogPuckLoading();
|
||||
} else {
|
||||
hideDialogPuckLoading ();
|
||||
hideDialogPuckLoading();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void onPuckScanned(String datamatrix){
|
||||
|
||||
void onPuckScanned(String datamatrix) {
|
||||
if (isPuckLoading()) {
|
||||
getMainFrame().setPuckDatamatrix(datamatrix);
|
||||
if (puckMountMode == PuckMountMode.Dialog){
|
||||
if (puckMountMode == PuckMountMode.Dialog) {
|
||||
showDialogPuckLoading();
|
||||
dialogPuckLoading.onPuckScanned(datamatrix);
|
||||
}
|
||||
} else{
|
||||
} else {
|
||||
getMainFrame().setPuckDatamatrix(null);
|
||||
}
|
||||
}
|
||||
|
||||
void onPuckMounted(Puck puck, String datamatrix){
|
||||
|
||||
void onPuckMounted(Puck puck, String datamatrix) {
|
||||
if (isPuckLoading()) {
|
||||
if (puckMountMode == PuckMountMode.Dialog){
|
||||
if (puckMountMode == PuckMountMode.Dialog) {
|
||||
showDialogPuckLoading();
|
||||
dialogPuckLoading.onPuckMounted(puck, datamatrix);
|
||||
} else {
|
||||
} else {
|
||||
if (!datamatrix.isEmpty()) {
|
||||
linkPuckDatamatrix(puck, datamatrix, true);
|
||||
} else {
|
||||
askPuckDatamatrix(puck);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void onPuckUnmounted(Puck puck){
|
||||
|
||||
void onPuckUnmounted(Puck puck) {
|
||||
if (isPuckLoading()) {
|
||||
if (puckMountMode == PuckMountMode.Dialog){
|
||||
try{
|
||||
Sample sample = getMountedSample();
|
||||
if ((sample!=null) && (sample.getPuck() == puck)){
|
||||
resetMountedSample();
|
||||
sample.setLoaded(false);
|
||||
SwingUtilities.invokeLater(()->{;
|
||||
getMainFrame().refresh();
|
||||
});
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
Logger.getLogger(Controller.class.getName()).log(Level.WARNING, null, ex);
|
||||
}
|
||||
if (puckMountMode == PuckMountMode.Dialog) {
|
||||
showDialogPuckLoading();
|
||||
dialogPuckLoading.onPuckUnmounted(puck);
|
||||
} else {
|
||||
linkPuckDatamatrix(puck, null, true);
|
||||
linkPuckDatamatrix(puck, null, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user