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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user