Compare commits

..

No commits in common. "master" and "V2.0.0" have entirely different histories.

725 changed files with 413441 additions and 42355 deletions

5
.gitignore vendored
View File

@ -6,8 +6,5 @@
SCViewer initiator_target.launch SCViewer initiator_target.launch
SCViewer.xcf SCViewer.xcf
SCViewer_1.png SCViewer_1.png
*.launch
copyrightLog.txt copyrightLog.txt
/workspace
?*.launch
/.settings/
.tycho-consumer-pom.xml

View File

@ -1,23 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.m2e.Maven2LaunchConfigurationType">
<intAttribute key="M2_COLORS" value="0"/>
<booleanAttribute key="M2_DEBUG_OUTPUT" value="false"/>
<stringAttribute key="M2_GOALS" value="package"/>
<booleanAttribute key="M2_NON_RECURSIVE" value="false"/>
<booleanAttribute key="M2_OFFLINE" value="false"/>
<stringAttribute key="M2_PROFILES" value=""/>
<listAttribute key="M2_PROPERTIES"/>
<stringAttribute key="M2_RUNTIME" value="EMBEDDED"/>
<booleanAttribute key="M2_SKIP_TESTS" value="false"/>
<intAttribute key="M2_THREADS" value="1"/>
<booleanAttribute key="M2_UPDATE_SNAPSHOTS" value="false"/>
<stringAttribute key="M2_USER_SETTINGS" value=""/>
<booleanAttribute key="M2_WORKSPACE_RESOLUTION" value="false"/>
<booleanAttribute key="org.eclipse.debug.core.ATTR_FORCE_SYSTEM_CONSOLE_ENCODING" value="false"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_ATTR_USE_ARGFILE" value="false"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_SHOW_CODEDETAILS_IN_EXCEPTION_MESSAGES" value="true"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_CLASSPATH_ONLY_JAR" value="false"/>
<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-17/"/>
<stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="${project_loc:com.minres.scviewer.parent}"/>
</launchConfiguration>

View File

@ -1,23 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.m2e.Maven2LaunchConfigurationType">
<intAttribute key="M2_COLORS" value="0"/>
<booleanAttribute key="M2_DEBUG_OUTPUT" value="false"/>
<stringAttribute key="M2_GOALS" value="package"/>
<booleanAttribute key="M2_NON_RECURSIVE" value="false"/>
<booleanAttribute key="M2_OFFLINE" value="false"/>
<stringAttribute key="M2_PROFILES" value="release-composite"/>
<listAttribute key="M2_PROPERTIES"/>
<stringAttribute key="M2_RUNTIME" value="EMBEDDED"/>
<booleanAttribute key="M2_SKIP_TESTS" value="false"/>
<intAttribute key="M2_THREADS" value="4"/>
<booleanAttribute key="M2_UPDATE_SNAPSHOTS" value="false"/>
<stringAttribute key="M2_USER_SETTINGS" value=""/>
<booleanAttribute key="M2_WORKSPACE_RESOLUTION" value="true"/>
<booleanAttribute key="org.eclipse.debug.core.ATTR_FORCE_SYSTEM_CONSOLE_ENCODING" value="false"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_ATTR_USE_ARGFILE" value="false"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_SHOW_CODEDETAILS_IN_EXCEPTION_MESSAGES" value="true"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_CLASSPATH_ONLY_JAR" value="false"/>
<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-17/"/>
<stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="${project_loc:com.minres.scviewer.parent}"/>
</launchConfiguration>

View File

@ -1,26 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.m2e.Maven2LaunchConfigurationType">
<intAttribute key="M2_COLORS" value="0"/>
<booleanAttribute key="M2_DEBUG_OUTPUT" value="false"/>
<stringAttribute key="M2_GOALS" value="tycho-versions:set-version tycho-versions:update-pom"/>
<booleanAttribute key="M2_NON_RECURSIVE" value="false"/>
<booleanAttribute key="M2_OFFLINE" value="false"/>
<stringAttribute key="M2_PROFILES" value=""/>
<listAttribute key="M2_PROPERTIES">
<listEntry value="newVersion=${string_prompt:new version number}"/>
</listAttribute>
<stringAttribute key="M2_RUNTIME" value="EMBEDDED"/>
<booleanAttribute key="M2_SKIP_TESTS" value="false"/>
<intAttribute key="M2_THREADS" value="1"/>
<booleanAttribute key="M2_UPDATE_SNAPSHOTS" value="false"/>
<stringAttribute key="M2_USER_SETTINGS" value=""/>
<booleanAttribute key="M2_WORKSPACE_RESOLUTION" value="false"/>
<stringAttribute key="bad_container_name" value="/com.minres.scviewer.parent/.launch"/>
<booleanAttribute key="org.eclipse.debug.core.ATTR_FORCE_SYSTEM_CONSOLE_ENCODING" value="false"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_ATTR_USE_ARGFILE" value="false"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_SHOW_CODEDETAILS_IN_EXCEPTION_MESSAGES" value="true"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_CLASSPATH_ONLY_JAR" value="false"/>
<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-17/"/>
<stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="${project_loc:com.minres.scviewer.parent}"/>
</launchConfiguration>

View File

