Added support for VCD Database

This commit is contained in:
Eyck Jentzsch 2015-01-06 17:14:16 +01:00
parent a76c99dfb9
commit de28761ce0
89 changed files with 402236 additions and 539 deletions

View File

@ -12,3 +12,5 @@ Require-Bundle: com.minres.scviewer.database;bundle-version="1.0.0",
Bundle-ClassPath: ., Bundle-ClassPath: .,
sqlite-jdbc-3.8.7.jar sqlite-jdbc-3.8.7.jar
Service-Component: OSGI-INF/component.xml Service-Component: OSGI-INF/component.xml
Export-Package: com.minres.scviewer.database.sqlite
Bundle-ActivationPolicy: lazy

View File

@ -2,6 +2,6 @@
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="SQLiteDbFactory"> <scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="SQLiteDbFactory">
<implementation class="com.minres.scviewer.database.sqlite.SQLiteDbFactory"/> <implementation class="com.minres.scviewer.database.sqlite.SQLiteDbFactory"/>
<service> <service>
<provide interface="com.minres.scviewer.database.ITransactionDbFactory"/> <provide interface="com.minres.scviewer.database.IWaveformDbFactory"/>
</service> </service>
</scr:component> </scr:component>

View File

@ -9,23 +9,25 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import com.minres.scviewer.database.EventTime; import com.minres.scviewer.database.EventTime;
import com.minres.scviewer.database.ITrAttribute; import com.minres.scviewer.database.HierNode;
import com.minres.scviewer.database.ITrDb; import com.minres.scviewer.database.IWaveformDb;
import com.minres.scviewer.database.ITrHierNode; import com.minres.scviewer.database.IHierNode;
import com.minres.scviewer.database.ITrStream; import com.minres.scviewer.database.ITxStream;
import com.minres.scviewer.database.IWaveform;
import com.minres.scviewer.database.InputFormatException; import com.minres.scviewer.database.InputFormatException;
import com.minres.scviewer.database.RelationType; import com.minres.scviewer.database.RelationType;
import com.minres.scviewer.database.sqlite.db.IDatabase; import com.minres.scviewer.database.sqlite.db.IDatabase;
import com.minres.scviewer.database.sqlite.db.SQLiteDatabase;
import com.minres.scviewer.database.sqlite.db.SQLiteDatabaseSelectHandler; import com.minres.scviewer.database.sqlite.db.SQLiteDatabaseSelectHandler;
import com.minres.scviewer.database.sqlite.tables.ScvSimProps; import com.minres.scviewer.database.sqlite.tables.ScvSimProps;
import com.minres.scviewer.database.sqlite.tables.ScvStream; import com.minres.scviewer.database.sqlite.tables.ScvStream;
import com.minres.scviewer.database.sqlite.tables.ScvTxEvent; import com.minres.scviewer.database.sqlite.tables.ScvTxEvent;
public class SQLiteDb extends HierNode implements ITrDb { public class SQLiteDb extends HierNode implements IWaveformDb {
protected IDatabase database; protected IDatabase database;
protected List<ITrStream> streams; protected List<IWaveform> streams;
long timeResolution=1; long timeResolution=1;
@ -55,13 +57,13 @@ public class SQLiteDb extends HierNode implements ITrDb {
} }
@Override @Override
public List<ITrStream> getAllStreams() { public List<IWaveform> getAllWaves() {
if(streams==null){ if(streams==null){
SQLiteDatabaseSelectHandler<ScvStream> handler = new SQLiteDatabaseSelectHandler<ScvStream>(ScvStream.class, database); SQLiteDatabaseSelectHandler<ScvStream> handler = new SQLiteDatabaseSelectHandler<ScvStream>(ScvStream.class, database);
streams=new ArrayList<ITrStream>(); streams=new ArrayList<IWaveform>();
try { try {
for(ScvStream scvStream:handler.selectObjects()){ for(ScvStream scvStream:handler.selectObjects()){
streams.add(new Stream(this, scvStream)); streams.add(new TxStream(this, scvStream));
} }
} catch (SecurityException | IllegalArgumentException | InstantiationException | IllegalAccessException } catch (SecurityException | IllegalArgumentException | InstantiationException | IllegalAccessException
| InvocationTargetException | SQLException | IntrospectionException e) { | InvocationTargetException | SQLException | IntrospectionException e) {
@ -83,7 +85,7 @@ public class SQLiteDb extends HierNode implements ITrDb {
| InvocationTargetException | SQLException | IntrospectionException e) { | InvocationTargetException | SQLException | IntrospectionException e) {
e.printStackTrace(); e.printStackTrace();
} }
addHierarchyNodes(); buildHierarchyNodes();
} }
@Override @Override
@ -92,31 +94,27 @@ public class SQLiteDb extends HierNode implements ITrDb {
} }
@Override @Override
public ITrStream getStreamByName(String name) { public IWaveform getStreamByName(String name) {
for (ITrStream n : getAllStreams()) { for (IWaveform n : getAllWaves())
if (n.getName().equals(name)) { if (n.getName().equals(name))
return n; return n;
}
}
return null; return null;
} }
public ITrStream getStreamById(long id) { public ITxStream getStreamById(long id) {
for (ITrStream n : getAllStreams()) { for (IWaveform n : getAllWaves())
if (n.getId().equals(id)) { if (n.getId().equals(id))
return n; return (ITxStream) n;
}
}
return null; return null;
} }
private void addHierarchyNodes() throws InputFormatException{ private void buildHierarchyNodes() throws InputFormatException{
for(ITrStream stream:getAllStreams()){ for(IWaveform stream:getAllWaves()){
String[] hier = stream.getFullName().split("\\./"); String[] hier = stream.getFullName().split("\\./");
ITrHierNode node = this; IHierNode node = this;
for(String name:hier){ for(String name:hier){
ITrHierNode n1 = null; IHierNode n1 = null;
for (ITrHierNode n : node.getChildNodes()) { for (IHierNode n : node.getChildNodes()) {
if (n.getName().equals(name)) { if (n.getName().equals(name)) {
n1=n; n1=n;
break; break;

View File

@ -3,10 +3,10 @@ package com.minres.scviewer.database.sqlite;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import com.minres.scviewer.database.ITrDb; import com.minres.scviewer.database.IWaveformDb;
import com.minres.scviewer.database.ITransactionDbFactory; import com.minres.scviewer.database.IWaveformDbFactory;
public class SQLiteDbFactory implements ITransactionDbFactory { public class SQLiteDbFactory implements IWaveformDbFactory {
private byte[] x = "SQLite format 3".getBytes(); private byte[] x = "SQLite format 3".getBytes();
@ -14,7 +14,7 @@ public class SQLiteDbFactory implements ITransactionDbFactory {
} }
@Override @Override
public ITrDb createDatabase(File file) { public IWaveformDb createDatabase(File file) {
try { try {
FileInputStream fis = new FileInputStream(file); FileInputStream fis = new FileInputStream(file);
byte[] buffer = new byte[x.length]; byte[] buffer = new byte[x.length];

View File

@ -9,27 +9,27 @@ import java.util.List;
import com.minres.scviewer.database.AssociationType; import com.minres.scviewer.database.AssociationType;
import com.minres.scviewer.database.EventTime; import com.minres.scviewer.database.EventTime;
import com.minres.scviewer.database.ITrAttribute; import com.minres.scviewer.database.ITxAttribute;
import com.minres.scviewer.database.ITrGenerator; import com.minres.scviewer.database.ITxGenerator;
import com.minres.scviewer.database.ITrRelation; import com.minres.scviewer.database.ITxRelation;
import com.minres.scviewer.database.ITrStream; import com.minres.scviewer.database.ITxStream;
import com.minres.scviewer.database.ITransaction; import com.minres.scviewer.database.ITx;
import com.minres.scviewer.database.sqlite.db.SQLiteDatabaseSelectHandler; import com.minres.scviewer.database.sqlite.db.SQLiteDatabaseSelectHandler;
import com.minres.scviewer.database.sqlite.tables.ScvTx; import com.minres.scviewer.database.sqlite.tables.ScvTx;
import com.minres.scviewer.database.sqlite.tables.ScvTxAttribute; import com.minres.scviewer.database.sqlite.tables.ScvTxAttribute;
import com.minres.scviewer.database.sqlite.tables.ScvTxEvent; import com.minres.scviewer.database.sqlite.tables.ScvTxEvent;
import com.minres.scviewer.database.sqlite.tables.ScvTxRelation; import com.minres.scviewer.database.sqlite.tables.ScvTxRelation;
public class Transaction implements ITransaction { public class Tx implements ITx {
private Stream trStream; private TxStream trStream;
private Generator trGenerator; private TxGenerator trGenerator;
private ScvTx scvTx; private ScvTx scvTx;
private List<ITrAttribute> attributes; private List<ITxAttribute> attributes;
private EventTime begin, end; private EventTime begin, end;
private List<ITrRelation> incoming, outgoing; private List<ITxRelation> incoming, outgoing;
public Transaction(Stream trStream, Generator trGenerator, ScvTx scvTx) { public Tx(TxStream trStream, TxGenerator trGenerator, ScvTx scvTx) {
this.trStream=trStream; this.trStream=trStream;
this.trGenerator=trGenerator; this.trGenerator=trGenerator;
this.scvTx=scvTx; this.scvTx=scvTx;
@ -41,12 +41,12 @@ public class Transaction implements ITransaction {
} }
@Override @Override
public ITrStream getStream() { public ITxStream getStream() {
return trStream; return trStream;
} }
@Override @Override
public ITrGenerator getGenerator() { public ITxGenerator getGenerator() {
return trGenerator; return trGenerator;
} }
@ -83,14 +83,14 @@ public class Transaction implements ITransaction {
} }
@Override @Override
public List<ITrAttribute> getAttributes() { public List<ITxAttribute> getAttributes() {
if(attributes==null){ if(attributes==null){
SQLiteDatabaseSelectHandler<ScvTxAttribute> handler = new SQLiteDatabaseSelectHandler<ScvTxAttribute>( SQLiteDatabaseSelectHandler<ScvTxAttribute> handler = new SQLiteDatabaseSelectHandler<ScvTxAttribute>(
ScvTxAttribute.class, trStream.getDb().getDb(), "tx="+scvTx.getId()); ScvTxAttribute.class, trStream.getDb().getDb(), "tx="+scvTx.getId());
try { try {
attributes = new ArrayList<ITrAttribute>(); attributes = new ArrayList<ITxAttribute>();
for(ScvTxAttribute scvAttribute:handler.selectObjects()){ for(ScvTxAttribute scvAttribute:handler.selectObjects()){
attributes.add(new Attribute(this, scvAttribute)); attributes.add(new TxAttribute(this, scvAttribute));
} }
} catch (SecurityException | IllegalArgumentException | InstantiationException | IllegalAccessException } catch (SecurityException | IllegalArgumentException | InstantiationException | IllegalAccessException
@ -101,12 +101,12 @@ public class Transaction implements ITransaction {
} }
@Override @Override
public Collection<ITrRelation> getIncomingRelations() { public Collection<ITxRelation> getIncomingRelations() {
if(incoming==null){ if(incoming==null){
SQLiteDatabaseSelectHandler<ScvTxRelation> handler = new SQLiteDatabaseSelectHandler<ScvTxRelation>( SQLiteDatabaseSelectHandler<ScvTxRelation> handler = new SQLiteDatabaseSelectHandler<ScvTxRelation>(
ScvTxRelation.class, trStream.getDb().getDb(), "sink="+scvTx.getId()); ScvTxRelation.class, trStream.getDb().getDb(), "sink="+scvTx.getId());
try { try {
incoming = new ArrayList<ITrRelation>(); incoming = new ArrayList<ITxRelation>();
for(ScvTxRelation scvRelation:handler.selectObjects()){ for(ScvTxRelation scvRelation:handler.selectObjects()){
incoming.add(createRelation(scvRelation, false)); incoming.add(createRelation(scvRelation, false));
} }
@ -118,12 +118,12 @@ public class Transaction implements ITransaction {
} }
@Override @Override
public Collection<ITrRelation> getOutgoingRelations() { public Collection<ITxRelation> getOutgoingRelations() {
if(outgoing==null){ if(outgoing==null){
SQLiteDatabaseSelectHandler<ScvTxRelation> handler = new SQLiteDatabaseSelectHandler<ScvTxRelation>( SQLiteDatabaseSelectHandler<ScvTxRelation> handler = new SQLiteDatabaseSelectHandler<ScvTxRelation>(
ScvTxRelation.class, trStream.getDb().getDb(), "src="+scvTx.getId()); ScvTxRelation.class, trStream.getDb().getDb(), "src="+scvTx.getId());
try { try {
outgoing = new ArrayList<ITrRelation>(); outgoing = new ArrayList<ITxRelation>();
for(ScvTxRelation scvRelation:handler.selectObjects()){ for(ScvTxRelation scvRelation:handler.selectObjects()){
outgoing.add(createRelation(scvRelation, true)); outgoing.add(createRelation(scvRelation, true));
} }
@ -134,17 +134,17 @@ public class Transaction implements ITransaction {
return outgoing; return outgoing;
} }
private ITrRelation createRelation(ScvTxRelation rel, boolean outgoing) { private ITxRelation createRelation(ScvTxRelation rel, boolean outgoing) {
long otherId = outgoing?rel.getSink():rel.getSrc(); long otherId = outgoing?rel.getSink():rel.getSrc();
try { try {
List<ScvTx> scvTx=new SQLiteDatabaseSelectHandler<ScvTx>(ScvTx.class, trStream.getDb().getDb(), "id="+otherId).selectObjects(); List<ScvTx> scvTx=new SQLiteDatabaseSelectHandler<ScvTx>(ScvTx.class, trStream.getDb().getDb(), "id="+otherId).selectObjects();
assert(scvTx.size()==1); assert(scvTx.size()==1);
ITrStream stream = trStream.getDb().getStreamById(scvTx.get(0).getStream()); ITxStream stream = trStream.getDb().getStreamById(scvTx.get(0).getStream());
Transaction that=(Transaction) stream.getTransactionById(otherId); Tx that=(Tx) stream.getTransactionById(otherId);
if(outgoing) if(outgoing)
return new Relation(trStream.getDb().getRelationType(rel.getName()), this, that); return new TxRelation(trStream.getDb().getRelationType(rel.getName()), this, that);
else else
return new Relation(trStream.getDb().getRelationType(rel.getName()), that, this); return new TxRelation(trStream.getDb().getRelationType(rel.getName()), that, this);
} catch (SecurityException | IllegalArgumentException | InstantiationException | IllegalAccessException } catch (SecurityException | IllegalArgumentException | InstantiationException | IllegalAccessException
| InvocationTargetException | SQLException | IntrospectionException e) { | InvocationTargetException | SQLException | IntrospectionException e) {
} }

View File

@ -2,15 +2,15 @@ package com.minres.scviewer.database.sqlite;
import com.minres.scviewer.database.AssociationType; import com.minres.scviewer.database.AssociationType;
import com.minres.scviewer.database.DataType; import com.minres.scviewer.database.DataType;
import com.minres.scviewer.database.ITrAttribute; import com.minres.scviewer.database.ITxAttribute;
import com.minres.scviewer.database.sqlite.tables.ScvTxAttribute; import com.minres.scviewer.database.sqlite.tables.ScvTxAttribute;
public class Attribute implements ITrAttribute{ public class TxAttribute implements ITxAttribute{
Transaction trTransaction; Tx trTransaction;
ScvTxAttribute scvAttribute; ScvTxAttribute scvAttribute;
public Attribute(Transaction trTransaction, ScvTxAttribute scvAttribute) { public TxAttribute(Tx trTransaction, ScvTxAttribute scvAttribute) {
this.trTransaction=trTransaction; this.trTransaction=trTransaction;
this.scvAttribute=scvAttribute; this.scvAttribute=scvAttribute;
} }

View File

@ -2,16 +2,16 @@ package com.minres.scviewer.database.sqlite;
import java.util.List; import java.util.List;
import com.minres.scviewer.database.ITrGenerator; import com.minres.scviewer.database.ITxGenerator;
import com.minres.scviewer.database.ITrStream; import com.minres.scviewer.database.ITxStream;
import com.minres.scviewer.database.ITransaction; import com.minres.scviewer.database.ITx;
import com.minres.scviewer.database.sqlite.tables.ScvGenerator; import com.minres.scviewer.database.sqlite.tables.ScvGenerator;
public class Generator implements ITrGenerator { public class TxGenerator implements ITxGenerator {
private ITrStream stream; private ITxStream stream;
private ScvGenerator scvGenerator; private ScvGenerator scvGenerator;
public Generator(ITrStream stream, ScvGenerator scvGenerator) { public TxGenerator(ITxStream stream, ScvGenerator scvGenerator) {
this.stream=stream; this.stream=stream;
this.scvGenerator=scvGenerator; this.scvGenerator=scvGenerator;
} }
@ -22,7 +22,7 @@ public class Generator implements ITrGenerator {
} }
@Override @Override
public ITrStream getStream() { public ITxStream getStream() {
return stream; return stream;
} }
@ -32,7 +32,7 @@ public class Generator implements ITrGenerator {
} }
@Override @Override
public List<ITransaction> getTransactions() { public List<ITx> getTransactions() {
return null; return null;
} }

View File

@ -1,15 +1,15 @@
package com.minres.scviewer.database.sqlite; package com.minres.scviewer.database.sqlite;
import com.minres.scviewer.database.ITrRelation; import com.minres.scviewer.database.ITxRelation;
import com.minres.scviewer.database.ITransaction; import com.minres.scviewer.database.ITx;
import com.minres.scviewer.database.RelationType; import com.minres.scviewer.database.RelationType;
public class Relation implements ITrRelation { public class TxRelation implements ITxRelation {
RelationType relationType; RelationType relationType;
Transaction source, target; Tx source, target;
public Relation(RelationType relationType, Transaction source, Transaction target) { public TxRelation(RelationType relationType, Tx source, Tx target) {
this.source = source; this.source = source;
this.target = target; this.target = target;
this.relationType = relationType; this.relationType = relationType;
@ -21,12 +21,12 @@ public class Relation implements ITrRelation {
} }
@Override @Override
public ITransaction getSource() { public ITx getSource() {
return source; return source;
} }
@Override @Override
public ITransaction getTarget() { public ITx getTarget() {
return target; return target;
} }

View File

@ -4,29 +4,31 @@ import java.beans.IntrospectionException;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import com.minres.scviewer.database.ITrDb; import com.minres.scviewer.database.HierNode;
import com.minres.scviewer.database.ITrGenerator; import com.minres.scviewer.database.ITxGenerator;
import com.minres.scviewer.database.ITrStream; import com.minres.scviewer.database.ITxStream;
import com.minres.scviewer.database.ITransaction; import com.minres.scviewer.database.ITx;
import com.minres.scviewer.database.sqlite.db.SQLiteDatabaseSelectHandler; import com.minres.scviewer.database.sqlite.db.SQLiteDatabaseSelectHandler;
import com.minres.scviewer.database.sqlite.tables.ScvGenerator; import com.minres.scviewer.database.sqlite.tables.ScvGenerator;
import com.minres.scviewer.database.sqlite.tables.ScvStream; import com.minres.scviewer.database.sqlite.tables.ScvStream;
import com.minres.scviewer.database.sqlite.tables.ScvTx; import com.minres.scviewer.database.sqlite.tables.ScvTx;
public class Stream extends HierNode implements ITrStream { public class TxStream extends HierNode implements ITxStream {
private String fullName; private String fullName;
private SQLiteDb db; private SQLiteDb db;
private ScvStream scvStream; private ScvStream scvStream;
private HashMap<Integer, Generator> generators;
private List<ITransaction> transactions; private HashMap<Integer, TxGenerator> generators;
public Stream(SQLiteDb trSQLiteDb, ScvStream scvStream) { private List<ITx> transactions;
public TxStream(SQLiteDb trSQLiteDb, ScvStream scvStream) {
super(scvStream.getName()); super(scvStream.getName());
fullName=scvStream.getName(); fullName=scvStream.getName();
this.scvStream=scvStream; this.scvStream=scvStream;
@ -54,33 +56,33 @@ public class Stream extends HierNode implements ITrStream {
} }
@Override @Override
public List<ITrGenerator> getGenerators() { public List<ITxGenerator> getGenerators() {
if(generators==null){ if(generators==null){
SQLiteDatabaseSelectHandler<ScvGenerator> handler = new SQLiteDatabaseSelectHandler<ScvGenerator>( SQLiteDatabaseSelectHandler<ScvGenerator> handler = new SQLiteDatabaseSelectHandler<ScvGenerator>(
ScvGenerator.class, db.getDb(), "stream="+scvStream.getId()); ScvGenerator.class, db.getDb(), "stream="+scvStream.getId());
generators=new HashMap<Integer, Generator>(); generators=new HashMap<Integer, TxGenerator>();
try { try {
for(ScvGenerator scvGenerator:handler.selectObjects()){ for(ScvGenerator scvGenerator:handler.selectObjects()){
generators.put(scvGenerator.getId(), new Generator(this, scvGenerator)); generators.put(scvGenerator.getId(), new TxGenerator(this, scvGenerator));
} }
} catch (SecurityException | IllegalArgumentException | InstantiationException | IllegalAccessException } catch (SecurityException | IllegalArgumentException | InstantiationException | IllegalAccessException
| InvocationTargetException | SQLException | IntrospectionException e) { | InvocationTargetException | SQLException | IntrospectionException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
return new ArrayList<ITrGenerator>(generators.values()); return new ArrayList<ITxGenerator>(generators.values());
} }
@Override @Override
public List<ITransaction> getTransactions() { public List<ITx> getTransactions() {
checkTransactions(); checkTransactions();
return transactions; return transactions;
} }
@Override @Override
public ITransaction getTransactionById(long id) { public ITx getTransactionById(long id) {
checkTransactions(); checkTransactions();
for(ITransaction trans:transactions){ for(ITx trans:transactions){
if(trans.getId()==id) if(trans.getId()==id)
return trans; return trans;
} }
@ -92,10 +94,10 @@ public class Stream extends HierNode implements ITrStream {
if(generators==null) getGenerators(); if(generators==null) getGenerators();
SQLiteDatabaseSelectHandler<ScvTx> handler = new SQLiteDatabaseSelectHandler<ScvTx>(ScvTx.class, db.getDb(), SQLiteDatabaseSelectHandler<ScvTx> handler = new SQLiteDatabaseSelectHandler<ScvTx>(ScvTx.class, db.getDb(),
"stream="+scvStream.getId()); "stream="+scvStream.getId());
transactions=new ArrayList<ITransaction>(); transactions=new ArrayList<ITx>();
try { try {
for(ScvTx scvTx:handler.selectObjects()){ for(ScvTx scvTx:handler.selectObjects()){
transactions.add(new Transaction(this, generators.get(scvTx.getGenerator()), scvTx)); transactions.add(new Tx(this, generators.get(scvTx.getGenerator()), scvTx));
} }
} catch (SecurityException | IllegalArgumentException | InstantiationException | IllegalAccessException } catch (SecurityException | IllegalArgumentException | InstantiationException | IllegalAccessException
| InvocationTargetException | SQLException | IntrospectionException e) { | InvocationTargetException | SQLException | IntrospectionException e) {

View File

@ -1,4 +1,4 @@
package com.minres.scviewer.database.sqlite; package com.minres.scviewer.database.sqlite.db;
import java.sql.Connection; import java.sql.Connection;
import java.sql.DriverManager; import java.sql.DriverManager;
@ -7,8 +7,6 @@ import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Statement; import java.sql.Statement;
import com.minres.scviewer.database.sqlite.db.IDatabase;
public class SQLiteDatabase implements IDatabase { public class SQLiteDatabase implements IDatabase {
protected String dbFileName; protected String dbFileName;

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -0,0 +1 @@
/bin/

View File

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.minres.scviewer.database.test</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ds.core.builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding//src/com/minres/scviewer/database/test/DatabaseServicesTest.java=UTF-8

View File

@ -0,0 +1,7 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.7

View File

@ -0,0 +1,3 @@
eclipse.preferences.version=1
pluginProject.extensions=false
resolve.requirebundle=false

View File

@ -0,0 +1,11 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: SCViewer database tests
Bundle-SymbolicName: com.minres.scviewer.database.test
Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: MINRES Technologies GnbH
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Require-Bundle: org.junit,
com.minres.scviewer.database
Service-Component: OSGI-INF/component.xml
Bundle-ActivationPolicy: lazy

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="com.minres.scviewer.database.test">
<implementation class="com.minres.scviewer.database.test.DatabaseServicesTest"/>
<reference bind="bind" cardinality="1..n" interface="com.minres.scviewer.database.IWaveformDbFactory" name="IWaveformDbFactory" policy="dynamic" unbind="unbind"/>
</scr:component>

View File

@ -0,0 +1,5 @@
output.. = bin/
bin.includes = META-INF/,\
.,\
OSGI-INF/component.xml
source.. = src/

Binary file not shown.

View File

@ -0,0 +1,254 @@
scv_tr_stream (ID 1, name "pipelined_stream", kind "transactor")
scv_tr_stream (ID 2, name "addr_stream", kind "transactor")
scv_tr_stream (ID 3, name "data_stream", kind "transactor")
scv_tr_generator (ID 4, name "read", scv_tr_stream 1,
begin_attribute (ID 0, name "addr", type "UNSIGNED")
end_attribute (ID 1, name "data", type "UNSIGNED")
)
scv_tr_generator (ID 5, name "write", scv_tr_stream 1,
begin_attribute (ID 0, name "addr", type "UNSIGNED")
end_attribute (ID 1, name "data", type "UNSIGNED")
)
scv_tr_generator (ID 6, name "addr", scv_tr_stream 2,
begin_attribute (ID 0, name "addr", type "UNSIGNED")
)
scv_tr_generator (ID 7, name "rdata", scv_tr_stream 3,
end_attribute (ID 0, name "data", type "UNSIGNED")
)
scv_tr_generator (ID 8, name "wdata", scv_tr_stream 3,
begin_attribute (ID 0, name "data", type "UNSIGNED")
)
tx_begin 1 4 0 s
a 0
tx_record_attribute 1 "data_size" UNSIGNED = 24
tx_begin 2 6 0 s
a 0
tx_relation "addr_phase" 2 1
tx_end 2 6 180 ns
tx_begin 3 7 180 ns
tx_relation "data_phase" 3 1
tx_begin 4 4 180 ns
a 0
tx_record_attribute 4 "data_size" UNSIGNED = 24
tx_begin 5 6 180 ns
a 0
tx_relation "addr_phase" 5 4
tx_end 5 6 300 ns
tx_end 3 7 420 ns
a 0
tx_end 1 4 420 ns
a 0
tx_begin 6 4 420 ns
a 1
tx_record_attribute 6 "data_size" UNSIGNED = 24
tx_begin 7 6 420 ns
a 1
tx_relation "addr_phase" 7 6
tx_begin 8 7 420 ns
tx_relation "data_phase" 8 4
tx_end 7 6 480 ns
tx_end 8 7 620 ns
a 0
tx_end 4 4 620 ns
a 0
tx_begin 9 4 620 ns
a 1
tx_record_attribute 9 "data_size" UNSIGNED = 24
tx_begin 10 6 620 ns
a 1
tx_relation "addr_phase" 10 9
tx_begin 11 7 620 ns
tx_relation "data_phase" 11 6
tx_end 11 7 700 ns
a 1
tx_end 6 4 700 ns
a 1
tx_end 10 6 760 ns
tx_begin 12 7 760 ns
tx_relation "data_phase" 12 9
tx_begin 13 4 760 ns
a 2
tx_record_attribute 13 "data_size" UNSIGNED = 24
tx_begin 14 6 760 ns
a 2
tx_relation "addr_phase" 14 13
tx_end 14 6 880 ns
tx_end 12 7 980 ns
a 1
tx_end 9 4 980 ns
a 1
tx_begin 15 4 980 ns
a 2
tx_record_attribute 15 "data_size" UNSIGNED = 24
tx_begin 16 6 980 ns
a 2
tx_relation "addr_phase" 16 15
tx_begin 17 7 980 ns
tx_relation "data_phase" 17 13
tx_end 16 6 1040 ns
tx_end 17 7 1200 ns
a 2
tx_end 13 4 1200 ns
a 2
tx_begin 18 4 1200 ns
a 120
tx_record_attribute 18 "data_size" UNSIGNED = 24
tx_begin 19 6 1200 ns
a 120
tx_relation "addr_phase" 19 18
tx_begin 20 7 1200 ns
tx_relation "data_phase" 20 15
tx_end 19 6 1300 ns
tx_end 20 7 1340 ns
a 2
tx_end 15 4 1340 ns
a 2
tx_begin 21 4 1340 ns
a 11
tx_record_attribute 21 "data_size" UNSIGNED = 24
tx_begin 22 6 1340 ns
a 11
tx_relation "addr_phase" 22 21
tx_begin 23 7 1340 ns
tx_relation "data_phase" 23 18
tx_end 23 7 1420 ns
a 120
tx_end 18 4 1420 ns
a 120
tx_end 22 6 1540 ns
tx_begin 24 7 1540 ns
tx_relation "data_phase" 24 21
tx_begin 25 4 1540 ns
a 147
tx_record_attribute 25 "data_size" UNSIGNED = 24
tx_begin 26 6 1540 ns
a 147
tx_relation "addr_phase" 26 25
tx_end 24 7 1660 ns
a 11
tx_end 21 4 1660 ns
a 11
tx_end 26 6 1740 ns
tx_begin 27 7 1740 ns
tx_relation "data_phase" 27 25
tx_begin 28 4 1740 ns
a 99
tx_record_attribute 28 "data_size" UNSIGNED = 24
tx_begin 29 6 1740 ns
a 99
tx_relation "addr_phase" 29 28
tx_end 29 6 1800 ns
tx_end 27 7 1980 ns
a 147
tx_end 25 4 1980 ns
a 147
tx_begin 30 4 1980 ns
a 55
tx_record_attribute 30 "data_size" UNSIGNED = 24
tx_begin 31 6 1980 ns
a 55
tx_relation "addr_phase" 31 30
tx_begin 32 7 1980 ns
tx_relation "data_phase" 32 28
tx_end 32 7 2060 ns
a 99
tx_end 28 4 2060 ns
a 99
tx_end 31 6 2100 ns
tx_begin 33 7 2100 ns
tx_relation "data_phase" 33 30
tx_begin 34 4 2100 ns
a 126
tx_record_attribute 34 "data_size" UNSIGNED = 24
tx_begin 35 6 2100 ns
a 126
tx_relation "addr_phase" 35 34
tx_end 33 7 2340 ns
a 55
tx_end 30 4 2340 ns
a 55
tx_end 35 6 2340 ns
tx_begin 36 7 2340 ns
tx_relation "data_phase" 36 34
tx_begin 37 5 2340 ns
a 204
tx_record_attribute 37 "data_size" UNSIGNED = 24
tx_begin 38 6 2340 ns
a 204
tx_relation "addr_phase" 38 37
tx_end 38 6 2400 ns
tx_end 36 7 2540 ns
a 126
tx_end 34 4 2540 ns
a 126
tx_begin 39 5 2540 ns
a 242
tx_record_attribute 39 "data_size" UNSIGNED = 24
tx_begin 40 6 2540 ns
a 242
tx_relation "addr_phase" 40 39
tx_begin 41 8 2540 ns
a 211
tx_relation "data_phase" 41 37
tx_end 41 8 2640 ns
tx_end 37 5 2640 ns
a 211
tx_end 40 6 2780 ns
tx_begin 42 8 2780 ns
a 58
tx_relation "data_phase" 42 39
tx_begin 43 5 2780 ns
a 135
tx_record_attribute 43 "data_size" UNSIGNED = 24
tx_begin 44 6 2780 ns
a 135
tx_relation "addr_phase" 44 43
tx_end 44 6 2960 ns
tx_end 42 8 3 us
tx_end 39 5 3 us
a 58
tx_begin 45 5 3 us
a 26
tx_record_attribute 45 "data_size" UNSIGNED = 24
tx_begin 46 6 3 us
a 26
tx_relation "addr_phase" 46 45
tx_begin 47 8 3 us
a 31
tx_relation "data_phase" 47 43
tx_end 47 8 3140 ns
tx_end 43 5 3140 ns
a 31
tx_end 46 6 3200 ns
tx_begin 48 8 3200 ns
a 37
tx_relation "data_phase" 48 45
tx_begin 49 5 3200 ns
a 176
tx_record_attribute 49 "data_size" UNSIGNED = 24
tx_begin 50 6 3200 ns
a 176
tx_relation "addr_phase" 50 49
tx_end 50 6 3300 ns
tx_end 48 8 3380 ns
tx_end 45 5 3380 ns
a 37
tx_begin 51 5 3380 ns
a 58
tx_record_attribute 51 "data_size" UNSIGNED = 24
tx_begin 52 6 3380 ns
a 58
tx_relation "addr_phase" 52 51
tx_begin 53 8 3380 ns
a 220
tx_relation "data_phase" 53 49
tx_end 52 6 3440 ns
tx_end 53 8 3560 ns
tx_end 49 5 3560 ns
a 220
tx_begin 54 8 3560 ns
a 109
tx_relation "data_phase" 54 51
tx_end 54 8 3660 ns
tx_end 51 5 3660 ns
a 109

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,99 @@
package com.minres.scviewer.database.test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.File;
import java.net.URISyntaxException;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import com.minres.scviewer.database.IWaveformDb;
import com.minres.scviewer.database.IWaveformDbFactory;
public class DatabaseServicesTest {
private static CountDownLatch dependencyLatch = new CountDownLatch(3);// 1 = number of dependencies required
private static List<IWaveformDbFactory> services=new LinkedList<IWaveformDbFactory>();
public void bind(IWaveformDbFactory factory){
services.add(factory);
dependencyLatch.countDown();
// System.out.println("service added");
}
public void unbind(IWaveformDbFactory factory){
services.remove(factory);
}
@Before
public void setUp() throws Exception {
// Wait for OSGi dependencies
try {
dependencyLatch.await(10, TimeUnit.SECONDS);
// Dependencies fulfilled
} catch (InterruptedException ex) {
fail("OSGi dependencies unfulfilled");
}
}
@After
public void tearDown() throws Exception {
}
@Test
public void testVCD() throws URISyntaxException {
File f = new File("inputs/my_db.vcd").getAbsoluteFile();
assertTrue(f.exists());
IWaveformDb database=null;
for(IWaveformDbFactory factory:services){
database = factory.createDatabase(f);
if(database!=null) break;
}
assertNotNull(database);
assertEquals(3, services.size());
assertEquals(14, database.getAllWaves().size());
assertEquals(2, database.getChildNodes().size());
}
@Test
public void testTxSQLite() throws URISyntaxException {
File f = new File("inputs/my_db.txdb").getAbsoluteFile();
assertTrue(f.exists());
IWaveformDb database=null;
for(IWaveformDbFactory factory:services){
database = factory.createDatabase(f);
if(database!=null) break;
}
assertNotNull(database);
assertEquals(3, services.size());
assertEquals(3, database.getAllWaves().size());
assertEquals(3, database.getChildNodes().size());
}
@Test
public void testTxText() throws URISyntaxException {
File f = new File("inputs/my_db.txlog").getAbsoluteFile();
assertTrue(f.exists());
IWaveformDb database=null;
for(IWaveformDbFactory factory:services){
database = factory.createDatabase(f);
if(database!=null) break;
}
assertNotNull(database);
assertEquals(3, services.size());
assertEquals(3, database.getAllWaves().size());
assertEquals(3, database.getChildNodes().size());
}
}

View File

@ -13,3 +13,5 @@ Require-Bundle: com.minres.scviewer.database;bundle-version="1.0.0",
org.eclipse.equinox.ds;bundle-version="1.4.200", org.eclipse.equinox.ds;bundle-version="1.4.200",
org.eclipse.osgi.services;bundle-version="3.4.0" org.eclipse.osgi.services;bundle-version="3.4.0"
Service-Component: OSGI-INF/component.xml Service-Component: OSGI-INF/component.xml
Export-Package: com.minres.scviewer.database.text
Bundle-ActivationPolicy: lazy

View File

@ -2,6 +2,6 @@
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="TextDbFactory"> <scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="TextDbFactory">
<implementation class="com.minres.scviewer.database.text.TextDbFactory"/> <implementation class="com.minres.scviewer.database.text.TextDbFactory"/>
<service> <service>
<provide interface="com.minres.scviewer.database.ITransactionDbFactory"/> <provide interface="com.minres.scviewer.database.IWaveformDbFactory"/>
</service> </service>
</scr:component> </scr:component>

View File

@ -1,54 +0,0 @@
/*******************************************************************************
* Copyright (c) 2012 IT Just working.
* 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:
* IT Just working - initial API and implementation
*******************************************************************************/
package com.minres.scviewer.database.text;
import java.beans.PropertyChangeListener;
import java.util.List;
import java.util.Map;
import com.minres.scviewer.database.ITrHierNode;
class HierNode implements ITrHierNode {
String name
def childs = []
public HierNode(){
}
public HierNode(String name){
this.name=name
}
@Override
public List<ITrHierNode> getChildNodes() {
return childs.sort{it.name}
}
@Override
public String getFullName() {
// TODO Auto-generated method stub
return name;
}
@Override
public void addPropertyChangeListener(PropertyChangeListener l) {
// TODO Auto-generated method stub
}
@Override
public void removePropertyChangeListener(PropertyChangeListener l) {
// TODO Auto-generated method stub
}
}

View File

@ -19,17 +19,18 @@ import java.util.TreeMap;
import com.minres.scviewer.database.AssociationType; import com.minres.scviewer.database.AssociationType;
import com.minres.scviewer.database.DataType; import com.minres.scviewer.database.DataType;
import com.minres.scviewer.database.ITrAttrType; import com.minres.scviewer.database.HierNode;
import com.minres.scviewer.database.ITrAttribute; import com.minres.scviewer.database.ITxAttributeType;
import com.minres.scviewer.database.ITrDb; import com.minres.scviewer.database.ITxAttribute;
import com.minres.scviewer.database.ITrGenerator; import com.minres.scviewer.database.IWaveformDb;
import com.minres.scviewer.database.ITrHierNode; import com.minres.scviewer.database.ITxGenerator;
import com.minres.scviewer.database.ITrStream; import com.minres.scviewer.database.IHierNode;
import com.minres.scviewer.database.ITxStream;
import com.minres.scviewer.database.InputFormatException; import com.minres.scviewer.database.InputFormatException;
import com.minres.scviewer.database.EventTime import com.minres.scviewer.database.EventTime
import com.minres.scviewer.database.RelationType import com.minres.scviewer.database.RelationType
public class TextDb extends HierNode implements ITrDb{ public class TextDb extends HierNode implements IWaveformDb{
private EventTime maxTime; private EventTime maxTime;
@ -37,6 +38,10 @@ public class TextDb extends HierNode implements ITrDb{
def relationTypes=[:] def relationTypes=[:]
public TextDb() {
super("TextDb");
}
public String getFullName() { public String getFullName() {
return getName(); return getName();
} }
@ -46,21 +51,21 @@ public class TextDb extends HierNode implements ITrDb{
return maxTime; return maxTime;
} }
public ITrStream getStreamByName(String name){ public ITxStream getStreamByName(String name){
streams.find{ITrStream stream-> stream.fullName == name } streams.find{ITxStream stream-> stream.fullName == name }
} }
public List<ITrStream> getAllStreams() { public List<ITxStream> getAllWaves() {
return new LinkedList<ITrStream>(streams); return new LinkedList<ITxStream>(streams);
} }
public List<ITrHierNode> getChildNodes() { public List<IHierNode> getChildNodes() {
return childs.sort{it.name}; return childs.sort{it.name};
} }
public Map<Long, ITrGenerator> getGeneratorsById() { public Map<Long, ITxGenerator> getGeneratorsById() {
TreeMap<Long, ITrGenerator> res = new TreeMap<Long, ITrGenerator>(); TreeMap<Long, ITxGenerator> res = new TreeMap<Long, ITxGenerator>();
streams.each{Stream stream -> stream.generators.each{res.put(it.id, id)} } streams.each{TxStream stream -> stream.generators.each{res.put(it.id, id)} }
return res; return res;
} }
@ -78,8 +83,8 @@ public class TextDb extends HierNode implements ITrDb{
def streamsById = [:] def streamsById = [:]
def generatorsById = [:] def generatorsById = [:]
def transactionsById = [:] def transactionsById = [:]
Generator generator TxGenerator generator
Transaction transaction Tx transaction
boolean endTransaction=false boolean endTransaction=false
def matcher def matcher
input.eachLine { line -> input.eachLine { line ->
@ -91,19 +96,19 @@ public class TextDb extends HierNode implements ITrDb{
case "end_attribute": case "end_attribute":
if ((matcher = line =~ /^scv_tr_stream\s+\(ID (\d+),\s+name\s+"([^"]+)",\s+kind\s+"([^"]+)"\)$/)) { if ((matcher = line =~ /^scv_tr_stream\s+\(ID (\d+),\s+name\s+"([^"]+)",\s+kind\s+"([^"]+)"\)$/)) {
def id = Integer.parseInt(matcher[0][1]) def id = Integer.parseInt(matcher[0][1])
def stream = new Stream(id, this, matcher[0][2], matcher[0][3]) def stream = new TxStream(id, this, matcher[0][2], matcher[0][3])
streams<<stream streams<<stream
streamsById[id]=stream streamsById[id]=stream
} else if ((matcher = line =~ /^scv_tr_generator\s+\(ID\s+(\d+),\s+name\s+"([^"]+)",\s+scv_tr_stream\s+(\d+),$/)) { } else if ((matcher = line =~ /^scv_tr_generator\s+\(ID\s+(\d+),\s+name\s+"([^"]+)",\s+scv_tr_stream\s+(\d+),$/)) {
def id = Integer.parseInt(matcher[0][1]) def id = Integer.parseInt(matcher[0][1])
ITrStream stream=streamsById[Integer.parseInt(matcher[0][3])] ITxStream stream=streamsById[Integer.parseInt(matcher[0][3])]
generator=new Generator(id, stream, matcher[0][2]) generator=new TxGenerator(id, stream, matcher[0][2])
stream.generators<<generator stream.generators<<generator
generatorsById[id]=generator generatorsById[id]=generator
} else if ((matcher = line =~ /^begin_attribute \(ID (\d+), name "([^"]+)", type "([^"]+)"\)$/)) { } else if ((matcher = line =~ /^begin_attribute \(ID (\d+), name "([^"]+)", type "([^"]+)"\)$/)) {
generator.begin_attrs << AttrType.getAttrType(matcher[0][2], DataType.valueOf(matcher[0][3]), AssociationType.BEGIN) generator.begin_attrs << TxAttributeType.getAttrType(matcher[0][2], DataType.valueOf(matcher[0][3]), AssociationType.BEGIN)
} else if ((matcher = line =~ /^end_attribute \(ID (\d+), name "([^"]+)", type "([^"]+)"\)$/)) { } else if ((matcher = line =~ /^end_attribute \(ID (\d+), name "([^"]+)", type "([^"]+)"\)$/)) {
generator.end_attrs << AttrType.getAttrType(matcher[0][2], DataType.valueOf(matcher[0][3]), AssociationType.END) generator.end_attrs << TxAttributeType.getAttrType(matcher[0][2], DataType.valueOf(matcher[0][3]), AssociationType.END)
} }
break; break;
case ")": case ")":
@ -111,8 +116,8 @@ public class TextDb extends HierNode implements ITrDb{
break break
case "tx_begin"://matcher = line =~ /^tx_begin\s+(\d+)\s+(\d+)\s+(\d+)\s+([munpf]?s)/ case "tx_begin"://matcher = line =~ /^tx_begin\s+(\d+)\s+(\d+)\s+(\d+)\s+([munpf]?s)/
def id = Integer.parseInt(tokens[1]) def id = Integer.parseInt(tokens[1])
Generator gen=generatorsById[Integer.parseInt(tokens[2])] TxGenerator gen=generatorsById[Integer.parseInt(tokens[2])]
transaction = new Transaction(id, gen.stream, gen, new EventTime(Integer.parseInt(tokens[3]), tokens[4])) transaction = new Tx(id, gen.stream, gen, new EventTime(Integer.parseInt(tokens[3]), tokens[4]))
gen.transactions << transaction gen.transactions << transaction
transactionsById[id]= transaction transactionsById[id]= transaction
gen.begin_attrs_idx=0; gen.begin_attrs_idx=0;
@ -130,21 +135,21 @@ public class TextDb extends HierNode implements ITrDb{
break break
case "tx_record_attribute"://matcher = line =~ /^tx_record_attribute\s+(\d+)\s+"([^"]+)"\s+(\S+)\s*=\s*(.+)$/ case "tx_record_attribute"://matcher = line =~ /^tx_record_attribute\s+(\d+)\s+"([^"]+)"\s+(\S+)\s*=\s*(.+)$/
def id = Integer.parseInt(tokens[1]) def id = Integer.parseInt(tokens[1])
transactionsById[id].attributes<<new Attribute(tokens[2][1..-2], DataType.valueOf(tokens[3]), AssociationType.RECORD, tokens[5..-1].join(' ')) transactionsById[id].attributes<<new TxAttribute(tokens[2][1..-2], DataType.valueOf(tokens[3]), AssociationType.RECORD, tokens[5..-1].join(' '))
break break
case "a"://matcher = line =~ /^a\s+(.+)$/ case "a"://matcher = line =~ /^a\s+(.+)$/
if(endTransaction){ if(endTransaction){
transaction.attributes << new Attribute(transaction.generator.end_attrs[0], tokens[1]) transaction.attributes << new TxAttribute(transaction.generator.end_attrs[0], tokens[1])
} else { } else {
transaction.attributes << new Attribute(transaction.generator.begin_attrs[0], tokens[1]) transaction.attributes << new TxAttribute(transaction.generator.begin_attrs[0], tokens[1])
} }
break break
case "tx_relation"://matcher = line =~ /^tx_relation\s+\"(\S+)\"\s+(\d+)\s+(\d+)$/ case "tx_relation"://matcher = line =~ /^tx_relation\s+\"(\S+)\"\s+(\d+)\s+(\d+)$/
Transaction tr1= transactionsById[Integer.parseInt(tokens[2])] Tx tr1= transactionsById[Integer.parseInt(tokens[2])]
Transaction tr2= transactionsById[Integer.parseInt(tokens[3])] Tx tr2= transactionsById[Integer.parseInt(tokens[3])]
def relType=tokens[1][1..-2] def relType=tokens[1][1..-2]
if(!relationTypes.containsKey(relType)) relationTypes[relType]=new RelationType(relType) if(!relationTypes.containsKey(relType)) relationTypes[relType]=new RelationType(relType)
def rel = new Relation(relationTypes[relType], tr1, tr2) def rel = new TxRelation(relationTypes[relType], tr1, tr2)
tr1.outgoingRelations<<rel tr1.outgoingRelations<<rel
tr2.incomingRelations<<rel tr2.incomingRelations<<rel
break break
@ -157,9 +162,9 @@ public class TextDb extends HierNode implements ITrDb{
} }
def addHierarchyNodes(){ def addHierarchyNodes(){
streams.each{ Stream stream-> streams.each{ TxStream stream->
def hier = stream.fullName.split(/\./) def hier = stream.fullName.split(/\./)
ITrHierNode node = this IHierNode node = this
hier.each { name -> hier.each { name ->
def n1 = node.childNodes.find{it.name == name} def n1 = node.childNodes.find{it.name == name}
if(name == hier[-1]){ //leaf if(name == hier[-1]){ //leaf

View File

@ -2,15 +2,15 @@ package com.minres.scviewer.database.text
import java.io.FileInputStream; import java.io.FileInputStream;
import com.minres.scviewer.database.ITrDb import com.minres.scviewer.database.IWaveformDb
import com.minres.scviewer.database.ITransactionDbFactory; import com.minres.scviewer.database.IWaveformDbFactory;
class TextDbFactory implements ITransactionDbFactory { class TextDbFactory implements IWaveformDbFactory {
byte[] x = "scv_tr_stream".bytes byte[] x = "scv_tr_stream".bytes
@Override @Override
public ITrDb createDatabase(File file) { public IWaveformDb createDatabase(File file) {
try { try {
FileInputStream fis = new FileInputStream(file); FileInputStream fis = new FileInputStream(file);
byte[] buffer = new byte[x.size()]; byte[] buffer = new byte[x.size()];

View File

@ -15,37 +15,37 @@ import java.util.Set
import com.minres.scviewer.database.* import com.minres.scviewer.database.*
class Transaction implements ITransaction { class Tx implements ITx {
Long id Long id
Generator generator TxGenerator generator
Stream stream TxStream stream
EventTime beginTime EventTime beginTime
EventTime endTime EventTime endTime
ArrayList<ITrAttribute> attributes = new ArrayList<ITrAttribute>() ArrayList<ITxAttribute> attributes = new ArrayList<ITxAttribute>()
def incomingRelations =[] def incomingRelations =[]
def outgoingRelations =[] def outgoingRelations =[]
Transaction(int id, Stream stream, Generator generator, EventTime begin){ Tx(int id, TxStream stream, TxGenerator generator, EventTime begin){
this.id=id this.id=id
this.generator=generator this.generator=generator
this.beginTime=begin this.beginTime=begin
} }
@Override @Override
public Collection<ITrRelation> getIncomingRelations() { public Collection<ITxRelation> getIncomingRelations() {
return incomingRelations; return incomingRelations;
} }
@Override @Override
public Collection<ITrRelation> getOutgoingRelations() { public Collection<ITxRelation> getOutgoingRelations() {
return outgoingRelations; return outgoingRelations;
} }

View File

@ -12,17 +12,17 @@ package com.minres.scviewer.database.text
import com.minres.scviewer.database.AssociationType; import com.minres.scviewer.database.AssociationType;
import com.minres.scviewer.database.DataType; import com.minres.scviewer.database.DataType;
import com.minres.scviewer.database.ITrAttrType; import com.minres.scviewer.database.ITxAttributeType;
import com.minres.scviewer.database.ITrAttribute import com.minres.scviewer.database.ITxAttribute
class Attribute implements ITrAttribute{ class TxAttribute implements ITxAttribute{
AttrType attributeType TxAttributeType attributeType
def value def value
Attribute(String name, DataType dataType, AssociationType type, value){ TxAttribute(String name, DataType dataType, AssociationType type, value){
attributeType = AttrTypeFactory.instance.getAttrType(name, dataType, type) attributeType = TxAttributeTypeFactory.instance.getAttrType(name, dataType, type)
switch(dataType){ switch(dataType){
case DataType.STRING: case DataType.STRING:
case DataType.ENUMERATION: case DataType.ENUMERATION:
@ -33,11 +33,11 @@ class Attribute implements ITrAttribute{
} }
} }
Attribute(AttrType other){ TxAttribute(TxAttributeType other){
attributeType=other attributeType=other
} }
Attribute(AttrType other, value){ TxAttribute(TxAttributeType other, value){
this(other.name, other.dataType, other.type, value) this(other.name, other.dataType, other.type, value)
} }

View File

@ -12,18 +12,18 @@ package com.minres.scviewer.database.text
import com.minres.scviewer.database.AssociationType; import com.minres.scviewer.database.AssociationType;
import com.minres.scviewer.database.DataType; import com.minres.scviewer.database.DataType;
import com.minres.scviewer.database.ITrAttrType; import com.minres.scviewer.database.ITxAttributeType;
class AttrType implements ITrAttrType { class TxAttributeType implements ITxAttributeType {
String name String name
DataType dataType DataType dataType
AssociationType type AssociationType type
static AttrType getAttrType(String name, DataType dataType, AssociationType type){ static TxAttributeType getAttrType(String name, DataType dataType, AssociationType type){
AttrTypeFactory.instance.getAttrType(name, dataType, type) TxAttributeTypeFactory.instance.getAttrType(name, dataType, type)
} }
AttrType(String name, DataType dataType, AssociationType type){ TxAttributeType(String name, DataType dataType, AssociationType type){
this.name=name this.name=name
this.dataType=dataType this.dataType=dataType
this.type=type this.type=type

View File

@ -12,25 +12,25 @@ package com.minres.scviewer.database.text
import com.minres.scviewer.database.AssociationType; import com.minres.scviewer.database.AssociationType;
import com.minres.scviewer.database.DataType import com.minres.scviewer.database.DataType
import com.minres.scviewer.database.ITrAttrType import com.minres.scviewer.database.ITxAttributeType
import com.minres.scviewer.database.ITrAttribute import com.minres.scviewer.database.ITxAttribute
class AttrTypeFactory { class TxAttributeTypeFactory {
private static final instance = new AttrTypeFactory() private static final instance = new TxAttributeTypeFactory()
def attributes = [:] def attributes = [:]
private AttrTypeFactory() { private TxAttributeTypeFactory() {
AttrTypeFactory.metaClass.constructor = {-> instance } TxAttributeTypeFactory.metaClass.constructor = {-> instance }
} }
ITrAttrType getAttrType(String name, DataType dataType, AssociationType type){ ITxAttributeType getAttrType(String name, DataType dataType, AssociationType type){
def key = name+":"+dataType.toString() def key = name+":"+dataType.toString()
ITrAttrType res ITxAttributeType res
if(attributes.containsKey(key)){ if(attributes.containsKey(key)){
res=attributes[key] res=attributes[key]
} else { } else {
res=new AttrType(name, dataType, type) res=new TxAttributeType(name, dataType, type)
attributes[key]=res attributes[key]=res
} }
return res return res

View File

@ -13,35 +13,35 @@ package com.minres.scviewer.database.text
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import com.minres.scviewer.database.ITrAttrType import com.minres.scviewer.database.ITxAttributeType
import com.minres.scviewer.database.ITrAttribute; import com.minres.scviewer.database.ITxAttribute;
import com.minres.scviewer.database.ITrGenerator; import com.minres.scviewer.database.ITxGenerator;
import com.minres.scviewer.database.ITrStream; import com.minres.scviewer.database.ITxStream;
import com.minres.scviewer.database.ITransaction; import com.minres.scviewer.database.ITx;
class Generator implements ITrGenerator{ class TxGenerator implements ITxGenerator{
Long id Long id
Stream stream TxStream stream
String name String name
Boolean active = false Boolean active = false
ArrayList<ITransaction> transactions=[] ArrayList<ITx> transactions=[]
ArrayList<ITrAttrType> begin_attrs = [] ArrayList<ITxAttributeType> begin_attrs = []
int begin_attrs_idx = 0 int begin_attrs_idx = 0
ArrayList<ITrAttrType> end_attrs= [] ArrayList<ITxAttributeType> end_attrs= []
int end_attrs_idx = 0 int end_attrs_idx = 0
Generator(int id, Stream stream, name){ TxGenerator(int id, TxStream stream, name){
this.id=id this.id=id
this.stream=stream this.stream=stream
this.name=name this.name=name
} }
ITrStream getStream(){ ITxStream getStream(){
return stream; return stream;
} }
List<ITransaction> getTransactions(){ List<ITx> getTransactions(){
return transactions return transactions
} }

View File

@ -1,18 +1,18 @@
package com.minres.scviewer.database.text package com.minres.scviewer.database.text
import com.minres.scviewer.database.ITrRelation import com.minres.scviewer.database.ITxRelation
import com.minres.scviewer.database.ITransaction; import com.minres.scviewer.database.ITx;
import com.minres.scviewer.database.RelationType; import com.minres.scviewer.database.RelationType;
class Relation implements ITrRelation { class TxRelation implements ITxRelation {
Transaction source Tx source
Transaction target Tx target
RelationType relationType RelationType relationType
public Relation(RelationType relationType, Transaction source, Transaction target) { public TxRelation(RelationType relationType, Tx source, Tx target) {
this.source = source; this.source = source;
this.target = target; this.target = target;
this.relationType = relationType; this.relationType = relationType;
@ -24,12 +24,12 @@ class Relation implements ITrRelation {
} }
@Override @Override
public ITransaction getSource() { public ITx getSource() {
return source; return source;
} }
@Override @Override
public ITransaction getTarget() { public ITx getTarget() {
return target; return target;
} }

View File

@ -14,13 +14,14 @@ import java.beans.PropertyChangeListener;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import com.minres.scviewer.database.ITrDb import com.minres.scviewer.database.HierNode;
import com.minres.scviewer.database.ITrGenerator import com.minres.scviewer.database.IWaveformDb
import com.minres.scviewer.database.ITrHierNode import com.minres.scviewer.database.ITxGenerator
import com.minres.scviewer.database.ITrStream import com.minres.scviewer.database.IHierNode
import com.minres.scviewer.database.ITransaction import com.minres.scviewer.database.ITxStream
import com.minres.scviewer.database.ITx
class Stream extends HierNode implements ITrStream { class TxStream extends HierNode implements ITxStream {
Long id; Long id;
@ -34,31 +35,27 @@ class Stream extends HierNode implements ITrStream {
private allTransactions; private allTransactions;
public TrHierNode(String name){ TxStream(int id, TextDb db, String name, String kind){
this.name=name super(name)
}
Stream(int id, TextDb db, String name, String kind){
this.id=id this.id=id
this.database=db this.database=db
this.name=name
this.fullName=name this.fullName=name
this.kind=kind this.kind=kind
} }
List<ITrGenerator> getGenerators(){ List<ITxGenerator> getGenerators(){
return generators as List<ITrGenerator> return generators as List<ITxGenerator>
} }
@Override @Override
public ITrDb getDb() { public IWaveformDb getDb() {
return database; return database;
} }
// FIXME: maybe need to be somewhere else // FIXME: maybe need to be somewhere else
public int getMaxConcurrrentTx() { public int getMaxConcurrrentTx() {
def rowendtime = [0] def rowendtime = [0]
getTransactions().each{Transaction tx -> getTransactions().each{Tx tx ->
def rowIdx = 0 def rowIdx = 0
for(rowIdx=0; rowendtime.size()<rowIdx || rowendtime[rowIdx]>tx.beginTime.value; rowIdx++); for(rowIdx=0; rowendtime.size()<rowIdx || rowendtime[rowIdx]>tx.beginTime.value; rowIdx++);
if(rowendtime.size<=rowIdx){ if(rowendtime.size<=rowIdx){
@ -71,14 +68,14 @@ class Stream extends HierNode implements ITrStream {
} }
@Override @Override
public List<ITransaction> getTransactions() { public List<ITx> getTransactions() {
if(!allTransactions) if(!allTransactions)
allTransactions=generators.transactions.flatten().sort{it.beginTime.value} allTransactions=generators.transactions.flatten().sort{it.beginTime.value}
return allTransactions return allTransactions
} }
@Override @Override
public ITransaction getTransactionById(long id) { public ITx getTransactionById(long id) {
if(!allTransactions) if(!allTransactions)
allTransactions=generators.transactions.flatten().sort{it.beginTime.value} allTransactions=generators.transactions.flatten().sort{it.beginTime.value}
allTransactions.find{it.id==id} allTransactions.find{it.id==id}

View File

@ -20,6 +20,11 @@
<arguments> <arguments>
</arguments> </arguments>
</buildCommand> </buildCommand>
<buildCommand>
<name>org.eclipse.pde.ds.core.builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec> </buildSpec>
<natures> <natures>
<nature>org.eclipse.pde.PluginNature</nature> <nature>org.eclipse.pde.PluginNature</nature>

View File

@ -5,4 +5,7 @@ Bundle-SymbolicName: com.minres.scviewer.database
Bundle-Version: 1.0.0.qualifier Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: MINRES Technologies GmbH Bundle-Vendor: MINRES Technologies GmbH
Bundle-RequiredExecutionEnvironment: JavaSE-1.7 Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Export-Package: com.minres.scviewer.database Export-Package: com.minres.scviewer.database,
com.minres.scviewer.database.vcd
Service-Component: OSGI-INF/component.xml
Bundle-ActivationPolicy: lazy

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="VCDDbFactory">
<implementation class="com.minres.scviewer.database.vcd.VCDDbFactory"/>
<service>
<provide interface="com.minres.scviewer.database.IWaveformDbFactory"/>
</service>
</scr:component>

View File

@ -1,4 +1,5 @@
source.. = src/
output.. = bin/ output.. = bin/
bin.includes = META-INF/,\ bin.includes = META-INF/,\
. .,\
OSGI-INF/component.xml
source.. = src/

View File

@ -1,3 +1,5 @@
package com.minres.scviewer.database; package com.minres.scviewer.database;
public enum AssociationType {BEGIN, RECORD, END} public enum AssociationType {
BEGIN, RECORD, END
}

View File

@ -1,16 +1,18 @@
package com.minres.scviewer.database; package com.minres.scviewer.database;
public enum DataType {
BOOLEAN, // bool public enum DataType {
ENUMERATION, // enum BOOLEAN, // bool
INTEGER, // char, short, int, long, long long, sc_int, sc_bigint ENUMERATION, // enum
UNSIGNED, // unsigned { char, short, int, long, long long }, sc_uint, sc_biguint INTEGER, // char, short, int, long, long long, sc_int, sc_bigint
FLOATING_POINT_NUMBER, // float, double UNSIGNED, // unsigned { char, short, int, long, long long }, sc_uint,
BIT_VECTOR, // sc_bit, sc_bv // sc_biguint
LOGIC_VECTOR, // sc_logic, sc_lv FLOATING_POINT_NUMBER, // float, double
FIXED_POINT_INTEGER, // sc_fixed BIT_VECTOR, // sc_bit, sc_bv
UNSIGNED_FIXED_POINT_INTEGER, // sc_ufixed LOGIC_VECTOR, // sc_logic, sc_lv
RECORD, // struct/class FIXED_POINT_INTEGER, // sc_fixed
POINTER, // T* UNSIGNED_FIXED_POINT_INTEGER, // sc_ufixed
ARRAY, // T[N] RECORD, // struct/class
STRING // string, std::string POINTER, // T*
}; ARRAY, // T[N]
STRING // string, std::string
};

View File

@ -16,8 +16,11 @@ public class EventTime implements Comparable<EventTime>{
public static final double MS = 1000000000.0; public static final double MS = 1000000000.0;
public static final EventTime ZERO = new EventTime(0L, "fs");
private long value; // unit is femto seconds private long value; // unit is femto seconds
public EventTime(Long value, String unit){ public EventTime(Long value, String unit){
setValue(value, unit); setValue(value, unit);
} }

View File

@ -1,32 +1,26 @@
package com.minres.scviewer.database.sqlite; package com.minres.scviewer.database;
import java.beans.PropertyChangeListener; import java.beans.PropertyChangeListener;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import com.minres.scviewer.database.ITrHierNode; public class HierNode implements IHierNode {
public class HierNode implements ITrHierNode {
protected String name; protected String name;
protected ArrayList<ITrHierNode> childs; protected ArrayList<IHierNode> childs;
public HierNode(String name) { public HierNode(String name) {
this.name=name; this.name=name;
childs = new ArrayList<ITrHierNode>(); childs = new ArrayList<IHierNode>();
} }
@Override @Override
public void addPropertyChangeListener(PropertyChangeListener l) { public void addPropertyChangeListener(PropertyChangeListener l) {
// TODO Auto-generated method stub
} }
@Override @Override
public void removePropertyChangeListener(PropertyChangeListener l) { public void removePropertyChangeListener(PropertyChangeListener l) {
// TODO Auto-generated method stub
} }
@Override @Override
@ -45,7 +39,7 @@ public class HierNode implements ITrHierNode {
} }
@Override @Override
public List<ITrHierNode> getChildNodes() { public List<IHierNode> getChildNodes() {
return childs; return childs;
} }

View File

@ -13,7 +13,8 @@ package com.minres.scviewer.database;
import java.beans.PropertyChangeListener; import java.beans.PropertyChangeListener;
import java.util.List; import java.util.List;
public interface ITrHierNode { public interface IHierNode {
/** /**
* Attach a non-null PropertyChangeListener to this object. * Attach a non-null PropertyChangeListener to this object.
* *
@ -23,6 +24,7 @@ public interface ITrHierNode {
* if the parameter is null * if the parameter is null
*/ */
public void addPropertyChangeListener(PropertyChangeListener l); public void addPropertyChangeListener(PropertyChangeListener l);
/** /**
* Remove a PropertyChangeListener from this component. * Remove a PropertyChangeListener from this component.
* *
@ -37,6 +39,6 @@ public interface ITrHierNode {
public void setName(String name); public void setName(String name);
public List<ITrHierNode> getChildNodes(); public List<IHierNode> getChildNodes();
} }

View File

@ -0,0 +1,13 @@
package com.minres.scviewer.database;
import java.util.NavigableSet;
public interface ISignal<T extends ISignalChange> extends IWaveform{
public NavigableSet<ISignalChange> getSignalChanges();
public T getSignalChangeByTime(EventTime time);
public NavigableSet<ISignalChange> getSignalChangesByTimes(EventTime start, EventTime end);
}

View File

@ -0,0 +1,9 @@
package com.minres.scviewer.database;
public interface ISignalChange extends Comparable<ISignalChange>{
public EventTime getTime();
public ISignalChange duplicate() throws CloneNotSupportedException;
}

View File

@ -0,0 +1,7 @@
package com.minres.scviewer.database;
public interface ISignalChangeMulti extends ISignalChange {
public String getValue();
}

View File

@ -0,0 +1,7 @@
package com.minres.scviewer.database;
public interface ISignalChangeSingle extends ISignalChange{
public char getValue();
}

View File

@ -1,10 +0,0 @@
package com.minres.scviewer.database;
public interface ITrRelation {
RelationType getRelationType();
ITransaction getSource();
ITransaction getTarget();
}

View File

@ -1,9 +0,0 @@
package com.minres.scviewer.database;
import java.io.File;
public interface ITransactionDbFactory {
ITrDb createDatabase(File file);
}

View File

@ -12,23 +12,22 @@ package com.minres.scviewer.database;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Set;
public interface ITransaction { public interface ITx {
public Long getId(); public Long getId();
public ITrStream getStream(); public ITxStream getStream();
public ITrGenerator getGenerator(); public ITxGenerator getGenerator();
public EventTime getBeginTime(); public EventTime getBeginTime();
public EventTime getEndTime(); public EventTime getEndTime();
public List<ITrAttribute> getAttributes(); public List<ITxAttribute> getAttributes();
public Collection<ITrRelation> getIncomingRelations(); public Collection<ITxRelation> getIncomingRelations();
public Collection<ITrRelation> getOutgoingRelations(); public Collection<ITxRelation> getOutgoingRelations();
} }

View File

@ -10,6 +10,6 @@
*******************************************************************************/ *******************************************************************************/
package com.minres.scviewer.database; package com.minres.scviewer.database;
public interface ITrAttribute extends ITrAttrType { public interface ITxAttribute extends ITxAttributeType {
public Object getValue(); public Object getValue();
} }

View File

@ -10,7 +10,7 @@
*******************************************************************************/ *******************************************************************************/
package com.minres.scviewer.database; package com.minres.scviewer.database;
public interface ITrAttrType { public interface ITxAttributeType {
public String getName(); public String getName();
public DataType getDataType(); public DataType getDataType();
public AssociationType getType(); public AssociationType getType();

View File

@ -12,9 +12,9 @@ package com.minres.scviewer.database;
import java.util.List; import java.util.List;
public interface ITrGenerator { public interface ITxGenerator {
public Long getId(); public Long getId();
public ITrStream getStream(); public ITxStream getStream();
public String getName(); public String getName();
public List<ITransaction> getTransactions(); public List<ITx> getTransactions();
} }

View File

@ -0,0 +1,10 @@
package com.minres.scviewer.database;
public interface ITxRelation {
RelationType getRelationType();
ITx getSource();
ITx getTarget();
}

View File

@ -12,18 +12,12 @@ package com.minres.scviewer.database;
import java.util.List; import java.util.List;
public interface ITrStream extends ITrHierNode { public interface ITxStream extends IWaveform {
public Long getId(); public List<ITxGenerator> getGenerators();
public String getKind(); public List<ITx> getTransactions();
public ITrDb getDb(); public ITx getTransactionById(long id);
public List<ITrGenerator> getGenerators();
public List<ITransaction> getTransactions();
public ITransaction getTransactionById(long id);
} }

View File

@ -0,0 +1,12 @@
package com.minres.scviewer.database;
public interface IWaveform extends IHierNode {
public Long getId();
public String getKind();
public IWaveformDb getDb();
}

View File

@ -11,19 +11,18 @@
package com.minres.scviewer.database; package com.minres.scviewer.database;
import java.io.File; import java.io.File;
import java.io.InputStream;
import java.util.List; import java.util.List;
public interface ITrDb extends ITrHierNode { public interface IWaveformDb extends IHierNode {
public EventTime getMaxTime(); public EventTime getMaxTime();
public ITrStream getStreamByName(String name); public IWaveform getStreamByName(String name);
public List<ITrStream> getAllStreams(); public List<IWaveform> getAllWaves();
public void load(File inp) throws InputFormatException; public void load(File inp) throws Exception;
public void clear(); public void clear();

View File

@ -0,0 +1,9 @@
package com.minres.scviewer.database;
import java.io.File;
public interface IWaveformDbFactory {
IWaveformDb createDatabase(File file);
}

View File

@ -0,0 +1,36 @@
package com.minres.scviewer.database;
public class SignalChange implements ISignalChange {
EventTime time;
public SignalChange() {
time=EventTime.ZERO;
}
public SignalChange(EventTime time) {
super();
this.time = time;
}
@Override
public int compareTo(ISignalChange o) {
return time.compareTo(o.getTime());
}
@Override
public EventTime getTime() {
return time;
}
public void setTime(EventTime time) {
this.time = time;
}
@Override
public ISignalChange duplicate() throws CloneNotSupportedException {
return (ISignalChange) this.clone();
}
}

View File

@ -0,0 +1,39 @@
package com.minres.scviewer.database.vcd;
public class BitVector {
public static final char VALUE_X = 'X';
public static final char VALUE_Z = 'Z';
public static final char VALUE_1 = '1';
public static final char VALUE_0 = '0';
private final int width;
private char[] value;
public BitVector(int netWidth) {
this.width=netWidth;
value = new char[netWidth];
for(int i=0; i<netWidth; i++) value[i]='0';
}
public void setValue(int i, char value) {
this.value[i]=value;
}
public char[] getValue() {
return value;
}
public void setValue(char[] value) {
this.value = value;
}
public int getWidth() {
return width;
}
public String toString(){
return new String(value);
}
}

View File

@ -0,0 +1,48 @@
package com.minres.scviewer.database.vcd;
// TODO: Auto-generated Javadoc
/**
* The Interface ITraceBuilder.
*/
public interface IVCDDatabaseBuilder {
/**
* Enter module.
*
* @param tokenString the token string
*/
public void enterModule(String tokenString);
/**
* Exit module.
*/
public void exitModule();
/**
* New net.
*
* @param netName the net name
* @param i the index of the net, -1 if a new one, otherwise the id if the referenced
* @param width the width
* @return the integer
*/
public Integer newNet(String netName, int i, int width) ;
/**
* Gets the net width.
*
* @param intValue the int value
* @return the net width
*/
public int getNetWidth(int intValue);
/**
* Append transition.
*
* @param intValue the int value
* @param fCurrentTime the f current time
* @param decodedValues the decoded values
*/
public void appendTransition(int intValue, long fCurrentTime, BitVector decodedValues);
}

View File

@ -0,0 +1,211 @@
package com.minres.scviewer.database.vcd;
import java.io.File;
import java.io.FileInputStream;
import java.util.HashMap;
import java.util.List;
import java.util.Stack;
import java.util.Vector;
import com.minres.scviewer.database.EventTime;
import com.minres.scviewer.database.HierNode;
import com.minres.scviewer.database.ISignal;
import com.minres.scviewer.database.ISignalChange;
import com.minres.scviewer.database.ISignalChangeMulti;
import com.minres.scviewer.database.ISignalChangeSingle;
import com.minres.scviewer.database.IWaveformDb;
import com.minres.scviewer.database.IHierNode;
import com.minres.scviewer.database.ITxStream;
import com.minres.scviewer.database.IWaveform;
import com.minres.scviewer.database.InputFormatException;
import com.minres.scviewer.database.SignalChange;
// TODO: Auto-generated Javadoc
/**
* The Class VCDDb.
*/
public class VCDDb extends HierNode implements IWaveformDb, IVCDDatabaseBuilder {
private static final String TIME_RES = "ps";
/** The module stack. */
private Stack<String> moduleStack;
/** The signals. */
private List<IWaveform> signals;
private HashMap<String, IWaveform> waveformLookup;
private long maxTime;
/**
* Instantiates a new VCD db.
*
* @param netName the net name
*/
public VCDDb() {
super("VCDDb");
signals = new Vector<IWaveform>();
waveformLookup = new HashMap<String, IWaveform>();
}
/* (non-Javadoc)
* @see com.minres.scviewer.database.ITrDb#getStreamByName(java.lang.String)
*/
@Override
public ITxStream getStreamByName(String name) {
return null;
}
/* (non-Javadoc)
* @see com.minres.scviewer.database.ITrDb#load(java.io.File)
*/
@SuppressWarnings("unchecked")
@Override
public void load(File inp) throws Exception {
moduleStack= new Stack<String>();
boolean res = new VCDFileParser(false).load(new FileInputStream(inp), this);
moduleStack=null;
if(!res) throw new InputFormatException();
EventTime lastTime=new EventTime(maxTime, TIME_RES);
for(IWaveform signal:signals){
ISignalChange change = ((ISignal<ISignalChange>)signal).getSignalChanges().last();
if(lastTime.compareTo(change.getTime())>0){
ISignalChange lastChange = change.duplicate();
((SignalChange)lastChange).setTime(lastTime);
((ISignal<ISignalChange>)signal).getSignalChanges().add(lastChange);
}
}
buildHierarchyNodes();
}
/* (non-Javadoc)
* @see com.minres.scviewer.database.ITrDb#clear()
*/
@Override
public void clear() {
signals.clear();
}
/* (non-Javadoc)
* @see com.minres.scviewer.database.ITrDb#getMaxTime()
*/
@Override
public EventTime getMaxTime() {
return new EventTime(maxTime, TIME_RES);
}
/* (non-Javadoc)
* @see com.minres.scviewer.database.ITrDb#getAllWaves()
*/
@Override
public List<IWaveform> getAllWaves() {
return signals;
}
/* (non-Javadoc)
* @see com.minres.scviewer.database.vcd.ITraceBuilder#enterModule(java.lang.String)
*/
@Override
public void enterModule(String tokenString) {
if(moduleStack.isEmpty())
moduleStack.push(tokenString);
else
moduleStack.push(moduleStack.peek()+"."+tokenString);
}
/* (non-Javadoc)
* @see com.minres.scviewer.database.vcd.ITraceBuilder#exitModule()
*/
@Override
public void exitModule() {
if(!moduleStack.isEmpty()) moduleStack.pop();
}
/* (non-Javadoc)
* @see com.minres.scviewer.database.vcd.ITraceBuilder#newNet(java.lang.String, int, int)
*/
@Override
public Integer newNet(String netName, int i, int width) {
int id = signals.size();
VCDSignal<? extends ISignalChange> signal;
if(width==1){
signal = i<0 ? new VCDSignal<ISignalChangeSingle>(id, netName) :
new VCDSignal<ISignalChangeSingle>(signals.get(i), id, netName);
} else {
signal = i<0 ? new VCDSignal<ISignalChangeMulti>(id, netName, width) :
new VCDSignal<ISignalChangeMulti>(signals.get(i), id, netName);
};
signals.add(signal);
return id;
}
/* (non-Javadoc)
* @see com.minres.scviewer.database.vcd.ITraceBuilder#getNetWidth(int)
*/
@Override
public int getNetWidth(int intValue) {
VCDSignal<? extends ISignalChange> signal = (VCDSignal<? extends ISignalChange>) signals.get(intValue);
return signal.getWidth();
}
/* (non-Javadoc)
* @see com.minres.scviewer.database.vcd.ITraceBuilder#appendTransition(int, long, com.minres.scviewer.database.vcd.BitVector)
*/
@SuppressWarnings("unchecked")
@Override
public void appendTransition(int intValue, long fCurrentTime, BitVector decodedValues) {
VCDSignal<? extends ISignalChange> signal = (VCDSignal<? extends ISignalChange>) signals.get(intValue);
EventTime time = new EventTime(fCurrentTime, TIME_RES);
if(signal.getWidth()==1){
VCDSignalChangeSingle change = new VCDSignalChangeSingle(time, decodedValues.getValue()[0]);
((VCDSignal<ISignalChangeSingle>)signal).addSignalChange(change);
} else {
VCDSignalChangeMulti change = new VCDSignalChangeMulti(time, new String(decodedValues.getValue()));
((VCDSignal<VCDSignalChangeMulti>)signal).addSignalChange(change);
}
maxTime= Math.max(maxTime, fCurrentTime);
}
private void buildHierarchyNodes() throws InputFormatException{
for(IWaveform stream:getAllWaves()){
waveformLookup.put(stream.getFullName(), stream);
String[] hier = stream.getFullName().split("\\.");
IHierNode node = this;
for(String name:hier){
IHierNode n1 = null;
for (IHierNode n : node.getChildNodes()) {
if (n.getName().equals(name)) {
n1=n;
break;
}
}
if(name == hier[hier.length-1]){ //leaf
if(n1!=null) {
if(n1 instanceof HierNode){
node.getChildNodes().remove(n1);
stream.getChildNodes().addAll(n1.getChildNodes());
} else {
throw new InputFormatException();
}
}
stream.setName(name);
node.getChildNodes().add(stream);
node=stream;
} else { // intermediate
if(n1 != null) {
node=n1;
} else {
HierNode newNode = new HierNode(name);
node.getChildNodes().add(newNode);
node=newNode;
}
}
}
}
}
}

View File

@ -0,0 +1,37 @@
package com.minres.scviewer.database.vcd;
import java.io.File;
import java.io.FileInputStream;
import com.minres.scviewer.database.IWaveformDb;
import com.minres.scviewer.database.IWaveformDbFactory;
public class VCDDbFactory implements IWaveformDbFactory {
private byte[] x = "$date".getBytes();
public VCDDbFactory(){
}
@Override
public IWaveformDb createDatabase(File 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 null;
VCDDb db = new VCDDb();
db.load(file);
return db;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}

View File

@ -0,0 +1,212 @@
package com.minres.scviewer.database.vcd;
import java.io.*;
import java.util.*;
class VCDFileParser {
private StreamTokenizer tokenizer;
private IVCDDatabaseBuilder traceBuilder;
private HashMap<String, Integer> nameToNetMap = new HashMap<String, Integer>();
private long picoSecondsPerIncrement;
private boolean stripNetWidth;
long currentTime;
public VCDFileParser(boolean stripNetWidth) {
this.stripNetWidth=stripNetWidth;
}
public boolean load(InputStream is, IVCDDatabaseBuilder builder) {
tokenizer = new StreamTokenizer(new BufferedReader(new InputStreamReader(is)));
tokenizer.resetSyntax();
tokenizer.wordChars(33, 126);
tokenizer.whitespaceChars('\r', '\r');
tokenizer.whitespaceChars('\n', '\n');
tokenizer.whitespaceChars(' ', ' ');
tokenizer.whitespaceChars('\t', '\t');
try {
traceBuilder = builder;
currentTime=0;
while (parseDefinition());
while (parseTransition());
return true;
} catch (Exception exc) {
exc.printStackTrace();
return false;
}
}
private void parseScope() throws Exception {
nextToken(); // Scope type (ignore)
nextToken();
traceBuilder.enterModule(tokenizer.sval);
match("$end");
}
private void parseUpscope() throws Exception {
match("$end");
traceBuilder.exitModule();
}
private void parseVar() throws Exception {
nextToken(); // type
nextToken(); // size
int width = Integer.parseInt(tokenizer.sval);
nextToken();
String id = tokenizer.sval;
nextToken();
String netName = tokenizer.sval;
while (nextToken() && !tokenizer.sval.equals("$end")) {
netName+=tokenizer.sval;
}
Integer net = nameToNetMap.get(id);
if (net == null) {
// We've never seen this net before
if(stripNetWidth){
int openBracket = netName.indexOf('[');
if (openBracket != -1) netName = netName.substring(0, openBracket);
}
nameToNetMap.put(id, traceBuilder.newNet(netName, -1, width));
} else {
// Shares data with existing net. Add as clone.
traceBuilder.newNet(netName, net, width);
}
}
private void parseTimescale() throws Exception {
nextToken();
String s = tokenizer.sval;
nextToken();
while(!tokenizer.sval.equals("$end")){
s+=" "+tokenizer.sval;
nextToken();
}
switch (s.charAt(s.length() - 2)){
case 'p': // Nano-seconds
picoSecondsPerIncrement = 1;
s = s.substring(0, s.length() - 2).trim();
break;
case 'n': // Nano-seconds
picoSecondsPerIncrement = 1000;
s = s.substring(0, s.length() - 2).trim();
break;
case 'u': // Microseconds
picoSecondsPerIncrement = 1000000;
s = s.substring(0, s.length() - 2).trim();
break;
case 'm': // Microseconds
picoSecondsPerIncrement = 1000000000;
s = s.substring(0, s.length() - 2).trim();
break;
default: // Seconds
picoSecondsPerIncrement = 1000000000000L;
s = s.substring(0, s.length() - 1);
break;
}
picoSecondsPerIncrement *= Long.parseLong(s);
}
private boolean parseDefinition() throws Exception {
nextToken();
if (tokenizer.sval.equals("$scope"))
parseScope();
else if (tokenizer.sval.equals("$var"))
parseVar();
else if (tokenizer.sval.equals("$upscope"))
parseUpscope();
else if (tokenizer.sval.equals("$timescale"))
parseTimescale();
else if (tokenizer.sval.equals("$enddefinitions")) {
match("$end");
return false;
} else {
// Ignore this defintion
do {
if (!nextToken()) return false;
} while (!tokenizer.sval.equals("$end"));
}
return true;
}
private boolean parseTransition() throws Exception {
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;
} else {
if(tokenizer.sval.equals("$comment")){
do {
if (!nextToken()) return false;
} while (!tokenizer.sval.equals("$end"));
return true;
}
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
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);
id = tokenizer.sval.substring(1);
}
Integer net = nameToNetMap.get(id);
if (net == null) {
System.out.println("unknown net " + id + " value " + value);
return true;
}
int netWidth = traceBuilder.getNetWidth(net);
BitVector decodedValues = new BitVector(netWidth);
if (value.equals("z") && netWidth > 1) {
for (int i = 0; i < netWidth; i++)
decodedValues.setValue(i, BitVector.VALUE_Z);
} else if (value.equals("x") && netWidth > 1) {
for (int i = 0; i < netWidth; i++)
decodedValues.setValue(i, BitVector.VALUE_X);
} else {
int stringIndex = 0;
for (int convertedIndex = netWidth - value.length(); convertedIndex < netWidth; convertedIndex++) {
switch (value.charAt(stringIndex++)) {
case 'z':
decodedValues.setValue(convertedIndex, BitVector.VALUE_Z);
break;
case '1':
decodedValues.setValue(convertedIndex, BitVector.VALUE_1);
break;
case '0':
decodedValues.setValue(convertedIndex, BitVector.VALUE_0);
break;
case 'x':
decodedValues.setValue(convertedIndex, BitVector.VALUE_X);
break;
default:
decodedValues.setValue(convertedIndex, BitVector.VALUE_X);
}
}
}
traceBuilder.appendTransition(net, currentTime, decodedValues);
}
return true;
}
private void match(String value) throws Exception {
nextToken();
if (!tokenizer.sval.equals(value))
throw new Exception("Line "+tokenizer.lineno()+": parse error, expected "+value+" got "+tokenizer.sval);
}
private boolean nextToken() throws IOException {
return tokenizer.nextToken() != StreamTokenizer.TT_EOF;
}
};

View File

@ -0,0 +1,108 @@
package com.minres.scviewer.database.vcd;
import java.util.Collections;
import java.util.NavigableSet;
import java.util.TreeSet;
import com.minres.scviewer.database.EventTime;
import com.minres.scviewer.database.HierNode;
import com.minres.scviewer.database.ISignal;
import com.minres.scviewer.database.ISignalChange;
import com.minres.scviewer.database.IWaveformDb;
import com.minres.scviewer.database.IWaveform;
import com.minres.scviewer.database.SignalChange;
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;
private VCDDb db;
TreeSet<ISignalChange> values;
public VCDSignal(String name) {
this(0, name, 1);
}
public VCDSignal(int id, String name) {
this(id,name,1);
}
public VCDSignal(int id, String name, int width) {
super(name);
fullName=name;
this.id=id;
this.width=width;
this.values=new TreeSet<ISignalChange>();
}
@SuppressWarnings("unchecked")
public VCDSignal(IWaveform other, int id, String name) {
super(name);
fullName=name;
this.id=id;
assert(other instanceof VCDSignal<?>);
this.width=((VCDSignal<? extends ISignalChange>)other).width;
this.values=((VCDSignal<T>)other).values;
}
@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){
values.add(change);
}
@Override
public NavigableSet<ISignalChange> getSignalChanges() {
return values;
}
@Override
public T getSignalChangeByTime(EventTime time) {
return (T) values.floor(new SignalChange(time));
}
@Override
public NavigableSet<ISignalChange> getSignalChangesByTimes(EventTime start, EventTime end) {
ISignalChange low = values.floor(new SignalChange(start));
ISignalChange high = values.ceiling(new SignalChange(end));
if(high!=null)
return values.subSet(low, true, high, true);
else
return values.subSet(low, true, values.last(), true);
}
}

View File

@ -0,0 +1,28 @@
package com.minres.scviewer.database.vcd;
import com.minres.scviewer.database.EventTime;
import com.minres.scviewer.database.ISignalChangeMulti;
import com.minres.scviewer.database.SignalChange;
public class VCDSignalChangeMulti extends SignalChange implements ISignalChangeMulti, Cloneable {
private String value;
public VCDSignalChangeMulti(EventTime time) {
super(time);
}
public VCDSignalChangeMulti(EventTime time, String value) {
super(time);
this.value=value;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}

View File

@ -0,0 +1,24 @@
package com.minres.scviewer.database.vcd;
import com.minres.scviewer.database.EventTime;
import com.minres.scviewer.database.ISignalChangeSingle;
import com.minres.scviewer.database.SignalChange;
public class VCDSignalChangeSingle extends SignalChange implements ISignalChangeSingle, Cloneable {
private char value;
public VCDSignalChangeSingle(EventTime time, char value) {
super(time);
this.value=value;
}
public char getValue() {
return value;
}
public void setValue(char value) {
this.value = value;
}
}

View File

@ -20,4 +20,3 @@ Bundle-ActivationPolicy: lazy
Import-Package: org.eclipse.ui.views.contentoutline Import-Package: org.eclipse.ui.views.contentoutline
Bundle-ClassPath: ., Bundle-ClassPath: .,
swing2swt.jar swing2swt.jar
Service-Component: OSGI-INF/component.xml

View File

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="com.minres.scviewer.ui">
<implementation class="com.minres.scviewer.ui.TxEditorPlugin"/>
<reference bind="setTransactionDbFactory" cardinality="0..n" interface="com.minres.scviewer.database.ITransactionDbFactory" name="ITransactionDbFactory" policy="dynamic" unbind="unsetTransactionDbFactory"/>
</scr:component>

View File

@ -21,8 +21,8 @@
class="com.minres.scviewer.ui.TxEditorPart" class="com.minres.scviewer.ui.TxEditorPart"
contributorClass="com.minres.scviewer.ui.TxEditorActionBarContributor" contributorClass="com.minres.scviewer.ui.TxEditorActionBarContributor"
extensions="txdb" extensions="txdb"
filenames="*.txdb,*.txlog" filenames="*.txdb,*.txlog,*.vcd"
icon="icons/scviewer.gif" icon="res/images/scviewer.png"
id="com.minres.scviewer.ui.TxEditorPart" id="com.minres.scviewer.ui.TxEditorPart"
name="Wave Viewer"> name="Wave Viewer">
</editor> </editor>

View File

Before

Width:  |  Height:  |  Size: 118 B

After

Width:  |  Height:  |  Size: 118 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 255 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 717 B

View File

@ -13,7 +13,6 @@ package com.minres.scviewer.ui;
import java.io.File; import java.io.File;
import java.util.List; import java.util.List;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.dialogs.MessageDialog;
@ -25,7 +24,6 @@ import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.PartInitException; import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI; import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.ide.FileStoreEditorInput; import org.eclipse.ui.ide.FileStoreEditorInput;
import org.eclipse.ui.internal.ide.dialogs.IFileStoreFilter;
import org.eclipse.ui.part.EditorPart; import org.eclipse.ui.part.EditorPart;
import org.eclipse.ui.views.contentoutline.IContentOutlinePage; import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
import org.eclipse.ui.views.properties.IPropertySheetPage; import org.eclipse.ui.views.properties.IPropertySheetPage;
@ -33,12 +31,12 @@ import org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributo
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage; import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
import org.osgi.framework.BundleContext; import org.osgi.framework.BundleContext;
import org.osgi.framework.FrameworkUtil; import org.osgi.framework.FrameworkUtil;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceReference; import org.osgi.framework.ServiceReference;
import com.minres.scviewer.database.ITrDb; import com.minres.scviewer.database.IWaveformDb;
import com.minres.scviewer.database.ITrStream; import com.minres.scviewer.database.ITxStream;
import com.minres.scviewer.database.ITransactionDbFactory; import com.minres.scviewer.database.IWaveformDbFactory;
import com.minres.scviewer.database.IWaveform;
import com.minres.scviewer.ui.swt.TxDisplay; import com.minres.scviewer.ui.swt.TxDisplay;
import com.minres.scviewer.ui.views.TxOutlinePage; import com.minres.scviewer.ui.views.TxOutlinePage;
@ -51,7 +49,7 @@ public class TxEditorPart extends EditorPart implements ITabbedPropertySheetPage
private TxDisplay txDisplay; private TxDisplay txDisplay;
/** This is the root of the editor's model. */ /** This is the root of the editor's model. */
private ITrDb database; private IWaveformDb database;
private Composite myParent; private Composite myParent;
@ -85,7 +83,7 @@ public class TxEditorPart extends EditorPart implements ITabbedPropertySheetPage
if(getEditorInput()!=null && ((TxEditorInput) getEditorInput()).getStreamNames().size()>0 && database!=null){ if(getEditorInput()!=null && ((TxEditorInput) getEditorInput()).getStreamNames().size()>0 && database!=null){
if(MessageDialog.openConfirm(parent.getShell(), "Confirm", "Do you want the restore last state of the wave form?")) if(MessageDialog.openConfirm(parent.getShell(), "Confirm", "Do you want the restore last state of the wave form?"))
for(String streamName:((TxEditorInput) getEditorInput()).getStreamNames()){ for(String streamName:((TxEditorInput) getEditorInput()).getStreamNames()){
ITrStream stream = database.getStreamByName(streamName); IWaveform stream = database.getStreamByName(streamName);
if(stream!=null) if(stream!=null)
txDisplay.addStream(stream); txDisplay.addStream(stream);
} }
@ -126,10 +124,10 @@ public class TxEditorPart extends EditorPart implements ITabbedPropertySheetPage
protected void getTrDatabase(File file) { protected void getTrDatabase(File file) {
try { try {
BundleContext context = FrameworkUtil.getBundle(this.getClass()).getBundleContext(); BundleContext context = FrameworkUtil.getBundle(this.getClass()).getBundleContext();
ServiceReference<?>[] serviceReferences = context.getServiceReferences(ITransactionDbFactory.class.getName(), null); ServiceReference<?>[] serviceReferences = context.getServiceReferences(IWaveformDbFactory.class.getName(), null);
if(serviceReferences!=null){ if(serviceReferences!=null){
for(ServiceReference<?> serviceReference:serviceReferences){ for(ServiceReference<?> serviceReference:serviceReferences){
database = ((ITransactionDbFactory) context.getService(serviceReference)).createDatabase(file); database = ((IWaveformDbFactory) context.getService(serviceReference)).createDatabase(file);
if(database!=null){ if(database!=null){
if(txDisplay !=null) database.addPropertyChangeListener(txDisplay); if(txDisplay !=null) database.addPropertyChangeListener(txDisplay);
return; return;
@ -180,7 +178,7 @@ public class TxEditorPart extends EditorPart implements ITabbedPropertySheetPage
return super.getAdapter(type); return super.getAdapter(type);
} }
public ITrDb getModel() { public IWaveformDb getModel() {
return database; return database;
} }
@ -202,38 +200,38 @@ public class TxEditorPart extends EditorPart implements ITabbedPropertySheetPage
return false; return false;
} }
public ITrDb getDatabase() { public IWaveformDb getDatabase() {
return database; return database;
} }
public void addStreamToList(ITrStream stream){ public void addStreamToList(IWaveform obj){
if(getEditorInput() instanceof TxEditorInput && !((TxEditorInput) getEditorInput()).getStreamNames().contains(stream.getFullName())){ if(getEditorInput() instanceof TxEditorInput && !((TxEditorInput) getEditorInput()).getStreamNames().contains(obj.getFullName())){
((TxEditorInput) getEditorInput()).getStreamNames().add(stream.getFullName()); ((TxEditorInput) getEditorInput()).getStreamNames().add(obj.getFullName());
txDisplay.addStream(stream); txDisplay.addStream(obj);
} else } else
txDisplay.addStream(stream); txDisplay.addStream(obj);
} }
public void addStreamsToList(ITrStream[] streams){ public void addStreamsToList(IWaveform[] iWaveforms){
for(ITrStream stream:streams) for(IWaveform stream:iWaveforms)
addStreamToList(stream); addStreamToList(stream);
} }
public void removeStreamFromList(ITrStream stream){ public void removeStreamFromList(IWaveform obj){
if(getEditorInput() instanceof TxEditorInput && ((TxEditorInput) getEditorInput()).getStreamNames().contains(stream.getFullName())){ if(getEditorInput() instanceof TxEditorInput && ((TxEditorInput) getEditorInput()).getStreamNames().contains(obj.getFullName())){
((TxEditorInput) getEditorInput()).getStreamNames().remove(stream.getFullName()); ((TxEditorInput) getEditorInput()).getStreamNames().remove(obj.getFullName());
txDisplay.removeStream(stream); txDisplay.removeStream(obj);
} else } else
txDisplay.removeStream(stream); txDisplay.removeStream(obj);
} }
public void removeStreamsFromList(ITrStream[] streams){ public void removeStreamsFromList(IWaveform[] iWaveforms){
for(ITrStream stream:streams) for(IWaveform stream:iWaveforms)
removeStreamFromList(stream); removeStreamFromList(stream);
} }
public List<ITrStream> getStreamList(){ public List<IWaveform> getStreamList(){
return txDisplay.getStreamList(); return txDisplay.getStreamList();
} }

View File

@ -24,7 +24,7 @@ import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.eclipse.wb.swt.SWTResourceManager; import org.eclipse.wb.swt.SWTResourceManager;
import org.osgi.framework.BundleContext; import org.osgi.framework.BundleContext;
import com.minres.scviewer.database.ITransactionDbFactory; import com.minres.scviewer.database.IWaveformDbFactory;
/** /**
* The activator class controls the plug-in life cycle * The activator class controls the plug-in life cycle
@ -133,21 +133,4 @@ public class TxEditorPlugin extends AbstractUIPlugin {
return resourceBundle; return resourceBundle;
} }
private ITransactionDbFactory transactionDbFactory;
private List<ITransactionDbFactory> factories= new ArrayList<ITransactionDbFactory>();
public ITransactionDbFactory getTransactionDbFactory() {
return transactionDbFactory;
}
public void setTransactionDbFactory(ITransactionDbFactory transactionDbFactory) {
factories.add( transactionDbFactory);
System.out.println("Service bound");
}
public void unsetTransactionDbFactory(ITransactionDbFactory transactionDbFactory) {
factories.remove(transactionDbFactory);
System.out.println("Service unbound");
}
} }

View File

@ -3,7 +3,7 @@ package com.minres.scviewer.ui.adapter;
import org.eclipse.core.runtime.IAdapterFactory; import org.eclipse.core.runtime.IAdapterFactory;
import org.eclipse.ui.views.properties.IPropertySource; import org.eclipse.ui.views.properties.IPropertySource;
import com.minres.scviewer.database.ITransaction; import com.minres.scviewer.database.ITx;
public class AdapterFactory implements IAdapterFactory { public class AdapterFactory implements IAdapterFactory {
@ -11,7 +11,7 @@ public class AdapterFactory implements IAdapterFactory {
@Override @Override
public Object getAdapter(Object adaptableObject, Class adapterType) { public Object getAdapter(Object adaptableObject, Class adapterType) {
if (adapterType == IPropertySource.class) if (adapterType == IPropertySource.class)
return new ITransactionPropertySource((ITransaction) adaptableObject); return new ITransactionPropertySource((ITx) adaptableObject);
return null; return null;
} }

View File

@ -16,11 +16,11 @@ import org.eclipse.ui.views.properties.IPropertyDescriptor;
import org.eclipse.ui.views.properties.IPropertySource; import org.eclipse.ui.views.properties.IPropertySource;
import org.eclipse.ui.views.properties.PropertyDescriptor; import org.eclipse.ui.views.properties.PropertyDescriptor;
import com.minres.scviewer.database.ITransaction; import com.minres.scviewer.database.ITx;
public class ITransactionPropertySource implements IPropertySource { public class ITransactionPropertySource implements IPropertySource {
private ITransaction iTransaction; private ITx iTransaction;
public final static String PROPERTY_ID = "ID"; public final static String PROPERTY_ID = "ID";
public final static String PROPERTY_BEGINTIME = "BEGINTIME"; public final static String PROPERTY_BEGINTIME = "BEGINTIME";
@ -29,7 +29,7 @@ public class ITransactionPropertySource implements IPropertySource {
protected IPropertyDescriptor[] propertyDescriptors; protected IPropertyDescriptor[] propertyDescriptors;
public ITransactionPropertySource(ITransaction iTransaction) { public ITransactionPropertySource(ITx iTransaction) {
this.iTransaction=iTransaction; this.iTransaction=iTransaction;
} }

View File

@ -0,0 +1,7 @@
package com.minres.scviewer.ui.swt;
public interface IWaveformWidget {
Transaction highlight(Object sel);
}

View File

@ -70,9 +70,9 @@ public class Ruler extends Composite {
int end=start+e.width; int end=start+e.width;
gc.setBackground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND)); gc.setBackground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
gc.fillRectangle(new Rectangle(0, 0, e.width, height)); gc.fillRectangle(new Rectangle(e.x, e.y, e.width, height));
gc.setBackground(headerBgColor); gc.setBackground(headerBgColor);
gc.fillRectangle(new Rectangle(0, 0, e.width, height - 1)); gc.fillRectangle(new Rectangle(e.x, e.y, e.width, height - 1));
gc.setForeground(headerFgColor); gc.setForeground(headerFgColor);
gc.drawLine(0, bottom, e.width, bottom); gc.drawLine(0, bottom, e.width, bottom);

View File

@ -0,0 +1,168 @@
package com.minres.scviewer.ui.swt;
import java.util.NavigableSet;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.wb.swt.SWTResourceManager;
import com.minres.scviewer.database.EventTime;
import com.minres.scviewer.database.ISignal;
import com.minres.scviewer.database.ISignalChange;
import com.minres.scviewer.database.ISignalChangeMulti;
import com.minres.scviewer.database.ISignalChangeSingle;
import com.minres.scviewer.ui.TxEditorPlugin;
public class SignalWidget extends Canvas implements IWaveformWidget{
static final int trackHeight = 50;
static final int trackInset = 2;
static final int txHeight = trackHeight - 2 * trackInset;
static double zoomFactor = EventTime.NS;
private Color lineColor;
private Color trackBgColor;
private Color color0;
private Color color1;
private Color colorZ;
private Color colorZdark;
private Color colorX;
private Color colorXdark;
private Color colorC;
private long length;
ISignal<ISignalChange> signal;
public SignalWidget(Composite parent, int style) {
super(parent, style);
addPaintListener(new PaintListener() {
public void paintControl(PaintEvent e) {
SignalWidget.this.paintControl(e);
}
});
TxEditorPlugin plugin=TxEditorPlugin.getDefault();
lineColor=plugin.getColor(TxEditorPlugin.lineColor);
trackBgColor=plugin.getColor(TxEditorPlugin.trackBgDarkColor);
color0=SWTResourceManager.getColor(SWT.COLOR_DARK_GREEN);
color1=SWTResourceManager.getColor(SWT.COLOR_GREEN);
colorZ=SWTResourceManager.getColor(SWT.COLOR_GRAY);
colorX=SWTResourceManager.getColor(SWT.COLOR_RED);
colorZdark=SWTResourceManager.getColor(SWT.COLOR_DARK_GRAY);
colorXdark=SWTResourceManager.getColor(SWT.COLOR_DARK_RED);
colorC=SWTResourceManager.getColor(SWT.COLOR_BLUE);
}
public void setTransactions(ISignal<ISignalChange> signal) {
this.signal=signal;
ISignalChange change = signal.getSignalChanges().last();
length=(long) (change.getTime().getValue()/zoomFactor);
layout(true,true);
}
@Override
public Point computeSize (int wHint, int hHint, boolean changed) {
return new Point((int) length, trackHeight);
}
void paintControl(PaintEvent e) {
GC gc = e.gc;
gc.setForeground(lineColor);
gc.setFillRule(SWT.FILL_EVEN_ODD);
gc.setBackground(trackBgColor);
gc.setLineWidth(1);
gc.setLineStyle(SWT.LINE_SOLID);
gc.fillRectangle(new Rectangle(e.x, e.y, e.width, e.height));
ISignalChange lastChange = null;
NavigableSet<ISignalChange> visibleChanges = signal.getSignalChangesByTimes(
new EventTime((long) (e.x*zoomFactor), "fs"),
new EventTime((long) ((e.x+e.width)*zoomFactor), "fs"));
for(ISignalChange actChange:visibleChanges){
if(lastChange!=null){
drawValues(e, gc, lastChange, actChange);
}
lastChange=actChange;
}
}
protected void drawValues(PaintEvent e, GC gc, ISignalChange lastChange, ISignalChange actChange) {
if(lastChange instanceof ISignalChangeSingle){
int yOffset = trackHeight/2;
Color color = colorX;
switch(((ISignalChangeSingle) lastChange).getValue()){
case '1':
color=color1;
yOffset = trackHeight/3;
break;
case '0':
color=color0;
yOffset = 2*trackHeight/3;
break;
case 'Z':
color=colorZ;
break;
default:
}
gc.setForeground(color);
int endTime= (int)(actChange.getTime().getValue()/zoomFactor);
gc.drawLine((int)(lastChange.getTime().getValue()/zoomFactor), yOffset,
endTime, yOffset);
int yNext = trackHeight/2;
switch(((ISignalChangeSingle) actChange).getValue()){
case '1':
yNext = trackHeight/3;
break;
case '0':
yNext = 2*trackHeight/3;
break;
default:
}
gc.setForeground(colorC);
if(yOffset<yNext)
gc.drawLine(endTime, yOffset, endTime, yNext);
else
gc.drawLine(endTime, yNext, endTime, yOffset);
} else if(lastChange instanceof ISignalChangeMulti){
int yOffsetT = trackHeight/3;
int yOffsetM = trackHeight/2;
int yOffsetB = 2*trackHeight/3;
Color color = color1;
Color colorBorder = color0;
ISignalChangeMulti last = (ISignalChangeMulti) lastChange;
if(last.getValue().contains("X")){
color=colorX;
colorBorder=colorXdark;
}else if(last.getValue().contains("Z")){
color=colorZ;
colorBorder=colorZdark;
}
int beginTime= (int)(lastChange.getTime().getValue()/zoomFactor);
int endTime= (int)(actChange.getTime().getValue()/zoomFactor);
int[] points = {
beginTime,yOffsetM,
beginTime+1,yOffsetT,
endTime-1,yOffsetT,
endTime,yOffsetM,
endTime-1,yOffsetB,
beginTime+1,yOffsetB
};
gc.setBackground(color);
gc.fillPolygon(points);
gc.setForeground(colorBorder);
gc.drawPolygon(points);
gc.drawText(last.getValue(), beginTime+1, yOffsetT+1);
}
}
@Override
public Transaction highlight(Object sel) {
// TODO Auto-generated method stub
return null;
}
}

View File

@ -21,10 +21,10 @@ import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Layout; import org.eclipse.swt.widgets.Layout;
import com.minres.scviewer.database.EventTime; import com.minres.scviewer.database.EventTime;
import com.minres.scviewer.database.ITransaction; import com.minres.scviewer.database.ITx;
import com.minres.scviewer.ui.TxEditorPlugin; import com.minres.scviewer.ui.TxEditorPlugin;
public class Track extends Composite implements MouseListener { public class Track extends Composite implements IWaveformWidget, MouseListener {
static final int trackHeight = 50; static final int trackHeight = 50;
static final int trackInset = 2; static final int trackInset = 2;
@ -34,9 +34,9 @@ public class Track extends Composite implements MouseListener {
private Color lineColor; private Color lineColor;
private Color trackBgColor; private Color trackBgColor;
private ITransaction highlightedTx=null; private ITx highlightedTx=null;
private HashMap<ITransaction, Transaction> transactionMap = new HashMap<ITransaction, Transaction>(); private HashMap<ITx, Transaction> transactionMap = new HashMap<ITx, Transaction>();
class TrackLayoutData { class TrackLayoutData {
protected int x, y; protected int x, y;
@ -121,11 +121,11 @@ public class Track extends Composite implements MouseListener {
} }
public void setTransactions(List<ITransaction> transactions) { public void setTransactions(List<ITx> transactions) {
Vector<ITransaction> rowendtime = new Vector<ITransaction>(); Vector<ITx> rowendtime = new Vector<ITx>();
for (ITransaction tx : transactions) { for (ITx tx : transactions) {
int rowIdx = 0; int rowIdx = 0;
for (ITransaction lastTx : rowendtime) { for (ITx lastTx : rowendtime) {
if((lastTx.getEndTime().getValue()-lastTx.getBeginTime().getValue())>0){ if((lastTx.getEndTime().getValue()-lastTx.getBeginTime().getValue())>0){
if (lastTx.getEndTime().compareTo(tx.getBeginTime())<=0 ) if (lastTx.getEndTime().compareTo(tx.getBeginTime())<=0 )
break; break;
@ -187,16 +187,19 @@ public class Track extends Composite implements MouseListener {
this.notifyListeners(SWT.MouseUp, event); this.notifyListeners(SWT.MouseUp, event);
} }
public Transaction highlightTransaction(ITransaction tx){ public Transaction highlight(Object obj){
if(highlightedTx!=null){ if(obj instanceof ITx){
transactionMap.get(highlightedTx).highlight(false); ITx tx = (ITx) obj;
highlightedTx=null; if(highlightedTx!=null){
} transactionMap.get(highlightedTx).highlight(false);
if(tx!=null && transactionMap.containsKey(tx)){ highlightedTx=null;
Transaction trans = transactionMap.get(tx); }
trans.highlight(true); if(tx!=null && transactionMap.containsKey(tx)){
highlightedTx=tx; Transaction trans = transactionMap.get(tx);
return trans; trans.highlight(true);
highlightedTx=tx;
return trans;
}
} }
return null; return null;
} }

View File

@ -52,14 +52,17 @@ import org.eclipse.wb.swt.SWTResourceManager;
import swing2swt.layout.BorderLayout; import swing2swt.layout.BorderLayout;
import com.minres.scviewer.database.ITrStream; import com.minres.scviewer.database.ISignal;
import com.minres.scviewer.database.ITransaction; import com.minres.scviewer.database.ISignalChange;
import com.minres.scviewer.database.ITxStream;
import com.minres.scviewer.database.ITx;
import com.minres.scviewer.database.IWaveform;
public class TxDisplay implements PropertyChangeListener, ISelectionProvider, MouseListener{ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, MouseListener{
private ListenerList listeners = new ListenerList(); private ListenerList listeners = new ListenerList();
private ITrStream currentStreamSelection; private ITxStream currentStreamSelection;
private ITransaction currentSelection; private ITx currentSelection;
private ScrolledComposite valueListScrolled; private ScrolledComposite valueListScrolled;
private ScrolledComposite nameListScrolled; private ScrolledComposite nameListScrolled;
private Composite nameList; private Composite nameList;
@ -67,10 +70,10 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
private ScrolledComposite trackListScrolled; private ScrolledComposite trackListScrolled;
private Composite trackList; private Composite trackList;
private Composite top; private Composite top;
private ArrayList<ITrStream> streams=new ArrayList<ITrStream>(); private ArrayList<IWaveform> streams=new ArrayList<IWaveform>();
private Composite trackPane; private Composite trackPane;
private Ruler ruler; private Ruler ruler;
private HashMap<ITrStream, Track> trackMap = new HashMap<ITrStream, Track>(); private HashMap<IWaveform, IWaveformWidget> trackMap = new HashMap<IWaveform, IWaveformWidget>();
public TxDisplay(Composite parent) { public TxDisplay(Composite parent) {
top = new Composite(parent, SWT.NONE); top = new Composite(parent, SWT.NONE);
@ -207,40 +210,63 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
} }
public void streamListChanged() { public void streamListChanged() {
LinkedList<ITrStream>toAdd = new LinkedList<ITrStream>(); LinkedList<IWaveform>toAdd = new LinkedList<IWaveform>();
toAdd.addAll(streams); toAdd.addAll(streams);
for(Control child:trackList.getChildren()){ for(Control child:trackList.getChildren()){
Track track = (Track) child; IWaveform stream=(IWaveform) child.getData("WAVEFORM");
Control c = (Control)track.getData("NAMEWIDGET");
ITrStream stream=(ITrStream) track.getData("STREAM");
if(!streams.contains(stream)){ if(!streams.contains(stream)){
track.setVisible(false); child.setVisible(false);
c.setVisible(false); ((Control)(child.getData("NAMEWIDGET"))).setVisible(false);
((Control)(child.getData("VALUEWIDGET"))).setVisible(false);
}else{ }else{
toAdd.remove(stream); toAdd.remove(stream);
track.setVisible(true); child.setVisible(true);
c.setVisible(true); ((Control)(child.getData("NAMEWIDGET"))).setVisible(true);
((Control)(child.getData("VALUEWIDGET"))).setVisible(true);
} }
} }
for(ITrStream stream: toAdd){ for(IWaveform wave: toAdd){
Track track = new Track(trackList,SWT.NONE); if(wave instanceof ITxStream){
track.setTransactions(stream.getTransactions()); ITxStream stream = (ITxStream) wave;
track.setData("STREAM", stream); Track track = new Track(trackList,SWT.NONE);
track.addMouseListener(this); track.setTransactions(stream.getTransactions());
Point trackSize = track.computeSize(SWT.DEFAULT,SWT.DEFAULT); track.setData("WAVEFORM", stream);
track.addMouseListener(this);
Label trackName = new Label(nameList, SWT.NONE); Point trackSize = track.computeSize(SWT.DEFAULT,SWT.DEFAULT);
trackName.setText(stream.getFullName());
RowData trackNamelayoutData = new RowData(SWT.DEFAULT, trackSize.y); Label trackName = new Label(nameList, SWT.NONE);
trackName.setLayoutData(trackNamelayoutData); trackName.setText(stream.getFullName());
track.setData("NAMEWIDGET", trackName); RowData trackNamelayoutData = new RowData(SWT.DEFAULT, trackSize.y);
trackName.setLayoutData(trackNamelayoutData);
Label trackValue = new Label(valueList, SWT.NONE); track.setData("NAMEWIDGET", trackName);
trackValue.setText("-");
RowData trackValuelayoutData = new RowData(SWT.DEFAULT, trackSize.y); Label trackValue = new Label(valueList, SWT.NONE);
trackValue.setLayoutData(trackValuelayoutData); trackValue.setText("-");
track.setData("VALUEWIDGET", trackValue); RowData trackValuelayoutData = new RowData(SWT.DEFAULT, trackSize.y);
trackMap.put(stream, track); trackValue.setLayoutData(trackValuelayoutData);
track.setData("VALUEWIDGET", trackValue);
trackMap.put(stream, track);
} else if(wave instanceof ISignal<?>){
ISignal<ISignalChange> isignal = (ISignal<ISignalChange>) wave;
SignalWidget signal = new SignalWidget(trackList, SWT.NONE);
signal.setTransactions(isignal);
signal.setData("WAVEFORM", isignal);
signal.addMouseListener(this);
Point trackSize = signal.computeSize(SWT.DEFAULT,SWT.DEFAULT);
Label trackName = new Label(nameList, SWT.NONE);
trackName.setText(isignal.getFullName());
RowData trackNamelayoutData = new RowData(SWT.DEFAULT, trackSize.y);
trackName.setLayoutData(trackNamelayoutData);
signal.setData("NAMEWIDGET", trackName);
Label trackValue = new Label(valueList, SWT.NONE);
trackValue.setText("-");
RowData trackValuelayoutData = new RowData(SWT.DEFAULT, trackSize.y);
trackValue.setLayoutData(trackValuelayoutData);
signal.setData("VALUEWIDGET", trackValue);
trackMap.put(isignal, signal);
}
} }
recalculateNameBounds(); recalculateNameBounds();
recalculateValueBounds(); recalculateValueBounds();
@ -276,9 +302,9 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
@Override @Override
public void propertyChange(PropertyChangeEvent pce) { public void propertyChange(PropertyChangeEvent pce) {
currentSelection=null; currentSelection=null;
ITrStream str = (ITrStream)pce.getNewValue(); ITxStream str = (ITxStream)pce.getNewValue();
if(str instanceof ITrStream) if(str instanceof ITxStream)
currentStreamSelection=(ITrStream)str; currentStreamSelection=(ITxStream)str;
if(currentStreamSelection!=null) if(currentStreamSelection!=null)
setSelection(getSelection()); setSelection(getSelection());
else else
@ -309,15 +335,15 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
public void setSelection(ISelection selection) { public void setSelection(ISelection selection) {
if(selection instanceof IStructuredSelection){ if(selection instanceof IStructuredSelection){
Object sel =((IStructuredSelection)selection).getFirstElement(); Object sel =((IStructuredSelection)selection).getFirstElement();
if(sel instanceof ITransaction && currentSelection!=sel){ if(sel instanceof ITx && currentSelection!=sel){
if(currentSelection!=null){ if(currentSelection!=null){
ITrStream stream = currentSelection.getGenerator().getStream(); ITxStream stream = currentSelection.getGenerator().getStream();
if(trackMap.containsKey(stream)) trackMap.get(stream).highlightTransaction(null); if(trackMap.containsKey(stream)) trackMap.get(stream).highlight(null);
} }
currentSelection=(ITransaction) sel; currentSelection=(ITx) sel;
ITrStream stream = currentSelection.getGenerator().getStream(); ITxStream stream = currentSelection.getGenerator().getStream();
if(trackMap.containsKey(stream)){ if(trackMap.containsKey(stream)){
Transaction trans = trackMap.get(stream).highlightTransaction(currentSelection); Transaction trans = trackMap.get(stream).highlight(sel);
trackListScrolled.showControl(trans); trackListScrolled.showControl(trans);
} }
Object[] list = listeners.getListeners(); Object[] list = listeners.getListeners();
@ -337,7 +363,7 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
if(e.data!=null){ if(e.data!=null){
StructuredSelection sel = new StructuredSelection(((Transaction)e.data).getData()); StructuredSelection sel = new StructuredSelection(((Transaction)e.data).getData());
setSelection(sel); setSelection(sel);
}else{ }else if(e.widget instanceof Track){
StructuredSelection sel = new StructuredSelection(new Object[]{ ((Track)e.widget).getData()}); StructuredSelection sel = new StructuredSelection(new Object[]{ ((Track)e.widget).getData()});
setSelection(sel); setSelection(sel);
} }
@ -347,26 +373,26 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
public void mouseUp(MouseEvent e) { public void mouseUp(MouseEvent e) {
} }
public boolean addStream(ITrStream paramE){ public boolean addStream(IWaveform stream){
boolean res = streams.add(paramE); boolean res = streams.add(stream);
streamListChanged(); streamListChanged();
return res; return res;
} }
public boolean addAllStreams(ITrStream[] streams) { public boolean addAllStreams(ITxStream[] streams) {
boolean res = this.streams.addAll(Arrays.asList(streams)); boolean res = this.streams.addAll(Arrays.asList(streams));
streamListChanged(); streamListChanged();
return res; return res;
} }
public boolean addAllStreams(Collection<? extends ITrStream> paramCollection){ public boolean addAllStreams(Collection<? extends ITxStream> paramCollection){
boolean res = streams.addAll(paramCollection); boolean res = streams.addAll(paramCollection);
streamListChanged(); streamListChanged();
return res; return res;
} }
public boolean removeStream(ITrStream paramObject){ public boolean removeStream(IWaveform obj){
boolean res = streams.remove(paramObject); boolean res = streams.remove(obj);
streamListChanged(); streamListChanged();
return res; return res;
} }
@ -377,11 +403,11 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
return res; return res;
} }
public List<ITrStream> getStreamList(){ public List<IWaveform> getStreamList(){
return Collections.unmodifiableList(streams); return Collections.unmodifiableList(streams);
} }
public boolean removeAllStreams(ITrStream[] streams) { public boolean removeAllStreams(ITxStream[] streams) {
boolean res = this.streams.removeAll(Arrays.asList(streams)); boolean res = this.streams.removeAll(Arrays.asList(streams));
streamListChanged(); streamListChanged();
return res; return res;

View File

@ -35,9 +35,10 @@ import org.eclipse.ui.part.IPageSite;
import org.eclipse.ui.views.contentoutline.ContentOutline; import org.eclipse.ui.views.contentoutline.ContentOutline;
import org.eclipse.ui.views.contentoutline.ContentOutlinePage; import org.eclipse.ui.views.contentoutline.ContentOutlinePage;
import com.minres.scviewer.database.ITrHierNode; import com.minres.scviewer.database.IHierNode;
import com.minres.scviewer.database.ITrStream; import com.minres.scviewer.database.ITxStream;
import com.minres.scviewer.database.ITransaction; import com.minres.scviewer.database.ITx;
import com.minres.scviewer.database.IWaveform;
import com.minres.scviewer.ui.TxEditorPart; import com.minres.scviewer.ui.TxEditorPart;
import com.minres.scviewer.ui.views.provider.TxDbTreeContentProvider; import com.minres.scviewer.ui.views.provider.TxDbTreeContentProvider;
import com.minres.scviewer.ui.views.provider.TxDbTreeLabelProvider; import com.minres.scviewer.ui.views.provider.TxDbTreeLabelProvider;
@ -124,10 +125,10 @@ public class TxOutlinePage extends ContentOutlinePage implements ISelectionList
if(selection instanceof IStructuredSelection){ if(selection instanceof IStructuredSelection){
IStructuredSelection sel = (IStructuredSelection) selection; IStructuredSelection sel = (IStructuredSelection) selection;
Object obj = sel.getFirstElement(); Object obj = sel.getFirstElement();
menuMgr.add(makeStreamAction("Add to Wave", ISharedImages.IMG_OBJ_ADD, sel, obj instanceof ITrStream, false)); menuMgr.add(makeStreamAction("Add to Wave", ISharedImages.IMG_OBJ_ADD, sel, obj instanceof IWaveform, false));
menuMgr.add(makeStreamAction("Add all to Wave", ISharedImages.IMG_OBJ_ADD, sel, true, false)); menuMgr.add(makeStreamAction("Add all to Wave", ISharedImages.IMG_OBJ_ADD, sel, true, false));
menuMgr.add(makeStreamAction("Remove from Wave", ISharedImages.IMG_TOOL_DELETE, sel, obj instanceof ITrStream,true)); // menuMgr.add(makeStreamAction("Remove from Wave", ISharedImages.IMG_TOOL_DELETE, sel, obj instanceof IWaveform, true));
menuMgr.add(makeStreamAction("Remove all from Wave", ISharedImages.IMG_TOOL_DELETE, sel, true, true)); // menuMgr.add(makeStreamAction("Remove all from Wave", ISharedImages.IMG_TOOL_DELETE, sel, true, true));
} }
} }
@ -168,8 +169,8 @@ public class TxOutlinePage extends ContentOutlinePage implements ISelectionList
ISelection selection = anEvent.getSelection(); ISelection selection = anEvent.getSelection();
if (!selection.isEmpty()) { if (!selection.isEmpty()) {
Object tmp = ((IStructuredSelection) selection).getFirstElement(); Object tmp = ((IStructuredSelection) selection).getFirstElement();
if (tmp instanceof ITrHierNode) { if (tmp instanceof IHierNode) {
fireSelectionChanged(new StructuredSelection((ITrHierNode) tmp)); fireSelectionChanged(new StructuredSelection((IHierNode) tmp));
} }
} }
} }
@ -179,31 +180,31 @@ public class TxOutlinePage extends ContentOutlinePage implements ISelectionList
public void run() { public void run() {
if(selection!=null) if(selection!=null)
for(Object obj :selection.toArray()){ for(Object obj :selection.toArray()){
if(obj instanceof ITrStream){ if(obj instanceof IWaveform){
if(remove) if(remove)
editor.removeStreamFromList((ITrStream) obj); editor.removeStreamFromList((IWaveform) obj);
else else
editor.addStreamToList((ITrStream) obj); editor.addStreamToList((IWaveform) obj);
} else if(obj instanceof ITrHierNode){ } else if(obj instanceof IHierNode){
LinkedList<ITrHierNode> queue = new LinkedList<ITrHierNode>(); LinkedList<IHierNode> queue = new LinkedList<IHierNode>();
LinkedList<ITrStream> streams = new LinkedList<ITrStream>(); LinkedList<IWaveform> streams = new LinkedList<IWaveform>();
queue.add((ITrHierNode)obj); queue.add((IHierNode)obj);
while(queue.size()>0){ while(queue.size()>0){
ITrHierNode n = queue.poll(); IHierNode n = queue.poll();
if(n instanceof ITrStream) streams.add((ITrStream) n); if(n instanceof IWaveform) streams.add((IWaveform) n);
queue.addAll(n.getChildNodes()); queue.addAll(n.getChildNodes());
} }
if(remove) if(remove)
editor.removeStreamsFromList(streams.toArray(new ITrStream[]{})); editor.removeStreamsFromList(streams.toArray(new IWaveform[]{}));
else else
editor.addStreamsToList(streams.toArray(new ITrStream[]{})); editor.addStreamsToList(streams.toArray(new IWaveform[]{}));
} }
} }
} }
}; };
action.setText(text); action.setText(text);
action.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(imgDescriptor)); action.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(imgDescriptor));
if(selection.getFirstElement() instanceof ITrStream && editor.getStreamList().contains(selection.getFirstElement())) if(selection.getFirstElement() instanceof IWaveform && editor.getStreamList().contains(selection.getFirstElement()))
action.setEnabled(false); action.setEnabled(false);
else else
action.setEnabled(true); action.setEnabled(true);

View File

@ -13,19 +13,19 @@ package com.minres.scviewer.ui.views.provider;
import org.eclipse.jface.viewers.ITreeContentProvider; import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.Viewer;
import com.minres.scviewer.database.ITrDb; import com.minres.scviewer.database.IWaveformDb;
import com.minres.scviewer.database.ITrHierNode; import com.minres.scviewer.database.IHierNode;
public class TxDbTreeContentProvider implements ITreeContentProvider { public class TxDbTreeContentProvider implements ITreeContentProvider {
private ITrDb database; private IWaveformDb database;
@Override @Override
public void dispose() { } public void dispose() { }
@Override @Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
database=(ITrDb)newInput; database=(IWaveformDb)newInput;
} }
@Override @Override
@ -35,8 +35,8 @@ public class TxDbTreeContentProvider implements ITreeContentProvider {
@Override @Override
public Object[] getChildren(Object parentElement) { public Object[] getChildren(Object parentElement) {
if(parentElement instanceof ITrHierNode){ if(parentElement instanceof IHierNode){
return ((ITrHierNode)parentElement).getChildNodes().toArray(); return ((IHierNode)parentElement).getChildNodes().toArray();
} }
return null; return null;
} }

View File

@ -17,9 +17,10 @@ import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ILabelProviderListener; import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.Image;
import com.minres.scviewer.database.ITrDb; import com.minres.scviewer.database.ISignal;
import com.minres.scviewer.database.ITrHierNode; import com.minres.scviewer.database.IWaveformDb;
import com.minres.scviewer.database.ITrStream; import com.minres.scviewer.database.IHierNode;
import com.minres.scviewer.database.ITxStream;
import com.minres.scviewer.ui.TxEditorPlugin; import com.minres.scviewer.ui.TxEditorPlugin;
public class TxDbTreeLabelProvider implements ILabelProvider { public class TxDbTreeLabelProvider implements ILabelProvider {
@ -28,6 +29,7 @@ public class TxDbTreeLabelProvider implements ILabelProvider {
private Image database; private Image database;
private Image stream; private Image stream;
private Image signal;
private Image folder; private Image folder;
@ -36,6 +38,7 @@ public class TxDbTreeLabelProvider implements ILabelProvider {
database=TxEditorPlugin.createImage("database"); database=TxEditorPlugin.createImage("database");
stream=TxEditorPlugin.createImage("stream"); stream=TxEditorPlugin.createImage("stream");
folder=TxEditorPlugin.createImage("folder"); folder=TxEditorPlugin.createImage("folder");
signal=TxEditorPlugin.createImage("signal");
} }
@Override @Override
@ -48,6 +51,7 @@ public class TxDbTreeLabelProvider implements ILabelProvider {
if(database!=null) database.dispose(); if(database!=null) database.dispose();
if(stream!=null) stream.dispose(); if(stream!=null) stream.dispose();
if(folder!=null) folder.dispose(); if(folder!=null) folder.dispose();
if(signal!=null) signal.dispose();
} }
@Override @Override
@ -62,11 +66,13 @@ public class TxDbTreeLabelProvider implements ILabelProvider {
@Override @Override
public Image getImage(Object element) { public Image getImage(Object element) {
if(element instanceof ITrDb){ if(element instanceof IWaveformDb){
return database; return database;
}else if(element instanceof ITrStream){ }else if(element instanceof ITxStream){
return stream; return stream;
}else if(element instanceof ITrHierNode){ }else if(element instanceof ISignal<?>){
return signal;
}else if(element instanceof IHierNode){
return folder; return folder;
} else } else
return null; return null;
@ -74,7 +80,7 @@ public class TxDbTreeLabelProvider implements ILabelProvider {
@Override @Override
public String getText(Object element) { public String getText(Object element) {
return ((ITrHierNode)element).getName(); return ((IHierNode)element).getName();
} }
} }

View File

@ -44,8 +44,8 @@ import org.eclipse.ui.views.properties.tabbed.AbstractPropertySection;
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage; import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
import com.minres.scviewer.database.AssociationType; import com.minres.scviewer.database.AssociationType;
import com.minres.scviewer.database.ITrAttribute; import com.minres.scviewer.database.ITxAttribute;
import com.minres.scviewer.database.ITransaction; import com.minres.scviewer.database.ITx;
public class AttributeProperty extends AbstractPropertySection implements ISelectionProvider { public class AttributeProperty extends AbstractPropertySection implements ISelectionProvider {
@ -53,7 +53,7 @@ public class AttributeProperty extends AbstractPropertySection implements ISelec
private ListenerList listeners = new ListenerList(); private ListenerList listeners = new ListenerList();
private ITransaction iTr; private ITx iTr;
private ISelection currentSelection; private ISelection currentSelection;
@ -104,19 +104,19 @@ public class AttributeProperty extends AbstractPropertySection implements ISelec
treeViewer.setAutoExpandLevel(2); treeViewer.setAutoExpandLevel(2);
treeViewer.setContentProvider(new ITreeContentProvider() { treeViewer.setContentProvider(new ITreeContentProvider() {
TreeMap<String, List<ITrAttribute>> hier = new TreeMap<String, List<ITrAttribute>>(); TreeMap<String, List<ITxAttribute>> hier = new TreeMap<String, List<ITxAttribute>>();
HashMap<ITrAttribute, String> parents = new HashMap<ITrAttribute, String>(); HashMap<ITxAttribute, String> parents = new HashMap<ITxAttribute, String>();
@Override @Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
if (newInput instanceof ITransaction) { if (newInput instanceof ITx) {
List<ITrAttribute> attributes = ((ITransaction)newInput).getAttributes(); List<ITxAttribute> attributes = ((ITx)newInput).getAttributes();
hier.clear(); hier.clear();
parents.clear(); parents.clear();
String location="Begin"; String location="Begin";
List<ITrAttribute> childs=new LinkedList<ITrAttribute>(); List<ITxAttribute> childs=new LinkedList<ITxAttribute>();
for (ITrAttribute attr : attributes) for (ITxAttribute attr : attributes)
if (attr != null && attr.getType()==AssociationType.BEGIN){ if (attr != null && attr.getType()==AssociationType.BEGIN){
childs.add(attr); childs.add(attr);
parents.put(attr, location); parents.put(attr, location);
@ -124,8 +124,8 @@ public class AttributeProperty extends AbstractPropertySection implements ISelec
if(childs.size()>0) hier.put(location, childs); if(childs.size()>0) hier.put(location, childs);
location="Transaction"; location="Transaction";
childs=new LinkedList<ITrAttribute>(); childs=new LinkedList<ITxAttribute>();
for (ITrAttribute attr : attributes) for (ITxAttribute attr : attributes)
if (attr != null && attr.getType()==AssociationType.RECORD){ if (attr != null && attr.getType()==AssociationType.RECORD){
childs.add(attr); childs.add(attr);
parents.put(attr, location); parents.put(attr, location);
@ -133,8 +133,8 @@ public class AttributeProperty extends AbstractPropertySection implements ISelec
if(childs.size()>0) hier.put(location, childs); if(childs.size()>0) hier.put(location, childs);
location="End"; location="End";
childs=new LinkedList<ITrAttribute>(); childs=new LinkedList<ITxAttribute>();
for (ITrAttribute attr : attributes) for (ITxAttribute attr : attributes)
if (attr != null && attr.getType()==AssociationType.END){ if (attr != null && attr.getType()==AssociationType.END){
childs.add(attr); childs.add(attr);
parents.put(attr, location); parents.put(attr, location);
@ -154,7 +154,7 @@ public class AttributeProperty extends AbstractPropertySection implements ISelec
@Override @Override
public Object getParent(Object element) { public Object getParent(Object element) {
if (element instanceof ITrAttribute) if (element instanceof ITxAttribute)
return parents.get(element); return parents.get(element);
else else
return null; return null;
@ -192,8 +192,8 @@ public class AttributeProperty extends AbstractPropertySection implements ISelec
public String getColumnText(Object element, int columnIndex) { public String getColumnText(Object element, int columnIndex) {
if (columnIndex == 0 && element instanceof String) if (columnIndex == 0 && element instanceof String)
return element.toString(); return element.toString();
else if(element instanceof ITrAttribute){ else if(element instanceof ITxAttribute){
ITrAttribute attr = (ITrAttribute)element; ITxAttribute attr = (ITxAttribute)element;
if (columnIndex == 1 ) if (columnIndex == 1 )
return attr.getName(); return attr.getName();
else if (columnIndex == 2 ) else if (columnIndex == 2 )
@ -235,8 +235,8 @@ public class AttributeProperty extends AbstractPropertySection implements ISelec
currentSelection = null; currentSelection = null;
Assert.isTrue(selection instanceof IStructuredSelection); Assert.isTrue(selection instanceof IStructuredSelection);
Object input = ((IStructuredSelection) selection).getFirstElement(); Object input = ((IStructuredSelection) selection).getFirstElement();
Assert.isTrue(input instanceof ITransaction); Assert.isTrue(input instanceof ITx);
iTr = (ITransaction) input; iTr = (ITx) input;
} }
public void refresh() { public void refresh() {

View File

@ -49,8 +49,8 @@ import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.views.properties.tabbed.AbstractPropertySection; import org.eclipse.ui.views.properties.tabbed.AbstractPropertySection;
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage; import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
import com.minres.scviewer.database.ITrRelation; import com.minres.scviewer.database.ITxRelation;
import com.minres.scviewer.database.ITransaction; import com.minres.scviewer.database.ITx;
import com.minres.scviewer.database.RelationType; import com.minres.scviewer.database.RelationType;
public class RelatedProperty extends AbstractPropertySection implements ISelectionProvider, ISelectionChangedListener { public class RelatedProperty extends AbstractPropertySection implements ISelectionProvider, ISelectionChangedListener {
@ -59,7 +59,7 @@ public class RelatedProperty extends AbstractPropertySection implements ISelecti
private ListenerList listeners = new ListenerList(); private ListenerList listeners = new ListenerList();
private ITransaction iTr; private ITx iTr;
private ISelection currentSelection; private ISelection currentSelection;
@ -105,26 +105,26 @@ public class RelatedProperty extends AbstractPropertySection implements ISelecti
treeViewer.setAutoExpandLevel(2); treeViewer.setAutoExpandLevel(2);
treeViewer.setContentProvider(new ITreeContentProvider() { treeViewer.setContentProvider(new ITreeContentProvider() {
TreeMap<String, Collection<ITrRelation>> hier = new TreeMap<String, Collection<ITrRelation>>(); TreeMap<String, Collection<ITxRelation>> hier = new TreeMap<String, Collection<ITxRelation>>();
HashMap<ITrRelation, String> parents = new HashMap<ITrRelation, String>(); HashMap<ITxRelation, String> parents = new HashMap<ITxRelation, String>();
@Override @Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
if (newInput instanceof ITransaction) { if (newInput instanceof ITx) {
hier.clear(); hier.clear();
parents.clear(); parents.clear();
String relName = "incoming"; String relName = "incoming";
Collection<ITrRelation> relSet = ((ITransaction)newInput).getIncomingRelations(); Collection<ITxRelation> relSet = ((ITx)newInput).getIncomingRelations();
if (relSet != null && relSet.size() > 0) { if (relSet != null && relSet.size() > 0) {
hier.put(relName, relSet); hier.put(relName, relSet);
for (ITrRelation rel : relSet) for (ITxRelation rel : relSet)
parents.put(rel, relName); parents.put(rel, relName);
} }
relName = "outgoing"; relName = "outgoing";
relSet = ((ITransaction)newInput).getOutgoingRelations(); relSet = ((ITx)newInput).getOutgoingRelations();
if (relSet != null && relSet.size() > 0) { if (relSet != null && relSet.size() > 0) {
hier.put(relName, relSet); hier.put(relName, relSet);
for (ITrRelation rel : relSet) for (ITxRelation rel : relSet)
parents.put(rel, relName); parents.put(rel, relName);
} }
} }
@ -141,7 +141,7 @@ public class RelatedProperty extends AbstractPropertySection implements ISelecti
@Override @Override
public Object getParent(Object element) { public Object getParent(Object element) {
if (element instanceof ITransaction) if (element instanceof ITx)
return parents.get(element); return parents.get(element);
else else
return null; return null;
@ -179,14 +179,14 @@ public class RelatedProperty extends AbstractPropertySection implements ISelecti
public String getColumnText(Object element, int columnIndex) { public String getColumnText(Object element, int columnIndex) {
if (columnIndex == 0 && element instanceof String) if (columnIndex == 0 && element instanceof String)
return element.toString(); return element.toString();
else if (columnIndex == 1 && element instanceof ITrRelation) else if (columnIndex == 1 && element instanceof ITxRelation)
return ((ITrRelation) element).getRelationType().getName(); return ((ITxRelation) element).getRelationType().getName();
else if (columnIndex == 2 && element instanceof ITrRelation){ else if (columnIndex == 2 && element instanceof ITxRelation){
ITrRelation rel = (ITrRelation) element; ITxRelation rel = (ITxRelation) element;
if(rel.getTarget()==iTr) if(rel.getTarget()==iTr)
return ((ITrRelation) element).getSource().getId().toString(); return ((ITxRelation) element).getSource().getId().toString();
else else
return ((ITrRelation) element).getTarget().getId().toString(); return ((ITxRelation) element).getTarget().getId().toString();
} }
else else
return null; return null;
@ -217,13 +217,13 @@ public class RelatedProperty extends AbstractPropertySection implements ISelecti
// } // }
} }
private Action makeTransactionAction(final Object obj, final ITransaction transaction) { private Action makeTransactionAction(final Object obj, final ITx transaction) {
Action action = new Action() { Action action = new Action() {
public void run() { public void run() {
if(obj instanceof ITrRelation){ if(obj instanceof ITxRelation){
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
ITransaction targetTransaction = ((ITrRelation)obj).getSource()==transaction? ITx targetTransaction = ((ITxRelation)obj).getSource()==transaction?
((ITrRelation)obj).getTarget():((ITrRelation)obj).getSource(); ((ITxRelation)obj).getTarget():((ITxRelation)obj).getSource();
for(IEditorReference editorRef: page.getEditorReferences()){ for(IEditorReference editorRef: page.getEditorReferences()){
IWorkbenchPart part =editorRef.getPart(false); IWorkbenchPart part =editorRef.getPart(false);
if(editorRef.getPage().isPartVisible(part)){ if(editorRef.getPage().isPartVisible(part)){
@ -245,8 +245,8 @@ public class RelatedProperty extends AbstractPropertySection implements ISelecti
currentSelection = null; currentSelection = null;
Assert.isTrue(selection instanceof IStructuredSelection); Assert.isTrue(selection instanceof IStructuredSelection);
Object input = ((IStructuredSelection) selection).getFirstElement(); Object input = ((IStructuredSelection) selection).getFirstElement();
Assert.isTrue(input instanceof ITransaction); Assert.isTrue(input instanceof ITx);
iTr = (ITransaction) input; iTr = (ITx) input;
} }
public void refresh() { public void refresh() {

View File

@ -59,8 +59,19 @@ public:
clk("clk"), rw("rw"), addr_req("addr_req"), addr_ack("addr_ack"), bus_addr("bus_addr"), data_rdy("data_rdy"), bus_data( clk("clk"), rw("rw"), addr_req("addr_req"), addr_ack("addr_ack"), bus_addr("bus_addr"), data_rdy("data_rdy"), bus_data(
"bus_data") { "bus_data") {
} }
virtual void trace( sc_trace_file* tf ) const;
}; };
void pipelined_bus_ports::trace( sc_trace_file* tf ) const {
sc_trace(tf, clk, clk.name());
sc_trace(tf, rw, rw.name());
sc_trace(tf, addr_req, addr_req.name());
sc_trace(tf, addr_ack, addr_ack.name());
sc_trace(tf, bus_addr, bus_addr.name());
sc_trace(tf, data_rdy, data_rdy.name());
sc_trace(tf, bus_data, bus_data.name());
}
class rw_pipelined_transactor: public rw_task_if, public pipelined_bus_ports { class rw_pipelined_transactor: public rw_task_if, public pipelined_bus_ports {
fifo_mutex addr_phase;fifo_mutex data_phase; fifo_mutex addr_phase;fifo_mutex data_phase;
@ -325,7 +336,7 @@ int sc_main(int argc, char *argv[]) {
#endif #endif
scv_tr_db db(fileName); scv_tr_db db(fileName);
scv_tr_db::set_default_db(&db); scv_tr_db::set_default_db(&db);
sc_trace_file* tf = sc_create_vcd_trace_file("my_db");
// create signals // create signals
sc_clock clk("clk", 20.0, SC_NS, 0.5, 0.0, SC_NS, true); sc_clock clk("clk", 20.0, SC_NS, 0.5, 0.0, SC_NS, true);
sc_signal<bool> rw; sc_signal<bool> rw;
@ -350,6 +361,7 @@ int sc_main(int argc, char *argv[]) {
tr.bus_addr(bus_addr); tr.bus_addr(bus_addr);
tr.data_rdy(data_rdy); tr.data_rdy(data_rdy);
tr.bus_data(bus_data); tr.bus_data(bus_data);
tr.trace(tf);
duv.clk(clk); duv.clk(clk);
duv.rw(rw); duv.rw(rw);
@ -358,13 +370,14 @@ int sc_main(int argc, char *argv[]) {
duv.bus_addr(bus_addr); duv.bus_addr(bus_addr);
duv.data_rdy(data_rdy); duv.data_rdy(data_rdy);
duv.bus_data(bus_data); duv.bus_data(bus_data);
duv.trace(tf);
// Accellera SystemC >=2.2 got picky about multiple drivers. // Accellera SystemC >=2.2 got picky about multiple drivers.
// Disable check for bus simulation. // Disable check for bus simulation.
sc_report_handler::set_actions(SC_ID_MORE_THAN_ONE_SIGNAL_DRIVER_, SC_DO_NOTHING); sc_report_handler::set_actions(SC_ID_MORE_THAN_ONE_SIGNAL_DRIVER_, SC_DO_NOTHING);
// run the simulation // run the simulation
sc_start(1.0, SC_MS); sc_start(1.0, SC_MS);
sc_close_vcd_trace_file(tf);
return 0; return 0;
} }