cleans interfaces up

This commit is contained in:
Eyck Jentzsch 2023-02-27 13:07:10 +01:00
parent bba4349e1e
commit 299f76323f
16 changed files with 73 additions and 45 deletions

View File

@ -142,6 +142,11 @@ abstract class AbstractTxStream extends HierNode implements IWaveform {
return rowCount; return rowCount;
} }
@Override
public int getWidth() {
return 0;
}
/** /**
* Calculate concurrency. * Calculate concurrency.
*/ */

View File

@ -184,7 +184,7 @@ public class FtrDbLoader implements IWaveformDbLoader {
* @throws InputFormatException the input format exception * @throws InputFormatException the input format exception
*/ */
@Override @Override
public void load(IWaveformDb db, File file) throws InputFormatException { public void load(File file) throws InputFormatException {
dispose(); dispose();
this.file=file; this.file=file;
try { try {

View File

@ -71,6 +71,11 @@ abstract class AbstractTxStream extends HierNode implements IWaveform {
return maxConcurrency; return maxConcurrency;
} }
@Override
public int getWidth() {
return 0;
}
@Override @Override
public IEventList getEvents(){ public IEventList getEvents(){
if(events==null){ if(events==null){

View File

@ -21,7 +21,6 @@ import java.util.Collection;
import java.util.List; import java.util.List;
import com.minres.scviewer.database.IWaveform; import com.minres.scviewer.database.IWaveform;
import com.minres.scviewer.database.IWaveformDb;
import com.minres.scviewer.database.IWaveformDbLoader; import com.minres.scviewer.database.IWaveformDbLoader;
import com.minres.scviewer.database.InputFormatException; import com.minres.scviewer.database.InputFormatException;
import com.minres.scviewer.database.RelationType; import com.minres.scviewer.database.RelationType;
@ -94,8 +93,8 @@ public class SQLiteDbLoader implements IWaveformDbLoader {
// } // }
@Override @Override
public void load(IWaveformDb db, File file) throws InputFormatException { public void load(File file) throws InputFormatException {
database=new SQLiteDatabase(file.getAbsolutePath(), db); database=new SQLiteDatabase(file.getAbsolutePath());
database.setData("TIMERESOLUTION", 1L); database.setData("TIMERESOLUTION", 1L);
SQLiteDatabaseSelectHandler<ScvSimProps> handler = new SQLiteDatabaseSelectHandler<>(ScvSimProps.class, database); SQLiteDatabaseSelectHandler<ScvSimProps> handler = new SQLiteDatabaseSelectHandler<>(ScvSimProps.class, database);
try { try {

View File

@ -26,8 +26,6 @@ public class SQLiteDatabase implements IDatabase {
protected String dbFileName; protected String dbFileName;
protected IWaveformDb waveformDb;
protected HashMap<String, Object> props; protected HashMap<String, Object> props;
static { static {
@ -43,10 +41,9 @@ public class SQLiteDatabase implements IDatabase {
} }
} }
public SQLiteDatabase(String dbFileName, IWaveformDb waveformDb) { public SQLiteDatabase(String dbFileName) {
super(); super();
this.dbFileName = dbFileName; this.dbFileName = dbFileName;
this.waveformDb = waveformDb;
props = new HashMap<String, Object>(); props = new HashMap<String, Object>();
} }
@ -96,7 +93,7 @@ public class SQLiteDatabase implements IDatabase {
@Override @Override
public IWaveformDb getWaveformDb() { public IWaveformDb getWaveformDb() {
return waveformDb; return null;
} }
} }

View File

@ -143,6 +143,10 @@ abstract class AbstractTxStream extends HierNode implements IWaveform {
return rowCount; return rowCount;
} }
@Override
public int getWidth() {
return 0;
}
/** /**
* Calculate concurrency. * Calculate concurrency.
*/ */

View File

@ -222,7 +222,7 @@ public class TextDbLoader implements IWaveformDbLoader {
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public void load(IWaveformDb db, File file) throws InputFormatException { public void load(File file) throws InputFormatException {
dispose(); dispose();
FileType fType = getFileType(file); FileType fType = getFileType(file);
if (file.length() < MEMMAP_LIMIT * (fType!=FileType.PLAIN ? 1 : 10) if (file.length() < MEMMAP_LIMIT * (fType!=FileType.PLAIN ? 1 : 10)

View File

@ -71,7 +71,7 @@ public class VCDDbLoader implements IWaveformDbLoader, IVCDDatabaseBuilder {
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public void load(IWaveformDb db, File file) throws InputFormatException { public void load(File file) throws InputFormatException {
dispose(); dispose();
this.maxTime=0; this.maxTime=0;
boolean res = false; boolean res = false;
@ -176,7 +176,7 @@ public class VCDDbLoader implements IWaveformDbLoader, IVCDDatabaseBuilder {
@Override @Override
public int getNetWidth(int intValue) { public int getNetWidth(int intValue) {
VCDSignal<?> signal = (VCDSignal<?>) signals.get(intValue); VCDSignal<?> signal = (VCDSignal<?>) signals.get(intValue);
return signal.getRowCount(); return signal.getWidth();
} }
/* (non-Javadoc) /* (non-Javadoc)

View File

@ -205,41 +205,17 @@ class VCDFileParser {
else else
traceBuilder.appendTransition(net, currentTime, Double.parseDouble(value)); traceBuilder.appendTransition(net, currentTime, Double.parseDouble(value));
} else { } else {
BitVector decodedValues = new BitVector(netWidth); BitVector decodedValues;
if (value.equals("z") && netWidth > 1) { if (value.equals("z") && netWidth > 1) {
decodedValues = new BitVector(netWidth);
for (int i = 0; i < netWidth; i++) for (int i = 0; i < netWidth; i++)
decodedValues.setValue(i, BitValue.Z); decodedValues.setValue(i, BitValue.Z);
} else if (value.equals("x") && netWidth > 1) { } else if (value.equals("x") && netWidth > 1) {
decodedValues = new BitVector(netWidth);
for (int i = 0; i < netWidth; i++) for (int i = 0; i < netWidth; i++)
decodedValues.setValue(i, BitValue.X); decodedValues.setValue(i, BitValue.X);
} else { } else {
int stringIndex = 0; decodedValues = BitVector.fromString(netWidth, value);
for (int convertedIndex = netWidth -1; convertedIndex >=0; convertedIndex--) {
if(convertedIndex<value.length()) {
switch (value.charAt(stringIndex++)) {
case 'z':
decodedValues.setValue(convertedIndex, BitValue.Z);
break;
case '1':
decodedValues.setValue(convertedIndex, BitValue.ONE);
break;
case '0':
decodedValues.setValue(convertedIndex, BitValue.ZERO);
break;
case 'x':
decodedValues.setValue(convertedIndex, BitValue.X);
break;
default:
decodedValues.setValue(convertedIndex, BitValue.X);
}
} else {
decodedValues.setValue(convertedIndex, BitValue.ZERO);
}
}
} }
traceBuilder.appendTransition(net, currentTime, decodedValues); traceBuilder.appendTransition(net, currentTime, decodedValues);
} }

View File

@ -100,9 +100,13 @@ public class VCDSignal<T extends IEvent> extends HierNode implements IWaveform {
} }
@Override @Override
public int getRowCount() { public int getWidth() {
return width; return width;
} }
@Override
public int getRowCount() {
return 1;
}
@Override @Override
public String getKind() { public String getKind() {

View File

@ -33,6 +33,37 @@ public class BitVector implements IEvent {
packedValues[i] = 0; packedValues[i] = 0;
} }
public static BitVector fromString(int netWidth, String value){
BitVector bv = new BitVector(netWidth);
int stringIndex = 0;
for (int convertedIndex = netWidth -1; convertedIndex >=0; convertedIndex--) {
if(convertedIndex<value.length()) {
switch (value.charAt(stringIndex++)) {
case 'z':
bv.setValue(convertedIndex, BitValue.Z);
break;
case '1':
bv.setValue(convertedIndex, BitValue.ONE);
break;
case '0':
bv.setValue(convertedIndex, BitValue.ZERO);
break;
case 'x':
bv.setValue(convertedIndex, BitValue.X);
break;
default:
bv.setValue(convertedIndex, BitValue.X);
}
} else {
bv.setValue(convertedIndex, BitValue.ZERO);
}
}
return bv;
}
/** /**
* Sets the value. * Sets the value.
* *

View File

@ -78,4 +78,11 @@ public interface IWaveform extends IHierNode {
*/ */
public int getRowCount(); public int getRowCount();
/**
* Gets the width.
*
* @return the width
*/
public int getWidth();
} }

View File

@ -55,7 +55,7 @@ public interface IWaveformDbLoader {
* @param inputFile the input file * @param inputFile the input file
* @throws InputFormatException the input format exception * @throws InputFormatException the input format exception
*/ */
public void load(IWaveformDb db, File inputFile) throws InputFormatException; public void load(File inputFile) throws InputFormatException;
/** /**
* Gets the max time. * Gets the max time.

View File

@ -135,7 +135,7 @@ public class WaveformDb extends HierNode implements IWaveformDb, PropertyChangeL
IWaveformDbLoader loader = loaderFactory.getLoader(); IWaveformDbLoader loader = loaderFactory.getLoader();
loader.addPropertyChangeListener(this); loader.addPropertyChangeListener(this);
try { try {
loader.load(this, inp); loader.load(inp);
} catch (Exception e) { } catch (Exception e) {
LOG.error("error loading file "+inp.getName(), e); LOG.error("error loading file "+inp.getName(), e);
retval=false; retval=false;

View File

@ -139,7 +139,7 @@ public class TxDbLabelProvider implements ILabelProvider {
case FILTER: case FILTER:
break; break;
case SIGNAL: case SIGNAL:
if(((IWaveform) element).getRowCount()==1) if(((IWaveform) element).getWidth()==1)
return signal; return signal;
else else
return wave; return wave;

View File

@ -77,7 +77,7 @@ public class TxDbTreeLabelProvider implements ILabelProvider {
case FILTER: case FILTER:
break; break;
case SIGNAL: case SIGNAL:
if(((IWaveform) element).getRowCount()==1) if(((IWaveform) element).getWidth()==1)
return signal; return signal;
else else
return wave; return wave;