used slf4j for logging

This commit is contained in:
hneemann 2017-03-12 21:20:24 +01:00
parent ff1cb6ab9a
commit bb03f7cdbd
5 changed files with 35 additions and 12 deletions

13
pom.xml
View File

@ -14,6 +14,7 @@
<maven.build.timestamp.format>yyyy-MM-dd HH:mm</maven.build.timestamp.format>
<build.timestamp>${maven.build.timestamp}</build.timestamp>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<version.org.slf4j>1.7.24</version.org.slf4j>
</properties>
<distributionManagement>
@ -210,6 +211,18 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${version.org.slf4j}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>${version.org.slf4j}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/xalan/xalan -->
<dependency>
<groupId>xalan</groupId>

View File

@ -12,6 +12,8 @@ import de.neemann.digital.core.flipflops.FlipflopJK;
import de.neemann.digital.core.flipflops.FlipflopT;
import de.neemann.digital.core.wiring.Clock;
import de.neemann.digital.lang.Lang;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
@ -23,6 +25,7 @@ import java.util.List;
* @author hneemann
*/
public class ModelAnalyser {
private static final Logger LOGGER = LoggerFactory.getLogger(ModelAnalyser.class);
private static final int MAX_INPUTS_ALLOWED = 24;
private final Model model;
@ -109,7 +112,7 @@ public class ModelAnalyser {
* @throws NodeException NodeException
*/
public TruthTable analyse() throws NodeException {
System.out.print("start to analyse the model");
LOGGER.debug("start to analyse the model...");
long time = System.currentTimeMillis();
BitSetter bitsetter = new BitSetter(inputs.size()) {
@Override
@ -138,7 +141,7 @@ public class ModelAnalyser {
}
}
time = System.currentTimeMillis() - time;
System.out.println(": " + time / 1000.0 + " sec");
LOGGER.debug("model analysis: " + time / 1000.0 + " sec");
return tt;
}

View File

@ -5,6 +5,8 @@ import de.neemann.digital.analyse.expression.*;
import de.neemann.digital.analyse.quinemc.primeselector.PrimeSelector;
import de.neemann.digital.analyse.quinemc.primeselector.PrimeSelectorDefault;
import de.neemann.digital.lang.Lang;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.*;
@ -16,6 +18,7 @@ import static de.neemann.digital.analyse.expression.Operation.or;
* @author hneemann
*/
public class QuineMcCluskey {
private static final Logger LOGGER = LoggerFactory.getLogger(QuineMcCluskey.class);
private final TableRows rows;
private final List<Variable> variables;
@ -119,7 +122,7 @@ public class QuineMcCluskey {
public QuineMcCluskey simplify(PrimeSelector ps) {
QuineMcCluskey t = this;
while (!t.isFinished()) {
System.out.println("QMC " + t.rows.size());
LOGGER.debug("QMC rows " + t.rows.size());
t = t.simplifyStep();
}
return t.simplifyPrimes(ps);
@ -231,7 +234,7 @@ public class QuineMcCluskey {
for (TableRow r : primes)
columns.addAll(r.getSource());
System.out.println("initial primes "+primes.size());
LOGGER.debug("initial primes " + primes.size());
// remove all primes which are easy to remove
while (true) {
@ -263,7 +266,7 @@ public class QuineMcCluskey {
columns.removeAll(colsToDelete);
}
System.out.println("residual primes "+primes.size());
LOGGER.debug("residual primes " + primes.size());
// try to reduce the number of primes needed
if (primeSelector != null && !columns.isEmpty()) {
@ -271,7 +274,7 @@ public class QuineMcCluskey {
availPrimes.addAll(primes);
primes.clear();
primeSelector.select(primes, availPrimes, columns);
System.out.println("final primes "+primes.size());
LOGGER.debug("final primes " + primes.size());
}
return this;

View File

@ -15,6 +15,8 @@ import de.neemann.digital.lang.Lang;
import de.neemann.gui.ErrorMessage;
import de.neemann.gui.StringUtils;
import de.neemann.gui.ToolTipAction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.swing.*;
import javax.swing.filechooser.FileNameExtensionFilter;
@ -31,6 +33,8 @@ import java.util.HashMap;
* @author hneemann
*/
public class LibrarySelector implements ElementNotFoundNotification {
private static final Logger LOGGER = LoggerFactory.getLogger(LibrarySelector.class);
private final ElementLibrary library;
private final ShapeFactory shapeFactory;
private final State elementState;
@ -227,7 +231,7 @@ public class LibrarySelector implements ElementNotFoundNotification {
private Imported importElement(File file) throws IOException {
try {
System.out.println("load element " + file);
LOGGER.debug("load element " + file);
Circuit circuit = Circuit.loadCircuit(file, shapeFactory);
ElementTypeDescriptionCustom description =
new ElementTypeDescriptionCustom(file,

View File

@ -13,6 +13,8 @@ import de.neemann.digital.analyse.quinemc.TableRow;
import de.neemann.digital.analyse.quinemc.primeselector.PrimeSelector;
import de.neemann.digital.analyse.quinemc.primeselector.PrimeSelectorDefault;
import de.neemann.digital.lang.Lang;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.Collections;
@ -27,7 +29,7 @@ import java.util.concurrent.TimeUnit;
* @author hneemann
*/
public class ExpressionCreator {
private static final Logger LOGGER = LoggerFactory.getLogger(ExpressionCreator.class);
private static final int MAX_INPUTS_ALLOWED = 12;
private final TruthTable theTable;
@ -58,9 +60,7 @@ public class ExpressionCreator {
final int t = table;
ex.submit(() -> {
try {
System.out.println("start " + t);
simplify(listener, vars, theTable.getResultName(t), theTable.getResult(t));
System.out.println("end " + t);
} catch (ExpressionException | FormatterException | AnalyseException e) {
e.printStackTrace();
}
@ -79,14 +79,14 @@ public class ExpressionCreator {
listener.close();
}
time = System.currentTimeMillis() - time;
System.out.println("time: " + time / 1000.0 + " sec");
LOGGER.debug("time: " + time / 1000.0 + " sec");
}
private void simplify(ExpressionListener listener, List<Variable> vars, String resultName, BoolTable boolTable) throws AnalyseException, ExpressionException, FormatterException {
TableReducer tr = new TableReducer(vars, boolTable);
List<Variable> localVars = vars;
if (tr.canReduce()) {
System.out.println(resultName + " reduced from " + vars.size() + " to " + tr.getVars().size() + " variables");
LOGGER.debug(resultName + " reduced from " + vars.size() + " to " + tr.getVars().size() + " variables");
boolTable = tr.getTable();
localVars = tr.getVars();
}