2015-01-06 17:14:16 +01:00
|
|
|
package com.minres.scviewer.database.vcd;
|
|
|
|
|
2015-01-20 18:50:15 +01:00
|
|
|
import java.util.Collection;
|
|
|
|
import java.util.Map.Entry;
|
|
|
|
import java.util.NavigableMap;
|
|
|
|
import java.util.TreeMap;
|
2015-01-06 17:14:16 +01:00
|
|
|
|
2015-01-20 18:50:15 +01:00
|
|
|
import com.google.common.collect.Ordering;
|
|
|
|
import com.google.common.collect.TreeMultimap;
|
2015-01-06 17:14:16 +01:00
|
|
|
import com.minres.scviewer.database.HierNode;
|
|
|
|
import com.minres.scviewer.database.ISignal;
|
|
|
|
import com.minres.scviewer.database.ISignalChange;
|
2015-01-20 18:50:15 +01:00
|
|
|
import com.minres.scviewer.database.IWaveformEvent;
|
2015-01-06 17:14:16 +01:00
|
|
|
import com.minres.scviewer.database.IWaveform;
|
2015-01-10 00:23:46 +01:00
|
|
|
import com.minres.scviewer.database.IWaveformDb;
|
2015-01-06 17:14:16 +01:00
|
|
|
|
|
|
|
public class VCDSignal<T extends ISignalChange> extends HierNode implements ISignal<T> {
|
|
|
|
|
|
|
|
private long id;
|
|
|
|
|
|
|
|
private String fullName;
|
|
|
|
|
|
|
|
private final String kind = "signal";
|
|
|
|
|
|
|
|
private final int width;
|
|
|
|
|
2015-01-10 00:23:46 +01:00
|
|
|
private IWaveformDb db;
|
2015-01-06 17:14:16 +01:00
|
|
|
|
2015-01-20 18:50:15 +01:00
|
|
|
TreeMap<Long, T> values;
|
2015-01-06 17:14:16 +01:00
|
|
|
|
2015-01-10 00:23:46 +01:00
|
|
|
public VCDSignal(IWaveformDb db, String name) {
|
|
|
|
this(db, 0, name, 1);
|
2015-01-06 17:14:16 +01:00
|
|
|
}
|
|
|
|
|
2015-01-10 00:23:46 +01:00
|
|
|
public VCDSignal(IWaveformDb db, int id, String name) {
|
|
|
|
this(db, id,name,1);
|
2015-01-06 17:14:16 +01:00
|
|
|
}
|
|
|
|
|
2015-01-10 00:23:46 +01:00
|
|
|
public VCDSignal(IWaveformDb db, int id, String name, int width) {
|
2015-01-06 17:14:16 +01:00
|
|
|
super(name);
|
2015-01-10 00:23:46 +01:00
|
|
|
this.db=db;
|
2015-01-06 17:14:16 +01:00
|
|
|
fullName=name;
|
|
|
|
this.id=id;
|
|
|
|
this.width=width;
|
2015-01-20 18:50:15 +01:00
|
|
|
this.values=new TreeMap<Long, T>();
|
2015-01-06 17:14:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
2015-01-20 18:50:15 +01:00
|
|
|
public VCDSignal(IWaveform<? extends ISignalChange> other, int id, String name) {
|
2015-01-06 17:14:16 +01:00
|
|
|
super(name);
|
|
|
|
fullName=name;
|
|
|
|
this.id=id;
|
|
|
|
assert(other instanceof VCDSignal<?>);
|
2015-01-20 18:50:15 +01:00
|
|
|
this.width=((VCDSignal<? extends IWaveformEvent>)other).width;
|
2015-01-06 17:14:16 +01:00
|
|
|
this.values=((VCDSignal<T>)other).values;
|
2015-01-10 00:23:46 +01:00
|
|
|
this.db=other.getDb();
|
2015-01-06 17:14:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getFullName() {
|
|
|
|
return fullName;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setId(int id) {
|
|
|
|
this.id=id;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Long getId() {
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getKind() {
|
|
|
|
return kind;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getWidth() {
|
|
|
|
return width;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public IWaveformDb getDb() {
|
|
|
|
return db;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void addSignalChange(T change){
|
2015-01-20 18:50:15 +01:00
|
|
|
values.put(change.getTime(), change);
|
2015-01-06 17:14:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-01-20 18:50:15 +01:00
|
|
|
public NavigableMap<Long, T> getEvents() {
|
2015-01-06 17:14:16 +01:00
|
|
|
return values;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-01-20 18:50:15 +01:00
|
|
|
public T getWaveformEventsAtTime(Long time) {
|
|
|
|
return values.get(time);
|
2015-01-06 17:14:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|