Skip to content

Commit

Permalink
- Add a configuration wizard for ActuatorSignaler.
Browse files Browse the repository at this point in the history
  • Loading branch information
vonnieda committed Jun 28, 2020
1 parent cde2cc6 commit 5280aa8
Show file tree
Hide file tree
Showing 3 changed files with 116 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package org.openpnp.machine.reference.signaler;

import org.openpnp.ConfigurationListener;
import org.openpnp.gui.support.Wizard;
import org.openpnp.machine.reference.signaler.wizards.ActuatorSignalerConfigurationWizard;
import org.openpnp.model.Configuration;
import org.openpnp.spi.Actuator;
import org.openpnp.spi.Machine;
import org.openpnp.spi.base.AbstractJobProcessor;
import org.openpnp.spi.base.AbstractMachine;
import org.openpnp.spi.base.AbstractSignaler;
import org.simpleframework.xml.Attribute;
import org.simpleframework.xml.core.Commit;
import org.simpleframework.xml.core.Persist;

/**
Expand Down Expand Up @@ -81,6 +82,7 @@ public Actuator getActuator() {

public void setActuator(Actuator actuator) {
this.actuator = actuator;
firePropertyChange("actuator", null, actuator);
}

public AbstractJobProcessor.State getJobState() {
Expand All @@ -89,6 +91,7 @@ public AbstractJobProcessor.State getJobState() {

public void setJobState(AbstractJobProcessor.State jobState) {
this.jobState = jobState;
firePropertyChange("jobState", null, jobState);
}

public AbstractMachine.State getMachineState() {
Expand All @@ -97,5 +100,11 @@ public AbstractMachine.State getMachineState() {

public void setMachineState(AbstractMachine.State machineState) {
this.machineState = machineState;
firePropertyChange("machineState", null, machineState);
}

@Override
public Wizard getConfigurationWizard() {
return new ActuatorSignalerConfigurationWizard(this);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/*
* Copyright (C) 2011 Jason von Nieda <jason@vonnieda.org>
*
* This file is part of OpenPnP.
*
* OpenPnP is free software: you can redistribute it and/or modify it under the terms of the GNU
* General Public License as published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* OpenPnP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*
* You should have received a copy of the GNU General Public License along with OpenPnP. If not, see
* <http://www.gnu.org/licenses/>.
*
* For more information about OpenPnP visit http://openpnp.org
*/

package org.openpnp.machine.reference.signaler.wizards;

import javax.swing.JComboBox;
import javax.swing.JLabel;

import org.openpnp.gui.support.AbstractConfigurationWizard;
import org.openpnp.machine.reference.signaler.ActuatorSignaler;
import org.openpnp.model.Configuration;
import org.openpnp.spi.Actuator;
import org.openpnp.spi.base.AbstractJobProcessor;
import org.openpnp.spi.base.AbstractMachine;

import com.jgoodies.forms.layout.ColumnSpec;
import com.jgoodies.forms.layout.FormLayout;
import com.jgoodies.forms.layout.FormSpecs;
import com.jgoodies.forms.layout.RowSpec;

@SuppressWarnings("serial")
public class ActuatorSignalerConfigurationWizard extends AbstractConfigurationWizard {
private final ActuatorSignaler signaler;
private JLabel lblNewLabel;
private JLabel lblNewLabel_1;
private JLabel lblNewLabel_2;
private JComboBox actuator;
private JComboBox jobState;
private JComboBox machineState;

public ActuatorSignalerConfigurationWizard(ActuatorSignaler actuator) {
this.signaler = actuator;
createUi();
}
private void createUi() {
contentPanel.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,
FormSpecs.RELATED_GAP_ROWSPEC,
FormSpecs.DEFAULT_ROWSPEC,
FormSpecs.RELATED_GAP_ROWSPEC,
FormSpecs.DEFAULT_ROWSPEC,}));

lblNewLabel = new JLabel("Actuator");
contentPanel.add(lblNewLabel, "2, 2, right, default");

actuator = new JComboBox();
contentPanel.add(actuator, "4, 2, fill, default");

lblNewLabel_1 = new JLabel("Job State");
contentPanel.add(lblNewLabel_1, "2, 4, right, default");

jobState = new JComboBox();
contentPanel.add(jobState, "4, 4, fill, default");

lblNewLabel_2 = new JLabel("Machine State");
contentPanel.add(lblNewLabel_2, "2, 6, right, default");

machineState = new JComboBox();
contentPanel.add(machineState, "4, 6, fill, default");

for (Actuator actuator : Configuration.get().getMachine().getActuators()) {
this.actuator.addItem(actuator);
}

jobState.addItem(null);
for (AbstractJobProcessor.State state : AbstractJobProcessor.State.values()) {
this.jobState.addItem(state);
}

machineState.addItem(null);
for (AbstractMachine.State state : AbstractMachine.State.values()) {
this.machineState.addItem(state);
}
}

@Override
public void createBindings() {
addWrappedBinding(signaler, "actuator", actuator, "selectedItem");
addWrappedBinding(signaler, "jobState", jobState, "selectedItem");
addWrappedBinding(signaler, "machineState", machineState, "selectedItem");
}
}
6 changes: 2 additions & 4 deletions src/main/java/org/openpnp/spi/base/AbstractSignaler.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.openpnp.spi.base;

import java.awt.event.ActionEvent;
import java.util.ArrayList;

import javax.swing.AbstractAction;
import javax.swing.Action;
Expand All @@ -12,15 +11,14 @@
import org.openpnp.gui.support.Icons;
import org.openpnp.gui.support.PropertySheetWizardAdapter;
import org.openpnp.gui.support.Wizard;
import org.openpnp.machine.reference.psh.NozzleTipsPropertySheetHolder;
import org.openpnp.model.AbstractModelObject;
import org.openpnp.model.Configuration;
import org.openpnp.spi.PropertySheetHolder;
import org.openpnp.spi.Signaler;
import org.openpnp.spi.WizardConfigurable;
import org.openpnp.spi.PropertySheetHolder.PropertySheet;
import org.simpleframework.xml.Attribute;

public abstract class AbstractSignaler implements Signaler, WizardConfigurable {
public abstract class AbstractSignaler extends AbstractModelObject implements Signaler, WizardConfigurable {

@Attribute
protected String id;
Expand Down

0 comments on commit 5280aa8

Please sign in to comment.