@ -1,8 +1,12 @@
SCViewer SCViewer
======== ========
SCViewer is composed of a set of eclipse plugins to display VCD (e.g. created by SystemC VCD trace) and transaction streams. Those streams can be SCViewer is composed of a set of eclipse plugins to display VCD and transaction streams
created by the SystemC Verification Library (SCV, For further description of the SCV please refer to https://www.accellera.org/activities/working-groups/systemc-verification) or by the **L**ight**w**eight **T**ranasaction **R**ecording for SystemC ( [LWTR4SC](https://github.com/Minres/LWTR4SC) ). created by the SystemC VCD trace implementation and the SystemC Verification Library (SCV).
For further description of the SCV please refer to
http://www.accellera.org/activities/committees/systemc-verification.
> If you encounter issue when running on Linux please try running as `SWT_GTK3=0 scviewer` as there exist issues wiht GTK3.
The viewer has the following features The viewer has the following features
- support of VCD files (compressed and uncompressed) - support of VCD files (compressed and uncompressed)
@ -14,57 +18,14 @@ The viewer has the following features
- sqlite based - sqlite based
- visualization of transaction relations - visualization of transaction relations
> If you encounter issue when running on Linux please try running as `SWT_GTK3=0 scviewer` as there exist issues wiht GTK3. To build the plugins the Eclipse SDK or PDE can be used. In both cases the Groovy
eclipse plugin (http://groovy.codehaus.org/Eclipse+Plugin or Market) has to be
To build the plugins the Eclipse SDK or PDE can be used. installed.
Key Shortcuts
=============
Legend:
* Left Mouse Button: LMB
* Middle Mouse Button: MMB
* Mouse Scroll wheel: MScrl
* Context any means Name List, Value List or Waveform
| Input | Modifier | Context | Action |
|------------|----------|----------|-----------------------------------|
| LMB click | | any | select |
| LMB click | Shift | Waveform | move selected marker to position |
| LMB click | Control | Waveform | move cursor to position |
| LMB drag | | Waveform | zoom to range |
| MMB click | | Waveform | move selected marker to position |
| MScrl | | any | scroll window up/down |
| MScrl | Shift | any | scroll window left/right |
| MScrl | Control | Waveform | zoom in/out |
| Key left | | Waveform | scroll window to the left (slow) |
| Key right | | Waveform | scroll window to the right (slow) |
| Key left | Shift | Waveform | scroll window to the left (fast) |
| Key right | Shift | Waveform | scroll window to the right (fast) |
| Key up | | Waveform | move selection up |
| Key down | | Waveform | move selection down |
| Key up | Control | Waveform | move selected track up |
| Key down | Control | Waveform | move selected track down |
| Key + | Control | Waveform | zoom in |
| Key - | Control | Waveform | zoom out |
| Key Pos1 | | Waveform | jump to selected marker |
| Key End | | Waveform | jump to cursor |
| Key Del | | any | delete selected entries |
| LMB click | | ZoomBar | increment/decrement 1 page |
| LMB drag | | ZoomBar | drag both markers (pan) |
| LMB drag | Control | ZoomBar | drag one marker (zoom) |
| MMB drag | | ZoomBar | drag one marker (zoom) |
| xMB dclick | | ZoomBar | pan to position |
| MScrl | | ZoomBar | scroll window left/right |
| MScrl | Shift | ZoomBar | scroll window left/right double speed |
| MScrl | Control | ZoomBar | zoom in/out |
| Key left | | ZoomBar | scroll window to the left (slow) |
| Key right | | ZoomBar | scroll window to the right (slow) |
| Key up | | ZoomBar | scroll window to the left (slow) |
| Key down | | ZoomBar | scroll window to the right (slow) |
| Key PgUp | | ZoomBar | scroll window to the left (fast) |
| Key PgDown | | ZoomBar | scroll window to the right (fast) |
| Key Pos1 | | ZoomBar | scroll to begin |
| Key End | | ZoomBar | scroll to end |
TODO
====
- add more tests
- move to feature based product to allow automatic updates
- improve graphics
- catch-up e3 plugin to functionality of e4 product
- add calculated traces

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry exported="true" kind="lib" path="json-20180813.jar" sourcepath="json-20180813-sources.jar"/>
<classpathentry exported="true" kind="lib" path="leveldb-0.11-SNAPSHOT-uber.jar" sourcepath="leveldb-0.11-SNAPSHOT-sources.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<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,4 @@
/json-20180813-sources.jar
/leveldb-0.11-SNAPSHOT-sources.jar
/bin/
/target/

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<projectDescription> <projectDescription>
<name>com.minres.scviewer.database.fst</name> <name>com.minres.scviewer.database.leveldb</name>
<comment></comment> <comment></comment>
<projects> <projects>
</projects> </projects>

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.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8

View File

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

View File

@ -0,0 +1,5 @@
eclipse.preferences.version=1
enabled=true
path=OSGI-INF
validationErrorLevel=error
validationErrorLevel.missingImplicitUnbindMethod=error

View File

@ -0,0 +1,18 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Leveldb
Bundle-SymbolicName: com.minres.scviewer.database.leveldb
Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: MINRES Technologies GmbH
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Import-Package: org.osgi.framework;version="1.3.0"
Automatic-Module-Name: com.minres.scviewer.database.leveldb
Service-Component: OSGI-INF/*.xml
Require-Bundle: com.minres.scviewer.database;bundle-version="1.0.0",
org.eclipse.equinox.util;bundle-version="1.0.500",
org.eclipse.equinox.ds;bundle-version="1.4.200",
org.eclipse.osgi.services;bundle-version="3.4.0"
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: leveldb-0.11-SNAPSHOT-uber.jar,
.,
json-20180813.jar

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="FtrDbLoaderFactory"> <scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="LevelDbLoader">
<implementation class="com.minres.scviewer.database.ftr.FtrDbLoaderFactory"/> <implementation class="com.minres.scviewer.database.leveldb.LevelDBLoader"/>
<service> <service>
<provide interface="com.minres.scviewer.database.IWaveformDbLoaderFactory"/> <provide interface="com.minres.scviewer.database.IWaveformDbLoader"/>
</service> </service>
</scr:component> </scr:component>

View File

@ -0,0 +1,7 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
OSGI-INF/,\
leveldb-0.11-SNAPSHOT-uber.jar,\
json-20180813.jar

Binary file not shown.

View File

@ -1,14 +1,13 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>com.minres.scviewer.database.fst</artifactId> <artifactId>com.minres.scviewer.database.leveldb</artifactId>
<version>1.0.0-SNAPSHOT</version> <version>1.0.0-SNAPSHOT</version>
<parent> <parent>
<groupId>com.minres.scviewer</groupId> <groupId>com.minres.scviewer</groupId>
<artifactId>com.minres.scviewer.parent</artifactId> <artifactId>com.minres.scviewer.parent</artifactId>
<version>2.19.4</version> <version>2.0.0-SNAPSHOT</version>
<relativePath>../..</relativePath> <relativePath>../com.minres.scviewer.parent</relativePath>
</parent> </parent>
<packaging>eclipse-plugin</packaging> <packaging>eclipse-plugin</packaging>
</project> </project>

View File

@ -0,0 +1,87 @@
package com.minres.scviewer.database.leveldb;
import static java.nio.charset.StandardCharsets.UTF_8;
import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map.Entry;
import org.iq80.leveldb.Options;
import org.iq80.leveldb.impl.SeekingIterator;
import org.json.JSONObject;
import com.minres.scviewer.database.IWaveform;
import com.minres.scviewer.database.IWaveformDb;
import com.minres.scviewer.database.IWaveformDbLoader;
import com.minres.scviewer.database.RelationType;
public class LevelDBLoader implements IWaveformDbLoader {
static byte[] toByteArray(String value) {
return value.getBytes(UTF_8);
}
private TxDBWrapper levelDb;
private IWaveformDb db;
private Long maxTime=null;
private List<RelationType> usedRelationsList = new ArrayList<>();
@Override
public boolean load(IWaveformDb db, File inp) throws Exception {
try {
this.db=db;
levelDb = new TxDBWrapper(new Options(), inp);
JSONObject configVal = new JSONObject(levelDb.get("__config"));
if(!configVal.isEmpty())
levelDb.setTimeResolution(configVal.getLong("resolution"));
} catch(Exception e) {
return false;
}
return true;
}
@Override
public Long getMaxTime() {
if(maxTime==null) {
SeekingIterator<String, String> it = levelDb.iterator();
it.seek("st~");
Entry<String, String> val = null;
while(it.hasNext()) {
Entry<String, String> v = it.next();
if(!v.getKey().startsWith("st~")) continue;
val=v;
}
if(val==null)
maxTime = 0L;
else {
String[] token = val.getKey().split("~");
maxTime = Long.parseLong(token[2], 16)*levelDb.getTimeResolution();
}
}
return maxTime;
}
@Override
public List<IWaveform> getAllWaves() {
List<IWaveform> streams=new ArrayList<IWaveform>();
SeekingIterator<String, String> it = levelDb.iterator();
it.seek("s~");
while(it.hasNext()) {
Entry<String, String> val = it.next();
if(!val.getKey().startsWith("s~")) break;
TxStream stream = new TxStream(levelDb, db, new JSONObject(val.getValue()));
stream.setRelationTypeList(usedRelationsList);
streams.add(stream);
}
return streams;
}
@Override
public Collection<RelationType> getAllRelationTypes() {
// return Collections.emptyList();
return usedRelationsList;
}
}

View File

@ -0,0 +1,51 @@
package com.minres.scviewer.database.leveldb;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.iq80.leveldb.shaded.guava.collect.Maps.immutableEntry;
import java.util.Map.Entry;
import org.iq80.leveldb.DBIterator;
import org.iq80.leveldb.impl.SeekingIterator;
class StringDbIterator implements SeekingIterator<String, String> {
private final DBIterator iterator;
StringDbIterator(DBIterator iterator) {
this.iterator = iterator;
}
@Override
public boolean hasNext() {
return iterator.hasNext();
}
@Override
public void seekToFirst() {
iterator.seekToFirst();
}
@Override
public void seek(String targetKey) {
iterator.seek(targetKey.getBytes(UTF_8));
}
@Override
public Entry<String, String> peek() {
return adapt(iterator.peekNext());
}
@Override
public Entry<String, String> next() {
return adapt(iterator.next());
}
@Override
public void remove() {
throw new UnsupportedOperationException();
}
private Entry<String, String> adapt(Entry<byte[], byte[]> next) {
return immutableEntry(new String(next.getKey(), UTF_8), new String(next.getValue(), UTF_8));
}
}

View File

@ -0,0 +1,172 @@
/*******************************************************************************
* 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.leveldb;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.iq80.leveldb.impl.SeekingIterator;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import com.minres.scviewer.database.ITx;
import com.minres.scviewer.database.ITxAttribute;
import com.minres.scviewer.database.ITxEvent;
import com.minres.scviewer.database.ITxGenerator;
import com.minres.scviewer.database.ITxRelation;
import com.minres.scviewer.database.ITxStream;
public class Tx implements ITx {
private TxDBWrapper levelDb;
private TxStream trStream;
private TxGenerator trGenerator;
private long id;
private long start_time=0;
private long end_time=0;
private int concurency_index;
private boolean initialized=false;
private List<ITxAttribute> attributes;
private List<ITxRelation> incoming, outgoing;
public Tx(TxDBWrapper levelDb, TxStream trStream, TxGenerator trGenerator, long id) {
this.levelDb=levelDb;
this.trStream=trStream;
this.trGenerator=trGenerator;
this.id=id;
}
@Override
public Long getId() {
return id;
}
@Override
public ITxStream<ITxEvent> getStream() {
return trStream;
}
@Override
public ITxGenerator getGenerator() {
return trGenerator;
}
@Override
public int getConcurrencyIndex() {
if(!initialized) loadFromDb();
return concurency_index;
}
@Override
public Long getBeginTime() {
if(!initialized) loadFromDb();
return start_time;
}
@Override
public Long getEndTime() {
loadFromDb();
return end_time;
}
@Override
public List<ITxAttribute> getAttributes() {
if(attributes==null) {
loadFromDb();
}
return attributes;
}
@Override
public Collection<ITxRelation> getIncomingRelations() {
if(incoming==null) {
incoming = new ArrayList<ITxRelation>();
SeekingIterator<String, String> it = levelDb.iterator();
String key = "ri~"+String.format("%016x", id);
it.seek(key);
while(it.hasNext()) {
String val = it.next().getKey();
if(!val.startsWith(key)) break;;
String[] token = val.split("~");
long otherId = Long.parseLong(token[2], 16);
incoming.add(createRelation(otherId, token[3], false));
}
}
return incoming;
}
@Override
public Collection<ITxRelation> getOutgoingRelations() {
if(outgoing==null) {
outgoing = new ArrayList<ITxRelation>();
SeekingIterator<String, String> it = levelDb.iterator();
String key="ro~"+String.format("%016x", id);
it.seek(key);
while(it.hasNext()) {
String val = it.next().getKey();
if(!val.startsWith(key)) break;
String[] token = val.split("~");
long otherId = Long.parseLong(token[2], 16);
outgoing.add(createRelation(otherId, token[3], true));
}
}
return outgoing;
}
@Override
public int compareTo(ITx o) {
int res = this.getBeginTime().compareTo(o.getBeginTime());
if(res!=0)
return res;
else
return this.getId().compareTo(o.getId());
}
@Override
public String toString() {
return "tx#"+getId()+"["+getBeginTime()/1000000+"ns - "+getEndTime()/1000000+"ns]";
}
private void loadFromDb() throws JSONException {
JSONObject dbVal = new JSONObject(levelDb.get("x~"+ String.format("%016x", id)));
start_time=dbVal.getLong("START_TIME") * levelDb.getTimeResolution();
end_time=dbVal.getLong("END_TIME") * levelDb.getTimeResolution();
concurency_index=dbVal.getInt("conc");
attributes=new ArrayList<>();
JSONArray arr = dbVal.getJSONArray("attr");
arr.forEach(entry -> {
TxAttribute attr = new TxAttribute(this, (JSONObject) entry);
attributes.add(attr);
});
initialized=true;
}
private ITxRelation createRelation(long otherId, String name, boolean outgoing) {
try {
JSONObject otherTxVal = new JSONObject(levelDb.get("x~"+ String.format("%016x", otherId)));
if(otherTxVal.isEmpty()) return null;
JSONObject otherStreamVal = new JSONObject(levelDb.get("s~"+ String.format("%016x", otherTxVal.getLong("s"))));
if(otherStreamVal.isEmpty()) return null;
TxStream tgtStream = (TxStream) trStream.getDb().getStreamByName(otherStreamVal.getString("name"));
Tx that = (Tx) tgtStream.getTransactions().get(otherId);
return outgoing?
new TxRelation(trStream.getRelationType(name), this, that):
new TxRelation(trStream.getRelationType(name), that, this);
} catch (SecurityException | IllegalArgumentException | JSONException e) {
e.printStackTrace();
}
return null;
}
}

View File

@ -0,0 +1,56 @@
/*******************************************************************************
* 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.leveldb;
import org.json.JSONObject;
import com.minres.scviewer.database.AssociationType;
import com.minres.scviewer.database.DataType;
import com.minres.scviewer.database.ITxAttribute;
public class TxAttribute implements ITxAttribute{
private String name;
private DataType dataType;
private AssociationType associationType;
private Object value;
public TxAttribute(Tx trTransaction, JSONObject attribute) {
this.name=attribute.getString("name");
this.dataType=DataType.values()[attribute.getInt("type")];
this.associationType=AssociationType.values()[attribute.getInt("assoc")];
this.value=attribute.get("value");
}
@Override
public String getName() {
return name;
}
@Override
public DataType getDataType() {
return dataType;
}
@Override
public AssociationType getType() {
return associationType;
}
@Override
public Object getValue() {
return value;
}
}

View File

@ -0,0 +1,90 @@
package com.minres.scviewer.database.leveldb;
import static java.nio.charset.StandardCharsets.UTF_8;
import java.io.File;
import java.io.IOException;
import org.iq80.leveldb.Options;
import org.iq80.leveldb.Range;
import org.iq80.leveldb.ReadOptions;
import org.iq80.leveldb.Snapshot;
import org.iq80.leveldb.impl.DbImpl;
import org.iq80.leveldb.impl.SeekingIterator;
class TxDBWrapper {
private final Options options;
private final ReadOptions ro = new ReadOptions();
private final File databaseDir;
private DbImpl db;
private long timeResolution=1L;;
TxDBWrapper(Options options, File databaseDir) throws IOException {
this.options = options.verifyChecksums(true).createIfMissing(false).errorIfExists(false).cacheSize(64*1024*1024);
this.databaseDir = databaseDir;
this.db = new DbImpl(options, databaseDir);
ro.snapshot(db.getSnapshot());
}
public String get(String key) {
byte[] slice = db.get(LevelDBLoader.toByteArray(key));
if (slice == null) {
return null;
}
return new String(slice, UTF_8);
}
public String get(String key, Snapshot snapshot) {
byte[] slice = db.get(LevelDBLoader.toByteArray(key), ro);
return slice == null? null : new String(slice, UTF_8);
}
public void put(String key, String value) {
db.put(LevelDBLoader.toByteArray(key), LevelDBLoader.toByteArray(value));
}
public void delete(String key) {
db.delete(LevelDBLoader.toByteArray(key));
}
public SeekingIterator<String, String> iterator() {
return new StringDbIterator(db.iterator());
}
public Snapshot getSnapshot() {
return db.getSnapshot();
}
public void close() {
try {
ro.snapshot().close();
db.close();
} catch (IOException e) {} // ignore any error
}
public long size(String start, String limit) {
return db.getApproximateSizes(new Range(LevelDBLoader.toByteArray(start), LevelDBLoader.toByteArray(limit)));
}
public long getMaxNextLevelOverlappingBytes() {
return db.getMaxNextLevelOverlappingBytes();
}
public void reopen() throws IOException {
reopen(options);
}
public void reopen(Options options) throws IOException {
this.close();
db = new DbImpl(options.verifyChecksums(true).createIfMissing(false).errorIfExists(false), databaseDir);
ro.snapshot(db.getSnapshot());
}
public long getTimeResolution() {
return timeResolution;
}
public void setTimeResolution(long resolution) {
this.timeResolution = resolution;
}
}

View File

@ -0,0 +1,57 @@
/*******************************************************************************
* 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.leveldb;
import com.minres.scviewer.database.ITx;
import com.minres.scviewer.database.ITxEvent;
import com.minres.scviewer.database.IWaveformEvent;
public class TxEvent implements ITxEvent {
private final Type type;
private ITx tx;
public TxEvent(Type type, ITx tx) {
super();
this.type = type;
this.tx = tx;
}
@Override
public Long getTime() {
return type==Type.BEGIN?tx.getBeginTime():tx.getEndTime();
}
@Override
public IWaveformEvent duplicate() throws CloneNotSupportedException {
return new TxEvent(type, tx);
}
@Override
public int compareTo(IWaveformEvent o) {
return getTime().compareTo(o.getTime());
}
@Override
public ITx getTransaction() {
return tx;
}
@Override
public Type getType() {
return type;
}
@Override
public String toString() {
return type.toString()+"@"+getTime()+" of tx #"+tx.getId();
}
}

View File

@ -0,0 +1,56 @@
/*******************************************************************************
* 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.leveldb;
import java.util.List;
import org.json.JSONObject;
import com.minres.scviewer.database.ITx;
import com.minres.scviewer.database.ITxEvent;
import com.minres.scviewer.database.ITxGenerator;
import com.minres.scviewer.database.ITxStream;
public class TxGenerator implements ITxGenerator {
private ITxStream<ITxEvent> stream;
private long id;
private String name;
public TxGenerator(ITxStream<ITxEvent> stream, JSONObject object) {
this.stream=stream;
this.id=object.getLong("id");
this.name=object.getString("name");
}
@Override
public Long getId() {
return id;
}
@Override
public ITxStream<ITxEvent> getStream() {
return stream;
}
@Override
public String getName() {
return name;
}
@Override
public List<ITx> getTransactions() {
return null;
}
}

View File

@ -0,0 +1,43 @@
/*******************************************************************************
* 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.leveldb;
import com.minres.scviewer.database.ITxRelation;
import com.minres.scviewer.database.ITx;
import com.minres.scviewer.database.RelationType;
public class TxRelation implements ITxRelation {
RelationType relationType;
Tx source, target;
public TxRelation(RelationType relationType, Tx source, Tx target) {
this.source = source;
this.target = target;
this.relationType = relationType;
}
@Override
public RelationType getRelationType() {
return relationType;
}
@Override
public ITx getSource() {
return source;
}
@Override
public ITx getTarget() {
return target;
}
}

View File

@ -0,0 +1,178 @@
/*******************************************************************************
* 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.leveldb;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.iq80.leveldb.impl.SeekingIterator;
import org.json.JSONObject;
import java.util.NavigableMap;
import java.util.TreeMap;
import java.util.Vector;
import com.minres.scviewer.database.HierNode;
import com.minres.scviewer.database.ITx;
import com.minres.scviewer.database.ITxEvent;
import com.minres.scviewer.database.ITxGenerator;
import com.minres.scviewer.database.ITxStream;
import com.minres.scviewer.database.IWaveform;
import com.minres.scviewer.database.IWaveformDb;
import com.minres.scviewer.database.RelationType;
public class TxStream extends HierNode implements ITxStream<ITxEvent> {
private TxDBWrapper levelDb;
private String fullName;
private String kind;
private IWaveformDb db;
private long id;
private TreeMap<Long, TxGenerator> generators;
private TreeMap<Long, ITx> transactions;
private Integer maxConcurrency;
private TreeMap<Long, List<ITxEvent>> events;
private List<RelationType> usedRelationsList;
public TxStream(TxDBWrapper database, IWaveformDb waveformDb, JSONObject object) {
super(object.get("name").toString());
this.levelDb=database;
this.db=waveformDb;
this.fullName=object.getString("name");
this.kind=object.getString("kind");
this.id = object.getLong("id");
}
@Override
public IWaveformDb getDb() {
return db;
}
@Override
public String getFullName() {
return fullName;
}
@Override
public Long getId() {
return id;
}
@Override
public String getKind() {
return kind;
}
@Override
public List<ITxGenerator> getGenerators() {
if(generators==null){
generators=new TreeMap<Long, TxGenerator>();
SeekingIterator<String, String> it = levelDb.iterator();
String key="sg~"+String.format("%016x", id);
it.seek(key);
while(it.hasNext()) {
Entry<String, String> val = it.next();
if(!val.getKey().startsWith(key)) break;
JSONObject jVal = new JSONObject(val.getValue());
generators.put(jVal.getLong("id"), new TxGenerator(this, jVal));
}
}
return new ArrayList<ITxGenerator>(generators.values());
}
@Override
public int getMaxConcurrency() {
if(maxConcurrency==null){
getTransactions();
}
return maxConcurrency;
}
@Override
public NavigableMap<Long, List<ITxEvent>> getEvents(){
if(events==null){
events=new TreeMap<Long, List<ITxEvent>>();
for(Entry<Long, ITx> entry:getTransactions().entrySet()){
ITx tx = entry.getValue();
putEvent(new TxEvent(TxEvent.Type.BEGIN, tx));
putEvent(new TxEvent(TxEvent.Type.END, tx));
}
}
return events;
}
private void putEvent(TxEvent ev){
Long time = ev.getTime();
if(!events.containsKey(time)){
Vector<ITxEvent> vector=new Vector<ITxEvent>();
vector.add(ev);
events.put(time, vector);
} else {
events.get(time).add(ev);
}
}
protected Map<Long, ITx> getTransactions() {
if(transactions==null){
if(generators==null) getGenerators();
transactions = new TreeMap<Long, ITx>();
maxConcurrency=0;
SeekingIterator<String, String> it = levelDb.iterator();
String key = "sgx~"+String.format("%016x", id);
it.seek(key);
while(it.hasNext()) {
Entry<String, String> val = it.next();
if(!val.getKey().startsWith(key)) break;
String[] token = val.getKey().split("~");
long gid = Long.parseLong(token[2], 16); // gen id
long id = Long.parseLong(token[3], 16); // tx id
ITx tx = new Tx(levelDb, this, generators.get(gid), id);
transactions.put(id, tx);
maxConcurrency= Math.max(maxConcurrency, tx.getConcurrencyIndex());
}
maxConcurrency++;
}
return transactions;
}
@Override
public Collection<ITxEvent> getWaveformEventsAtTime(Long time) {
return getEvents().get(time);
}
public void setRelationTypeList(List<RelationType> usedRelationsList){
this.usedRelationsList=usedRelationsList;
}
public RelationType getRelationType(String name) {
RelationType relType=RelationType.create(name);
if(!usedRelationsList.contains(relType)) usedRelationsList.add(relType);
return relType;
}
@Override
public Boolean equals(IWaveform other) {
return(other instanceof TxStream && this.getId()==other.getId());
}
}

View File

@ -1,11 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<classpath> <classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17"> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/> <classpathentry kind="src" path="src"/>
<classpathentry exported="true" kind="lib" path="sqlite-jdbc-3.8.7.jar"/>
<classpathentry kind="output" path="target/classes"/> <classpathentry kind="output" path="target/classes"/>
</classpath> </classpath>

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.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8

View File

@ -2,10 +2,13 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2 Bundle-ManifestVersion: 2
Bundle-Name: SQLite transaction database Bundle-Name: SQLite transaction database
Bundle-SymbolicName: com.minres.scviewer.database.sqlite Bundle-SymbolicName: com.minres.scviewer.database.sqlite
Bundle-Version: 1.1.0.qualifier Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: MINRES Technologies GmbH Bundle-Vendor: MINRES Technologies GmbH
Bundle-RequiredExecutionEnvironment: JavaSE-17 Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: com.minres.scviewer.database;bundle-version="1.0.0" Require-Bundle: com.minres.scviewer.database;bundle-version="1.0.0",
org.eclipse.equinox.util;bundle-version="1.0.500",
org.eclipse.equinox.ds;bundle-version="1.4.200",
org.eclipse.osgi.services;bundle-version="3.4.0"
Bundle-ClassPath: .,sqlite-jdbc-3.8.7.jar Bundle-ClassPath: .,sqlite-jdbc-3.8.7.jar
Service-Component: OSGI-INF/component.xml Service-Component: OSGI-INF/component.xml
Bundle-ActivationPolicy: lazy Bundle-ActivationPolicy: lazy

View File

@ -1,5 +1,5 @@
############################################################################### ###############################################################################
# Copyright (c) 2014, 2015-2021 MINRES Technologies GmbH and others. # Copyright (c) 2014, 2015 MINRES Technologies GmbH and others.
# All rights reserved. This program and the accompanying materials # All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0 # are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at # which accompanies this distribution, and is available at

View File

@ -4,8 +4,8 @@
<parent> <parent>
<groupId>com.minres.scviewer</groupId> <groupId>com.minres.scviewer</groupId>
<artifactId>com.minres.scviewer.parent</artifactId> <artifactId>com.minres.scviewer.parent</artifactId>
<version>2.19.4</version> <version>2.0.0-SNAPSHOT</version>
<relativePath>../..</relativePath> <relativePath>../com.minres.scviewer.parent</relativePath>
</parent> </parent>
<packaging>eclipse-plugin</packaging> <packaging>eclipse-plugin</packaging>
<dependencies> <dependencies>
@ -15,5 +15,5 @@
<version>3.8.7</version> <version>3.8.7</version>
</dependency> </dependency>
</dependencies> </dependencies>
<version>1.1.0-SNAPSHOT</version> <version>1.0.0-SNAPSHOT</version>
</project> </project>

View File

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2015-2021 MINRES Technologies GmbH and others. * Copyright (c) 2015 MINRES Technologies GmbH and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -11,9 +11,9 @@
package com.minres.scviewer.database.sqlite; package com.minres.scviewer.database.sqlite;
import java.beans.IntrospectionException; import java.beans.IntrospectionException;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.File; import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
@ -21,8 +21,8 @@ import java.util.Collection;
import java.util.List; import java.util.List;
import com.minres.scviewer.database.IWaveform; import com.minres.scviewer.database.IWaveform;
import com.minres.scviewer.database.IWaveformDb;
import com.minres.scviewer.database.IWaveformDbLoader; import com.minres.scviewer.database.IWaveformDbLoader;
import com.minres.scviewer.database.InputFormatException;
import com.minres.scviewer.database.RelationType; import com.minres.scviewer.database.RelationType;
import com.minres.scviewer.database.sqlite.db.IDatabase; import com.minres.scviewer.database.sqlite.db.IDatabase;
import com.minres.scviewer.database.sqlite.db.SQLiteDatabase; import com.minres.scviewer.database.sqlite.db.SQLiteDatabase;
@ -37,81 +37,75 @@ public class SQLiteDbLoader implements IWaveformDbLoader {
private List<RelationType> usedRelationsList = new ArrayList<>(); private List<RelationType> usedRelationsList = new ArrayList<>();
private IWaveformDb db;
private ScvSimProps scvSimProps; private ScvSimProps scvSimProps;
/** The pcs. */ public SQLiteDbLoader() {
protected PropertyChangeSupport pcs = new PropertyChangeSupport(this); }
@Override @Override
public long getMaxTime() { public Long getMaxTime() {
SQLiteDatabaseSelectHandler<ScvTxEvent> handler = new SQLiteDatabaseSelectHandler<>(ScvTxEvent.class, SQLiteDatabaseSelectHandler<ScvTxEvent> handler = new SQLiteDatabaseSelectHandler<ScvTxEvent>(ScvTxEvent.class,
database, "time = (SELECT MAX(time) FROM ScvTxEvent)"); database, "time = (SELECT MAX(time) FROM ScvTxEvent)");
try { try {
List<ScvTxEvent> event = handler.selectObjects(); List<ScvTxEvent> event = handler.selectObjects();
if(!event.isEmpty()) if(event.size()>0)
return event.get(0).getTime()*scvSimProps.getTime_resolution(); return event.get(0).getTime()*scvSimProps.getTime_resolution();
} catch (SecurityException | IllegalArgumentException | InstantiationException | IllegalAccessException } catch (SecurityException | IllegalArgumentException | InstantiationException | IllegalAccessException
| InvocationTargetException | SQLException | IntrospectionException | NoSuchMethodException e) { | InvocationTargetException | SQLException | IntrospectionException e) {
e.printStackTrace(); e.printStackTrace();
} }
return 0L; return 0L;
} }
@Override @Override
public Collection<IWaveform> getAllWaves() { public List<IWaveform> getAllWaves() {
SQLiteDatabaseSelectHandler<ScvStream> handler = new SQLiteDatabaseSelectHandler<>(ScvStream.class, database); SQLiteDatabaseSelectHandler<ScvStream> handler = new SQLiteDatabaseSelectHandler<ScvStream>(ScvStream.class, database);
List<IWaveform> streams=new ArrayList<>(); List<IWaveform> streams=new ArrayList<IWaveform>();
try { try {
for(ScvStream scvStream:handler.selectObjects()){ for(ScvStream scvStream:handler.selectObjects()){
TxStream stream = new TxStream(database, scvStream); TxStream stream = new TxStream(database, db, scvStream);
stream.setRelationTypeList(usedRelationsList); stream.setRelationTypeList(usedRelationsList);
streams.add(stream); streams.add(stream);
} }
} catch (SecurityException | IllegalArgumentException | InstantiationException | IllegalAccessException } catch (SecurityException | IllegalArgumentException | InstantiationException | IllegalAccessException
| InvocationTargetException | SQLException | IntrospectionException | NoSuchMethodException e) { | InvocationTargetException | SQLException | IntrospectionException e) {
// e.printStackTrace();
} }
return streams; return streams;
} }
// @Override private byte[] x = "SQLite format 3".getBytes();
// public boolean canLoad(File inputFile) {
// if (!inputFile.isDirectory() && inputFile.exists()) {
// try(InputStream stream = new FileInputStream(inputFile)){
// byte[] buffer = new byte[x.length];
// int readCnt = stream.read(buffer, 0, x.length);
// if (readCnt == x.length) {
// for (int i = 0; i < x.length; i++)
// if (buffer[i] != x[i])
// return false;
// }
// return true;
// } catch (Exception e) {
// return false;
// }
// }
// return false;
// }
@Override @Override
public void load(File file) throws InputFormatException { public boolean load(IWaveformDb db, File file) throws Exception {
this.db=db;
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 false;
} catch(FileNotFoundException e) {
return false;
}
database=new SQLiteDatabase(file.getAbsolutePath()); database=new SQLiteDatabase(file.getAbsolutePath());
database.setData("TIMERESOLUTION", 1L); database.setData("TIMERESOLUTION", 1L);
SQLiteDatabaseSelectHandler<ScvSimProps> handler = new SQLiteDatabaseSelectHandler<>(ScvSimProps.class, database); SQLiteDatabaseSelectHandler<ScvSimProps> handler = new SQLiteDatabaseSelectHandler<ScvSimProps>(ScvSimProps.class, database);
try { try {
for(ScvSimProps simProps:handler.selectObjects()){ for(ScvSimProps simProps:handler.selectObjects()){
scvSimProps=simProps; scvSimProps=simProps;
database.setData("TIMERESOLUTION", scvSimProps.getTime_resolution()); database.setData("TIMERESOLUTION", scvSimProps.getTime_resolution());
} }
pcs.firePropertyChange(IWaveformDbLoader.LOADING_FINISHED, null, null); return true;
} catch (SecurityException | IllegalArgumentException | InstantiationException | IllegalAccessException } catch (SecurityException | IllegalArgumentException | InstantiationException | IllegalAccessException
| InvocationTargetException | SQLException | IntrospectionException | NoSuchMethodException e) { | InvocationTargetException | SQLException | IntrospectionException e) {
throw new InputFormatException(e.toString()); e.printStackTrace();
} }
} return false;
public void dispose() {
database=null;
usedRelationsList=null;
} }
@Override @Override
@ -119,24 +113,4 @@ public class SQLiteDbLoader implements IWaveformDbLoader {
return usedRelationsList; return usedRelationsList;
} }
/**
* Adds the property change listener.
*
* @param l the l
*/
@Override
public void addPropertyChangeListener(PropertyChangeListener l) {
pcs.addPropertyChangeListener(l);
}
/**
* Removes the property change listener.
*
* @param l the l
*/
@Override
public void removePropertyChangeListener(PropertyChangeListener l) {
pcs.removePropertyChangeListener(l);
}
} }

