fix copyright header, javadoc, and warnings

This commit is contained in:
2021-01-09 12:43:02 +01:00
parent d970d07048
commit eb64cc60c5
41 changed files with 1856 additions and 541 deletions

View File

@ -1,5 +1,5 @@
###############################################################################
# Copyright (c) 2014, 2015 MINRES Technologies GmbH and others.
# Copyright (c) 2014, 2015 - 2020 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

View File

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2015 MINRES Technologies GmbH and others.
* Copyright (c) 2015 - 2020 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
@ -10,6 +10,16 @@
*******************************************************************************/
package com.minres.scviewer.database;
// TODO: Auto-generated Javadoc
/**
* The Enum AssociationType.
*/
public enum AssociationType {
BEGIN, RECORD, END
/** The begin. */
BEGIN,
/** The record. */
RECORD,
/** The end. */
END
}

View File

@ -1,68 +1,125 @@
/*******************************************************************************
* Copyright (c) 2020 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;
/**
* The Enum BitValue.
*/
public enum BitValue {
ZERO,
ONE,
X,
Z;
private static final BitValue[] ORDINAL_TABLE = BitValue.values();
/** The zero. */
ZERO,
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);
}
}
/** The one. */
ONE,
public char toChar() {
switch (this) {
case ZERO:
return '0';
case ONE:
return '1';
case X:
return 'x';
case Z:
return 'z';
}
/** The x. */
X,
return ' '; // Unreachable?
}
/** The z. */
Z;
public static BitValue fromInt(int i) {
if (i == 0) {
return ZERO;
} else {
return ONE;
}
}
/** The Constant ORDINAL_TABLE. */
private static final BitValue[] ORDINAL_TABLE = BitValue.values();
public int toInt() {
return (this == ONE) ? 1 : 0;
}
/**
* From char.
*
* @param c the c
* @return the bit value
*/
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 static BitValue fromOrdinal(int ord) {
return ORDINAL_TABLE[ord];
}
/**
* To char.
*
* @return the char
*/
public char toChar() {
switch (this) {
case ZERO:
return '0';
case ONE:
return '1';
case X:
return 'x';
case Z:
return 'z';
}
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;
}
}
return ' '; // Unreachable?
}
/**
* From int.
*
* @param i the i
* @return the bit value
*/
public static BitValue fromInt(int i) {
if (i == 0) {
return ZERO;
} else {
return ONE;
}
}
/**
* To int.
*
* @return the int
*/
public int toInt() {
return (this == ONE) ? 1 : 0;
}
/**
* From ordinal.
*
* @param ord the ord
* @return the bit value
*/
public static BitValue fromOrdinal(int ord) {
return ORDINAL_TABLE[ord];
}
/**
* Compare.
*
* @param other the other
* @return the int
*/
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;
}
}
}

