fix track and relation handling

This commit is contained in:
Eyck Jentzsch 2021-01-04 17:39:11 +01:00
parent 351a246238
commit 0d074ea6ae
10 changed files with 85 additions and 69 deletions

View File

@ -58,12 +58,6 @@ http://www.eclipse.org/legal/epl-v10.html
version="0.0.0"
unpack="false"/>
<plugin
id="org.codehaus.groovy"
download-size="0"
install-size="0"
version="0.0.0"/>
<plugin
id="com.minres.scviewer.database.vcd"
download-size="0"

View File

@ -8,7 +8,8 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Import-Package: org.osgi.framework;version="1.3.0"
Require-Bundle: com.minres.scviewer.database,
org.eclipse.osgi.services;bundle-version="3.4.0",
com.google.guava;bundle-version="15.0.0"
com.google.guava;bundle-version="15.0.0",
org.eclipse.collections;bundle-version="10.4.0"
Service-Component: OSGI-INF/component.xml
Bundle-ActivationPolicy: lazy
Automatic-Module-Name: com.minres.scviewer.database.text

View File

@ -21,7 +21,6 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.zip.GZIPInputStream;
@ -41,8 +40,8 @@ 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.RelationTypeFactory;
import com.minres.scviewer.database.tx.ITx;
import com.minres.scviewer.database.tx.ITxAttributeType;
public class TextDbLoader implements IWaveformDbLoader{
@ -58,7 +57,9 @@ public class TextDbLoader implements IWaveformDbLoader{
BTreeMap<Long, ScvTx> transactions;
BTreeMap<Long[], ScvRelation> relations;
BTreeMap<Long[], ScvRelation> relationsIn;
BTreeMap<Long[], ScvRelation> relationsOut;
BTreeMap<String[], TxAttributeType> attributeTypes;
@ -97,22 +98,27 @@ public class TextDbLoader implements IWaveformDbLoader{
mapDbFile.delete(); // we just need a file name
mapDbFile.deleteOnExit();
mapDb = DBMaker
.fileDB(mapDbFile)
.fileMmapEnableIfSupported()
.fileMmapPreclearDisable()
.memoryDirectDB()
// .fileDB(mapDbFile)
// .fileMmapEnable() // Always enable mmap
// .fileMmapEnableIfSupported()
// .fileMmapPreclearDisable()
.allocateStartSize(512*1024*1024)
.allocateIncrement(128*1024*1024)
.cleanerHackEnable()
.allocateStartSize(64*1024*1024)
.allocateIncrement(64*1024*1024)
.make();
TreeMapSink<Long, ScvTx> txSink = mapDb.treeMap("transactions", Serializer.LONG,Serializer.JAVA).createFromSink();
relations = mapDb
.treeMap("relations", new SerializerArrayTuple(Serializer.LONG, Serializer.LONG) ,Serializer.JAVA)
relationsIn = mapDb
.treeMap("relationsIn", new SerializerArrayTuple(Serializer.LONG, Serializer.LONG) ,Serializer.JAVA)
.createOrOpen();
relationsOut = mapDb
.treeMap("relationsOut", new SerializerArrayTuple(Serializer.LONG, Serializer.LONG) ,Serializer.JAVA)
.createOrOpen();
attributeTypes = mapDb
.treeMap("attributeTypes", new SerializerArrayTuple(Serializer.STRING, Serializer.STRING) ,Serializer.JAVA)
.createOrOpen();
try {
parser.setTransactionSink(txSink).setRelationMap(relations);
parser.setTransactionSink(txSink).setRelationMaps(relationsIn, relationsOut);
parser.parseInput(gzipped?new GZIPInputStream(new FileInputStream(file)):new FileInputStream(file));
} catch(IllegalArgumentException|ArrayIndexOutOfBoundsException e) {
} catch(Exception e) {
@ -176,7 +182,9 @@ public class TextDbLoader implements IWaveformDbLoader{
private TreeMapSink<Long, ScvTx> txSink;
private BTreeMap<Long[], ScvRelation> relations;
private BTreeMap<Long[], ScvRelation> relationsIn;
private BTreeMap<Long[], ScvRelation> relationsOut;
public TextDbParser(TextDbLoader loader) {
super();
@ -188,8 +196,9 @@ public class TextDbLoader implements IWaveformDbLoader{
return this;
}
public TextDbParser setRelationMap(BTreeMap<Long[], ScvRelation> relations) {
this.relations=relations;
public TextDbParser setRelationMaps(BTreeMap<Long[], ScvRelation> relationsIn, BTreeMap<Long[], ScvRelation> relationsOut) {
this.relationsIn=relationsIn;
this.relationsOut=relationsOut;
return this;
}
@ -218,11 +227,11 @@ public class TextDbLoader implements IWaveformDbLoader{
private String parseLine(String curLine, String nextLine) throws IOException{
String[] tokens = curLine.split("\\s+");
if("tx_record_attribute".equals(tokens[0])){//matcher = line =~ /^tx_record_attribute\s+(\d+)\s+"([^"]+)"\s+(\S+)\s*=\s*(.+)$/
if("tx_record_attribute".equals(tokens[0])){
Long id = Long.parseLong(tokens[1]);
String name = tokens[2].substring(1, tokens[2].length());
DataType type = DataType.valueOf(tokens[3]);
String remaining = tokens.length>5?String.join(" ", Arrays.copyOfRange(tokens, 5, tokens.length-1)):"";
String remaining = tokens.length>5?String.join(" ", Arrays.copyOfRange(tokens, 5, tokens.length)):"";
TxAttributeType attrType = getAttrType(name, type, AssociationType.RECORD);
transactionsById.get(id).attributes.add(new TxAttribute(attrType, remaining));
} else if("tx_begin".equals(tokens[0])){
@ -245,7 +254,7 @@ public class TextDbLoader implements IWaveformDbLoader{
}
}
txSink.put(tx.id, tx);
} else if("tx_end".equals(tokens[0])){//matcher = line =~ /^tx_end\s+(\d+)\s+(\d+)\s+(\d+)\s+([munpf]?s)/
} else if("tx_end".equals(tokens[0])){
Long id = Long.parseLong(tokens[1]);
ScvTx tx = transactionsById.get(id);
assert Long.parseLong(tokens[2])==tx.generatorId;
@ -271,14 +280,15 @@ public class TextDbLoader implements IWaveformDbLoader{
}
}
transactionsById.remove(tx.id);
} else if("tx_relation".equals(tokens[0])){//matcher = line =~ /^tx_relation\s+\"(\S+)\"\s+(\d+)\s+(\d+)$/
} else if("tx_relation".equals(tokens[0])){
Long tr2= Long.parseLong(tokens[2]);
Long tr1= Long.parseLong(tokens[3]);
String relType=tokens[1].substring(1, tokens[1].length()-2);
String relType=tokens[1].substring(1, tokens[1].length()-1);
if(!loader.relationTypes.containsKey(relType))
loader.relationTypes.put(relType, RelationType.create(relType));
loader.relationTypes.put(relType, RelationTypeFactory.create(relType));
ScvRelation rel = new ScvRelation(loader.relationTypes.get(relType), tr1, tr2);
relations.put(new Long[]{tr1, tr2}, rel);
relationsOut.put(new Long[]{tr1, tr2}, rel);
relationsIn.put(new Long[]{tr2, tr1}, rel);
} else if("scv_tr_stream".equals(tokens[0])){
Matcher matcher = scv_tr_stream.matcher(curLine);
if (matcher.matches()) {

View File

@ -36,13 +36,13 @@ class Tx implements ITx {
@Override
public Collection<ITxRelation> getIncomingRelations() {
NavigableMap<Long[], ScvRelation> rels = loader.relations.prefixSubMap(new Long[]{scvTx.getId(), null});
NavigableMap<Long[], ScvRelation> rels = loader.relationsIn.prefixSubMap(new Long[]{scvTx.getId()});
return rels.values().stream().map(rel -> new TxRelation(loader, rel)).collect(Collectors.toList());
}
@Override
public Collection<ITxRelation> getOutgoingRelations() {
NavigableMap<Long[], ScvRelation> rels = loader.relations.prefixSubMap(new Long[]{null, scvTx.getId()});
NavigableMap<Long[], ScvRelation> rels = loader.relationsOut.prefixSubMap(new Long[]{scvTx.getId()});
return rels.values().stream().map(rel -> new TxRelation(loader, rel)).collect(Collectors.toList());
}

View File

@ -36,7 +36,7 @@ public class TxAttribute implements ITxAttribute, Serializable {
switch(type.getDataType()){
case STRING:
case ENUMERATION:
this.value=value.substring(1, value.length()-2);
this.value=value.substring(1, value.length()-1);
break;
default:
this.value=value;

View File

@ -167,7 +167,8 @@ public class StreamPainter extends TrackPainter{
for(IEvent evt:firstTx.getValue()){
if(evt instanceof ITxEvent) {
ITx tx=((ITxEvent)evt).getTransaction();
if(evt.getKind()==EventKind.BEGIN && tx.getConcurrencyIndex()==lane && tx.getBeginTime()<=timePoint && tx.getEndTime()>=timePoint){
if((evt.getKind()==EventKind.BEGIN || evt.getKind()==EventKind.SINGLE)&&
tx.getConcurrencyIndex()==lane && tx.getBeginTime()<=timePoint && tx.getEndTime()>=timePoint){
return ((ITxEvent)evt).getTransaction();
}
}
@ -178,7 +179,8 @@ public class StreamPainter extends TrackPainter{
for(IEvent evt:firstTx.getValue()){
if(evt instanceof ITxEvent) {
ITx tx=((ITxEvent)evt).getTransaction();
if(evt.getKind()==EventKind.BEGIN && tx.getConcurrencyIndex()==lane && tx.getBeginTime()<=timePointHigh && tx.getEndTime()>=timePoint){
if((evt.getKind()==EventKind.BEGIN || evt.getKind()==EventKind.SINGLE) &&
tx.getConcurrencyIndex()==lane && tx.getBeginTime()<=timePointHigh && tx.getEndTime()>=timePoint){
return ((ITxEvent)evt).getTransaction();
}
}

View File

@ -575,7 +575,7 @@ public class WaveformView implements IWaveformView {
for(IEvent evt:firstTx.getValue()){
if(evt instanceof ITxEvent) {
ITx tx=((ITxEvent)evt).getTransaction();
if(evt.getKind()==EventKind.BEGIN && tx.getBeginTime()<=time && tx.getEndTime()>=time){
if((evt.getKind()==EventKind.BEGIN || evt.getKind()==EventKind.SINGLE) && tx.getBeginTime()<=time && tx.getEndTime()>=time){
if(resultsList[tx.getConcurrencyIndex()]==null)
resultsList[tx.getConcurrencyIndex()]= ((ITxEvent)evt).getTransaction();
}
@ -703,7 +703,7 @@ public class WaveformView implements IWaveformView {
} else {
if(!add) currentWaveformSelection.clear();
for(Object sel:((IStructuredSelection) selection).toArray()){
if (sel instanceof ITx && currentTxSelection != sel){
if (sel instanceof ITx){
ITx txSel = (ITx) sel;
TrackEntry trackEntry = getEntryForStream(txSel.getStream());
if(trackEntry==null && addIfNeeded){
@ -711,6 +711,8 @@ public class WaveformView implements IWaveformView {
streams.add(trackEntry);
}
currentTxSelection = txSel;
currentWaveformSelection.clear();
currentWaveformSelection.add(trackEntry);
selectionChanged = true;
} else if (sel instanceof TrackEntry && !currentWaveformSelection.contains(sel)) {
currentWaveformSelection.add((TrackEntry)sel);
@ -769,32 +771,29 @@ public class WaveformView implements IWaveformView {
*/
@Override
public void moveSelection(GotoDirection direction, RelationType relationType) {
TrackEntry selectedWaveform=null;
if(currentTxSelection!=null)
selectedWaveform = getEntryForStream(currentTxSelection.getStream());
else if(currentWaveformSelection.size()!=1) return;
if(selectedWaveform==null)
selectedWaveform = currentWaveformSelection.get(1);
if (selectedWaveform!=null && selectedWaveform.waveform.getType()==WaveformType.TRANSACTION && currentTxSelection!=null) {
if(currentWaveformSelection.size() !=1 && currentTxSelection==null) return;
TrackEntry selectedWaveform=currentWaveformSelection.size() == 1?
currentWaveformSelection.get(0) : getEntryForStream(currentTxSelection.getStream());
if(selectedWaveform.waveform.getType()==WaveformType.TRANSACTION && currentTxSelection!=null) {
if(relationType.equals(IWaveformView.NEXT_PREV_IN_STREAM)){
ITx transaction = null;
if (direction == GotoDirection.NEXT) {
ITxEvent[] thisEntryList = (ITxEvent[]) selectedWaveform.waveform.getEvents().get(currentTxSelection.getBeginTime());
IEvent[] eventsList = selectedWaveform.waveform.getEvents().get(currentTxSelection.getBeginTime());
boolean meFound=false;
for (ITxEvent evt : thisEntryList) {
if (evt.getKind() == EventKind.BEGIN) {
for (IEvent evt : eventsList) {
if (evt instanceof ITxEvent && evt.getKind() == EventKind.BEGIN || evt.getKind()==EventKind.SINGLE) {
if(meFound){
transaction = evt.getTransaction();
transaction = ((ITxEvent)evt).getTransaction();
break;
}
meFound|= evt.getTransaction().equals(currentTxSelection);
meFound|= ((ITxEvent)evt).getTransaction().equals(currentTxSelection);
}
}
if (transaction == null){
Entry<Long, IEvent[]> entry = selectedWaveform.waveform.getEvents().higherEntry(currentTxSelection.getBeginTime());
if (entry != null) do {
for (IEvent evt : entry.getValue()) {
if (evt instanceof ITxEvent && evt.getKind() == EventKind.BEGIN) {
if (evt instanceof ITxEvent && (evt.getKind() == EventKind.BEGIN || evt.getKind()==EventKind.SINGLE)) {
transaction = ((ITxEvent)evt).getTransaction();
break;
}
@ -804,10 +803,10 @@ public class WaveformView implements IWaveformView {
} while (entry != null && transaction == null);
}
} else if (direction == GotoDirection.PREV) {
IEvent[] thisEntryList = selectedWaveform.waveform.getEvents().get(currentTxSelection.getBeginTime());
IEvent[] eventsList = selectedWaveform.waveform.getEvents().get(currentTxSelection.getBeginTime());
boolean meFound=false;
for (IEvent evt : Lists.reverse(Arrays.asList(thisEntryList))) {
if (evt instanceof ITxEvent && evt.getKind() == EventKind.BEGIN) {
for (IEvent evt : Lists.reverse(Arrays.asList(eventsList))) {
if (evt instanceof ITxEvent && (evt.getKind() == EventKind.BEGIN || evt.getKind()==EventKind.SINGLE)) {
if(meFound){
transaction = ((ITxEvent)evt).getTransaction();
break;
@ -817,31 +816,33 @@ public class WaveformView implements IWaveformView {
}
if (transaction == null){
Entry<Long, IEvent[]> entry = selectedWaveform.waveform.getEvents().lowerEntry(currentTxSelection.getBeginTime());
if (entry != null)
do {
for (IEvent evt : Lists.reverse(Arrays.asList(thisEntryList))) {
if (evt instanceof ITxEvent && evt.getKind() == EventKind.BEGIN) {
transaction = ((ITxEvent)evt).getTransaction();
break;
}
if (entry != null) do {
for (IEvent evt : Lists.reverse(Arrays.asList(entry.getValue()))) {
if (evt instanceof ITxEvent && (evt.getKind() == EventKind.BEGIN || evt.getKind()==EventKind.SINGLE)) {
transaction = ((ITxEvent)evt).getTransaction();
break;
}
if (transaction == null)
entry = selectedWaveform.waveform.getEvents().lowerEntry(entry.getKey());
} while (entry != null && transaction == null);
}
if (transaction == null)
entry = selectedWaveform.waveform.getEvents().lowerEntry(entry.getKey());
} while (entry != null && transaction == null);
}
}
if (transaction != null) {
setSelection(new StructuredSelection(transaction));
}
} else {
ITxRelation tx = null;
if (direction == GotoDirection.NEXT) {
Collection<ITxRelation> outRel=currentTxSelection.getOutgoingRelations();
ITxRelation tx = selectTxToNavigateTo(outRel, relationType, true);
if(tx!=null) setSelection(new StructuredSelection(tx.getTarget()), true);
tx = selectTxToNavigateTo(outRel, relationType, true);
if(tx!=null)
setSelection(new StructuredSelection(tx.getTarget()), true);
} else if (direction == GotoDirection.PREV) {
Collection<ITxRelation> inRel=currentTxSelection.getIncomingRelations();
ITxRelation tx = selectTxToNavigateTo(inRel, relationType, false);
if(tx!=null) setSelection(new StructuredSelection(tx.getSource()), true);
tx = selectTxToNavigateTo(inRel, relationType, false);
if(tx!=null)
setSelection(new StructuredSelection(tx.getSource()), true);
}
}
}

View File

@ -17,7 +17,6 @@ import java.util.TreeMap;
import com.minres.scviewer.database.HierNode;
import com.minres.scviewer.database.IEvent;
import com.minres.scviewer.database.IWaveform;
import com.minres.scviewer.database.IWaveformDb;
import com.minres.scviewer.database.WaveformType;
public class VCDSignal<T extends IEvent> extends HierNode implements IWaveform {

View File

@ -250,7 +250,7 @@ public class TransactionList extends Composite {
if(trackEntry==null || trackEntry.waveform.getType()!=WaveformType.TRANSACTION) {
attrNames.clear();
tableViewer.setInput(emptyList);
} else {
} else if(stream != trackEntry.waveform) {
stream=trackEntry.waveform;
tableViewer.setInput(emptyList);
new Thread() {
@ -267,7 +267,7 @@ public class TransactionList extends Composite {
Collection<IEvent[]> values = stream.getEvents().values();
eventList = values.parallelStream().map(Arrays::asList)
.flatMap(List::stream)
.filter(evt -> evt.getKind()==EventKind.BEGIN)
.filter(evt -> evt.getKind()==EventKind.BEGIN || evt.getKind()==EventKind.SINGLE)
.map(evt-> {
ITx tx = ((ITxEvent)evt).getTransaction();
for(ITxAttribute attr: tx.getAttributes()) {
@ -287,7 +287,8 @@ public class TransactionList extends Composite {
txFilter.setSearchProp(attrNames.get(0).getName(), attrNames.get(0).getType());
if (searchPropComboViewer!=null) {
searchPropComboViewer.setInput(attrNames);
searchPropComboViewer.setSelection(new StructuredSelection(searchPropComboViewer.getElementAt(0)));
Object sel = searchPropComboViewer.getElementAt(0);
if(sel!=null) searchPropComboViewer.setSelection(new StructuredSelection(sel));
}
tableViewer.refresh(true);
}

View File

@ -2,3 +2,11 @@
/.my_db.txlog*
/EyeQ6_mem_platform.txlog
/EyeQ6_mem_platform.vcd
/hw_cfg7.txlog
/hw_cfg7.vcd
/hw_cfg_2_gen.txlog
/hw_cfg_2_gen.vcd
/hw_cfg_2_nc.txlog
/hw_cfg_2_nc.vcd
/test_05.txlog
/test_05.vcd