Preliminary implementation of SwissMX RT

This commit is contained in:
2023-04-26 09:22:59 +02:00
parent f961ee0758
commit a904eac8eb
9 changed files with 321 additions and 137 deletions

28
pom.xml
View File

@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>ch.psi</groupId>
<artifactId>MXSC</artifactId>
<version>1.12.0</version>
<version>1.19.0</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
@@ -14,13 +14,13 @@
<dependency>
<groupId>org.zeromq</groupId>
<artifactId>jeromq</artifactId>
<version>0.5.1</version>
<version>0.5.3</version>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<repositories>
@@ -39,6 +39,26 @@
<name>imagej</name>
<url>http://maven.imagej.net/content/repositories/public</url>
</repository>
<repository>
<id>libs-snapshots-local</id>
<name>libs-snapshots-local</name>
<url>https://artifacts.psi.ch/artifactory/libs-snapshots-local/</url>
</repository>
<repository>
<id>scijava-pub</id>
<name>scijava-pub</name>
<url>https://maven.scijava.org/content/repositories/public/</url>
</repository>
<repository>
<id>scijava</id>
<name>scijava</name>
<url>https://maven.scijava.org/</url>
</repository>
<repository>
<id>releases</id>
<name>releases</name>
<url>https://artifacts.psi.ch/artifactory/releases</url>
</repository>
</repositories>
<name>MXSC</name>

View File