View File

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2015 MINRES Technologies GmbH and others.
* Copyright (c) 2015 - 2020 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
@ -10,34 +10,56 @@
*******************************************************************************/
package com.minres.scviewer.database;
/**
* The Class BitVector.
*/
public class BitVector implements IEvent {
/** The width. */
private final int width;
/** The packed values. */
private int[] packedValues;
/**
* Instantiates a new bit vector.
*
* @param netWidth the net width
*/
public BitVector(int netWidth) {
this.width=netWidth;
packedValues = new int[(netWidth+15)/16];
for(int i=0; i<packedValues.length; i++) packedValues[i]=0;
this.width = netWidth;
packedValues = new int[(netWidth + 15) / 16];
for (int i = 0; i < packedValues.length; i++)
packedValues[i] = 0;
}
/**
* Sets the value.
*
* @param i the i
* @param value the value
*/
public void setValue(int i, BitValue value) {
int bitIndex = i*2;
int bitIndex = i * 2;
int wordOffset = bitIndex >> 5;
int bitOffset = bitIndex & 31;
packedValues[wordOffset] &= ~(3 << bitOffset);
packedValues[wordOffset] |= value.ordinal() << bitOffset;
}
/**
* Gets the value.
*
* @return the value
*/
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();
int currentWord = (packedValues[wordOffset] >> bitOffset) & 3;
res[width - i - 1] = BitValue.fromInt(currentWord).toChar();
bitOffset += 2;
if (bitOffset == 32) {
wordOffset++;
@ -47,6 +69,11 @@ public class BitVector implements IEvent {
return res;
}
/**
* Sets the value.
*
* @param value the new value
*/
public void setValue(char[] value) {
int bitIndex = width;
int wordOffset = bitIndex >> 4;
@ -61,41 +88,61 @@ public class BitVector implements IEvent {
}
}
/**
* Gets the width.
*
* @return the width
*/
public int getWidth() {
return width;
}
public String toString(){
/**
* To string.
*
* @return the string
*/
public String toString() {
return new String(getValue());
}
public String toHexString(){
int resWidth=(width-1)/4+1;
char[] value=getValue();
/**
* To hex string.
*
* @return the string
*/
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) {
BitValue val = BitValue.fromChar(value[4*i+j]);
switch(val) {
for (int i = resWidth - 1; i >= 0; i--) {
int digit = 0;
for (int j = 3; j >= 0; j--) {
if ((4 * i + j) < value.length) {
BitValue val = BitValue.fromChar(value[4 * i + j]);
switch (val) {
case X:
case Z:
res[i]=val.toChar();
res[i] = val.toChar();
continue;
case ONE:
digit+=1<<(3-j);
digit += 1 << (3 - j);
break;
default:
break;
}
}
}
res[i]=Character.forDigit(digit, 16); //((digit < 10) ? '0' + digit : 'a' + digit -10)
res[i] = Character.forDigit(digit, 16); // ((digit < 10) ? '0' + digit : 'a' + digit -10)
}
return new String(res);
return new String(res);
}
/**
* To unsigned value.
*
* @return the long
*/
public long toUnsignedValue() {
long res = 0;
int bitOffset = 0;
@ -103,10 +150,11 @@ public class BitVector implements IEvent {
int currentWord = 0;
// Copy values out of packed array
for (int i = 0; i < width; i++) {
if(bitOffset==0) currentWord = packedValues[wordOffset];
if (bitOffset == 0)
currentWord = packedValues[wordOffset];
switch (currentWord & 3) {
case 1:
res|=1<<i;
res |= 1 << i;
break;
case 2:
case 3:
@ -125,20 +173,26 @@ public class BitVector implements IEvent {
return res;
}
/**
* To signed value.
*
* @return the long
*/
public long toSignedValue() {
long res = 0;
int bitOffset = 0;
int wordOffset = 0;
int currentWord = 0;
int lastVal=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;
if (bitOffset == 0)
currentWord = packedValues[wordOffset];
lastVal = 0;
switch (currentWord & 3) {
case 1:
res|=1<<i;
lastVal=1;
res |= 1 << i;
lastVal = 1;
break;
case 2:
case 3:
@ -153,24 +207,39 @@ public class BitVector implements IEvent {
currentWord >>= 2;
}
}
if(lastVal!=0)
res |= -1l<<width;
if (lastVal != 0)
res |= -1l << width;
return res;
}
/**
* Gets the kind.
*
* @return the kind
*/
@Override
public EventKind getKind() {
return EventKind.SINGLE;
}
/**
* Gets the type.
*
* @return the type
*/
@Override
public WaveformType getType() {
return WaveformType.SIGNAL;
}
/**
* Duplicate.
*
* @return the i event
* @throws CloneNotSupportedException the clone not supported exception
*/
@Override
public IEvent duplicate() throws CloneNotSupportedException {
return (IEvent)this.clone();
return (IEvent) this.clone();
}
}

View File

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2015 MINRES Technologies GmbH and others.
* Copyright (c) 2015 - 2020 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
@ -10,19 +10,47 @@
*******************************************************************************/
package com.minres.scviewer.database;
/**
* The Enum DataType.
*/
public enum DataType {
BOOLEAN, // bool
ENUMERATION, // enum
INTEGER, // char, short, int, long, long long, sc_int, sc_bigint
/** The boolean. */
BOOLEAN,
/** The enumeration. */
// bool
ENUMERATION,
/** The integer. */
// enum
INTEGER,
/** The unsigned. */
// 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]
/** The floating point number. */
// sc_biguint
FLOATING_POINT_NUMBER,
/** The bit vector. */
// float, double
BIT_VECTOR,
/** The logic vector. */
// sc_bit, sc_bv
LOGIC_VECTOR,
/** The fixed point integer. */
// sc_logic, sc_lv
FIXED_POINT_INTEGER,
/** The unsigned fixed point integer. */
// sc_fixed
UNSIGNED_FIXED_POINT_INTEGER,
/** The record. */
// sc_ufixed
RECORD,
/** The pointer. */
// struct/class
POINTER,
/** The array. */
// T*
ARRAY,
/** The string. */
// T[N]
STRING // string, std::string
}

View File

@ -1,23 +1,58 @@
/*******************************************************************************
* Copyright (c) 2020 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;
/**
* The Class DoubleVal.
*/
public class DoubleVal implements IEvent {
/** The value. */
public final double value;
/**
* Instantiates a new double val.
*
* @param value the value
*/
public DoubleVal(double value) {
this.value=value;
this.value = value;
}
/**
* Gets the kind.
*
* @return the kind
*/
@Override
public EventKind getKind() {
return EventKind.SINGLE;
}
/**
* Gets the type.
*
* @return the type
*/
@Override
public WaveformType getType() {
return WaveformType.SIGNAL;
}
/**
* Duplicate.
*
* @return the i event
* @throws CloneNotSupportedException the clone not supported exception
*/
@Override
public IEvent duplicate() throws CloneNotSupportedException {
return (IEvent) clone();

View File

@ -1,5 +1,24 @@
/*******************************************************************************
* Copyright (c) 2020 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;
/**
* The Enum EventKind.
*/
public enum EventKind {
SINGLE, BEGIN, END
/** The single. */
SINGLE,
/** The begin. */
BEGIN,
/** The end. */
END
}

View File

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2015 MINRES Technologies GmbH and others.
* Copyright (c) 2015 - 2020 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
@ -15,76 +15,154 @@ import java.beans.PropertyChangeSupport;
import java.util.ArrayList;
import java.util.List;
/**
* The Class HierNode.
*/
public class HierNode implements IHierNode {
/** The name. */
protected String name;
/** The parent. */
protected IHierNode parent = null;
/** The childs. */
protected ArrayList<IHierNode> childs;
/** The pcs. */
protected PropertyChangeSupport pcs;
/**
* Instantiates a new hier node.
*/
public HierNode() {
childs = new ArrayList<>();
pcs=new PropertyChangeSupport(this);
pcs = new PropertyChangeSupport(this);
}
/**
* Instantiates a new hier node.
*
* @param name the name
*/
public HierNode(String name) {
this();
this.name=name;
this.name = name;
}
/**
* Instantiates a new hier node.
*
* @param name the name
* @param parent the parent
*/
public HierNode(String name, IHierNode parent) {
this();
this.name=name;
this.parent=parent;
this.name = name;
this.parent = parent;
}
/**
* 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);
}
/**
* Gets the full name.
*
* @return the full name
*/
@Override
public String getFullName() {
if(parent!=null)
return parent.getFullName()+"."+name;
if (parent != null)
return parent.getFullName() + "." + name;
else
return name;
}
/**
* Gets the name.
*
* @return the name
*/
@Override
public String getName() {
return name;
}
/**
* Sets the name.
*
* @param name the new name
*/
@Override
public void setName(String name) {
this.name=name;
this.name = name;
}
/**
* Sets the parent.
*
* @param parent the new parent
*/
@Override
public void setParent(IHierNode parent) {
this.parent=parent;
this.parent = parent;
}
/**
* Gets the child nodes.
*
* @return the child nodes
*/
@Override
public List<IHierNode> getChildNodes() {
return childs;
}
/**
* Adds the child.
*
* @param child the child
*/
public void addChild(IHierNode child) {
if (!childs.contains(child)) {
childs.add(child);
child.setParent(this);
}
}
/**
* Compare to.
*
* @param o the o
* @return the int
*/
@Override
public int compareTo(IHierNode o) {
return getFullName().compareTo(o.getFullName());
}
/**
* Derive waveform.
*
* @return the i derived waveform
*/
@Override
public IDerivedWaveform deriveWaveform() {
return null;

View File

@ -15,5 +15,10 @@ package com.minres.scviewer.database;
*/
public interface IDerivedWaveform extends IWaveform {
/**
* Adds the source waveform.
*
* @param waveform the waveform
*/
void addSourceWaveform(IWaveform waveform);
}

View File

@ -1,11 +1,40 @@
/*******************************************************************************
* Copyright (c) 2020 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;
/**
* The Interface IEvent.
*/
public interface IEvent {
/**
* Duplicate.
*
* @return the i event
* @throws CloneNotSupportedException the clone not supported exception
*/
public IEvent duplicate() throws CloneNotSupportedException;
/**
* Gets the kind.
*
* @return the kind
*/
public EventKind getKind();
/**
* Gets the type.
*
* @return the type
*/
public WaveformType getType();
}

View File

@ -16,25 +16,22 @@ import java.util.List;
/**
* The Interface IHierNode.
*/
public interface IHierNode extends Comparable<IHierNode>{
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
* @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
* @param l a PropertyChangeListener instance
*/
public void removePropertyChangeListener(PropertyChangeListener l) ;
public void removePropertyChangeListener(PropertyChangeListener l);
/**
* Gets the full name.
@ -42,21 +39,21 @@ public interface IHierNode extends Comparable<IHierNode>{
* @return the full name
*/
public String getFullName();
/**
* Gets the name.
*
* @return the name
*/
public String getName();
/**
* Sets the name.
*
* @param name the new name
*/
public void setName(String name);
/**
* Sets the parent.
*
@ -70,7 +67,7 @@ public interface IHierNode extends Comparable<IHierNode>{
* @return the child nodes
*/
public List<IHierNode> getChildNodes();
/**
* Derive waveform.
*

View File

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2015 MINRES Technologies GmbH and others.
* Copyright (c) 2015 - 2020 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
@ -12,22 +12,70 @@ package com.minres.scviewer.database;
import java.util.NavigableMap;
/**
* The Interface IWaveform.
*
* @author eyck
*/
public interface IWaveform extends IHierNode {
/**
* Gets the id.
*
* @return the id
*/
public Long getId();
/**
* Checks if is same.
*
* @param other the other
* @return true, if is same
*/
public boolean isSame(IWaveform other);
/**
* Gets the events.
*
* @return the events
*/
public NavigableMap<Long, IEvent[]> getEvents();
/**
* Gets the events at time.
*
* @param time the time
* @return the events at time
*/
public IEvent[] getEventsAtTime(Long time);
/**
* Gets the events before time.
*
* @param time the time
* @return the events before time
*/
public IEvent[] getEventsBeforeTime(Long time);
/**
* Gets the type.
*
* @return the type
*/
public WaveformType getType();
/**
* Gets the kind.
*
* @return the kind
*/
public String getKind();
/**
* Gets the width.
*
* @return the width
*/
public int getWidth();
}

View File

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2015 MINRES Technologies GmbH and others.
* Copyright (c) 2015 - 2020 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
@ -13,21 +13,58 @@ package com.minres.scviewer.database;
import java.io.File;
import java.util.List;
/**
* The Interface IWaveformDb.
*/
public interface IWaveformDb extends IHierNode {
/**
* Gets the max time.
*
* @return the max time
*/
public Long getMaxTime();
/**
* Gets the stream by name.
*
* @param name the name
* @return the stream by name
*/
public IWaveform getStreamByName(String name);
/**
* Gets the all waves.
*
* @return the all waves
*/
public List<IWaveform> getAllWaves();
/**
* Gets the all relation types.
*
* @return the all relation types
*/
public List<RelationType> getAllRelationTypes();
/**
* Load.
*
* @param inp the inp
* @return true, if successful
*/
public boolean load(File inp);
/**
* Checks if is loaded.
*
* @return true, if is loaded
*/
public boolean isLoaded();
/**
* Clear.
*/
public void clear();
}

View File

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2015 MINRES Technologies GmbH and others.
* Copyright (c) 2015 - 2020 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
@ -10,7 +10,15 @@
*******************************************************************************/
package com.minres.scviewer.database;
/**
* A factory for creating IWaveformDb objects.
*/
public interface IWaveformDbFactory {
/**
* Gets the database.
*
* @return the database
*/
IWaveformDb getDatabase();
}

View File

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2015 MINRES Technologies GmbH and others.
* Copyright (c) 2015 - 2020 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
@ -13,15 +13,66 @@ package com.minres.scviewer.database;
import java.io.File;
import java.util.Collection;
/**
* The Interface IWaveformDbLoader.
*/
public interface IWaveformDbLoader {
// static final String STREAM_ADDED = "StreamAdded";
//
// static final String GENERATOR_ADDED = "GeneratorAdded";
//
// static final String LOADING_FINISHED = "LoadingFinished";
// /**
// * 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) ;
/**
* Load.
*
* @param db the db
* @param inp the inp
* @return true, if successful
* @throws InputFormatException the input format exception
*/
public boolean load(IWaveformDb db, File inp) throws InputFormatException;
/**
* Gets the max time.
*
* @return the max time
*/
public Long getMaxTime();
public Collection<IWaveform> getAllWaves() ;
public Collection<RelationType> getAllRelationTypes() ;
/**
* Gets the all waves.
*
* @return the all waves
*/
public Collection<IWaveform> getAllWaves();
/**
* Gets the all relation types.
*
* @return the all relation types
*/
public Collection<RelationType> getAllRelationTypes();
/**
* Dispose.
*/
public void dispose();
}

View File

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2015 MINRES Technologies GmbH and others.
* Copyright (c) 2015 - 2020 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
@ -10,11 +10,12 @@
*******************************************************************************/
package com.minres.scviewer.database;
/**
* The Class InputFormatException.
*/
public class InputFormatException extends Exception {
/**
*
*/
/** The Constant serialVersionUID. */
private static final long serialVersionUID = 8676129878197783368L;
}

View File

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2015 MINRES Technologies GmbH and others.
* Copyright (c) 2015 - 2020 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
@ -12,40 +12,74 @@ package com.minres.scviewer.database;
import java.io.Serializable;
/**
* The Class RelationType.
*/
public class RelationType implements Serializable {
/**
*
*/
/** The Constant serialVersionUID. */
private static final long serialVersionUID = 6394859077558971735L;
/** The name. */
private String name;
/**
* Instantiates a new relation type.
*
* @param name the name
*/
RelationType(String name) {
super();
this.name = name;
}
/**
* Gets the name.
*
* @return the name
*/
public String getName() {
return name;
}
/**
* Sets the name.
*
* @param name the new name
*/
public void setName(String name) {
this.name = name;
}
public String toString(){
/**
* To string.
*
* @return the string
*/
public String toString() {
return name;
}
/**
* Hash code.
*
* @return the int
*/
@Override
public int hashCode() {
return name.hashCode();
}
/**
* Equals.
*
* @param obj the obj
* @return true, if successful
*/
@Override
public boolean equals(Object obj) {
if(obj instanceof RelationType)
return name.equals(((RelationType)obj).name);
if (obj instanceof RelationType)
return name.equals(((RelationType) obj).name);
else
return false;
}

View File

@ -1,22 +1,46 @@
/*******************************************************************************
* Copyright (c) 2020 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;
/**
* A factory for creating RelationType objects.
*/
public class RelationTypeFactory {
public static RelationType create(String name){
if(registry.containsKey(name)){
/**
* Creates the.
*
* @param name the name
* @return the relation type
*/
public static RelationType create(String name) {
if (registry.containsKey(name)) {
return registry.get(name);
}else{
} else {
RelationType relType = new RelationType(name);
registry.put(name, relType);
return relType;
}
}
private RelationTypeFactory() {}
/**
* Instantiates a new relation type factory.
*/
private RelationTypeFactory() {
}
/** The registry. */
private static HashMap<String, RelationType> registry = new HashMap<>();
}

View File

@ -1,5 +1,24 @@
/*******************************************************************************
* Copyright (c) 2020 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;
/**
* The Enum WaveformType.
*/
public enum WaveformType {
SIGNAL, TRANSACTION, FILTER
/** The signal. */
SIGNAL,
/** The transaction. */
TRANSACTION,
/** The filter. */
FILTER
}

View File

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2015 MINRES Technologies GmbH and others.
* Copyright (c) 2015 - 2020 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
@ -25,67 +25,114 @@ import com.minres.scviewer.database.IWaveformDb;
import com.minres.scviewer.database.IWaveformDbLoader;
import com.minres.scviewer.database.RelationType;
/**
* The Class WaveformDb.
*/
public class WaveformDb extends HierNode implements IWaveformDb {
private static List<IWaveformDbLoader> loaders=new LinkedList<>();
/** The loaders. */
private static List<IWaveformDbLoader> loaders = new LinkedList<>();
/** The loaded. */
private boolean loaded;
/** The relation types. */
private List<RelationType> relationTypes;
/** The waveforms. */
private Map<String, IWaveform> waveforms;
/** The max time. */
private Long maxTime;
public synchronized void bind(IWaveformDbLoader loader){
/**
* Bind.
*
* @param loader the loader
*/
public synchronized void bind(IWaveformDbLoader loader) {
loaders.add(loader);
}
public synchronized void unbind(IWaveformDbLoader loader){
/**
* Unbind.
*
* @param loader the loader
*/
public synchronized void unbind(IWaveformDbLoader loader) {
loaders.remove(loader);
}
/**
* Gets the loaders.
*
* @return the loaders
*/
public static List<IWaveformDbLoader> getLoaders() {
return Collections.unmodifiableList(loaders);
}
/**
* Instantiates a new waveform db.
*/
public WaveformDb() {
super();
waveforms = new HashMap<>();
relationTypes=new ArrayList<>();
maxTime=0L;
relationTypes = new ArrayList<>();
maxTime = 0L;
}
/**
* Gets the max time.
*
* @return the max time
*/
@Override
public Long getMaxTime() {
return maxTime;
}
/**
* Gets the stream by name.
*
* @param name the name
* @return the stream by name
*/
@Override
public IWaveform getStreamByName(String name) {
return waveforms.get(name);
}
/**
* Gets the all waves.
*
* @return the all waves
*/
@Override
public List<IWaveform> getAllWaves() {
return new ArrayList<>(waveforms.values());
}
/**
* Load.
*
* @param inp the inp
* @return true, if successful
*/
@Override
public boolean load(File inp){
for(IWaveformDbLoader loader:loaders){
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.load(this, inp)) {
for (IWaveform w : loader.getAllWaves()) {
waveforms.put(w.getFullName(), w);
}
if(loader.getMaxTime()>maxTime){
maxTime=loader.getMaxTime();
if (loader.getMaxTime() > maxTime) {
maxTime = loader.getMaxTime();
}
if(name==null) name=getFileBasename(inp.getName());
buildHierarchyNodes() ;
if (name == null)
name = getFileBasename(inp.getName());
buildHierarchyNodes();
relationTypes.addAll(loader.getAllRelationTypes());
pcs.firePropertyChange("WAVEFORMS", null, waveforms);
pcs.firePropertyChange("CHILDS", null, childs);
@ -95,67 +142,94 @@ public class WaveformDb extends HierNode implements IWaveformDb {
} catch (Exception e) {
return false;
}
}
}
return false;
}
/**
* Gets the file basename.
*
* @param f the f
* @return the file basename
*/
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;
}
String ext = "";
int i = f.lastIndexOf('.');
if (i > 0 && i < f.length() - 1) {
ext = f.substring(0, i);
}
return ext;
}
/**
* Clear.
*/
@Override
public void clear() {
waveforms.clear();
childs.clear();
loaded=false;
loaded = false;
}
/**
* Checks if is loaded.
*
* @return true, if is loaded
*/
public boolean isLoaded() {
return loaded;
}
/**
* Builds the hierarchy nodes.
*/
private void buildHierarchyNodes() {
for(IWaveform stream:getAllWaves()){
for (IWaveform stream : getAllWaves()) {
String[] hier = stream.getName().split("\\.");
IHierNode node = this;
for(int i=0; i<hier.length-1; ++i){
for (int i = 0; i < hier.length - 1; ++i) {
String name = hier[i];
IHierNode childNode = null;
for (IHierNode n : node.getChildNodes()) {
if (n.getName().equals(name)) {
childNode=n;
childNode = n;
break;
}
}
if(childNode != null) {
if (childNode != null) {
node = childNode;
break;
}
HierNode newNode = new HierNode(name, node);
node.getChildNodes().add(newNode);
node=newNode;
node = newNode;
}
node.getChildNodes().add(stream);
stream.setParent(node);
stream.setName(hier[hier.length-1]);
stream.setName(hier[hier.length - 1]);
}
sortRecursive(this);
}
/**
* Sort recursive.
*
* @param node the node
*/
private void sortRecursive(IHierNode node) {
Collections.sort(node.getChildNodes(), (IHierNode o1, IHierNode o2) -> o1.getName().compareTo(o2.getName()));
for(IHierNode n:node.getChildNodes()) {
if(!n.getChildNodes().isEmpty())
for (IHierNode n : node.getChildNodes()) {
if (!n.getChildNodes().isEmpty())
sortRecursive(n);
}
}
/**
* Gets the all relation types.
*
* @return the all relation types
*/
@Override
public List<RelationType> getAllRelationTypes() {
return relationTypes;

View File

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2015 MINRES Technologies GmbH and others.
* Copyright (c) 2015 - 2020 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
@ -17,12 +17,20 @@ import com.minres.scviewer.database.IWaveformDb;
import com.minres.scviewer.database.IWaveformDbFactory;
/**
* @author eyck
* A factory for creating WaveformDb objects.
*
* @author eyck
*/
public class WaveformDbFactory implements IWaveformDbFactory {
/* (non-Javadoc)
/**
* Gets the database.
*
* @return the database
*/
/*
* (non-Javadoc)
*
* @see com.minres.scviewer.database.IWaveformDbFactory#getDatabase()
*/
@Override

View File

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2015 MINRES Technologies GmbH and others.
* Copyright (c) 2015 - 2020 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
@ -15,23 +15,71 @@ import java.util.List;
import com.minres.scviewer.database.IWaveform;
public interface ITx extends Comparable<ITx>{
/**
* The Interface ITx.
*/
public interface ITx extends Comparable<ITx> {
/**
* Gets the id.
*
* @return the id
*/
public Long getId();
/**
* Gets the stream.
*
* @return the stream
*/
public IWaveform getStream();
/**
* Gets the generator.
*
* @return the generator
*/
public ITxGenerator getGenerator();
/**
* Gets the begin time.
*
* @return the begin time
*/
public Long getBeginTime();
/**
* Gets the end time.
*
* @return the end time
*/
public Long getEndTime();
/**
* Gets the concurrency index.
*
* @return the concurrency index
*/
public int getConcurrencyIndex();
/**
* Gets the attributes.
*
* @return the attributes
*/
public List<ITxAttribute> getAttributes();
/**
* Gets the incoming relations.
*
* @return the incoming relations
*/
public Collection<ITxRelation> getIncomingRelations();
/**
* Gets the outgoing relations.
*
* @return the outgoing relations
*/
public Collection<ITxRelation> getOutgoingRelations();
}

View File

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2015 MINRES Technologies GmbH and others.
* Copyright (c) 2015 - 2020 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
@ -10,6 +10,15 @@
*******************************************************************************/
package com.minres.scviewer.database.tx;
/**
* The Interface ITxAttribute.
*/
public interface ITxAttribute extends ITxAttributeType {
/**
* Gets the value.
*
* @return the value
*/
public Object getValue();
}

View File

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2015 MINRES Technologies GmbH and others.
* Copyright (c) 2015 - 2020 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
@ -13,8 +13,29 @@ package com.minres.scviewer.database.tx;
import com.minres.scviewer.database.AssociationType;
import com.minres.scviewer.database.DataType;
/**
* The Interface ITxAttributeType.
*/
public interface ITxAttributeType {
/**
* Gets the name.
*
* @return the name
*/
public String getName();
/**
* Gets the data type.
*
* @return the data type
*/
public DataType getDataType();
/**
* Gets the type.
*
* @return the type
*/
public AssociationType getType();
}

View File

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2015 MINRES Technologies GmbH and others.
* Copyright (c) 2015 - 2020 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
@ -12,9 +12,22 @@ package com.minres.scviewer.database.tx;
import com.minres.scviewer.database.IEvent;
/**
* The Interface ITxEvent.
*/
public interface ITxEvent extends IEvent {
/**
* Gets the time.
*
* @return the time
*/
public Long getTime();
public ITx getTransaction();
/**
* Gets the transaction.
*
* @return the transaction
*/
public ITx getTransaction();
}

View File

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2015 MINRES Technologies GmbH and others.
* Copyright (c) 2015 - 2020 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
@ -12,8 +12,16 @@ package com.minres.scviewer.database.tx;
import com.minres.scviewer.database.IWaveform;
/**
* The Interface ITxGenerator.
*/
public interface ITxGenerator extends IWaveform {
/**
* Gets the stream.
*
* @return the stream
*/
public IWaveform getStream();
}

View File

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2015 MINRES Technologies GmbH and others.
* Copyright (c) 2015 - 2020 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
@ -12,11 +12,29 @@ package com.minres.scviewer.database.tx;
import com.minres.scviewer.database.RelationType;
/**
* The Interface ITxRelation.
*/
public interface ITxRelation {
/**
* Gets the relation type.
*
* @return the relation type
*/
RelationType getRelationType();
/**
* Gets the source.
*
* @return the source
*/
ITx getSource();
/**
* Gets the target.
*
* @return the target
*/
ITx getTarget();
}