package org.openpnp.spi.base;
import javax.swing.Icon;
import org.openpnp.ConfigurationListener;
import org.openpnp.gui.support.Icons;
import org.openpnp.gui.support.PropertySheetWizardAdapter;
import org.openpnp.model.AbstractModelObject;
import org.openpnp.model.Configuration;
import org.openpnp.model.Part;
import org.openpnp.spi.Feeder;
import org.openpnp.spi.Nozzle;
import org.simpleframework.xml.Attribute;
public abstract class AbstractFeeder extends AbstractModelObject implements Feeder {
@Attribute
protected String id;
@Attribute(required = false)
protected String name;
@Attribute
protected boolean enabled;
@Attribute
protected String partId;
@Attribute(required=false)
protected int retryCount = 3;
protected Part part;
public AbstractFeeder() {
this.id = Configuration.createId("FDR");
this.name = getClass().getSimpleName();
Configuration.get().addListener(new ConfigurationListener.Adapter() {
@Override
public void configurationLoaded(Configuration configuration) throws Exception {
part = configuration.getPart(partId);
}
});
}
@Override
public String getId() {
return id;
}
@Override
public boolean isEnabled() {
return enabled;
}
@Override
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
@Override
public void setPart(Part part) {
this.part = part;
this.partId = part.getId();
}
@Override
public Part getPart() {
return part;
}
@Override
public String getName() {
return name;
}
@Override
public void setName(String name) {
this.name = name;
}
@Override
public Icon getPropertySheetHolderIcon() {
return Icons.editFeeder;
}
public int getRetryCount() {
return retryCount;
}
public void setRetryCount(int retryCount) {
this.retryCount = retryCount;
}
@Override
public PropertySheet[] getPropertySheets() {
return new PropertySheet[] {new PropertySheetWizardAdapter(getConfigurationWizard(), "Configuration")};
}
public void postPick(Nozzle nozzle) throws Exception { }
}