@@ -134,18 +134,36 @@ public class BasePlate extends DeviceBase {
new PointDouble(-129.9, -150),
new PointDouble(-64.95, -187.5),
};
final static PointDouble[] pucksPositionRt = new PointDouble[]{
new PointDouble(0, 150),
new PointDouble(-130, 75),
new PointDouble(-130, -75),
new PointDouble(0, -150),
new PointDouble(130, -75),
new PointDouble(130, 75)
};
//TODO: Fix SF only to change address based on BASE_PLATE_LAYOUT
final static PointDouble[] pucksPosition =
(MainPanel.BASE_PLATE_LAYOUT == BasePlateLayout.normal) ? pucksPositionNormal :
((MainPanel.BASE_PLATE_LAYOUT == BasePlateLayout.sf) ? pucksPositionSf : pucksPosition6s );
( (MainPanel.BASE_PLATE_LAYOUT == BasePlateLayout.sf) ? pucksPositionSf :
((MainPanel.BASE_PLATE_LAYOUT == BasePlateLayout.rt) ? pucksPositionRt : pucksPosition6s)
);
final static int numberOfPucks = pucksPosition.length;
final static int numberOfSegments = 6;
final static int numberOfPucksPerSegments = numberOfPucks/numberOfSegments;
//final static DimensionDouble size = new DimensionDouble(580.0, 580.0);
final static DimensionDouble size = new DimensionDouble(470.0, 470.0);
BasePlate() {
super("BasePlate", new BasePlateConfig());
if (MainPanel.BASE_PLATE_LAYOUT == BasePlateLayout.rt){
//Controller.getInstance().getContext().getDevicePool().removeDevice("puck_detection");
}
ArrayList<Puck> pucks = new ArrayList<>();
for (int i = 0; i < numberOfPucks; i++) {
new Puck(this, i);
@@ -193,7 +211,7 @@ public class BasePlate extends DeviceBase {
Puck.Detection[] getDetection() {
Puck.Detection[] ret = new Puck.Detection[Controller.NUMBER_OF_PUCKS];
for (int i = 0; i < ret.length; i++) {
ret[i] = getPucks()[i].detection;
ret[i] = getPucks()[i].getDetection();
}
return ret;
}

View File

@@ -54,8 +54,8 @@ public class Controller {
static Controller instance;
final BasePlate basePlate;
final RoomTemperatureBasePlate roomTemperatureBasePlate;
final /*Panel*/ MainPanel mainFrame;
RoomTemperatureBasePlate roomTemperatureBasePlate;
static /*Panel*/ MainPanel mainFrame;
Device hexiposi;
Device barcode_reader;
Device barcode_reader_puck;
@@ -67,9 +67,19 @@ public class Controller {
public static Controller getInstance() {
return instance;
}
public static boolean isRt() {
return Controller.mainFrame.isRt();
}
static void createInstance(Panel mainFrame) {
instance = new Controller(mainFrame);
Controller.mainFrame = (MainPanel) mainFrame;
System.setProperty(GenericDevice.PROPERTY_CONFIG_PATH, Context.getInstance().getSetup().getDevicesPath());
if (isRt()){
instance = new ControllerRT(mainFrame);
} else {
instance = new Controller(mainFrame);
}
}
enum PuckMountMode {
@@ -120,16 +130,19 @@ public class Controller {
static String PUCK_ESERA_DEVICE = "onewire";
public static final int NUMBER_OF_PUCKS = 30;
private Controller(Panel mainFrame) {
System.setProperty(GenericDevice.PROPERTY_CONFIG_PATH, Context.getInstance().getSetup().getDevicesPath());
protected Controller(){
basePlate = new BasePlate();
instance = this;
}
private Controller(Panel mainFrame) {
this();
//basePlate = new BasePlate();
puckState = new PuckState[NUMBER_OF_PUCKS];
for (int i = 0; i < NUMBER_OF_PUCKS; i++) {
puckState[i] = new PuckState(i + 1);
}
this.mainFrame = (MainPanel) mainFrame;
instance = this;
clearPuckStates();
basePlate.addListener(basePlateListener);
@@ -369,7 +382,7 @@ public class Controller {
}
}
final PuckState[] puckState;
PuckState[] puckState;
public PuckState[] getPuckStates() {
return puckState;

View File

@@ -0,0 +1,47 @@
package ch.psi.mxsc;
import static ch.psi.mxsc.Controller.NUMBER_OF_PUCKS;
import static ch.psi.mxsc.Controller.instance;
import ch.psi.pshell.core.Context;
import ch.psi.pshell.device.Device;
import ch.psi.pshell.device.DeviceAdapter;
import ch.psi.pshell.device.DeviceListener;
import ch.psi.pshell.device.GenericDevice;
import ch.psi.pshell.ui.Panel;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
*/
public class ControllerRT extends Controller{
ControllerRT(Panel mainFrame) {
//basePlate = new BasePlate();
basePlate.addListener(basePlateListener);
setPuckLoading(false);
}
final DeviceListener basePlateListener = new DeviceAdapter() {
@Override
public void onValueChanged(Device device, Object value, Object former) {
if (value != null) {
String segment = ((Object[]) value)[0].toString();
Integer puck = (Integer) ((Object[]) value)[1];
Integer sample = (Integer) ((Object[]) value)[2];
mainFrame.onSelectionChanged(segment, puck, sample);
} else {
mainFrame.onSelectionChanged(null, null, null);
}
}
};
void onTimer() {
try {
refreshSamplesTable();
} catch (Exception ex) {
Logger.getLogger(Controller.class.getName()).log(Level.WARNING, null, ex);
}
}
}

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="79" 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="14" 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="15" 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="17" max="32767" attributes="0"/>
<Component id="hexiposiPanel" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="10" max="32767" attributes="0"/>
<EmptySpace pref="12" 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="15" 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="15" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@@ -896,7 +896,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="111" 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"/>
@@ -1004,21 +1004,21 @@
<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="26" max="32767" attributes="0"/>
<EmptySpace pref="22" max="32767" attributes="0"/>
<Component id="panelExpert" min="-2" pref="93" max="-2" attributes="0"/>
<EmptySpace pref="30" max="32767" attributes="0"/>
<EmptySpace pref="22" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="32767" attributes="0"/>
<EmptySpace pref="9" max="32767" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="panelExpert" max="32767" attributes="0"/>
<Component id="devicesPanel" pref="235" max="32767" attributes="0"/>
<Component id="devicesPanel" pref="237" max="32767" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
<EmptySpace pref="10" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>

View File

@@ -55,11 +55,19 @@ public class MainPanel extends Panel {
public enum BasePlateLayout {
normal,
sf,
x06da
x06da,
rt
}
public static final BasePlateLayout BASE_PLATE_LAYOUT = App.hasArgument("sf") ? BasePlateLayout.sf :
( App.hasArgument("6d") ? BasePlateLayout.x06da : BasePlateLayout.normal);
public static final BasePlateLayout BASE_PLATE_LAYOUT =
App.hasArgument("sf") ? BasePlateLayout.sf :
( App.hasArgument("6d") ? BasePlateLayout.x06da :
( App.hasArgument("rt") ? BasePlateLayout.rt : BasePlateLayout.normal)
);
public static boolean isRt(){
return App.hasArgument("rt");
}
public MainPanel() {
initComponents();
getContext().getPluginManager().addDynamicClass(PuckDetection.class);
@@ -69,10 +77,15 @@ public class MainPanel extends Panel {
setDefaultDetail();
panelTablePucks.getVerticalScrollBar().setPreferredSize(new Dimension(20, 0));
panelTableSamples.getVerticalScrollBar().setPreferredSize(new Dimension(20, 0));
if (isRt()){
panelLegend.setVisible(false);
}
((DefaultTableModel)tablePucks.getModel()).setNumRows(BasePlate.numberOfPucks);
int row = 0;
for (String segment : new String[]{"A", "B", "C", "D", "E", "F"}) {
for (int puck = 1; puck <= 5; puck++) {
for (int puck = 1; puck <= BasePlate.numberOfPucksPerSegments; puck++) {
tablePucks.getModel().setValueAt(segment + puck, row++, 0);
}
}
@@ -153,84 +166,88 @@ public class MainPanel extends Panel {
@Override
public void onInitialize(int runCount) {
stopTimer();
Controller.getInstance().onInitialize(runCount);
panelDisplayMode.setVisible(Controller.getInstance().isRoomTempEnabled());
panelBeamlineStatus.setVisible(Controller.getInstance().isBeamlineStatusEnabled());
if (basePlatePanel.getDevice() != (Device) getDevice("BasePlate")) {
basePlatePanel.setDevice((Device) getDevice("BasePlate"));
}
try {
devicesPanel.initialize();
((Device) getDevice("dewar_level")).addListener(new DeviceAdapter() {
@Override
public void onValueChanged(Device device, Object value, Object former) {
updateLevel(value);
}
});
updateLevel(((Device) getDevice("dewar_level")).take());
((Device) getDevice("air_pressure_ok")).addListener(new DeviceAdapter() {
@Override
public void onValueChanged(Device device, Object value, Object former) {
updateAirPressure(value);
}
});
updateAirPressure(((Device) getDevice("air_pressure_ok")).take());
((Device) getDevice("n2_pressure_ok")).addListener(new DeviceAdapter() {
@Override
public void onValueChanged(Device device, Object value, Object former) {
updateN2Pressure(value);
}
});
updateN2Pressure(((Device) getDevice("n2_pressure_ok")).take());
((Device) getDevice("feedback_local_safety")).addListener(new DeviceAdapter() {
@Override
public void onValueChanged(Device device, Object value, Object former) {
updateLocalSafety(value);
}
});
updateLocalSafety(((Device) getDevice("feedback_local_safety")).take());
updateN2Pressure(((Device) getDevice("n2_pressure_ok")).take());
((Device) getDevice("gripper_dryer")).addListener(new DeviceAdapter() {
@Override
public void onValueChanged(Device device, Object value, Object former) {
updateDryer(value);
}
});
updateDryer(((Device) getDevice("gripper_dryer")).take());
((Device) getDevice("feedback_psys_safety")).addListener(new DeviceAdapter() {
@Override
public void onValueChanged(Device device, Object value, Object former) {
updatePsysSafety(value);
}
});
updatePsysSafety(((Device) getDevice("feedback_psys_safety")).take());
((Device) getDevice("robot")).addListener(new DeviceAdapter() {
@Override
public void onValueChanged(Device device, Object value, Object former) {
updateMode(value);
}
public void onStateChanged(Device device, State state, State former) {
if (!state.isNormal()) {
updateMode(null);
try{
Controller.getInstance().onInitialize(runCount);
panelDisplayMode.setVisible(Controller.getInstance().isRoomTempEnabled());
panelBeamlineStatus.setVisible(Controller.getInstance().isBeamlineStatusEnabled());
if (basePlatePanel.getDevice() != (Device) getDevice("BasePlate")) {
basePlatePanel.setDevice((Device) getDevice("BasePlate"));
}
try {
devicesPanel.initialize();
((Device) getDevice("dewar_level")).addListener(new DeviceAdapter() {
@Override
public void onValueChanged(Device device, Object value, Object former) {
updateLevel(value);
}
}
});
updateMode(((Device) getDevice("robot")).take());
} catch (Exception ex) {
this.getLogger().log(Level.SEVERE, null, ex);
});
updateLevel(((Device) getDevice("dewar_level")).take());
((Device) getDevice("air_pressure_ok")).addListener(new DeviceAdapter() {
@Override
public void onValueChanged(Device device, Object value, Object former) {
updateAirPressure(value);
}
});
updateAirPressure(((Device) getDevice("air_pressure_ok")).take());
((Device) getDevice("n2_pressure_ok")).addListener(new DeviceAdapter() {
@Override
public void onValueChanged(Device device, Object value, Object former) {
updateN2Pressure(value);
}
});
updateN2Pressure(((Device) getDevice("n2_pressure_ok")).take());
((Device) getDevice("feedback_local_safety")).addListener(new DeviceAdapter() {
@Override
public void onValueChanged(Device device, Object value, Object former) {
updateLocalSafety(value);
}
});
updateLocalSafety(((Device) getDevice("feedback_local_safety")).take());
updateN2Pressure(((Device) getDevice("n2_pressure_ok")).take());
((Device) getDevice("gripper_dryer")).addListener(new DeviceAdapter() {
@Override
public void onValueChanged(Device device, Object value, Object former) {
updateDryer(value);
}
});
updateDryer(((Device) getDevice("gripper_dryer")).take());
((Device) getDevice("feedback_psys_safety")).addListener(new DeviceAdapter() {
@Override
public void onValueChanged(Device device, Object value, Object former) {
updatePsysSafety(value);
}
});
updatePsysSafety(((Device) getDevice("feedback_psys_safety")).take());
((Device) getDevice("robot")).addListener(new DeviceAdapter() {
@Override
public void onValueChanged(Device device, Object value, Object former) {
updateMode(value);
}
public void onStateChanged(Device device, State state, State former) {
if (!state.isNormal()) {
updateMode(null);
}
}
});
updateMode(((Device) getDevice("robot")).take());
} catch (Exception ex) {
this.getLogger().log(Level.SEVERE, null, ex);
}
setPuckDatamatrix(null);
setSampleDatamatrix(null);
setBackgroundUpdate(true);
startTimer(3000, 1000);
updateCameraView();
} catch (Exception ex){
getLogger().log(Level.SEVERE, null, ex);
}
setPuckDatamatrix(null);
setSampleDatamatrix(null);
setBackgroundUpdate(true);
startTimer(3000, 1000);
updateCameraView();
}
@Override
@@ -490,7 +507,7 @@ public class MainPanel extends Panel {
buttonCalibrateCover.setVisible(expert);
devicesPanel.setActive(expert);
panelViewType.setVisible(expert);
panelDetection.setVisible(expert);
panelDetection.setVisible(expert && !isRt());
buttonDetectCover.setVisible(expert);
buttonConfig.setVisible(expert);
Puck.setDisplayDetectionError(expert);
@@ -575,6 +592,13 @@ public class MainPanel extends Panel {
}
}
);
if (isRt()){
for (int i=0; i<3; i++){
tableSamples.getColumnModel().getColumn(i).setMinWidth(0);
tableSamples.getColumnModel().getColumn(i).setMaxWidth(0);
tableSamples.getColumnModel().getColumn(i).setWidth(0);
}
}
}
void onSelectionChanged(String segment, Integer puck, Integer sample) {
@@ -876,18 +900,18 @@ public class MainPanel extends Panel {
panelHexiposiLayout.setHorizontalGroup(
panelHexiposiLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelHexiposiLayout.createSequentialGroup()
.addContainerGap(13, Short.MAX_VALUE)
.addContainerGap(9, Short.MAX_VALUE)
.addGroup(panelHexiposiLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
.addComponent(buttonDetectCover)
.addComponent(hexiposiPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(14, Short.MAX_VALUE))
.addContainerGap(9, Short.MAX_VALUE))
);
panelHexiposiLayout.setVerticalGroup(
panelHexiposiLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(panelHexiposiLayout.createSequentialGroup()
.addContainerGap(15, Short.MAX_VALUE)
.addContainerGap(14, Short.MAX_VALUE)
.addComponent(hexiposiPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 10, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 9, Short.MAX_VALUE)
.addComponent(buttonDetectCover)
.addContainerGap())
);
@@ -914,11 +938,11 @@ public class MainPanel extends Panel {
panelViewTypeLayout.setHorizontalGroup(
panelViewTypeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelViewTypeLayout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap(8, Short.MAX_VALUE)
.addGroup(panelViewTypeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
.addComponent(buttonDrawing)
.addComponent(buttonCamera))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap(8, Short.MAX_VALUE))
);
panelViewTypeLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonCamera, buttonDrawing});
@@ -1374,9 +1398,9 @@ public class MainPanel extends Panel {
.addGroup(panelDevicesLayout.createSequentialGroup()
.addGap(0, 0, 0)
.addComponent(devicesPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 26, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(panelExpert, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(30, Short.MAX_VALUE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
panelDevicesLayout.setVerticalGroup(
panelDevicesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@@ -1385,7 +1409,7 @@ public class MainPanel extends Panel {
.addGroup(panelDevicesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(panelExpert, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(devicesPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 235, Short.MAX_VALUE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap(8, Short.MAX_VALUE))
);
javax.swing.GroupLayout panelRightLayout = new javax.swing.GroupLayout(panelRight);
@@ -1404,7 +1428,7 @@ public class MainPanel extends Panel {
panelRightLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(panelRightLayout.createSequentialGroup()
.addGap(0, 0, 0)
.addComponent(panelDetail, javax.swing.GroupLayout.DEFAULT_SIZE, 107, Short.MAX_VALUE)
.addComponent(panelDetail, javax.swing.GroupLayout.DEFAULT_SIZE, 108, Short.MAX_VALUE)
.addGap(0, 0, 0)
.addComponent(panelDevices, javax.swing.GroupLayout.PREFERRED_SIZE, 280, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, 0)
@@ -1575,7 +1599,7 @@ public class MainPanel extends Panel {
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(panelTop, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGap(0, 0, 0)
.addComponent(panelBottom, javax.swing.GroupLayout.DEFAULT_SIZE, 74, Short.MAX_VALUE)
.addComponent(panelBottom, javax.swing.GroupLayout.DEFAULT_SIZE, 76, Short.MAX_VALUE)
.addGap(1, 1, 1))
);
}// </editor-fold>//GEN-END:initComponents

View File

@@ -18,7 +18,7 @@ import java.util.ArrayList;
public class Puck extends DeviceBase {
final static int signalX = -1;
final static PointDouble[] samplesPosition = new PointDouble[]{
final static PointDouble[] SAMPLES_POSITION_NORMAL = new PointDouble[]{
new PointDouble(0 * signalX, 24.24),
new PointDouble(23.05360995 * signalX, 7.490571944),
new PointDouble(14.24791452* signalX, -19.61057194),
@@ -37,6 +37,21 @@ public class Puck extends DeviceBase {
new PointDouble(-28.39445573 * signalX, 44.18263554)
};
final static PointDouble[] SAMPLES_POSITION_RT = new PointDouble[]{
new PointDouble(-30.0,-40.0),
new PointDouble(-2.0, -30.0),
new PointDouble(25.0, -40.0),
new PointDouble(45.0, -15.0),
new PointDouble(-30.0,0.0),
new PointDouble(-30.0, 40.0),
new PointDouble(-2.0, 30.0),
new PointDouble(25.0, 40.0),
new PointDouble(45.0, 15.0)
};
final static PointDouble[] samplesPosition = (MainPanel.BASE_PLATE_LAYOUT == MainPanel.BasePlateLayout.rt) ?
SAMPLES_POSITION_RT : SAMPLES_POSITION_NORMAL;
static final Character[] SEGMENTS_NORMAL =new Character[]{
'A', 'A','A', 'A', 'A',
'B', 'B', 'B', 'B', 'B',
@@ -64,6 +79,10 @@ public class Puck extends DeviceBase {
'F', 'F', 'F', 'F', 'F',
};
static final Character[] SEGMENTS_RT =new Character[]{
'A', 'B','C', 'D', 'E', 'F'
};
static final int[] NUMBERS_NORMAL = new int[]{
1, 2, 3, 4, 5,
1, 2, 3, 4, 5,
@@ -90,6 +109,10 @@ public class Puck extends DeviceBase {
1, 2, 3, 4, 5,
1, 2, 3, 4, 5,
};
static final int[] NUMBERS_RT = new int[]{
1, 1, 1, 1, 1, 1
};
static final int[] ADDRESSES_NORMAL = new int[]{
1, 2, 3, 4, 5,
@@ -144,12 +167,19 @@ public class Puck extends DeviceBase {
240.00, 240.00, 210.00, 220.89, 199.11,
};
static final double[] ANGLES_RT = new double[]{
0.00, 0.00, 0.00, 0.00, 0.00, 0.00
};
static final Character[] SEGMENTS = (MainPanel.BASE_PLATE_LAYOUT == MainPanel.BasePlateLayout.normal) ? SEGMENTS_NORMAL : (
(MainPanel.BASE_PLATE_LAYOUT == MainPanel.BasePlateLayout.sf) ? SEGMENTS_SF : SEGMENTS_6D
(MainPanel.BASE_PLATE_LAYOUT == MainPanel.BasePlateLayout.sf) ? SEGMENTS_SF : (
(MainPanel.BASE_PLATE_LAYOUT == MainPanel.BasePlateLayout.rt) ? SEGMENTS_RT : SEGMENTS_6D
)
);
static final int[] NUMBERS = (MainPanel.BASE_PLATE_LAYOUT == MainPanel.BasePlateLayout.normal) ? NUMBERS_NORMAL : (
(MainPanel.BASE_PLATE_LAYOUT == MainPanel.BasePlateLayout.sf) ? NUMBERS_SF : NUMBERS_6D
(MainPanel.BASE_PLATE_LAYOUT == MainPanel.BasePlateLayout.sf) ? NUMBERS_SF :
((MainPanel.BASE_PLATE_LAYOUT == MainPanel.BasePlateLayout.rt) ? NUMBERS_RT : NUMBERS_6D)
);
@@ -159,7 +189,8 @@ public class Puck extends DeviceBase {
static final double[] ANGLES = (MainPanel.BASE_PLATE_LAYOUT == MainPanel.BasePlateLayout.normal) ? ANGLES_NORMAL : (
(MainPanel.BASE_PLATE_LAYOUT == MainPanel.BasePlateLayout.sf) ? ANGLES_SF : ANGLES_6D
(MainPanel.BASE_PLATE_LAYOUT == MainPanel.BasePlateLayout.sf) ? ANGLES_SF :
((MainPanel.BASE_PLATE_LAYOUT == MainPanel.BasePlateLayout.rt) ? ANGLES_RT : ANGLES_6D)
);
final static PointDouble referencePosition = new PointDouble(0.0, -66.9 - 0.2);
@@ -168,12 +199,15 @@ public class Puck extends DeviceBase {
final static PointDouble ledMinispinePosition = new PointDouble(0.0, -36.0);
final static Double unipuckLedSize = 10.0;
final static Double minispineLedSize = 8.0;
PuckType puckType = PuckType.Unknown;
public PuckType getPuckType(){
if (MainPanel.BASE_PLATE_LAYOUT == MainPanel.BasePlateLayout.rt){
return PuckType.RT;
}
return puckType;
}
@@ -185,16 +219,19 @@ public class Puck extends DeviceBase {
Empty,
Minispine,
Unipuck,
RT,
Error,
Unknown;
public boolean isDefined(){
return (this==Minispine) || (this==Unipuck);
return (this==Minispine) || (this==Unipuck)|| (this==RT);
}
}
public String getStatus(){
Detection detection = getDetection();
PuckType puckType = getPuckType();
if ((detection==Detection.Present) && puckType.isDefined()) {
return puckType.toString();
}
@@ -347,7 +384,7 @@ public class Puck extends DeviceBase {
}
public int getUserIndex(){
return (getSegment() - new Character('A')) * 5 + getNumber() - 1;
return (getSegment() - new Character('A')) * BasePlate.numberOfPucksPerSegments + getNumber() - 1;
}
boolean enabled;
@@ -370,6 +407,9 @@ public class Puck extends DeviceBase {
Detection detection = Detection.Error;
public Detection getDetection() {
if (MainPanel.BASE_PLATE_LAYOUT == MainPanel.BasePlateLayout.rt){
return Detection.Present;
}
return detection;
}

View File

@@ -104,7 +104,7 @@ public class PuckGraphics {
if (puck.isDisabled()){
return basePlateGraphics.getColor();
}
switch (puck.detection) {
switch (puck.getDetection()) {
case Empty:
//ret = isHighlithted() ? new Color(224, 224, 224) : Color.LIGHT_GRAY;
ret = getEmptyColor();
@@ -142,9 +142,14 @@ public class PuckGraphics {
int getDrawSize() {
//All pucks
if (basePlateGraphics!=null) {
DimensionDouble puckSize = puck.getSize();
if (MainPanel.BASE_PLATE_LAYOUT == MainPanel.BasePlateLayout.rt){
puckSize = new DimensionDouble(100,100);
}
Rectangle rect = basePlateGraphics.getBoundingBox(); //TODO
int ret = Math.min((int) Math.round(((double)puck.getSize().getWidth() / basePlate.getSize().getWidth()) * rect.width),
(int) Math.round(((double)puck.getSize().getHeight() / basePlate.getSize().getHeight()) * rect.height)
int ret = Math.min((int) Math.round(((double)puckSize.getWidth() / basePlate.getSize().getWidth()) * rect.width),
(int) Math.round(((double)puckSize.getHeight() / basePlate.getSize().getHeight()) * rect.height)
);
if (puck.isSelected()) {
ret += 2;
@@ -228,10 +233,16 @@ public class PuckGraphics {
}
int getReferenceDrawSize() {
if (MainPanel.BASE_PLATE_LAYOUT == MainPanel.BasePlateLayout.rt){
return getDrawSize(10.0) ;
}
return getDrawSize(puck.referenceSize) ;
}
Point getReferenceDrawPosition() {
if (MainPanel.BASE_PLATE_LAYOUT == MainPanel.BasePlateLayout.rt){
return getDrawPosition(new PointDouble(-67.0, 0.0));
}
return getDrawPosition(new PointDouble(0, -67.0));
}
@@ -270,13 +281,23 @@ public class PuckGraphics {
g.setColor(refColor);
position = getReferenceDrawPosition();
size = getReferenceDrawSize();
//size+=1;
g.fillOval(position.x - size / 2, position.y - size / 2, size, size);
g.setColor(getBorderColor(drawBackground));
//size-=1;
g.setStroke(new BasicStroke(getBorderWidth(drawBackground)));
g.drawArc(position.x - size / 2, position.y - size / 2 , size, size, (int) (190 + (rotated ? puck.angle : 0)), 154);
g.setStroke(new BasicStroke(1f));
if (MainPanel.BASE_PLATE_LAYOUT == MainPanel.BasePlateLayout.rt){
g.fillRect(position.x-1, position.y - size*3 , size+1, size*6);
g.setColor(getBorderColor(drawBackground));
//size-=1;
g.setStroke(new BasicStroke(getBorderWidth(drawBackground)));
int height = (int)(size*2.4);
g.drawLine(position.x+size, position.y -height , position.x +size, position.y +height);
g.setStroke(new BasicStroke(1f));
} else {
//size+=1;
g.fillOval(position.x - size / 2, position.y - size / 2, size, size);
g.setColor(getBorderColor(drawBackground));
//size-=1;
g.setStroke(new BasicStroke(getBorderWidth(drawBackground)));
g.drawArc(position.x - size / 2, position.y - size / 2 , size, size, (int) (190 + (rotated ? puck.angle : 0)), 154);
g.setStroke(new BasicStroke(1f));
}
} else {
Point pu = getDrawUnipuckLedPosition();
Point pm = getDrawMinispineLedPosition();

View File

@@ -10,6 +10,7 @@ public class SampleInfo extends HashMap {
public enum PuckType {
Unipuck,
MiniSpine,
RT,
Unknown
}