diff --git a/NanoJ-Fluidics.jar b/NanoJ-Fluidics.jar index d85beda..8166efb 100644 Binary files a/NanoJ-Fluidics.jar and b/NanoJ-Fluidics.jar differ diff --git a/NanoJ-Fluidics_IJ.jar b/NanoJ-Fluidics_IJ.jar index 46b0537..5a8517f 100644 Binary files a/NanoJ-Fluidics_IJ.jar and b/NanoJ-Fluidics_IJ.jar differ diff --git a/NanoJ-Fluidics_MM.jar b/NanoJ-Fluidics_MM.jar index 06129cb..147981d 100644 Binary files a/NanoJ-Fluidics_MM.jar and b/NanoJ-Fluidics_MM.jar differ diff --git a/PackagedBinaries/NanoJ-Fluidics.zip b/PackagedBinaries/NanoJ-Fluidics.zip index 8e302b7..c7cfa61 100644 Binary files a/PackagedBinaries/NanoJ-Fluidics.zip and b/PackagedBinaries/NanoJ-Fluidics.zip differ diff --git a/PackagedBinaries/NanoJ-Fluidics_IJ.zip b/PackagedBinaries/NanoJ-Fluidics_IJ.zip index ec17fd4..b9165c8 100644 Binary files a/PackagedBinaries/NanoJ-Fluidics_IJ.zip and b/PackagedBinaries/NanoJ-Fluidics_IJ.zip differ diff --git a/PackagedBinaries/NanoJ-Fluidics_MM.zip b/PackagedBinaries/NanoJ-Fluidics_MM.zip index b6d7d68..81cb75a 100644 Binary files a/PackagedBinaries/NanoJ-Fluidics_MM.zip and b/PackagedBinaries/NanoJ-Fluidics_MM.zip differ diff --git a/src/nanoj/pumpControl/java/pumps/ConnectedSubPumpsList.java b/src/nanoj/pumpControl/java/pumps/ConnectedSubPumpsList.java index 46ecdf8..a53d63d 100644 --- a/src/nanoj/pumpControl/java/pumps/ConnectedSubPumpsList.java +++ b/src/nanoj/pumpControl/java/pumps/ConnectedSubPumpsList.java @@ -36,11 +36,15 @@ public void removePump(String pumpName,String port) { } public void removePump(Pump pump) { + ArrayList found = new ArrayList(); for (ConnectedSubPump subPump: list) - if (subPump.name.equals(pump.name)) - list.remove(subPump); + if (subPump.pump.equals(pump)) + found.add(subPump); - connectedPumps.remove(pump); + for (ConnectedSubPump foundPump : found) + list.remove(foundPump); + + connectedPumps.remove(found.get(0).pump); } public ConnectedSubPump getConnectedSubPump(String name, String subPump, String port) throws PumpNotFoundException { diff --git a/src/nanoj/pumpControl/java/pumps/PumpManager.java b/src/nanoj/pumpControl/java/pumps/PumpManager.java index 967c342..68430ea 100644 --- a/src/nanoj/pumpControl/java/pumps/PumpManager.java +++ b/src/nanoj/pumpControl/java/pumps/PumpManager.java @@ -124,6 +124,24 @@ public synchronized void stopPumping(String pumpName, String subPump, String por notifyObservers(NEW_STATUS_AVAILABLE); } + public synchronized boolean disconnect(String port) throws Exception { + boolean success = false; + Pump pump = null; + for (ConnectedSubPump subPump: connectedSubPumps) + if (subPump.port.equals(port)) { + pump = subPump.pump; + success = subPump.pump.disconnect(); + break; + } + + if (success) + connectedSubPumps.removePump(pump); + + setChanged(); + notifyObservers(PUMP_DISCONNECTED); + return success; + } + public synchronized boolean disconnect(int index) throws Exception { boolean success = connectedSubPumps.getConnectedSubPump(index).pump.disconnect(); String name = connectedSubPumps.getConnectedSubPump(index).name; @@ -147,6 +165,28 @@ public ConnectedSubPumpsList getConnectedPumpsList() { return connectedSubPumps; } + public Pump getPumpOnPort(String port) { + Pump pump = null; + for (ConnectedSubPump subPump: connectedSubPumps) + if (subPump.port.equals(port)) { + pump = subPump.pump; + break; + } + + return pump; + } + + public String getPumpNameOnPort(String port) { + String pump = "Not found"; + for (ConnectedSubPump subPump: connectedSubPumps) + if (subPump.port.equals(port)) { + pump = subPump.name; + break; + } + + return pump; + } + public synchronized boolean isConnected(int pumpIndex) { return connectedSubPumps != null && pumpIndex < connectedSubPumps.size() && diff --git a/src/nanoj/pumpControl/java/sequentialProtocol/tabs/PumpConnections.java b/src/nanoj/pumpControl/java/sequentialProtocol/tabs/PumpConnections.java index 0330d9d..b39c516 100644 --- a/src/nanoj/pumpControl/java/sequentialProtocol/tabs/PumpConnections.java +++ b/src/nanoj/pumpControl/java/sequentialProtocol/tabs/PumpConnections.java @@ -104,16 +104,12 @@ private class Disconnect implements ActionListener { @Override public void actionPerformed(ActionEvent e) { boolean success = false; - if (connectedPumpsTable.getSelectedRow() < 0) { - return; - } - String pump = null; - String port = null; + String port = "Undefined"; + String name = "Undefined"; try { - int selection = connectedPumpsTable.getSelectedRow(); - success = pumpManager.disconnect(selection); - pump = (String) connectedPumpsTableModel.getValueAt(selection,0); - port = (String) connectedPumpsTableModel.getValueAt(selection,2); + port = (String) portsList.getSelectedItem(); + name = pumpManager.getPumpNameOnPort(port); + success = pumpManager.disconnect(port); } catch (Exception e1) { gui.log.message("Error, failed to disconnect properly."); e1.printStackTrace(); @@ -124,7 +120,7 @@ public void actionPerformed(ActionEvent e) { for (ConnectedSubPump subPump: pumpManager.getConnectedPumpsList()) connectedPumpsTableModel.addRow(subPump.asConnectionArray()); - gui.log.message("Disconnected from " + pump + " on port " + port + "."); + gui.log.message("Disconnected from " + name + " on port " + port + "."); } } }