Implemented painter concept
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
@ -2,4 +2,4 @@
|
||||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="com.minres.scviewer.database">
|
||||
<implementation class="com.minres.scviewer.database.WaveformDb"/>
|
||||
<reference bind="bind" cardinality="0..n" interface="com.minres.scviewer.database.IWaveformDbLoader" name="IWaveformDbLoader" policy="dynamic" unbind="unbind"/>
|
||||
</scr:component>
|
||||
</scr:component>
|
@ -1,79 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2012 IT Just working.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IT Just working - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package com.minres.scviewer.database;
|
||||
|
||||
public class EventTime implements Comparable<EventTime>{
|
||||
public enum Unit {
|
||||
FS("fs"), PS("ps"), NS("ns"), US("us"), MS("ms"), SEC("s");
|
||||
|
||||
private String alternative;
|
||||
private Unit(String alternative){
|
||||
this.alternative=alternative;
|
||||
}
|
||||
|
||||
public static Unit fromString(String text) {
|
||||
if (text != null)
|
||||
for (Unit b : Unit.values()) {
|
||||
if (text.equalsIgnoreCase(b.name()) || text.equalsIgnoreCase(b.alternative)) return b;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
static final double[] scales = {
|
||||
1,
|
||||
1000.0,
|
||||
1000000.0,
|
||||
1000000000.0,
|
||||
1000000000000.0,
|
||||
1000000000000000.0};
|
||||
|
||||
public static final EventTime ZERO = new EventTime(0L);
|
||||
|
||||
private long value; // unit is femto seconds
|
||||
|
||||
public EventTime(Long value){
|
||||
this(value, Unit.FS);
|
||||
}
|
||||
|
||||
public EventTime(Long value, Unit scale){
|
||||
setValue(value, scale);
|
||||
}
|
||||
|
||||
public static double getScalingFactor(Unit scale){
|
||||
return scales[scale.ordinal()];
|
||||
}
|
||||
|
||||
public long getValue(){
|
||||
return(value);
|
||||
}
|
||||
|
||||
public double getScaledValue(Unit scale){
|
||||
return value/scales[scale.ordinal()];
|
||||
}
|
||||
|
||||
public void setValue(long value){
|
||||
this.value=value;
|
||||
}
|
||||
|
||||
public void setValue(long value, Unit scale){
|
||||
this.value=(long) (value*scales[scale.ordinal()]);
|
||||
}
|
||||
|
||||
public String toString(){
|
||||
return value/scales[Unit.NS.ordinal()] +"ns";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(EventTime other) {
|
||||
return this.value<other.value? -1 : this.value==other.value? 0 : 1;
|
||||
}
|
||||
}
|
@ -3,7 +3,6 @@ package com.minres.scviewer.database;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.beans.PropertyChangeSupport;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class HierNode implements IHierNode {
|
||||
|
@ -1,13 +1,14 @@
|
||||
package com.minres.scviewer.database;
|
||||
|
||||
import java.util.NavigableSet;
|
||||
import java.util.NavigableMap;
|
||||
|
||||
public interface ISignal<T extends ISignalChange> extends IWaveform{
|
||||
|
||||
public NavigableSet<ISignalChange> getSignalChanges();
|
||||
public interface ISignal<T extends ISignalChange> extends IWaveform<T>{
|
||||
|
||||
public T getSignalChangeByTime(EventTime time);
|
||||
public NavigableMap<Long, T> getEvents();
|
||||
|
||||
public T getWaveformEventsAtTime(Long time);
|
||||
|
||||
public NavigableSet<ISignalChange> getSignalChangesByTimes(EventTime start, EventTime end);
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,5 @@
|
||||
package com.minres.scviewer.database;
|
||||
|
||||
public interface ISignalChange extends Comparable<ISignalChange>{
|
||||
|
||||
public EventTime getTime();
|
||||
|
||||
public ISignalChange duplicate() throws CloneNotSupportedException;
|
||||
public interface ISignalChange extends IWaveformEvent {
|
||||
|
||||
}
|
||||
|
@ -17,13 +17,15 @@ public interface ITx extends Comparable<ITx>{
|
||||
|
||||
public Long getId();
|
||||
|
||||
public ITxStream getStream();
|
||||
public ITxStream<ITxEvent> getStream();
|
||||
|
||||
public ITxGenerator getGenerator();
|
||||
|
||||
public EventTime getBeginTime();
|
||||
public Long getBeginTime();
|
||||
|
||||
public EventTime getEndTime();
|
||||
public Long getEndTime();
|
||||
|
||||
public int getConcurrencyIndex();
|
||||
|
||||
public List<ITxAttribute> getAttributes();
|
||||
|
||||
|
@ -0,0 +1,9 @@
|
||||
package com.minres.scviewer.database;
|
||||
|
||||
public interface ITxEvent extends IWaveformEvent {
|
||||
enum Type {BEGIN, END};
|
||||
|
||||
public ITx getTransaction();
|
||||
|
||||
public Type getType();
|
||||
}
|
@ -14,7 +14,7 @@ import java.util.List;
|
||||
|
||||
public interface ITxGenerator {
|
||||
public Long getId();
|
||||
public ITxStream getStream();
|
||||
public ITxStream<ITxEvent> getStream();
|
||||
public String getName();
|
||||
public List<ITx> getTransactions();
|
||||
}
|
||||
|
@ -10,15 +10,18 @@
|
||||
*******************************************************************************/
|
||||
package com.minres.scviewer.database;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.NavigableSet;
|
||||
import java.util.NavigableMap;
|
||||
|
||||
public interface ITxStream extends IWaveform {
|
||||
public interface ITxStream<T extends ITxEvent> extends IWaveform<T> {
|
||||
|
||||
public List<ITxGenerator> getGenerators();
|
||||
|
||||
public NavigableSet<ITx> getTransactions();
|
||||
public int getMaxConcurrency();
|
||||
|
||||
public ITx getTransactionById(long id);
|
||||
public NavigableMap<Long, Collection<T>> getEvents();
|
||||
|
||||
public Collection<T> getWaveformEventsAtTime(Long time);
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.minres.scviewer.database;
|
||||
|
||||
public interface IWaveform extends IHierNode {
|
||||
|
||||
public interface IWaveform<T extends IWaveformEvent> extends IHierNode {
|
||||
|
||||
public Long getId();
|
||||
|
||||
@ -8,5 +9,4 @@ public interface IWaveform extends IHierNode {
|
||||
|
||||
public IWaveformDb getDb();
|
||||
|
||||
|
||||
}
|
||||
|
@ -16,11 +16,11 @@ import java.util.List;
|
||||
|
||||
public interface IWaveformDb extends IHierNode {
|
||||
|
||||
public EventTime getMaxTime();
|
||||
public Long getMaxTime();
|
||||
|
||||
public IWaveform getStreamByName(String name);
|
||||
public IWaveform<?> getStreamByName(String name);
|
||||
|
||||
public List<IWaveform> getAllWaves();
|
||||
public List<IWaveform<?>> getAllWaves();
|
||||
|
||||
public boolean load(File inp) throws Exception;
|
||||
|
||||
|
@ -7,8 +7,8 @@ public interface IWaveformDbLoader {
|
||||
|
||||
public boolean load(IWaveformDb db, File inp) throws Exception;
|
||||
|
||||
public EventTime getMaxTime();
|
||||
public Long getMaxTime();
|
||||
|
||||
public List<IWaveform> getAllWaves() ;
|
||||
public List<IWaveform<? extends IWaveformEvent>> getAllWaves() ;
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,10 @@
|
||||
package com.minres.scviewer.database;
|
||||
|
||||
|
||||
public interface IWaveformEvent extends Comparable<IWaveformEvent>{
|
||||
|
||||
public Long getTime();
|
||||
|
||||
public IWaveformEvent duplicate() throws CloneNotSupportedException;
|
||||
|
||||
}
|
@ -1,36 +1,36 @@
|
||||
package com.minres.scviewer.database;
|
||||
|
||||
public class SignalChange implements ISignalChange {
|
||||
public class SignalChange implements IWaveformEvent {
|
||||
|
||||
EventTime time;
|
||||
Long time;
|
||||
|
||||
|
||||
public SignalChange() {
|
||||
time=EventTime.ZERO;
|
||||
time=0L;
|
||||
}
|
||||
|
||||
public SignalChange(EventTime time) {
|
||||
public SignalChange(Long time) {
|
||||
super();
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(ISignalChange o) {
|
||||
public int compareTo(IWaveformEvent o) {
|
||||
return time.compareTo(o.getTime());
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventTime getTime() {
|
||||
public Long getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public void setTime(EventTime time) {
|
||||
public void setTime(Long time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ISignalChange duplicate() throws CloneNotSupportedException {
|
||||
return (ISignalChange) this.clone();
|
||||
public IWaveformEvent duplicate() throws CloneNotSupportedException {
|
||||
return (IWaveformEvent) this.clone();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -14,9 +14,9 @@ public class WaveformDb extends HierNode implements IWaveformDb {
|
||||
|
||||
private List<IHierNode> childNodes;
|
||||
|
||||
private Map<String, IWaveform> waveforms;
|
||||
private Map<String, IWaveform<?>> waveforms;
|
||||
|
||||
private EventTime maxTime;
|
||||
private Long maxTime;
|
||||
|
||||
|
||||
public void bind(IWaveformDbLoader loader){
|
||||
@ -34,31 +34,35 @@ public class WaveformDb extends HierNode implements IWaveformDb {
|
||||
|
||||
public WaveformDb() {
|
||||
super();
|
||||
waveforms = new HashMap<String, IWaveform>();
|
||||
maxTime=EventTime.ZERO;
|
||||
waveforms = new HashMap<String, IWaveform<?>>();
|
||||
maxTime=0L;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventTime getMaxTime() {
|
||||
public Long getMaxTime() {
|
||||
return maxTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWaveform getStreamByName(String name) {
|
||||
public IWaveform<?> getStreamByName(String name) {
|
||||
return waveforms.get(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IWaveform> getAllWaves() {
|
||||
return new ArrayList<IWaveform>(waveforms.values());
|
||||
public List<IWaveform<?>> getAllWaves() {
|
||||
return new ArrayList<IWaveform<?>>(waveforms.values());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean load(File inp) throws Exception {
|
||||
for(IWaveformDbLoader loader:loaders){
|
||||
if(loader.load(this, inp)){
|
||||
for(IWaveform w:loader.getAllWaves())
|
||||
for(IWaveform<?> w:loader.getAllWaves()){
|
||||
waveforms.put(w.getFullName(),w);
|
||||
}
|
||||
if(loader.getMaxTime()>maxTime){
|
||||
maxTime=loader.getMaxTime();
|
||||
}
|
||||
buildHierarchyNodes() ;
|
||||
if(name==null) name=getFileBasename(inp.getName());
|
||||
pcs.firePropertyChange("WAVEFORMS", null, waveforms);
|
||||
@ -86,7 +90,7 @@ public class WaveformDb extends HierNode implements IWaveformDb {
|
||||
|
||||
private void buildHierarchyNodes() throws InputFormatException{
|
||||
childNodes= new ArrayList<IHierNode>();
|
||||
for(IWaveform stream:getAllWaves()){
|
||||
for(IWaveform<?> stream:getAllWaves()){
|
||||
updateMaxTime(stream);
|
||||
String[] hier = stream.getFullName().split("\\.");
|
||||
IHierNode node = this;
|
||||
@ -126,14 +130,13 @@ public class WaveformDb extends HierNode implements IWaveformDb {
|
||||
}
|
||||
}
|
||||
|
||||
private void updateMaxTime(IWaveform stream) {
|
||||
EventTime last=null;
|
||||
if(stream instanceof ITxStream){
|
||||
last=((ITxStream)stream).getTransactions().last().getEndTime();
|
||||
} else if(stream instanceof ISignal<?>){
|
||||
last=((ISignal<ISignalChange>)stream).getSignalChanges().last().getTime();
|
||||
}
|
||||
if(last.getValue()>maxTime.getValue())
|
||||
private void updateMaxTime(IWaveform<?> waveform) {
|
||||
Long last=0L;
|
||||
if(waveform instanceof ITxStream<?>)
|
||||
last=((ITxStream<?>)waveform).getEvents().lastEntry().getKey();
|
||||
else if(waveform instanceof ISignal<?>)
|
||||
last=((ISignal<?>)waveform).getEvents().lastEntry().getKey();
|
||||
if(last>maxTime)
|
||||
maxTime=last;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user