Skip to content

Commit

Permalink
Fixing logic of previous commit that assumed peristaltic pumps would …
Browse files Browse the repository at this point in the history
…only be used for withdrawal.
  • Loading branch information
palmada committed Oct 10, 2018
1 parent 3033b66 commit a75d5b5
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 32 deletions.
Binary file modified NanoJ-Fluidics.jar
Binary file not shown.
Binary file modified NanoJ-Fluidics_IJ.jar
Binary file not shown.
Binary file modified NanoJ-Fluidics_MM.jar
Binary file not shown.
Binary file modified PackagedBinaries/NanoJ-Fluidics.zip
Binary file not shown.
Binary file modified PackagedBinaries/NanoJ-Fluidics_IJ.zip
Binary file not shown.
Binary file modified PackagedBinaries/NanoJ-Fluidics_MM.zip
Binary file not shown.
53 changes: 21 additions & 32 deletions src/nanoj/pumpControl/java/sequentialProtocol/Step.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public String toString() {
private FlowRateSlider rateSlider;
private JTextField volume;
private JComboBox volumeUnitsList;
private JLabel peristalticLabel = new JLabel("secs.");
private JComboBox action = new JComboBox(Pump.Action.values());
private int number;

Expand Down Expand Up @@ -110,7 +111,6 @@ public Step(int num) {
this.time = new JTextField(Integer.toString(time), 2);
Listener listener = new Listener();
this.time.addActionListener(listener);
this.time.addFocusListener(listener);
step.add(this.time);

timeUnitsList = new JComboBox(TimeUnit.values());
Expand Down Expand Up @@ -146,6 +146,7 @@ public Step(int num) {
volumeUnitsList = new JComboBox(VolumeUnit.values());
volumeUnitsList.setSelectedIndex(volumeUnit.ordinal());
step.add(volumeUnitsList);
step.add(peristalticLabel);

this.action.setSelectedItem(action);
step.add(this.action);
Expand Down Expand Up @@ -280,19 +281,22 @@ public void actionPerformed(ActionEvent e) {
}
}

class Listener implements ActionListener, FocusListener {
class Listener implements ActionListener {

void updateSyringeInformation() {
Syringe syringe = Syringe.values()[syringeList.getSelectedIndex()];

if (syringe.equals(Syringe.PERISTALTIC)) {
volume.setText(time.getText());
volumeUnitsList.setSelectedIndex(VolumeUnit.UL.ordinal());

volumeUnitsList.setEnabled(false);
volume.setEnabled(false);
volumeUnitsList.setVisible(false);
peristalticLabel.setVisible(true);

} else {
volumeUnitsList.setEnabled(true);
volume.setEnabled(true);
volumeUnitsList.setVisible(true);
peristalticLabel.setVisible(true);
}

if (pumpManager.anyPumpsConnected()) {
Expand All @@ -301,24 +305,6 @@ void updateSyringeInformation() {
}
}

public void updateTime() {
float duration;

try {
duration = Float.parseFloat(time.getText());
} catch (Exception e1) {
duration = 1;
}

if (duration < 0 ) {
time.setText("0");
}
else time.setText("" + Math.round(duration));

if (Syringe.values()[syringeList.getSelectedIndex()].equals(Syringe.PERISTALTIC))
volume.setText(time.getText());
}


@Override
public void actionPerformed(ActionEvent e) {
Expand All @@ -327,17 +313,20 @@ public void actionPerformed(ActionEvent e) {
}

if (e.getSource().equals(time)) {
updateTime();
float duration;

try {
duration = Float.parseFloat(time.getText());
} catch (Exception e1) {
duration = 1;
}

if (duration < 0 ) {
time.setText("0");
}
else time.setText("" + Math.round(duration));
}
}

@Override
public void focusGained(FocusEvent e) { }

@Override
public void focusLost(FocusEvent e) {
updateTime();
}
}

// Methods
Expand Down

0 comments on commit a75d5b5

Please sign in to comment.