fix sonarlint issues, add IDerivedWaveform interface
This commit is contained in:
parent
b2e269b67c
commit
6c5032da10
|
@ -13,7 +13,6 @@ package com.minres.scviewer.database.sqlite;
|
|||
import java.beans.IntrospectionException;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.sql.SQLException;
|
||||
|
@ -24,6 +23,7 @@ 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;
|
||||
import com.minres.scviewer.database.sqlite.db.IDatabase;
|
||||
import com.minres.scviewer.database.sqlite.db.SQLiteDatabase;
|
||||
|
@ -42,16 +42,13 @@ public class SQLiteDbLoader implements IWaveformDbLoader {
|
|||
|
||||
private ScvSimProps scvSimProps;
|
||||
|
||||
public SQLiteDbLoader() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getMaxTime() {
|
||||
SQLiteDatabaseSelectHandler<ScvTxEvent> handler = new SQLiteDatabaseSelectHandler<ScvTxEvent>(ScvTxEvent.class,
|
||||
SQLiteDatabaseSelectHandler<ScvTxEvent> handler = new SQLiteDatabaseSelectHandler<>(ScvTxEvent.class,
|
||||
database, "time = (SELECT MAX(time) FROM ScvTxEvent)");
|
||||
try {
|
||||
List<ScvTxEvent> event = handler.selectObjects();
|
||||
if(event.size()>0)
|
||||
if(!event.isEmpty())
|
||||
return event.get(0).getTime()*scvSimProps.getTime_resolution();
|
||||
} catch (SecurityException | IllegalArgumentException | InstantiationException | IllegalAccessException
|
||||
| InvocationTargetException | SQLException | IntrospectionException e) {
|
||||
|
@ -62,8 +59,8 @@ public class SQLiteDbLoader implements IWaveformDbLoader {
|
|||
|
||||
@Override
|
||||
public Collection<IWaveform> getAllWaves() {
|
||||
SQLiteDatabaseSelectHandler<ScvStream> handler = new SQLiteDatabaseSelectHandler<ScvStream>(ScvStream.class, database);
|
||||
List<IWaveform> streams=new ArrayList<IWaveform>();
|
||||
SQLiteDatabaseSelectHandler<ScvStream> handler = new SQLiteDatabaseSelectHandler<>(ScvStream.class, database);
|
||||
List<IWaveform> streams=new ArrayList<>();
|
||||
try {
|
||||
for(ScvStream scvStream:handler.selectObjects()){
|
||||
TxStream stream = new TxStream(database, db, scvStream);
|
||||
|
@ -72,7 +69,6 @@ public class SQLiteDbLoader implements IWaveformDbLoader {
|
|||
}
|
||||
} catch (SecurityException | IllegalArgumentException | InstantiationException | IllegalAccessException
|
||||
| InvocationTargetException | SQLException | IntrospectionException e) {
|
||||
// e.printStackTrace();
|
||||
}
|
||||
return streams;
|
||||
}
|
||||
|
@ -80,25 +76,21 @@ public class SQLiteDbLoader implements IWaveformDbLoader {
|
|||
private byte[] x = "SQLite format 3".getBytes();
|
||||
|
||||
@Override
|
||||
public boolean load(IWaveformDb db, File file) throws Exception {
|
||||
public boolean load(IWaveformDb db, File file) throws InputFormatException {
|
||||
if(file.isDirectory() || !file.exists()) return false;
|
||||
this.db=db;
|
||||
try {
|
||||
FileInputStream fis = new FileInputStream(file);
|
||||
try(FileInputStream fis = new FileInputStream(file)) {
|
||||
byte[] buffer = new byte[x.length];
|
||||
int read = fis.read(buffer, 0, x.length);
|
||||
fis.close();
|
||||
if (read == x.length)
|
||||
for (int i = 0; i < x.length; i++)
|
||||
if (buffer[i] != x[i]) return false;
|
||||
} catch(FileNotFoundException e) {
|
||||
return false;
|
||||
} catch(IOException e) { //if an I/O error occurs
|
||||
} catch(IOException e) {
|
||||
return false;
|
||||
}
|
||||
database=new SQLiteDatabase(file.getAbsolutePath());
|
||||
database.setData("TIMERESOLUTION", 1L);
|
||||
SQLiteDatabaseSelectHandler<ScvSimProps> handler = new SQLiteDatabaseSelectHandler<ScvSimProps>(ScvSimProps.class, database);
|
||||
SQLiteDatabaseSelectHandler<ScvSimProps> handler = new SQLiteDatabaseSelectHandler<>(ScvSimProps.class, database);
|
||||
try {
|
||||
for(ScvSimProps simProps:handler.selectObjects()){
|
||||
scvSimProps=simProps;
|
||||
|
|
|
@ -38,8 +38,10 @@ public class Tx implements ITx {
|
|||
private TxGenerator trGenerator;
|
||||
private ScvTx scvTx;
|
||||
private List<ITxAttribute> attributes;
|
||||
private Long begin, end;
|
||||
private List<ITxRelation> incoming, outgoing;
|
||||
private Long begin;
|
||||
private Long end;
|
||||
private List<ITxRelation> incoming;
|
||||
private List<ITxRelation> outgoing;
|
||||
|
||||
public Tx(IDatabase database, TxStream trStream, TxGenerator trGenerator, ScvTx scvTx) {
|
||||
this.database=database;
|
||||
|
@ -71,7 +73,7 @@ public class Tx implements ITx {
|
|||
@Override
|
||||
public Long getBeginTime() {
|
||||
if(begin==null){
|
||||
SQLiteDatabaseSelectHandler<ScvTxEvent> handler = new SQLiteDatabaseSelectHandler<ScvTxEvent>(ScvTxEvent.class,
|
||||
SQLiteDatabaseSelectHandler<ScvTxEvent> handler = new SQLiteDatabaseSelectHandler<>(ScvTxEvent.class,
|
||||
database, "tx="+scvTx.getId()+" AND type="+ AssociationType.BEGIN.ordinal());
|
||||
try {
|
||||
for(ScvTxEvent scvEvent:handler.selectObjects()){
|
||||
|
@ -87,7 +89,7 @@ public class Tx implements ITx {
|
|||
@Override
|
||||
public Long getEndTime() {
|
||||
if(end==null){
|
||||
SQLiteDatabaseSelectHandler<ScvTxEvent> handler = new SQLiteDatabaseSelectHandler<ScvTxEvent>(ScvTxEvent.class,
|
||||
SQLiteDatabaseSelectHandler<ScvTxEvent> handler = new SQLiteDatabaseSelectHandler<>(ScvTxEvent.class,
|
||||
database, "tx="+scvTx.getId()+" AND type="+ AssociationType.END.ordinal());
|
||||
try {
|
||||
for(ScvTxEvent scvEvent:handler.selectObjects()){
|
||||
|
@ -103,10 +105,10 @@ public class Tx implements ITx {
|
|||
@Override
|
||||
public List<ITxAttribute> getAttributes() {
|
||||
if(attributes==null){
|
||||
SQLiteDatabaseSelectHandler<ScvTxAttribute> handler = new SQLiteDatabaseSelectHandler<ScvTxAttribute>(
|
||||
SQLiteDatabaseSelectHandler<ScvTxAttribute> handler = new SQLiteDatabaseSelectHandler<>(
|
||||
ScvTxAttribute.class, database, "tx="+scvTx.getId());
|
||||
try {
|
||||
attributes = new ArrayList<ITxAttribute>();
|
||||
attributes = new ArrayList<>();
|
||||
for(ScvTxAttribute scvAttribute:handler.selectObjects()){
|
||||
attributes.add(new TxAttribute(this, scvAttribute));
|
||||
|
||||
|
@ -121,10 +123,10 @@ public class Tx implements ITx {
|
|||
@Override
|
||||
public Collection<ITxRelation> getIncomingRelations() {
|
||||
if(incoming==null){
|
||||
SQLiteDatabaseSelectHandler<ScvTxRelation> handler = new SQLiteDatabaseSelectHandler<ScvTxRelation>(
|
||||
SQLiteDatabaseSelectHandler<ScvTxRelation> handler = new SQLiteDatabaseSelectHandler<>(
|
||||
ScvTxRelation.class, database, "sink="+scvTx.getId());
|
||||
try {
|
||||
incoming = new ArrayList<ITxRelation>();
|
||||
incoming = new ArrayList<>();
|
||||
for(ScvTxRelation scvRelation:handler.selectObjects()){
|
||||
incoming.add(createRelation(scvRelation, false));
|
||||
}
|
||||
|
@ -138,10 +140,10 @@ public class Tx implements ITx {
|
|||
@Override
|
||||
public Collection<ITxRelation> getOutgoingRelations() {
|
||||
if(outgoing==null){
|
||||
SQLiteDatabaseSelectHandler<ScvTxRelation> handler = new SQLiteDatabaseSelectHandler<ScvTxRelation>(
|
||||
SQLiteDatabaseSelectHandler<ScvTxRelation> handler = new SQLiteDatabaseSelectHandler<>(
|
||||
ScvTxRelation.class, database, "src="+scvTx.getId());
|
||||
try {
|
||||
outgoing = new ArrayList<ITxRelation>();
|
||||
outgoing = new ArrayList<>();
|
||||
for(ScvTxRelation scvRelation:handler.selectObjects()){
|
||||
outgoing.add(createRelation(scvRelation, true));
|
||||
}
|
||||
|
@ -154,7 +156,7 @@ public class Tx implements ITx {
|
|||
|
||||
private ITxRelation createRelation(ScvTxRelation rel, boolean outgoing) {
|
||||
int otherId = outgoing?rel.getSink():rel.getSrc();
|
||||
SQLiteDatabaseSelectHandler<ScvTx> handler = new SQLiteDatabaseSelectHandler<ScvTx>(ScvTx.class, database,
|
||||
SQLiteDatabaseSelectHandler<ScvTx> handler = new SQLiteDatabaseSelectHandler<>(ScvTx.class, database,
|
||||
"id="+otherId);
|
||||
try {
|
||||
List<ScvTx> res = handler.selectObjects();
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
*******************************************************************************/
|
||||
package com.minres.scviewer.database.sqlite;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.minres.scviewer.database.IWaveform;
|
||||
|
@ -45,7 +46,7 @@ public class TxGenerator implements ITxGenerator {
|
|||
|
||||
@Override
|
||||
public List<ITx> getTransactions() {
|
||||
return null;
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,7 +17,8 @@ import com.minres.scviewer.database.tx.ITxRelation;
|
|||
public class TxRelation implements ITxRelation {
|
||||
|
||||
RelationType relationType;
|
||||
Tx source, target;
|
||||
Tx source;
|
||||
Tx target;
|
||||
|
||||
public TxRelation(RelationType relationType, Tx source, Tx target) {
|
||||
this.source = source;
|
||||
|
|
|
@ -40,21 +40,21 @@ public class TxStream extends HierNode implements IWaveform {
|
|||
private IDatabase database;
|
||||
|
||||
private String fullName;
|
||||
|
||||
|
||||
private IWaveformDb db;
|
||||
|
||||
|
||||
private ScvStream scvStream;
|
||||
|
||||
|
||||
private TreeMap<Integer, TxGenerator> generators;
|
||||
|
||||
|
||||
private TreeMap<Integer, ITx> transactions;
|
||||
|
||||
|
||||
private Integer maxConcurrency;
|
||||
|
||||
|
||||
private TreeMap<Long, IEvent[]> events;
|
||||
|
||||
private List<RelationType> usedRelationsList;
|
||||
|
||||
|
||||
public TxStream(IDatabase database, IWaveformDb waveformDb, ScvStream scvStream) {
|
||||
super(scvStream.getName());
|
||||
this.database=database;
|
||||
|
@ -80,9 +80,9 @@ public class TxStream extends HierNode implements IWaveform {
|
|||
|
||||
public List<ITxGenerator> getGenerators() {
|
||||
if(generators==null){
|
||||
SQLiteDatabaseSelectHandler<ScvGenerator> handler = new SQLiteDatabaseSelectHandler<ScvGenerator>(
|
||||
SQLiteDatabaseSelectHandler<ScvGenerator> handler = new SQLiteDatabaseSelectHandler<>(
|
||||
ScvGenerator.class, database, "stream="+scvStream.getId());
|
||||
generators=new TreeMap<Integer, TxGenerator>();
|
||||
generators=new TreeMap<>();
|
||||
try {
|
||||
for(ScvGenerator scvGenerator:handler.selectObjects()){
|
||||
generators.put(scvGenerator.getId(), new TxGenerator(this, scvGenerator));
|
||||
|
@ -92,22 +92,20 @@ public class TxStream extends HierNode implements IWaveform {
|
|||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return new ArrayList<ITxGenerator>(generators.values());
|
||||
return new ArrayList<>(generators.values());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
if(maxConcurrency==null){
|
||||
java.sql.Connection connection=null;
|
||||
java.sql.Statement statement=null;
|
||||
java.sql.ResultSet resultSet=null;
|
||||
try {
|
||||
connection = database.createConnection();
|
||||
statement = connection.createStatement();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("SELECT MAX(concurrencyLevel) as concurrencyLevel FROM ScvTx where stream=");
|
||||
sb.append(scvStream.getId());
|
||||
resultSet = statement.executeQuery(sb.toString());
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("SELECT MAX(concurrencyLevel) as concurrencyLevel FROM ScvTx where stream=");
|
||||
sb.append(scvStream.getId());
|
||||
try(
|
||||
java.sql.Connection connection = database.createConnection();
|
||||
java.sql.Statement statement = connection.createStatement();
|
||||
java.sql.ResultSet resultSet = statement.executeQuery(sb.toString());
|
||||
) {
|
||||
while (resultSet.next()) {
|
||||
if(maxConcurrency==null) maxConcurrency=0;
|
||||
Object value = resultSet.getObject("concurrencyLevel");
|
||||
|
@ -116,12 +114,6 @@ public class TxStream extends HierNode implements IWaveform {
|
|||
}
|
||||
} catch (SQLException e) {
|
||||
if(maxConcurrency==null) maxConcurrency=0;
|
||||
} finally {
|
||||
try{
|
||||
if(resultSet!=null) resultSet.close();
|
||||
if(statement!=null) statement.close();
|
||||
if(connection!=null) connection.close();
|
||||
} catch (SQLException e) { }
|
||||
}
|
||||
maxConcurrency+=1;
|
||||
}
|
||||
|
@ -131,7 +123,7 @@ public class TxStream extends HierNode implements IWaveform {
|
|||
@Override
|
||||
public NavigableMap<Long, IEvent[]> getEvents(){
|
||||
if(events==null){
|
||||
events=new TreeMap<Long, IEvent[]>();
|
||||
events=new TreeMap<>();
|
||||
for(Entry<Integer, ITx> entry:getTransactions().entrySet()){
|
||||
putEvent(new TxEvent(EventKind.BEGIN, entry.getValue()));
|
||||
putEvent(new TxEvent(EventKind.END, entry.getValue()));
|
||||
|
@ -156,8 +148,8 @@ public class TxStream extends HierNode implements IWaveform {
|
|||
protected Map<Integer, ITx> getTransactions() {
|
||||
if(transactions==null){
|
||||
if(generators==null) getGenerators();
|
||||
transactions = new TreeMap<Integer, ITx>();
|
||||
SQLiteDatabaseSelectHandler<ScvTx> handler = new SQLiteDatabaseSelectHandler<ScvTx>(ScvTx.class, database,
|
||||
transactions = new TreeMap<>();
|
||||
SQLiteDatabaseSelectHandler<ScvTx> handler = new SQLiteDatabaseSelectHandler<>(ScvTx.class, database,
|
||||
"stream="+scvStream.getId());
|
||||
try {
|
||||
for(ScvTx scvTx:handler.selectObjects()){
|
||||
|
@ -179,7 +171,7 @@ public class TxStream extends HierNode implements IWaveform {
|
|||
public void setRelationTypeList(List<RelationType> usedRelationsList){
|
||||
this.usedRelationsList=usedRelationsList;
|
||||
}
|
||||
|
||||
|
||||
public RelationType getRelationType(String name) {
|
||||
RelationType relType=RelationType.create(name);
|
||||
if(!usedRelationsList.contains(relType)) usedRelationsList.add(relType);
|
||||
|
@ -187,17 +179,17 @@ public class TxStream extends HierNode implements IWaveform {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Boolean equals(IWaveform other) {
|
||||
public boolean isSame(IWaveform other) {
|
||||
return(other instanceof TxStream && this.getId().equals(other.getId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEvent[] getEventsBeforeTime(Long time) {
|
||||
Entry<Long, IEvent[]> e = events.floorEntry(time);
|
||||
if(e==null)
|
||||
return null;
|
||||
else
|
||||
return events.floorEntry(time).getValue();
|
||||
Entry<Long, IEvent[]> e = events.floorEntry(time);
|
||||
if(e==null)
|
||||
return new IEvent[]{};
|
||||
else
|
||||
return events.floorEntry(time).getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -25,6 +25,7 @@ import com.minres.scviewer.database.DataType
|
|||
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
|
||||
import com.minres.scviewer.database.tx.ITxGenerator
|
||||
|
||||
|
@ -62,7 +63,7 @@ public class TextDbLoader implements IWaveformDbLoader{
|
|||
static final byte[] x = "scv_tr_stream".bytes
|
||||
|
||||
@Override
|
||||
boolean load(IWaveformDb db, File file) throws Exception {
|
||||
boolean load(IWaveformDb db, File file) throws InputFormatException {
|
||||
if(file.isDirectory() || !file.exists()) return false;
|
||||
this.db=db
|
||||
this.streams=[]
|
||||
|
|
|
@ -33,11 +33,6 @@ class TxEvent implements ITxEvent {
|
|||
return new TxEvent(kind, transaction, time);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// int compareTo(IWaveformEvent o) {
|
||||
// time.compareTo(o.time)
|
||||
// }
|
||||
|
||||
@Override
|
||||
public
|
||||
String toString() {
|
||||
|
|
|
@ -114,7 +114,7 @@ class TxStream extends HierNode implements IWaveform {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Boolean equals(IWaveform other) {
|
||||
public boolean isSame(IWaveform other) {
|
||||
return(other instanceof TxStream && this.getId()==other.getId());
|
||||
}
|
||||
|
||||
|
|
|
@ -1184,7 +1184,7 @@ public class WaveformView implements IWaveformView {
|
|||
|
||||
public TrackEntry getEntryForStream(IWaveform source) {
|
||||
for(TrackEntry trackEntry:streams)
|
||||
if(trackEntry.waveform.equals(source)) return trackEntry;
|
||||
if(trackEntry.waveform.isSame(source)) return trackEntry;
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,11 +14,11 @@ import java.io.File;
|
|||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.NavigableMap;
|
||||
import java.util.Stack;
|
||||
import java.util.TreeMap;
|
||||
import java.util.Vector;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
@ -37,39 +37,30 @@ import com.minres.scviewer.database.RelationType;
|
|||
*/
|
||||
public class VCDDbLoader implements IWaveformDbLoader, IVCDDatabaseBuilder {
|
||||
|
||||
|
||||
|
||||
/** The Constant TIME_RES. */
|
||||
private static final Long TIME_RES = 1000L; // ps;
|
||||
private static final Long TIME_RES = 1000L; // ps
|
||||
|
||||
/** The db. */
|
||||
private IWaveformDb db;
|
||||
|
||||
|
||||
/** The module stack. */
|
||||
private Stack<String> moduleStack;
|
||||
|
||||
private ArrayDeque<String> moduleStack;
|
||||
|
||||
/** The signals. */
|
||||
private List<IWaveform> signals;
|
||||
|
||||
|
||||
/** The max time. */
|
||||
private long maxTime;
|
||||
|
||||
/**
|
||||
* Instantiates a new VCD db.
|
||||
*/
|
||||
public VCDDbLoader() {
|
||||
}
|
||||
|
||||
private static boolean isGzipped(File f) {
|
||||
InputStream is = null;
|
||||
try {
|
||||
is = new FileInputStream(f);
|
||||
try (InputStream is = new FileInputStream(f)) {
|
||||
byte [] signature = new byte[2];
|
||||
int nread = is.read( signature ); //read the gzip signature
|
||||
return nread == 2 && signature[ 0 ] == (byte) 0x1f && signature[ 1 ] == (byte) 0x8b;
|
||||
} catch (IOException e) {
|
||||
}
|
||||
catch (IOException e) {
|
||||
return false;
|
||||
} finally {
|
||||
try { is.close();} catch (IOException e) { }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -79,21 +70,27 @@ public class VCDDbLoader implements IWaveformDbLoader, IVCDDatabaseBuilder {
|
|||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public boolean load(IWaveformDb db, File file) throws Exception {
|
||||
public boolean load(IWaveformDb db, File file) throws InputFormatException {
|
||||
if(file.isDirectory() || !file.exists()) return false;
|
||||
this.db=db;
|
||||
this.maxTime=0;
|
||||
String name = file.getCanonicalFile().getName();
|
||||
if(!(name.endsWith(".vcd") ||
|
||||
name.endsWith(".vcdz") ||
|
||||
name.endsWith(".vcdgz") ||
|
||||
name.endsWith(".vcd.gz")) )
|
||||
return false;
|
||||
signals = new Vector<IWaveform>();
|
||||
moduleStack= new Stack<String>();
|
||||
FileInputStream fis = new FileInputStream(file);
|
||||
boolean res = new VCDFileParser(false).load(isGzipped(file)?new GZIPInputStream(fis):fis, this);
|
||||
moduleStack=null;
|
||||
boolean res = false;
|
||||
try {
|
||||
String name = file.getCanonicalFile().getName();
|
||||
if(!(name.endsWith(".vcd") ||
|
||||
name.endsWith(".vcdz") ||
|
||||
name.endsWith(".vcdgz") ||
|
||||
name.endsWith(".vcd.gz")) )
|
||||
return false;
|
||||
signals = new Vector<>();
|
||||
moduleStack= new ArrayDeque<>();
|
||||
FileInputStream fis = new FileInputStream(file);
|
||||
res = new VCDFileParser(false).load(isGzipped(file)?new GZIPInputStream(fis):fis, this);
|
||||
moduleStack=null;
|
||||
} catch(IOException e) {
|
||||
moduleStack=null;
|
||||
throw new InputFormatException();
|
||||
}
|
||||
if(!res) throw new InputFormatException();
|
||||
// calculate max time of database
|
||||
for(IWaveform waveform:signals) {
|
||||
|
@ -159,9 +156,8 @@ public class VCDDbLoader implements IWaveformDbLoader, IVCDDatabaseBuilder {
|
|||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Integer newNet(String name, int i, int width) {
|
||||
String netName = moduleStack.empty()? name: moduleStack.lastElement()+"."+name;
|
||||
String netName = moduleStack.isEmpty()? name: moduleStack.peek()+"."+name;
|
||||
int id = signals.size();
|
||||
assert(width>=0);
|
||||
if(width==0) {
|
||||
signals.add( i<0 ? new VCDSignal<DoubleVal>(db, id, netName, width) :
|
||||
new VCDSignal<DoubleVal>((VCDSignal<DoubleVal>)signals.get(i), id, netName));
|
||||
|
@ -191,7 +187,7 @@ public class VCDDbLoader implements IWaveformDbLoader, IVCDDatabaseBuilder {
|
|||
Long time = currentTime* TIME_RES;
|
||||
signal.addSignalChange(time, value);
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.minres.scviewer.database.vcd.ITraceBuilder#appendTransition(int, long, com.minres.scviewer.database.vcd.BitVector)
|
||||
*/
|
||||
|
@ -202,7 +198,7 @@ public class VCDDbLoader implements IWaveformDbLoader, IVCDDatabaseBuilder {
|
|||
Long time = currentTime* TIME_RES;
|
||||
signal.addSignalChange(time, new DoubleVal(value));
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.minres.scviewer.database.IWaveformDbLoader#getAllRelationTypes()
|
||||
*/
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
package com.minres.scviewer.database.vcd;
|
||||
|
||||
import java.io.*;
|
||||
import java.text.ParseException;
|
||||
import java.util.*;
|
||||
|
||||
import com.minres.scviewer.database.BitValue;
|
||||
|
@ -19,7 +20,7 @@ import com.minres.scviewer.database.BitVector;
|
|||
class VCDFileParser {
|
||||
private StreamTokenizer tokenizer;
|
||||
private IVCDDatabaseBuilder traceBuilder;
|
||||
private HashMap<String, Integer> nameToNetMap = new HashMap<String, Integer>();
|
||||
private HashMap<String, Integer> nameToNetMap = new HashMap<>();
|
||||
private long picoSecondsPerIncrement;
|
||||
private boolean stripNetWidth;
|
||||
private boolean replaceColon;
|
||||
|
@ -50,19 +51,19 @@ class VCDFileParser {
|
|||
}
|
||||
}
|
||||
|
||||
private void parseScope() throws Exception {
|
||||
private void parseScope() throws IOException, ParseException {
|
||||
nextToken(); // Scope type (ignore)
|
||||
nextToken();
|
||||
traceBuilder.enterModule(tokenizer.sval);
|
||||
match("$end");
|
||||
}
|
||||
|
||||
private void parseUpscope() throws Exception {
|
||||
private void parseUpscope() throws IOException, ParseException {
|
||||
match("$end");
|
||||
traceBuilder.exitModule();
|
||||
}
|
||||
|
||||
private void parseVar() throws Exception {
|
||||
private void parseVar() throws IOException {
|
||||
nextToken(); // type
|
||||
String type = tokenizer.sval;
|
||||
nextToken(); // size
|
||||
|
@ -72,11 +73,12 @@ class VCDFileParser {
|
|||
nextToken();
|
||||
String id = tokenizer.sval;
|
||||
nextToken();
|
||||
String netName = tokenizer.sval;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(tokenizer.sval);
|
||||
while (nextToken() && !tokenizer.sval.equals("$end")) {
|
||||
netName+=tokenizer.sval;
|
||||
sb.append(tokenizer.sval);
|
||||
}
|
||||
|
||||
String netName = sb.toString();
|
||||
Integer net = nameToNetMap.get(id);
|
||||
if (net == null) { // We've never seen this net before
|
||||
int openBracket = netName.indexOf('[');
|
||||
|
@ -86,9 +88,9 @@ class VCDFileParser {
|
|||
}
|
||||
if(replaceColon) {
|
||||
if (openBracket != -1) {
|
||||
netName = netName.substring(0, openBracket).replaceAll(":", ".")+netName.substring(openBracket);
|
||||
netName = netName.substring(0, openBracket).replace(":", ".")+netName.substring(openBracket);
|
||||
} else
|
||||
netName=netName.replaceAll(":", ".");
|
||||
netName=netName.replace(":", ".");
|
||||
}
|
||||
nameToNetMap.put(id, traceBuilder.newNet(netName, -1, width));
|
||||
} else {
|
||||
|
@ -97,25 +99,28 @@ class VCDFileParser {
|
|||
}
|
||||
}
|
||||
|
||||
private void parseComment() throws Exception {
|
||||
private void parseComment() throws IOException {
|
||||
nextToken();
|
||||
String s = tokenizer.sval;
|
||||
StringBuilder s = new StringBuilder();
|
||||
s.append(tokenizer.sval);
|
||||
nextToken();
|
||||
while(!tokenizer.sval.equals("$end")){
|
||||
s+=" "+tokenizer.sval;
|
||||
s.append(" ").append(tokenizer.sval);
|
||||
nextToken();
|
||||
}
|
||||
replaceColon|=s.contains("ARTERIS Architecture");
|
||||
replaceColon|=s.toString().contains("ARTERIS Architecture");
|
||||
}
|
||||
|
||||
private void parseTimescale() throws Exception {
|
||||
private void parseTimescale() throws IOException {
|
||||
nextToken();
|
||||
String s = tokenizer.sval;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(tokenizer.sval);
|
||||
nextToken();
|
||||
while(!tokenizer.sval.equals("$end")){
|
||||
s+=" "+tokenizer.sval;
|
||||
sb.append(" ").append(tokenizer.sval);
|
||||
nextToken();
|
||||
}
|
||||
String s = sb.toString();
|
||||
switch (s.charAt(s.length() - 2)){
|
||||
case 'p': // Nano-seconds
|
||||
picoSecondsPerIncrement = 1;
|
||||
|
@ -141,7 +146,7 @@ class VCDFileParser {
|
|||
picoSecondsPerIncrement *= Long.parseLong(s);
|
||||
}
|
||||
|
||||
private boolean parseDefinition() throws Exception {
|
||||
private boolean parseDefinition() throws IOException, ParseException {
|
||||
nextToken();
|
||||
if (tokenizer.sval.equals("$scope"))
|
||||
parseScope();
|
||||
|
@ -166,7 +171,7 @@ class VCDFileParser {
|
|||
return true;
|
||||
}
|
||||
|
||||
private boolean parseTransition() throws Exception {
|
||||
private boolean parseTransition() throws IOException {
|
||||
if (!nextToken()) return false;
|
||||
if (tokenizer.sval.charAt(0) == '#') { // If the line begins with a #, this is a timestamp.
|
||||
currentTime = Long.parseLong(tokenizer.sval.substring(1)) * picoSecondsPerIncrement;
|
||||
|
@ -179,19 +184,13 @@ class VCDFileParser {
|
|||
}
|
||||
if (tokenizer.sval.equals("$dumpvars") || tokenizer.sval.equals("$end"))
|
||||
return true;
|
||||
String value, id;
|
||||
if (tokenizer.sval.charAt(0) == 'b') {
|
||||
// Multiple value net. Value appears first, followed by space,
|
||||
// then identifier
|
||||
String value;
|
||||
String id;
|
||||
if (tokenizer.sval.charAt(0) == 'b' || tokenizer.sval.charAt(0) == 'r') {
|
||||
// Multiple value net. Value appears first, followed by space, then identifier
|
||||
value = tokenizer.sval.substring(1);
|
||||
nextToken();
|
||||
id = tokenizer.sval;
|
||||
}else if (tokenizer.sval.charAt(0) == 'r') {
|
||||
// Multiple value net. Value appears first, followed by space,
|
||||
// then identifier
|
||||
value = tokenizer.sval.substring(1);
|
||||
nextToken();
|
||||
id = tokenizer.sval;
|
||||
} else {
|
||||
// Single value net. identifier first, then value, no space.
|
||||
value = tokenizer.sval.substring(0, 1);
|
||||
|
@ -199,10 +198,8 @@ class VCDFileParser {
|
|||
}
|
||||
|
||||
Integer net = nameToNetMap.get(id);
|
||||
if (net == null) {
|
||||
System.out.println("unknown net " + id + " value " + value);
|
||||
if (net == null)
|
||||
return true;
|
||||
}
|
||||
|
||||
int netWidth = traceBuilder.getNetWidth(net);
|
||||
if(netWidth==0) {
|
||||
|
@ -253,14 +250,14 @@ class VCDFileParser {
|
|||
return true;
|
||||
}
|
||||
|
||||
private void match(String value) throws Exception {
|
||||
private void match(String value) throws ParseException, IOException {
|
||||
nextToken();
|
||||
if (!tokenizer.sval.equals(value))
|
||||
throw new Exception("Line "+tokenizer.lineno()+": parse error, expected "+value+" got "+tokenizer.sval);
|
||||
throw new ParseException("Line "+tokenizer.lineno()+": parse error, expected "+value+" got "+tokenizer.sval, tokenizer.lineno());
|
||||
}
|
||||
|
||||
private boolean nextToken() throws IOException {
|
||||
return tokenizer.nextToken() != StreamTokenizer.TT_EOF;
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
|
|
@ -46,18 +46,16 @@ public class VCDSignal<T extends IEvent> extends HierNode implements IWaveform {
|
|||
fullName=name;
|
||||
this.id=id;
|
||||
this.width=width;
|
||||
this.values=new TreeMap<Long, IEvent[]>();
|
||||
this.values=new TreeMap<>();
|
||||
}
|
||||
|
||||
public VCDSignal(VCDSignal<T> other, int id, String name) {
|
||||
public VCDSignal(VCDSignal<T> o, int id, String name) {
|
||||
super(name);
|
||||
fullName=name;
|
||||
this.id=id;
|
||||
assert(other instanceof VCDSignal<?>);
|
||||
VCDSignal<T> o = (VCDSignal<T>)other;
|
||||
this.width=o.width;
|
||||
this.values=o.values;
|
||||
this.db=other.getDb();
|
||||
this.db=o.getDb();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -105,13 +103,13 @@ public class VCDSignal<T extends IEvent> extends HierNode implements IWaveform {
|
|||
public IEvent[] getEventsBeforeTime(Long time) {
|
||||
Entry<Long, IEvent[]> e = values.floorEntry(time);
|
||||
if(e==null)
|
||||
return null;
|
||||
return new IEvent[] {};
|
||||
else
|
||||
return values.floorEntry(time).getValue();
|
||||
return values.floorEntry(time).getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean equals(IWaveform other) {
|
||||
public boolean isSame(IWaveform other) {
|
||||
return( other instanceof VCDSignal<?> && this.getId().equals(other.getId()));
|
||||
}
|
||||
|
||||
|
|
|
@ -13,9 +13,9 @@ package com.minres.scviewer.database;
|
|||
public class BitVector implements IEvent {
|
||||
|
||||
private final int width;
|
||||
|
||||
|
||||
private int[] packedValues;
|
||||
|
||||
|
||||
public BitVector(int netWidth) {
|
||||
this.width=netWidth;
|
||||
packedValues = new int[(netWidth+15)/16];
|
||||
|
@ -31,19 +31,19 @@ public class BitVector implements IEvent {
|
|||
}
|
||||
|
||||
public char[] getValue() {
|
||||
int bitOffset = 0;
|
||||
int wordOffset = 0;
|
||||
char[] res = new char[width];
|
||||
// Copy values out of packed array
|
||||
for (int i = 0; i < width; i++) {
|
||||
int currentWord = (packedValues[wordOffset] >> bitOffset)&3;
|
||||
res[width-i-1]=BitValue.fromInt(currentWord).toChar();
|
||||
bitOffset += 2;
|
||||
if (bitOffset == 32) {
|
||||
wordOffset++;
|
||||
bitOffset = 0;
|
||||
}
|
||||
}
|
||||
int bitOffset = 0;
|
||||
int wordOffset = 0;
|
||||
char[] res = new char[width];
|
||||
// Copy values out of packed array
|
||||
for (int i = 0; i < width; i++) {
|
||||
int currentWord = (packedValues[wordOffset] >> bitOffset)&3;
|
||||
res[width-i-1]=BitValue.fromInt(currentWord).toChar();
|
||||
bitOffset += 2;
|
||||
if (bitOffset == 32) {
|
||||
wordOffset++;
|
||||
bitOffset = 0;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,7 @@ public class BitVector implements IEvent {
|
|||
public String toString(){
|
||||
return new String(getValue());
|
||||
}
|
||||
|
||||
|
||||
public String toHexString(){
|
||||
int resWidth=(width-1)/4+1;
|
||||
char[] value=getValue();
|
||||
|
@ -76,33 +76,34 @@ public class BitVector implements IEvent {
|
|||
for(int i=resWidth-1; i>=0; i--){
|
||||
int digit=0;
|
||||
for(int j=3; j>=0; j--){
|
||||
if((4*i+j)>=value.length) continue;
|
||||
BitValue val = BitValue.fromChar(value[4*i+j]);
|
||||
switch(val) {
|
||||
case X:
|
||||
case Z:
|
||||
res[i]=val.toChar();
|
||||
continue;
|
||||
case ONE:
|
||||
digit+=1<<(3-j);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
if((4*i+j)<value.length) {
|
||||
BitValue val = BitValue.fromChar(value[4*i+j]);
|
||||
switch(val) {
|
||||
case X:
|
||||
case Z:
|
||||
res[i]=val.toChar();
|
||||
continue;
|
||||
case ONE:
|
||||
digit+=1<<(3-j);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
res[i]=Character.forDigit(digit, 16); //((digit < 10) ? '0' + digit : 'a' + digit -10)
|
||||
}
|
||||
return new String(res);
|
||||
}
|
||||
|
||||
|
||||
public long toUnsignedValue() {
|
||||
long res = 0;
|
||||
int bitOffset = 0;
|
||||
int wordOffset = 0;
|
||||
int currentWord = 0;
|
||||
// Copy values out of packed array
|
||||
for (int i = 0; i < width; i++) {
|
||||
if(bitOffset==0) currentWord = packedValues[wordOffset];
|
||||
int bitOffset = 0;
|
||||
int wordOffset = 0;
|
||||
int currentWord = 0;
|
||||
// Copy values out of packed array
|
||||
for (int i = 0; i < width; i++) {
|
||||
if(bitOffset==0) currentWord = packedValues[wordOffset];
|
||||
switch (currentWord & 3) {
|
||||
case 1:
|
||||
res|=1<<i;
|
||||
|
@ -113,27 +114,27 @@ public class BitVector implements IEvent {
|
|||
default:
|
||||
break;
|
||||
}
|
||||
bitOffset += 2;
|
||||
if (bitOffset == 32) {
|
||||
wordOffset++;
|
||||
bitOffset = 0;
|
||||
} else {
|
||||
currentWord >>= 2;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
bitOffset += 2;
|
||||
if (bitOffset == 32) {
|
||||
wordOffset++;
|
||||
bitOffset = 0;
|
||||
} else {
|
||||
currentWord >>= 2;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
public long toSignedValue() {
|
||||
long res = 0;
|
||||
int bitOffset = 0;
|
||||
int wordOffset = 0;
|
||||
int currentWord = 0;
|
||||
int lastVal=0;
|
||||
// Copy values out of packed array
|
||||
for (int i = 0; i < width; i++) {
|
||||
if(bitOffset==0) currentWord = packedValues[wordOffset];
|
||||
lastVal=0;
|
||||
int bitOffset = 0;
|
||||
int wordOffset = 0;
|
||||
int currentWord = 0;
|
||||
int lastVal=0;
|
||||
// Copy values out of packed array
|
||||
for (int i = 0; i < width; i++) {
|
||||
if(bitOffset==0) currentWord = packedValues[wordOffset];
|
||||
lastVal=0;
|
||||
switch (currentWord & 3) {
|
||||
case 1:
|
||||
res|=1<<i;
|
||||
|
@ -144,16 +145,16 @@ public class BitVector implements IEvent {
|
|||
return 0;
|
||||
default:
|
||||
}
|
||||
bitOffset += 2;
|
||||
if (bitOffset == 32) {
|
||||
wordOffset++;
|
||||
bitOffset = 0;
|
||||
} else {
|
||||
currentWord >>= 2;
|
||||
}
|
||||
}
|
||||
if(lastVal!=0)
|
||||
res |= -1l<<width;
|
||||
bitOffset += 2;
|
||||
if (bitOffset == 32) {
|
||||
wordOffset++;
|
||||
bitOffset = 0;
|
||||
} else {
|
||||
currentWord >>= 2;
|
||||
}
|
||||
}
|
||||
if(lastVal!=0)
|
||||
res |= -1l<<width;
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,4 +25,4 @@ public enum DataType {
|
|||
POINTER, // T*
|
||||
ARRAY, // T[N]
|
||||
STRING // string, std::string
|
||||
};
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ public class HierNode implements IHierNode {
|
|||
protected PropertyChangeSupport pcs;
|
||||
|
||||
public HierNode() {
|
||||
childs = new ArrayList<IHierNode>();
|
||||
childs = new ArrayList<>();
|
||||
pcs=new PropertyChangeSupport(this);
|
||||
}
|
||||
|
||||
|
@ -85,4 +85,9 @@ public class HierNode implements IHierNode {
|
|||
return getFullName().compareTo(o.getFullName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDerivedWaveform deriveWaveform() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015, 2020 MINRES Technologies GmbH and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* MINRES Technologies GmbH - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package com.minres.scviewer.database;
|
||||
|
||||
/**
|
||||
* The Interface IDerivedWaveform.
|
||||
*/
|
||||
public interface IDerivedWaveform extends IWaveform {
|
||||
|
||||
void addSourceWaveform(IWaveform waveform);
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 MINRES Technologies GmbH and others.
|
||||
* Copyright (c) 2015, 2020 MINRES Technologies GmbH and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -13,6 +13,9 @@ package com.minres.scviewer.database;
|
|||
import java.beans.PropertyChangeListener;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The Interface IHierNode.
|
||||
*/
|
||||
public interface IHierNode extends Comparable<IHierNode>{
|
||||
|
||||
/**
|
||||
|
@ -33,14 +36,46 @@ public interface IHierNode extends Comparable<IHierNode>{
|
|||
*/
|
||||
public void removePropertyChangeListener(PropertyChangeListener l) ;
|
||||
|
||||
/**
|
||||
* Gets the full name.
|
||||
*
|
||||
* @return the full name
|
||||
*/
|
||||
public String getFullName();
|
||||
|
||||
/**
|
||||
* Gets the name.
|
||||
*
|
||||
* @return the name
|
||||
*/
|
||||
public String getName();
|
||||
|
||||
/**
|
||||
* Sets the name.
|
||||
*
|
||||
* @param name the new name
|
||||
*/
|
||||
public void setName(String name);
|
||||
|
||||
/**
|
||||
* Sets the parent.
|
||||
*
|
||||
* @param parent the new parent
|
||||
*/
|
||||
public void setParent(IHierNode parent);
|
||||
|
||||
/**
|
||||
* Gets the child nodes.
|
||||
*
|
||||
* @return the child nodes
|
||||
*/
|
||||
public List<IHierNode> getChildNodes();
|
||||
|
||||
/**
|
||||
* Derive waveform.
|
||||
*
|
||||
* @return the i derived waveform or null if none could be created
|
||||
*/
|
||||
public IDerivedWaveform deriveWaveform();
|
||||
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ public interface IWaveform extends IHierNode {
|
|||
|
||||
public IWaveformDb getDb();
|
||||
|
||||
public Boolean equals(IWaveform other);
|
||||
public boolean isSame(IWaveform other);
|
||||
|
||||
public NavigableMap<Long, IEvent[]> getEvents();
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ import java.util.Collection;
|
|||
|
||||
public interface IWaveformDbLoader {
|
||||
|
||||
public boolean load(IWaveformDb db, File inp) throws Exception;
|
||||
public boolean load(IWaveformDb db, File inp) throws InputFormatException;
|
||||
|
||||
public Long getMaxTime();
|
||||
|
||||
|
|
|
@ -50,4 +50,9 @@ public class RelationType {
|
|||
public int hashCode() {
|
||||
return name.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return name.equals(obj);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,6 @@ package com.minres.scviewer.database.internal;
|
|||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
@ -24,12 +23,11 @@ import com.minres.scviewer.database.IHierNode;
|
|||
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;
|
||||
|
||||
public class WaveformDb extends HierNode implements IWaveformDb {
|
||||
|
||||
private static List<IWaveformDbLoader> loaders=new LinkedList<IWaveformDbLoader>();
|
||||
private static List<IWaveformDbLoader> loaders=new LinkedList<>();
|
||||
|
||||
private boolean loaded;
|
||||
|
||||
|
@ -55,7 +53,7 @@ public class WaveformDb extends HierNode implements IWaveformDb {
|
|||
|
||||
public WaveformDb() {
|
||||
super();
|
||||
waveforms = new HashMap<String, IWaveform>();
|
||||
waveforms = new HashMap<>();
|
||||
relationTypes=new ArrayList<>();
|
||||
maxTime=0L;
|
||||
}
|
||||
|
@ -72,7 +70,7 @@ public class WaveformDb extends HierNode implements IWaveformDb {
|
|||
|
||||
@Override
|
||||
public List<IWaveform> getAllWaves() {
|
||||
return new ArrayList<IWaveform>(waveforms.values());
|
||||
return new ArrayList<>(waveforms.values());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -121,9 +119,8 @@ public class WaveformDb extends HierNode implements IWaveformDb {
|
|||
return loaded;
|
||||
}
|
||||
|
||||
private void buildHierarchyNodes() throws InputFormatException{
|
||||
private void buildHierarchyNodes() {
|
||||
for(IWaveform stream:getAllWaves()){
|
||||
//updateMaxTime(stream);
|
||||
String[] hier = stream.getName().split("\\.");
|
||||
IHierNode node = this;
|
||||
for(int i=0; i<hier.length-1; ++i){
|
||||
|
@ -152,14 +149,9 @@ public class WaveformDb extends HierNode implements IWaveformDb {
|
|||
}
|
||||
|
||||
private void sortRecursive(IHierNode node) {
|
||||
Collections.sort(node.getChildNodes(), new Comparator<IHierNode>() {
|
||||
@Override
|
||||
public int compare(IHierNode o1, IHierNode o2) {
|
||||
return o1.getName().compareTo(o2.getName()); }
|
||||
|
||||
});
|
||||
Collections.sort(node.getChildNodes(), (IHierNode o1, IHierNode o2) -> o1.getName().compareTo(o2.getName()));
|
||||
for(IHierNode n:node.getChildNodes()) {
|
||||
if(n.getChildNodes().size()>0)
|
||||
if(!n.getChildNodes().isEmpty())
|
||||
sortRecursive(n);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.io.File;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.minres.scviewer.database.IDerivedWaveform;
|
||||
import com.minres.scviewer.database.IHierNode;
|
||||
import com.minres.scviewer.database.IWaveform;
|
||||
import com.minres.scviewer.database.IWaveformDb;
|
||||
|
@ -85,4 +86,9 @@ public class LoadingWaveformDb implements IWaveformDb {
|
|||
public void clear() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDerivedWaveform deriveWaveform() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue