[WIP ]reorganized dir structure
This commit is contained in:
7
plugins/com.minres.scviewer.database/.classpath
Normal file
7
plugins/com.minres.scviewer.database/.classpath
Normal 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>
|
2
plugins/com.minres.scviewer.database/.gitignore
vendored
Normal file
2
plugins/com.minres.scviewer.database/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
/bin
|
||||
/target/
|
39
plugins/com.minres.scviewer.database/.project
Normal file
39
plugins/com.minres.scviewer.database/.project
Normal file
@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>com.minres.scviewer.database</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.ManifestBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.SchemaBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.ds.core.builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
<nature>org.eclipse.pde.PluginNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
@ -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
|
@ -0,0 +1,4 @@
|
||||
activeProfiles=
|
||||
eclipse.preferences.version=1
|
||||
resolveWorkspaceProjects=true
|
||||
version=1
|
12
plugins/com.minres.scviewer.database/META-INF/MANIFEST.MF
Normal file
12
plugins/com.minres.scviewer.database/META-INF/MANIFEST.MF
Normal file
@ -0,0 +1,12 @@
|
||||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: Waveform database
|
||||
Bundle-SymbolicName: com.minres.scviewer.database
|
||||
Bundle-Version: 1.0.0.qualifier
|
||||
Bundle-Vendor: MINRES Technologies GmbH
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
|
||||
Export-Package: com.minres.scviewer.database,
|
||||
com.minres.scviewer.database.internal;x-internal:=true
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Service-Component: OSGI-INF/component.xml,OSGI-INF/component2.xml
|
||||
Automatic-Module-Name: com.minres.scviewer.database
|
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="com.minres.scviewer.database.loader">
|
||||
<implementation class="com.minres.scviewer.database.internal.WaveformDb"/>
|
||||
<reference bind="bind" cardinality="1..n" interface="com.minres.scviewer.database.IWaveformDbLoader" name="IWaveformDbLoader" policy="dynamic" unbind="unbind"/>
|
||||
</scr:component>
|
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="com.minres.scviewer.database">
|
||||
<implementation class="com.minres.scviewer.database.internal.WaveformDbFactory"/>
|
||||
<service>
|
||||
<provide interface="com.minres.scviewer.database.IWaveformDbFactory"/>
|
||||
</service>
|
||||
</scr:component>
|
14
plugins/com.minres.scviewer.database/build.properties
Normal file
14
plugins/com.minres.scviewer.database/build.properties
Normal file
@ -0,0 +1,14 @@
|
||||
###############################################################################
|
||||
# Copyright (c) 2014, 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
|
||||
###############################################################################
|
||||
bin.includes = META-INF/,\
|
||||
.,\
|
||||
OSGI-INF/
|
||||
source.. = src/
|
12
plugins/com.minres.scviewer.database/pom.xml
Normal file
12
plugins/com.minres.scviewer.database/pom.xml
Normal file
@ -0,0 +1,12 @@
|
||||
<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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>com.minres.scviewer.database</artifactId>
|
||||
<parent>
|
||||
<groupId>com.minres.scviewer</groupId>
|
||||
<artifactId>com.minres.scviewer.parent</artifactId>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</project>
|
@ -0,0 +1,15 @@
|
||||
/*******************************************************************************
|
||||
* 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;
|
||||
|
||||
public enum AssociationType {
|
||||
BEGIN, RECORD, END
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
package com.minres.scviewer.database;
|
||||
public enum BitValue {
|
||||
ZERO,
|
||||
ONE,
|
||||
X,
|
||||
Z;
|
||||
|
||||
private static final BitValue[] ORDINAL_TABLE = BitValue.values();
|
||||
|
||||
public static BitValue fromChar(char c) {
|
||||
switch (c) {
|
||||
case '0':
|
||||
return ZERO;
|
||||
case '1':
|
||||
return ONE;
|
||||
case 'x':
|
||||
case 'X':
|
||||
return X;
|
||||
case 'z':
|
||||
case 'Z':
|
||||
return Z;
|
||||
default:
|
||||
throw new NumberFormatException("unknown digit " + c);
|
||||
}
|
||||
}
|
||||
|
||||
public char toChar() {
|
||||
switch (this) {
|
||||
case ZERO:
|
||||
return '0';
|
||||
case ONE:
|
||||
return '1';
|
||||
case X:
|
||||
return 'x';
|
||||
case Z:
|
||||
return 'z';
|
||||
}
|
||||
|
||||
return ' '; // Unreachable?
|
||||
}
|
||||
|
||||
public static BitValue fromInt(int i) {
|
||||
if (i == 0) {
|
||||
return ZERO;
|
||||
} else {
|
||||
return ONE;
|
||||
}
|
||||
}
|
||||
|
||||
public int toInt() {
|
||||
return (this == ONE) ? 1 : 0;
|
||||
}
|
||||
|
||||
public static BitValue fromOrdinal(int ord) {
|
||||
return ORDINAL_TABLE[ord];
|
||||
}
|
||||
|
||||
public int compare(BitValue other) {
|
||||
if (this == ONE && other == ZERO) {
|
||||
return 1;
|
||||
} else if (this == ZERO && other == ONE) {
|
||||
return -1;
|
||||
} else {
|
||||
// Either these are equal, or there is an X and Z, which match everything.
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,170 @@
|
||||
/*******************************************************************************
|
||||
* 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;
|
||||
|
||||
public class BitVector {
|
||||
|
||||
private final int width;
|
||||
|
||||
private int[] packedValues;
|
||||
|
||||
public BitVector(int netWidth) {
|
||||
this.width=netWidth;
|
||||
packedValues = new int[(netWidth+15)/16];
|
||||
for(int i=0; i<packedValues.length; i++) packedValues[i]=0;
|
||||
}
|
||||
|
||||
public void setValue(int i, BitValue value) {
|
||||
int bitIndex = i*2;
|
||||
int wordOffset = bitIndex >> 5;
|
||||
int bitOffset = bitIndex & 31;
|
||||
packedValues[wordOffset] &= ~(3 << bitOffset);
|
||||
packedValues[wordOffset] |= value.ordinal() << bitOffset;
|
||||
}
|
||||
|
||||
public char[] getValue() {
|
||||
int bitOffset = 0;
|
||||
int wordOffset = 0;
|
||||
char[] res = new char[width];
|
||||
// Copy values out of packed array
|
||||
for (int i = 0; i < width; i++) {
|
||||
int currentWord = (packedValues[wordOffset] >> bitOffset)&3;
|
||||
res[width-i-1]=BitValue.fromInt(currentWord).toChar();
|
||||
bitOffset += 2;
|
||||
if (bitOffset == 32) {
|
||||
wordOffset++;
|
||||
bitOffset = 0;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public void setValue(char[] value) {
|
||||
int bitIndex = width;
|
||||
int wordOffset = bitIndex >> 4;
|
||||
int bitOffset = (bitIndex * 2) % 32;
|
||||
for (int i = Math.min(value.length, width) - 1; i >= 0; i--) {
|
||||
packedValues[wordOffset] |= BitValue.fromChar(value[i]).ordinal() << bitOffset;
|
||||
bitOffset += 2;
|
||||
if (bitOffset == 32) {
|
||||
wordOffset++;
|
||||
bitOffset = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
public String toString(){
|
||||
return new String(getValue());
|
||||
}
|
||||
|
||||
public String toHexString(){
|
||||
int resWidth=(width-1)/4+1;
|
||||
char[] value=getValue();
|
||||
char[] res = new char[resWidth];
|
||||
for(int i=resWidth-1; i>=0; i--){
|
||||
int digit=0;
|
||||
for(int j=3; j>=0; j--){
|
||||
if((4*i+j)>=value.length) continue;
|
||||
BitValue val = BitValue.fromChar(value[4*i+j]);
|
||||
switch(val) {
|
||||
case X:
|
||||
case Z:
|
||||
res[i]=val.toChar();
|
||||
continue;
|
||||
case ONE:
|
||||
digit+=1<<(3-j);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
res[i]=Character.forDigit(digit, 16); //((digit < 10) ? '0' + digit : 'a' + digit -10)
|
||||
}
|
||||
return new String(res);
|
||||
}
|
||||
|
||||
public long toUnsignedValue() {
|
||||
long res = 0;
|
||||
int bitOffset = 0;
|
||||
int wordOffset = 0;
|
||||
int currentWord = 0;
|
||||
// Copy values out of packed array
|
||||
for (int i = 0; i < width; i++) {
|
||||
if(bitOffset==0) currentWord = packedValues[wordOffset];
|
||||
switch (currentWord & 3) {
|
||||
case 1:
|
||||
res|=1<<i;
|
||||
break;
|
||||
case 2:
|
||||
case 3:
|
||||
return 0;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
bitOffset += 2;
|
||||
if (bitOffset == 32) {
|
||||
wordOffset++;
|
||||
bitOffset = 0;
|
||||
} else {
|
||||
currentWord >>= 2;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public long toSignedValue() {
|
||||
long res = 0;
|
||||
int bitOffset = 0;
|
||||
int wordOffset = 0;
|
||||
int currentWord = 0;
|
||||
int lastVal=0;
|
||||
// Copy values out of packed array
|
||||
for (int i = 0; i < width; i++) {
|
||||
if(bitOffset==0) currentWord = packedValues[wordOffset];
|
||||
lastVal=0;
|
||||
switch (currentWord & 3) {
|
||||
case 1:
|
||||
res|=1<<i;
|
||||
lastVal=1;
|
||||
break;
|
||||
case 2:
|
||||
case 3:
|
||||
return 0;
|
||||
default:
|
||||
}
|
||||
bitOffset += 2;
|
||||
if (bitOffset == 32) {
|
||||
wordOffset++;
|
||||
bitOffset = 0;
|
||||
} else {
|
||||
currentWord >>= 2;
|
||||
}
|
||||
}
|
||||
for(int i=width; i<64; i++) {
|
||||
if(bitOffset==0) currentWord = packedValues[wordOffset];
|
||||
res|=lastVal<<i;
|
||||
bitOffset += 2;
|
||||
if (bitOffset == 32) {
|
||||
wordOffset++;
|
||||
bitOffset = 0;
|
||||
} else {
|
||||
currentWord >>= 2;
|
||||
}
|
||||
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,28 @@
|
||||
/*******************************************************************************
|
||||
* 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;
|
||||
|
||||
public enum DataType {
|
||||
BOOLEAN, // bool
|
||||
ENUMERATION, // enum
|
||||
INTEGER, // char, short, int, long, long long, sc_int, sc_bigint
|
||||
UNSIGNED, // unsigned { char, short, int, long, long long }, sc_uint,
|
||||
// sc_biguint
|
||||
FLOATING_POINT_NUMBER, // float, double
|
||||
BIT_VECTOR, // sc_bit, sc_bv
|
||||
LOGIC_VECTOR, // sc_logic, sc_lv
|
||||
FIXED_POINT_INTEGER, // sc_fixed
|
||||
UNSIGNED_FIXED_POINT_INTEGER, // sc_ufixed
|
||||
RECORD, // struct/class
|
||||
POINTER, // T*
|
||||
ARRAY, // T[N]
|
||||
STRING // string, std::string
|
||||
};
|
@ -0,0 +1,87 @@
|
||||
/*******************************************************************************
|
||||
* 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;
|
||||
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.beans.PropertyChangeSupport;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class HierNode implements IHierNode {
|
||||
|
||||
protected String name;
|
||||
|
||||
protected String parentName;
|
||||
|
||||
protected ArrayList<IHierNode> childs;
|
||||
|
||||
protected PropertyChangeSupport pcs;
|
||||
|
||||
public HierNode() {
|
||||
childs = new ArrayList<IHierNode>();
|
||||
pcs=new PropertyChangeSupport(this);
|
||||
}
|
||||
|
||||
public HierNode(String name) {
|
||||
this(name, "");
|
||||
}
|
||||
|
||||
public HierNode(String name, String parentName) {
|
||||
this();
|
||||
this.name=name;
|
||||
this.parentName=parentName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPropertyChangeListener(PropertyChangeListener l) {
|
||||
pcs.addPropertyChangeListener(l);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePropertyChangeListener(PropertyChangeListener l) {
|
||||
pcs.removePropertyChangeListener(l);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getFullName() {
|
||||
if(parentName!=null && parentName.length()>0)
|
||||
return parentName+"."+name;
|
||||
else
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setName(String name) {
|
||||
this.name=name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParentName(String name) {
|
||||
this.parentName=name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IHierNode> getChildNodes() {
|
||||
return childs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(IHierNode o) {
|
||||
return name.compareTo(o.getName());
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
/*******************************************************************************
|
||||
* 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;
|
||||
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.util.List;
|
||||
|
||||
public interface IHierNode extends Comparable<IHierNode>{
|
||||
|
||||
/**
|
||||
* Attach a non-null PropertyChangeListener to this object.
|
||||
*
|
||||
* @param l
|
||||
* a non-null PropertyChangeListener instance
|
||||
* @throws IllegalArgumentException
|
||||
* if the parameter is null
|
||||
*/
|
||||
public void addPropertyChangeListener(PropertyChangeListener l);
|
||||
|
||||
/**
|
||||
* Remove a PropertyChangeListener from this component.
|
||||
*
|
||||
* @param l
|
||||
* a PropertyChangeListener instance
|
||||
*/
|
||||
public void removePropertyChangeListener(PropertyChangeListener l) ;
|
||||
|
||||
public String getFullName();
|
||||
|
||||
public String getName();
|
||||
|
||||
public void setName(String name);
|
||||
|
||||
public void setParentName(String name);
|
||||
|
||||
public List<IHierNode> getChildNodes();
|
||||
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
/*******************************************************************************
|
||||
* 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;
|
||||
|
||||
import java.util.NavigableMap;
|
||||
|
||||
|
||||
public interface ISignal<T> extends IWaveform{
|
||||
|
||||
public NavigableMap<Long, T> getEvents();
|
||||
|
||||
public T getWaveformValueAtTime(Long time);
|
||||
|
||||
public T getWaveformValueBeforeTime(Long time);
|
||||
|
||||
public Class<?> getType();
|
||||
}
|
||||
|
@ -0,0 +1,35 @@
|
||||
/*******************************************************************************
|
||||
* 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;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public interface ITx extends Comparable<ITx>{
|
||||
|
||||
public Long getId();
|
||||
|
||||
public ITxStream<ITxEvent> getStream();
|
||||
|
||||
public ITxGenerator getGenerator();
|
||||
|
||||
public Long getBeginTime();
|
||||
|
||||
public Long getEndTime();
|
||||
|
||||
public int getConcurrencyIndex();
|
||||
|
||||
public List<ITxAttribute> getAttributes();
|
||||
|
||||
public Collection<ITxRelation> getIncomingRelations();
|
||||
|
||||
public Collection<ITxRelation> getOutgoingRelations();
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
/*******************************************************************************
|
||||
* 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;
|
||||
|
||||
public interface ITxAttribute extends ITxAttributeType {
|
||||
public Object getValue();
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
/*******************************************************************************
|
||||
* 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;
|
||||
|
||||
public interface ITxAttributeType {
|
||||
public String getName();
|
||||
public DataType getDataType();
|
||||
public AssociationType getType();
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
/*******************************************************************************
|
||||
* 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;
|
||||
|
||||
public interface ITxEvent extends IWaveformEvent {
|
||||
enum Type {BEGIN, END};
|
||||
|
||||
public ITx getTransaction();
|
||||
|
||||
public Type getType();
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
/*******************************************************************************
|
||||
* 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;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ITxGenerator {
|
||||
public Long getId();
|
||||
public ITxStream<ITxEvent> getStream();
|
||||
public String getName();
|
||||
public List<ITx> getTransactions();
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
/*******************************************************************************
|
||||
* 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;
|
||||
|
||||
public interface ITxRelation {
|
||||
|
||||
RelationType getRelationType();
|
||||
|
||||
ITx getSource();
|
||||
|
||||
ITx getTarget();
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
/*******************************************************************************
|
||||
* 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;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.NavigableMap;
|
||||
|
||||
public interface ITxStream<T extends ITxEvent> extends IWaveform {
|
||||
|
||||
public List<ITxGenerator> getGenerators();
|
||||
|
||||
public int getMaxConcurrency();
|
||||
|
||||
public NavigableMap<Long, List<ITxEvent>> getEvents();
|
||||
|
||||
public Collection<T> getWaveformEventsAtTime(Long time);
|
||||
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
/*******************************************************************************
|
||||
* 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;
|
||||
|
||||
|
||||
public interface IWaveform extends IHierNode {
|
||||
|
||||
public Long getId();
|
||||
|
||||
public String getKind();
|
||||
|
||||
public IWaveformDb getDb();
|
||||
|
||||
public Boolean equals(IWaveform other);
|
||||
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
/*******************************************************************************
|
||||
* 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;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public interface IWaveformDb extends IHierNode {
|
||||
|
||||
public Long getMaxTime();
|
||||
|
||||
public IWaveform getStreamByName(String name);
|
||||
|
||||
public List<IWaveform> getAllWaves();
|
||||
|
||||
public List<RelationType> getAllRelationTypes();
|
||||
|
||||
public boolean load(File inp);
|
||||
|
||||
public boolean isLoaded();
|
||||
|
||||
public void clear();
|
||||
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
/*******************************************************************************
|
||||
* 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;
|
||||
|
||||
public interface IWaveformDbFactory {
|
||||
|
||||
IWaveformDb getDatabase();
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
/*******************************************************************************
|
||||
* 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;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
|
||||
public interface IWaveformDbLoader {
|
||||
|
||||
public boolean load(IWaveformDb db, File inp) throws Exception;
|
||||
|
||||
public Long getMaxTime();
|
||||
|
||||
public Collection<IWaveform> getAllWaves() ;
|
||||
|
||||
public Collection<RelationType> getAllRelationTypes() ;
|
||||
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
/*******************************************************************************
|
||||
* 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;
|
||||
|
||||
|
||||
public interface IWaveformEvent extends Comparable<IWaveformEvent>{
|
||||
|
||||
public Long getTime();
|
||||
|
||||
public IWaveformEvent duplicate() throws CloneNotSupportedException;
|
||||
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
/*******************************************************************************
|
||||
* 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;
|
||||
|
||||
public class InputFormatException extends Exception {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 8676129878197783368L;
|
||||
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
/*******************************************************************************
|
||||
* 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;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class RelationType {
|
||||
|
||||
private static HashMap<String, RelationType> registry = new HashMap<>();
|
||||
|
||||
private String name;
|
||||
|
||||
public static RelationType create(String name){
|
||||
if(registry.containsKey(name)){
|
||||
return registry.get(name);
|
||||
}else{
|
||||
RelationType relType = new RelationType(name);
|
||||
registry.put(name, relType);
|
||||
return relType;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private RelationType(String name) {
|
||||
super();
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String toString(){
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return name.hashCode();
|
||||
}
|
||||
}
|
@ -0,0 +1,189 @@
|
||||
/*******************************************************************************
|
||||
* 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.internal;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.minres.scviewer.database.HierNode;
|
||||
import com.minres.scviewer.database.IHierNode;
|
||||
import com.minres.scviewer.database.IWaveform;
|
||||
import com.minres.scviewer.database.IWaveformDb;
|
||||
import com.minres.scviewer.database.IWaveformDbLoader;
|
||||
import com.minres.scviewer.database.InputFormatException;
|
||||
import com.minres.scviewer.database.RelationType;
|
||||
|
||||
public class WaveformDb extends HierNode implements IWaveformDb {
|
||||
|
||||
private static List<IWaveformDbLoader> loaders=new LinkedList<IWaveformDbLoader>();
|
||||
|
||||
private boolean loaded;
|
||||
|
||||
private List<IHierNode> childNodes;
|
||||
|
||||
private List<RelationType> relationTypes;
|
||||
|
||||
private Map<String, IWaveform> waveforms;
|
||||
|
||||
private Long maxTime;
|
||||
|
||||
|
||||
public synchronized void bind(IWaveformDbLoader loader){
|
||||
loaders.add(loader);
|
||||
}
|
||||
|
||||
public synchronized void unbind(IWaveformDbLoader loader){
|
||||
loaders.remove(loader);
|
||||
}
|
||||
|
||||
|
||||
public static List<IWaveformDbLoader> getLoaders() {
|
||||
return Collections.unmodifiableList(loaders);
|
||||
}
|
||||
|
||||
public WaveformDb() {
|
||||
super();
|
||||
waveforms = new HashMap<String, IWaveform>();
|
||||
relationTypes=new ArrayList<>();
|
||||
maxTime=0L;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getMaxTime() {
|
||||
return maxTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWaveform getStreamByName(String name) {
|
||||
return waveforms.get(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IWaveform> getAllWaves() {
|
||||
return new ArrayList<IWaveform>(waveforms.values());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean load(File inp){
|
||||
for(IWaveformDbLoader loader:loaders){
|
||||
try {
|
||||
if(loader.load(this, inp)){
|
||||
for(IWaveform w:loader.getAllWaves()){
|
||||
waveforms.put(w.getFullName(),w);
|
||||
}
|
||||
if(loader.getMaxTime()>maxTime){
|
||||
maxTime=loader.getMaxTime();
|
||||
}
|
||||
if(name==null) name=getFileBasename(inp.getName());
|
||||
buildHierarchyNodes() ;
|
||||
relationTypes.addAll(loader.getAllRelationTypes());
|
||||
pcs.firePropertyChange("WAVEFORMS", null, waveforms);
|
||||
pcs.firePropertyChange("CHILDS", null, childNodes);
|
||||
loaded = true;
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected static String getFileBasename(String f) {
|
||||
String ext = "";
|
||||
int i = f.lastIndexOf('.');
|
||||
if (i > 0 && i < f.length() - 1) {
|
||||
ext = f.substring(0, i);
|
||||
}
|
||||
return ext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
waveforms.clear();
|
||||
childNodes.clear();
|
||||
loaded=false;
|
||||
}
|
||||
|
||||
public boolean isLoaded() {
|
||||
return loaded;
|
||||
}
|
||||
|
||||
private void buildHierarchyNodes() throws InputFormatException{
|
||||
childNodes= new ArrayList<IHierNode>();
|
||||
for(IWaveform stream:getAllWaves()){
|
||||
//updateMaxTime(stream);
|
||||
String[] hier = stream.getName().split("\\.");
|
||||
IHierNode node = this;
|
||||
List<String> path=new LinkedList<String>();
|
||||
path.add(name);
|
||||
for(String name:hier){
|
||||
IHierNode n1 = null;
|
||||
for (IHierNode n : node.getChildNodes()) {
|
||||
if (n.getName().equals(name)) {
|
||||
n1=n;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(name.equals(hier[hier.length-1])){ //leaf
|
||||
if(n1!=null) {
|
||||
if(n1 instanceof HierNode){
|
||||
node.getChildNodes().remove(n1);
|
||||
stream.getChildNodes().addAll(n1.getChildNodes());
|
||||
Collections.sort(stream.getChildNodes());
|
||||
} else {
|
||||
throw new InputFormatException();
|
||||
}
|
||||
}
|
||||
stream.setName(name);
|
||||
stream.setParentName(join(path, "."));
|
||||
node.getChildNodes().add(stream);
|
||||
Collections.sort(node.getChildNodes());
|
||||
node=stream;
|
||||
} else { // intermediate
|
||||
if(n1 != null) {
|
||||
node=n1;
|
||||
} else {
|
||||
HierNode newNode = new HierNode(name, join(path, "."));
|
||||
node.getChildNodes().add(newNode);
|
||||
Collections.sort(node.getChildNodes());
|
||||
node=newNode;
|
||||
}
|
||||
}
|
||||
path.add(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static String join(Collection<?> col, String delim) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
Iterator<?> iter = col.iterator();
|
||||
if (iter.hasNext())
|
||||
sb.append(iter.next().toString());
|
||||
while (iter.hasNext()) {
|
||||
sb.append(delim);
|
||||
sb.append(iter.next().toString());
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RelationType> getAllRelationTypes() {
|
||||
return relationTypes;
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
/*******************************************************************************
|
||||
* 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.internal;
|
||||
|
||||
import com.minres.scviewer.database.IWaveformDb;
|
||||
import com.minres.scviewer.database.IWaveformDbFactory;
|
||||
|
||||
/**
|
||||
* @author eyck
|
||||
*
|
||||
*/
|
||||
public class WaveformDbFactory implements IWaveformDbFactory {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.minres.scviewer.database.IWaveformDbFactory#getDatabase()
|
||||
*/
|
||||
@Override
|
||||
public IWaveformDb getDatabase() {
|
||||
return new WaveformDb();
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user