This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
*/
|
||||
package ch.psi.mxsc;
|
||||
|
||||
import ch.psi.mxsc.MainPanel.BasePlateLayout;
|
||||
import ch.psi.pshell.device.Device;
|
||||
import ch.psi.pshell.device.DeviceBase;
|
||||
import ch.psi.pshell.imaging.DimensionDouble;
|
||||
@@ -14,77 +15,78 @@ import java.util.ArrayList;
|
||||
*
|
||||
*/
|
||||
public class BasePlate extends DeviceBase {
|
||||
|
||||
public enum WiringSetup{
|
||||
|
||||
public enum WiringSetup {
|
||||
natural,
|
||||
sf
|
||||
sf
|
||||
}
|
||||
|
||||
final static PointDouble[] pucksPosition = new PointDouble[]{
|
||||
/*
|
||||
new PointDouble(0, 75),
|
||||
new PointDouble(0, 150),
|
||||
new PointDouble(64.95, 187.5),
|
||||
new PointDouble(129.9, 150),
|
||||
new PointDouble(64.95, 112.5),
|
||||
new PointDouble(64.95, 37.5),
|
||||
new PointDouble(129.9, 75),
|
||||
new PointDouble(194.85, 37.5),
|
||||
new PointDouble(194.85, -37.5),
|
||||
new PointDouble(129.9, 0),
|
||||
new PointDouble(64.95, -37.5),
|
||||
new PointDouble(129.9, -75),
|
||||
new PointDouble(129.9, -150),
|
||||
new PointDouble(64.95, -187.5),
|
||||
new PointDouble(64.95, -112.5),
|
||||
new PointDouble(0, -75),
|
||||
new PointDouble(0, -150),
|
||||
new PointDouble(-64.95, -187.5),
|
||||
new PointDouble(-129.9, -150),
|
||||
new PointDouble(-64.95, -112.5),
|
||||
new PointDouble(-64.95, -37.5),
|
||||
new PointDouble(-129.9, -75),
|
||||
new PointDouble(-194.85, -37.5),
|
||||
new PointDouble(-194.85, 37.5),
|
||||
new PointDouble(-129.9, 0),
|
||||
new PointDouble(-64.95, 37.5),
|
||||
new PointDouble(-129.9, 75),
|
||||
new PointDouble(-129.9, 150),
|
||||
new PointDouble(-64.95, 187.5),
|
||||
new PointDouble(-64.95, 112.5)
|
||||
*/
|
||||
new PointDouble(0, 75),
|
||||
new PointDouble(0, 150),
|
||||
new PointDouble(-64.95, 112.5),
|
||||
new PointDouble(-64.95, 187.5),
|
||||
new PointDouble(-129.9, 150),
|
||||
new PointDouble(-64.95, 37.5),
|
||||
new PointDouble(-129.9, 75),
|
||||
new PointDouble(-129.9, 0),
|
||||
new PointDouble(-194.85, 37.5),
|
||||
new PointDouble(-194.85, -37.5),
|
||||
new PointDouble(-64.95, -37.5),
|
||||
new PointDouble(-129.9, -75),
|
||||
new PointDouble(-64.95, -112.5),
|
||||
new PointDouble(-129.9, -150),
|
||||
new PointDouble(-64.95, -187.5),
|
||||
new PointDouble(0, -75),
|
||||
new PointDouble(0, -150),
|
||||
new PointDouble(64.95, -112.5),
|
||||
new PointDouble(64.95, -187.5),
|
||||
new PointDouble(129.9, -150),
|
||||
new PointDouble(64.95, -37.5),
|
||||
new PointDouble(129.9, -75),
|
||||
new PointDouble(129.9, 0),
|
||||
new PointDouble(194.85, -37.5),
|
||||
new PointDouble(194.85, 37.5),
|
||||
new PointDouble(64.95, 37.5),
|
||||
new PointDouble(129.9, 75),
|
||||
new PointDouble(64.95, 112.5),
|
||||
new PointDouble(129.9, 150),
|
||||
new PointDouble(64.95, 187.5),
|
||||
|
||||
};
|
||||
|
||||
//TODO: Fix SF only to change address based on BASE_PLATE_LAYOUT
|
||||
final static PointDouble[] pucksPosition = (MainPanel.BASE_PLATE_LAYOUT == BasePlateLayout.normal)
|
||||
? new PointDouble[]{
|
||||
new PointDouble(0, 75),
|
||||
new PointDouble(0, 150),
|
||||
new PointDouble(-64.95, 112.5),
|
||||
new PointDouble(-64.95, 187.5),
|
||||
new PointDouble(-129.9, 150),
|
||||
new PointDouble(-64.95, 37.5),
|
||||
new PointDouble(-129.9, 75),
|
||||
new PointDouble(-129.9, 0),
|
||||
new PointDouble(-194.85, 37.5),
|
||||
new PointDouble(-194.85, -37.5),
|
||||
new PointDouble(-64.95, -37.5),
|
||||
new PointDouble(-129.9, -75),
|
||||
new PointDouble(-64.95, -112.5),
|
||||
new PointDouble(-129.9, -150),
|
||||
new PointDouble(-64.95, -187.5),
|
||||
new PointDouble(0, -75),
|
||||
new PointDouble(0, -150),
|
||||
new PointDouble(64.95, -112.5),
|
||||
new PointDouble(64.95, -187.5),
|
||||
new PointDouble(129.9, -150),
|
||||
new PointDouble(64.95, -37.5),
|
||||
new PointDouble(129.9, -75),
|
||||
new PointDouble(129.9, 0),
|
||||
new PointDouble(194.85, -37.5),
|
||||
new PointDouble(194.85, 37.5),
|
||||
new PointDouble(64.95, 37.5),
|
||||
new PointDouble(129.9, 75),
|
||||
new PointDouble(64.95, 112.5),
|
||||
new PointDouble(129.9, 150),
|
||||
new PointDouble(64.95, 187.5),}
|
||||
: new PointDouble[]{
|
||||
new PointDouble(0, 75),
|
||||
new PointDouble(0, 150),
|
||||
new PointDouble(64.95, 187.5),
|
||||
new PointDouble(129.9, 150),
|
||||
new PointDouble(64.95, 112.5),
|
||||
new PointDouble(64.95, 37.5),
|
||||
new PointDouble(129.9, 75),
|
||||
new PointDouble(194.85, 37.5),
|
||||
new PointDouble(194.85, -37.5),
|
||||
new PointDouble(129.9, 0),
|
||||
new PointDouble(64.95, -37.5),
|
||||
new PointDouble(129.9, -75),
|
||||
new PointDouble(129.9, -150),
|
||||
new PointDouble(64.95, -187.5),
|
||||
new PointDouble(64.95, -112.5),
|
||||
new PointDouble(0, -75),
|
||||
new PointDouble(0, -150),
|
||||
new PointDouble(-64.95, -187.5),
|
||||
new PointDouble(-129.9, -150),
|
||||
new PointDouble(-64.95, -112.5),
|
||||
new PointDouble(-64.95, -37.5),
|
||||
new PointDouble(-129.9, -75),
|
||||
new PointDouble(-194.85, -37.5),
|
||||
new PointDouble(-194.85, 37.5),
|
||||
new PointDouble(-129.9, 0),
|
||||
new PointDouble(-64.95, 37.5),
|
||||
new PointDouble(-129.9, 75),
|
||||
new PointDouble(-129.9, 150),
|
||||
new PointDouble(-64.95, 187.5),
|
||||
new PointDouble(-64.95, 112.5)
|
||||
|
||||
};
|
||||
final static int numberOfPucks = pucksPosition.length;
|
||||
//final static DimensionDouble size = new DimensionDouble(580.0, 580.0);
|
||||
final static DimensionDouble size = new DimensionDouble(470.0, 470.0);
|
||||
@@ -93,8 +95,8 @@ public class BasePlate extends DeviceBase {
|
||||
super("BasePlate", new BasePlateConfig());
|
||||
ArrayList<Puck> pucks = new ArrayList<>();
|
||||
for (int i = 0; i < numberOfPucks; i++) {
|
||||
new Puck(this, i);
|
||||
}
|
||||
new Puck(this, i);
|
||||
}
|
||||
getPucks()[0].setSelected(true);
|
||||
}
|
||||
|
||||
@@ -108,8 +110,6 @@ public class BasePlate extends DeviceBase {
|
||||
return (BasePlateConfig) super.getConfig();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Puck[] getPucks() {
|
||||
ArrayList<Puck> ret = new ArrayList<>();
|
||||
for (Device d : getChildren()) {
|
||||
@@ -117,68 +117,66 @@ public class BasePlate extends DeviceBase {
|
||||
}
|
||||
return ret.toArray(new Puck[0]);
|
||||
}
|
||||
|
||||
|
||||
Puck getSelectedPuck(){
|
||||
for (Puck p:getPucks()){
|
||||
if (p.isSelected()){
|
||||
|
||||
Puck getSelectedPuck() {
|
||||
for (Puck p : getPucks()) {
|
||||
if (p.isSelected()) {
|
||||
return p;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return null;
|
||||
}
|
||||
|
||||
Puck.Detection[] getDetection(){
|
||||
|
||||
Puck.Detection[] getDetection() {
|
||||
Puck.Detection[] ret = new Puck.Detection[Controller.NUMBER_OF_PUCKS];
|
||||
for (int i=0; i<ret.length;i++){
|
||||
for (int i = 0; i < ret.length; i++) {
|
||||
ret[i] = getPucks()[i].detection;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
Sample getSelectedSample(){
|
||||
|
||||
Sample getSelectedSample() {
|
||||
Puck puck = getSelectedPuck();
|
||||
if (puck != null){
|
||||
for (Sample s: puck.getSamples()){
|
||||
if (s.isSelected()){
|
||||
if (puck != null) {
|
||||
for (Sample s : puck.getSamples()) {
|
||||
if (s.isSelected()) {
|
||||
return s;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return null;
|
||||
}
|
||||
|
||||
void resetSelection(){
|
||||
|
||||
void resetSelection() {
|
||||
Puck puck = getSelectedPuck();
|
||||
if (puck != null){
|
||||
if (puck != null) {
|
||||
puck.setSelected(false);
|
||||
}
|
||||
}
|
||||
|
||||
Sample getLoadedSample(){
|
||||
for (Puck p:getPucks()){
|
||||
for (Sample s: p.getSamples()){
|
||||
if (s.isLoaded()){
|
||||
|
||||
Sample getLoadedSample() {
|
||||
for (Puck p : getPucks()) {
|
||||
for (Sample s : p.getSamples()) {
|
||||
if (s.isLoaded()) {
|
||||
return s;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
void resetLoadedSample(){
|
||||
for (Puck p:getPucks()){
|
||||
for (Sample s: p.getSamples()){
|
||||
return null;
|
||||
}
|
||||
|
||||
void resetLoadedSample() {
|
||||
for (Puck p : getPucks()) {
|
||||
for (Sample s : p.getSamples()) {
|
||||
s.setLoaded(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
DimensionDouble getSize(){
|
||||
DimensionDouble getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
|
||||
public int getNumberOfPucks() {
|
||||
return numberOfPucks;
|
||||
}
|
||||
@@ -186,80 +184,78 @@ public class BasePlate extends DeviceBase {
|
||||
public PointDouble getPuckPosition(Puck puck) {
|
||||
return pucksPosition[puck.index];
|
||||
}
|
||||
|
||||
|
||||
public Puck getPuckByName(String name) {
|
||||
for (Device d : getChildren()) {
|
||||
if (d.getName().equals(name)){
|
||||
if (d.getName().equals(name)) {
|
||||
return (Puck) d;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Sample getSampleByName(String name) {
|
||||
try{
|
||||
Puck p = getPuckByName(name.substring(0,2));
|
||||
if (p!=null){
|
||||
return p.getSamples()[Integer.valueOf(name.substring(2,3))-1];
|
||||
try {
|
||||
Puck p = getPuckByName(name.substring(0, 2));
|
||||
if (p != null) {
|
||||
return p.getSamples()[Integer.valueOf(name.substring(2, 3)) - 1];
|
||||
}
|
||||
} catch (Exception ex){
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void clearId(String id) {
|
||||
for (Device d : getChildren()) {
|
||||
if (d instanceof Puck){
|
||||
if ((id==null) || id.equals(((Puck) d).getId())){
|
||||
if (d instanceof Puck) {
|
||||
if ((id == null) || id.equals(((Puck) d).getId())) {
|
||||
((Puck) d).setId(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void loadSample(Sample sample) throws Exception{
|
||||
}
|
||||
|
||||
public void loadSample(Sample sample) throws Exception {
|
||||
Sample loaded = getLoadedSample();
|
||||
if (loaded !=null){
|
||||
if (loaded != null) {
|
||||
throw new Exception("Sample already loaded: " + loaded);
|
||||
}
|
||||
if (sample!=null){
|
||||
}
|
||||
if (sample != null) {
|
||||
resetLoadedSample();
|
||||
//TODO
|
||||
sample.setLoaded(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void unloadSample(Sample sample) throws Exception{
|
||||
if (sample!=null){
|
||||
|
||||
public void unloadSample(Sample sample) throws Exception {
|
||||
if (sample != null) {
|
||||
//TODO
|
||||
resetLoadedSample();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void loadSample() throws Exception{
|
||||
loadSample(getSelectedSample());
|
||||
}
|
||||
|
||||
public void unloadSample() throws Exception{
|
||||
unloadSample (getLoadedSample());
|
||||
public void loadSample() throws Exception {
|
||||
loadSample(getSelectedSample());
|
||||
}
|
||||
|
||||
|
||||
void onSelectionChanged(){
|
||||
|
||||
public void unloadSample() throws Exception {
|
||||
unloadSample(getLoadedSample());
|
||||
}
|
||||
|
||||
void onSelectionChanged() {
|
||||
Sample sample = getSelectedSample();
|
||||
if (sample!=null){
|
||||
if (sample != null) {
|
||||
//setCache(sample.getName());
|
||||
setCache(new Object[]{sample.getPuck().segment, sample.getPuck().number, sample.index+1});
|
||||
setCache(new Object[]{sample.getPuck().segment, sample.getPuck().number, sample.index + 1});
|
||||
} else {
|
||||
Puck puck = getSelectedPuck();
|
||||
if (puck!=null){
|
||||
if (puck != null) {
|
||||
//setCache(puck.getName());
|
||||
setCache(new Object[]{puck.segment, puck.number, null});
|
||||
} else {
|
||||
setCache(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -44,6 +44,12 @@ public class MainPanel extends Panel {
|
||||
Boolean manualMode;
|
||||
Boolean roomTemperature;
|
||||
public final String PUCK_LOADING_STATUS = "Puck loading";
|
||||
|
||||
public enum BasePlateLayout{
|
||||
normal,
|
||||
sf
|
||||
}
|
||||
public static final BasePlateLayout BASE_PLATE_LAYOUT = App.hasArgument("sf") ? BasePlateLayout.sf: BasePlateLayout.normal;
|
||||
|
||||
public MainPanel() {
|
||||
initComponents();
|
||||
|
||||
@@ -13,7 +13,7 @@ import java.util.ArrayList;
|
||||
*
|
||||
*/
|
||||
public class Puck extends DeviceBase {
|
||||
|
||||
|
||||
final static int signalX = -1;
|
||||
final static PointDouble[] samplesPosition = new PointDouble[]{
|
||||
new PointDouble(0 * signalX, 24.24),
|
||||
@@ -34,70 +34,63 @@ public class Puck extends DeviceBase {
|
||||
new PointDouble(-28.39445573 * signalX, 44.18263554)
|
||||
};
|
||||
|
||||
/*
|
||||
static final Character[] SEGMENTS = new Character[]{'A', 'A',
|
||||
'F', 'F', 'F', 'F', 'F',
|
||||
'E', 'E', 'E', 'E', 'E',
|
||||
'D', 'D', 'D', 'D', 'D',
|
||||
'C', 'C', 'C', 'C', 'C',
|
||||
'B', 'B', 'B', 'B', 'B',
|
||||
'A', 'A', 'A'};
|
||||
static final int[] NUMBERS = new int[]{1, 2,
|
||||
5, 4, 3, 1, 2,
|
||||
5, 4, 3, 1, 2,
|
||||
5, 4, 3, 1, 2,
|
||||
5, 4, 3, 1, 2,
|
||||
5, 4, 3, 1, 2,
|
||||
5, 4, 3};
|
||||
static final int[] ADDRESSES = new int[]{6, 7,
|
||||
5, 4, 3, 1, 2,
|
||||
20, 19, 18, 16, 17,
|
||||
15, 14, 13, 11, 12,
|
||||
30, 29, 28, 26, 27,
|
||||
25, 24, 23, 21, 22,
|
||||
10, 9, 8};
|
||||
static final double[] ANGLES = new double[]{
|
||||
0.00, 0.00, 19.11, 40.89, 30.00,
|
||||
60.00, 60.00, 79.11, 100.89, 90.00,
|
||||
120.00, 120.00, 139.11, 160.89, 150.00,
|
||||
180.00, 180.00, 199.11, 220.89, 210.00,
|
||||
240.00, 240.00, 259.11, 280.89, 270.00,
|
||||
300.00, 300.00, 319.11, 340.89, 330.00};
|
||||
*/
|
||||
|
||||
static final Character[] SEGMENTS = new Character[]{
|
||||
static final Character[] SEGMENTS = (MainPanel.BASE_PLATE_LAYOUT == MainPanel.BasePlateLayout.normal) ? new Character[]{
|
||||
'A', 'A','A', 'A', 'A',
|
||||
'B', 'B', 'B', 'B', 'B',
|
||||
'C', 'C', 'C', 'C', 'C',
|
||||
'D', 'D', 'D', 'D', 'D',
|
||||
'E', 'E', 'E', 'E', 'E',
|
||||
'F', 'F', 'F', 'F', 'F',
|
||||
};
|
||||
static final int[] NUMBERS = new int[]{
|
||||
} : new Character[]{'A', 'A',
|
||||
'F', 'F', 'F', 'F', 'F',
|
||||
'E', 'E', 'E', 'E', 'E',
|
||||
'D', 'D', 'D', 'D', 'D',
|
||||
'C', 'C', 'C', 'C', 'C',
|
||||
'B', 'B', 'B', 'B', 'B',
|
||||
'A', 'A', 'A'};;
|
||||
static final int[] NUMBERS = (MainPanel.BASE_PLATE_LAYOUT == MainPanel.BasePlateLayout.normal) ?new int[]{
|
||||
1, 2, 3, 4, 5,
|
||||
1, 2, 3, 4, 5,
|
||||
1, 2, 3, 4, 5,
|
||||
1, 2, 3, 4, 5,
|
||||
1, 2, 3, 4, 5,
|
||||
1, 2, 3, 4, 5,
|
||||
};
|
||||
static final int[] ADDRESSES = new int[]{
|
||||
} : new int[]{1, 2,
|
||||
5, 4, 3, 1, 2,
|
||||
5, 4, 3, 1, 2,
|
||||
5, 4, 3, 1, 2,
|
||||
5, 4, 3, 1, 2,
|
||||
5, 4, 3, 1, 2,
|
||||
5, 4, 3}; ;
|
||||
static final int[] ADDRESSES =(MainPanel.BASE_PLATE_LAYOUT == MainPanel.BasePlateLayout.normal) ? new int[]{
|
||||
1, 2, 3, 4, 5,
|
||||
6, 7, 8, 9, 10,
|
||||
11, 12, 13, 14, 15,
|
||||
16, 17, 18, 19, 20,
|
||||
21, 22, 23, 24, 25,
|
||||
26, 27, 28, 29, 30
|
||||
};
|
||||
} : new int[]{6, 7,
|
||||
5, 4, 3, 1, 2,
|
||||
20, 19, 18, 16, 17,
|
||||
15, 14, 13, 11, 12,
|
||||
30, 29, 28, 26, 27,
|
||||
25, 24, 23, 21, 22,
|
||||
10, 9, 8};;
|
||||
|
||||
static final double[] ANGLES = new double[]{
|
||||
static final double[] ANGLES = (MainPanel.BASE_PLATE_LAYOUT == MainPanel.BasePlateLayout.normal) ?new double[]{
|
||||
0.00, 0.00, 330.00, 340.89, 319.11,
|
||||
300.00, 300.00, 270.00, 280.89, 259.11,
|
||||
240.00, 240.00, 210.00, 220.89, 199.11,
|
||||
180.00, 180.00, 150.00, 160.89, 139.11,
|
||||
120.00, 120.00, 90.00, 100.89, 79.11,
|
||||
60.00, 60.00, 30.00, 40.89, 19.11
|
||||
};
|
||||
} : new double[]{
|
||||
0.00, 0.00, 19.11, 40.89, 30.00,
|
||||
60.00, 60.00, 79.11, 100.89, 90.00,
|
||||
120.00, 120.00, 139.11, 160.89, 150.00,
|
||||
180.00, 180.00, 199.11, 220.89, 210.00,
|
||||
240.00, 240.00, 259.11, 280.89, 270.00,
|
||||
300.00, 300.00, 319.11, 340.89, 330.00}; ;
|
||||
|
||||
final static PointDouble referencePosition = new PointDouble(0.0, -66.9 - 0.2);
|
||||
final static Double referenceSize = 6.2 + 0.2;
|
||||
|
||||
Reference in New Issue
Block a user