the description field can be used to define pin assignments

This commit is contained in:
hneemann 2016-06-02 22:20:44 +02:00
parent 61930b5b73
commit 7c76aa8b0e
4 changed files with 27 additions and 1 deletions

View File

@ -72,6 +72,9 @@ public class PinMap {
* @throws PinMapException PinMapException
*/
public PinMap parseString(String assignment) throws PinMapException {
if (assignment == null)
return this;
StringTokenizer st = new StringTokenizer(assignment, ";,");
while (st.hasMoreTokens()) {
String tok = st.nextToken();

View File

@ -510,4 +510,11 @@ public class Circuit {
this.measurementOrdering = measurementOrdering;
}
/**
* @return the description
*/
public String getDescription() {
return getAttributes().get(Keys.DESCRIPTION);
}
}

View File

@ -486,7 +486,9 @@ public class Main extends JFrame implements ClosingWindowListener.ConfirmSave, E
public void actionPerformed(ActionEvent e) {
try {
Model model = new ModelDescription(circuitComponent.getCircuit(), library).createModel(false);
new TableDialog(Main.this, new ModelAnalyser(model).analyse(), shapeFactory, filename).setVisible(true);
new TableDialog(Main.this, new ModelAnalyser(model).analyse(), shapeFactory, filename)
.setPinDescription(circuitComponent.getCircuit().getDescription())
.setVisible(true);
elementState.activate();
} catch (PinException | NodeException | AnalyseException e1) {
showErrorAndStopModel(Lang.get("msg_annalyseErr"), e1);

View File

@ -65,6 +65,7 @@ public class TableDialog extends JDialog {
private TableColumn column;
private int columnIndex;
private AllSolutionsDialog allSolutionsDialog;
private String pinDescription;
/**
* Creates a new instance
@ -287,6 +288,7 @@ public class TableDialog extends JDialog {
if (fileChooser.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) {
try {
try (OutputStream out = new FileOutputStream(fileChooser.getSelectedFile())) {
expressionExporter.getPinMapping().parseString(pinDescription);
new BuiderExpressionCreator(expressionExporter.getBuilder(), ExpressionModifier.IDENTITY).create();
expressionExporter.writeTo(out);
}
@ -328,6 +330,7 @@ public class TableDialog extends JDialog {
f = new File(f.getParentFile(), name);
Gal16v8CuplExporter cupl = new Gal16v8CuplExporter(name.substring(0, name.length() - 4));
cupl.getPinMapping().parseString(pinDescription);
new BuiderExpressionCreator(cupl.getBuilder(), ExpressionModifier.IDENTITY).create();
try (FileOutputStream out = new FileOutputStream(f)) {
cupl.writeTo(out);
@ -362,6 +365,17 @@ public class TableDialog extends JDialog {
calculateExpressions();
}
/**
* Sets a pin description
*
* @param pinDescription the pin description
* @return this for chained calls
*/
public TableDialog setPinDescription(String pinDescription) {
this.pinDescription = pinDescription;
return this;
}
private class CalculationTableModelListener implements TableModelListener {
@Override
public void tableChanged(TableModelEvent tableModelEvent) {