Possibility to add/remove devices to the pool without initializing/closing them.

This commit is contained in:
2018-09-06 15:31:58 +02:00
parent 9053e14c41
commit 18f8b38cc3
3 changed files with 28 additions and 29 deletions

View File

@@ -97,7 +97,10 @@ public class Controller {
instance = this;
clearPuckStates();
basePlate.addListener(new DeviceAdapter() {
basePlate.addListener(basePlateListener);
}
final DeviceListener basePlateListener = new DeviceAdapter() {
@Override
public void onValueChanged(Device device, Object value, Object former) {
if (value!=null){
@@ -109,8 +112,7 @@ public class Controller {
Controller.this.mainFrame.onSelectionChanged(null,null,null);
}
}
});
}
};
String getCurrentSelection(){
Object value = basePlate.take();
@@ -145,18 +147,8 @@ public class Controller {
}
void onInitialize(int runCount) {
//GenericDevice former = getDevice("BasePlate");
//if (former != null) {
//getMainFrame().removeDevice(former);
// if (basePlate.getState() == State.Closing){
// try {
// basePlate.initialize();
// } catch (Exception ex) {
// Logger.getLogger(Controller.class.getName()).log(Level.SEVERE, null, ex);
// }
// }
//}
getMainFrame().addDevice(basePlate);
basePlate.addListener(basePlateListener);
System.out.println(basePlate.getState());
@@ -200,11 +192,18 @@ public class Controller {
}
public void onStateChange(State state, State former) {
if (state == State.Initializing){
getMainFrame().removeDevice(basePlate);
}
}
void onTimer(){
try {
Controller.getInstance().setPuckLoading(Controller.getInstance().isPuckLoading());
setPuckLoading(Controller.getInstance().isPuckLoading());
} catch (Exception ex) {
Controller.getInstance().setPuckLoading(false);
setPuckLoading(false);
}
}
@@ -562,7 +561,7 @@ public class Controller {
System.out.println("Setting to: " + puck.getName() + " datamatrix: " + datamatrix);
puck.setId(datamatrix);
getMainFrame().refresh();
getMainFrame().refresh();
}
}

View File

@@ -31,7 +31,7 @@
<Group type="102" alignment="1" attributes="0">
<Component id="panelTop" max="32767" attributes="0"/>
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
<Component id="panelBottom" pref="74" max="32767" attributes="0"/>
<Component id="panelBottom" pref="76" max="32767" attributes="0"/>
<EmptySpace min="-2" pref="1" max="-2" attributes="0"/>
</Group>
</Group>
@@ -334,21 +334,21 @@
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace pref="13" max="32767" attributes="0"/>
<EmptySpace pref="9" max="32767" attributes="0"/>
<Group type="103" groupAlignment="2" attributes="0">
<Component id="buttonDetectCover" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="hexiposiPanel" alignment="2" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="14" max="32767" attributes="0"/>
<EmptySpace pref="9" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace pref="15" max="32767" attributes="0"/>
<EmptySpace pref="14" max="32767" attributes="0"/>
<Component id="hexiposiPanel" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="10" max="32767" attributes="0"/>
<EmptySpace pref="9" max="32767" attributes="0"/>
<Component id="buttonDetectCover" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
@@ -384,12 +384,12 @@
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace max="32767" attributes="0"/>
<EmptySpace pref="8" max="32767" attributes="0"/>
<Group type="103" groupAlignment="2" attributes="0">
<Component id="buttonDrawing" linkSize="25" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="buttonCamera" linkSize="25" alignment="2" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
<EmptySpace pref="8" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@@ -882,7 +882,7 @@
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
<Component id="panelDetail" pref="107" max="32767" attributes="0"/>
<Component id="panelDetail" pref="108" max="32767" attributes="0"/>
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
<Component id="panelDevices" min="-2" pref="280" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
@@ -990,9 +990,9 @@
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
<Component id="devicesPanel" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="28" max="32767" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="panelExpert" min="-2" pref="93" max="-2" attributes="0"/>
<EmptySpace pref="31" max="32767" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@@ -1004,7 +1004,7 @@
<Component id="panelExpert" max="32767" attributes="0"/>
<Component id="devicesPanel" pref="235" max="32767" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
<EmptySpace pref="8" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>

View File

@@ -168,7 +168,7 @@ public class MainPanel extends Panel {
@Override
public void onStateChange(State state, State former) {
Controller.getInstance().onStateChange(state, former);
}