View File

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2015-2021 MINRES Technologies GmbH and others. * Copyright (c) 2015 MINRES Technologies GmbH and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -18,7 +18,12 @@ import java.util.Collection;
import java.util.List; import java.util.List;
import com.minres.scviewer.database.AssociationType; import com.minres.scviewer.database.AssociationType;
import com.minres.scviewer.database.IWaveform; import com.minres.scviewer.database.ITx;
import com.minres.scviewer.database.ITxAttribute;
import com.minres.scviewer.database.ITxEvent;
import com.minres.scviewer.database.ITxGenerator;
import com.minres.scviewer.database.ITxRelation;
import com.minres.scviewer.database.ITxStream;
import com.minres.scviewer.database.sqlite.db.IDatabase; import com.minres.scviewer.database.sqlite.db.IDatabase;
import com.minres.scviewer.database.sqlite.db.SQLiteDatabaseSelectHandler; import com.minres.scviewer.database.sqlite.db.SQLiteDatabaseSelectHandler;
import com.minres.scviewer.database.sqlite.tables.ScvStream; import com.minres.scviewer.database.sqlite.tables.ScvStream;
@ -26,9 +31,6 @@ import com.minres.scviewer.database.sqlite.tables.ScvTx;
import com.minres.scviewer.database.sqlite.tables.ScvTxAttribute; import com.minres.scviewer.database.sqlite.tables.ScvTxAttribute;
import com.minres.scviewer.database.sqlite.tables.ScvTxEvent; import com.minres.scviewer.database.sqlite.tables.ScvTxEvent;
import com.minres.scviewer.database.sqlite.tables.ScvTxRelation; import com.minres.scviewer.database.sqlite.tables.ScvTxRelation;
import com.minres.scviewer.database.tx.ITx;
import com.minres.scviewer.database.tx.ITxAttribute;
import com.minres.scviewer.database.tx.ITxRelation;
public class Tx implements ITx { public class Tx implements ITx {
@ -37,10 +39,8 @@ public class Tx implements ITx {
private TxGenerator trGenerator; private TxGenerator trGenerator;
private ScvTx scvTx; private ScvTx scvTx;
private List<ITxAttribute> attributes; private List<ITxAttribute> attributes;
private long begin=-1; private Long begin, end;
private long end=-1; private List<ITxRelation> incoming, outgoing;
private List<ITxRelation> incoming;
private List<ITxRelation> outgoing;
public Tx(IDatabase database, TxStream trStream, TxGenerator trGenerator, ScvTx scvTx) { public Tx(IDatabase database, TxStream trStream, TxGenerator trGenerator, ScvTx scvTx) {
this.database=database; this.database=database;
@ -50,51 +50,52 @@ public class Tx implements ITx {
} }
@Override @Override
public long getId() { public Long getId() {
return (long) scvTx.getId(); return (long) scvTx.getId();
} }
@Override @Override
public IWaveform getStream() { public ITxStream<ITxEvent> getStream() {
return trStream; return trStream;
} }
@Override @Override
public IWaveform getGenerator() { public ITxGenerator getGenerator() {
return trGenerator; return trGenerator;
} }
int getConcurrencyIndex() { @Override
public int getConcurrencyIndex() {
return scvTx.getConcurrencyLevel(); return scvTx.getConcurrencyLevel();
} }
@Override @Override
public long getBeginTime() { public Long getBeginTime() {
if(begin<0){ if(begin==null){
SQLiteDatabaseSelectHandler<ScvTxEvent> handler = new SQLiteDatabaseSelectHandler<>(ScvTxEvent.class, SQLiteDatabaseSelectHandler<ScvTxEvent> handler = new SQLiteDatabaseSelectHandler<ScvTxEvent>(ScvTxEvent.class,
database, "tx="+scvTx.getId()+" AND type="+ AssociationType.BEGIN.ordinal()); database, "tx="+scvTx.getId()+" AND type="+ AssociationType.BEGIN.ordinal());
try { try {
for(ScvTxEvent scvEvent:handler.selectObjects()){ for(ScvTxEvent scvEvent:handler.selectObjects()){
begin= scvEvent.getTime()*(Long)database.getData("TIMERESOLUTION"); begin= scvEvent.getTime()*(Long)database.getData("TIMERESOLUTION");
} }
} catch (SecurityException | IllegalArgumentException | InstantiationException | IllegalAccessException } catch (SecurityException | IllegalArgumentException | InstantiationException | IllegalAccessException
| InvocationTargetException | SQLException | IntrospectionException | NoSuchMethodException e) { | InvocationTargetException | SQLException | IntrospectionException e) {
} }
} }
return begin; return begin;
} }
@Override @Override
public long getEndTime() { public Long getEndTime() {
if(end<0){ if(end==null){
SQLiteDatabaseSelectHandler<ScvTxEvent> handler = new SQLiteDatabaseSelectHandler<>(ScvTxEvent.class, SQLiteDatabaseSelectHandler<ScvTxEvent> handler = new SQLiteDatabaseSelectHandler<ScvTxEvent>(ScvTxEvent.class,
database, "tx="+scvTx.getId()+" AND type="+ AssociationType.END.ordinal()); database, "tx="+scvTx.getId()+" AND type="+ AssociationType.END.ordinal());
try { try {
for(ScvTxEvent scvEvent:handler.selectObjects()){ for(ScvTxEvent scvEvent:handler.selectObjects()){
end = scvEvent.getTime()*(Long)database.getData("TIMERESOLUTION"); end = scvEvent.getTime()*(Long)database.getData("TIMERESOLUTION");
} }
} catch (SecurityException | IllegalArgumentException | InstantiationException | IllegalAccessException } catch (SecurityException | IllegalArgumentException | InstantiationException | IllegalAccessException
| InvocationTargetException | SQLException | IntrospectionException | NoSuchMethodException e) { | InvocationTargetException | SQLException | IntrospectionException e) {
} }
} }
return end; return end;
@ -103,16 +104,16 @@ public class Tx implements ITx {
@Override @Override
public List<ITxAttribute> getAttributes() { public List<ITxAttribute> getAttributes() {
if(attributes==null){ if(attributes==null){
SQLiteDatabaseSelectHandler<ScvTxAttribute> handler = new SQLiteDatabaseSelectHandler<>( SQLiteDatabaseSelectHandler<ScvTxAttribute> handler = new SQLiteDatabaseSelectHandler<ScvTxAttribute>(
ScvTxAttribute.class, database, "tx="+scvTx.getId()); ScvTxAttribute.class, database, "tx="+scvTx.getId());
try { try {
attributes = new ArrayList<>(); attributes = new ArrayList<ITxAttribute>();
for(ScvTxAttribute scvAttribute:handler.selectObjects()){ for(ScvTxAttribute scvAttribute:handler.selectObjects()){
attributes.add(new TxAttribute(this, scvAttribute)); attributes.add(new TxAttribute(this, scvAttribute));
} }
} catch (SecurityException | IllegalArgumentException | InstantiationException | IllegalAccessException } catch (SecurityException | IllegalArgumentException | InstantiationException | IllegalAccessException
| InvocationTargetException | SQLException | IntrospectionException | NoSuchMethodException e) { | InvocationTargetException | SQLException | IntrospectionException e) {
} }
} }
return attributes; return attributes;
@ -121,15 +122,15 @@ public class Tx implements ITx {
@Override @Override
public Collection<ITxRelation> getIncomingRelations() { public Collection<ITxRelation> getIncomingRelations() {
if(incoming==null){ if(incoming==null){
SQLiteDatabaseSelectHandler<ScvTxRelation> handler = new SQLiteDatabaseSelectHandler<>( SQLiteDatabaseSelectHandler<ScvTxRelation> handler = new SQLiteDatabaseSelectHandler<ScvTxRelation>(
ScvTxRelation.class, database, "sink="+scvTx.getId()); ScvTxRelation.class, database, "sink="+scvTx.getId());
try { try {
incoming = new ArrayList<>(); incoming = new ArrayList<ITxRelation>();
for(ScvTxRelation scvRelation:handler.selectObjects()){ for(ScvTxRelation scvRelation:handler.selectObjects()){
incoming.add(createRelation(scvRelation, false)); incoming.add(createRelation(scvRelation, false));
} }
} catch (SecurityException | IllegalArgumentException | InstantiationException | IllegalAccessException } catch (SecurityException | IllegalArgumentException | InstantiationException | IllegalAccessException
| InvocationTargetException | SQLException | IntrospectionException | NoSuchMethodException e) { | InvocationTargetException | SQLException | IntrospectionException e) {
} }
} }
return incoming; return incoming;
@ -138,15 +139,15 @@ public class Tx implements ITx {
@Override @Override
public Collection<ITxRelation> getOutgoingRelations() { public Collection<ITxRelation> getOutgoingRelations() {
if(outgoing==null){ if(outgoing==null){
SQLiteDatabaseSelectHandler<ScvTxRelation> handler = new SQLiteDatabaseSelectHandler<>( SQLiteDatabaseSelectHandler<ScvTxRelation> handler = new SQLiteDatabaseSelectHandler<ScvTxRelation>(
ScvTxRelation.class, database, "src="+scvTx.getId()); ScvTxRelation.class, database, "src="+scvTx.getId());
try { try {
outgoing = new ArrayList<>(); outgoing = new ArrayList<ITxRelation>();
for(ScvTxRelation scvRelation:handler.selectObjects()){ for(ScvTxRelation scvRelation:handler.selectObjects()){
outgoing.add(createRelation(scvRelation, true)); outgoing.add(createRelation(scvRelation, true));
} }
} catch (SecurityException | IllegalArgumentException | InstantiationException | IllegalAccessException } catch (SecurityException | IllegalArgumentException | InstantiationException | IllegalAccessException
| InvocationTargetException | SQLException | IntrospectionException | NoSuchMethodException e) { | InvocationTargetException | SQLException | IntrospectionException e) {
} }
} }
return outgoing; return outgoing;
@ -154,7 +155,7 @@ public class Tx implements ITx {
private ITxRelation createRelation(ScvTxRelation rel, boolean outgoing) { private ITxRelation createRelation(ScvTxRelation rel, boolean outgoing) {
int otherId = outgoing?rel.getSink():rel.getSrc(); int otherId = outgoing?rel.getSink():rel.getSrc();
SQLiteDatabaseSelectHandler<ScvTx> handler = new SQLiteDatabaseSelectHandler<>(ScvTx.class, database, SQLiteDatabaseSelectHandler<ScvTx> handler = new SQLiteDatabaseSelectHandler<ScvTx>(ScvTx.class, database,
"id="+otherId); "id="+otherId);
try { try {
List<ScvTx> res = handler.selectObjects(); List<ScvTx> res = handler.selectObjects();
@ -162,14 +163,14 @@ public class Tx implements ITx {
List<ScvStream> streams = new SQLiteDatabaseSelectHandler<ScvStream>(ScvStream.class, database, List<ScvStream> streams = new SQLiteDatabaseSelectHandler<ScvStream>(ScvStream.class, database,
"id="+res.get(0).getStream()).selectObjects(); "id="+res.get(0).getStream()).selectObjects();
if(streams.size()!=1) return null; if(streams.size()!=1) return null;
TxStream tgtStream = (TxStream) database.getWaveformDb().getStreamByName(streams.get(0).getName()); TxStream tgtStream = (TxStream) trStream.getDb().getStreamByName(streams.get(0).getName());
Tx that = (Tx) tgtStream.getTransactions().get(otherId); Tx that = (Tx) tgtStream.getTransactions().get(otherId);
if(outgoing) if(outgoing)
return new TxRelation(trStream.getRelationType(rel.getName()), this, that); return new TxRelation(trStream.getRelationType(rel.getName()), this, that);
else else
return new TxRelation(trStream.getRelationType(rel.getName()), that, this); return new TxRelation(trStream.getRelationType(rel.getName()), that, this);
} catch (SecurityException | IllegalArgumentException | InstantiationException | IllegalAccessException } catch (SecurityException | IllegalArgumentException | InstantiationException | IllegalAccessException
| InvocationTargetException | SQLException | IntrospectionException | NoSuchMethodException e) { | InvocationTargetException | SQLException | IntrospectionException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -178,11 +179,11 @@ public class Tx implements ITx {
@Override @Override
public int compareTo(ITx o) { public int compareTo(ITx o) {
int res = Long.compare(this.getBeginTime(), o.getBeginTime()); int res = this.getBeginTime().compareTo(o.getBeginTime());
if(res!=0) if(res!=0)
return res; return res;
else else
return Long.compare(this.getId(), o.getId()); return this.getId().compareTo(o.getId());
} }
@Override @Override

View File

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2015-2021 MINRES Technologies GmbH and others. * Copyright (c) 2015 MINRES Technologies GmbH and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -12,8 +12,8 @@ package com.minres.scviewer.database.sqlite;
import com.minres.scviewer.database.AssociationType; import com.minres.scviewer.database.AssociationType;
import com.minres.scviewer.database.DataType; import com.minres.scviewer.database.DataType;
import com.minres.scviewer.database.ITxAttribute;
import com.minres.scviewer.database.sqlite.tables.ScvTxAttribute; import com.minres.scviewer.database.sqlite.tables.ScvTxAttribute;
import com.minres.scviewer.database.tx.ITxAttribute;
public class TxAttribute implements ITxAttribute{ public class TxAttribute implements ITxAttribute{
@ -32,18 +32,7 @@ public class TxAttribute implements ITxAttribute{
@Override @Override
public DataType getDataType() { public DataType getDataType() {
int dt = scvAttribute.getData_type(); return DataType.values()[scvAttribute.getData_type()];
switch(dt) {
case 12:
return DataType.STRING;
case 10:
return DataType.POINTER;
default:
if(dt<9)
return DataType.values()[dt];
else
return DataType.NONE;
}
} }
@Override @Override

View File

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2015-2021 MINRES Technologies GmbH and others. * Copyright (c) 2015 MINRES Technologies GmbH and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -10,40 +10,43 @@
*******************************************************************************/ *******************************************************************************/
package com.minres.scviewer.database.sqlite; package com.minres.scviewer.database.sqlite;
import com.minres.scviewer.database.EventKind; import com.minres.scviewer.database.ITx;
import com.minres.scviewer.database.IEvent; import com.minres.scviewer.database.ITxEvent;
import com.minres.scviewer.database.WaveformType; import com.minres.scviewer.database.IWaveformEvent;
import com.minres.scviewer.database.tx.ITx;
import com.minres.scviewer.database.tx.ITxEvent;
public class TxEvent implements ITxEvent { public class TxEvent implements ITxEvent {
private final EventKind type; private final Type type;
private ITx tx; private ITx tx;
public TxEvent(EventKind type, ITx tx) { public TxEvent(Type type, ITx tx) {
super(); super();
this.type = type; this.type = type;
this.tx = tx; this.tx = tx;
} }
@Override @Override
public long getTime() { public Long getTime() {
return type==EventKind.BEGIN?tx.getBeginTime():tx.getEndTime(); return type==Type.BEGIN?tx.getBeginTime():tx.getEndTime();
} }
@Override @Override
public IEvent duplicate() throws CloneNotSupportedException { public IWaveformEvent duplicate() throws CloneNotSupportedException {
return new TxEvent(type, tx); return new TxEvent(type, tx);
} }
@Override
public int compareTo(IWaveformEvent o) {
return getTime().compareTo(o.getTime());
}
@Override @Override
public ITx getTransaction() { public ITx getTransaction() {
return tx; return tx;
} }
@Override @Override
public EventKind getKind() { public Type getType() {
return type; return type;
} }
@ -51,15 +54,4 @@ public class TxEvent implements ITxEvent {
public String toString() { public String toString() {
return type.toString()+"@"+getTime()+" of tx #"+tx.getId(); return type.toString()+"@"+getTime()+" of tx #"+tx.getId();
} }
@Override
public WaveformType getType() {
return WaveformType.TRANSACTION;
}
@Override
public int getRowIndex() {
return ((Tx)tx).getConcurrencyIndex();
}
} }

View File

@ -0,0 +1,52 @@
/*******************************************************************************
* 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.sqlite;
import java.util.List;
import com.minres.scviewer.database.ITx;
import com.minres.scviewer.database.ITxEvent;
import com.minres.scviewer.database.ITxGenerator;
import com.minres.scviewer.database.ITxStream;
import com.minres.scviewer.database.sqlite.tables.ScvGenerator;
public class TxGenerator implements ITxGenerator {
private ITxStream<ITxEvent> stream;
private ScvGenerator scvGenerator;
public TxGenerator(ITxStream<ITxEvent> stream, ScvGenerator scvGenerator) {
this.stream=stream;
this.scvGenerator=scvGenerator;
}
@Override
public Long getId() {
return (long) scvGenerator.getId();
}
@Override
public ITxStream<ITxEvent> getStream() {
return stream;
}
@Override
public String getName() {
return scvGenerator.getName();
}
@Override
public List<ITx> getTransactions() {
return null;
}
}

View File

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2015-2021 MINRES Technologies GmbH and others. * Copyright (c) 2015 MINRES Technologies GmbH and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -10,15 +10,14 @@
*******************************************************************************/ *******************************************************************************/
package com.minres.scviewer.database.sqlite; package com.minres.scviewer.database.sqlite;
import com.minres.scviewer.database.ITxRelation;
import com.minres.scviewer.database.ITx;
import com.minres.scviewer.database.RelationType; import com.minres.scviewer.database.RelationType;
import com.minres.scviewer.database.tx.ITx;
import com.minres.scviewer.database.tx.ITxRelation;
public class TxRelation implements ITxRelation { public class TxRelation implements ITxRelation {
RelationType relationType; RelationType relationType;
Tx source; Tx source, target;
Tx target;
public TxRelation(RelationType relationType, Tx source, Tx target) { public TxRelation(RelationType relationType, Tx source, Tx target) {
this.source = source; this.source = source;

View File

@ -0,0 +1,199 @@
/*******************************************************************************
* 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.sqlite;
import java.beans.IntrospectionException;
import java.lang.reflect.InvocationTargetException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.NavigableMap;
import java.util.TreeMap;
import java.util.Vector;
import com.minres.scviewer.database.HierNode;
import com.minres.scviewer.database.ITx;
import com.minres.scviewer.database.ITxEvent;
import com.minres.scviewer.database.ITxGenerator;
import com.minres.scviewer.database.ITxStream;
import com.minres.scviewer.database.IWaveform;
import com.minres.scviewer.database.IWaveformDb;
import com.minres.scviewer.database.RelationType;
import com.minres.scviewer.database.sqlite.db.IDatabase;
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 TxStream extends HierNode implements ITxStream<ITxEvent> {
private IDatabase database;
private String fullName;
private IWaveformDb db;
private ScvStream scvStream;
private TreeMap<Integer, TxGenerator> generators;
private TreeMap<Integer, ITx> transactions;
private Integer maxConcurrency;
private TreeMap<Long, List<ITxEvent>> events;
private List<RelationType> usedRelationsList;
public TxStream(IDatabase database, IWaveformDb waveformDb, ScvStream scvStream) {
super(scvStream.getName());
this.database=database;
fullName=scvStream.getName();
this.scvStream=scvStream;
db=waveformDb;
}
@Override
public IWaveformDb getDb() {
return db;
}
@Override
public String getFullName() {
return fullName;
}
@Override
public Long getId() {
return (long) scvStream.getId();
}
@Override
public String getKind() {
return scvStream.getKind();
}
@Override
public List<ITxGenerator> getGenerators() {
if(generators==null){
SQLiteDatabaseSelectHandler<ScvGenerator> handler = new SQLiteDatabaseSelectHandler<ScvGenerator>(
ScvGenerator.class, database, "stream="+scvStream.getId());
generators=new TreeMap<Integer, TxGenerator>();
try {
for(ScvGenerator scvGenerator:handler.selectObjects()){
generators.put(scvGenerator.getId(), new TxGenerator(this, scvGenerator));
}
} catch (SecurityException | IllegalArgumentException | InstantiationException | IllegalAccessException
| InvocationTargetException | SQLException | IntrospectionException e) {
e.printStackTrace();
}
}
return new ArrayList<ITxGenerator>(generators.values());
}
@Override
public int getMaxConcurrency() {
if(maxConcurrency==null){
java.sql.Connection connection=null;
java.sql.Statement statement=null;
java.sql.ResultSet resultSet=null;
try {
connection = database.createConnection();
statement = connection.createStatement();
StringBuilder sb = new StringBuilder();
sb.append("SELECT MAX(concurrencyLevel) as concurrencyLevel FROM ScvTx where stream=");
sb.append(scvStream.getId());
resultSet = statement.executeQuery(sb.toString());
while (resultSet.next()) {
if(maxConcurrency==null) maxConcurrency=0;
Object value = resultSet.getObject("concurrencyLevel");
if(value!=null)
maxConcurrency=(Integer) value;
}
} catch (SQLException e) {
if(maxConcurrency==null) maxConcurrency=0;
} finally {
try{
if(resultSet!=null) resultSet.close();
if(statement!=null) statement.close();
if(connection!=null) connection.close();
} catch (SQLException e) { }
}
maxConcurrency+=1;
}
return maxConcurrency;
}
@Override
public NavigableMap<Long, List<ITxEvent>> getEvents(){
if(events==null){
events=new TreeMap<Long, List<ITxEvent>>();
for(Entry<Integer, ITx> entry:getTransactions().entrySet()){
putEvent(new TxEvent(TxEvent.Type.BEGIN, entry.getValue()));
putEvent(new TxEvent(TxEvent.Type.END, entry.getValue()));
}
}
return events;
}
private void putEvent(TxEvent ev){
Long time = ev.getTime();
if(!events.containsKey(time)){
Vector<ITxEvent> vector=new Vector<ITxEvent>();
vector.add(ev);
events.put(time, vector);
} else {
events.get(time).add(ev);
}
}
protected Map<Integer, ITx> getTransactions() {
if(transactions==null){
if(generators==null) getGenerators();
transactions = new TreeMap<Integer, ITx>();
SQLiteDatabaseSelectHandler<ScvTx> handler = new SQLiteDatabaseSelectHandler<ScvTx>(ScvTx.class, database,
"stream="+scvStream.getId());
try {
for(ScvTx scvTx:handler.selectObjects()){
transactions.put(scvTx.getId(), new Tx(database, this, generators.get(scvTx.getGenerator()), scvTx));
}
} catch (SecurityException | IllegalArgumentException | InstantiationException | IllegalAccessException
| InvocationTargetException | SQLException | IntrospectionException e) {
e.printStackTrace();
}
}
return transactions;
}
@Override
public Collection<ITxEvent> getWaveformEventsAtTime(Long time) {
return getEvents().get(time);
}
public void setRelationTypeList(List<RelationType> usedRelationsList){
this.usedRelationsList=usedRelationsList;
}
public RelationType getRelationType(String name) {
RelationType relType=RelationType.create(name);
if(!usedRelationsList.contains(relType)) usedRelationsList.add(relType);
return relType;
}
@Override
public Boolean equals(IWaveform other) {
return(other instanceof TxStream && this.getId()==other.getId());
}
}

View File

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2015-2021 MINRES Technologies GmbH and others. * Copyright (c) 2015 MINRES Technologies GmbH and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at

View File

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2015-2021 MINRES Technologies GmbH and others. * Copyright (c) 2015 MINRES Technologies GmbH and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -16,8 +16,6 @@ import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Statement; import java.sql.Statement;
import com.minres.scviewer.database.IWaveformDb;
/** /**
* *
* Creates a connection to a database. * Creates a connection to a database.
@ -60,6 +58,4 @@ public interface IDatabase {
public void setData(String name, Object value); public void setData(String name, Object value);
public Object getData(String name); public Object getData(String name);
public IWaveformDb getWaveformDb();
} }

View File

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2015-2021 MINRES Technologies GmbH and others. * Copyright (c) 2015 MINRES Technologies GmbH and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -20,8 +20,6 @@ import java.sql.SQLException;
import java.sql.Statement; import java.sql.Statement;
import java.util.HashMap; import java.util.HashMap;
import com.minres.scviewer.database.IWaveformDb;
public class SQLiteDatabase implements IDatabase { public class SQLiteDatabase implements IDatabase {
protected String dbFileName; protected String dbFileName;
@ -91,9 +89,4 @@ public class SQLiteDatabase implements IDatabase {
return props.get(name); return props.get(name);
} }
@Override
public IWaveformDb getWaveformDb() {
return null;
}
} }

View File

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2015-2021 MINRES Technologies GmbH and others. * Copyright (c) 2015 MINRES Technologies GmbH and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at

View File

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2015-2021 MINRES Technologies GmbH and others. * Copyright (c) 2015 MINRES Technologies GmbH and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -75,11 +75,11 @@ public class SQLiteDatabaseSelectHandler<T> extends AbstractDatabaseHandler<T> {
* @throws IllegalAccessException * @throws IllegalAccessException
* @throws IntrospectionException * @throws IntrospectionException
* @throws InvocationTargetException * @throws InvocationTargetException
* @throws NoSuchMethodException
*/ */
public synchronized List<T> selectObjects() throws SQLException, public synchronized List<T> selectObjects() throws SQLException,
SecurityException, IllegalArgumentException,
InstantiationException, IllegalAccessException, InstantiationException, IllegalAccessException,
IntrospectionException, InvocationTargetException, IllegalArgumentException, NoSuchMethodException, SecurityException { IntrospectionException, InvocationTargetException {
Connection connection = null; Connection connection = null;
Statement statement = null; Statement statement = null;
@ -114,18 +114,18 @@ public class SQLiteDatabaseSelectHandler<T> extends AbstractDatabaseHandler<T> {
* @throws IllegalAccessException * @throws IllegalAccessException
* @throws IntrospectionException * @throws IntrospectionException
* @throws InvocationTargetException * @throws InvocationTargetException
* @throws NoSuchMethodException
*/ */
private List<T> createObjects(ResultSet resultSet) private List<T> createObjects(ResultSet resultSet)
throws SQLException, InstantiationException, throws SecurityException, IllegalArgumentException,
SQLException, InstantiationException,
IllegalAccessException, IntrospectionException, IllegalAccessException, IntrospectionException,
InvocationTargetException, IllegalArgumentException, NoSuchMethodException, SecurityException { InvocationTargetException {
List<T> list = new ArrayList<>(); List<T> list = new ArrayList<T>();
while (resultSet.next()) { while (resultSet.next()) {
T instance = type.getDeclaredConstructor().newInstance(); T instance = type.newInstance();
for (Field field : type.getDeclaredFields()) { for (Field field : type.getDeclaredFields()) {

View File

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2015-2021 MINRES Technologies GmbH and others. * Copyright (c) 2015 MINRES Technologies GmbH and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at

View File

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2015-2021 MINRES Technologies GmbH and others. * Copyright (c) 2015 MINRES Technologies GmbH and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at

View File

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2015-2021 MINRES Technologies GmbH and others. * Copyright (c) 2015 MINRES Technologies GmbH and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at

View File

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2015-2021 MINRES Technologies GmbH and others. * Copyright (c) 2015 MINRES Technologies GmbH and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at

View File

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2015-2021 MINRES Technologies GmbH and others. * Copyright (c) 2015 MINRES Technologies GmbH and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at

View File

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2015-2021 MINRES Technologies GmbH and others. * Copyright (c) 2015 MINRES Technologies GmbH and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at

View File

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2015-2021 MINRES Technologies GmbH and others. * Copyright (c) 2015 MINRES Technologies GmbH and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at

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.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>

View File

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

View File

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

View File

@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.pde.ui.JunitLaunchConfig">
<booleanAttribute key="append.args" value="true"/>
<stringAttribute key="application" value="org.eclipse.pde.junit.runtime.coretestapplication"/>
<booleanAttribute key="askclear" value="false"/>
<booleanAttribute key="automaticAdd" value="true"/>
<booleanAttribute key="automaticValidate" value="false"/>
<stringAttribute key="bootstrap" value=""/>
<stringAttribute key="checked" value="[NONE]"/>
<booleanAttribute key="clearConfig" value="true"/>
<booleanAttribute key="clearws" value="true"/>
<booleanAttribute key="clearwslog" value="false"/>
<stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/pde-junit"/>
<booleanAttribute key="default" value="true"/>
<stringAttribute key="deselected_workspace_plugins" value="com.minres.scviewer.e4.application,com.minres.scviewer.ui"/>
<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"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/>
</listAttribute>
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value="=com.minres.scviewer.database.test"/>
<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.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"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms40m -Xmx512m"/>
<stringAttribute key="pde.version" value="3.3"/>
<stringAttribute key="product" value="com.minres.scviewer.e4.product"/>
<booleanAttribute key="run_in_ui_thread" value="true"/>
<stringAttribute key="selected_target_plugins" value="com.google.guava@default:default,javax.annotation@default:default,javax.inject@default:default,javax.servlet@default:default,org.apache.ant@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.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.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.di@default:default,org.eclipse.e4.ui.model.workbench@default:default,org.eclipse.e4.ui.services@default:default,org.eclipse.emf.common@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.preferences@default:default,org.eclipse.equinox.registry@default:default,org.eclipse.equinox.util@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"/>
<stringAttribute key="selected_workspace_plugins" value="com.minres.scviewer.database.sqlite@default:true,com.minres.scviewer.database.test@default:default,com.minres.scviewer.database.text@default:true,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:true,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="false"/>
<booleanAttribute key="useProduct" value="false"/>
</launchConfiguration>

View File

@ -2,14 +2,14 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2 Bundle-ManifestVersion: 2
Bundle-Name: SCViewer database tests Bundle-Name: SCViewer database tests
Bundle-SymbolicName: com.minres.scviewer.database.test Bundle-SymbolicName: com.minres.scviewer.database.test
Bundle-Version: 4.0.0.qualifier Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: MINRES Technologies GmbH Bundle-Vendor: MINRES Technologies GnbH
Bundle-RequiredExecutionEnvironment: JavaSE-17 Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: com.minres.scviewer.database, Require-Bundle: org.junit,
com.minres.scviewer.database,
com.minres.scviewer.database.sqlite;bundle-version="1.0.0", com.minres.scviewer.database.sqlite;bundle-version="1.0.0",
com.minres.scviewer.database.text;bundle-version="1.0.0", com.minres.scviewer.database.text;bundle-version="1.0.0",
com.minres.scviewer.database.vcd;bundle-version="1.0.0", com.minres.scviewer.database.vcd;bundle-version="1.0.0"
org.junit
Bundle-ActivationPolicy: lazy Bundle-ActivationPolicy: lazy
Service-Component: OSGI-INF/component.xml Service-Component: OSGI-INF/component.xml
Automatic-Module-Name: com.minres.scviewer.database.test Automatic-Module-Name: com.minres.scviewer.database.test

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?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"> <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.TestWaveformDbFactory"/> <implementation class="com.minres.scviewer.database.test.DatabaseServicesTest"/>
<reference bind="setFactory" cardinality="1..1" interface="com.minres.scviewer.database.IWaveformDbFactory" name="IWaveformDbFactory" policy="static" unbind="unsetFactory"/> <reference bind="setFactory" cardinality="1..1" interface="com.minres.scviewer.database.IWaveformDbFactory" name="IWaveformDbFactory" policy="static" unbind="unsetFactory"/>
</scr:component> </scr:component>

View File

@ -0,0 +1,2 @@
/.scviewer.*
/.my_db.txlog*

View File

@ -235,4 +235,20 @@ tx_end 45 5 3380 ns
a 37 a 37
tx_begin 51 5 3380 ns tx_begin 51 5 3380 ns
a 58 a 58
tx_record_attribute 51 "data_ 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

View File

@ -0,0 +1 @@
MANIFEST-000045

View File

@ -0,0 +1 @@
2018/11/03-15:38:59.715484 139851522529088Delete type=3 #1

File diff suppressed because it is too large Load Diff

View File

@ -2,12 +2,11 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>com.minres.scviewer.database.test</artifactId> <artifactId>com.minres.scviewer.database.test</artifactId>
<version>4.0.0-SNAPSHOT</version>
<parent> <parent>
<groupId>com.minres.scviewer</groupId> <groupId>com.minres.scviewer</groupId>
<artifactId>com.minres.scviewer.parent</artifactId> <artifactId>com.minres.scviewer.parent</artifactId>
<version>2.19.4</version> <version>2.0.0-SNAPSHOT</version>
<relativePath>../..</relativePath> <relativePath>../com.minres.scviewer.parent</relativePath>
</parent> </parent>
<packaging>eclipse-test-plugin</packaging> <packaging>eclipse-test-plugin</packaging>
<build> <build>
@ -15,8 +14,18 @@
<plugin> <plugin>
<groupId>org.eclipse.tycho</groupId> <groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-surefire-plugin</artifactId> <artifactId>tycho-surefire-plugin</artifactId>
<version>${tycho-version}</version> <version>0.23.1</version>
<configuration>
<!-- <bundleStartLevel /> -->
<dependencies>
<dependency>
<type>p2-installable-unit</type>
<artifactId>org.eclipse.equinox.ds</artifactId>
</dependency>
</dependencies>
</configuration>
</plugin> </plugin>
</plugins> </plugins>
</build> </build>
<version>1.0.0-SNAPSHOT</version>
</project> </project>

View File

@ -0,0 +1,147 @@
/*******************************************************************************
* 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 java.util.List;
import java.util.Map.Entry;
import java.util.NavigableMap;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import com.minres.scviewer.database.AssociationType;
import com.minres.scviewer.database.DataType;
import com.minres.scviewer.database.ISignal;
import com.minres.scviewer.database.ITx;
import com.minres.scviewer.database.ITxAttribute;
import com.minres.scviewer.database.ITxEvent;
import com.minres.scviewer.database.ITxEvent.Type;
import com.minres.scviewer.database.ITxStream;
import com.minres.scviewer.database.IWaveform;
import com.minres.scviewer.database.IWaveformDb;
import com.minres.scviewer.database.IWaveformDbFactory;
public class DatabaseServicesTest {
private static IWaveformDbFactory waveformDbFactory;
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();
}
@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);
List<IWaveform> waves= waveformDb.getAllWaves();
assertEquals(14, waves.size());
assertEquals(2, waveformDb.getChildNodes().size());
IWaveform bus_data_wave = waves.get(0);
ISignal<?> bus_data_sig = (ISignal<?>) bus_data_wave;
Entry<Long, ?> bus_data_entry = bus_data_sig.getEvents().floorEntry(1400000000L);
assertTrue("01111000".equals(bus_data_entry.getValue().toString()));
IWaveform rw_wave = waves.get(2);
ISignal<?> rw_sig = (ISignal<?>) rw_wave;
Entry<Long, ?> rw_entry = rw_sig.getEvents().floorEntry(2360000000L);
assertTrue("1".equals(rw_entry.getValue().toString()));
}
@Test
public void testTxSQLite() throws Exception {
File f = new File("inputs/my_sqldb.txdb").getAbsoluteFile();
assertTrue(f.exists());
waveformDb.load(f);
assertNotNull(waveformDb);
assertEquals(3, waveformDb.getAllWaves().size());
assertEquals(1, waveformDb.getChildNodes().size());
}
@Test
public void testTxText() throws Exception {
File f = new File("inputs/my_db.txlog").getAbsoluteFile();
assertTrue(f.exists());
waveformDb.load(f);
assertNotNull(waveformDb);
assertEquals(3, waveformDb.getAllWaves().size());
assertEquals(1, waveformDb.getChildNodes().size());
}
//@Test
public void testTxLDb() throws Exception {
File f = new File("inputs/my_ldb.txldb").getAbsoluteFile();
assertTrue(f.exists());
waveformDb.load(f);
assertNotNull(waveformDb);
assertEquals(1, waveformDb.getChildNodes().size());
List<IWaveform> waves = waveformDb.getAllWaves();
assertEquals(3, waves.size());
IWaveform wave = waves.get(0);
assertTrue(wave instanceof ITxStream<?>);
ITxStream<?> stream = (ITxStream<?>) wave;
assertEquals(2, stream.getGenerators().size());
NavigableMap<Long, List<ITxEvent>> eventsList = stream.getEvents();
assertEquals(27, eventsList.size());
Entry<Long, List<ITxEvent>> eventEntry = eventsList.firstEntry();
assertEquals(100000000L, (long) eventEntry.getKey());
List<ITxEvent> events = eventEntry.getValue();
assertEquals(1, events.size());
ITxEvent event = events.get(0);
assertEquals(Type.BEGIN, event.getType());
ITx tx = event.getTransaction();
assertEquals(3L, (long) tx.getId());
List<ITxAttribute> attrs = tx.getAttributes();
assertEquals(1, attrs.size());
ITxAttribute attr = attrs.get(0);
assertEquals("data", attr.getName());
assertEquals(DataType.UNSIGNED, attr.getDataType());
assertEquals(AssociationType.END, attr.getType());
assertTrue(attr.getValue() instanceof Integer);
assertEquals(0, (int) attr.getValue());
}
@Test
public void testHierarchicalVCD() throws Exception {
File f = new File("inputs/simple_system.vcd").getAbsoluteFile();
assertTrue(f.exists());
waveformDb.load(f);
assertNotNull(waveformDb);
assertEquals(779, waveformDb.getAllWaves().size());
assertEquals(1, waveformDb.getChildNodes().size());
}
}

View File

@ -1,29 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<classpath> <classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"> <classpathentry exported="true" kind="lib" path="lib/elsa-3.0.0-M5.jar"/>
<attributes> <classpathentry exported="true" kind="lib" path="lib/eclipse-collections-9.2.0.jar"/>
<attribute name="maven.pomderived" value="true"/> <classpathentry exported="true" kind="lib" path="lib/eclipse-collections-api-9.2.0.jar"/>
</attributes> <classpathentry exported="true" kind="lib" path="lib/eclipse-collections-forkjoin-9.2.0.jar"/>
</classpathentry> <classpathentry exported="true" kind="lib" path="lib/kotlin-stdlib-1.2.42.jar"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry exported="true" kind="lib" path="lib/lz4-1.3.0.jar"/>
<classpathentry kind="src" output="target/classes" path="src">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry exported="true" kind="lib" path="lib/mapdb-3.0.7.jar" sourcepath="lib/mapdb-3.0.7-sources.jar"> <classpathentry exported="true" kind="lib" path="lib/mapdb-3.0.7.jar" sourcepath="lib/mapdb-3.0.7-sources.jar">
<attributes> <attributes>
<attribute name="javadoc_location" value="jar:platform:/resource/com.minres.scviewer.database.text/lib/mapdb-3.0.7-javadoc.jar!/"/> <attribute name="javadoc_location" value="jar:platform:/resource/com.minres.scviewer.database.text/lib/mapdb-3.0.7-javadoc.jar!/"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry exported="true" kind="lib" path="lib/kotlin-stdlib-1.2.42.jar"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry exported="true" kind="lib" path="lib/lz4-1.3.0.jar"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry exported="true" kind="lib" path="lib/elsa-3.0.0-M5.jar"/> <classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> <classpathentry exported="true" kind="con" path="GROOVY_DSL_SUPPORT"/>
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/> <classpathentry kind="output" path="target/classes"/>
</classpath> </classpath>

View File

@ -33,6 +33,7 @@
</buildSpec> </buildSpec>
<natures> <natures>
<nature>org.eclipse.m2e.core.maven2Nature</nature> <nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.jdt.groovy.core.groovyNature</nature>
<nature>org.eclipse.pde.PluginNature</nature> <nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature> <nature>org.eclipse.jdt.core.javanature</nature>
</natures> </natures>

View File

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

View File

@ -1,2 +1,2 @@
eclipse.preferences.version=1 eclipse.preferences.version=1
encoding/<project>=UTF-8 groovy.compiler.level=26

View File

@ -0,0 +1,25 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Textual transaction database
Bundle-SymbolicName: com.minres.scviewer.database.text
Bundle-Version: 2.0.0.qualifier
Bundle-Vendor: MINRES Technologies GmbH
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Import-Package: org.osgi.framework;version="1.3.0"
Require-Bundle: com.minres.scviewer.database;bundle-version="1.0.0",
org.codehaus.groovy;bundle-version="1.8.6",
org.eclipse.equinox.util;bundle-version="1.0.500",
org.eclipse.equinox.ds;bundle-version="1.4.200",
org.eclipse.osgi.services;bundle-version="3.4.0",
com.google.guava;bundle-version="15.0.0"
Service-Component: OSGI-INF/component.xml
Bundle-ActivationPolicy: lazy
Automatic-Module-Name: com.minres.scviewer.database.text
Bundle-ClassPath: lib/mapdb-3.0.7.jar,
.,
lib/eclipse-collections-9.2.0.jar,
lib/eclipse-collections-api-9.2.0.jar,
lib/eclipse-collections-forkjoin-9.2.0.jar,
lib/kotlin-stdlib-1.2.42.jar,
lib/lz4-1.3.0.jar,
lib/elsa-3.0.0-M5.jar

View File

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

View File

@ -1,5 +1,5 @@
############################################################################### ###############################################################################
# Copyright (c) 2014, 2015-2021 MINRES Technologies GmbH and others. # Copyright (c) 2014, 2015 MINRES Technologies GmbH and others.
# All rights reserved. This program and the accompanying materials # All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0 # are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at # which accompanies this distribution, and is available at
@ -13,6 +13,9 @@ bin.includes = META-INF/,\
OSGI-INF/,\ OSGI-INF/,\
lib/,\ lib/,\
lib/mapdb-3.0.7.jar,\ lib/mapdb-3.0.7.jar,\
lib/eclipse-collections-9.2.0.jar,\
lib/eclipse-collections-api-9.2.0.jar,\
lib/eclipse-collections-forkjoin-9.2.0.jar,\
lib/kotlin-stdlib-1.2.42.jar,\ lib/kotlin-stdlib-1.2.42.jar,\
lib/lz4-1.3.0.jar,\ lib/lz4-1.3.0.jar,\
lib/elsa-3.0.0-M5.jar lib/elsa-3.0.0-M5.jar

Some files were not shown because too many files have changed in this diff Show More