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;
}
@Override
public int getWidth() {
return 0;
}
/**
* Calculate concurrency.
*/

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -205,41 +205,17 @@ class VCDFileParser {
else
traceBuilder.appendTransition(net, currentTime, Double.parseDouble(value));
} else {
BitVector decodedValues = new BitVector(netWidth);
BitVector decodedValues;
if (value.equals("z") && netWidth > 1) {
decodedValues = new BitVector(netWidth);
for (int i = 0; i < netWidth; i++)
decodedValues.setValue(i, BitValue.Z);
} else if (value.equals("x") && netWidth > 1) {
decodedValues = new BitVector(netWidth);
for (int i = 0; i < netWidth; i++)
decodedValues.setValue(i, BitValue.X);
} else {
int stringIndex = 0;
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);
}
}
decodedValues = BitVector.fromString(netWidth, value);
}
traceBuilder.appendTransition(net, currentTime, decodedValues);
}

View File

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

View File

@ -33,6 +33,37 @@ public class BitVector implements IEvent {
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.
*

View File

@ -78,4 +78,11 @@ public interface IWaveform extends IHierNode {
*/
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
* @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.

View File

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

View File

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

View File

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