/*
* 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.feeder;
import javax.swing.Action;
import org.openpnp.gui.support.PropertySheetWizardAdapter;
import org.openpnp.gui.support.Wizard;
import org.openpnp.machine.reference.ReferenceFeeder;
import org.openpnp.machine.reference.feeder.wizards.ReferenceAutoFeederConfigurationWizard;
import org.openpnp.model.Configuration;
import org.openpnp.model.Location;
import org.openpnp.spi.Actuator;
import org.openpnp.spi.Nozzle;
import org.openpnp.spi.PropertySheetHolder;
import org.pmw.tinylog.Logger;
import org.simpleframework.xml.Attribute;
/**
* Not yet finished feeder that will be used for automated feeding. Just getting the idea down
* on paper, as it were. It will have an actuator attached and you will be able to choose
* to either toggle the feeder with a delay or send a double.
*/
public class ReferenceAutoFeeder extends ReferenceFeeder {
@Attribute(required=false)
protected String actuatorName;
@Attribute(required=false)
protected double actuatorValue;
@Override
public Location getPickLocation() throws Exception {
return location;
}
@Override
public void feed(Nozzle nozzle) throws Exception {
if (actuatorName == null) {
Logger.warn("No actuatorName specified for feeder.");
return;
}
Actuator actuator = nozzle.getHead().getActuatorByName(actuatorName);
if (actuator == null) {
actuator = Configuration.get().getMachine().getActuatorByName(actuatorName);
}
if (actuator == null) {
throw new Exception(getName() + " feed failed. Unable to find an actuator named " + actuatorName);
}
actuator.actuate(actuatorValue);
}
public String getActuatorName() {
return actuatorName;
}
public void setActuatorName(String actuatorName) {
this.actuatorName = actuatorName;
}
public double getActuatorValue() {
return actuatorValue;
}
public void setActuatorValue(double actuatorValue) {
this.actuatorValue = actuatorValue;
}
@Override
public Wizard getConfigurationWizard() {
return new ReferenceAutoFeederConfigurationWizard(this);
}
@Override
public String getPropertySheetHolderTitle() {
return getClass().getSimpleName() + " " + getName();
}
@Override
public PropertySheetHolder[] getChildPropertySheetHolders() {
// TODO Auto-generated method stub
return null;
}
@Override
public Action[] getPropertySheetHolderActions() {
// TODO Auto-generated method stub
return null;
}
}