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: .,
sqlite-jdbc-3.8.7.jar
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">
<implementation class="com.minres.scviewer.database.sqlite.SQLiteDbFactory"/>
<service>
<provide interface="com.minres.scviewer.database.ITransactionDbFactory"/>
<provide interface="com.minres.scviewer.database.IWaveformDbFactory"/>
</service>
</scr:component>

View File

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

View File

@ -3,10 +3,10 @@ package com.minres.scviewer.database.sqlite;
import java.io.File;
import java.io.FileInputStream;
import com.minres.scviewer.database.ITrDb;
import com.minres.scviewer.database.ITransactionDbFactory;
import com.minres.scviewer.database.IWaveformDb;
import com.minres.scviewer.database.IWaveformDbFactory;
public class SQLiteDbFactory implements ITransactionDbFactory {
public class SQLiteDbFactory implements IWaveformDbFactory {
private byte[] x = "SQLite format 3".getBytes();
@ -14,7 +14,7 @@ public class SQLiteDbFactory implements ITransactionDbFactory {
}
@Override
public ITrDb createDatabase(File file) {
public IWaveformDb createDatabase(File file) {
try {
FileInputStream fis = new FileInputStream(file);
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.EventTime;
import com.minres.scviewer.database.ITrAttribute;
import com.minres.scviewer.database.ITrGenerator;
import com.minres.scviewer.database.ITrRelation;
import com.minres.scviewer.database.ITrStream;
import com.minres.scviewer.database.ITransaction;
import com.minres.scviewer.database.ITxAttribute;
import com.minres.scviewer.database.ITxGenerator;
import com.minres.scviewer.database.ITxRelation;
import com.minres.scviewer.database.ITxStream;
import com.minres.scviewer.database.ITx;
import com.minres.scviewer.database.sqlite.db.SQLiteDatabaseSelectHandler;
import com.minres.scviewer.database.sqlite.tables.ScvTx;
import com.minres.scviewer.database.sqlite.tables.ScvTxAttribute;
import com.minres.scviewer.database.sqlite.tables.ScvTxEvent;
import com.minres.scviewer.database.sqlite.tables.ScvTxRelation;
public class Transaction implements ITransaction {
public class Tx implements ITx {
private Stream trStream;
private Generator trGenerator;
private TxStream trStream;
private TxGenerator trGenerator;
private ScvTx scvTx;
private List<ITrAttribute> attributes;
private List<ITxAttribute> attributes;
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.trGenerator=trGenerator;
this.scvTx=scvTx;
@ -41,12 +41,12 @@ public class Transaction implements ITransaction {
}
@Override
public ITrStream getStream() {
public ITxStream getStream() {
return trStream;
}
@Override
public ITrGenerator getGenerator() {
public ITxGenerator getGenerator() {
return trGenerator;
}
@ -83,14 +83,14 @@ public class Transaction implements ITransaction {
}
@Override
public List<ITrAttribute> getAttributes() {
public List<ITxAttribute> getAttributes() {
if(attributes==null){
SQLiteDatabaseSelectHandler<ScvTxAttribute> handler = new SQLiteDatabaseSelectHandler<ScvTxAttribute>(
ScvTxAttribute.class, trStream.getDb().getDb(), "tx="+scvTx.getId());
try {
attributes = new ArrayList<ITrAttribute>();
attributes = new ArrayList<ITxAttribute>();
for(ScvTxAttribute scvAttribute:handler.selectObjects()){
attributes.add(new Attribute(this, scvAttribute));
attributes.add(new TxAttribute(this, scvAttribute));
}
} catch (SecurityException | IllegalArgumentException | InstantiationException | IllegalAccessException
@ -101,12 +101,12 @@ public class Transaction implements ITransaction {
}
@Override
public Collection<ITrRelation> getIncomingRelations() {
public Collection<ITxRelation> getIncomingRelations() {
if(incoming==null){
SQLiteDatabaseSelectHandler<ScvTxRelation> handler = new SQLiteDatabaseSelectHandler<ScvTxRelation>(
ScvTxRelation.class, trStream.getDb().getDb(), "sink="+scvTx.getId());
try {
incoming = new ArrayList<ITrRelation>();
incoming = new ArrayList<ITxRelation>();
for(ScvTxRelation scvRelation:handler.selectObjects()){
incoming.add(createRelation(scvRelation, false));
}
@ -118,12 +118,12 @@ public class Transaction implements ITransaction {
}
@Override
public Collection<ITrRelation> getOutgoingRelations() {
public Collection<ITxRelation> getOutgoingRelations() {
if(outgoing==null){
SQLiteDatabaseSelectHandler<ScvTxRelation> handler = new SQLiteDatabaseSelectHandler<ScvTxRelation>(
ScvTxRelation.class, trStream.getDb().getDb(), "src="+scvTx.getId());
try {
outgoing = new ArrayList<ITrRelation>();
outgoing = new ArrayList<ITxRelation>();
for(ScvTxRelation scvRelation:handler.selectObjects()){
outgoing.add(createRelation(scvRelation, true));
}
@ -134,17 +134,17 @@ public class Transaction implements ITransaction {
return outgoing;
}
private ITrRelation createRelation(ScvTxRelation rel, boolean outgoing) {
private ITxRelation createRelation(ScvTxRelation rel, boolean outgoing) {
long otherId = outgoing?rel.getSink():rel.getSrc();
try {
List<ScvTx> scvTx=new SQLiteDatabaseSelectHandler<ScvTx>(ScvTx.class, trStream.getDb().getDb(), "id="+otherId).selectObjects();
assert(scvTx.size()==1);
ITrStream stream = trStream.getDb().getStreamById(scvTx.get(0).getStream());
Transaction that=(Transaction) stream.getTransactionById(otherId);
ITxStream stream = trStream.getDb().getStreamById(scvTx.get(0).getStream());
Tx that=(Tx) stream.getTransactionById(otherId);
if(outgoing)
return new Relation(trStream.getDb().getRelationType(rel.getName()), this, that);
return new TxRelation(trStream.getDb().getRelationType(rel.getName()), this, that);
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
| 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.DataType;
import com.minres.scviewer.database.ITrAttribute;
import com.minres.scviewer.database.ITxAttribute;
import com.minres.scviewer.database.sqlite.tables.ScvTxAttribute;
public class Attribute implements ITrAttribute{
public class TxAttribute implements ITxAttribute{
Transaction trTransaction;
Tx trTransaction;
ScvTxAttribute scvAttribute;
public Attribute(Transaction trTransaction, ScvTxAttribute scvAttribute) {
public TxAttribute(Tx trTransaction, ScvTxAttribute scvAttribute) {
this.trTransaction=trTransaction;
this.scvAttribute=scvAttribute;
}

View File

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

View File

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

View File

@ -4,29 +4,31 @@ import java.beans.IntrospectionException;
import java.lang.reflect.InvocationTargetException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import com.minres.scviewer.database.ITrDb;
import com.minres.scviewer.database.ITrGenerator;
import com.minres.scviewer.database.ITrStream;
import com.minres.scviewer.database.ITransaction;
import com.minres.scviewer.database.HierNode;
import com.minres.scviewer.database.ITxGenerator;
import com.minres.scviewer.database.ITxStream;
import com.minres.scviewer.database.ITx;
import com.minres.scviewer.database.sqlite.db.SQLiteDatabaseSelectHandler;
import com.minres.scviewer.database.sqlite.tables.ScvGenerator;
import com.minres.scviewer.database.sqlite.tables.ScvStream;
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 SQLiteDb db;
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());
fullName=scvStream.getName();
this.scvStream=scvStream;
@ -54,33 +56,33 @@ public class Stream extends HierNode implements ITrStream {
}
@Override
public List<ITrGenerator> getGenerators() {
public List<ITxGenerator> getGenerators() {
if(generators==null){
SQLiteDatabaseSelectHandler<ScvGenerator> handler = new SQLiteDatabaseSelectHandler<ScvGenerator>(
ScvGenerator.class, db.getDb(), "stream="+scvStream.getId());
generators=new HashMap<Integer, Generator>();
generators=new HashMap<Integer, TxGenerator>();
try {
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
| InvocationTargetException | SQLException | IntrospectionException e) {
e.printStackTrace();
}
}
return new ArrayList<ITrGenerator>(generators.values());
return new ArrayList<ITxGenerator>(generators.values());
}
@Override
public List<ITransaction> getTransactions() {
public List<ITx> getTransactions() {
checkTransactions();
return transactions;
}
@Override
public ITransaction getTransactionById(long id) {
public ITx getTransactionById(long id) {
checkTransactions();
for(ITransaction trans:transactions){
for(ITx trans:transactions){
if(trans.getId()==id)
return trans;
}
@ -92,10 +94,10 @@ public class Stream extends HierNode implements ITrStream {
if(generators==null) getGenerators();
SQLiteDatabaseSelectHandler<ScvTx> handler = new SQLiteDatabaseSelectHandler<ScvTx>(ScvTx.class, db.getDb(),
"stream="+scvStream.getId());
transactions=new ArrayList<ITransaction>();
transactions=new ArrayList<ITx>();
try {
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
| 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.DriverManager;
@ -7,8 +7,6 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import com.minres.scviewer.database.sqlite.db.IDatabase;
public class SQLiteDatabase implements IDatabase {
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.osgi.services;bundle-version="3.4.0"
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">
<implementation class="com.minres.scviewer.database.text.TextDbFactory"/>
<service>
<provide interface="com.minres.scviewer.database.ITransactionDbFactory"/>
<provide interface="com.minres.scviewer.database.IWaveformDbFactory"/>
</service>
</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.DataType;
import com.minres.scviewer.database.ITrAttrType;
import com.minres.scviewer.database.ITrAttribute;
import com.minres.scviewer.database.ITrDb;
import com.minres.scviewer.database.ITrGenerator;
import com.minres.scviewer.database.ITrHierNode;
import com.minres.scviewer.database.ITrStream;
import com.minres.scviewer.database.HierNode;
import com.minres.scviewer.database.ITxAttributeType;
import com.minres.scviewer.database.ITxAttribute;
import com.minres.scviewer.database.IWaveformDb;
import com.minres.scviewer.database.ITxGenerator;
import com.minres.scviewer.database.IHierNode;
import com.minres.scviewer.database.ITxStream;
import com.minres.scviewer.database.InputFormatException;
import com.minres.scviewer.database.EventTime
import com.minres.scviewer.database.RelationType
public class TextDb extends HierNode implements ITrDb{
public class TextDb extends HierNode implements IWaveformDb{
private EventTime maxTime;
@ -37,6 +38,10 @@ public class TextDb extends HierNode implements ITrDb{
def relationTypes=[:]
public TextDb() {
super("TextDb");
}
public String getFullName() {
return getName();
}
@ -46,21 +51,21 @@ public class TextDb extends HierNode implements ITrDb{
return maxTime;
}
public ITrStream getStreamByName(String name){
streams.find{ITrStream stream-> stream.fullName == name }
public ITxStream getStreamByName(String name){
streams.find{ITxStream stream-> stream.fullName == name }
}
public List<ITrStream> getAllStreams() {
return new LinkedList<ITrStream>(streams);
public List<ITxStream> getAllWaves() {
return new LinkedList<ITxStream>(streams);
}
public List<ITrHierNode> getChildNodes() {
public List<IHierNode> getChildNodes() {
return childs.sort{it.name};
}
public Map<Long, ITrGenerator> getGeneratorsById() {
TreeMap<Long, ITrGenerator> res = new TreeMap<Long, ITrGenerator>();
streams.each{Stream stream -> stream.generators.each{res.put(it.id, id)} }
public Map<Long, ITxGenerator> getGeneratorsById() {
TreeMap<Long, ITxGenerator> res = new TreeMap<Long, ITxGenerator>();
streams.each{TxStream stream -> stream.generators.each{res.put(it.id, id)} }
return res;
}
@ -78,8 +83,8 @@ public class TextDb extends HierNode implements ITrDb{
def streamsById = [:]
def generatorsById = [:]
def transactionsById = [:]
Generator generator
Transaction transaction
TxGenerator generator
Tx transaction
boolean endTransaction=false
def matcher
input.eachLine { line ->
@ -91,19 +96,19 @@ public class TextDb extends HierNode implements ITrDb{
case "end_attribute":
if ((matcher = line =~ /^scv_tr_stream\s+\(ID (\d+),\s+name\s+"([^"]+)",\s+kind\s+"([^"]+)"\)$/)) {
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
streamsById[id]=stream
} 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])
ITrStream stream=streamsById[Integer.parseInt(matcher[0][3])]
generator=new Generator(id, stream, matcher[0][2])
ITxStream stream=streamsById[Integer.parseInt(matcher[0][3])]
generator=new TxGenerator(id, stream, matcher[0][2])
stream.generators<<generator
generatorsById[id]=generator
} 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 "([^"]+)"\)$/)) {
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;
case ")":
@ -111,8 +116,8 @@ public class TextDb extends HierNode implements ITrDb{
break
case "tx_begin"://matcher = line =~ /^tx_begin\s+(\d+)\s+(\d+)\s+(\d+)\s+([munpf]?s)/
def id = Integer.parseInt(tokens[1])
Generator gen=generatorsById[Integer.parseInt(tokens[2])]
transaction = new Transaction(id, gen.stream, gen, new EventTime(Integer.parseInt(tokens[3]), tokens[4]))
TxGenerator gen=generatorsById[Integer.parseInt(tokens[2])]
transaction = new Tx(id, gen.stream, gen, new EventTime(Integer.parseInt(tokens[3]), tokens[4]))
gen.transactions << transaction
transactionsById[id]= transaction
gen.begin_attrs_idx=0;
@ -130,21 +135,21 @@ public class TextDb extends HierNode implements ITrDb{
break
case "tx_record_attribute"://matcher = line =~ /^tx_record_attribute\s+(\d+)\s+"([^"]+)"\s+(\S+)\s*=\s*(.+)$/
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
case "a"://matcher = line =~ /^a\s+(.+)$/
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 {
transaction.attributes << new Attribute(transaction.generator.begin_attrs[0], tokens[1])
transaction.attributes << new TxAttribute(transaction.generator.begin_attrs[0], tokens[1])
}
break
case "tx_relation"://matcher = line =~ /^tx_relation\s+\"(\S+)\"\s+(\d+)\s+(\d+)$/
Transaction tr1= transactionsById[Integer.parseInt(tokens[2])]
Transaction tr2= transactionsById[Integer.parseInt(tokens[3])]
Tx tr1= transactionsById[Integer.parseInt(tokens[2])]
Tx tr2= transactionsById[Integer.parseInt(tokens[3])]
def relType=tokens[1][1..-2]
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
tr2.incomingRelations<<rel
break
@ -157,9 +162,9 @@ public class TextDb extends HierNode implements ITrDb{
}
def addHierarchyNodes(){
streams.each{ Stream stream->
streams.each{ TxStream stream->
def hier = stream.fullName.split(/\./)
ITrHierNode node = this
IHierNode node = this
hier.each { name ->
def n1 = node.childNodes.find{it.name == name}
if(name == hier[-1]){ //leaf

View File

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

View File

@ -15,37 +15,37 @@ import java.util.Set
import com.minres.scviewer.database.*
class Transaction implements ITransaction {
class Tx implements ITx {
Long id
Generator generator
TxGenerator generator
Stream stream
TxStream stream
EventTime beginTime
EventTime endTime
ArrayList<ITrAttribute> attributes = new ArrayList<ITrAttribute>()
ArrayList<ITxAttribute> attributes = new ArrayList<ITxAttribute>()
def incomingRelations =[]
def outgoingRelations =[]
Transaction(int id, Stream stream, Generator generator, EventTime begin){
Tx(int id, TxStream stream, TxGenerator generator, EventTime begin){
this.id=id
this.generator=generator
this.beginTime=begin
}
@Override
public Collection<ITrRelation> getIncomingRelations() {
public Collection<ITxRelation> getIncomingRelations() {
return incomingRelations;
}
@Override
public Collection<ITrRelation> getOutgoingRelations() {
public Collection<ITxRelation> getOutgoingRelations() {
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.DataType;
import com.minres.scviewer.database.ITrAttrType;
import com.minres.scviewer.database.ITrAttribute
import com.minres.scviewer.database.ITxAttributeType;
import com.minres.scviewer.database.ITxAttribute
class Attribute implements ITrAttribute{
class TxAttribute implements ITxAttribute{
AttrType attributeType
TxAttributeType attributeType
def value
Attribute(String name, DataType dataType, AssociationType type, value){
attributeType = AttrTypeFactory.instance.getAttrType(name, dataType, type)
TxAttribute(String name, DataType dataType, AssociationType type, value){
attributeType = TxAttributeTypeFactory.instance.getAttrType(name, dataType, type)
switch(dataType){
case DataType.STRING:
case DataType.ENUMERATION:
@ -33,11 +33,11 @@ class Attribute implements ITrAttribute{
}
}
Attribute(AttrType other){
TxAttribute(TxAttributeType other){
attributeType=other
}
Attribute(AttrType other, value){
TxAttribute(TxAttributeType other, 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.DataType;
import com.minres.scviewer.database.ITrAttrType;
import com.minres.scviewer.database.ITxAttributeType;
class AttrType implements ITrAttrType {
class TxAttributeType implements ITxAttributeType {
String name
DataType dataType
AssociationType type
static AttrType getAttrType(String name, DataType dataType, AssociationType type){
AttrTypeFactory.instance.getAttrType(name, dataType, type)
static TxAttributeType getAttrType(String name, DataType dataType, AssociationType 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.dataType=dataType
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.DataType
import com.minres.scviewer.database.ITrAttrType
import com.minres.scviewer.database.ITrAttribute
import com.minres.scviewer.database.ITxAttributeType
import com.minres.scviewer.database.ITxAttribute
class AttrTypeFactory {
private static final instance = new AttrTypeFactory()
class TxAttributeTypeFactory {
private static final instance = new TxAttributeTypeFactory()
def attributes = [:]
private AttrTypeFactory() {
AttrTypeFactory.metaClass.constructor = {-> instance }
private TxAttributeTypeFactory() {
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()
ITrAttrType res
ITxAttributeType res
if(attributes.containsKey(key)){
res=attributes[key]
} else {
res=new AttrType(name, dataType, type)
res=new TxAttributeType(name, dataType, type)
attributes[key]=res
}
return res

View File

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

View File

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

View File

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

View File

@ -20,6 +20,11 @@
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ds.core.builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<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-Vendor: MINRES Technologies GmbH
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/
bin.includes = META-INF/,\
.
.,\
OSGI-INF/component.xml
source.. = src/

View File

@ -1,3 +1,5 @@
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;
public enum DataType {
BOOLEAN, // bool
ENUMERATION, // enum
INTEGER, // char, short, int, long, long long, sc_int, sc_bigint
UNSIGNED, // unsigned { char, short, int, long, long long }, sc_uint, sc_biguint
FLOATING_POINT_NUMBER, // float, double
BIT_VECTOR, // sc_bit, sc_bv
LOGIC_VECTOR, // sc_logic, sc_lv
FIXED_POINT_INTEGER, // sc_fixed
UNSIGNED_FIXED_POINT_INTEGER, // sc_ufixed
RECORD, // struct/class
POINTER, // T*
ARRAY, // T[N]
STRING // string, std::string
};
public enum DataType {
BOOLEAN, // bool
ENUMERATION, // enum
INTEGER, // char, short, int, long, long long, sc_int, sc_bigint
UNSIGNED, // unsigned { char, short, int, long, long long }, sc_uint,
// sc_biguint
FLOATING_POINT_NUMBER, // float, double
BIT_VECTOR, // sc_bit, sc_bv
LOGIC_VECTOR, // sc_logic, sc_lv
FIXED_POINT_INTEGER, // sc_fixed
UNSIGNED_FIXED_POINT_INTEGER, // sc_ufixed
RECORD, // struct/class
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 EventTime ZERO = new EventTime(0L, "fs");
private long value; // unit is femto seconds
public EventTime(Long value, String 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.util.ArrayList;
import java.util.List;
import com.minres.scviewer.database.ITrHierNode;
public class HierNode implements ITrHierNode {
public class HierNode implements IHierNode {
protected String name;
protected ArrayList<ITrHierNode> childs;
protected ArrayList<IHierNode> childs;
public HierNode(String name) {
this.name=name;
childs = new ArrayList<ITrHierNode>();
childs = new ArrayList<IHierNode>();
}
@Override
public void addPropertyChangeListener(PropertyChangeListener l) {
// TODO Auto-generated method stub
}
@Override
public void removePropertyChangeListener(PropertyChangeListener l) {
// TODO Auto-generated method stub
}
@Override
@ -45,7 +39,7 @@ public class HierNode implements ITrHierNode {
}
@Override
public List<ITrHierNode> getChildNodes() {
public List<IHierNode> getChildNodes() {
return childs;
}

View File

@ -13,7 +13,8 @@ package com.minres.scviewer.database;
import java.beans.PropertyChangeListener;
import java.util.List;
public interface ITrHierNode {
public interface IHierNode {
/**
* Attach a non-null PropertyChangeListener to this object.
*
@ -23,6 +24,7 @@ public interface ITrHierNode {
* if the parameter is null
*/
public void addPropertyChangeListener(PropertyChangeListener l);
/**
* Remove a PropertyChangeListener from this component.
*
@ -37,6 +39,6 @@ public interface ITrHierNode {
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.List;
import java.util.Set;
public interface ITransaction {
public interface ITx {
public Long getId();
public ITrStream getStream();
public ITxStream getStream();
public ITrGenerator getGenerator();
public ITxGenerator getGenerator();
public EventTime getBeginTime();
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;
public interface ITrAttribute extends ITrAttrType {
public interface ITxAttribute extends ITxAttributeType {
public Object getValue();
}

View File

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

View File

@ -12,9 +12,9 @@ package com.minres.scviewer.database;
import java.util.List;
public interface ITrGenerator {
public interface ITxGenerator {
public Long getId();
public ITrStream getStream();
public ITxStream getStream();
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;
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 List<ITrGenerator> getGenerators();
public List<ITransaction> getTransactions();
public ITransaction getTransactionById(long id);
public ITx 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;
import java.io.File;
import java.io.InputStream;
import java.util.List;
public interface ITrDb extends ITrHierNode {
public interface IWaveformDb extends IHierNode {
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();

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
Bundle-ClassPath: .,
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"
contributorClass="com.minres.scviewer.ui.TxEditorActionBarContributor"
extensions="txdb"
filenames="*.txdb,*.txlog"
icon="icons/scviewer.gif"
filenames="*.txdb,*.txlog,*.vcd"
icon="res/images/scviewer.png"
id="com.minres.scviewer.ui.TxEditorPart"
name="Wave Viewer">
</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.util.List;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.dialogs.MessageDialog;
@ -25,7 +24,6 @@ import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.ide.FileStoreEditorInput;
import org.eclipse.ui.internal.ide.dialogs.IFileStoreFilter;
import org.eclipse.ui.part.EditorPart;
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
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.osgi.framework.BundleContext;
import org.osgi.framework.FrameworkUtil;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceReference;
import com.minres.scviewer.database.ITrDb;
import com.minres.scviewer.database.ITrStream;
import com.minres.scviewer.database.ITransactionDbFactory;
import com.minres.scviewer.database.IWaveformDb;
import com.minres.scviewer.database.ITxStream;
import com.minres.scviewer.database.IWaveformDbFactory;
import com.minres.scviewer.database.IWaveform;
import com.minres.scviewer.ui.swt.TxDisplay;
import com.minres.scviewer.ui.views.TxOutlinePage;
@ -51,7 +49,7 @@ public class TxEditorPart extends EditorPart implements ITabbedPropertySheetPage
private TxDisplay txDisplay;
/** This is the root of the editor's model. */
private ITrDb database;
private IWaveformDb database;
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(MessageDialog.openConfirm(parent.getShell(), "Confirm", "Do you want the restore last state of the wave form?"))
for(String streamName:((TxEditorInput) getEditorInput()).getStreamNames()){
ITrStream stream = database.getStreamByName(streamName);
IWaveform stream = database.getStreamByName(streamName);
if(stream!=null)
txDisplay.addStream(stream);
}
@ -126,10 +124,10 @@ public class TxEditorPart extends EditorPart implements ITabbedPropertySheetPage
protected void getTrDatabase(File file) {
try {
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){
for(ServiceReference<?> serviceReference:serviceReferences){
database = ((ITransactionDbFactory) context.getService(serviceReference)).createDatabase(file);
database = ((IWaveformDbFactory) context.getService(serviceReference)).createDatabase(file);
if(database!=null){
if(txDisplay !=null) database.addPropertyChangeListener(txDisplay);
return;
@ -180,7 +178,7 @@ public class TxEditorPart extends EditorPart implements ITabbedPropertySheetPage
return super.getAdapter(type);
}
public ITrDb getModel() {
public IWaveformDb getModel() {
return database;
}
@ -202,38 +200,38 @@ public class TxEditorPart extends EditorPart implements ITabbedPropertySheetPage
return false;
}
public ITrDb getDatabase() {
public IWaveformDb getDatabase() {
return database;
}
public void addStreamToList(ITrStream stream){
if(getEditorInput() instanceof TxEditorInput && !((TxEditorInput) getEditorInput()).getStreamNames().contains(stream.getFullName())){
((TxEditorInput) getEditorInput()).getStreamNames().add(stream.getFullName());
txDisplay.addStream(stream);
public void addStreamToList(IWaveform obj){
if(getEditorInput() instanceof TxEditorInput && !((TxEditorInput) getEditorInput()).getStreamNames().contains(obj.getFullName())){
((TxEditorInput) getEditorInput()).getStreamNames().add(obj.getFullName());
txDisplay.addStream(obj);
} else
txDisplay.addStream(stream);
txDisplay.addStream(obj);
}
public void addStreamsToList(ITrStream[] streams){
for(ITrStream stream:streams)
public void addStreamsToList(IWaveform[] iWaveforms){
for(IWaveform stream:iWaveforms)
addStreamToList(stream);
}
public void removeStreamFromList(ITrStream stream){
if(getEditorInput() instanceof TxEditorInput && ((TxEditorInput) getEditorInput()).getStreamNames().contains(stream.getFullName())){
((TxEditorInput) getEditorInput()).getStreamNames().remove(stream.getFullName());
txDisplay.removeStream(stream);
public void removeStreamFromList(IWaveform obj){
if(getEditorInput() instanceof TxEditorInput && ((TxEditorInput) getEditorInput()).getStreamNames().contains(obj.getFullName())){
((TxEditorInput) getEditorInput()).getStreamNames().remove(obj.getFullName());
txDisplay.removeStream(obj);
} else
txDisplay.removeStream(stream);
txDisplay.removeStream(obj);
}
public void removeStreamsFromList(ITrStream[] streams){
for(ITrStream stream:streams)
public void removeStreamsFromList(IWaveform[] iWaveforms){
for(IWaveform stream:iWaveforms)
removeStreamFromList(stream);
}
public List<ITrStream> getStreamList(){
public List<IWaveform> getStreamList(){
return txDisplay.getStreamList();
}

View File

@ -24,7 +24,7 @@ import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.eclipse.wb.swt.SWTResourceManager;
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
@ -133,21 +133,4 @@ public class TxEditorPlugin extends AbstractUIPlugin {
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.ui.views.properties.IPropertySource;
import com.minres.scviewer.database.ITransaction;
import com.minres.scviewer.database.ITx;
public class AdapterFactory implements IAdapterFactory {
@ -11,7 +11,7 @@ public class AdapterFactory implements IAdapterFactory {
@Override
public Object getAdapter(Object adaptableObject, Class adapterType) {
if (adapterType == IPropertySource.class)
return new ITransactionPropertySource((ITransaction) adaptableObject);
return new ITransactionPropertySource((ITx) adaptableObject);
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.PropertyDescriptor;
import com.minres.scviewer.database.ITransaction;
import com.minres.scviewer.database.ITx;
public class ITransactionPropertySource implements IPropertySource {
private ITransaction iTransaction;
private ITx iTransaction;
public final static String PROPERTY_ID = "ID";
public final static String PROPERTY_BEGINTIME = "BEGINTIME";
@ -29,7 +29,7 @@ public class ITransactionPropertySource implements IPropertySource {
protected IPropertyDescriptor[] propertyDescriptors;
public ITransactionPropertySource(ITransaction iTransaction) {
public ITransactionPropertySource(ITx 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;
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.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.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 com.minres.scviewer.database.EventTime;
import com.minres.scviewer.database.ITransaction;
import com.minres.scviewer.database.ITx;
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 trackInset = 2;
@ -34,9 +34,9 @@ public class Track extends Composite implements MouseListener {
private Color lineColor;
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 {
protected int x, y;
@ -121,11 +121,11 @@ public class Track extends Composite implements MouseListener {
}
public void setTransactions(List<ITransaction> transactions) {
Vector<ITransaction> rowendtime = new Vector<ITransaction>();
for (ITransaction tx : transactions) {
public void setTransactions(List<ITx> transactions) {
Vector<ITx> rowendtime = new Vector<ITx>();
for (ITx tx : transactions) {
int rowIdx = 0;
for (ITransaction lastTx : rowendtime) {
for (ITx lastTx : rowendtime) {
if((lastTx.getEndTime().getValue()-lastTx.getBeginTime().getValue())>0){
if (lastTx.getEndTime().compareTo(tx.getBeginTime())<=0 )
break;
@ -187,16 +187,19 @@ public class Track extends Composite implements MouseListener {
this.notifyListeners(SWT.MouseUp, event);
}
public Transaction highlightTransaction(ITransaction tx){
if(highlightedTx!=null){
transactionMap.get(highlightedTx).highlight(false);
highlightedTx=null;
}
if(tx!=null && transactionMap.containsKey(tx)){
Transaction trans = transactionMap.get(tx);
trans.highlight(true);
highlightedTx=tx;
return trans;
public Transaction highlight(Object obj){
if(obj instanceof ITx){
ITx tx = (ITx) obj;
if(highlightedTx!=null){
transactionMap.get(highlightedTx).highlight(false);
highlightedTx=null;
}
if(tx!=null && transactionMap.containsKey(tx)){
Transaction trans = transactionMap.get(tx);
trans.highlight(true);
highlightedTx=tx;
return trans;
}
}
return null;
}

View File

@ -52,14 +52,17 @@ import org.eclipse.wb.swt.SWTResourceManager;
import swing2swt.layout.BorderLayout;
import com.minres.scviewer.database.ITrStream;
import com.minres.scviewer.database.ITransaction;
import com.minres.scviewer.database.ISignal;
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{
private ListenerList listeners = new ListenerList();
private ITrStream currentStreamSelection;
private ITransaction currentSelection;
private ITxStream currentStreamSelection;
private ITx currentSelection;
private ScrolledComposite valueListScrolled;
private ScrolledComposite nameListScrolled;
private Composite nameList;
@ -67,10 +70,10 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
private ScrolledComposite trackListScrolled;
private Composite trackList;
private Composite top;
private ArrayList<ITrStream> streams=new ArrayList<ITrStream>();
private ArrayList<IWaveform> streams=new ArrayList<IWaveform>();
private Composite trackPane;
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) {
top = new Composite(parent, SWT.NONE);
@ -207,40 +210,63 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
}
public void streamListChanged() {
LinkedList<ITrStream>toAdd = new LinkedList<ITrStream>();
LinkedList<IWaveform>toAdd = new LinkedList<IWaveform>();
toAdd.addAll(streams);
for(Control child:trackList.getChildren()){
Track track = (Track) child;
Control c = (Control)track.getData("NAMEWIDGET");
ITrStream stream=(ITrStream) track.getData("STREAM");
IWaveform stream=(IWaveform) child.getData("WAVEFORM");
if(!streams.contains(stream)){
track.setVisible(false);
c.setVisible(false);
child.setVisible(false);
((Control)(child.getData("NAMEWIDGET"))).setVisible(false);
((Control)(child.getData("VALUEWIDGET"))).setVisible(false);
}else{
toAdd.remove(stream);
track.setVisible(true);
c.setVisible(true);
child.setVisible(true);
((Control)(child.getData("NAMEWIDGET"))).setVisible(true);
((Control)(child.getData("VALUEWIDGET"))).setVisible(true);
}
}
for(ITrStream stream: toAdd){
Track track = new Track(trackList,SWT.NONE);
track.setTransactions(stream.getTransactions());
track.setData("STREAM", stream);
track.addMouseListener(this);
Point trackSize = track.computeSize(SWT.DEFAULT,SWT.DEFAULT);
Label trackName = new Label(nameList, SWT.NONE);
trackName.setText(stream.getFullName());
RowData trackNamelayoutData = new RowData(SWT.DEFAULT, trackSize.y);
trackName.setLayoutData(trackNamelayoutData);
track.setData("NAMEWIDGET", trackName);
Label trackValue = new Label(valueList, SWT.NONE);
trackValue.setText("-");
RowData trackValuelayoutData = new RowData(SWT.DEFAULT, trackSize.y);
trackValue.setLayoutData(trackValuelayoutData);
track.setData("VALUEWIDGET", trackValue);
trackMap.put(stream, track);
for(IWaveform wave: toAdd){
if(wave instanceof ITxStream){
ITxStream stream = (ITxStream) wave;
Track track = new Track(trackList,SWT.NONE);
track.setTransactions(stream.getTransactions());
track.setData("WAVEFORM", stream);
track.addMouseListener(this);
Point trackSize = track.computeSize(SWT.DEFAULT,SWT.DEFAULT);
Label trackName = new Label(nameList, SWT.NONE);
trackName.setText(stream.getFullName());
RowData trackNamelayoutData = new RowData(SWT.DEFAULT, trackSize.y);
trackName.setLayoutData(trackNamelayoutData);
track.setData("NAMEWIDGET", trackName);
Label trackValue = new Label(valueList, SWT.NONE);
trackValue.setText("-");
RowData trackValuelayoutData = new RowData(SWT.DEFAULT, trackSize.y);
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();
recalculateValueBounds();
@ -276,9 +302,9 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
@Override
public void propertyChange(PropertyChangeEvent pce) {
currentSelection=null;
ITrStream str = (ITrStream)pce.getNewValue();
if(str instanceof ITrStream)
currentStreamSelection=(ITrStream)str;
ITxStream str = (ITxStream)pce.getNewValue();
if(str instanceof ITxStream)
currentStreamSelection=(ITxStream)str;
if(currentStreamSelection!=null)
setSelection(getSelection());
else
@ -309,15 +335,15 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
public void setSelection(ISelection selection) {
if(selection instanceof IStructuredSelection){
Object sel =((IStructuredSelection)selection).getFirstElement();
if(sel instanceof ITransaction && currentSelection!=sel){
if(sel instanceof ITx && currentSelection!=sel){
if(currentSelection!=null){
ITrStream stream = currentSelection.getGenerator().getStream();
if(trackMap.containsKey(stream)) trackMap.get(stream).highlightTransaction(null);
ITxStream stream = currentSelection.getGenerator().getStream();
if(trackMap.containsKey(stream)) trackMap.get(stream).highlight(null);
}
currentSelection=(ITransaction) sel;
ITrStream stream = currentSelection.getGenerator().getStream();
currentSelection=(ITx) sel;
ITxStream stream = currentSelection.getGenerator().getStream();
if(trackMap.containsKey(stream)){
Transaction trans = trackMap.get(stream).highlightTransaction(currentSelection);
Transaction trans = trackMap.get(stream).highlight(sel);
trackListScrolled.showControl(trans);
}
Object[] list = listeners.getListeners();
@ -337,7 +363,7 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
if(e.data!=null){
StructuredSelection sel = new StructuredSelection(((Transaction)e.data).getData());
setSelection(sel);
}else{
}else if(e.widget instanceof Track){
StructuredSelection sel = new StructuredSelection(new Object[]{ ((Track)e.widget).getData()});
setSelection(sel);
}
@ -347,26 +373,26 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
public void mouseUp(MouseEvent e) {
}
public boolean addStream(ITrStream paramE){
boolean res = streams.add(paramE);
public boolean addStream(IWaveform stream){
boolean res = streams.add(stream);
streamListChanged();
return res;
}
public boolean addAllStreams(ITrStream[] streams) {
public boolean addAllStreams(ITxStream[] streams) {
boolean res = this.streams.addAll(Arrays.asList(streams));
streamListChanged();
return res;
}
public boolean addAllStreams(Collection<? extends ITrStream> paramCollection){
public boolean addAllStreams(Collection<? extends ITxStream> paramCollection){
boolean res = streams.addAll(paramCollection);
streamListChanged();
return res;
}
public boolean removeStream(ITrStream paramObject){
boolean res = streams.remove(paramObject);
public boolean removeStream(IWaveform obj){
boolean res = streams.remove(obj);
streamListChanged();
return res;
}
@ -377,11 +403,11 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
return res;
}
public List<ITrStream> getStreamList(){
public List<IWaveform> getStreamList(){
return Collections.unmodifiableList(streams);
}
public boolean removeAllStreams(ITrStream[] streams) {
public boolean removeAllStreams(ITxStream[] streams) {
boolean res = this.streams.removeAll(Arrays.asList(streams));
streamListChanged();
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.ContentOutlinePage;
import com.minres.scviewer.database.ITrHierNode;
import com.minres.scviewer.database.ITrStream;
import com.minres.scviewer.database.ITransaction;
import com.minres.scviewer.database.IHierNode;
import com.minres.scviewer.database.ITxStream;
import com.minres.scviewer.database.ITx;
import com.minres.scviewer.database.IWaveform;
import com.minres.scviewer.ui.TxEditorPart;
import com.minres.scviewer.ui.views.provider.TxDbTreeContentProvider;
import com.minres.scviewer.ui.views.provider.TxDbTreeLabelProvider;
@ -124,10 +125,10 @@ public class TxOutlinePage extends ContentOutlinePage implements ISelectionList
if(selection instanceof IStructuredSelection){
IStructuredSelection sel = (IStructuredSelection) selection;
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("Remove from Wave", ISharedImages.IMG_TOOL_DELETE, sel, obj instanceof ITrStream,true));
menuMgr.add(makeStreamAction("Remove all from Wave", ISharedImages.IMG_TOOL_DELETE, sel, true, 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));
}
}
@ -168,8 +169,8 @@ public class TxOutlinePage extends ContentOutlinePage implements ISelectionList
ISelection selection = anEvent.getSelection();
if (!selection.isEmpty()) {
Object tmp = ((IStructuredSelection) selection).getFirstElement();
if (tmp instanceof ITrHierNode) {
fireSelectionChanged(new StructuredSelection((ITrHierNode) tmp));
if (tmp instanceof IHierNode) {
fireSelectionChanged(new StructuredSelection((IHierNode) tmp));
}
}
}
@ -179,31 +180,31 @@ public class TxOutlinePage extends ContentOutlinePage implements ISelectionList
public void run() {
if(selection!=null)
for(Object obj :selection.toArray()){
if(obj instanceof ITrStream){
if(obj instanceof IWaveform){
if(remove)
editor.removeStreamFromList((ITrStream) obj);
editor.removeStreamFromList((IWaveform) obj);
else
editor.addStreamToList((ITrStream) obj);
} else if(obj instanceof ITrHierNode){
LinkedList<ITrHierNode> queue = new LinkedList<ITrHierNode>();
LinkedList<ITrStream> streams = new LinkedList<ITrStream>();
queue.add((ITrHierNode)obj);
editor.addStreamToList((IWaveform) obj);
} else if(obj instanceof IHierNode){
LinkedList<IHierNode> queue = new LinkedList<IHierNode>();
LinkedList<IWaveform> streams = new LinkedList<IWaveform>();
queue.add((IHierNode)obj);
while(queue.size()>0){
ITrHierNode n = queue.poll();
if(n instanceof ITrStream) streams.add((ITrStream) n);
IHierNode n = queue.poll();
if(n instanceof IWaveform) streams.add((IWaveform) n);
queue.addAll(n.getChildNodes());
}
if(remove)
editor.removeStreamsFromList(streams.toArray(new ITrStream[]{}));
editor.removeStreamsFromList(streams.toArray(new IWaveform[]{}));
else
editor.addStreamsToList(streams.toArray(new ITrStream[]{}));
editor.addStreamsToList(streams.toArray(new IWaveform[]{}));
}
}
}
};
action.setText(text);
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);
else
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.Viewer;
import com.minres.scviewer.database.ITrDb;
import com.minres.scviewer.database.ITrHierNode;
import com.minres.scviewer.database.IWaveformDb;
import com.minres.scviewer.database.IHierNode;
public class TxDbTreeContentProvider implements ITreeContentProvider {
private ITrDb database;
private IWaveformDb database;
@Override
public void dispose() { }
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
database=(ITrDb)newInput;
database=(IWaveformDb)newInput;
}
@Override
@ -35,8 +35,8 @@ public class TxDbTreeContentProvider implements ITreeContentProvider {
@Override
public Object[] getChildren(Object parentElement) {
if(parentElement instanceof ITrHierNode){
return ((ITrHierNode)parentElement).getChildNodes().toArray();
if(parentElement instanceof IHierNode){
return ((IHierNode)parentElement).getChildNodes().toArray();
}
return null;
}

View File

@ -17,9 +17,10 @@ import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.swt.graphics.Image;
import com.minres.scviewer.database.ITrDb;
import com.minres.scviewer.database.ITrHierNode;
import com.minres.scviewer.database.ITrStream;
import com.minres.scviewer.database.ISignal;
import com.minres.scviewer.database.IWaveformDb;
import com.minres.scviewer.database.IHierNode;
import com.minres.scviewer.database.ITxStream;
import com.minres.scviewer.ui.TxEditorPlugin;
public class TxDbTreeLabelProvider implements ILabelProvider {
@ -28,6 +29,7 @@ public class TxDbTreeLabelProvider implements ILabelProvider {
private Image database;
private Image stream;
private Image signal;
private Image folder;
@ -36,6 +38,7 @@ public class TxDbTreeLabelProvider implements ILabelProvider {
database=TxEditorPlugin.createImage("database");
stream=TxEditorPlugin.createImage("stream");
folder=TxEditorPlugin.createImage("folder");
signal=TxEditorPlugin.createImage("signal");
}
@Override
@ -48,6 +51,7 @@ public class TxDbTreeLabelProvider implements ILabelProvider {
if(database!=null) database.dispose();
if(stream!=null) stream.dispose();
if(folder!=null) folder.dispose();
if(signal!=null) signal.dispose();
}
@Override
@ -62,11 +66,13 @@ public class TxDbTreeLabelProvider implements ILabelProvider {
@Override
public Image getImage(Object element) {
if(element instanceof ITrDb){
if(element instanceof IWaveformDb){
return database;
}else if(element instanceof ITrStream){
}else if(element instanceof ITxStream){
return stream;
}else if(element instanceof ITrHierNode){
}else if(element instanceof ISignal<?>){
return signal;
}else if(element instanceof IHierNode){
return folder;
} else
return null;
@ -74,7 +80,7 @@ public class TxDbTreeLabelProvider implements ILabelProvider {
@Override
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 com.minres.scviewer.database.AssociationType;
import com.minres.scviewer.database.ITrAttribute;
import com.minres.scviewer.database.ITransaction;
import com.minres.scviewer.database.ITxAttribute;
import com.minres.scviewer.database.ITx;
public class AttributeProperty extends AbstractPropertySection implements ISelectionProvider {
@ -53,7 +53,7 @@ public class AttributeProperty extends AbstractPropertySection implements ISelec
private ListenerList listeners = new ListenerList();
private ITransaction iTr;
private ITx iTr;
private ISelection currentSelection;
@ -104,19 +104,19 @@ public class AttributeProperty extends AbstractPropertySection implements ISelec
treeViewer.setAutoExpandLevel(2);
treeViewer.setContentProvider(new ITreeContentProvider() {
TreeMap<String, List<ITrAttribute>> hier = new TreeMap<String, List<ITrAttribute>>();
HashMap<ITrAttribute, String> parents = new HashMap<ITrAttribute, String>();
TreeMap<String, List<ITxAttribute>> hier = new TreeMap<String, List<ITxAttribute>>();
HashMap<ITxAttribute, String> parents = new HashMap<ITxAttribute, String>();
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
if (newInput instanceof ITransaction) {
List<ITrAttribute> attributes = ((ITransaction)newInput).getAttributes();
if (newInput instanceof ITx) {
List<ITxAttribute> attributes = ((ITx)newInput).getAttributes();
hier.clear();
parents.clear();
String location="Begin";
List<ITrAttribute> childs=new LinkedList<ITrAttribute>();
for (ITrAttribute attr : attributes)
List<ITxAttribute> childs=new LinkedList<ITxAttribute>();
for (ITxAttribute attr : attributes)
if (attr != null && attr.getType()==AssociationType.BEGIN){
childs.add(attr);
parents.put(attr, location);
@ -124,8 +124,8 @@ public class AttributeProperty extends AbstractPropertySection implements ISelec
if(childs.size()>0) hier.put(location, childs);
location="Transaction";
childs=new LinkedList<ITrAttribute>();
for (ITrAttribute attr : attributes)
childs=new LinkedList<ITxAttribute>();
for (ITxAttribute attr : attributes)
if (attr != null && attr.getType()==AssociationType.RECORD){
childs.add(attr);
parents.put(attr, location);
@ -133,8 +133,8 @@ public class AttributeProperty extends AbstractPropertySection implements ISelec
if(childs.size()>0) hier.put(location, childs);
location="End";
childs=new LinkedList<ITrAttribute>();
for (ITrAttribute attr : attributes)
childs=new LinkedList<ITxAttribute>();
for (ITxAttribute attr : attributes)
if (attr != null && attr.getType()==AssociationType.END){
childs.add(attr);
parents.put(attr, location);
@ -154,7 +154,7 @@ public class AttributeProperty extends AbstractPropertySection implements ISelec
@Override
public Object getParent(Object element) {
if (element instanceof ITrAttribute)
if (element instanceof ITxAttribute)
return parents.get(element);
else
return null;
@ -192,8 +192,8 @@ public class AttributeProperty extends AbstractPropertySection implements ISelec
public String getColumnText(Object element, int columnIndex) {
if (columnIndex == 0 && element instanceof String)
return element.toString();
else if(element instanceof ITrAttribute){
ITrAttribute attr = (ITrAttribute)element;
else if(element instanceof ITxAttribute){
ITxAttribute attr = (ITxAttribute)element;
if (columnIndex == 1 )
return attr.getName();
else if (columnIndex == 2 )
@ -235,8 +235,8 @@ public class AttributeProperty extends AbstractPropertySection implements ISelec
currentSelection = null;
Assert.isTrue(selection instanceof IStructuredSelection);
Object input = ((IStructuredSelection) selection).getFirstElement();
Assert.isTrue(input instanceof ITransaction);
iTr = (ITransaction) input;
Assert.isTrue(input instanceof ITx);
iTr = (ITx) input;
}
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.TabbedPropertySheetPage;
import com.minres.scviewer.database.ITrRelation;
import com.minres.scviewer.database.ITransaction;
import com.minres.scviewer.database.ITxRelation;
import com.minres.scviewer.database.ITx;
import com.minres.scviewer.database.RelationType;
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 ITransaction iTr;
private ITx iTr;
private ISelection currentSelection;
@ -105,26 +105,26 @@ public class RelatedProperty extends AbstractPropertySection implements ISelecti
treeViewer.setAutoExpandLevel(2);
treeViewer.setContentProvider(new ITreeContentProvider() {
TreeMap<String, Collection<ITrRelation>> hier = new TreeMap<String, Collection<ITrRelation>>();
HashMap<ITrRelation, String> parents = new HashMap<ITrRelation, String>();
TreeMap<String, Collection<ITxRelation>> hier = new TreeMap<String, Collection<ITxRelation>>();
HashMap<ITxRelation, String> parents = new HashMap<ITxRelation, String>();
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
if (newInput instanceof ITransaction) {
if (newInput instanceof ITx) {
hier.clear();
parents.clear();
String relName = "incoming";
Collection<ITrRelation> relSet = ((ITransaction)newInput).getIncomingRelations();
Collection<ITxRelation> relSet = ((ITx)newInput).getIncomingRelations();
if (relSet != null && relSet.size() > 0) {
hier.put(relName, relSet);
for (ITrRelation rel : relSet)
for (ITxRelation rel : relSet)
parents.put(rel, relName);
}
relName = "outgoing";
relSet = ((ITransaction)newInput).getOutgoingRelations();
relSet = ((ITx)newInput).getOutgoingRelations();
if (relSet != null && relSet.size() > 0) {
hier.put(relName, relSet);
for (ITrRelation rel : relSet)
for (ITxRelation rel : relSet)
parents.put(rel, relName);
}
}
@ -141,7 +141,7 @@ public class RelatedProperty extends AbstractPropertySection implements ISelecti
@Override
public Object getParent(Object element) {
if (element instanceof ITransaction)
if (element instanceof ITx)
return parents.get(element);
else
return null;
@ -179,14 +179,14 @@ public class RelatedProperty extends AbstractPropertySection implements ISelecti
public String getColumnText(Object element, int columnIndex) {
if (columnIndex == 0 && element instanceof String)
return element.toString();
else if (columnIndex == 1 && element instanceof ITrRelation)
return ((ITrRelation) element).getRelationType().getName();
else if (columnIndex == 2 && element instanceof ITrRelation){
ITrRelation rel = (ITrRelation) element;
else if (columnIndex == 1 && element instanceof ITxRelation)
return ((ITxRelation) element).getRelationType().getName();
else if (columnIndex == 2 && element instanceof ITxRelation){
ITxRelation rel = (ITxRelation) element;
if(rel.getTarget()==iTr)
return ((ITrRelation) element).getSource().getId().toString();
return ((ITxRelation) element).getSource().getId().toString();
else
return ((ITrRelation) element).getTarget().getId().toString();
return ((ITxRelation) element).getTarget().getId().toString();
}
else
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() {
public void run() {
if(obj instanceof ITrRelation){
if(obj instanceof ITxRelation){
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
ITransaction targetTransaction = ((ITrRelation)obj).getSource()==transaction?
((ITrRelation)obj).getTarget():((ITrRelation)obj).getSource();
ITx targetTransaction = ((ITxRelation)obj).getSource()==transaction?
((ITxRelation)obj).getTarget():((ITxRelation)obj).getSource();
for(IEditorReference editorRef: page.getEditorReferences()){
IWorkbenchPart part =editorRef.getPart(false);
if(editorRef.getPage().isPartVisible(part)){
@ -245,8 +245,8 @@ public class RelatedProperty extends AbstractPropertySection implements ISelecti
currentSelection = null;
Assert.isTrue(selection instanceof IStructuredSelection);
Object input = ((IStructuredSelection) selection).getFirstElement();
Assert.isTrue(input instanceof ITransaction);
iTr = (ITransaction) input;
Assert.isTrue(input instanceof ITx);
iTr = (ITx) input;
}
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(
"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 {
fifo_mutex addr_phase;fifo_mutex data_phase;
@ -325,7 +336,7 @@ int sc_main(int argc, char *argv[]) {
#endif
scv_tr_db db(fileName);
scv_tr_db::set_default_db(&db);
sc_trace_file* tf = sc_create_vcd_trace_file("my_db");
// create signals
sc_clock clk("clk", 20.0, SC_NS, 0.5, 0.0, SC_NS, true);
sc_signal<bool> rw;
@ -350,6 +361,7 @@ int sc_main(int argc, char *argv[]) {
tr.bus_addr(bus_addr);
tr.data_rdy(data_rdy);
tr.bus_data(bus_data);
tr.trace(tf);
duv.clk(clk);
duv.rw(rw);
@ -358,13 +370,14 @@ int sc_main(int argc, char *argv[]) {
duv.bus_addr(bus_addr);
duv.data_rdy(data_rdy);
duv.bus_data(bus_data);
duv.trace(tf);
// Accellera SystemC >=2.2 got picky about multiple drivers.
// Disable check for bus simulation.
sc_report_handler::set_actions(SC_ID_MORE_THAN_ONE_SIGNAL_DRIVER_, SC_DO_NOTHING);
// run the simulation
sc_start(1.0, SC_MS);
sc_close_vcd_trace_file(tf);
return 0;
}