Compare commits
2 Commits
master
...
feature/te
Author | SHA1 | Date |
---|---|---|
Eyck Jentzsch | 397863875e | |
Eyck Jentzsch | 73c257af03 |
|
@ -1,3 +1,4 @@
|
|||
eclipse.preferences.version=1
|
||||
encoding//src/com/minres/scviewer/database/test/DatabaseServicesPerformanceTest.java=UTF-8
|
||||
encoding//src/com/minres/scviewer/database/test/DatabaseServicesTest.java=UTF-8
|
||||
encoding/<project>=UTF-8
|
||||
|
|
|
@ -16,18 +16,18 @@
|
|||
<booleanAttribute key="includeOptional" value="true"/>
|
||||
<stringAttribute key="location" value="${workspace_loc}/../junit-workspace"/>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||
<listEntry value="/com.minres.scviewer.database.test"/>
|
||||
<listEntry value="/com.minres.scviewer.database.test/src/com/minres/scviewer/database/test/DatabaseServicesTest.java"/>
|
||||
</listAttribute>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||
<listEntry value="4"/>
|
||||
<listEntry value="1"/>
|
||||
</listAttribute>
|
||||
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value="=com.minres.scviewer.database.test"/>
|
||||
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
|
||||
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
|
||||
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
|
||||
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
|
||||
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value=""/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="com.minres.scviewer.database.test.DatabaseServicesTest"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="com.minres.scviewer.database.test"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
|
||||
|
|
|
@ -1,5 +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"/>
|
||||
<implementation class="com.minres.scviewer.database.test.DatabaseFactory"/>
|
||||
<reference bind="setFactory" cardinality="1..1" interface="com.minres.scviewer.database.IWaveformDbFactory" name="IWaveformDbFactory" policy="static" unbind="unsetFactory"/>
|
||||
</scr:component>
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
/.scviewer.*
|
||||
/.my_db.txlog*
|
||||
/.simple_system.txlog_bdb.*
|
||||
|
|
Binary file not shown.
|
@ -0,0 +1,24 @@
|
|||
package com.minres.scviewer.database.test;
|
||||
|
||||
import com.minres.scviewer.database.IWaveformDb;
|
||||
import com.minres.scviewer.database.IWaveformDbFactory;
|
||||
|
||||
public class DatabaseFactory {
|
||||
private static IWaveformDbFactory waveformDbFactory;
|
||||
|
||||
public synchronized void setFactory(IWaveformDbFactory service) {
|
||||
waveformDbFactory = service;
|
||||
}
|
||||
|
||||
public synchronized void unsetFactory(IWaveformDbFactory service) {
|
||||
if (waveformDbFactory == service) {
|
||||
waveformDbFactory = null;
|
||||
}
|
||||
}
|
||||
|
||||
public IWaveformDb getDatabase() {
|
||||
return waveformDbFactory.getDatabase();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 MINRES Technologies GmbH and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* MINRES Technologies GmbH - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package com.minres.scviewer.database.test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
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 DatabaseServicesPerformanceTest {
|
||||
|
||||
private DatabaseFactory databaseFactory;
|
||||
|
||||
private IWaveformDb waveformDb;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
databaseFactory = new DatabaseFactory();
|
||||
waveformDb=databaseFactory.getDatabase();
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testVCD() throws Exception {
|
||||
File f = new File("inputs/my_db.vcd").getAbsoluteFile();
|
||||
assertTrue(f.exists());
|
||||
waveformDb.load(f);
|
||||
assertNotNull(waveformDb);
|
||||
assertEquals(14, waveformDb.getAllWaves().size());
|
||||
assertEquals(2, waveformDb.getChildNodes().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTxText() throws Exception {
|
||||
File f = new File("inputs/simple_system.txlog").getAbsoluteFile();
|
||||
assertTrue(f.exists());
|
||||
long timeBefore = System.currentTimeMillis();
|
||||
waveformDb.load(f);
|
||||
long timeAfter = System.currentTimeMillis();
|
||||
long elapsed = timeAfter - timeBefore;
|
||||
assertNotNull(waveformDb);
|
||||
System.out.println("elapsed:" + elapsed);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -26,23 +26,13 @@ import com.minres.scviewer.database.IWaveformDbFactory;
|
|||
public class DatabaseServicesTest {
|
||||
|
||||
|
||||
private static IWaveformDbFactory waveformDbFactory;
|
||||
private DatabaseFactory databaseFactory;
|
||||
|
||||
private IWaveformDb waveformDb;
|
||||
|
||||
public synchronized void setFactory(IWaveformDbFactory service) {
|
||||
waveformDbFactory = service;
|
||||
}
|
||||
|
||||
public synchronized void unsetFactory(IWaveformDbFactory service) {
|
||||
if (waveformDbFactory == service) {
|
||||
waveformDbFactory = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
waveformDb=waveformDbFactory.getDatabase();
|
||||
waveformDb=new DatabaseFactory().getDatabase();
|
||||
// Wait for OSGi dependencies
|
||||
// for (int i = 0; i < 10; i++) {
|
||||
// if (waveformDb.size() == 3) // Dependencies fulfilled
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
eclipse.preferences.version=1
|
||||
groovy.compiler.level=23
|
||||
groovy.compiler.level=24
|
||||
groovy.script.filters=**/*.dsld,y,**/*.gradle,n
|
||||
|
|
|
@ -26,17 +26,21 @@ import com.minres.scviewer.database.IWaveformDb
|
|||
import com.minres.scviewer.database.IWaveformDbLoader
|
||||
import com.minres.scviewer.database.RelationType
|
||||
|
||||
public class TextDbLoader implements IWaveformDbLoader{
|
||||
public class TextDbLoader implements IWaveformDbLoader, Serializable{
|
||||
|
||||
private Long maxTime;
|
||||
|
||||
IWaveformDb db;
|
||||
transient IWaveformDb db;
|
||||
|
||||
DB backingDb;
|
||||
transient DB backingDb;
|
||||
|
||||
def streams = []
|
||||
transient def streamsById = [:]
|
||||
|
||||
def relationTypes=[:]
|
||||
transient def generatorsById = [:]
|
||||
|
||||
transient def transactionsById = [:]
|
||||
|
||||
transient def relationTypes=[:]
|
||||
|
||||
public TextDbLoader() {
|
||||
}
|
||||
|
@ -48,37 +52,39 @@ public class TextDbLoader implements IWaveformDbLoader{
|
|||
|
||||
@Override
|
||||
public List<IWaveform> getAllWaves() {
|
||||
return new LinkedList<IWaveform>(streams);
|
||||
return new LinkedList<IWaveform>(streamsById.values());
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
// public Map<Long, ITxGenerator> getGeneratorsById() {
|
||||
// TreeMap<Long, ITxGenerator> res = new TreeMap<Long, ITxGenerator>();
|
||||
// streamsById.values().each{TxStream stream ->
|
||||
// stream.generators.each{res.put(it.id, id)} }
|
||||
// return res;
|
||||
// }
|
||||
|
||||
static final byte[] x = "scv_tr_stream".bytes
|
||||
|
||||
@Override
|
||||
boolean load(IWaveformDb db, File file) throws Exception {
|
||||
this.db=db
|
||||
this.streams=[]
|
||||
def gzipped = isGzipped(file)
|
||||
if(isTxfile(gzipped?new GZIPInputStream(new FileInputStream(file)):new FileInputStream(file))){
|
||||
if(true) {
|
||||
def parentDir=file.absoluteFile.parent
|
||||
def filename=file.name
|
||||
new File(parentDir).eachFileRecurse (FileType.FILES) { f -> if(f.name=~/^\.${filename}/) f.delete() }
|
||||
this.backingDb = DBMaker.openFile(parentDir+File.separator+"."+filename+"_bdb")
|
||||
.deleteFilesAfterClose()
|
||||
.useRandomAccessFile()
|
||||
.setMRUCacheSize(4096)
|
||||
//.disableTransactions()
|
||||
//.enableHardCache()
|
||||
.enableMRUCache()
|
||||
.setMRUCacheSize(1024*4096)
|
||||
.disableTransactions()
|
||||
.disableLocking()
|
||||
.make();
|
||||
} else {
|
||||
this.backingDb = DBMaker.openMemory().disableLocking().make()
|
||||
}
|
||||
streamsById = backingDb.createHashMap("streamsById")
|
||||
generatorsById = backingDb.createHashMap("generatorsById")
|
||||
transactionsById = backingDb.createHashMap("transactionsById")
|
||||
relationTypes=backingDb.createHashMap("relationTypes")
|
||||
parseInput(gzipped?new GZIPInputStream(new FileInputStream(file)):new FileInputStream(file))
|
||||
calculateConcurrencyIndicees()
|
||||
return true
|
||||
|
@ -122,9 +128,7 @@ public class TextDbLoader implements IWaveformDbLoader{
|
|||
}
|
||||
}
|
||||
private def parseInput(InputStream inputStream){
|
||||
def streamsById = [:]
|
||||
def generatorsById = [:]
|
||||
def transactionsById = [:]
|
||||
//def transactionsById = backingDb.createHashMap("transactionsById")
|
||||
TxGenerator generator
|
||||
Tx transaction
|
||||
boolean endTransaction=false
|
||||
|
@ -139,15 +143,14 @@ public class TextDbLoader implements IWaveformDbLoader{
|
|||
case "begin_attribute":
|
||||
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 TxStream(db, id, matcher[0][2], matcher[0][3], backingDb)
|
||||
streams<<stream
|
||||
def id = Long.parseLong(matcher[0][1])
|
||||
def stream = new TxStream(this, id, matcher[0][2], matcher[0][3])
|
||||
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])
|
||||
ITxStream stream=streamsById[Integer.parseInt(matcher[0][3])]
|
||||
generator=new TxGenerator(id, stream, matcher[0][2])
|
||||
stream.generators<<generator
|
||||
def id = Long.parseLong(matcher[0][1])
|
||||
ITxStream stream=streamsById[Long.parseLong(matcher[0][3])]
|
||||
generator=new TxGenerator(this, id, stream.id, matcher[0][2])
|
||||
stream.generators<<id
|
||||
generatorsById[id]=generator
|
||||
} else if ((matcher = line =~ /^begin_attribute \(ID (\d+), name "([^"]+)", type "([^"]+)"\)$/)) {
|
||||
generator.begin_attrs << TxAttributeType.getAttrType(matcher[0][2], DataType.valueOf(matcher[0][3]), AssociationType.BEGIN)
|
||||
|
@ -159,9 +162,9 @@ public class TextDbLoader implements IWaveformDbLoader{
|
|||
generator=null
|
||||
break
|
||||
case "tx_begin"://matcher = line =~ /^tx_begin\s+(\d+)\s+(\d+)\s+(\d+)\s+([munpf]?s)/
|
||||
def id = Integer.parseInt(tokens[1])
|
||||
TxGenerator gen=generatorsById[Integer.parseInt(tokens[2])]
|
||||
transaction = new Tx(id, gen.stream, gen, Long.parseLong(tokens[3])*stringToScale(tokens[4]))
|
||||
def id = Long.parseLong(tokens[1])
|
||||
TxGenerator gen=generatorsById[Long.parseLong(tokens[2])]
|
||||
transaction = new Tx(this, id, gen.id, Long.parseLong(tokens[3])*stringToScale(tokens[4]))
|
||||
gen.transactions << transaction
|
||||
transactionsById[id]= transaction
|
||||
gen.begin_attrs_idx=0;
|
||||
|
@ -169,16 +172,16 @@ public class TextDbLoader implements IWaveformDbLoader{
|
|||
endTransaction=false
|
||||
break
|
||||
case "tx_end"://matcher = line =~ /^tx_end\s+(\d+)\s+(\d+)\s+(\d+)\s+([munpf]?s)/
|
||||
def id = Integer.parseInt(tokens[1])
|
||||
def id = Long.parseLong(tokens[1])
|
||||
transaction = transactionsById[id]
|
||||
assert Integer.parseInt(tokens[2])==transaction.generator.id
|
||||
assert Long.parseLong(tokens[2])==transaction.generator.id
|
||||
transaction.endTime = Long.parseLong(tokens[3])*stringToScale(tokens[4])
|
||||
transaction.generator.end_attrs_idx=0;
|
||||
maxTime = maxTime>transaction.endTime?maxTime:transaction.endTime
|
||||
endTransaction=true
|
||||
break
|
||||
case "tx_record_attribute"://matcher = line =~ /^tx_record_attribute\s+(\d+)\s+"([^"]+)"\s+(\S+)\s*=\s*(.+)$/
|
||||
def id = Integer.parseInt(tokens[1])
|
||||
def id = Long.parseLong(tokens[1])
|
||||
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+(.+)$/
|
||||
|
@ -189,8 +192,8 @@ public class TextDbLoader implements IWaveformDbLoader{
|
|||
}
|
||||
break
|
||||
case "tx_relation"://matcher = line =~ /^tx_relation\s+\"(\S+)\"\s+(\d+)\s+(\d+)$/
|
||||
Tx tr2= transactionsById[Integer.parseInt(tokens[2])]
|
||||
Tx tr1= transactionsById[Integer.parseInt(tokens[3])]
|
||||
Tx tr2= transactionsById[Long.parseLong(tokens[2])]
|
||||
Tx tr1= transactionsById[Long.parseLong(tokens[3])]
|
||||
def relType=tokens[1][1..-2]
|
||||
if(!relationTypes.containsKey(relType)) relationTypes[relType]=RelationType.create(relType)
|
||||
def rel = new TxRelation(relationTypes[relType], tr1, tr2)
|
||||
|
@ -202,14 +205,14 @@ public class TextDbLoader implements IWaveformDbLoader{
|
|||
|
||||
}
|
||||
lineCnt++
|
||||
if((lineCnt%1000) == 0) {
|
||||
backingDb.commit()
|
||||
}
|
||||
}
|
||||
backingDb.commit();
|
||||
}
|
||||
|
||||
private def calculateConcurrencyIndicees(){
|
||||
streams.each{ TxStream stream -> stream.getMaxConcurrency() }
|
||||
streamsById.values().each{ TxStream stream ->
|
||||
stream.getMaxConcurrency()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -12,13 +12,13 @@ package com.minres.scviewer.database.text
|
|||
|
||||
import com.minres.scviewer.database.*
|
||||
|
||||
class Tx implements ITx {
|
||||
class Tx implements ITx, Serializable {
|
||||
|
||||
TextDbLoader loader
|
||||
|
||||
Long id
|
||||
|
||||
TxGenerator generator
|
||||
|
||||
TxStream stream
|
||||
Long generator_id
|
||||
|
||||
int concurrencyIndex
|
||||
|
||||
|
@ -32,10 +32,10 @@ class Tx implements ITx {
|
|||
|
||||
def outgoingRelations =[]
|
||||
|
||||
Tx(int id, TxStream stream, TxGenerator generator, Long begin){
|
||||
Tx(TextDbLoader loader, Long id, Long generator_id, Long begin){
|
||||
this.loader=loader
|
||||
this.id=id
|
||||
this.stream=stream
|
||||
this.generator=generator
|
||||
this.generator_id=generator_id
|
||||
this.beginTime=begin
|
||||
this.endTime=begin
|
||||
}
|
||||
|
@ -64,4 +64,14 @@ class Tx implements ITx {
|
|||
return "tx#"+getId()+"["+getBeginTime()/1000000+"ns - "+getEndTime()/1000000+"ns]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITxStream<ITxEvent> getStream() {
|
||||
return generator.stream;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITxGenerator getGenerator() {
|
||||
return loader.generatorsById[generator_id];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ import com.minres.scviewer.database.DataType;
|
|||
import com.minres.scviewer.database.ITxAttributeType;
|
||||
import com.minres.scviewer.database.ITxAttribute
|
||||
|
||||
class TxAttribute implements ITxAttribute{
|
||||
class TxAttribute implements ITxAttribute, Serializable {
|
||||
|
||||
TxAttributeType attributeType
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ import com.minres.scviewer.database.AssociationType;
|
|||
import com.minres.scviewer.database.DataType;
|
||||
import com.minres.scviewer.database.ITxAttributeType;
|
||||
|
||||
class TxAttributeType implements ITxAttributeType {
|
||||
class TxAttributeType implements ITxAttributeType, Serializable {
|
||||
String name
|
||||
DataType dataType
|
||||
AssociationType type
|
||||
|
|
|
@ -4,7 +4,7 @@ import com.minres.scviewer.database.ITx
|
|||
import com.minres.scviewer.database.ITxEvent
|
||||
import com.minres.scviewer.database.IWaveformEvent
|
||||
|
||||
class TxEvent implements ITxEvent {
|
||||
class TxEvent implements ITxEvent, Serializable {
|
||||
|
||||
final ITxEvent.Type type;
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ package com.minres.scviewer.database.text
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.jdbm.DB
|
||||
import com.minres.scviewer.database.ITxAttributeType
|
||||
import com.minres.scviewer.database.ITxAttribute;
|
||||
import com.minres.scviewer.database.ITxEvent;
|
||||
|
@ -21,10 +21,11 @@ import com.minres.scviewer.database.ITxStream;
|
|||
import com.minres.scviewer.database.ITx;
|
||||
import com.minres.scviewer.database.IWaveformEvent;
|
||||
|
||||
class TxGenerator implements ITxGenerator{
|
||||
class TxGenerator implements ITxGenerator, Serializable{
|
||||
Long id
|
||||
TxStream stream
|
||||
Long stream_id
|
||||
String name
|
||||
TextDbLoader loader;
|
||||
Boolean active = false
|
||||
ArrayList<ITx> transactions=[]
|
||||
|
||||
|
@ -33,14 +34,15 @@ class TxGenerator implements ITxGenerator{
|
|||
ArrayList<ITxAttributeType> end_attrs= []
|
||||
int end_attrs_idx = 0
|
||||
|
||||
TxGenerator(int id, TxStream stream, name){
|
||||
TxGenerator(TextDbLoader loader, Long id, Long stream_id, name){
|
||||
this.id=id
|
||||
this.stream=stream
|
||||
this.stream_id=stream_id
|
||||
this.name=name
|
||||
this.loader=loader
|
||||
}
|
||||
|
||||
ITxStream<? extends ITxEvent> getStream(){
|
||||
return stream;
|
||||
return loader.streamsById[stream_id];
|
||||
}
|
||||
|
||||
List<ITx> getTransactions(){
|
||||
|
|
|
@ -4,7 +4,7 @@ import com.minres.scviewer.database.ITxRelation
|
|||
import com.minres.scviewer.database.ITx;
|
||||
import com.minres.scviewer.database.RelationType;
|
||||
|
||||
class TxRelation implements ITxRelation {
|
||||
class TxRelation implements ITxRelation, Serializable {
|
||||
Tx source
|
||||
|
||||
Tx target
|
||||
|
|
|
@ -27,11 +27,11 @@ import com.minres.scviewer.database.IHierNode
|
|||
import com.minres.scviewer.database.ITxStream
|
||||
import com.minres.scviewer.database.ITx
|
||||
|
||||
class TxStream extends HierNode implements ITxStream {
|
||||
class TxStream extends HierNode implements ITxStream, Serializable {
|
||||
|
||||
Long id
|
||||
|
||||
IWaveformDb database
|
||||
transient TextDbLoader loader
|
||||
|
||||
String fullName
|
||||
|
||||
|
@ -43,24 +43,24 @@ class TxStream extends HierNode implements ITxStream {
|
|||
|
||||
private TreeMap<Long, List<ITxEvent>> events
|
||||
|
||||
TxStream(IWaveformDb db, int id, String name, String kind, DB backingStore){
|
||||
TxStream(TextDbLoader loader, Long id, String name, String kind){
|
||||
super(name)
|
||||
this.id=id
|
||||
this.database=db
|
||||
this.loader=loader
|
||||
this.fullName=name
|
||||
this.kind=kind
|
||||
this.maxConcurrency=0
|
||||
//events = new TreeMap<Long, List<ITxEvent>>()
|
||||
events=backingStore.createTreeMap("stream-"+name)
|
||||
events = new TreeMap<Long, List<ITxEvent>>()
|
||||
//events=backingStore.createTreeMap("stream-"+name)
|
||||
}
|
||||
|
||||
List<ITxGenerator> getGenerators(){
|
||||
return generators as List<ITxGenerator>
|
||||
return generators.collect { loader.generatorsById[it] } as List<ITxGenerator>
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWaveformDb getDb() {
|
||||
return database
|
||||
return loader.db
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.eclipse.swt.graphics.Rectangle;
|
|||
import com.minres.scviewer.database.ISignal;
|
||||
import com.minres.scviewer.database.ISignalChange;
|
||||
import com.minres.scviewer.database.ISignalChangeMulti;
|
||||
import com.minres.scviewer.database.ISignalChangeReal;
|
||||
import com.minres.scviewer.database.ISignalChangeSingle;
|
||||
import com.minres.scviewer.database.ui.TrackEntry;
|
||||
import com.minres.scviewer.database.ui.WaveformColors;
|
||||
|
@ -107,8 +108,13 @@ public class SignalPainter extends TrackPainter {
|
|||
NavigableMap<Long, ? extends ISignalChange> entries = signal.getEvents().subMap(first.getKey(), false, last.getKey(), true);
|
||||
SignalChange left = new SignalChange(first);
|
||||
SignalChange right = new SignalChange(entries.size() > 0 ? entries.firstEntry() : first);
|
||||
SignalStencil stencil = left.value instanceof ISignalChangeSingle ? new SingleBitStencil() : new MultiBitStencil(gc);
|
||||
|
||||
SignalStencil stencil = null;
|
||||
if(left.value instanceof ISignalChangeSingle)
|
||||
stencil= new SingleBitStencil();
|
||||
else if(left.value instanceof ISignalChangeMulti)
|
||||
stencil= new MultiBitStencil(gc);
|
||||
else
|
||||
stencil= new RealStencil(left.value, entries);
|
||||
maxX = area.x + area.width;
|
||||
yOffsetT = this.waveCanvas.getTrackHeight() / 5 + area.y;
|
||||
yOffsetM = this.waveCanvas.getTrackHeight() / 2 + area.y;
|
||||
|
@ -122,7 +128,6 @@ public class SignalPainter extends TrackPainter {
|
|||
// b) left to close to right
|
||||
if (left.time == right.time) {
|
||||
right.time = endTime;
|
||||
|
||||
} else {
|
||||
multiple = true;
|
||||
long eTime = (xBegin + 1) * this.waveCanvas.getScaleFactor();
|
||||
|
@ -144,7 +149,9 @@ public class SignalPainter extends TrackPainter {
|
|||
if (xEnd == xBegin) {
|
||||
multiple = true;
|
||||
long eTime = (xBegin + 1) * this.waveCanvas.getScaleFactor();
|
||||
right.set(entries.floorEntry(eTime), endTime);
|
||||
Entry<Long, ? extends ISignalChange> entry = entries.floorEntry(eTime);
|
||||
if(entry!=null && entry.getKey()> right.time)
|
||||
right.set(entry, endTime);
|
||||
xEnd = getXEnd(eTime);
|
||||
}
|
||||
} while (left.time < endTime);
|
||||
|
@ -254,7 +261,84 @@ public class SignalPainter extends TrackPainter {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class RealStencil implements SignalStencil {
|
||||
double min;
|
||||
double max;
|
||||
double diff;
|
||||
|
||||
public RealStencil(ISignalChange value, NavigableMap<Long, ? extends ISignalChange> entries) {
|
||||
min=((ISignalChangeReal) value).getValue();
|
||||
max=min;
|
||||
for (ISignalChange e : entries.values()) {
|
||||
double v = ((ISignalChangeReal)e).getValue();
|
||||
max= Double.isNaN(max)? v : Math.max(max, v);
|
||||
min= Double.isNaN(min)? v : Math.min(min, v);
|
||||
}
|
||||
int nans = (Double.isNaN(max)?2:0) + (Double.isNaN(max)?1:0);
|
||||
switch(nans) {
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
max=min;
|
||||
break;
|
||||
case 2:
|
||||
min=max;
|
||||
case 3:
|
||||
max=min=0;
|
||||
}
|
||||
diff=max-min;
|
||||
if(diff==0.0) {
|
||||
if(max>0)
|
||||
min=0.0;
|
||||
else if(min<0.0)
|
||||
max=0.0;
|
||||
else {
|
||||
max=1.0;
|
||||
min=0.0;
|
||||
}
|
||||
diff=max-min;
|
||||
}
|
||||
}
|
||||
|
||||
public void draw(GC gc, Rectangle area, ISignalChange left, ISignalChange right, int xBegin, int xEnd, boolean multiple) {
|
||||
double value = ((ISignalChangeReal)left).getValue();
|
||||
if(Double.isNaN(value)) {
|
||||
Color color = waveCanvas.colors[WaveformColors.SIGNAL_NAN.ordinal()];
|
||||
int width = xEnd - xBegin;
|
||||
if (width > 1) {
|
||||
int[] points = {
|
||||
xBegin, yOffsetT,
|
||||
xEnd, yOffsetT,
|
||||
xEnd, yOffsetB,
|
||||
xBegin, yOffsetB
|
||||
};
|
||||
gc.setForeground(color);
|
||||
gc.drawPolygon(points);
|
||||
gc.setBackground(color);
|
||||
gc.fillPolygon(points);
|
||||
} else {
|
||||
gc.setForeground(color);
|
||||
gc.drawLine(xEnd, yOffsetT, xEnd, yOffsetB);
|
||||
}
|
||||
} else {
|
||||
Color color = waveCanvas.colors[WaveformColors.SIGNAL_ANALOG.ordinal()];
|
||||
int height=yOffsetT-yOffsetB;
|
||||
double offset=value-min;
|
||||
int yOffset=diff>0?(int)(height*(offset/diff)) + yOffsetB:yOffsetM;
|
||||
gc.setForeground(color);
|
||||
if (xEnd > maxX) {
|
||||
gc.drawLine(xBegin, yOffset, maxX, yOffset);
|
||||
} else {
|
||||
gc.drawLine(xBegin, yOffset, xEnd, yOffset);
|
||||
double nextOffset = ((ISignalChangeReal)right).getValue()-min;
|
||||
int yNext = diff>0?(int)(height*(nextOffset/diff)) + yOffsetB:height/2;
|
||||
if (yOffset != yNext)
|
||||
gc.drawLine(xEnd, yOffset, xEnd, yNext);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ISignal<? extends ISignalChange> getSignal() {
|
||||
|
|
|
@ -156,6 +156,8 @@ public class WaveformCanvas extends Canvas {
|
|||
colors[WaveformColors.SIGNALZ.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_YELLOW);
|
||||
colors[WaveformColors.SIGNALX.ordinal()] = SWTResourceManager.getColor(255, 51, 51);
|
||||
colors[WaveformColors.SIGNALU.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_YELLOW);
|
||||
colors[WaveformColors.SIGNAL_ANALOG.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GREEN);
|
||||
colors[WaveformColors.SIGNAL_NAN.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED);
|
||||
colors[WaveformColors.SIGNAL_TEXT.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_WHITE);
|
||||
colors[WaveformColors.CURSOR.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED);
|
||||
colors[WaveformColors.CURSOR_DRAG.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GRAY);
|
||||
|
|
|
@ -72,6 +72,7 @@ import com.google.common.collect.Lists;
|
|||
import com.minres.scviewer.database.ISignal;
|
||||
import com.minres.scviewer.database.ISignalChange;
|
||||
import com.minres.scviewer.database.ISignalChangeMulti;
|
||||
import com.minres.scviewer.database.ISignalChangeReal;
|
||||
import com.minres.scviewer.database.ISignalChangeSingle;
|
||||
import com.minres.scviewer.database.ITx;
|
||||
import com.minres.scviewer.database.ITxEvent;
|
||||
|
@ -458,6 +459,8 @@ public class WaveformViewer implements IWaveformViewer {
|
|||
entry.setValue("b'"+((ISignalChangeSingle)event).getValue());
|
||||
} else if(event instanceof ISignalChangeMulti){
|
||||
entry.setValue("h'"+((ISignalChangeMulti)event).getValue().toHexString());
|
||||
} else if(event instanceof ISignalChangeReal){
|
||||
entry.setValue(Double.toString(((ISignalChangeReal)event).getValue()));
|
||||
}
|
||||
} else if(entry.getKey() instanceof ITxStream<?>){
|
||||
ITxStream<?> stream = (ITxStream<?>) entry.getKey();
|
||||
|
|
|
@ -14,7 +14,7 @@ public enum WaveformColors {
|
|||
LINE, LINE_HIGHLITE,
|
||||
TRACK_BG_EVEN, TRACK_BG_ODD, TRACK_BG_HIGHLITE,
|
||||
TX_BG, TX_BG_HIGHLITE, TX_BORDER,
|
||||
SIGNAL0, SIGNAL1, SIGNALZ, SIGNALX, SIGNALU, SIGNAL_TEXT,
|
||||
SIGNAL0, SIGNAL1, SIGNALZ, SIGNALX, SIGNALU, SIGNAL_TEXT, SIGNAL_ANALOG, SIGNAL_NAN,
|
||||
CURSOR, CURSOR_DRAG, CURSOR_TEXT,
|
||||
MARKER, MARKER_TEXT, REL_ARROW, REL_ARROW_HIGHLITE
|
||||
}
|
|
@ -12,18 +12,25 @@ package com.minres.scviewer.database;
|
|||
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.beans.PropertyChangeSupport;
|
||||
import java.beans.Transient;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class HierNode implements IHierNode {
|
||||
public class HierNode implements IHierNode, Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -2278641781226609616L;
|
||||
|
||||
protected String name;
|
||||
|
||||
protected String parentName;
|
||||
|
||||
protected ArrayList<IHierNode> childs;
|
||||
protected transient ArrayList<IHierNode> childs;
|
||||
|
||||
protected PropertyChangeSupport pcs;
|
||||
protected transient PropertyChangeSupport pcs;
|
||||
|
||||
public HierNode() {
|
||||
childs = new ArrayList<IHierNode>();
|
||||
|
|
|
@ -10,9 +10,15 @@
|
|||
*******************************************************************************/
|
||||
package com.minres.scviewer.database;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class RelationType {
|
||||
public class RelationType implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -5598253591502850283L;
|
||||
|
||||
private static HashMap<String, RelationType> registry = new HashMap<>();
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
package com.minres.scviewer.database.internal;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
@ -31,7 +32,12 @@ import com.minres.scviewer.database.IWaveformEvent;
|
|||
import com.minres.scviewer.database.InputFormatException;
|
||||
import com.minres.scviewer.database.RelationType;
|
||||
|
||||
public class WaveformDb extends HierNode implements IWaveformDb {
|
||||
public class WaveformDb extends HierNode implements IWaveformDb, Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 4917280760027131179L;
|
||||
|
||||
private static List<IWaveformDbLoader> loaders=new LinkedList<IWaveformDbLoader>();
|
||||
|
||||
|
|
|
@ -46,6 +46,8 @@ public class DefaultValuesInitializer extends AbstractPreferenceInitializer {
|
|||
colors[WaveformColors.SIGNALZ.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_YELLOW);
|
||||
colors[WaveformColors.SIGNALX.ordinal()] = SWTResourceManager.getColor(255, 51, 51);
|
||||
colors[WaveformColors.SIGNALU.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_YELLOW);
|
||||
colors[WaveformColors.SIGNAL_ANALOG.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GREEN);
|
||||
colors[WaveformColors.SIGNAL_NAN.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED);
|
||||
colors[WaveformColors.SIGNAL_TEXT.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_WHITE);
|
||||
colors[WaveformColors.CURSOR.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED);
|
||||
colors[WaveformColors.CURSOR_DRAG.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GRAY);
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<launchConfiguration type="org.eclipse.pde.ui.RuntimeWorkbench">
|
||||
<booleanAttribute key="append.args" value="true"/>
|
||||
<stringAttribute key="application" value="org.eclipse.e4.ui.workbench.swt.E4Application"/>
|
||||
<booleanAttribute key="askclear" value="true"/>
|
||||
<booleanAttribute key="automaticAdd" value="false"/>
|
||||
<booleanAttribute key="automaticValidate" value="false"/>
|
||||
<stringAttribute key="bootstrap" value=""/>
|
||||
<stringAttribute key="checked" value="[NONE]"/>
|
||||
<booleanAttribute key="clearConfig" value="false"/>
|
||||
<booleanAttribute key="clearws" value="false"/>
|
||||
<booleanAttribute key="clearwslog" value="false"/>
|
||||
<stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/SCViewer (restart)"/>
|
||||
<booleanAttribute key="default" value="false"/>
|
||||
<booleanAttribute key="includeOptional" value="true"/>
|
||||
<stringAttribute key="location" value="${workspace_loc}/../runtime-com.minres.scviewer.e4.application.product"/>
|
||||
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog -clearPersistedState -data @none"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms40m -Xmx4G -Xdock:icon=../Resources/Eclipse.icns -XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts"/>
|
||||
<stringAttribute key="pde.version" value="3.3"/>
|
||||
<stringAttribute key="product" value="com.minres.scviewer.e4.application.product"/>
|
||||
<stringAttribute key="productFile" value="/com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.product"/>
|
||||
<stringAttribute key="selected_target_plugins" value="com.google.guava@default:default,com.ibm.icu@default:default,javax.annotation@default:default,javax.inject@default:default,javax.servlet@default:default,javax.xml@default:default,org.apache.ant@default:default,org.apache.batik.css@default:default,org.apache.batik.util.gui@default:default,org.apache.batik.util@default:default,org.apache.commons.jxpath@default:default,org.apache.felix.gogo.command@default:default,org.apache.felix.gogo.runtime@default:default,org.codehaus.groovy@default:default,org.eclipse.ant.core@default:default,org.eclipse.core.commands@default:default,org.eclipse.core.contenttype@default:default,org.eclipse.core.databinding.observable@default:default,org.eclipse.core.databinding.property@default:default,org.eclipse.core.databinding@default:default,org.eclipse.core.expressions@default:default,org.eclipse.core.filesystem.macosx@default:false,org.eclipse.core.filesystem@default:default,org.eclipse.core.jobs@default:default,org.eclipse.core.resources@default:default,org.eclipse.core.runtime@default:true,org.eclipse.core.variables@default:default,org.eclipse.e4.core.commands@default:default,org.eclipse.e4.core.contexts@default:default,org.eclipse.e4.core.di.annotations@default:default,org.eclipse.e4.core.di.extensions@default:default,org.eclipse.e4.core.di@default:default,org.eclipse.e4.core.services@default:default,org.eclipse.e4.emf.xpath@default:default,org.eclipse.e4.ui.bindings@default:default,org.eclipse.e4.ui.css.core@default:default,org.eclipse.e4.ui.css.swt.theme@default:default,org.eclipse.e4.ui.css.swt@default:default,org.eclipse.e4.ui.di@default:default,org.eclipse.e4.ui.model.workbench@default:default,org.eclipse.e4.ui.services@default:default,org.eclipse.e4.ui.widgets@default:default,org.eclipse.e4.ui.workbench.addons.swt@default:default,org.eclipse.e4.ui.workbench.renderers.swt.cocoa@default:false,org.eclipse.e4.ui.workbench.renderers.swt@default:default,org.eclipse.e4.ui.workbench.swt@default:default,org.eclipse.e4.ui.workbench3@default:default,org.eclipse.e4.ui.workbench@default:default,org.eclipse.emf.common@default:default,org.eclipse.emf.ecore.change@default:default,org.eclipse.emf.ecore.xmi@default:default,org.eclipse.emf.ecore@default:default,org.eclipse.equinox.app@default:default,org.eclipse.equinox.bidi@default:default,org.eclipse.equinox.common@2:true,org.eclipse.equinox.ds@1:true,org.eclipse.equinox.event@default:default,org.eclipse.equinox.preferences@default:default,org.eclipse.equinox.registry@default:default,org.eclipse.equinox.util@default:default,org.eclipse.jface.databinding@default:default,org.eclipse.jface@default:default,org.eclipse.osgi.compatibility.state@default:false,org.eclipse.osgi.services@default:default,org.eclipse.osgi@-1:true,org.eclipse.swt.cocoa.macosx.x86_64@default:false,org.eclipse.swt@default:default,org.hamcrest.core@default:default,org.junit@default:default,org.w3c.css.sac@default:default,org.w3c.dom.events@default:default,org.w3c.dom.smil@default:default,org.w3c.dom.svg@default:default"/>
|
||||
<stringAttribute key="selected_workspace_plugins" value="com.minres.scviewer.database.sqlite@default:default,com.minres.scviewer.database.text@default:default,com.minres.scviewer.database.ui.swt@default:default,com.minres.scviewer.database.ui@default:default,com.minres.scviewer.database.vcd@default:default,com.minres.scviewer.database@default:default,com.minres.scviewer.e4.application@default:default,com.opcoach.e4.preferences@default:default"/>
|
||||
<booleanAttribute key="show_selected_only" value="false"/>
|
||||
<booleanAttribute key="tracing" value="false"/>
|
||||
<booleanAttribute key="useCustomFeatures" value="false"/>
|
||||
<booleanAttribute key="useDefaultConfig" value="true"/>
|
||||
<booleanAttribute key="useDefaultConfigArea" value="true"/>
|
||||
<booleanAttribute key="useProduct" value="true"/>
|
||||
<booleanAttribute key="usefeatures" value="false"/>
|
||||
</launchConfiguration>
|
|
@ -9,7 +9,7 @@
|
|||
<repository location="http://download.eclipse.org/releases/neon"/>
|
||||
</location>
|
||||
<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="true" type="InstallableUnit">
|
||||
<unit id="org.codehaus.groovy24.feature.feature.group" version="2.9.2.xx-201701211811-e46"/>
|
||||
<unit id="org.codehaus.groovy24.feature.feature.group" version="2.9.3.xx-201806261157-e46"/>
|
||||
<repository location="http://dist.springsource.org/snapshot/GRECLIPSE/e4.6"/>
|
||||
</location>
|
||||
</locations>
|
||||
|
@ -17,8 +17,7 @@
|
|||
<arch>x86_64</arch>
|
||||
<nl>de_DE</nl>
|
||||
</environment>
|
||||
<targetJRE path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.launching.macosx.MacOSXType/Java SE 7 [1.7.0_45]"/>
|
||||
<launcherArgs>
|
||||
<vmArgs>-Dosgi.requiredJavaVersion=1.6 -XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts -XX:MaxPermSize=256m -Xdock:icon=../Resources/Eclipse.icns -XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts -Xms40m -Xmx512m -Xdock:icon=../Resources/Eclipse.icns -XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts</vmArgs>
|
||||
<vmArgs>-Dosgi.requiredJavaVersion=1.7 -XX:MaxPermSize=256 -Xms40m -Xmx2G </vmArgs>
|
||||
</launcherArgs>
|
||||
</target>
|
|
@ -1,2 +1,3 @@
|
|||
eclipse.preferences.version=1
|
||||
groovy.compiler.level=23
|
||||
groovy.compiler.level=24
|
||||
groovy.script.filters=**/*.dsld,y,**/*.gradle,n
|
||||
|
|
Loading…
Reference in New Issue