Search in sources :

Example 1 with Analyzer

use of com.cburch.logisim.analyze.gui.Analyzer in project logisim-evolution by reds-heig.

the class ProjectCircuitActions method doAnalyze.

public static void doAnalyze(Project proj, Circuit circuit) {
    Map<Instance, String> pinNames = Analyze.getPinLabels(circuit);
    ArrayList<String> inputNames = new ArrayList<String>();
    ArrayList<String> outputNames = new ArrayList<String>();
    for (Map.Entry<Instance, String> entry : pinNames.entrySet()) {
        Instance pin = entry.getKey();
        boolean isInput = Pin.FACTORY.isInputPin(pin);
        if (isInput) {
            inputNames.add(entry.getValue());
        } else {
            outputNames.add(entry.getValue());
        }
        if (pin.getAttributeValue(StdAttr.WIDTH).getWidth() > 1) {
            if (isInput) {
                analyzeError(proj, Strings.get("analyzeMultibitInputError"));
            } else {
                analyzeError(proj, Strings.get("analyzeMultibitOutputError"));
            }
            return;
        }
    }
    if (inputNames.size() > AnalyzerModel.MAX_INPUTS) {
        analyzeError(proj, StringUtil.format(Strings.get("analyzeTooManyInputsError"), "" + AnalyzerModel.MAX_INPUTS));
        return;
    }
    if (outputNames.size() > AnalyzerModel.MAX_OUTPUTS) {
        analyzeError(proj, StringUtil.format(Strings.get("analyzeTooManyOutputsError"), "" + AnalyzerModel.MAX_OUTPUTS));
        return;
    }
    Analyzer analyzer = AnalyzerManager.getAnalyzer();
    analyzer.getModel().setCurrentCircuit(proj, circuit);
    configureAnalyzer(proj, circuit, analyzer, pinNames, inputNames, outputNames);
    analyzer.setVisible(true);
    analyzer.toFront();
}
Also used : Instance(com.cburch.logisim.instance.Instance) ArrayList(java.util.ArrayList) Analyzer(com.cburch.logisim.analyze.gui.Analyzer) Map(java.util.Map)

Aggregations

Analyzer (com.cburch.logisim.analyze.gui.Analyzer)1 Instance (com.cburch.logisim.instance.Instance)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1