Skip to content

Commit

Permalink
Work in progress, backup commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
markmaker committed May 3, 2020
1 parent 53e7875 commit ce3f543
Show file tree
Hide file tree
Showing 25 changed files with 400 additions and 75 deletions.
8 changes: 4 additions & 4 deletions src/main/java/org/openpnp/gui/support/AxesComboBoxModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ public int compare(Axis o1, Axis o2) {
};
final private AbstractMachine machine;
final private boolean addEmpty;
final private boolean controllerOnly;
final private Class<? extends Axis> types;

public AxesComboBoxModel(AbstractMachine machine, boolean controllerOnly, boolean addEmpty) {
public AxesComboBoxModel(AbstractMachine machine, Class<? extends Axis> types, boolean addEmpty) {
this.machine = machine;
this.addEmpty = addEmpty;
this.controllerOnly = controllerOnly;
this.types = types;
addAllElements();
if (machine != null) { // we're not in Window Builder Design Mode
this.machine.addPropertyChangeListener("axes", this);
Expand All @@ -63,7 +63,7 @@ private void addAllElements() {
axes = new ArrayList<>(machine.getAxes());
Collections.sort(axes, comparator);
for (Axis axis : axes) {
if (!controllerOnly || axis instanceof AbstractControllerAxis) {
if (types.isInstance(axis)) {
addElement(axis.getName());
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/openpnp/gui/support/Icons.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ public class Icons {
public static Icon processActivity1Icon = getIcon("/icons/process-activity-1.svg");
public static Icon processActivity2Icon = getIcon("/icons/process-activity-2.svg");

public static Icon axisAll = getIcon("/icons/axis-all.svg");
public static Icon axisCartesian = getIcon("/icons/axis-cartesian.svg");
public static Icon axisRotation = getIcon("/icons/axis-rotate.svg");
public static Icon driver = getIcon("/icons/driver.svg");

public static Icon getIcon(String resourceName, int width, int height) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.openpnp.spi.Axis;
import org.openpnp.spi.base.AbstractControllerAxis;
import org.openpnp.spi.base.AbstractMachine;
import org.openpnp.spi.base.AbstractTransformedAxis;

import com.jgoodies.forms.layout.ColumnSpec;
import com.jgoodies.forms.layout.FormLayout;
Expand Down Expand Up @@ -78,25 +79,26 @@ public AbstractTransformedAxisConfigurationWizard(AbstractMachine machine) {
lblInputAxisX = new JLabel("Input X");
panelTransformation.add(lblInputAxisX, "2, 2, right, default");

inputAxisX = new JComboBox(new AxesComboBoxModel(machine, true, true));
AbstractTransformedAxis axis = (AbstractTransformedAxis) getAxis();
inputAxisX = new JComboBox(new AxesComboBoxModel(machine, axis.getInputAxesClass(), true));
panelTransformation.add(inputAxisX, "4, 2, fill, default");

lblInputAxisY = new JLabel("Input Y");
panelTransformation.add(lblInputAxisY, "2, 4, right, default");

inputAxisY = new JComboBox(new AxesComboBoxModel(machine, true, true));
inputAxisY = new JComboBox(new AxesComboBoxModel(machine, axis.getInputAxesClass(), true));
panelTransformation.add(inputAxisY, "4, 4, fill, default");

lblInputAxisZ = new JLabel("Input Z");
panelTransformation.add(lblInputAxisZ, "2, 6, right, default");

inputAxisZ = new JComboBox(new AxesComboBoxModel(machine, true, true));
inputAxisZ = new JComboBox(new AxesComboBoxModel(machine, axis.getInputAxesClass(), true));
panelTransformation.add(inputAxisZ, "4, 6, fill, default");

lblInputAxisRotation = new JLabel("Input Rotation");
panelTransformation.add(lblInputAxisRotation, "2, 8, right, default");

inputAxisRotation = new JComboBox(new AxesComboBoxModel(machine, true, true));
inputAxisRotation = new JComboBox(new AxesComboBoxModel(machine, axis.getInputAxesClass(), true));
panelTransformation.add(inputAxisRotation, "4, 8, fill, default");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,7 @@ public synchronized void disconnect() {
@Override
public PropertySheet[] getPropertySheets() {
return new PropertySheet[] {
new PropertySheetWizardAdapter(super.getConfigurationWizard(), "Communications"),
new PropertySheetWizardAdapter(super.getConfigurationWizard()),
new PropertySheetWizardAdapter(new Neoden4DriverConfigurationWizard(this), "Machine")
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.openpnp.model.LengthUnit;
import org.openpnp.model.Location;
import org.openpnp.spi.Camera;
import org.openpnp.spi.Driver;
import org.openpnp.spi.PropertySheetHolder;
import org.openpnp.spi.base.AbstractActuator;
import org.pmw.tinylog.Logger;
Expand All @@ -43,7 +44,7 @@

public class ReferenceActuator extends AbstractActuator implements ReferenceHeadMountable {


@Element
private Location headOffsets = new Location(LengthUnit.Millimeters);

Expand Down Expand Up @@ -195,11 +196,12 @@ public Length getSafeZ() {
public void setSafeZ(Length safeZ) {
this.safeZ = safeZ;
}

ReferenceDriver getDriver() {
return getMachine().getDriver();

@Override
public ReferenceDriver getDriver() {
return (ReferenceDriver)super.getDriver();
}

ReferenceMachine getMachine() {
return (ReferenceMachine) Configuration.get().getMachine();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package org.openpnp.machine.reference;

import javax.swing.Icon;

import org.openpnp.gui.support.Wizard;
import org.openpnp.machine.reference.wizards.ReferenceControllerAxisConfigurationWizard;
import org.openpnp.spi.base.AbstractControllerAxis;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public void configurationLoaded(Configuration configuration)
addDriver(driver);
if (driver instanceof GcodeDriver) {
GcodeDriver gcodeDriver= (GcodeDriver)driver;
drivers.addAll(gcodeDriver.getSubDrivers());
gcodeDriver.migrateSubDrivers(ReferenceMachine.this);
}
driver = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import org.openpnp.gui.support.Wizard;
import org.openpnp.machine.reference.wizards.ReferenceNegatedAxisConfigurationWizard;
import org.openpnp.model.Location;
import org.openpnp.spi.Axis;
import org.openpnp.spi.base.AbstractControllerAxis;
import org.openpnp.spi.base.AbstractTransformedAxis;

/**
Expand Down Expand Up @@ -42,4 +44,9 @@ public Location transformFromRaw(Location location) {
// it's reversible
return transformToRaw(location);
}

@Override
public Class<? extends Axis> getInputAxesClass() {
return AbstractControllerAxis.class;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,6 @@ private Command() {
@Commit
public void commit() {
super.commit();
for (GcodeDriver driver : subDrivers) {
driver.parent = this;
}
}

public void createDefaults() {
Expand Down Expand Up @@ -1122,10 +1119,10 @@ static protected boolean hasVariable(String command, String name) {
@Override
public PropertySheet[] getPropertySheets() {
return new PropertySheet[] {
new PropertySheetWizardAdapter(super.getConfigurationWizard()),
new PropertySheetWizardAdapter(new GcodeDriverSettings(this), "Driver Settings"),
new PropertySheetWizardAdapter(new GcodeDriverGcodes(this), "Gcode"),
new PropertySheetWizardAdapter(new GcodeDriverConsole(this), "Console"),
new PropertySheetWizardAdapter(super.getConfigurationWizard(), "Communications")
};
}

Expand Down Expand Up @@ -1289,8 +1286,12 @@ public void setBackslashEscapedCharactersEnabled(boolean backslashEscapedCharact
}

@Deprecated
public List<GcodeDriver> getSubDrivers() {
return subDrivers;
public void migrateSubDrivers(ReferenceMachine machine) throws Exception {
for (GcodeDriver gcodeDriver : subDrivers) {
machine.addDriver(gcodeDriver);
}
// TODO: set it null after the last use of it was reworked.
subDrivers = new ArrayList<>();
}

public static class Axis {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener;

import org.openpnp.gui.components.ComponentDecorators;
import org.openpnp.gui.support.AbstractConfigurationWizard;
import org.openpnp.gui.support.IntegerConverter;
import org.openpnp.machine.reference.driver.AbstractReferenceDriver;
Expand Down Expand Up @@ -37,11 +38,33 @@ public class AbstractReferenceDriverConfigurationWizard extends AbstractConfigur
private JPanel panelTcp;
private JTextField commsMethod;
private JCheckBox connectionKeepAlive;
private JPanel panelController;
private JLabel lblName;
private JTextField driverName;

public AbstractReferenceDriverConfigurationWizard(AbstractReferenceDriver driver) {
this.driver = driver;

contentPanel.setLayout(new BoxLayout(contentPanel, BoxLayout.Y_AXIS));

panelController = new JPanel();
panelController.setBorder(new TitledBorder(null, "Properties", TitledBorder.LEADING, TitledBorder.TOP, null, null));
contentPanel.add(panelController);
panelController.setLayout(new FormLayout(new ColumnSpec[] {
FormSpecs.RELATED_GAP_COLSPEC,
FormSpecs.DEFAULT_COLSPEC,
FormSpecs.RELATED_GAP_COLSPEC,
FormSpecs.DEFAULT_COLSPEC,},
new RowSpec[] {
FormSpecs.RELATED_GAP_ROWSPEC,
FormSpecs.DEFAULT_ROWSPEC,}));

lblName = new JLabel("Name");
panelController.add(lblName, "2, 2, right, default");

driverName = new JTextField();
panelController.add(driverName, "4, 2, fill, default");
driverName.setColumns(10);

//Selector code
JPanel panelComms = new JPanel();
Expand Down Expand Up @@ -277,6 +300,8 @@ private void refreshPortList() {
public void createBindings() {
IntegerConverter integerConverter = new IntegerConverter();

addWrappedBinding(driver, "name", driverName, "text");

addWrappedBinding(driver, "communicationsType", commsMethod, "text");
addWrappedBinding(driver, "connectionKeepAlive", connectionKeepAlive, "selected");

Expand All @@ -291,5 +316,7 @@ public void createBindings() {

addWrappedBinding(driver, "ipAddress", ipAddressTextField, "text");
addWrappedBinding(driver, "port", portTextField, "text", integerConverter);

ComponentDecorators.decorateWithAutoSelect(driverName);
}
}

0 comments on commit ce3f543

Please sign in to comment.