diff --git a/nb-configuration.xml b/nb-configuration.xml
index 1b67107a..f7bd337c 100644
--- a/nb-configuration.xml
+++ b/nb-configuration.xml
@@ -39,5 +39,6 @@ Any value defined here will override the pom.xml file value but is only applicab
true
LF
false
+ JDK_21_Temurin
diff --git a/src/main/java/jcs/JCS.java b/src/main/java/jcs/JCS.java
index f4fae943..689b9287 100755
--- a/src/main/java/jcs/JCS.java
+++ b/src/main/java/jcs/JCS.java
@@ -68,9 +68,7 @@ public class JCS extends Thread {
private static UICallback uiCallback;
- //private final List refreshEventListeners;
private JCS() {
- //refreshEventListeners = new ArrayList<>();
}
public static void logProgress(String message) {
@@ -237,6 +235,12 @@ public static void main(String[] args) {
JCS jcs = JCS.getInstance();
jcs.startGui();
+
+ //check the connection to the command station
+ if (!JCS.getJcsCommandStation().isConnected()) {
+ JCS.getJcsCommandStation().connectInBackground();
+ }
+
} else {
Logger.error("Could not obtain a Persistent store. Quitting....");
logProgress("Error! Can't Obtain a Persistent store!");
@@ -286,8 +290,6 @@ private void startGui() {
jcsFrame.setVisible(true);
jcsFrame.toFront();
jcsFrame.showOverviewPanel();
- boolean con = "true".equalsIgnoreCase(System.getProperty("controller.autoconnect", "true"));
- jcsFrame.connect(con);
});
JCS.logProgress("JCS started...");
diff --git a/src/main/java/jcs/commandStation/JCSCommandStation.java b/src/main/java/jcs/commandStation/JCSCommandStation.java
index 66680d7d..ec9c9a3a 100755
--- a/src/main/java/jcs/commandStation/JCSCommandStation.java
+++ b/src/main/java/jcs/commandStation/JCSCommandStation.java
@@ -118,27 +118,36 @@ private JCSCommandStation(boolean autoConnectController) {
}
}
- public final boolean connectInBackground() {
- executor.execute(() -> connect());
-
+ public final synchronized boolean connectInBackground() {
long now = System.currentTimeMillis();
- long timemax = now + 2000;
+ long start = now;
+ long timemax = now + 3000;
+
+ executor.execute(() -> connect());
- boolean con;
- synchronized (this) {
+ boolean con = false;
+ if (decoderController != null) {
con = decoderController.isConnected();
- while (!con && timemax < now) {
- try {
- wait(500);
- } catch (InterruptedException ex) {
- Logger.trace(ex);
- }
- now = System.currentTimeMillis();
- }
- if (!(timemax < now)) {
- Logger.trace("Timeout connecting...");
+ } else {
+ Logger.trace("Can't connect as there is no DecoderController configured !");
+ }
+
+ while (!con && now < timemax) {
+ try {
+ wait(500);
+ } catch (InterruptedException ex) {
+ Logger.trace(ex);
}
+ now = System.currentTimeMillis();
+ con = decoderController.isConnected();
}
+
+ if (con) {
+ Logger.trace("Connected to " + decoderController.getCommandStationBean().getDescription() + " in " + (now - start) + " ms");
+ } else {
+ Logger.trace("Timeout connecting...");
+ }
+
return con;
}
@@ -439,7 +448,7 @@ public boolean isPowerOn() {
}
public void changeLocomotiveDirection(Direction newDirection, LocomotiveBean locomotive) {
- Logger.debug("Changing direction to " + newDirection + " for: " + locomotive.getName() + " id: " + locomotive.getId());
+ Logger.debug("Changing direction to " + newDirection + " for: " + locomotive.getName() + " id: " + locomotive.getId() + " velocity: "+ locomotive.getVelocity());
int address;
if ("marklin.cs".equals(locomotive.getCommandStationId()) || "esu-ecos".equals(locomotive.getCommandStationId())) {
diff --git a/src/main/java/jcs/commandStation/esu/ecos/net/EcosTCPConnection.java b/src/main/java/jcs/commandStation/esu/ecos/net/EcosTCPConnection.java
index a1cdd443..e84a702f 100644
--- a/src/main/java/jcs/commandStation/esu/ecos/net/EcosTCPConnection.java
+++ b/src/main/java/jcs/commandStation/esu/ecos/net/EcosTCPConnection.java
@@ -264,7 +264,7 @@ public void run() {
Logger.trace("Event has no END tag " + sb.toString() + " in " + (now - start) + " ms");
} else {
EcosMessage emsg = new EcosMessage(sb.toString());
- Logger.trace("Complete: " + emsg.isResponseComplete() + "\n" + emsg.getMessage() + "\n" + emsg.getResponse());
+ Logger.trace("Complete: " + emsg.isResponseComplete() + ((emsg.getMessage() != null) ? " -> " + emsg.getMessage() + " -> " : "") + emsg.getResponse());
eventQueue.offer(emsg);
}
diff --git a/src/main/java/jcs/entities/LocomotiveBean.java b/src/main/java/jcs/entities/LocomotiveBean.java
index 74f66cb8..d18c0451 100644
--- a/src/main/java/jcs/entities/LocomotiveBean.java
+++ b/src/main/java/jcs/entities/LocomotiveBean.java
@@ -54,6 +54,11 @@ public class LocomotiveBean implements Serializable {
private String dispatcherDirection;
private String locomotiveDirection;
+ private Integer speedOne;
+ private Integer speedTwo;
+ private Integer speedThree;
+ private Integer speedFour;
+
private Image locIcon;
private CommandStationBean commandStationBean;
@@ -321,6 +326,42 @@ public void setCommandStationId(String commandStationId) {
this.commandStationId = commandStationId;
}
+ @Column(name = "speed_1")
+ public Integer getSpeedOne() {
+ return speedOne;
+ }
+
+ public void setSpeedOne(Integer speedOne) {
+ this.speedOne = speedOne;
+ }
+
+ @Column(name = "speed_2")
+ public Integer getSpeedTwo() {
+ return speedTwo;
+ }
+
+ public void setSpeedTwo(Integer speedTwo) {
+ this.speedTwo = speedTwo;
+ }
+
+ @Column(name = "speed_3")
+ public Integer getSpeedThree() {
+ return speedThree;
+ }
+
+ public void setSpeedThree(Integer speedThree) {
+ this.speedThree = speedThree;
+ }
+
+ @Column(name = "speed_4")
+ public Integer getSpeedFour() {
+ return speedFour;
+ }
+
+ public void setSpeedFour(Integer speedFour) {
+ this.speedFour = speedFour;
+ }
+
@Transient
public CommandStationBean getCommandStationBean() {
return commandStationBean;
diff --git a/src/main/java/jcs/entities/SensorBean.java b/src/main/java/jcs/entities/SensorBean.java
index a9d69ca8..129a3103 100755
--- a/src/main/java/jcs/entities/SensorBean.java
+++ b/src/main/java/jcs/entities/SensorBean.java
@@ -371,18 +371,11 @@ public boolean equalsId(Object obj) {
@Override
public String toString() {
- //return name;
- return toLogString();
+ return name;
+ //return toLogString();
}
public String toLogString() {
-// String ids;
-// if (id == null) {
-// ids = "(" + generateId() + ")";
-// } else {
-// ids = id;
-// }
-
return "SensorBean{"
+ "id="
+ id
diff --git a/src/main/java/jcs/persistence/H2PersistenceService.java b/src/main/java/jcs/persistence/H2PersistenceService.java
index 2959d1a3..491dafc8 100755
--- a/src/main/java/jcs/persistence/H2PersistenceService.java
+++ b/src/main/java/jcs/persistence/H2PersistenceService.java
@@ -251,7 +251,7 @@ public FunctionBean getLocomotiveFunction(LocomotiveBean locomotive, Integer num
@Override
public FunctionBean getLocomotiveFunction(Long locomotiveId, Integer number) {
- String commandStationId = getDefaultCommandStation().getId();
+ //String commandStationId = getDefaultCommandStation().getId();
FunctionBean fb = database.where("locomotive_id=? and f_number=?", locomotiveId, number).first(FunctionBean.class);
if (fb != null) {
@@ -970,15 +970,15 @@ public synchronized BlockBean persist(BlockBean block) {
database.insert(block);
}
- changeSupport.firePropertyChange("data.blockr", prev, block);
+ changeSupport.firePropertyChange("data.block", prev, block);
return block;
}
@Override
public synchronized void remove(BlockBean block) {
- int rows = this.database.delete(block).getRowsAffected();
+ int rows = database.delete(block).getRowsAffected();
Logger.trace(rows + " rows deleted");
- changeSupport.firePropertyChange("data.sblock.deleted", block, null);
+ changeSupport.firePropertyChange("data.block.deleted", block, null);
}
@Override
@@ -990,7 +990,6 @@ public synchronized void removeAllBlocks() {
@Override
public List getCommandStations() {
- //List commandStationBeans = database.where("enabled=true").results(CommandStationBean.class);
List commandStationBeans = database.results(CommandStationBean.class);
return commandStationBeans;
}
diff --git a/src/main/java/jcs/ui/DispatcherStatusPanel.java b/src/main/java/jcs/ui/DispatcherStatusPanel.java
index ffa01da7..230f3ef7 100644
--- a/src/main/java/jcs/ui/DispatcherStatusPanel.java
+++ b/src/main/java/jcs/ui/DispatcherStatusPanel.java
@@ -17,13 +17,12 @@
import javax.swing.JPanel;
import jcs.commandStation.events.RefreshEvent;
-import jcs.commandStation.events.RefreshEventListener;
import jcs.ui.util.LocomotiveSelectionChangedListener;
/**
*
*/
-public class DispatcherStatusPanel extends JPanel implements RefreshEventListener {
+public class DispatcherStatusPanel extends JPanel { //implements RefreshEventListener {
private static final long serialVersionUID = 6158244271104499799L;
@@ -43,15 +42,14 @@ public void refresh() {
locomotiveTablePanel.refresh();
}
- @Override
- public void onChange(RefreshEvent event) {
- locomotiveTablePanel.onChange(event);
- }
+// @Override
+// public void onChange(RefreshEvent event) {
+// locomotiveTablePanel.onChange(event);
+// }
public void addLocomotiveSelectionChangeListener(LocomotiveSelectionChangedListener listener) {
locomotiveTablePanel.addLocomotiveSelectionChangeListener(listener);
dispatcherTablePanel.addLocomotiveSelectionChangeListener(listener);
-
}
public void removeLocomotiveSelectionChangeListener(LocomotiveSelectionChangedListener listener) {
diff --git a/src/main/java/jcs/ui/DriverCabPanel.java b/src/main/java/jcs/ui/DriverCabPanel.java
index 145ec0cd..11fc5a86 100644
--- a/src/main/java/jcs/ui/DriverCabPanel.java
+++ b/src/main/java/jcs/ui/DriverCabPanel.java
@@ -17,6 +17,7 @@
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
+import javax.swing.JPanel;
import javax.swing.JSlider;
import javax.swing.event.ChangeListener;
import jcs.JCS;
@@ -34,7 +35,7 @@
*
* @author frans
*/
-public class DriverCabPanel extends javax.swing.JPanel implements LocomotiveDirectionEventListener, LocomotiveSpeedEventListener, PowerEventListener {
+public class DriverCabPanel extends JPanel implements LocomotiveDirectionEventListener, LocomotiveSpeedEventListener, PowerEventListener {
private static final long serialVersionUID = 8833627645563021982L;
@@ -53,7 +54,7 @@ public DriverCabPanel() {
}
public DriverCabPanel(LocomotiveBean locomotiveBean) {
- executor = Executors.newFixedThreadPool(3);
+ executor = Executors.newCachedThreadPool();
initComponents();
postInit();
setLocomotiveBean(locomotiveBean);
@@ -416,20 +417,21 @@ public void onDirectionChange(LocomotiveDirectionEvent event) {
if (event.isEventFor(locomotiveBean)) {
Logger.trace(lb.getName() + " direction changed from " + this.locomotiveBean.getDirection() + " to " + lb.getDirection());
+ disableListener = true;
- //locomotiveBean.setRichtung(lb.getRichtung());
locomotiveBean.setDirection(lb.getDirection());
- disableListener = true;
if (Direction.BACKWARDS.equals(lb.getDirection())) {
this.reverseButton.setSelected(true);
} else {
this.forwardButton.setSelected(true);
}
- disableListener = false;
+
if (this.directionListener != null) {
this.directionListener.onDirectionChange(event);
}
+
+ disableListener = false;
}
}
diff --git a/src/main/java/jcs/ui/JCSFrame.java b/src/main/java/jcs/ui/JCSFrame.java
index fc38cc65..c334ac43 100755
--- a/src/main/java/jcs/ui/JCSFrame.java
+++ b/src/main/java/jcs/ui/JCSFrame.java
@@ -220,6 +220,8 @@ private void showLocomotives() {
locomotiveDialog.setLocationRelativeTo(null);
}
locomotiveDialog.setVisible(true);
+
+ //Should add a listener here?
}
private void showAccessories() {
@@ -969,20 +971,16 @@ public void connect(boolean connect) {
if (JCS.getJcsCommandStation() != null) {
if (connect) {
String ip = JCS.getJcsCommandStation().getCommandStationBean().getIpAddress();
+ String name = JCS.getJcsCommandStation().getCommandStationBean().getDescription();
if (Ping.IsReachable(ip)) {
if ("AWT-EventQueue-0".equals(Thread.currentThread().getName())) {
JCS.getJcsCommandStation().connectInBackground();
} else {
-
JCS.getJcsCommandStation().connect();
}
} else {
Logger.debug("Can't reach ip " + ip + "...");
-
-
- JOptionPane.showMessageDialog(this, "Can't connect. "+ip+" is not reachable.", "Can't Connect", JOptionPane.ERROR_MESSAGE, null);
-
-
+ JOptionPane.showMessageDialog(this, "Can't connect to " + name + ", " + ip + " is not reachable.", "Can't Connect", JOptionPane.ERROR_MESSAGE, null);
}
InfoBean info = JCS.getJcsCommandStation().getCommandStationInfo();
@@ -1147,7 +1145,7 @@ private void startAllLocomotives() {
private String getTitleString() {
String jcsVersion = VersionInfo.getVersion();
- if (JCS.getJcsCommandStation() != null && JCS.getJcsCommandStation().getCommandStationInfo() != null) {
+ if (JCS.getJcsCommandStation() != null && JCS.getJcsCommandStation().getCommandStationInfo() != null && JCS.getJcsCommandStation().getCommandStationInfo().getProductName() != null) {
InfoBean info = JCS.getJcsCommandStation().getCommandStationInfo();
return "JCS " + "Connected to " + info.getProductName();
} else {
@@ -1207,6 +1205,14 @@ public void powerChanged(PowerEvent event) {
powerButton.setSelected(event.isPower());
}
+ public void refreshData() {
+ Logger.trace("Refresh data due to settings change...");
+ }
+
+ public void refreshLocomotives() {
+ this.dispatcherStatusPanel.refresh();
+ }
+
// Variables declaration - do not modify//GEN-BEGIN:variables
private JMenuItem aboutMI;
diff --git a/src/main/java/jcs/ui/KeyboardSensorPanel.java b/src/main/java/jcs/ui/KeyboardSensorPanel.java
index 685ce5a5..39ca7740 100755
--- a/src/main/java/jcs/ui/KeyboardSensorPanel.java
+++ b/src/main/java/jcs/ui/KeyboardSensorPanel.java
@@ -24,7 +24,6 @@
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
-import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
diff --git a/src/main/java/jcs/ui/VNCPanel.java b/src/main/java/jcs/ui/VNCPanel.java
index d7b100f9..d4cab75d 100644
--- a/src/main/java/jcs/ui/VNCPanel.java
+++ b/src/main/java/jcs/ui/VNCPanel.java
@@ -53,18 +53,20 @@
* In hind site I think is a welcome addition, hance this is added into the main frame
*
*/
-public class VNCPanel extends javax.swing.JPanel {
-
+public class VNCPanel extends JPanel {
+
+ private static final long serialVersionUID = -2967801064769591519L;
+
private Image lastFrame;
private VernacularConfig config;
private VernacularClient client;
private static final int DEFAULT_VNC_PORT = 5900;
-
+
public VNCPanel() {
initComponents();
initVnc();
}
-
+
private void initVnc() {
try {
if (JCS.getJcsCommandStation() != null) {
@@ -75,12 +77,12 @@ private void initVnc() {
if (JCS.getJcsCommandStation().isConnected()) {
String ip = JCS.getJcsCommandStation().getCommandStationInfo().getIpAddress();
int port = DEFAULT_VNC_PORT;
-
- if(Ping.IsReachable(ip)) {
+
+ if (Ping.IsReachable(ip)) {
connect(ip, port);
} else {
- Logger.trace("Can't reach "+ip+" ...");
- }
+ Logger.trace("Can't reach " + ip + " ...");
+ }
}
}
}
@@ -88,9 +90,10 @@ private void initVnc() {
Logger.warn("Error during init " + e.getMessage());
}
}
-
+
private void addDrawingSurface() {
this.viewerPanel.add(new JPanel() {
+ private static final long serialVersionUID = -1852494391952623917L;
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
@@ -112,7 +115,7 @@ public void paintComponent(Graphics g) {
}
}, CENTER);
}
-
+
private void initialiseVernacularClient() {
config = new VernacularConfig();
config.setColorDepth(BPP_24_TRUE);
@@ -128,19 +131,19 @@ private void initialiseVernacularClient() {
config.setRemoteClipboardListener(t -> getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(t), null));
//config.setUseLocalMousePointer(localCursorMenuItem.isSelected());
config.setUseLocalMousePointer(true);
-
+
config.setEnableCopyrectEncoding(true);
config.setEnableRreEncoding(true);
config.setEnableHextileEncoding(true);
config.setEnableZLibEncoding(false);
-
+
client = new VernacularClient(config);
}
-
+
private boolean resizeRequired(Image frame) {
return lastFrame == null || lastFrame.getWidth(null) != frame.getWidth(null) || lastFrame.getHeight(null) != frame.getHeight(null);
}
-
+
private void renderFrame(Image frame) {
if (resizeRequired(frame)) {
resizeWindow(frame);
@@ -148,7 +151,7 @@ private void renderFrame(Image frame) {
lastFrame = frame;
repaint();
}
-
+
private void resizeWindow(Image frame) {
int remoteWidth = frame.getWidth(null);
int remoteHeight = frame.getHeight(null);
@@ -160,7 +163,7 @@ private void resizeWindow(Image frame) {
int paddingTop = getHeight() - this.viewerPanel.getHeight();
int paddingSides = getWidth() - this.viewerPanel.getWidth();
int maxWidth = (int) screenSize.getWidth() - paddingSides;
-
+
int maxHeight = (int) screenSize.getHeight() - paddingTop;
if (remoteWidth <= maxWidth && remoteHeight < maxHeight) {
setWindowSize(remoteWidth, remoteHeight);
@@ -171,40 +174,40 @@ private void resizeWindow(Image frame) {
setWindowSize(scaledWidth, scaledHeight);
}
}
-
+
private void setWindowSize(int width, int height) {
this.viewerPanel.setPreferredSize(new Dimension(width, height));
}
-
+
private void resetUI() {
setCursor(getDefaultCursor());
lastFrame = null;
repaint();
}
-
+
private boolean connected() {
return client != null && client.isRunning();
}
-
+
private void connect(String host, int port) {
lastFrame = null;
client.start(host, port);
}
-
+
private void disconnect() {
if (connected()) {
client.stop();
}
resetUI();
}
-
+
private int scaleMouseX(int x) {
if (lastFrame == null) {
return x;
}
return (int) (x * ((double) lastFrame.getWidth(null) / this.viewerPanel.getWidth()));
}
-
+
private int scaleMouseY(int y) {
if (lastFrame == null) {
return y;
@@ -375,19 +378,19 @@ public static void main(String args[]) {
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) {
Logger.error("Can't set the LookAndFeel: " + ex);
}
-
+
java.awt.EventQueue.invokeLater(() -> {
VNCPanel vncPanel = new VNCPanel();
JFrame testFrame = new JFrame("VNCPanel Tester");
-
+
URL iconUrl = KeyboardSensorPanel.class.getResource("/media/jcs-train-64.png");
if (iconUrl != null) {
testFrame.setIconImage(new ImageIcon(iconUrl).getImage());
}
-
+
JFrame.setDefaultLookAndFeelDecorated(true);
testFrame.add(vncPanel);
-
+
testFrame.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
@@ -402,5 +405,5 @@ public void windowClosing(java.awt.event.WindowEvent e) {
testFrame.setVisible(true);
});
}
-
+
}
diff --git a/src/main/java/jcs/ui/layout/LayoutCanvas.java b/src/main/java/jcs/ui/layout/LayoutCanvas.java
index a3ce2914..89d15fcb 100755
--- a/src/main/java/jcs/ui/layout/LayoutCanvas.java
+++ b/src/main/java/jcs/ui/layout/LayoutCanvas.java
@@ -88,8 +88,7 @@ public enum Mode {
CONTROL
}
- static final int LINE_GRID = 0;
- static final int DOT_GRID = 1;
+ static final int LINE_GRID = 1;
private int gridType = LINE_GRID;
@@ -109,6 +108,8 @@ public enum Mode {
private RoutesDialog routesDialog;
+ private boolean showCenter;
+
public LayoutCanvas() {
this(false);
}
@@ -119,9 +120,11 @@ public LayoutCanvas(boolean readonly) {
setOpaque(true);
setDoubleBuffered(true);
+ showCenter = "true".equalsIgnoreCase(System.getProperty("tile.show.center", "false"));
+
this.readonly = readonly;
- this.executor = Executors.newSingleThreadExecutor();
- //this.executor = Executors.newCachedThreadPool();
+ drawGrid = !readonly;
+ this.executor = Executors.newCachedThreadPool();
this.mode = Mode.SELECT;
this.orientation = Orientation.EAST;
@@ -145,10 +148,12 @@ public void paint(Graphics g) {
super.paint(g);
if (drawGrid) {
- if (this.gridType == LINE_GRID) {
- paintLineGrid(g);
- } else {
- paintDotGrid(g);
+ switch (gridType) {
+ case 1 ->
+ paintLineGrid(g);
+ case 2 ->
+ paintDotGrid(g);
+ //default -> no grid
}
}
@@ -216,19 +221,9 @@ void setMode(LayoutCanvas.Mode mode) {
Logger.trace("Mode: " + mode);
}
- void setDrawGrid(boolean flag) {
- if (flag) {
- switch (gridType) {
- case LINE_GRID ->
- gridType = DOT_GRID;
- case DOT_GRID ->
- gridType = LINE_GRID;
- default ->
- gridType = LINE_GRID;
- }
- }
- drawGrid = flag;
- repaint();
+ void setGridType(int gridType) {
+ this.gridType = gridType;
+ executor.execute((() -> repaint()));
}
void setTileType(TileBean.TileType tileType) {
@@ -241,23 +236,16 @@ void setDirection(Direction direction) {
}
void loadLayoutInBackground() {
- this.executor.execute(() -> loadTiles());
-
-// new Thread(new Runnable() {
-// public void run() {
-// final String text = readHugeFile();
-// SwingUtilities.invokeLater(new Runnable() {
-// public void run() {
-// canvas.setTiles();
-// }
-// });
-// }
-// }).start();
- }
+ executor.execute(() -> {
+ List tiles = TileCache.loadTiles(readonly);
- private void loadTiles() {
- List tiles = TileCache.loadTiles(readonly);
+ java.awt.EventQueue.invokeLater(() -> {
+ loadTiles(tiles);
+ });
+ });
+ }
+ private void loadTiles(List tiles) {
removeAll();
selectedTile = null;
@@ -285,7 +273,6 @@ private void loadTiles() {
for (Tile tile : tiles) {
add(tile);
- boolean showCenter = "true".equalsIgnoreCase(System.getProperty("tile.show.center", "false"));
if (showCenter) {
tile.setDrawCenterPoint(showCenter);
}
@@ -293,7 +280,7 @@ private void loadTiles() {
}
private void mouseMoveAction(MouseEvent evt) {
- Point sp = LayoutUtil.snapToGrid(evt.getPoint());
+ //Point sp = LayoutUtil.snapToGrid(evt.getPoint());
if (selectedTile != null) {
setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
} else {
@@ -352,10 +339,10 @@ private void mousePressedAction(MouseEvent evt) {
}
}
case DELETE -> {
- Tile toBeDeleted = (Tile) getComponentAt(snapPoint);
- if (toBeDeleted != null) {
+ Component c = getComponentAt(snapPoint);
+ if (c != null && c instanceof Tile) {
+ Tile toBeDeleted = (Tile) c;
removeTile(toBeDeleted);
- //selectedTiles.clear();
repaint(toBeDeleted.getTileBounds());
selectedTile = null;
}
@@ -487,7 +474,7 @@ private void executeControlActionForTile(Tile tile, Point p) {
bcd.setVisible(true);
Logger.trace("Block properties closed");
- this.repaint(block.getTileBounds());
+ repaint(block.getTileBounds());
}
case SIGNAL -> {
//this.executor.execute(() -> toggleSignal((Signal) tile));
@@ -556,6 +543,7 @@ private void editSelectedTileProperties() {
default -> {
}
}
+ //TODO: only repaint the edited tile?
repaint();
}
}
@@ -1005,8 +993,9 @@ private void resetDispatcherMIActionPerformed(ActionEvent evt) {//GEN-FIRST:even
Block block = (Block) selectedTile;
LocomotiveBean locomotive = block.getBlockBean().getLocomotive();
- this.executor.execute(() -> {
+ executor.execute(() -> {
AutoPilot.resetDispatcher(locomotive);
+
repaint();
});
}
diff --git a/src/main/java/jcs/ui/layout/LayoutPanel.form b/src/main/java/jcs/ui/layout/LayoutPanel.form
index b512ef69..f11e99af 100755
--- a/src/main/java/jcs/ui/layout/LayoutPanel.form
+++ b/src/main/java/jcs/ui/layout/LayoutPanel.form
@@ -317,16 +317,24 @@
-
+
-
+
-
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/main/java/jcs/ui/layout/LayoutPanel.java b/src/main/java/jcs/ui/layout/LayoutPanel.java
index 4f14ede6..bfc68413 100755
--- a/src/main/java/jcs/ui/layout/LayoutPanel.java
+++ b/src/main/java/jcs/ui/layout/LayoutPanel.java
@@ -18,6 +18,7 @@
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
+import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ComponentAdapter;
@@ -55,121 +56,131 @@
*
*/
public class LayoutPanel extends JPanel {
-
+
private static final long serialVersionUID = 2275543202224445302L;
-
+
private final boolean readonly;
-
+
+ private int gridType;
+
+ private static final String GRID_0 = "/media/square-grid-24.png";
+ private static final String GRID_1 = "/media/grid-2-24.png";
+ private static final String GRID_2 = "/media/grid-dot-24.png";
+
public LayoutPanel() {
this(false);
}
-
+
public LayoutPanel(boolean readonly) {
this.readonly = readonly;
initComponents();
postInit();
}
-
+
private void postInit() {
RunUtil.loadProperties();
-
- this.straightBtn.setSelected(true);
- this.canvas.setTileType(TileType.STRAIGHT);
- this.setMode(readonly ? LayoutCanvas.Mode.CONTROL : LayoutCanvas.Mode.SELECT);
-
+
+ straightBtn.setSelected(true);
+ canvas.setTileType(TileType.STRAIGHT);
+ setMode(readonly ? LayoutCanvas.Mode.CONTROL : LayoutCanvas.Mode.SELECT);
+
if (readonly) {
- this.canvas.setDrawGrid(!readonly);
-
+ //this.canvas.setDrawGrid(!readonly);
+ this.canvas.setGridType(0);
+
this.loadBtn.setEnabled(!readonly);
this.loadBtn.setVisible(!readonly);
this.toolBar.remove(this.loadBtn);
-
+
this.routeBtn.setEnabled(readonly);
this.routeBtn.setVisible(readonly);
-
+
this.selectBtn.setEnabled(!readonly);
this.selectBtn.setVisible(!readonly);
this.toolBar.remove(this.selectBtn);
-
+
this.addBtn.setEnabled(!readonly);
this.addBtn.setVisible(!readonly);
-
+
this.deleteBtn.setEnabled(!readonly);
this.deleteBtn.setVisible(!readonly);
-
+
this.gridBtn.setEnabled(!readonly);
this.gridBtn.setVisible(!readonly);
-
+
this.straightBtn.setEnabled(!readonly);
this.straightBtn.setVisible(!readonly);
-
+
this.curvedBtn.setEnabled(!readonly);
this.curvedBtn.setVisible(!readonly);
-
+
this.blockBtn.setEnabled(!readonly);
this.blockBtn.setVisible(!readonly);
-
+
this.sensorBtn.setEnabled(!readonly);
this.sensorBtn.setVisible(!readonly);
-
+
this.signalBtn.setEnabled(!readonly);
this.signalBtn.setVisible(!readonly);
-
+
this.leftSwitchBtn.setEnabled(!readonly);
this.leftSwitchBtn.setVisible(!readonly);
-
+
this.rightSwitchBtn.setEnabled(!readonly);
this.rightSwitchBtn.setVisible(!readonly);
-
+
this.crossLBtn.setEnabled(!readonly);
this.crossLBtn.setVisible(!readonly);
-
+
this.crossRBtn.setEnabled(!readonly);
this.crossRBtn.setVisible(!readonly);
-
+
this.endTrackBtn.setEnabled(!readonly);
this.endTrackBtn.setVisible(!readonly);
-
+
this.straightDirectionBtn.setEnabled(!readonly);
this.straightDirectionBtn.setVisible(!readonly);
-
+
this.crossingBtn.setEnabled(!readonly);
this.crossingBtn.setVisible(!readonly);
-
+
this.flipVerticalBtn.setEnabled(!readonly);
this.flipVerticalBtn.setVisible(!readonly);
-
+
this.flipHorizontalBtn.setEnabled(!readonly);
this.flipHorizontalBtn.setVisible(!readonly);
+ } else {
+ gridType = 1;
+ gridBtn.setIcon(new ImageIcon(getClass().getResource(GRID_1)));
+ canvas.setGridType(gridType);
}
- this.toolBar.remove(this.autoPilotBtn);
- this.toolBar.remove(this.resetAutopilotBtn);
- this.toolBar.remove(this.startAllLocomotivesBtn);
-
+ toolBar.remove(autoPilotBtn);
+ toolBar.remove(resetAutopilotBtn);
+ toolBar.remove(startAllLocomotivesBtn);
+
if (readonly) {
loadLayout();
Powerlistener powerlistener = new Powerlistener();
JCS.getJcsCommandStation().addPowerEventListener(powerlistener);
}
-
}
-
+
public void loadLayout() {
canvas.loadLayoutInBackground();
}
-
+
public void rotateSelectedTile() {
canvas.rotateSelectedTile();
}
-
+
public void flipSelectedTileHorizontal() {
canvas.flipSelectedTileHorizontal();
}
-
+
public void flipSelectedTileVerical() {
canvas.flipSelectedTileVertical();
}
-
+
public void deleteSelectedTile() {
canvas.deleteSelectedTile();
}
@@ -204,7 +215,7 @@ private void initComponents() {
startAllLocomotivesBtn = new JToggleButton();
resetAutopilotBtn = new JButton();
filler1 = new Box.Filler(new Dimension(20, 0), new Dimension(20, 0), new Dimension(20, 32767));
- gridBtn = new JToggleButton();
+ gridBtn = new JButton();
filler2 = new Box.Filler(new Dimension(20, 0), new Dimension(20, 0), new Dimension(20, 32767));
selectBtn = new JButton();
addBtn = new JButton();
@@ -420,11 +431,13 @@ public void actionPerformed(ActionEvent evt) {
toolBar.add(resetAutopilotBtn);
toolBar.add(filler1);
- gridBtn.setIcon(new ImageIcon(getClass().getResource("/media/grid-2-24.png"))); // NOI18N
- gridBtn.setSelected(true);
- gridBtn.setToolTipText("Show Grid");
+ gridBtn.setIcon(new ImageIcon(getClass().getResource("/media/square-grid-24.png"))); // NOI18N
+ gridBtn.setFocusable(false);
gridBtn.setHorizontalTextPosition(SwingConstants.CENTER);
- gridBtn.setSelectedIcon(new ImageIcon(getClass().getResource("/media/grid-dot-24.png"))); // NOI18N
+ gridBtn.setMargin(new Insets(2, 2, 2, 2));
+ gridBtn.setMaximumSize(new Dimension(38, 38));
+ gridBtn.setMinimumSize(new Dimension(38, 38));
+ gridBtn.setPreferredSize(new Dimension(38, 38));
gridBtn.setVerticalTextPosition(SwingConstants.BOTTOM);
gridBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
@@ -845,10 +858,6 @@ private void sensorBtnActionPerformed(ActionEvent evt) {//GEN-FIRST:event_sensor
setTileType(TileBean.TileType.SENSOR);
}//GEN-LAST:event_sensorBtnActionPerformed
- private void gridBtnActionPerformed(ActionEvent evt) {//GEN-FIRST:event_gridBtnActionPerformed
- this.canvas.setDrawGrid(this.gridBtn.isSelected());
- }//GEN-LAST:event_gridBtnActionPerformed
-
private void formComponentResized(ComponentEvent evt) {//GEN-FIRST:event_formComponentResized
//TODO!
//Logger.debug(evt.getComponent().getSize());// TODO add your handling code here:
@@ -895,7 +904,7 @@ private void endTrackBtnActionPerformed(ActionEvent evt) {//GEN-FIRST:event_endT
private void autoPilotBtnActionPerformed(ActionEvent evt) {//GEN-FIRST:event_autoPilotBtnActionPerformed
Logger.trace(evt.getActionCommand() + (autoPilotBtn.isSelected() ? " Enable" : " Disable") + " Auto mode");
-
+
if (autoPilotBtn.isSelected()) {
startAllLocomotivesBtn.setEnabled(true);
} else {
@@ -904,7 +913,7 @@ private void autoPilotBtnActionPerformed(ActionEvent evt) {//GEN-FIRST:event_aut
//}
startAllLocomotivesBtn.setEnabled(false);
}
-
+
AutoPilot.runAutoPilot(autoPilotBtn.isSelected());
}//GEN-LAST:event_autoPilotBtnActionPerformed
@@ -923,18 +932,38 @@ private void resetAutopilotBtnActionPerformed(ActionEvent evt) {//GEN-FIRST:even
AutoPilot.reset();
}//GEN-LAST:event_resetAutopilotBtnActionPerformed
+ private void gridBtnActionPerformed(ActionEvent evt) {//GEN-FIRST:event_gridBtnActionPerformed
+ gridType++;
+ if (gridType > 2) {
+ gridType = 0;
+ }
+ switch (gridType) {
+
+ case 0 -> {
+ gridBtn.setIcon(new ImageIcon(getClass().getResource(GRID_0)));
+ }
+ case 1 -> {
+ gridBtn.setIcon(new ImageIcon(getClass().getResource(GRID_1)));
+ }
+ case 2 -> {
+ gridBtn.setIcon(new ImageIcon(getClass().getResource(GRID_2)));
+ }
+ }
+ canvas.setGridType(gridType);
+ }//GEN-LAST:event_gridBtnActionPerformed
+
private void setTileType(TileBean.TileType tileType) {
canvas.setTileType(tileType);
}
-
+
private void setDirection(Direction direction) {
canvas.setDirection(direction);
}
-
+
public void showRoutes() {
canvas.showRoutesDialog();
}
-
+
public void setMode(LayoutCanvas.Mode mode) {
switch (mode) {
case SELECT -> {
@@ -958,12 +987,12 @@ public void setMode(LayoutCanvas.Mode mode) {
deleteBtn.setIcon(new ImageIcon(getClass().getResource("/media/delete-24.png")));
}
}
-
+
canvas.setMode(mode);
}
-
+
private class Powerlistener implements PowerEventListener {
-
+
@Override
public void onPowerChange(PowerEvent event) {
//Logger.info("Track Power is " + (event.isPower() ? "on" : "off"));
@@ -998,7 +1027,7 @@ public void onPowerChange(PowerEvent event) {
private JMenuItem flipHorizontalMI;
private JButton flipVerticalBtn;
private JMenuItem flipVerticalMI;
- private JToggleButton gridBtn;
+ private JButton gridBtn;
private JMenuItem horizontalMI;
private JMenuItem leftMI;
private JToggleButton leftSwitchBtn;
diff --git a/src/main/java/jcs/ui/panel/DispatcherTablePanel.java b/src/main/java/jcs/ui/panel/DispatcherTablePanel.java
index 4783f934..9dea73d8 100644
--- a/src/main/java/jcs/ui/panel/DispatcherTablePanel.java
+++ b/src/main/java/jcs/ui/panel/DispatcherTablePanel.java
@@ -93,6 +93,10 @@ public Component getTableCellRendererComponent(JTable table, Object value, boole
}
}
+ public void refresh() {
+ locomotiveDispatcherTableModel.refresh();
+ }
+
/**
* This method is called from within the constructor to initialize the form. WARNING: Do NOT modify this code. The content of this method is always regenerated by the Form Editor.
*/
diff --git a/src/main/java/jcs/ui/settings/CommandStationPanel.java b/src/main/java/jcs/ui/settings/CommandStationPanel.java
index 3abb9829..8d9ac3cc 100644
--- a/src/main/java/jcs/ui/settings/CommandStationPanel.java
+++ b/src/main/java/jcs/ui/settings/CommandStationPanel.java
@@ -43,6 +43,7 @@
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JDialog;
+import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
@@ -53,6 +54,7 @@
import javax.swing.JTree;
import javax.swing.SpinnerNumberModel;
import javax.swing.SwingConstants;
+import javax.swing.SwingUtilities;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.DefaultMutableTreeNode;
@@ -75,6 +77,7 @@
import static jcs.entities.CommandStationBean.MARKLIN_CS;
import jcs.entities.SensorBean;
import jcs.persistence.PersistenceFactory;
+import jcs.ui.JCSFrame;
import jcs.ui.swing.layout.VerticalFlowLayout;
import jcs.util.Ping;
import org.tinylog.Logger;
@@ -85,20 +88,22 @@
*/
public class CommandStationPanel extends JPanel implements TreeSelectionListener {
+ private static final long serialVersionUID = -6257688549267578845L;
+
private ComboBoxModel commandStationCBM;
private ComboBoxModel feedbackCBM;
private ComboBoxModel serialPortCBM;
private ComboBoxModel fbpSerialPortCBM;
private CommandStationBean selectedCommandStation;
private CommandStationBean selectedFeedbackProvider;
-
+
private final ExecutorService executor;
-
+
private CommandStationBean emptyCS;
private CommandStationBean emptyFB;
-
+
private DecoderController controller;
-
+
public CommandStationPanel() {
initComponents();
executor = Executors.newSingleThreadExecutor();
@@ -106,23 +111,23 @@ public CommandStationPanel() {
initModels(null);
}
}
-
+
private void initModels(CommandStationBean selected) {
if (selected == null) {
selectedCommandStation = PersistenceFactory.getService().getDefaultCommandStation();
} else {
selectedCommandStation = selected;
}
-
+
if (selectedCommandStation != null && !selectedCommandStation.isFeedbackSupport()) {
selectedFeedbackProvider = PersistenceFactory.getService().getEnabledFeedbackProvider();
}
-
+
List allCommandStations = PersistenceFactory.getService().getCommandStations();
-
+
List commandStations = new ArrayList<>();
List feedbackProviders = new ArrayList<>();
-
+
for (CommandStationBean csb : allCommandStations) {
if (csb.isDecoderControlSupport()) {
commandStations.add(csb);
@@ -130,47 +135,47 @@ private void initModels(CommandStationBean selected) {
feedbackProviders.add(csb);
}
}
-
+
emptyCS = new CommandStationBean();
emptyCS.setDecoderControlSupport(true);
emptyFB = new CommandStationBean();
emptyFB.setFeedbackSupport(true);
-
+
commandStations.add(emptyCS);
feedbackProviders.add(emptyFB);
-
+
if (selectedCommandStation == null) {
selectedCommandStation = emptyCS;
}
-
+
if (selectedFeedbackProvider == null) {
selectedFeedbackProvider = emptyFB;
}
-
+
CommandStationBean[] csba = new CommandStationBean[commandStations.size()];
CommandStationBean[] fbpa = new CommandStationBean[feedbackProviders.size()];
commandStations.toArray(csba);
feedbackProviders.toArray(fbpa);
-
+
commandStationCBM = new DefaultComboBoxModel<>(csba);
commandStationCBM.setSelectedItem(selectedCommandStation);
commandStationCB.setModel(commandStationCBM);
-
+
feedbackCBM = new DefaultComboBoxModel<>(fbpa);
feedbackCBM.setSelectedItem(selectedFeedbackProvider);
feedbackCB.setModel(feedbackCBM);
-
+
SerialPort comPorts[] = SerialPort.getCommPorts();
String[] ports = new String[comPorts.length];
for (int i = 0; i < comPorts.length; i++) {
ports[i] = comPorts[i].getSystemPortName();
}
-
+
serialPortCBM = new DefaultComboBoxModel<>(ports);
fbpSerialPortCBM = new DefaultComboBoxModel<>(ports);
serialCB.setModel(serialPortCBM);
fbpSerialCB.setModel(fbpSerialPortCBM);
-
+
if (CommandStationBean.ConnectionType.SERIAL == selectedCommandStation.getConnectionType()) {
String port = selectedCommandStation.getSerialPort();
serialCB.setSelectedItem(port);
@@ -178,12 +183,12 @@ private void initModels(CommandStationBean selected) {
} else {
networkRB.setSelected(true);
}
-
+
if (selectedFeedbackProvider.getConnectionType() != null && CommandStationBean.ConnectionType.SERIAL == selectedFeedbackProvider.getConnectionType()) {
String port = selectedFeedbackProvider.getSerialPort();
fbpSerialCB.setSelectedItem(port);
}
-
+
setComponents();
if (!selectedCommandStation.isVirtual() && CommandStationBean.ConnectionType.NETWORK == selectedCommandStation.getConnectionType() && selectedCommandStation.getIpAddress() != null && selectedCommandStation.getIpAddress().length() > 8) {
executor.execute(() -> checkConnection(selectedCommandStation));
@@ -597,27 +602,27 @@ private void setComponents() {
controllerLbl.setVisible(selectedCommandStation.isDecoderControlSupport());
accessoryControllerLbl.setVisible(selectedCommandStation.isAccessoryControlSupport());
feedbackProviderLbl.setVisible(selectedCommandStation.isFeedbackSupport());
-
+
virtualCB.setSelected(selectedCommandStation.isVirtual());
-
+
discoverBtn.setVisible(selectedCommandStation.isIpAutoConfiguration());
ipTF.setText(selectedCommandStation.getIpAddress());
-
+
serialCB.setVisible(CommandStationBean.ConnectionType.SERIAL == selectedCommandStation.getConnectionType());
ipTF.setVisible(CommandStationBean.ConnectionType.NETWORK == selectedCommandStation.getConnectionType());
-
+
networkRB.setVisible(selectedCommandStation.getSupportedConnectionTypes().size() > 1);
serialRB.setVisible(selectedCommandStation.getSupportedConnectionTypes().size() > 1);
networkRB.setSelected(CommandStationBean.ConnectionType.NETWORK == selectedCommandStation.getConnectionType());
-
+
if (serialCB.isVisible()) {
ipOrPortLbl.setText("Serial Port:");
} else {
ipOrPortLbl.setText("ip Address:");
}
-
+
checkBtn.setVisible(CommandStationBean.ConnectionType.NETWORK == selectedCommandStation.getConnectionType() && selectedCommandStation.getIpAddress() != null && selectedCommandStation.getIpAddress().length() > 8);
-
+
if (selectedCommandStation.getIpAddress() == null || selectedCommandStation.getIpAddress().length() > 8) {
ipTF.setBackground(new java.awt.Color(255, 255, 255));
connectBtn.setEnabled(true);
@@ -629,45 +634,45 @@ private void setComponents() {
feedbackCB.setVisible(!selectedCommandStation.isFeedbackSupport());
feedbackCB.setEnabled(!selectedCommandStation.isFeedbackSupport());
feedbackLbl.setVisible(!selectedCommandStation.isFeedbackSupport());
-
+
secondfbpLbl.setVisible(!selectedCommandStation.isFeedbackSupport() && selectedFeedbackProvider.isFeedbackSupport() && selectedFeedbackProvider.getId() != null);
-
+
fbpSerialCB.setVisible(!selectedCommandStation.isFeedbackSupport());
fbpSerialCB.setEnabled(!selectedCommandStation.isFeedbackSupport());
fbpSerialLbl.setVisible(!selectedCommandStation.isFeedbackSupport());
-
+
if (controller != null && controller.isConnected()) {
InfoBean ib = controller.getCommandStationInfo();
connectedToLbl.setText("Connected to : " + ib.getProductName());
connectedToLbl.setVisible(true);
-
+
serialLbl.setText("Serial: " + ib.getSerialNumber());
serialLbl.setVisible(true);
-
+
if (ib.getSoftwareVersion() != null) {
swVersionLbl.setText("Software version: " + ib.getSoftwareVersion());
swVersionLbl.setVisible(true);
} else {
swVersionLbl.setVisible(false);
}
-
+
if (ib.getHardwareVersion() != null) {
hwVersionLbl.setText(("Hardware version: " + ib.getHardwareVersion()));
hwVersionLbl.setVisible(true);
} else {
hwVersionLbl.setVisible(false);
}
-
+
connectBtn.setText("Disconnect");
//feedback settings
List modules = ((FeedbackController) controller).getFeedbackModules();
-
+
mainLbl.setVisible(true);
mainSpinner.setVisible(true);
-
+
updateBtn.setVisible(true);
-
+
for (FeedbackModule fbm : modules) {
Integer busNr = fbm.getBusNumber();
if (busNr == null) {
@@ -689,7 +694,7 @@ private void setComponents() {
}
}
}
-
+
if (selectedCommandStation.getId().equals(CommandStationBean.MARKLIN_CS)) {
bus1Lbl.setVisible(true);
bus1Spinner.setVisible(true);
@@ -729,7 +734,7 @@ private void setComponents() {
//Feedback modules
mainLbl.setVisible(false);
mainSpinner.setVisible(false);
-
+
bus1Lbl.setVisible(false);
bus1Spinner.setVisible(false);
bus2Lbl.setVisible(false);
@@ -738,10 +743,10 @@ private void setComponents() {
bus3Spinner.setVisible(false);
updateBtn.setVisible(false);
}
-
+
buildTree();
}
-
+
private void buildTree() {
Logger.trace("build tree");
String rootDesc;
@@ -750,29 +755,29 @@ private void buildTree() {
} else {
rootDesc = "";
}
-
+
DefaultMutableTreeNode root = new DefaultMutableTreeNode(rootDesc);
createNodes(root);
-
+
DefaultTreeModel model = new DefaultTreeModel(root);
-
+
devicesTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
devicesTree.addTreeSelectionListener(this);
-
+
devicesTree.setModel(model);
}
-
+
private void createNodes(DefaultMutableTreeNode root) {
Logger.trace("Create feedback nodes");
if (controller == null) {
return;
}
-
+
List devices = controller.getDevices();
-
+
for (Device d : devices) {
DefaultMutableTreeNode deviceNode = new DefaultMutableTreeNode(d.getId() + " " + d.getName());
-
+
if (d.isFeedback()) {
List modules = ((FeedbackController) controller).getFeedbackModules();
Collections.sort(modules);
@@ -792,49 +797,50 @@ private void createNodes(DefaultMutableTreeNode root) {
}
sb.append(" module: ");
sb.append(fm.getModuleNumber());
-
+
DefaultMutableTreeNode moduleNode = new DefaultMutableTreeNode(sb);
Logger.trace("M " + sb.toString());
-
+
deviceNode.add(moduleNode);
}
-
+
}
-
+
root.add(deviceNode);
}
-
+
}
-
+
+ //TODO
public void valueChanged(TreeSelectionEvent e) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) devicesTree.getLastSelectedPathComponent();
-
+
if (node == null) {
return;
}
-
+
Object nodeInfo = node.getUserObject();
-
+
if (node.isLeaf()) {
-
+
} else {
}
}
-
+
private void changeDefaultCommandStation(final CommandStationBean newDefault) {
PersistenceFactory.getService().changeDefaultCommandStation(newDefault);
java.awt.EventQueue.invokeLater(() -> {
setComponents();
});
}
-
+
private void persistCommandStation(final CommandStationBean commandStation) {
PersistenceFactory.getService().persist(commandStation);
java.awt.EventQueue.invokeLater(() -> {
setComponents();
});
}
-
+
private void commandStationCBActionPerformed(ActionEvent evt) {//GEN-FIRST:event_commandStationCBActionPerformed
CommandStationBean newSelectedCommandStation = (CommandStationBean) commandStationCBM.getSelectedItem();
@@ -854,12 +860,12 @@ private void commandStationCBActionPerformed(ActionEvent evt) {//GEN-FIRST:event
} else {
selectedCommandStation = newSelectedCommandStation;
}
-
+
selectedCommandStation = (CommandStationBean) commandStationCBM.getSelectedItem();
selectedCommandStation.setEnabled(true);
selectedCommandStation.setDefault(true);
executor.execute(() -> changeDefaultCommandStation(selectedCommandStation));
-
+
Logger.trace("Selected CS: " + selectedCommandStation.getDescription());
}//GEN-LAST:event_commandStationCBActionPerformed
@@ -947,7 +953,7 @@ private void fbpSerialCBActionPerformed(ActionEvent evt) {//GEN-FIRST:event_fbpS
private void connectBtnActionPerformed(ActionEvent evt) {//GEN-FIRST:event_connectBtnActionPerformed
Logger.trace("Try to connect to " + selectedCommandStation.getDescription());
-
+
if ("Connect".equals(connectBtn.getText())) {
executor.execute(() -> connect(selectedCommandStation));
} else {
@@ -961,10 +967,10 @@ private void updateBtnActionPerformed(ActionEvent evt) {//GEN-FIRST:event_update
updateSensors();
});
}//GEN-LAST:event_updateBtnActionPerformed
-
+
private void updateSensors() {
List modules = ((FeedbackController) controller).getFeedbackModules();
-
+
Logger.trace("There are " + modules.size() + " feedback modules");
//Catch errors if any...
try {
@@ -978,16 +984,16 @@ private void updateSensors() {
} catch (Exception e) {
Logger.error("Error updating sensors! " + e);
}
-
+
java.awt.EventQueue.invokeLater(() -> {
setComponents();
updateBtn.setEnabled(true);
});
}
-
+
private List getFeedbackModules(String commandStationId) {
List sensors = PersistenceFactory.getService().getSensorsByCommandStationId(commandStationId);
-
+
List modules = new ArrayList<>();
if (!sensors.isEmpty()) {
Integer id = -1;
@@ -1001,47 +1007,52 @@ private List getFeedbackModules(String commandStationId) {
}
}
}
-
+
return modules;
}
-
+
private InetAddress discover(final CommandStationBean commandStation) {
final JOptionPane optionPane = new JOptionPane("Try to discovering a " + commandStation.getDescription(),
JOptionPane.INFORMATION_MESSAGE,
JOptionPane.DEFAULT_OPTION);
-
+
final JDialog discoverDialog = new JDialog((JDialog) null, "Discovering...");
discoverDialog.setContentPane(optionPane);
discoverDialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
discoverDialog.pack();
discoverDialog.setLocationRelativeTo(null);
discoverDialog.setVisible(true);
-
+
InetAddress inetAddress = null;
if (MARKLIN_CS.equals(commandStation.getId())) {
inetAddress = CSConnectionFactory.discoverCs();
} else if (ESU_ECOS.equals(commandStation.getId())) {
inetAddress = EcosConnectionFactory.discoverEcos();
}
-
+
if (inetAddress != null) {
Logger.trace("Discovered host " + inetAddress.getHostAddress() + " for " + commandStation.getDescription());
commandStation.setIpAddress(inetAddress.getHostAddress());
persistCommandStation(commandStation);
}
-
+
java.awt.EventQueue.invokeLater(() -> {
discoverDialog.setVisible(false);
discoverDialog.dispose();
});
-
+
return inetAddress;
}
-
+
+ private JFrame getParentFrame() {
+ JFrame frame = (JFrame) SwingUtilities.getRoot(this);
+ return frame;
+ }
+
private void checkConnection(final CommandStationBean commandStation) {
String ip = commandStation.getIpAddress();
boolean canConnect = Ping.IsReachable(ip);
-
+
java.awt.EventQueue.invokeLater(() -> {
if (canConnect) {
ipTF.setBackground(new java.awt.Color(204, 255, 204));
@@ -1049,35 +1060,40 @@ private void checkConnection(final CommandStationBean commandStation) {
} else {
ipTF.setBackground(new java.awt.Color(255, 255, 255));
connectBtn.setEnabled(false);
- JOptionPane.showMessageDialog(this, "Can't connect with host " + ip, "Can't Connect", JOptionPane.WARNING_MESSAGE);
+
+ //Only show the MessageDial when in Dialog
+ if (!(getParentFrame() instanceof JCSFrame)) {
+ JOptionPane.showMessageDialog(this, "Can't connect with host " + ip, "Can't Connect", JOptionPane.WARNING_MESSAGE);
+ } else {
+ Logger.trace("Can't connect with host " + ip);
+ }
}
});
}
-
+
private void disconnect() {
if (controller != null) {
controller.disconnect();
controller = null;
-
+
java.awt.EventQueue.invokeLater(() -> {
setComponents();
});
-
}
}
-
+
private void connect(final CommandStationBean commandStation) {
final JOptionPane optionPane = new JOptionPane("Try to connect to " + commandStation.getDescription(),
JOptionPane.INFORMATION_MESSAGE,
JOptionPane.DEFAULT_OPTION);
-
+
final JDialog connectingDialog = new JDialog((JDialog) null, "Connecting...");
connectingDialog.setContentPane(optionPane);
connectingDialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
connectingDialog.pack();
connectingDialog.setLocationRelativeTo(null);
connectingDialog.setVisible(true);
-
+
if (null == commandStation.getId()) {
Logger.trace("Unknown Controller!");
} else {
@@ -1094,36 +1110,31 @@ private void connect(final CommandStationBean commandStation) {
Logger.trace("Unknown Controller!");
}
}
-
+
if (controller == null) {
return;
}
-
+
controller.connect();
if (controller.isConnected()) {
//Obtain some info from the controller
Logger.trace("Connected to " + controller.getCommandStationInfo());
-
+
java.awt.EventQueue.invokeLater(() -> {
setComponents();
});
}
-
+
java.awt.EventQueue.invokeLater(() -> {
connectingDialog.setVisible(false);
connectingDialog.dispose();
});
-
- //} catch (UnknownHostException ex) {
- // Logger.error("Unknown host " + commandStation.getIpAddress());
- // return false;
- //}
}
-
+
@Override
public void setVisible(boolean b) {
super.setVisible(b);
-
+
if (!b && this.controller != null) {
if (controller.isConnected()) {
controller.disconnect();
diff --git a/src/main/java/jcs/ui/settings/CommandStationPanel1.form b/src/main/java/jcs/ui/settings/CommandStationPanel1.form
deleted file mode 100644
index 3ab718a8..00000000
--- a/src/main/java/jcs/ui/settings/CommandStationPanel1.form
+++ /dev/null
@@ -1,2807 +0,0 @@
-
-
-
diff --git a/src/main/java/jcs/ui/settings/CommandStationPanel1.java b/src/main/java/jcs/ui/settings/CommandStationPanel1.java
deleted file mode 100644
index 8d0a1845..00000000
--- a/src/main/java/jcs/ui/settings/CommandStationPanel1.java
+++ /dev/null
@@ -1,1688 +0,0 @@
-/*
- * Copyright 2023 Frans Jacobs.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package jcs.ui.settings;
-
-import com.fazecast.jSerialComm.SerialPort;
-import com.fazecast.jSerialComm.SerialPortInvalidPortException;
-import java.awt.BorderLayout;
-import java.awt.Dimension;
-import java.awt.FlowLayout;
-import java.awt.Insets;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.FocusAdapter;
-import java.awt.event.FocusEvent;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.util.List;
-import java.util.Set;
-import javax.swing.Box;
-import javax.swing.BoxLayout;
-import javax.swing.ButtonGroup;
-import javax.swing.ComboBoxModel;
-import javax.swing.DefaultComboBoxModel;
-import javax.swing.ImageIcon;
-import javax.swing.JButton;
-import javax.swing.JCheckBox;
-import javax.swing.JComboBox;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JProgressBar;
-import javax.swing.JRadioButton;
-import javax.swing.JSpinner;
-import javax.swing.JTextField;
-import javax.swing.SpinnerNumberModel;
-import javax.swing.SwingConstants;
-import javax.swing.SwingWorker;
-import javax.swing.event.ChangeEvent;
-import javax.swing.event.ChangeListener;
-import jcs.JCS;
-import jcs.commandStation.ControllerFactory;
-import jcs.commandStation.DecoderController;
-import jcs.commandStation.FeedbackController;
-import jcs.entities.CommandStationBean;
-import jcs.entities.CommandStationBean.ConnectionType;
-import jcs.entities.CommandStationBean.Protocol;
-import jcs.commandStation.entities.FeedbackModule;
-import jcs.persistence.PersistenceFactory;
-import jcs.ui.swing.layout.VerticalFlowLayout;
-import jcs.util.Ping;
-import org.tinylog.Logger;
-
-/**
- *
- * @author frans
- */
-public class CommandStationPanel1 extends JPanel implements PropertyChangeListener {
-
- private CommandStationBean selectedCommandStation;
- private ComboBoxModel commandStationComboBoxModel;
- private ComboBoxModel serialPortComboBoxModel;
-
- private Task task;
-
- public CommandStationPanel1() {
- initComponents();
- if (PersistenceFactory.getService() != null) {
- initModels(null);
- }
- }
-
- private void initModels(CommandStationBean selected) {
- if (selected == null) {
- selectedCommandStation = PersistenceFactory.getService().getDefaultCommandStation();
- } else {
- selectedCommandStation = selected;
- }
-
- List commandStations = PersistenceFactory.getService().getCommandStations();
- CommandStationBean[] cmdSts = new CommandStationBean[commandStations.size()];
- commandStations.toArray(cmdSts);
-
- if (selectedCommandStation == null) {
- selectedCommandStation = new CommandStationBean();
- //Add the empty Commandstation
- commandStations.add(selectedCommandStation);
- }
-
- commandStationComboBoxModel = new DefaultComboBoxModel<>(cmdSts);
- commandStationComboBoxModel.setSelectedItem(selectedCommandStation);
- commandStationComboBox.setModel(commandStationComboBoxModel);
-
- SerialPort comPorts[] = SerialPort.getCommPorts();
- String[] ports = new String[comPorts.length];
- for (int i = 0; i < comPorts.length; i++) {
- ports[i] = comPorts[i].getSystemPortName();
- }
-
- serialPortComboBoxModel = new DefaultComboBoxModel<>(ports);
- this.serialPortCB.setModel(serialPortComboBoxModel);
-
- setFieldValues();
- enableFields(false);
-
- this.progressBar.setVisible(false);
- }
-
- private void setFieldValues() {
- if (selectedCommandStation != null) {
-
- this.networkRB.setSelected(selectedCommandStation.getConnectionType() == ConnectionType.NETWORK);
- this.serialRB.setSelected(selectedCommandStation.getConnectionType() == ConnectionType.SERIAL);
-
- String id = selectedCommandStation.getId();
- this.idTF.setText("Id: " + id);
-
- String description = selectedCommandStation.getDescription();
- this.descriptionTF.setText(description);
-
- String shortName = selectedCommandStation.getShortName();
- this.shortNameLbl.setText(shortName);
- this.shortNameTF.setText(shortName);
-
- String className = selectedCommandStation.getClassName();
- this.classNameTF.setText(className);
-
- if (ConnectionType.SERIAL == selectedCommandStation.getConnectionType()) {
- String portName = selectedCommandStation.getSerialPort();
- if (portName != null) {
- try {
- SerialPort comPort = SerialPort.getCommPort(portName);
- this.serialPortComboBoxModel.setSelectedItem(comPort.getSystemPortName());
- } catch (SerialPortInvalidPortException ioe) {
- Logger.warn("Can't find com port: " + portName + "; " + ioe.getMessage());
- }
- }
- }
-
- String ipAddress = selectedCommandStation.getIpAddress();
- this.ipAddressTF.setText(ipAddress);
-
- Integer networkPort = selectedCommandStation.getNetworkPort();
- if (networkPort != null) {
- this.portSpinner.setValue(this.selectedCommandStation.getNetworkPort());
- } else {
- this.portSpinner.setValue(0);
- }
-
- boolean ipAutoConfiguration = selectedCommandStation.isIpAutoConfiguration();
- this.autoConfChkBox.setSelected(ipAutoConfiguration);
-
- boolean commandAndControlSupport = selectedCommandStation.isDecoderControlSupport();
- this.decoderControlCB.setSelected(commandAndControlSupport);
-
- boolean accessorySupport = selectedCommandStation.isAccessoryControlSupport();
- this.accessorySupportCB.setSelected(accessorySupport);
-
- boolean feedbackSupport = selectedCommandStation.isFeedbackSupport();
- this.feedbackSupportCB.setSelected(feedbackSupport);
-
- boolean locomotiveSynchronizationSupport = selectedCommandStation.isLocomotiveSynchronizationSupport();
- this.locomotiveSynchSupportCB.setSelected(locomotiveSynchronizationSupport);
-
- boolean accessorySynchronizationSupport = selectedCommandStation.isAccessorySynchronizationSupport();
- this.accessorySynchSupportCB.setSelected(accessorySynchronizationSupport);
-
- boolean locomotiveImageSynchronizationSupport = selectedCommandStation.isLocomotiveImageSynchronizationSupport();
- this.locomotiveImageSynchSupportCB.setSelected(locomotiveImageSynchronizationSupport);
-
- boolean locomotiveFunctionSynchronizationSupport = selectedCommandStation.isLocomotiveFunctionSynchronizationSupport();
- this.locomotiveFunctionSynchSupportCB.setSelected(locomotiveFunctionSynchronizationSupport);
-
- Set protocols = selectedCommandStation.getSupportedProtocols();
- this.mmRB.setSelected(protocols.contains(Protocol.MM));
- this.mfxRB.setSelected(protocols.contains(Protocol.MFX));
- this.dccRB.setSelected(protocols.contains(Protocol.DCC));
- this.sxRB.setSelected(protocols.contains(Protocol.SX));
-
- boolean defaultCs = selectedCommandStation.isDefault();
- this.defaultCommandStationChkBox.setSelected(defaultCs);
- boolean enabled = selectedCommandStation.isEnabled();
- this.enabledCB.setSelected(enabled);
-
- String lastUsedSerial = selectedCommandStation.getLastUsedSerial();
- if (lastUsedSerial != null) {
- this.lastUsedSerialLbl.setVisible(true);
- this.lastUsedSerialLbl.setText("Serial number: " + lastUsedSerial);
- } else {
- this.lastUsedSerialLbl.setVisible(false);
- }
-
- Set supportedConnectionTypes = selectedCommandStation.getSupportedConnectionTypes();
- this.supConTypeNetworkRB.setSelected(supportedConnectionTypes.contains(ConnectionType.NETWORK));
- this.supConTypeSerialRB.setSelected(supportedConnectionTypes.contains(ConnectionType.SERIAL));
-
- if (feedbackSupport) {
- String fbid = selectedCommandStation.getFeedbackModuleIdentifier();
- if (fbid != null && !"".equals(fbid)) {
- int node = Integer.parseInt(fbid);
- this.nodeSpinner.setValue(node);
- }
-
- Integer channelCount = selectedCommandStation.getFeedbackChannelCount();
- if (channelCount != null) {
- this.channelCountSpinner.setValue(channelCount);
- }
- Integer bus0Lenght = selectedCommandStation.getFeedbackBus0ModuleCount();
- if (bus0Lenght != null) {
- this.bus0Spinner.setValue(bus0Lenght);
- }
-
- Integer bus1Lenght = selectedCommandStation.getFeedbackBus1ModuleCount();
- if (bus1Lenght != null) {
- this.bus1Spinner.setValue(bus1Lenght);
- }
-
- Integer bus2Lenght = selectedCommandStation.getFeedbackBus2ModuleCount();
- if (bus2Lenght != null) {
- this.bus2Spinner.setValue(bus2Lenght);
- }
-
- Integer bus3Lenght = selectedCommandStation.getFeedbackBus3ModuleCount();
- if (bus3Lenght != null) {
- this.bus3Spinner.setValue(bus3Lenght);
- }
-
- }
- }
- }
-
- private void enableFields(boolean enable) {
- Set supportedConnectionTypes = selectedCommandStation.getSupportedConnectionTypes();
- if (supportedConnectionTypes.size() > 1) {
- this.networkRB.setEnabled(supportedConnectionTypes.contains(ConnectionType.NETWORK));
- this.serialRB.setEnabled(supportedConnectionTypes.contains(ConnectionType.SERIAL));
- } else {
- this.networkRB.setEnabled(false);
- this.serialRB.setEnabled(false);
- }
-
- if (this.networkRB.isSelected()) {
- this.serialPortCB.setVisible(false);
- this.serialPortCB.setPreferredSize(new Dimension(150, 30));
- this.serialPortRefreshBtn.setVisible(false);
- this.ipAddressTF.setVisible(true);
-
- this.connectionPropertiesLbl.setText("IP Address:");
-
- this.portLbl.setVisible(true);
- this.portSpinner.setVisible(true);
- this.autoConfChkBox.setVisible(true);
- this.portSpinner.setEnabled(enable);
- this.autoConfChkBox.setEnabled(enable);
- }
-
- if (this.serialRB.isSelected()) {
- this.serialPortCB.setPreferredSize(new Dimension(250, 30));
- this.serialPortCB.setVisible(true);
- this.ipAddressTF.setVisible(false);
- this.serialPortRefreshBtn.setVisible(true);
-
- this.connectionPropertiesLbl.setText("Serial Port:");
-
- this.portLbl.setVisible(false);
- this.portSpinner.setVisible(false);
- this.autoConfChkBox.setVisible(false);
- }
-
- this.decoderControlCB.setEnabled(enable);
- this.accessorySupportCB.setEnabled(enable);
- this.feedbackSupportCB.setEnabled(enable);
-
- boolean fbEnable = this.feedbackSupportCB.isSelected();
- this.nodeSpinner.setEnabled(fbEnable);
-
- this.channelCountSpinner.setEnabled(fbEnable);
- this.bus0Spinner.setEnabled(fbEnable);
- this.bus1Spinner.setEnabled(fbEnable);
- this.bus2Spinner.setEnabled(fbEnable);
- this.bus3Spinner.setEnabled(fbEnable);
-
- this.locomotiveSynchSupportCB.setEnabled(enable);
- this.accessorySynchSupportCB.setEnabled(enable);
- this.locomotiveImageSynchSupportCB.setEnabled(enable);
- this.locomotiveFunctionSynchSupportCB.setEnabled(enable);
-
- this.mmRB.setEnabled(enable);
- this.mfxRB.setEnabled(enable);
- this.dccRB.setEnabled(enable);
- this.sxRB.setEnabled(enable);
-
- this.supConTypeNetworkRB.setEnabled(enable);
- this.supConTypeSerialRB.setEnabled(enable);
-
- this.descriptionTF.setEnabled(enable);
- this.classNameTF.setEnabled(enable);
- this.idTF.setEnabled(enable);
-
- //Only when editmode is on show the extra fields
- this.nameLbl.setVisible(enable);
- this.classNameLbl.setVisible(enable);
- this.descriptionTF.setVisible(enable);
- this.classNameTF.setVisible(enable);
- this.idLbl.setVisible(enable);
-
- this.shortNameTFLb.setVisible(enable);
- this.shortNameTF.setEnabled(enable);
- this.shortNameTF.setVisible(enable);
-
- this.supConTypeNetworkRB.setVisible(enable);
- this.supConTypeSerialRB.setVisible(enable);
- this.supportedConnectionTypesLbl.setVisible(enable);
-
- this.idTF.setVisible(enable);
- this.newBtn.setEnabled(enable);
- this.newBtn.setVisible(enable);
-
- this.saveBtn.setVisible(enable);
- this.saveBtn.setEnabled(enable);
- }
-
- /**
- * This method is called from within the constructor to initialize the form. WARNING: Do NOT modify this code. The content of this method is always regenerated by the Form Editor.
- */
- @SuppressWarnings("deprecation")
- // //GEN-BEGIN:initComponents
- private void initComponents() {
-
- connectionTypeBG = new ButtonGroup();
- topPanel = new JPanel();
- commandStationSelectionPanel = new JPanel();
- commandStationLbl = new JLabel();
- commandStationComboBox = new JComboBox<>();
- defaultCommandStationChkBox = new JCheckBox();
- filler5 = new Box.Filler(new Dimension(20, 0), new Dimension(20, 0), new Dimension(20, 32767));
- shortNameLbl = new JLabel();
- filler6 = new Box.Filler(new Dimension(10, 0), new Dimension(10, 0), new Dimension(10, 32767));
- csPropertiesPanel = new JPanel();
- enabledCB = new JCheckBox();
- virtualCB = new JCheckBox();
- filler4 = new Box.Filler(new Dimension(100, 0), new Dimension(100, 0), new Dimension(100, 32767));
- lastUsedSerialLbl = new JLabel();
- centerPanel = new JPanel();
- connectionPanel = new JPanel();
- connectionTypeLbl = new JLabel();
- networkRB = new JRadioButton();
- serialRB = new JRadioButton();
- filler7 = new Box.Filler(new Dimension(20, 0), new Dimension(20, 0), new Dimension(20, 32767));
- connectionPropertiesLbl = new JLabel();
- serialPortCB = new JComboBox<>();
- serialPortRefreshBtn = new JButton();
- ipAddressTF = new JTextField();
- portLbl = new JLabel();
- portSpinner = new JSpinner();
- autoConfChkBox = new JCheckBox();
- capabilitiesPanel = new JPanel();
- connectionTestPanel = new JPanel();
- filler3 = new Box.Filler(new Dimension(26, 0), new Dimension(26, 0), new Dimension(20, 32767));
- testConnectionBtn = new JButton();
- filler2 = new Box.Filler(new Dimension(20, 0), new Dimension(20, 0), new Dimension(20, 32767));
- connectionTestResultLbl = new JLabel();
- progressBar = new JProgressBar();
- decoderControlSupportPanel = new JPanel();
- decoderControlCB = new JCheckBox();
- accessorySupportPanel = new JPanel();
- accessorySupportCB = new JCheckBox();
- feedbackSupportPanel = new JPanel();
- feedbackSupportCB = new JCheckBox();
- FeedbackPropertiesPanel = new JPanel();
- feedbackIdLbl = new JLabel();
- nodeSpinner = new JSpinner();
- channelCountLbl = new JLabel();
- channelCountSpinner = new JSpinner();
- bus0Lbl = new JLabel();
- bus0Spinner = new JSpinner();
- bus1Lbl = new JLabel();
- bus1Spinner = new JSpinner();
- bus2Lbl = new JLabel();
- bus2Spinner = new JSpinner();
- bus3Lbl = new JLabel();
- bus3Spinner = new JSpinner();
- recreateSensorsBtn = new JButton();
- locomotiveSynchSupportPanel = new JPanel();
- locomotiveSynchSupportCB = new JCheckBox();
- accessorySynchSupportPanel = new JPanel();
- accessorySynchSupportCB = new JCheckBox();
- locomotiveImageSynchSupportPanel = new JPanel();
- locomotiveImageSynchSupportCB = new JCheckBox();
- locomotiveFunctionSynchSupportPanel = new JPanel();
- locomotiveFunctionSynchSupportCB = new JCheckBox();
- protocolPanel = new JPanel();
- supportedProtocolsLbl = new JLabel();
- mmRB = new JRadioButton();
- mfxRB = new JRadioButton();
- dccRB = new JRadioButton();
- sxRB = new JRadioButton();
- filler10 = new Box.Filler(new Dimension(20, 0), new Dimension(20, 0), new Dimension(20, 32767));
- supportedConnectionTypesLbl = new JLabel();
- supConTypeNetworkRB = new JRadioButton();
- supConTypeSerialRB = new JRadioButton();
- descPanel = new JPanel();
- nameLbl = new JLabel();
- descriptionTF = new JTextField();
- filler9 = new Box.Filler(new Dimension(15, 0), new Dimension(15, 0), new Dimension(15, 32767));
- classNameLbl = new JLabel();
- classNameTF = new JTextField();
- shortNameTFLb = new JLabel();
- shortNameTF = new JTextField();
- bottomPanel = new JPanel();
- leftBottomPanel = new JPanel();
- enableEditCB = new JCheckBox();
- newBtn = new JButton();
- filler8 = new Box.Filler(new Dimension(30, 0), new Dimension(30, 0), new Dimension(30, 32767));
- idLbl = new JLabel();
- idTF = new JTextField();
- rightBottomPanel = new JPanel();
- filler1 = new Box.Filler(new Dimension(50, 0), new Dimension(200, 0), new Dimension(150, 32767));
- saveBtn = new JButton();
-
- setMinimumSize(new Dimension(1080, 600));
- setName("Form"); // NOI18N
- setPreferredSize(new Dimension(1080, 600));
- setLayout(new BorderLayout());
-
- topPanel.setMinimumSize(new Dimension(1000, 50));
- topPanel.setName("topPanel"); // NOI18N
- topPanel.setPreferredSize(new Dimension(1000, 50));
- topPanel.setRequestFocusEnabled(false);
- topPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
-
- commandStationSelectionPanel.setMinimumSize(new Dimension(400, 33));
- commandStationSelectionPanel.setName("commandStationSelectionPanel"); // NOI18N
- commandStationSelectionPanel.setPreferredSize(new Dimension(525, 35));
- FlowLayout flowLayout2 = new FlowLayout(FlowLayout.LEFT, 5, 2);
- flowLayout2.setAlignOnBaseline(true);
- commandStationSelectionPanel.setLayout(flowLayout2);
-
- commandStationLbl.setHorizontalAlignment(SwingConstants.TRAILING);
- commandStationLbl.setLabelFor(commandStationComboBox);
- commandStationLbl.setText("Command Station:");
- commandStationLbl.setMaximumSize(new Dimension(110, 17));
- commandStationLbl.setMinimumSize(new Dimension(110, 17));
- commandStationLbl.setName("commandStationLbl"); // NOI18N
- commandStationLbl.setPreferredSize(new Dimension(110, 17));
- commandStationSelectionPanel.add(commandStationLbl);
-
- commandStationComboBox.setName("commandStationComboBox"); // NOI18N
- commandStationComboBox.setPreferredSize(new Dimension(200, 30));
- commandStationComboBox.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent evt) {
- commandStationComboBoxActionPerformed(evt);
- }
- });
- commandStationSelectionPanel.add(commandStationComboBox);
-
- defaultCommandStationChkBox.setText("Default");
- defaultCommandStationChkBox.setHorizontalTextPosition(SwingConstants.LEADING);
- defaultCommandStationChkBox.setName("defaultCommandStationChkBox"); // NOI18N
- defaultCommandStationChkBox.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent evt) {
- defaultCommandStationChkBoxActionPerformed(evt);
- }
- });
- commandStationSelectionPanel.add(defaultCommandStationChkBox);
-
- filler5.setName("filler5"); // NOI18N
- commandStationSelectionPanel.add(filler5);
-
- shortNameLbl.setText("shortName");
- shortNameLbl.setMaximumSize(new Dimension(70, 17));
- shortNameLbl.setMinimumSize(new Dimension(70, 17));
- shortNameLbl.setName("shortNameLbl"); // NOI18N
- shortNameLbl.setPreferredSize(new Dimension(70, 17));
- commandStationSelectionPanel.add(shortNameLbl);
-
- filler6.setName("filler6"); // NOI18N
- commandStationSelectionPanel.add(filler6);
-
- topPanel.add(commandStationSelectionPanel);
-
- csPropertiesPanel.setName("csPropertiesPanel"); // NOI18N
- csPropertiesPanel.setPreferredSize(new Dimension(450, 33));
- FlowLayout flowLayout1 = new FlowLayout(FlowLayout.LEFT);
- flowLayout1.setAlignOnBaseline(true);
- csPropertiesPanel.setLayout(flowLayout1);
-
- enabledCB.setText("Enabled");
- enabledCB.setHorizontalAlignment(SwingConstants.CENTER);
- enabledCB.setHorizontalTextPosition(SwingConstants.LEFT);
- enabledCB.setName("enabledCB"); // NOI18N
- enabledCB.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent evt) {
- enabledCBActionPerformed(evt);
- }
- });
- csPropertiesPanel.add(enabledCB);
-
- virtualCB.setText("Virtual");
- virtualCB.setToolTipText("Enable Virtual Mode");
- virtualCB.setHorizontalAlignment(SwingConstants.CENTER);
- virtualCB.setHorizontalTextPosition(SwingConstants.LEFT);
- virtualCB.setName("virtualCB"); // NOI18N
- virtualCB.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent evt) {
- virtualCBActionPerformed(evt);
- }
- });
- csPropertiesPanel.add(virtualCB);
-
- filler4.setName("filler4"); // NOI18N
- csPropertiesPanel.add(filler4);
-
- lastUsedSerialLbl.setText("serial");
- lastUsedSerialLbl.setDoubleBuffered(true);
- lastUsedSerialLbl.setName("lastUsedSerialLbl"); // NOI18N
- csPropertiesPanel.add(lastUsedSerialLbl);
-
- topPanel.add(csPropertiesPanel);
-
- add(topPanel, BorderLayout.NORTH);
-
- centerPanel.setMinimumSize(new Dimension(1000, 540));
- centerPanel.setName("centerPanel"); // NOI18N
- centerPanel.setPreferredSize(new Dimension(1075, 500));
- centerPanel.setLayout(new BorderLayout());
-
- connectionPanel.setName("connectionPanel"); // NOI18N
- connectionPanel.setPreferredSize(new Dimension(1022, 45));
- FlowLayout flowLayout3 = new FlowLayout(FlowLayout.LEFT, 5, 2);
- flowLayout3.setAlignOnBaseline(true);
- connectionPanel.setLayout(flowLayout3);
-
- connectionTypeLbl.setHorizontalAlignment(SwingConstants.TRAILING);
- connectionTypeLbl.setText("Connection Type(s):");
- connectionTypeLbl.setName("connectionTypeLbl"); // NOI18N
- connectionPanel.add(connectionTypeLbl);
-
- connectionTypeBG.add(networkRB);
- networkRB.setText("Network");
- networkRB.setName("networkRB"); // NOI18N
- networkRB.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent evt) {
- networkRBActionPerformed(evt);
- }
- });
- connectionPanel.add(networkRB);
-
- connectionTypeBG.add(serialRB);
- serialRB.setText("Serial");
- serialRB.setName("serialRB"); // NOI18N
- serialRB.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent evt) {
- serialRBActionPerformed(evt);
- }
- });
- connectionPanel.add(serialRB);
-
- filler7.setName("filler7"); // NOI18N
- connectionPanel.add(filler7);
-
- connectionPropertiesLbl.setHorizontalAlignment(SwingConstants.TRAILING);
- connectionPropertiesLbl.setText("Properties:");
- connectionPropertiesLbl.setName("connectionPropertiesLbl"); // NOI18N
- connectionPropertiesLbl.setPreferredSize(new Dimension(100, 17));
- connectionPanel.add(connectionPropertiesLbl);
-
- serialPortCB.setName("serialPortCB"); // NOI18N
- serialPortCB.setPreferredSize(new Dimension(150, 30));
- serialPortCB.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent evt) {
- serialPortCBActionPerformed(evt);
- }
- });
- connectionPanel.add(serialPortCB);
-
- serialPortRefreshBtn.setIcon(new ImageIcon(getClass().getResource("/media/sync-black-24.png"))); // NOI18N
- serialPortRefreshBtn.setToolTipText("Refresh Serial Ports");
- serialPortRefreshBtn.setMargin(new Insets(2, 2, 2, 2));
- serialPortRefreshBtn.setName("serialPortRefreshBtn"); // NOI18N
- serialPortRefreshBtn.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent evt) {
- serialPortRefreshBtnActionPerformed(evt);
- }
- });
- connectionPanel.add(serialPortRefreshBtn);
-
- ipAddressTF.setText("0.0.0.0");
- ipAddressTF.setToolTipText("");
- ipAddressTF.setDoubleBuffered(true);
- ipAddressTF.setName("ipAddressTF"); // NOI18N
- ipAddressTF.setPreferredSize(new Dimension(150, 30));
- ipAddressTF.addFocusListener(new FocusAdapter() {
- public void focusLost(FocusEvent evt) {
- ipAddressTFFocusLost(evt);
- }
- });
- connectionPanel.add(ipAddressTF);
-
- portLbl.setText("Port:");
- portLbl.setName("portLbl"); // NOI18N
- connectionPanel.add(portLbl);
-
- portSpinner.setModel(new SpinnerNumberModel(0, 0, 65563, 1));
- portSpinner.setName("portSpinner"); // NOI18N
- portSpinner.setPreferredSize(new Dimension(100, 30));
- portSpinner.addChangeListener(new ChangeListener() {
- public void stateChanged(ChangeEvent evt) {
- portSpinnerStateChanged(evt);
- }
- });
- connectionPanel.add(portSpinner);
-
- autoConfChkBox.setText("Auto IP Configuration");
- autoConfChkBox.setName("autoConfChkBox"); // NOI18N
- connectionPanel.add(autoConfChkBox);
-
- centerPanel.add(connectionPanel, BorderLayout.NORTH);
-
- capabilitiesPanel.setName("capabilitiesPanel"); // NOI18N
- VerticalFlowLayout verticalFlowLayout1 = new VerticalFlowLayout();
- verticalFlowLayout1.sethAlignment(0);
- verticalFlowLayout1.sethGap(15);
- capabilitiesPanel.setLayout(verticalFlowLayout1);
-
- connectionTestPanel.setName("connectionTestPanel"); // NOI18N
- FlowLayout flowLayout9 = new FlowLayout(FlowLayout.RIGHT);
- flowLayout9.setAlignOnBaseline(true);
- connectionTestPanel.setLayout(flowLayout9);
-
- filler3.setName("filler3"); // NOI18N
- connectionTestPanel.add(filler3);
-
- testConnectionBtn.setIcon(new ImageIcon(getClass().getResource("/media/connect-24.png"))); // NOI18N
- testConnectionBtn.setText("Test");
- testConnectionBtn.setToolTipText("Test Connection and refresh Sensor Settings if applicable");
- testConnectionBtn.setDoubleBuffered(true);
- testConnectionBtn.setFocusable(false);
- testConnectionBtn.setHorizontalTextPosition(SwingConstants.LEADING);
- testConnectionBtn.setIconTextGap(2);
- testConnectionBtn.setMargin(new Insets(2, 2, 2, 2));
- testConnectionBtn.setMaximumSize(new Dimension(65, 40));
- testConnectionBtn.setMinimumSize(new Dimension(65, 40));
- testConnectionBtn.setName("testConnectionBtn"); // NOI18N
- testConnectionBtn.setPreferredSize(new Dimension(65, 40));
- testConnectionBtn.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent evt) {
- testConnectionBtnActionPerformed(evt);
- }
- });
- connectionTestPanel.add(testConnectionBtn);
-
- filler2.setName("filler2"); // NOI18N
- connectionTestPanel.add(filler2);
-
- connectionTestResultLbl.setText("Not Connected");
- connectionTestResultLbl.setName("connectionTestResultLbl"); // NOI18N
- connectionTestResultLbl.setPreferredSize(new Dimension(222, 17));
- connectionTestPanel.add(connectionTestResultLbl);
- connectionTestResultLbl.getAccessibleContext().setAccessibleName("");
-
- progressBar.setName("progressBar"); // NOI18N
- progressBar.setPreferredSize(new Dimension(200, 4));
- connectionTestPanel.add(progressBar);
-
- capabilitiesPanel.add(connectionTestPanel);
-
- decoderControlSupportPanel.setName("decoderControlSupportPanel"); // NOI18N
- FlowLayout flowLayout4 = new FlowLayout(FlowLayout.LEFT);
- flowLayout4.setAlignOnBaseline(true);
- decoderControlSupportPanel.setLayout(flowLayout4);
-
- decoderControlCB.setText("Decoder Control Support");
- decoderControlCB.setName("decoderControlCB"); // NOI18N
- decoderControlCB.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent evt) {
- decoderControlCBActionPerformed(evt);
- }
- });
- decoderControlSupportPanel.add(decoderControlCB);
-
- capabilitiesPanel.add(decoderControlSupportPanel);
-
- accessorySupportPanel.setName("accessorySupportPanel"); // NOI18N
- FlowLayout flowLayout12 = new FlowLayout(FlowLayout.LEFT);
- flowLayout12.setAlignOnBaseline(true);
- accessorySupportPanel.setLayout(flowLayout12);
-
- accessorySupportCB.setText("Accessory Support");
- accessorySupportCB.setName("accessorySupportCB"); // NOI18N
- accessorySupportCB.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent evt) {
- accessorySupportCBActionPerformed(evt);
- }
- });
- accessorySupportPanel.add(accessorySupportCB);
-
- capabilitiesPanel.add(accessorySupportPanel);
-
- feedbackSupportPanel.setName("feedbackSupportPanel"); // NOI18N
- FlowLayout flowLayout5 = new FlowLayout(FlowLayout.LEFT);
- flowLayout5.setAlignOnBaseline(true);
- feedbackSupportPanel.setLayout(flowLayout5);
-
- feedbackSupportCB.setText("Feedback Support");
- feedbackSupportCB.setName("feedbackSupportCB"); // NOI18N
- feedbackSupportCB.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent evt) {
- feedbackSupportCBActionPerformed(evt);
- }
- });
- feedbackSupportPanel.add(feedbackSupportCB);
-
- capabilitiesPanel.add(feedbackSupportPanel);
-
- FeedbackPropertiesPanel.setName("FeedbackPropertiesPanel"); // NOI18N
- FeedbackPropertiesPanel.setPreferredSize(new Dimension(1075, 33));
- FlowLayout flowLayout13 = new FlowLayout(FlowLayout.LEFT);
- flowLayout13.setAlignOnBaseline(true);
- FeedbackPropertiesPanel.setLayout(flowLayout13);
-
- feedbackIdLbl.setHorizontalAlignment(SwingConstants.TRAILING);
- feedbackIdLbl.setLabelFor(nodeSpinner);
- feedbackIdLbl.setText("Feedback Id:");
- feedbackIdLbl.setName("feedbackIdLbl"); // NOI18N
- feedbackIdLbl.setPreferredSize(new Dimension(90, 17));
- FeedbackPropertiesPanel.add(feedbackIdLbl);
-
- nodeSpinner.setModel(new SpinnerNumberModel(0, 0, 256, 1));
- nodeSpinner.setName("nodeSpinner"); // NOI18N
- nodeSpinner.addChangeListener(new ChangeListener() {
- public void stateChanged(ChangeEvent evt) {
- nodeSpinnerStateChanged(evt);
- }
- });
- FeedbackPropertiesPanel.add(nodeSpinner);
-
- channelCountLbl.setHorizontalAlignment(SwingConstants.TRAILING);
- channelCountLbl.setLabelFor(channelCountSpinner);
- channelCountLbl.setText("Channel Count:");
- channelCountLbl.setName("channelCountLbl"); // NOI18N
- channelCountLbl.setPreferredSize(new Dimension(90, 17));
- FeedbackPropertiesPanel.add(channelCountLbl);
- channelCountLbl.getAccessibleContext().setAccessibleName("Channel Count");
-
- channelCountSpinner.setModel(new SpinnerNumberModel(0, 0, 32, 1));
- channelCountSpinner.setName("channelCountSpinner"); // NOI18N
- channelCountSpinner.setPreferredSize(new Dimension(50, 23));
- channelCountSpinner.addChangeListener(new ChangeListener() {
- public void stateChanged(ChangeEvent evt) {
- channelCountSpinnerStateChanged(evt);
- }
- });
- FeedbackPropertiesPanel.add(channelCountSpinner);
-
- bus0Lbl.setHorizontalAlignment(SwingConstants.TRAILING);
- bus0Lbl.setLabelFor(bus0Spinner);
- bus0Lbl.setText("Ch 0 Modules:");
- bus0Lbl.setName("bus0Lbl"); // NOI18N
- bus0Lbl.setPreferredSize(new Dimension(90, 17));
- FeedbackPropertiesPanel.add(bus0Lbl);
-
- bus0Spinner.setModel(new SpinnerNumberModel(0, 0, 32, 1));
- bus0Spinner.setName("bus0Spinner"); // NOI18N
- bus0Spinner.setPreferredSize(new Dimension(50, 23));
- bus0Spinner.addChangeListener(new ChangeListener() {
- public void stateChanged(ChangeEvent evt) {
- bus0SpinnerStateChanged(evt);
- }
- });
- FeedbackPropertiesPanel.add(bus0Spinner);
-
- bus1Lbl.setHorizontalAlignment(SwingConstants.TRAILING);
- bus1Lbl.setLabelFor(bus1Spinner);
- bus1Lbl.setText("Ch 1 Modules:");
- bus1Lbl.setName("bus1Lbl"); // NOI18N
- bus1Lbl.setPreferredSize(new Dimension(90, 17));
- FeedbackPropertiesPanel.add(bus1Lbl);
-
- bus1Spinner.setModel(new SpinnerNumberModel(0, 0, 32, 1));
- bus1Spinner.setName("bus1Spinner"); // NOI18N
- bus1Spinner.setPreferredSize(new Dimension(50, 23));
- bus1Spinner.addChangeListener(new ChangeListener() {
- public void stateChanged(ChangeEvent evt) {
- bus1SpinnerStateChanged(evt);
- }
- });
- FeedbackPropertiesPanel.add(bus1Spinner);
-
- bus2Lbl.setHorizontalAlignment(SwingConstants.TRAILING);
- bus2Lbl.setLabelFor(bus2Spinner);
- bus2Lbl.setText("Ch 2 Modules:");
- bus2Lbl.setName("bus2Lbl"); // NOI18N
- bus2Lbl.setPreferredSize(new Dimension(90, 17));
- FeedbackPropertiesPanel.add(bus2Lbl);
-
- bus2Spinner.setModel(new SpinnerNumberModel(0, 0, 32, 1));
- bus2Spinner.setName("bus2Spinner"); // NOI18N
- bus2Spinner.setPreferredSize(new Dimension(50, 23));
- bus2Spinner.addChangeListener(new ChangeListener() {
- public void stateChanged(ChangeEvent evt) {
- bus2SpinnerStateChanged(evt);
- }
- });
- FeedbackPropertiesPanel.add(bus2Spinner);
-
- bus3Lbl.setHorizontalAlignment(SwingConstants.TRAILING);
- bus3Lbl.setLabelFor(bus3Spinner);
- bus3Lbl.setText("Ch 3 Modules:");
- bus3Lbl.setName("bus3Lbl"); // NOI18N
- bus3Lbl.setPreferredSize(new Dimension(90, 17));
- FeedbackPropertiesPanel.add(bus3Lbl);
-
- bus3Spinner.setModel(new SpinnerNumberModel(0, 0, 32, 1));
- bus3Spinner.setName("bus3Spinner"); // NOI18N
- bus3Spinner.setPreferredSize(new Dimension(50, 23));
- bus3Spinner.addChangeListener(new ChangeListener() {
- public void stateChanged(ChangeEvent evt) {
- bus3SpinnerStateChanged(evt);
- }
- });
- FeedbackPropertiesPanel.add(bus3Spinner);
-
- recreateSensorsBtn.setText("Re-create Sensors");
- recreateSensorsBtn.setName("recreateSensorsBtn"); // NOI18N
- recreateSensorsBtn.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent evt) {
- recreateSensorsBtnActionPerformed(evt);
- }
- });
- FeedbackPropertiesPanel.add(recreateSensorsBtn);
-
- capabilitiesPanel.add(FeedbackPropertiesPanel);
-
- locomotiveSynchSupportPanel.setName("locomotiveSynchSupportPanel"); // NOI18N
- FlowLayout flowLayout6 = new FlowLayout(FlowLayout.LEFT);
- flowLayout6.setAlignOnBaseline(true);
- locomotiveSynchSupportPanel.setLayout(flowLayout6);
-
- locomotiveSynchSupportCB.setText("Locomotive Synchronization Support");
- locomotiveSynchSupportCB.setName("locomotiveSynchSupportCB"); // NOI18N
- locomotiveSynchSupportCB.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent evt) {
- locomotiveSynchSupportCBActionPerformed(evt);
- }
- });
- locomotiveSynchSupportPanel.add(locomotiveSynchSupportCB);
-
- capabilitiesPanel.add(locomotiveSynchSupportPanel);
-
- accessorySynchSupportPanel.setName("accessorySynchSupportPanel"); // NOI18N
- FlowLayout flowLayout7 = new FlowLayout(FlowLayout.LEFT);
- flowLayout7.setAlignOnBaseline(true);
- accessorySynchSupportPanel.setLayout(flowLayout7);
-
- accessorySynchSupportCB.setText("Accessory Synchronization Support");
- accessorySynchSupportCB.setName("accessorySynchSupportCB"); // NOI18N
- accessorySynchSupportCB.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent evt) {
- accessorySynchSupportCBActionPerformed(evt);
- }
- });
- accessorySynchSupportPanel.add(accessorySynchSupportCB);
-
- capabilitiesPanel.add(accessorySynchSupportPanel);
-
- locomotiveImageSynchSupportPanel.setName("locomotiveImageSynchSupportPanel"); // NOI18N
-
- locomotiveImageSynchSupportCB.setText("Locomotive Image Synchronization Support");
- locomotiveImageSynchSupportCB.setName("locomotiveImageSynchSupportCB"); // NOI18N
- locomotiveImageSynchSupportCB.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent evt) {
- locomotiveImageSynchSupportCBActionPerformed(evt);
- }
- });
- locomotiveImageSynchSupportPanel.add(locomotiveImageSynchSupportCB);
-
- capabilitiesPanel.add(locomotiveImageSynchSupportPanel);
-
- locomotiveFunctionSynchSupportPanel.setName("locomotiveFunctionSynchSupportPanel"); // NOI18N
- FlowLayout flowLayout8 = new FlowLayout(FlowLayout.LEFT);
- flowLayout8.setAlignOnBaseline(true);
- locomotiveFunctionSynchSupportPanel.setLayout(flowLayout8);
-
- locomotiveFunctionSynchSupportCB.setText("Locomotive Functions Synchronization Support");
- locomotiveFunctionSynchSupportCB.setName("locomotiveFunctionSynchSupportCB"); // NOI18N
- locomotiveFunctionSynchSupportCB.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent evt) {
- locomotiveFunctionSynchSupportCBActionPerformed(evt);
- }
- });
- locomotiveFunctionSynchSupportPanel.add(locomotiveFunctionSynchSupportCB);
-
- capabilitiesPanel.add(locomotiveFunctionSynchSupportPanel);
-
- protocolPanel.setName("protocolPanel"); // NOI18N
-
- supportedProtocolsLbl.setText("Supported Protocols:");
- supportedProtocolsLbl.setName("supportedProtocolsLbl"); // NOI18N
- protocolPanel.add(supportedProtocolsLbl);
-
- mmRB.setText("MM");
- mmRB.setToolTipText("Marklin MM");
- mmRB.setName("mmRB"); // NOI18N
- mmRB.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent evt) {
- mmRBActionPerformed(evt);
- }
- });
- protocolPanel.add(mmRB);
-
- mfxRB.setText("MFX");
- mfxRB.setToolTipText("Marklin MFX");
- mfxRB.setName("mfxRB"); // NOI18N
- mfxRB.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent evt) {
- mfxRBActionPerformed(evt);
- }
- });
- protocolPanel.add(mfxRB);
-
- dccRB.setText("DCC");
- dccRB.setToolTipText("DCC");
- dccRB.setName("dccRB"); // NOI18N
- dccRB.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent evt) {
- dccRBActionPerformed(evt);
- }
- });
- protocolPanel.add(dccRB);
-
- sxRB.setText("SX");
- sxRB.setToolTipText("Selectrix");
- sxRB.setName("sxRB"); // NOI18N
- sxRB.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent evt) {
- sxRBActionPerformed(evt);
- }
- });
- protocolPanel.add(sxRB);
-
- filler10.setName("filler10"); // NOI18N
- protocolPanel.add(filler10);
-
- supportedConnectionTypesLbl.setText("Supported Connection Types:");
- supportedConnectionTypesLbl.setName("supportedConnectionTypesLbl"); // NOI18N
- protocolPanel.add(supportedConnectionTypesLbl);
-
- supConTypeNetworkRB.setText("Network");
- supConTypeNetworkRB.setToolTipText("");
- supConTypeNetworkRB.setName("supConTypeNetworkRB"); // NOI18N
- supConTypeNetworkRB.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent evt) {
- supConTypeNetworkRBActionPerformed(evt);
- }
- });
- protocolPanel.add(supConTypeNetworkRB);
-
- supConTypeSerialRB.setText("Serial");
- supConTypeSerialRB.setName("supConTypeSerialRB"); // NOI18N
- supConTypeSerialRB.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent evt) {
- supConTypeSerialRBActionPerformed(evt);
- }
- });
- protocolPanel.add(supConTypeSerialRB);
-
- capabilitiesPanel.add(protocolPanel);
-
- descPanel.setName("descPanel"); // NOI18N
-
- nameLbl.setText("Name:");
- nameLbl.setName("nameLbl"); // NOI18N
- descPanel.add(nameLbl);
-
- descriptionTF.setText("description");
- descriptionTF.setName("descriptionTF"); // NOI18N
- descriptionTF.setPreferredSize(new Dimension(200, 23));
- descriptionTF.addFocusListener(new FocusAdapter() {
- public void focusLost(FocusEvent evt) {
- descriptionTFFocusLost(evt);
- }
- });
- descPanel.add(descriptionTF);
-
- filler9.setName("filler9"); // NOI18N
- descPanel.add(filler9);
-
- classNameLbl.setText("Class name:");
- classNameLbl.setName("classNameLbl"); // NOI18N
- descPanel.add(classNameLbl);
-
- classNameTF.setText("class name");
- classNameTF.setName("classNameTF"); // NOI18N
- classNameTF.setPreferredSize(new Dimension(350, 23));
- classNameTF.addFocusListener(new FocusAdapter() {
- public void focusLost(FocusEvent evt) {
- classNameTFFocusLost(evt);
- }
- });
- descPanel.add(classNameTF);
-
- shortNameTFLb.setText("Shot Name:");
- shortNameTFLb.setName("shortNameTFLb"); // NOI18N
- descPanel.add(shortNameTFLb);
-
- shortNameTF.setName("shortNameTF"); // NOI18N
- shortNameTF.setPreferredSize(new Dimension(100, 23));
- shortNameTF.addFocusListener(new FocusAdapter() {
- public void focusLost(FocusEvent evt) {
- shortNameTFFocusLost(evt);
- }
- });
- descPanel.add(shortNameTF);
-
- capabilitiesPanel.add(descPanel);
-
- centerPanel.add(capabilitiesPanel, BorderLayout.CENTER);
-
- add(centerPanel, BorderLayout.CENTER);
-
- bottomPanel.setName("bottomPanel"); // NOI18N
- bottomPanel.setPreferredSize(new Dimension(1014, 40));
- bottomPanel.setRequestFocusEnabled(false);
- bottomPanel.setLayout(new BoxLayout(bottomPanel, BoxLayout.LINE_AXIS));
-
- leftBottomPanel.setName("leftBottomPanel"); // NOI18N
- FlowLayout flowLayout11 = new FlowLayout(FlowLayout.LEFT);
- flowLayout11.setAlignOnBaseline(true);
- leftBottomPanel.setLayout(flowLayout11);
-
- enableEditCB.setText("Enable Edit");
- enableEditCB.setName("enableEditCB"); // NOI18N
- enableEditCB.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent evt) {
- enableEditCBActionPerformed(evt);
- }
- });
- leftBottomPanel.add(enableEditCB);
-
- newBtn.setIcon(new ImageIcon(getClass().getResource("/media/add-24.png"))); // NOI18N
- newBtn.setToolTipText("Add a New Command Station");
- newBtn.setEnabled(false);
- newBtn.setName("newBtn"); // NOI18N
- newBtn.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent evt) {
- newBtnActionPerformed(evt);
- }
- });
- leftBottomPanel.add(newBtn);
-
- filler8.setName("filler8"); // NOI18N
- leftBottomPanel.add(filler8);
-
- idLbl.setText("id:");
- idLbl.setName("idLbl"); // NOI18N
- leftBottomPanel.add(idLbl);
-
- idTF.setText("id");
- idTF.setName("idTF"); // NOI18N
- idTF.setPreferredSize(new Dimension(200, 23));
- idTF.addFocusListener(new FocusAdapter() {
- public void focusLost(FocusEvent evt) {
- idTFFocusLost(evt);
- }
- });
- leftBottomPanel.add(idTF);
-
- bottomPanel.add(leftBottomPanel);
-
- rightBottomPanel.setName("rightBottomPanel"); // NOI18N
- FlowLayout flowLayout10 = new FlowLayout(FlowLayout.RIGHT);
- flowLayout10.setAlignOnBaseline(true);
- rightBottomPanel.setLayout(flowLayout10);
-
- filler1.setName("filler1"); // NOI18N
- rightBottomPanel.add(filler1);
-
- saveBtn.setIcon(new ImageIcon(getClass().getResource("/media/save-24.png"))); // NOI18N
- saveBtn.setToolTipText("Save and Exit");
- saveBtn.setEnabled(false);
- saveBtn.setName("saveBtn"); // NOI18N
- saveBtn.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent evt) {
- saveBtnActionPerformed(evt);
- }
- });
- rightBottomPanel.add(saveBtn);
-
- bottomPanel.add(rightBottomPanel);
-
- add(bottomPanel, BorderLayout.SOUTH);
- }// //GEN-END:initComponents
-
-
- private void testConnectionBtnActionPerformed(ActionEvent evt) {//GEN-FIRST:event_testConnectionBtnActionPerformed
- Logger.trace(evt.getActionCommand());
- this.progressBar.setVisible(true);
- progressBar.setIndeterminate(true);
-
- task = new Task();
- task.addPropertyChangeListener(this);
- task.execute();
- }//GEN-LAST:event_testConnectionBtnActionPerformed
-
- private void commandStationComboBoxActionPerformed(ActionEvent evt) {//GEN-FIRST:event_commandStationComboBoxActionPerformed
- //Switch power off and disconnect the the previous one!
- CommandStationBean newSelectedCommandStation = (CommandStationBean) commandStationComboBoxModel.getSelectedItem();
-
- if (!selectedCommandStation.getId().equals(newSelectedCommandStation.getId())) {
- try {
- if (JCS.getJcsCommandStation() != null) {
- JCS.getJcsCommandStation().switchPower(false);
- }
- if (JCS.getParentFrame() != null) {
- JCS.getParentFrame().connect(false);
- }
- } catch (Exception e) {
- Logger.error(e.getMessage());
- }
- }
-
- selectedCommandStation = (CommandStationBean) commandStationComboBoxModel.getSelectedItem();
- defaultCommandStationChkBox.setSelected(selectedCommandStation.isDefault());
- setFieldValues();
- this.enableFields(this.enableEditCB.isSelected());
- Logger.trace("Selected CS: " + this.selectedCommandStation.getDescription());
- }//GEN-LAST:event_commandStationComboBoxActionPerformed
-
- private void defaultCommandStationChkBoxActionPerformed(ActionEvent evt) {//GEN-FIRST:event_defaultCommandStationChkBoxActionPerformed
- Logger.trace("Setting " + selectedCommandStation + " as default");
- PersistenceFactory.getService().changeDefaultCommandStation(selectedCommandStation);
- initModels(null);
- }//GEN-LAST:event_defaultCommandStationChkBoxActionPerformed
-
- private void saveBtnActionPerformed(ActionEvent evt) {//GEN-FIRST:event_saveBtnActionPerformed
- Logger.trace(evt.getActionCommand());
- CommandStationBean csb = this.selectedCommandStation;
- PersistenceFactory.getService().persist(this.selectedCommandStation);
- initModels(csb);
- }//GEN-LAST:event_saveBtnActionPerformed
-
- private void ipAddressTFFocusLost(FocusEvent evt) {//GEN-FIRST:event_ipAddressTFFocusLost
- Logger.trace("IP address:" + ipAddressTF.getText());
- this.selectedCommandStation.setIpAddress(this.ipAddressTF.getText());
- PersistenceFactory.getService().persist(this.selectedCommandStation);
- }//GEN-LAST:event_ipAddressTFFocusLost
-
- private void portSpinnerStateChanged(ChangeEvent evt) {//GEN-FIRST:event_portSpinnerStateChanged
- Logger.trace("Port: " + this.portSpinner.getValue());
- this.selectedCommandStation.setNetworkPort((Integer) this.portSpinner.getValue());
- }//GEN-LAST:event_portSpinnerStateChanged
-
- private void feedbackSupportCBActionPerformed(ActionEvent evt) {//GEN-FIRST:event_feedbackSupportCBActionPerformed
- this.selectedCommandStation.setFeedbackSupport(this.feedbackSupportCB.isSelected());
- }//GEN-LAST:event_feedbackSupportCBActionPerformed
-
- private void enableEditCBActionPerformed(ActionEvent evt) {//GEN-FIRST:event_enableEditCBActionPerformed
- Logger.trace(evt.getActionCommand() + " " + this.enableEditCB.isSelected());
- enableFields(this.enableEditCB.isSelected());
- }//GEN-LAST:event_enableEditCBActionPerformed
-
- private void newBtnActionPerformed(ActionEvent evt) {//GEN-FIRST:event_newBtnActionPerformed
- this.selectedCommandStation = new CommandStationBean();
- this.selectedCommandStation.setId("new.cs");
- this.selectedCommandStation.setConnectionType(ConnectionType.NETWORK);
-
- ((DefaultComboBoxModel) commandStationComboBoxModel).addElement(selectedCommandStation);
- this.commandStationComboBoxModel.setSelectedItem(selectedCommandStation);
- setFieldValues();
- }//GEN-LAST:event_newBtnActionPerformed
-
- private void enabledCBActionPerformed(ActionEvent evt) {//GEN-FIRST:event_enabledCBActionPerformed
- this.selectedCommandStation.setEnabled(this.enabledCB.isSelected());
- PersistenceFactory.getService().persist(this.selectedCommandStation);
- }//GEN-LAST:event_enabledCBActionPerformed
-
- private void descriptionTFFocusLost(FocusEvent evt) {//GEN-FIRST:event_descriptionTFFocusLost
- this.selectedCommandStation.setDescription(this.descriptionTF.getText());
- }//GEN-LAST:event_descriptionTFFocusLost
-
- private void classNameTFFocusLost(FocusEvent evt) {//GEN-FIRST:event_classNameTFFocusLost
- this.selectedCommandStation.setClassName(this.classNameTF.getText());
- }//GEN-LAST:event_classNameTFFocusLost
-
- private void idTFFocusLost(FocusEvent evt) {//GEN-FIRST:event_idTFFocusLost
- this.selectedCommandStation.setId(this.idTF.getText());
- }//GEN-LAST:event_idTFFocusLost
-
- private void locomotiveFunctionSynchSupportCBActionPerformed(ActionEvent evt) {//GEN-FIRST:event_locomotiveFunctionSynchSupportCBActionPerformed
- this.selectedCommandStation.setLocomotiveFunctionSynchronizationSupport(this.locomotiveFunctionSynchSupportCB.isSelected());
- }//GEN-LAST:event_locomotiveFunctionSynchSupportCBActionPerformed
-
- private void locomotiveImageSynchSupportCBActionPerformed(ActionEvent evt) {//GEN-FIRST:event_locomotiveImageSynchSupportCBActionPerformed
- this.selectedCommandStation.setLocomotiveImageSynchronizationSupport(this.locomotiveImageSynchSupportCB.isSelected());
- }//GEN-LAST:event_locomotiveImageSynchSupportCBActionPerformed
-
- private void accessorySynchSupportCBActionPerformed(ActionEvent evt) {//GEN-FIRST:event_accessorySynchSupportCBActionPerformed
- this.selectedCommandStation.setAccessorySynchronizationSupport(this.accessorySynchSupportCB.isSelected());
- }//GEN-LAST:event_accessorySynchSupportCBActionPerformed
-
- private void locomotiveSynchSupportCBActionPerformed(ActionEvent evt) {//GEN-FIRST:event_locomotiveSynchSupportCBActionPerformed
- this.selectedCommandStation.setLocomotiveSynchronizationSupport(this.locomotiveSynchSupportCB.isSelected());
- }//GEN-LAST:event_locomotiveSynchSupportCBActionPerformed
-
- private void decoderControlCBActionPerformed(ActionEvent evt) {//GEN-FIRST:event_decoderControlCBActionPerformed
- this.selectedCommandStation.setDecoderControlSupport(this.decoderControlCB.isSelected());
- }//GEN-LAST:event_decoderControlCBActionPerformed
-
- private void networkRBActionPerformed(ActionEvent evt) {//GEN-FIRST:event_networkRBActionPerformed
- //this.enableFields(this.enableEditCB.isSelected());
- this.selectedCommandStation.setConnectionType(ConnectionType.NETWORK);
- Logger.trace("Connectiontypes set to: " + ConnectionType.NETWORK);
- PersistenceFactory.getService().persist(this.selectedCommandStation);
- this.enableFields(this.enableEditCB.isSelected());
- }//GEN-LAST:event_networkRBActionPerformed
-
- private void serialRBActionPerformed(ActionEvent evt) {//GEN-FIRST:event_serialRBActionPerformed
- //this.enableFields(this.enableEditCB.isSelected());
- this.selectedCommandStation.setConnectionType(ConnectionType.SERIAL);
- Logger.trace("Connectiontypes set to: " + ConnectionType.SERIAL);
- PersistenceFactory.getService().persist(this.selectedCommandStation);
- this.enableFields(this.enableEditCB.isSelected());
- }//GEN-LAST:event_serialRBActionPerformed
-
- private void shortNameTFFocusLost(FocusEvent evt) {//GEN-FIRST:event_shortNameTFFocusLost
- this.selectedCommandStation.setShortName(this.shortNameTF.getText());
- this.shortNameLbl.setText(this.selectedCommandStation.getShortName());
- }//GEN-LAST:event_shortNameTFFocusLost
-
- private void mmRBActionPerformed(ActionEvent evt) {//GEN-FIRST:event_mmRBActionPerformed
- if (this.mmRB.isSelected()) {
- this.selectedCommandStation.addProtocol(Protocol.MM);
- } else {
- this.selectedCommandStation.removeProtocol(Protocol.MM);
- }
- }//GEN-LAST:event_mmRBActionPerformed
-
- private void mfxRBActionPerformed(ActionEvent evt) {//GEN-FIRST:event_mfxRBActionPerformed
- if (this.mfxRB.isSelected()) {
- this.selectedCommandStation.addProtocol(Protocol.MFX);
- } else {
- this.selectedCommandStation.removeProtocol(Protocol.MFX);
- }
- }//GEN-LAST:event_mfxRBActionPerformed
-
- private void dccRBActionPerformed(ActionEvent evt) {//GEN-FIRST:event_dccRBActionPerformed
- if (this.dccRB.isSelected()) {
- this.selectedCommandStation.addProtocol(Protocol.DCC);
- } else {
- this.selectedCommandStation.removeProtocol(Protocol.DCC);
- }
- }//GEN-LAST:event_dccRBActionPerformed
-
- private void sxRBActionPerformed(ActionEvent evt) {//GEN-FIRST:event_sxRBActionPerformed
- if (this.sxRB.isSelected()) {
- this.selectedCommandStation.addProtocol(Protocol.SX);
- } else {
- this.selectedCommandStation.removeProtocol(Protocol.SX);
- }
- }//GEN-LAST:event_sxRBActionPerformed
-
- private void accessorySupportCBActionPerformed(ActionEvent evt) {//GEN-FIRST:event_accessorySupportCBActionPerformed
- this.selectedCommandStation.setAccessoryControlSupport(this.accessorySupportCB.isSelected());
- }//GEN-LAST:event_accessorySupportCBActionPerformed
-
- private void serialPortRefreshBtnActionPerformed(ActionEvent evt) {//GEN-FIRST:event_serialPortRefreshBtnActionPerformed
- SerialPort comPorts[] = SerialPort.getCommPorts();
-
- String[] ports = new String[comPorts.length];
- for (int i = 0; i < comPorts.length; i++) {
- ports[i] = comPorts[i].getSystemPortName();
- }
- serialPortComboBoxModel = new DefaultComboBoxModel<>(ports);
- serialPortCB.setModel(serialPortComboBoxModel);
-
- String portName = selectedCommandStation.getSerialPort();
- Logger.trace("Selected portName: " + portName);
-
- if (portName != null) {
- try {
- SerialPort comPort = SerialPort.getCommPort(portName);
- this.serialPortComboBoxModel.setSelectedItem(comPort);
- Logger.trace("Selected ComPort: " + comPort);
-
- if (comPort != null) {
- this.serialPortComboBoxModel.setSelectedItem(comPort.getSystemPortName());
- }
- } catch (SerialPortInvalidPortException ioe) {
- Logger.warn("Can't find com port: " + portName + "; " + ioe.getMessage());
- }
- }
- }//GEN-LAST:event_serialPortRefreshBtnActionPerformed
-
- private void serialPortCBActionPerformed(ActionEvent evt) {//GEN-FIRST:event_serialPortCBActionPerformed
- String port = serialPortComboBoxModel.getSelectedItem().toString();
-
- SerialPort comPort = SerialPort.getCommPort(port);
-
- String portDescription = comPort.getSystemPortName();
- this.selectedCommandStation.setSerialPort(portDescription);
- Logger.trace("Selected Comport: " + portDescription);
- PersistenceFactory.getService().persist(this.selectedCommandStation);
- }//GEN-LAST:event_serialPortCBActionPerformed
-
- private void supConTypeNetworkRBActionPerformed(ActionEvent evt) {//GEN-FIRST:event_supConTypeNetworkRBActionPerformed
- if (this.supConTypeNetworkRB.isSelected()) {
- this.selectedCommandStation.addSupportedConnectionType(ConnectionType.NETWORK);
- } else {
- this.selectedCommandStation.removeSupportedConnectionType(ConnectionType.NETWORK);
- }
- }//GEN-LAST:event_supConTypeNetworkRBActionPerformed
-
- private void supConTypeSerialRBActionPerformed(ActionEvent evt) {//GEN-FIRST:event_supConTypeSerialRBActionPerformed
- if (this.supConTypeSerialRB.isSelected()) {
- this.selectedCommandStation.addSupportedConnectionType(ConnectionType.SERIAL);
- } else {
- this.selectedCommandStation.removeSupportedConnectionType(ConnectionType.SERIAL);
- }
- }//GEN-LAST:event_supConTypeSerialRBActionPerformed
-
- private void channelCountSpinnerStateChanged(ChangeEvent evt) {//GEN-FIRST:event_channelCountSpinnerStateChanged
- this.selectedCommandStation.setFeedbackChannelCount((Integer) this.channelCountSpinner.getValue());
- PersistenceFactory.getService().persist(this.selectedCommandStation);
- }//GEN-LAST:event_channelCountSpinnerStateChanged
-
- private void bus0SpinnerStateChanged(ChangeEvent evt) {//GEN-FIRST:event_bus0SpinnerStateChanged
- this.selectedCommandStation.setFeedbackBus0ModuleCount((Integer) this.bus0Spinner.getValue());
- PersistenceFactory.getService().persist(this.selectedCommandStation);
- }//GEN-LAST:event_bus0SpinnerStateChanged
-
- private void bus1SpinnerStateChanged(ChangeEvent evt) {//GEN-FIRST:event_bus1SpinnerStateChanged
- this.selectedCommandStation.setFeedbackBus1ModuleCount((Integer) this.bus1Spinner.getValue());
- PersistenceFactory.getService().persist(this.selectedCommandStation);
- }//GEN-LAST:event_bus1SpinnerStateChanged
-
- private void bus2SpinnerStateChanged(ChangeEvent evt) {//GEN-FIRST:event_bus2SpinnerStateChanged
- this.selectedCommandStation.setFeedbackBus2ModuleCount((Integer) this.bus2Spinner.getValue());
- PersistenceFactory.getService().persist(this.selectedCommandStation);
- }//GEN-LAST:event_bus2SpinnerStateChanged
-
- private void bus3SpinnerStateChanged(ChangeEvent evt) {//GEN-FIRST:event_bus3SpinnerStateChanged
- this.selectedCommandStation.setFeedbackBus3ModuleCount((Integer) this.bus3Spinner.getValue());
- PersistenceFactory.getService().persist(this.selectedCommandStation);
- }//GEN-LAST:event_bus3SpinnerStateChanged
-
- private void nodeSpinnerStateChanged(ChangeEvent evt) {//GEN-FIRST:event_nodeSpinnerStateChanged
- this.selectedCommandStation.setFeedbackModuleIdentifier(this.nodeSpinner.getValue().toString());
- PersistenceFactory.getService().persist(this.selectedCommandStation);
- }//GEN-LAST:event_nodeSpinnerStateChanged
-
- private void recreateSensorsBtnActionPerformed(ActionEvent evt) {//GEN-FIRST:event_recreateSensorsBtnActionPerformed
- recreateSensors();
- }//GEN-LAST:event_recreateSensorsBtnActionPerformed
-
- private void virtualCBActionPerformed(ActionEvent evt) {//GEN-FIRST:event_virtualCBActionPerformed
- this.selectedCommandStation.setVirtual(this.virtualCB.isSelected());
- PersistenceFactory.getService().persist(this.selectedCommandStation);
- }//GEN-LAST:event_virtualCBActionPerformed
-
- private void recreateSensors() {
-
- if (selectedCommandStation.isFeedbackSupport()) {
- List feedbackModules = ((FeedbackController) selectedCommandStation).getFeedbackModules();
- PersistenceFactory.getService().removeAllSensors();
-
- for (FeedbackModule fm : feedbackModules) {
- PersistenceFactory.getService().persistSensorBeans(fm.getSensors());
- }
- }
- }
-
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
- if ("progress".equals(evt.getPropertyName())) {
- int progress = (Integer) evt.getNewValue();
- progressBar.setValue(progress);
- progressBar.setIndeterminate(progress > 20);
-
- if (task.isDone()) {
- testConnectionBtn.setEnabled(true);
- }
- }
-
- if ("ipAddress".equals(evt.getPropertyName())) {
- Logger.trace("Found IP address: " + evt.getNewValue());
- ipAddressTF.setText((String) evt.getNewValue());
- selectedCommandStation.setIpAddress(this.ipAddressTF.getText());
- }
-
- if ("serial".equals(evt.getPropertyName())) {
- Logger.trace("Found Serial: " + evt.getNewValue());
- lastUsedSerialLbl.setText((String) evt.getNewValue());
- selectedCommandStation.setLastUsedSerial(lastUsedSerialLbl.getText());
- lastUsedSerialLbl.setText("Serial number: " + lastUsedSerialLbl.getText());
- lastUsedSerialLbl.setVisible(true);
- }
-
- if ("node".equals(evt.getPropertyName())) {
- Logger.trace("Node id: " + evt.getNewValue());
- selectedCommandStation.setFeedbackModuleIdentifier("" + evt.getNewValue());
- this.nodeSpinner.setValue(evt.getNewValue());
- }
-
- if ("channels".equals(evt.getPropertyName())) {
- Logger.trace("Feedback channel count: " + evt.getNewValue());
- selectedCommandStation.setFeedbackChannelCount((Integer) evt.getNewValue());
- this.channelCountSpinner.setValue(evt.getNewValue());
- }
-
- if ("bus0".equals(evt.getPropertyName())) {
- Logger.trace("Bus 0 Lenght: " + evt.getNewValue());
- selectedCommandStation.setFeedbackBus0ModuleCount((Integer) evt.getNewValue());
- bus0Spinner.setValue(evt.getNewValue());
- }
-
- if ("bus1".equals(evt.getPropertyName())) {
- Logger.trace("Bus 1 Lenght: " + evt.getNewValue());
- selectedCommandStation.setFeedbackBus1ModuleCount((Integer) evt.getNewValue());
- bus1Spinner.setValue(evt.getNewValue());
- }
-
- if ("bus2".equals(evt.getPropertyName())) {
- Logger.trace("Bus 2 Lenght: " + evt.getNewValue());
- selectedCommandStation.setFeedbackBus2ModuleCount((Integer) evt.getNewValue());
- bus2Spinner.setValue(evt.getNewValue());
- }
-
- if ("bus3".equals(evt.getPropertyName())) {
- Logger.trace("Bus 3 Lenght: " + evt.getNewValue());
- selectedCommandStation.setFeedbackBus3ModuleCount((Integer) evt.getNewValue());
- bus3Spinner.setValue(evt.getNewValue());
- }
-
- if ("done".equals(evt.getPropertyName())) {
- Logger.trace("Done: " + evt.getNewValue());
- this.connectionTestResultLbl.setText((String) evt.getNewValue());
- this.progressBar.setVisible(false);
- PersistenceFactory.getService().persist(this.selectedCommandStation);
- }
- }
-
- class Task extends SwingWorker {
-
- @Override
- public Void doInBackground() {
- setProgress(0);
-
- if (null == selectedCommandStation.getConnectionType()) {
- firePropertyChange("done", "", "Can't Connect");
- setProgress(100);
- } else {
- switch (selectedCommandStation.getConnectionType()) {
- case NETWORK -> {
- boolean canConnect = false;
- try {
- String ip = selectedCommandStation.getIpAddress();
- setProgress(10);
- DecoderController commandStation = createCommandStation(selectedCommandStation);
- setProgress(20);
-
- if (ip == null && selectedCommandStation.isIpAutoConfiguration()) {
- //Try to obtain the ip through auto configuration
- //A connection could be there...
- canConnect = commandStation.isConnected();
- if (canConnect) {
- Logger.trace("allready connected");
- } else {
- //try to connected
- canConnect = commandStation.connect();
- }
- setProgress(30);
- } else {
- if (Ping.IsReachable(ip)) {
- setProgress(10);
- canConnect = commandStation.isConnected();
- if (canConnect) {
- Logger.trace("allready connected");
- } else {
- canConnect = commandStation.connect();
- setProgress(20);
- }
- }
- }
- if (canConnect) {
- firePropertyChange("ipAddress", "", commandStation.getIp());
- //Lets obtain some data fail safe
- try {
- String sn = commandStation.getCommandStationInfo().getSerialNumber();
- firePropertyChange("serial", "", sn);
- setProgress(50);
-
- if (commandStation instanceof FeedbackController feedbackController) {
- List feedbackModules = feedbackController.getFeedbackModules();
-
- if (!feedbackModules.isEmpty()) {
- Logger.trace(feedbackController.getCommandStationInfo().getProductName() + " Supports Feedback");
- //String id = fbDevice.getIdentifier();
-
-// int node = Integer.parseInt(id.replace("0x", ""), 16);
-// firePropertyChange("node", selectedCommandStation.getFeedbackModuleIdentifier(), node);
-//
-// Integer channelCount = fbDevice.getSensorBuses().size();
-// firePropertyChange("channels", selectedCommandStation.getFeedbackChannelCount(), channelCount);
-//
-// Integer bus0 = fbDevice.getBusLength(0);
-// firePropertyChange("bus0", selectedCommandStation.getFeedbackBus0ModuleCount(), bus0);
-//
-// Integer bus1 = fbDevice.getBusLength(1);
-// firePropertyChange("bus1", selectedCommandStation.getFeedbackBus1ModuleCount(), bus1);
-//
-// Integer bus2 = fbDevice.getBusLength(2);
-// firePropertyChange("bus2", selectedCommandStation.getFeedbackBus2ModuleCount(), bus2);
-//
-// Integer bus3 = fbDevice.getBusLength(3);
-// firePropertyChange("bus3", selectedCommandStation.getFeedbackBus3ModuleCount(), bus3);
-//
-// Logger.trace("ID: " + id + " Node: " + node + " Bus 0: " + bus0 + " Bus 1: " + bus1 + " Bus 2: " + bus2 + " Bus 3: " + bus3);
- }
- }
- } catch (RuntimeException e) {
- Logger.warn("Error in data retrieval " + e.getMessage());
- }
- setProgress(90);
-
- String ipaddress = commandStation.getIp();
- ipAddressTF.setText(ipaddress);
-
- commandStation.disconnect();
- firePropertyChange("done", "", "Connection succeeded");
- setProgress(100);
-
- } else {
- firePropertyChange("done", "", "Can't Connect");
- setProgress(100);
- }
- } catch (Exception e) {
- Logger.error(e.getMessage());
- firePropertyChange("done", "", "Can't Connect");
- setProgress(100);
- }
- }
-
- case SERIAL -> {
- String commPort = selectedCommandStation.getSerialPort();
- setProgress(10);
- if (commPort != null) {
- try {
- SerialPort comPort = SerialPort.getCommPort(commPort);
- comPort.openPort();
- if (comPort.isOpen()) {
- firePropertyChange("done", "", "Connection succeeded");
- setProgress(100);
- comPort.closePort();
- } else {
- firePropertyChange("done", "", "Can't open port " + commPort + " connection failed");
- setProgress(100);
- }
- } catch (SerialPortInvalidPortException ioe) {
- firePropertyChange("done", "", "Port " + commPort + " does not exist. Connection failed");
- setProgress(100);
- }
- }
- }
- default -> {
- firePropertyChange("done", "", "Can't Connect");
- setProgress(100);
- }
- }
- }
-
- return null;
- }
-
- @Override
- public void done() {
- testConnectionBtn.setEnabled(true);
- }
- }
-
- private DecoderController createCommandStation(CommandStationBean commandStationBean) {
- return ControllerFactory.getDecoderController(commandStationBean, false);
- }
-
- // Variables declaration - do not modify//GEN-BEGIN:variables
- JPanel FeedbackPropertiesPanel;
- JCheckBox accessorySupportCB;
- JPanel accessorySupportPanel;
- JCheckBox accessorySynchSupportCB;
- JPanel accessorySynchSupportPanel;
- JCheckBox autoConfChkBox;
- JPanel bottomPanel;
- JLabel bus0Lbl;
- JSpinner bus0Spinner;
- JLabel bus1Lbl;
- JSpinner bus1Spinner;
- JLabel bus2Lbl;
- JSpinner bus2Spinner;
- JLabel bus3Lbl;
- JSpinner bus3Spinner;
- JPanel capabilitiesPanel;
- JPanel centerPanel;
- JLabel channelCountLbl;
- JSpinner channelCountSpinner;
- JLabel classNameLbl;
- JTextField classNameTF;
- JComboBox commandStationComboBox;
- JLabel commandStationLbl;
- JPanel commandStationSelectionPanel;
- JPanel connectionPanel;
- JLabel connectionPropertiesLbl;
- JPanel connectionTestPanel;
- JLabel connectionTestResultLbl;
- ButtonGroup connectionTypeBG;
- JLabel connectionTypeLbl;
- JPanel csPropertiesPanel;
- JRadioButton dccRB;
- JCheckBox decoderControlCB;
- JPanel decoderControlSupportPanel;
- JCheckBox defaultCommandStationChkBox;
- JPanel descPanel;
- JTextField descriptionTF;
- JCheckBox enableEditCB;
- JCheckBox enabledCB;
- JLabel feedbackIdLbl;
- JCheckBox feedbackSupportCB;
- JPanel feedbackSupportPanel;
- Box.Filler filler1;
- Box.Filler filler10;
- Box.Filler filler2;
- Box.Filler filler3;
- Box.Filler filler4;
- Box.Filler filler5;
- Box.Filler filler6;
- Box.Filler filler7;
- Box.Filler filler8;
- Box.Filler filler9;
- JLabel idLbl;
- JTextField idTF;
- JTextField ipAddressTF;
- JLabel lastUsedSerialLbl;
- JPanel leftBottomPanel;
- JCheckBox locomotiveFunctionSynchSupportCB;
- JPanel locomotiveFunctionSynchSupportPanel;
- JCheckBox locomotiveImageSynchSupportCB;
- JPanel locomotiveImageSynchSupportPanel;
- JCheckBox locomotiveSynchSupportCB;
- JPanel locomotiveSynchSupportPanel;
- JRadioButton mfxRB;
- JRadioButton mmRB;
- JLabel nameLbl;
- JRadioButton networkRB;
- JButton newBtn;
- JSpinner nodeSpinner;
- JLabel portLbl;
- JSpinner portSpinner;
- JProgressBar progressBar;
- JPanel protocolPanel;
- JButton recreateSensorsBtn;
- JPanel rightBottomPanel;
- JButton saveBtn;
- JComboBox serialPortCB;
- JButton serialPortRefreshBtn;
- JRadioButton serialRB;
- JLabel shortNameLbl;
- JTextField shortNameTF;
- JLabel shortNameTFLb;
- JRadioButton supConTypeNetworkRB;
- JRadioButton supConTypeSerialRB;
- JLabel supportedConnectionTypesLbl;
- JLabel supportedProtocolsLbl;
- JRadioButton sxRB;
- JButton testConnectionBtn;
- JPanel topPanel;
- JCheckBox virtualCB;
- // End of variables declaration//GEN-END:variables
-}
diff --git a/src/main/java/jcs/ui/settings/LocomotiveDialog.form b/src/main/java/jcs/ui/settings/LocomotiveDialog.form
index 6c4307ca..77be1591 100644
--- a/src/main/java/jcs/ui/settings/LocomotiveDialog.form
+++ b/src/main/java/jcs/ui/settings/LocomotiveDialog.form
@@ -9,6 +9,9 @@
+
+
+
diff --git a/src/main/java/jcs/ui/settings/LocomotiveDialog.java b/src/main/java/jcs/ui/settings/LocomotiveDialog.java
index 19cf1dfc..dc2b35b6 100644
--- a/src/main/java/jcs/ui/settings/LocomotiveDialog.java
+++ b/src/main/java/jcs/ui/settings/LocomotiveDialog.java
@@ -19,6 +19,7 @@
import javax.swing.JFrame;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
+import jcs.ui.JCSFrame;
import org.tinylog.Logger;
/**
@@ -48,13 +49,25 @@ private void initComponents() {
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setTitle("Locomotives");
+ addWindowListener(new java.awt.event.WindowAdapter() {
+ public void windowClosed(java.awt.event.WindowEvent evt) {
+ formWindowClosed(evt);
+ }
+ });
getContentPane().add(locomotiveSettingsPanel1, java.awt.BorderLayout.CENTER);
pack();
}// //GEN-END:initComponents
+ private void formWindowClosed(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosed
+ if (getParent() instanceof JCSFrame jCSFrame) {
+ jCSFrame.refreshLocomotives();
+ }
+ }//GEN-LAST:event_formWindowClosed
+
/**
* Only for testing
+ *
* @param args the command line arguments
*/
public static void main(String args[]) {
@@ -76,11 +89,11 @@ public void windowClosing(java.awt.event.WindowEvent e) {
System.exit(0);
}
});
-
+
dialog.pack();
dialog.setLocationRelativeTo(null);
dialog.setVisible(true);
-
+
});
}
diff --git a/src/main/java/jcs/ui/settings/LocomotiveSettingsPanel.form b/src/main/java/jcs/ui/settings/LocomotiveSettingsPanel.form
index ec9e6185..4c4fa9a5 100755
--- a/src/main/java/jcs/ui/settings/LocomotiveSettingsPanel.form
+++ b/src/main/java/jcs/ui/settings/LocomotiveSettingsPanel.form
@@ -1447,6 +1447,64 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -1500,6 +1558,134 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -1513,14 +1699,14 @@
-
+
-
+
@@ -1529,19 +1715,19 @@
-
+
-
+
-
+
-
+
@@ -1549,7 +1735,7 @@
-
+
@@ -1561,7 +1747,7 @@
-
+
@@ -1604,7 +1790,7 @@
-
+
@@ -1613,16 +1799,16 @@
-
+
-
+
-
+
@@ -1630,7 +1816,7 @@
-
+
@@ -1642,7 +1828,7 @@
-
+
@@ -1751,14 +1937,14 @@
-
+
-
+
@@ -1767,19 +1953,19 @@
-
+
-
+
-
+
-
+
@@ -1787,7 +1973,7 @@
-
+
@@ -1799,16 +1985,16 @@
-
+
-
+
-
+
@@ -1819,12 +2005,12 @@
-
+
-
+
diff --git a/src/main/java/jcs/ui/settings/LocomotiveSettingsPanel.java b/src/main/java/jcs/ui/settings/LocomotiveSettingsPanel.java
index fccb6019..edf982fc 100755
--- a/src/main/java/jcs/ui/settings/LocomotiveSettingsPanel.java
+++ b/src/main/java/jcs/ui/settings/LocomotiveSettingsPanel.java
@@ -278,6 +278,14 @@ private void initComponents() {
showCB = new JCheckBox();
commuterCB = new JCheckBox();
row6Panel = new JPanel();
+ speed1Lbl = new JLabel();
+ speed1Spinner = new JSpinner();
+ speed2Lbl = new JLabel();
+ speed2Spinner = new JSpinner();
+ speed3Lbl = new JLabel();
+ speed3Spinner = new JSpinner();
+ speed4Lbl = new JLabel();
+ speed4Spinner = new JSpinner();
row7Panel = new JPanel();
row9Panel = new JPanel();
filler2 = new Box.Filler(new Dimension(0, 50), new Dimension(0, 50), new Dimension(32767, 300));
@@ -610,6 +618,35 @@ public void actionPerformed(ActionEvent evt) {
FlowLayout flowLayout7 = new FlowLayout(FlowLayout.LEFT);
flowLayout7.setAlignOnBaseline(true);
row6Panel.setLayout(flowLayout7);
+
+ speed1Lbl.setHorizontalAlignment(SwingConstants.TRAILING);
+ speed1Lbl.setLabelFor(speed1Spinner);
+ speed1Lbl.setText("Speed 1:");
+ speed1Lbl.setPreferredSize(new Dimension(100, 17));
+ row6Panel.add(speed1Lbl);
+ row6Panel.add(speed1Spinner);
+
+ speed2Lbl.setHorizontalAlignment(SwingConstants.TRAILING);
+ speed2Lbl.setLabelFor(speed2Spinner);
+ speed2Lbl.setText("Speed 2:");
+ speed2Lbl.setPreferredSize(new Dimension(60, 17));
+ row6Panel.add(speed2Lbl);
+ row6Panel.add(speed2Spinner);
+
+ speed3Lbl.setHorizontalAlignment(SwingConstants.TRAILING);
+ speed3Lbl.setLabelFor(speed3Spinner);
+ speed3Lbl.setText("Speed 3:");
+ speed3Lbl.setPreferredSize(new Dimension(60, 17));
+ row6Panel.add(speed3Lbl);
+ row6Panel.add(speed3Spinner);
+
+ speed4Lbl.setHorizontalAlignment(SwingConstants.TRAILING);
+ speed4Lbl.setLabelFor(speed4Spinner);
+ speed4Lbl.setText("Speed 4:");
+ speed4Lbl.setPreferredSize(new Dimension(60, 17));
+ row6Panel.add(speed4Lbl);
+ row6Panel.add(speed4Spinner);
+
locoDetailPanel.add(row6Panel);
row7Panel.setMinimumSize(new Dimension(380, 30));
@@ -1031,14 +1068,14 @@ public void propertyChange(PropertyChangeEvent evt) {
if (!locoListModel.contains((LocomotiveBean) evt.getNewValue())) {
locoListModel.add((LocomotiveBean) evt.getNewValue());
}
- this.locomotiveList.setSelectedValue(evt.getNewValue(), true);
+ locomotiveList.setSelectedValue(evt.getNewValue(), true);
}
if ("done".equals(evt.getPropertyName())) {
Logger.trace("Done: " + evt.getNewValue());
//this.connectionTestResultLbl.setText((String) evt.getNewValue());
- this.synchPB.setVisible(false);
- this.locomotiveList.setEnabled(true);
+ synchPB.setVisible(false);
+ locomotiveList.setEnabled(true);
locomotiveList.clearSelection();
}
}
@@ -1156,7 +1193,6 @@ public Void doInBackground() {
public void done() {
initModels();
synchronizeBtn.setEnabled(commandStationBean.isLocomotiveSynchronizationSupport());
-
}
}
@@ -1201,6 +1237,14 @@ public void done() {
JPanel row9Panel;
JButton saveBtn;
JCheckBox showCB;
+ JLabel speed1Lbl;
+ JSpinner speed1Spinner;
+ JLabel speed2Lbl;
+ JSpinner speed2Spinner;
+ JLabel speed3Lbl;
+ JSpinner speed3Spinner;
+ JLabel speed4Lbl;
+ JSpinner speed4Spinner;
JProgressBar synchPB;
JButton synchronizeBtn;
JCheckBox synchronizeCB;
diff --git a/src/main/java/jcs/ui/settings/SettingsDialog.form b/src/main/java/jcs/ui/settings/SettingsDialog.form
index 929e22bb..cdac96a2 100755
--- a/src/main/java/jcs/ui/settings/SettingsDialog.form
+++ b/src/main/java/jcs/ui/settings/SettingsDialog.form
@@ -14,6 +14,9 @@
+
+
+
diff --git a/src/main/java/jcs/ui/settings/SettingsDialog.java b/src/main/java/jcs/ui/settings/SettingsDialog.java
index bb7fd0e5..07cda962 100755
--- a/src/main/java/jcs/ui/settings/SettingsDialog.java
+++ b/src/main/java/jcs/ui/settings/SettingsDialog.java
@@ -22,6 +22,8 @@
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JPanel;
@@ -31,6 +33,7 @@
import javax.swing.WindowConstants;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
+import jcs.ui.JCSFrame;
import org.tinylog.Logger;
/**
@@ -74,6 +77,11 @@ private void initComponents() {
setAlwaysOnTop(true);
setMinimumSize(new Dimension(1024, 750));
setName("Options"); // NOI18N
+ addWindowListener(new WindowAdapter() {
+ public void windowClosed(WindowEvent evt) {
+ formWindowClosed(evt);
+ }
+ });
centerPanel.setMinimumSize(new Dimension(1021, 750));
centerPanel.setName("centerPanel"); // NOI18N
@@ -120,6 +128,12 @@ private void dialogTPStateChanged(ChangeEvent evt) {//GEN-FIRST:event_dialogTPSt
Logger.debug("Refreshed " + (c != null ? c.getName() : ""));
}//GEN-LAST:event_dialogTPStateChanged
+ private void formWindowClosed(WindowEvent evt) {//GEN-FIRST:event_formWindowClosed
+ if (getParent() instanceof JCSFrame jCSFrame) {
+ jCSFrame.refreshLocomotives();
+ }
+ }//GEN-LAST:event_formWindowClosed
+
/**
* @param args the command line arguments
*/
diff --git a/src/main/resources/media/square-grid-24.png b/src/main/resources/media/square-grid-24.png
new file mode 100755
index 00000000..dbf96029
Binary files /dev/null and b/src/main/resources/media/square-grid-24.png differ
diff --git a/src/main/resources/tinylog-dev.properties b/src/main/resources/tinylog-dev.properties
index 0766ee23..eb231718 100755
--- a/src/main/resources/tinylog-dev.properties
+++ b/src/main/resources/tinylog-dev.properties
@@ -36,5 +36,7 @@ exception = strip: jdk.internal
level@jcs.util = info
#level@jcs.commandStation = debug
-#level@jcs.ui.layout = info
+level@jcs.ui.layout.tiles = info
+level@jcs.ui.layout.tiles.ui = warn
+
level@jcs.commandStation.esu.ecos.EcosMessage = info
\ No newline at end of file
diff --git a/src/main/resources/tinylog.properties b/src/main/resources/tinylog.properties
index 50d15434..77ce10aa 100755
--- a/src/main/resources/tinylog.properties
+++ b/src/main/resources/tinylog.properties
@@ -36,4 +36,6 @@ exception = strip: jdk.internal
level@jcs.util = info
#level@jcs.commandStation = debug
#level@jcs.ui.layout = info
+level@jcs.ui.layout.tiles = info
+level@jcs.ui.layout.tiles.ui = warn
level@jcs.commandStation.esu.ecos.EcosMessage = info
\ No newline at end of file
diff --git a/src/main/resources/update-jcs-db-002.sql b/src/main/resources/update-jcs-db-002.sql
index d05c1091..ed568411 100644
--- a/src/main/resources/update-jcs-db-002.sql
+++ b/src/main/resources/update-jcs-db-002.sql
@@ -21,15 +21,21 @@ alter table sensors add bus_nr integer not null default 0;
alter table sensors add command_station_id varchar(255) not null;
alter table sensors drop constraint sens_deid_coid_un;
+
drop index sens_deid_coid_un_idx;
alter table sensors add constraint sens_deid_coid_un unique (device_id,contact_id,bus_nr,command_station_id);
-
alter table tiles alter sensor_id integer;
alter table blocks alter plus_sensor_id integer;
alter table blocks alter min_sensor_id integer;
+alter table locomotives drop constraint loco_addr_dety_un;
+drop index loco_addr_dety_un_idx;
+alter table locomotives add speed_1 integer;
+alter table locomotives add speed_2 integer;
+alter table locomotives add speed_3 integer;
+alter table locomotives add speed_4 integer;
update jcs_version set db_version = '0.0.3', app_version = '0.0.3';
commit;
\ No newline at end of file
diff --git a/src/test/java/jcs/commandStation/autopilot/state/StateMachineStepByStepTest.java b/src/test/java/jcs/commandStation/autopilot/state/StateMachineStepByStepTest.java
index abde0114..3f9bf3da 100644
--- a/src/test/java/jcs/commandStation/autopilot/state/StateMachineStepByStepTest.java
+++ b/src/test/java/jcs/commandStation/autopilot/state/StateMachineStepByStepTest.java
@@ -76,9 +76,14 @@ public void setUp() {
route.setLocked(false);
ps.persist(route);
}
- JCS.getJcsCommandStation().switchPower(true);
- AutoPilot.runAutoPilot(true);
- Logger.info("=========================== setUp done..............");
+ if (JCS.getJcsCommandStation().connect()) {
+
+ JCS.getJcsCommandStation().switchPower(true);
+ AutoPilot.runAutoPilot(true);
+ Logger.info("=========================== setUp done..............");
+ } else {
+ Logger.error("###### Can't connect to command station! ########");
+ }
}
@AfterEach
diff --git a/src/test/java/jcs/persistence/util/EntityInfoTest.java b/src/test/java/jcs/persistence/util/EntityInfoTest.java
index 753588db..4b9c2d9b 100644
--- a/src/test/java/jcs/persistence/util/EntityInfoTest.java
+++ b/src/test/java/jcs/persistence/util/EntityInfoTest.java
@@ -134,10 +134,7 @@ public void testGetAllColumnNames() {
Object bean = createBean();
EntityInfo instance = new EntityInfo(bean.getClass());
- String[] cols = new String[]{"dispatcher_direction", "id", "name", "address", "tacho_max", "v_min", "velocity", "locomotive_direction", "commuter", "show", "icon", "imported", "command_station_id", "synchronize", "uid", "decoder_type"};
-
- //expected:<[dispatcher_direction, id, name, address, tacho_max, v_min, velocity, locomotive_direction, commuter, show, icon, imported, command_station_id, synchronize, uid, decoder_type]>
- //but was :<[commandStationBean, functions, functionCount, dispatcher_direction, id, image, name, address, decoder, tacho_max, v_min, velocity, locomotive_direction, commuter, show, icon, imported, command_station_id, synchronize, uid, richtung, decoder_type]>
+ String[] cols = new String[]{"speed_2", "speed_3", "speed_1", "dispatcher_direction", "speed_4", "id", "name", "address", "tacho_max", "v_min", "velocity", "locomotive_direction", "commuter", "show", "icon", "imported", "command_station_id", "synchronize", "uid", "decoder_type"};
List expResult = Arrays.asList(cols);
List result = instance.getAllColumnNames();
@@ -153,7 +150,7 @@ public void testGetAllColumnNamesIgnoreTransientCols() {
Object bean = createBean();
EntityInfo instance = new EntityInfo(bean.getClass(), true);
- String[] cols = new String[]{"commandStationBean", "functions", "active", "functionCount", "dispatcher_direction", "id", "image", "name", "address", "decoder", "tacho_max", "v_min", "velocity", "locomotive_direction", "commuter", "show", "icon", "imported", "command_station_id", "synchronize", "uid", "richtung", "decoder_type"};
+ String[] cols = new String[]{"commandStationBean", "functions", "functionCount", "dispatcher_direction", "id", "active", "speed_2", "speed_3", "speed_1", "speed_4", "image", "name", "address", "decoder", "tacho_max", "v_min", "velocity", "locomotive_direction", "commuter", "show", "icon", "imported", "command_station_id", "synchronize", "uid", "richtung", "decoder_type"};
List expResult = Arrays.asList(cols);