Compare commits
15 Commits
Author | SHA1 | Date | |
---|---|---|---|
08fdc18290 | |||
5c784af74f | |||
ff4cb91aed | |||
31ed3e4858 | |||
0007ab9322 | |||
f723a770c7 | |||
af1b3d00dc | |||
316647031a | |||
929cf21ff8 | |||
6ff48cac7a | |||
b083094cc8 | |||
8180a0e5d7 | |||
5a39bab52e | |||
02ba74ae16 | |||
c02f8a6520 |
11
README.md
11
README.md
@ -25,8 +25,10 @@ The plugins are structured as follows:
|
||||
- com.minres.scviewer.feature
|
||||
the feature combining the plugins above into a somhow usable form
|
||||
- scv_tr_sqlite
|
||||
a C++ project containing the SQLite based SCV database implementation. A simple
|
||||
example (scv_tr_recording_example.cpp) for testig purposes is provided.
|
||||
a C++ project containing the SQLite based SCV database implementation and the scv4tlm
|
||||
socket implementations.
|
||||
A simple example (scv_tr_recording_example.cpp) for testig purposes of the database is
|
||||
provided.
|
||||
|
||||
To build the plugins the Eclipse SDK or PDE can be used. In both cases the Groovy
|
||||
eclipse plugin (http://groovy.codehaus.org/Eclipse+Plugin or Market) has to be
|
||||
@ -34,6 +36,7 @@ installed.
|
||||
|
||||
TODO
|
||||
====
|
||||
- refactor the graphical viewer (again)
|
||||
- add more tests
|
||||
- additional analysis means
|
||||
- move to feature based product to allow automatic updates
|
||||
- improve graphics
|
||||
- catch-up e3 plugin to functionality of e4 product
|
@ -222,16 +222,32 @@ public class WaveformCanvas extends Canvas {
|
||||
}
|
||||
|
||||
public void setZoomLevel(int level) {
|
||||
long oldScaleFactor=scaleFactor;
|
||||
if(level<unitMultiplier.length*unitString.length){
|
||||
this.level = level;
|
||||
this.scaleFactor = (long) Math.pow(10, level/2);
|
||||
if(level%2==1) this.scaleFactor*=3;
|
||||
ITx tx = arrowPainter.getTx();
|
||||
arrowPainter.setTx(null);
|
||||
/*
|
||||
* xc = tc/oldScaleFactor
|
||||
* xoffs = xc+origin.x
|
||||
* xcn = tc/newScaleFactor
|
||||
* t0n = (xcn-xoffs)*scaleFactor
|
||||
*/
|
||||
long tc=cursorPainters.get(0).getTime(); // cursor time
|
||||
long xc=tc/oldScaleFactor; // cursor total x-offset
|
||||
long xoffs=xc+origin.x; // cursor offset relative to left border
|
||||
long xcn=tc/scaleFactor; // new total x-offset
|
||||
long originX=xcn-xoffs;
|
||||
if(originX>0)
|
||||
origin.x=(int) -originX; // new cursor time offset relative to left border
|
||||
else
|
||||
origin.x=0;
|
||||
syncScrollBars();
|
||||
arrowPainter.setTx(tx);
|
||||
arrowPainter.setTx(tx);
|
||||
redraw();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public long getScaleFactor() {
|
||||
|
@ -20,6 +20,7 @@ import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.NavigableMap;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import org.eclipse.core.runtime.ListenerList;
|
||||
@ -772,52 +773,56 @@ public class WaveformViewer implements IWaveformViewer {
|
||||
|
||||
protected void paintNames(GC gc, Rectangle rect) {
|
||||
if (streams.size() > 0) {
|
||||
Integer firstKey = trackVerticalOffset.floorKey(rect.y);
|
||||
if (firstKey == null)
|
||||
firstKey = trackVerticalOffset.firstKey();
|
||||
Integer lastKey = trackVerticalOffset.floorKey(rect.y + rect.height);
|
||||
Rectangle subArea = new Rectangle(rect.x, 0, rect.width, waveformCanvas.getTrackHeight());
|
||||
if (lastKey == firstKey) {
|
||||
TrackEntry trackEntry=trackVerticalOffset.get(firstKey);
|
||||
IWaveform<? extends IWaveformEvent> w = trackEntry.waveform;
|
||||
if (w instanceof ITxStream<?>)
|
||||
subArea.height *= ((ITxStream<?>) w).getMaxConcurrency();
|
||||
drawTextFormat(gc, subArea, firstKey, w.getFullName(), trackEntry.selected);
|
||||
} else {
|
||||
for (Entry<Integer, TrackEntry> entry : trackVerticalOffset.subMap(firstKey, true, lastKey, true).entrySet()) {
|
||||
IWaveform<? extends IWaveformEvent> w = entry.getValue().waveform;
|
||||
subArea.height = waveformCanvas.getTrackHeight();
|
||||
try {
|
||||
Integer firstKey = trackVerticalOffset.floorKey(rect.y);
|
||||
if (firstKey == null)
|
||||
firstKey = trackVerticalOffset.firstKey();
|
||||
Integer lastKey = trackVerticalOffset.floorKey(rect.y + rect.height);
|
||||
Rectangle subArea = new Rectangle(rect.x, 0, rect.width, waveformCanvas.getTrackHeight());
|
||||
if (lastKey == firstKey) {
|
||||
TrackEntry trackEntry=trackVerticalOffset.get(firstKey);
|
||||
IWaveform<? extends IWaveformEvent> w = trackEntry.waveform;
|
||||
if (w instanceof ITxStream<?>)
|
||||
subArea.height *= ((ITxStream<?>) w).getMaxConcurrency();
|
||||
drawTextFormat(gc, subArea, entry.getKey(), w.getFullName(), entry.getValue().selected);
|
||||
drawTextFormat(gc, subArea, firstKey, w.getFullName(), trackEntry.selected);
|
||||
} else {
|
||||
for (Entry<Integer, TrackEntry> entry : trackVerticalOffset.subMap(firstKey, true, lastKey, true).entrySet()) {
|
||||
IWaveform<? extends IWaveformEvent> w = entry.getValue().waveform;
|
||||
subArea.height = waveformCanvas.getTrackHeight();
|
||||
if (w instanceof ITxStream<?>)
|
||||
subArea.height *= ((ITxStream<?>) w).getMaxConcurrency();
|
||||
drawTextFormat(gc, subArea, entry.getKey(), w.getFullName(), entry.getValue().selected);
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch(NoSuchElementException e){}
|
||||
}
|
||||
}
|
||||
|
||||
protected void paintValues(GC gc, Rectangle rect) {
|
||||
if (streams.size() > 0) {
|
||||
Integer firstKey = trackVerticalOffset.floorKey(rect.y);
|
||||
if (firstKey == null)
|
||||
firstKey = trackVerticalOffset.firstKey();
|
||||
Integer lastKey = trackVerticalOffset.floorKey(rect.y + rect.height);
|
||||
Rectangle subArea = new Rectangle(rect.x, 0, rect.width, waveformCanvas.getTrackHeight());
|
||||
if (lastKey == firstKey) {
|
||||
TrackEntry trackEntry=trackVerticalOffset.get(firstKey);
|
||||
IWaveform<? extends IWaveformEvent> w = trackEntry.waveform;
|
||||
if (w instanceof ITxStream<?>)
|
||||
subArea.height *= ((ITxStream<?>) w).getMaxConcurrency();
|
||||
drawValue(gc, subArea, firstKey, actualValues.get(w), trackEntry.selected);
|
||||
} else {
|
||||
for (Entry<Integer, TrackEntry> entry : trackVerticalOffset.subMap(firstKey, true, lastKey, true)
|
||||
.entrySet()) {
|
||||
IWaveform<? extends IWaveformEvent> w = entry.getValue().waveform;
|
||||
subArea.height = waveformCanvas.getTrackHeight();
|
||||
try {
|
||||
Integer firstKey = trackVerticalOffset.floorKey(rect.y);
|
||||
if (firstKey == null)
|
||||
firstKey = trackVerticalOffset.firstKey();
|
||||
Integer lastKey = trackVerticalOffset.floorKey(rect.y + rect.height);
|
||||
Rectangle subArea = new Rectangle(rect.x, 0, rect.width, waveformCanvas.getTrackHeight());
|
||||
if (lastKey == firstKey) {
|
||||
TrackEntry trackEntry=trackVerticalOffset.get(firstKey);
|
||||
IWaveform<? extends IWaveformEvent> w = trackEntry.waveform;
|
||||
if (w instanceof ITxStream<?>)
|
||||
subArea.height *= ((ITxStream<?>) w).getMaxConcurrency();
|
||||
drawValue(gc, subArea, entry.getKey(), actualValues.get(w), entry.getValue().selected);
|
||||
drawValue(gc, subArea, firstKey, actualValues.get(w), trackEntry.selected);
|
||||
} else {
|
||||
for (Entry<Integer, TrackEntry> entry : trackVerticalOffset.subMap(firstKey, true, lastKey, true)
|
||||
.entrySet()) {
|
||||
IWaveform<? extends IWaveformEvent> w = entry.getValue().waveform;
|
||||
subArea.height = waveformCanvas.getTrackHeight();
|
||||
if (w instanceof ITxStream<?>)
|
||||
subArea.height *= ((ITxStream<?>) w).getMaxConcurrency();
|
||||
drawValue(gc, subArea, entry.getKey(), actualValues.get(w), entry.getValue().selected);
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch(NoSuchElementException e){}
|
||||
}
|
||||
}
|
||||
|
||||
@ -846,11 +851,11 @@ public class WaveformViewer implements IWaveformViewer {
|
||||
gc.drawText(value, subArea.x + 5, subArea.y + yOffset + (waveformCanvas.getTrackHeight() - size.y) / 2, true);
|
||||
}
|
||||
|
||||
|
||||
public void setHighliteRelation(RelationType relationType){
|
||||
this.waveformCanvas.setHighliteRelation(relationType);
|
||||
}
|
||||
|
||||
|
||||
public void setHighliteRelation(RelationType relationType){
|
||||
this.waveformCanvas.setHighliteRelation(relationType);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.minres.scviewer.database.swt.IWaveformPanel#getMaxTime()
|
||||
*/
|
||||
@ -918,8 +923,8 @@ public class WaveformViewer implements IWaveformViewer {
|
||||
* @see com.minres.scviewer.database.swt.IWaveformPanel#getActMarkerTime()
|
||||
*/
|
||||
@Override
|
||||
public long getSelectedMarkerTime(){
|
||||
return getMarkerTime(selectedMarker);
|
||||
public int getSelectedMarkerId(){
|
||||
return selectedMarker;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1163,4 +1168,16 @@ public class WaveformViewer implements IWaveformViewer {
|
||||
public void setColors(HashMap<WaveformColors, RGB> colourMap) {
|
||||
waveformCanvas.initColors(colourMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getBaselineTime() {
|
||||
return -waveformCanvas.getScaleFactorPow10()*waveformCanvas.getOrigin().x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBaselineTime(Long time) {
|
||||
Point origin = waveformCanvas.getOrigin();
|
||||
origin.x=(int) (-time/waveformCanvas.getScaleFactorPow10());
|
||||
waveformCanvas.setOrigin(origin);
|
||||
}
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ public interface IWaveformViewer extends PropertyChangeListener, ISelectionProvi
|
||||
|
||||
public long getCursorTime();
|
||||
|
||||
public long getSelectedMarkerTime();
|
||||
public int getSelectedMarkerId();
|
||||
|
||||
public long getMarkerTime(int index);
|
||||
|
||||
@ -96,4 +96,8 @@ public interface IWaveformViewer extends PropertyChangeListener, ISelectionProvi
|
||||
public List<ICursor> getCursorList();
|
||||
|
||||
public void setColors(HashMap<WaveformColors, RGB> colourMap);
|
||||
|
||||
public long getBaselineTime();
|
||||
|
||||
public void setBaselineTime(Long scale);
|
||||
}
|
@ -12,9 +12,8 @@ package com.minres.scviewer.database.vcd;
|
||||
|
||||
import com.minres.scviewer.database.BitVector;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Interface ITraceBuilder.
|
||||
* The Interface IVCDDatabaseBuilder. It allows to add VCD events into the database
|
||||
*/
|
||||
public interface IVCDDatabaseBuilder {
|
||||
|
||||
|
@ -31,15 +31,16 @@ import com.minres.scviewer.database.IWaveformEvent;
|
||||
import com.minres.scviewer.database.InputFormatException;
|
||||
import com.minres.scviewer.database.RelationType;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class VCDDb.
|
||||
*/
|
||||
public class VCDDbLoader implements IWaveformDbLoader, IVCDDatabaseBuilder {
|
||||
|
||||
|
||||
/** The Constant TIME_RES. */
|
||||
private static final Long TIME_RES = 1000L; // ps;
|
||||
|
||||
/** The db. */
|
||||
private IWaveformDb db;
|
||||
|
||||
/** The module stack. */
|
||||
@ -48,17 +49,17 @@ public class VCDDbLoader implements IWaveformDbLoader, IVCDDatabaseBuilder {
|
||||
/** The signals. */
|
||||
private List<IWaveform<? extends IWaveformEvent>> signals;
|
||||
|
||||
/** The max time. */
|
||||
private long maxTime;
|
||||
|
||||
/**
|
||||
* Instantiates a new VCD db.
|
||||
*
|
||||
* @param netName the net name
|
||||
*/
|
||||
public VCDDbLoader() {
|
||||
}
|
||||
|
||||
private byte[] x = "$date".getBytes();
|
||||
/** The date bytes. */
|
||||
private byte[] dateBytes = "$date".getBytes();
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.minres.scviewer.database.ITrDb#load(java.io.File)
|
||||
@ -68,12 +69,12 @@ public class VCDDbLoader implements IWaveformDbLoader, IVCDDatabaseBuilder {
|
||||
public boolean load(IWaveformDb db, File file) throws Exception {
|
||||
this.db=db;
|
||||
FileInputStream fis = new FileInputStream(file);
|
||||
byte[] buffer = new byte[x.length];
|
||||
int read = fis.read(buffer, 0, x.length);
|
||||
byte[] buffer = new byte[dateBytes.length];
|
||||
int read = fis.read(buffer, 0, dateBytes.length);
|
||||
fis.close();
|
||||
if (read == x.length)
|
||||
for (int i = 0; i < x.length; i++)
|
||||
if (buffer[i] != x[i])
|
||||
if (read == dateBytes.length)
|
||||
for (int i = 0; i < dateBytes.length; i++)
|
||||
if (buffer[i] != dateBytes[i])
|
||||
return false;
|
||||
|
||||
signals = new Vector<IWaveform<? extends IWaveformEvent>>();
|
||||
@ -180,6 +181,9 @@ public class VCDDbLoader implements IWaveformDbLoader, IVCDDatabaseBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.minres.scviewer.database.IWaveformDbLoader#getAllRelationTypes()
|
||||
*/
|
||||
@Override
|
||||
public Collection<RelationType> getAllRelationTypes(){
|
||||
return Collections.emptyList();
|
||||
|
@ -34,8 +34,13 @@
|
||||
</children>
|
||||
<mainMenu xmi:id="_95PfyXNmEeWBq8z1Dv39LA" elementId="menu:org.eclipse.ui.main.menu">
|
||||
<children xsi:type="menu:Menu" xmi:id="_95QGwHNmEeWBq8z1Dv39LA" elementId="com.minres.scviewer.e4.application.menu.file" label="File">
|
||||
<children xsi:type="menu:HandledMenuItem" xmi:id="_VJG3YHgvEeWwZ-9vrAR2UQ" elementId="" label="Open" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/folder_database.png" command="_95PfwHNmEeWBq8z1Dv39LA"/>
|
||||
<children xsi:type="menu:HandledMenuItem" xmi:id="_95QGwnNmEeWBq8z1Dv39LA" label="Save" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/save_edit.png" command="_95Pfw3NmEeWBq8z1Dv39LA"/>
|
||||
<children xsi:type="menu:HandledMenuItem" xmi:id="_VJG3YHgvEeWwZ-9vrAR2UQ" elementId="" label="Open Database" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/folder_database.png" command="_95PfwHNmEeWBq8z1Dv39LA"/>
|
||||
<children xsi:type="menu:HandledMenuItem" xmi:id="_e7MOYJedEeW09eyIbHsdvg" elementId="" label="Load settings" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/folder_page.png" command="_7-AIMJebEeW09eyIbHsdvg">
|
||||
<parameters xmi:id="_4vtYgJehEeW09eyIbHsdvg" elementId="com.minres.scviewer.e4.application.parameter.30" name="com.minres.scviewer.e4.application.commandparameter.loadStore" value="load"/>
|
||||
</children>
|
||||
<children xsi:type="menu:HandledMenuItem" xmi:id="_95QGwnNmEeWBq8z1Dv39LA" label="Save settings" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/script_save.png" command="_7-AIMJebEeW09eyIbHsdvg">
|
||||
<parameters xmi:id="_61QIsJehEeW09eyIbHsdvg" elementId="com.minres.scviewer.e4.application.parameter.31" name="com.minres.scviewer.e4.application.commandparameter.loadStore" value="store"/>
|
||||
</children>
|
||||
<children xsi:type="menu:HandledMenuItem" xmi:id="_95QGw3NmEeWBq8z1Dv39LA" label="Quit" command="_95PfvHNmEeWBq8z1Dv39LA"/>
|
||||
</children>
|
||||
<children xsi:type="menu:Menu" xmi:id="_ZyHC0HgvEeWwZ-9vrAR2UQ" elementId="" label="Edit">
|
||||
@ -77,6 +82,9 @@
|
||||
<trimBars xmi:id="_95QGy3NmEeWBq8z1Dv39LA" elementId="org.eclipse.ui.main.toolbar">
|
||||
<children xsi:type="menu:ToolBar" xmi:id="_95QGzHNmEeWBq8z1Dv39LA" elementId="toolbar:org.eclipse.ui.main.toolbar">
|
||||
<children xsi:type="menu:HandledToolItem" xmi:id="_95QGzXNmEeWBq8z1Dv39LA" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/folder_database.png" tooltip="Open new database" command="_95PfwHNmEeWBq8z1Dv39LA"/>
|
||||
<children xsi:type="menu:HandledToolItem" xmi:id="_o9UBUJeiEeW09eyIbHsdvg" elementId="com.minres.scviewer.e4.application.handledtoolitem.loadsettings" label="Load settings" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/folder_page.png" command="_7-AIMJebEeW09eyIbHsdvg">
|
||||
<parameters xmi:id="_tQZAEJeiEeW09eyIbHsdvg" elementId="com.minres.scviewer.e4.application.parameter.32" name="com.minres.scviewer.e4.application.commandparameter.loadStore" value="load"/>
|
||||
</children>
|
||||
<children xsi:type="menu:HandledToolItem" xmi:id="_95QGznNmEeWBq8z1Dv39LA" toBeRendered="false" visible="false" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/save_edit.png" command="_95Pfw3NmEeWBq8z1Dv39LA"/>
|
||||
</children>
|
||||
<children xsi:type="menu:ToolBar" xmi:id="_VUv_AHckEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.toolbar.0">
|
||||
@ -134,6 +142,9 @@
|
||||
</children>
|
||||
</trimBars>
|
||||
</children>
|
||||
<children xsi:type="basic:Dialog" xmi:id="_8BTkQIytEeWid7xO48ZBXw" elementId="com.minres.scviewer.e4.application.dialog.aboutscviewer" toBeRendered="false" visible="false" selectedElement="__VNlAIytEeWid7xO48ZBXw" label="About SCViewer" y="600">
|
||||
<children xsi:type="basic:Part" xmi:id="__VNlAIytEeWid7xO48ZBXw" elementId="com.minres.scviewer.e4.application.part.0" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.parts.AboutDialog"/>
|
||||
</children>
|
||||
<handlers xmi:id="_95PfvXNmEeWBq8z1Dv39LA" elementId="com.minres.scviewer.e4.application.handler.quitCommand" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.QuitHandler" command="_95PfvHNmEeWBq8z1Dv39LA"/>
|
||||
<handlers xmi:id="_95PfwXNmEeWBq8z1Dv39LA" elementId="com.minres.scviewer.e4.application.handler.openCommand" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.OpenHandler" command="_95PfwHNmEeWBq8z1Dv39LA"/>
|
||||
<handlers xmi:id="_95PfxHNmEeWBq8z1Dv39LA" elementId="com.minres.scviewer.e4.application.handler.saveCommand" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.SaveHandler" command="_95Pfw3NmEeWBq8z1Dv39LA"/>
|
||||
@ -142,6 +153,7 @@
|
||||
<handlers xmi:id="_CTcpEIl_EeWxJ_wPkM6yGQ" elementId="com.minres.scviewer.e4.application.handler.preferences" contributionURI="bundleclass://com.opcoach.e4.preferences/com.opcoach.e4.preferences.handlers.E4PreferencesHandler" command="_AxH6sIl_EeWxJ_wPkM6yGQ"/>
|
||||
<handlers xmi:id="_UUnX8IoNEeWxJ_wPkM6yGQ" elementId="com.minres.scviewer.e4.application.handler.set_them" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.ThemeSetHandler" command="_KlGlsIoNEeWxJ_wPkM6yGQ"/>
|
||||
<handlers xmi:id="_V4EscIuGEeWid7xO48ZBXw" elementId="com.minres.scviewer.e4.application.handler.setreleationtype" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.SetRelationTypeHandler" command="_E9lUgIt2EeWid7xO48ZBXw"/>
|
||||
<handlers xmi:id="__99WoJebEeW09eyIbHsdvg" elementId="com.minres.scviewer.e4.application.handler.loadStoreSettings" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.LoadStoreSettingsHandler" command="_7-AIMJebEeW09eyIbHsdvg"/>
|
||||
<bindingTables xmi:id="_95PfvnNmEeWBq8z1Dv39LA" bindingContext="_95PfuXNmEeWBq8z1Dv39LA">
|
||||
<bindings xmi:id="_95Pfv3NmEeWBq8z1Dv39LA" keySequence="M1+Q" command="_95PfvHNmEeWBq8z1Dv39LA"/>
|
||||
<bindings xmi:id="_95PfwnNmEeWBq8z1Dv39LA" keySequence="M1+O" command="_95PfwHNmEeWBq8z1Dv39LA"/>
|
||||
@ -152,7 +164,7 @@
|
||||
<children xmi:id="_95PfunNmEeWBq8z1Dv39LA" elementId="org.eclipse.ui.contexts.window" name="In Windows"/>
|
||||
<children xmi:id="_95Pfu3NmEeWBq8z1Dv39LA" elementId="org.eclipse.ui.contexts.dialog" name="In Dialogs"/>
|
||||
</rootContext>
|
||||
<descriptors xmi:id="_KicY0HRMEeWBq8z1Dv39LA" elementId="com.minres.scviewer.e4.application.partdescriptor.waveformviewer" label="SCViewer" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/scviewer.png" allowMultiple="true" category="General" closeable="true" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.parts.WaveformViewerPart">
|
||||
<descriptors xmi:id="_KicY0HRMEeWBq8z1Dv39LA" elementId="com.minres.scviewer.e4.application.partdescriptor.waveformviewer" label="SCViewer" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/scviewer.png" allowMultiple="true" category="General" closeable="true" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.parts.WaveformViewer">
|
||||
<tags>categoryTag:General</tags>
|
||||
<handlers xmi:id="_BSIuEHacEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.handler.navigateEventCommand" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.NavigateEvent" command="_79rx4HabEeWwZ-9vrAR2UQ"/>
|
||||
<handlers xmi:id="_JpdGwHXKEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.handler.navigateTransCommand" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.NavigateTrans" command="_Gn3lEHXKEeWwZ-9vrAR2UQ"/>
|
||||
@ -223,6 +235,9 @@
|
||||
<commands xmi:id="_E9lUgIt2EeWid7xO48ZBXw" elementId="com.minres.scviewer.e4.application.command.setrelationtype" commandName="SetRelationType">
|
||||
<parameters xmi:id="_xnW7IIt_EeWid7xO48ZBXw" elementId="com.minres.scviewer.e4.application.commandparameter.relationName" name="relationName" optional="false"/>
|
||||
</commands>
|
||||
<commands xmi:id="_7-AIMJebEeW09eyIbHsdvg" elementId="com.minres.scviewer.e4.application.command.loadStoreSettings" commandName="loadStoreSettings">
|
||||
<parameters xmi:id="_wxY3EJehEeW09eyIbHsdvg" elementId="com.minres.scviewer.e4.application.commandparameter.loadStore" name="loadStore"/>
|
||||
</commands>
|
||||
<addons xmi:id="_95PfsnNmEeWBq8z1Dv39LA" elementId="org.eclipse.e4.core.commands.service" contributionURI="bundleclass://org.eclipse.e4.core.commands/org.eclipse.e4.core.commands.CommandServiceAddon"/>
|
||||
<addons xmi:id="_95Pfs3NmEeWBq8z1Dv39LA" elementId="org.eclipse.e4.ui.contexts.service" contributionURI="bundleclass://org.eclipse.e4.ui.services/org.eclipse.e4.ui.services.ContextServiceAddon"/>
|
||||
<addons xmi:id="_95PftHNmEeWBq8z1Dv39LA" elementId="org.eclipse.e4.ui.bindings.service" contributionURI="bundleclass://org.eclipse.e4.ui.bindings/org.eclipse.e4.ui.bindings.BindingServiceAddon"/>
|
||||
|
BIN
com.minres.scviewer.e4.application/icons/database_go.png
Normal file
BIN
com.minres.scviewer.e4.application/icons/database_go.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 698 B |
BIN
com.minres.scviewer.e4.application/icons/folder_page.png
Normal file
BIN
com.minres.scviewer.e4.application/icons/folder_page.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 688 B |
BIN
com.minres.scviewer.e4.application/icons/script_save.png
Normal file
BIN
com.minres.scviewer.e4.application/icons/script_save.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 804 B |
@ -34,7 +34,7 @@ import org.osgi.service.event.Event;
|
||||
import org.osgi.service.event.EventHandler;
|
||||
|
||||
/**
|
||||
* This is a stub implementation containing e4 LifeCycle annotated methods.<br />
|
||||
* This implementation contains e4 LifeCycle annotated methods.<br />
|
||||
* There is a corresponding entry in <em>plugin.xml</em> (under the
|
||||
* <em>org.eclipse.core.runtime.products' extension point</em>) that references
|
||||
* this class.
|
||||
@ -42,10 +42,21 @@ import org.osgi.service.event.EventHandler;
|
||||
@SuppressWarnings("restriction")
|
||||
public class E4LifeCycle {
|
||||
|
||||
/**
|
||||
* Post construct.
|
||||
*
|
||||
* @param eventBroker the event broker
|
||||
*/
|
||||
@PostConstruct
|
||||
private static void postConstruct(final IEventBroker eventBroker) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Post context create. Open a database if given on command line using the OpenViewHandler
|
||||
*
|
||||
* @param appContext the app context
|
||||
* @param eventBroker the event broker
|
||||
*/
|
||||
@PostContextCreate
|
||||
void postContextCreate(IApplicationContext appContext, final IEventBroker eventBroker) {
|
||||
final String[] args = (String[])appContext.getArguments().get(IApplicationContext.APPLICATION_ARGS);
|
||||
@ -66,18 +77,40 @@ public class E4LifeCycle {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Pre save.
|
||||
*
|
||||
* @param workbenchContext the workbench context
|
||||
*/
|
||||
@PreSave
|
||||
void preSave(IEclipseContext workbenchContext) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Process additions.
|
||||
*
|
||||
* @param workbenchContext the workbench context
|
||||
*/
|
||||
@ProcessAdditions
|
||||
void processAdditions(IEclipseContext workbenchContext) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Process removals.
|
||||
*
|
||||
* @param workbenchContext the workbench context
|
||||
*/
|
||||
@ProcessRemovals
|
||||
void processRemovals(IEclipseContext workbenchContext) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Join.
|
||||
*
|
||||
* @param tokens the tokens
|
||||
* @return the string
|
||||
*/
|
||||
String join(String[] tokens){
|
||||
StringBuilder sb = new StringBuilder();
|
||||
boolean first=true;
|
||||
@ -89,10 +122,25 @@ public class E4LifeCycle {
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* The Class OpenViewHandler.
|
||||
*/
|
||||
private class OpenViewHandler {
|
||||
|
||||
/** The app. */
|
||||
@Inject MApplication app;
|
||||
|
||||
/** The model service. */
|
||||
@Inject EModelService modelService;
|
||||
|
||||
/** The part service. */
|
||||
@Inject EPartService partService;
|
||||
|
||||
/**
|
||||
* Open view for file.
|
||||
*
|
||||
* @param name the name
|
||||
*/
|
||||
public void openViewForFile(String name){
|
||||
File file = new File(name);
|
||||
MPart part = partService.createPart("com.minres.scviewer.e4.application.partdescriptor.waveformviewer");
|
||||
|
@ -27,19 +27,31 @@ import org.eclipse.e4.ui.workbench.modeling.EModelService;
|
||||
import org.eclipse.e4.ui.workbench.modeling.EPartService;
|
||||
|
||||
import com.minres.scviewer.database.RelationType;
|
||||
import com.minres.scviewer.e4.application.parts.WaveformViewerPart;
|
||||
import com.minres.scviewer.e4.application.parts.WaveformViewer;
|
||||
|
||||
/**
|
||||
* The Class NavigateContribution. Currently not used in Application.e4xmi
|
||||
*/
|
||||
public class NavigateContribution {
|
||||
|
||||
/** The part service. */
|
||||
@Inject EPartService partService;
|
||||
|
||||
/**
|
||||
* About to show.
|
||||
*
|
||||
* @param items the items
|
||||
* @param application the application
|
||||
* @param modelService the model service
|
||||
*/
|
||||
@AboutToShow
|
||||
public void aboutToShow(List<MMenuElement> items, MApplication application, EModelService modelService) {
|
||||
// modelService.getActivePerspective(window)
|
||||
// modelService.findElements(application,"myID",MPart.class, EModelService.IN_ACTIVE_PERSPECTIVE);
|
||||
// MDirectMenuItem dynamicItem = MMenuFactory.INSTANCE.createDirectMenuItem();
|
||||
MPart part = partService.getActivePart();
|
||||
if(part.getObject()instanceof WaveformViewerPart){
|
||||
WaveformViewerPart waveformViewerPart = (WaveformViewerPart) part.getObject();
|
||||
if(part.getObject()instanceof WaveformViewer){
|
||||
WaveformViewer waveformViewerPart = (WaveformViewer) part.getObject();
|
||||
RelationType relationTypeFilter = waveformViewerPart.getRelationTypeFilter();
|
||||
MCommand command = modelService.findElements(application,
|
||||
"com.minres.scviewer.e4.application.command.setrelationtype", MCommand.class, null).get(0);
|
||||
|
@ -32,24 +32,41 @@ import org.eclipse.swt.widgets.Composite;
|
||||
import com.minres.scviewer.database.ITx;
|
||||
import com.minres.scviewer.database.RelationType;
|
||||
import com.minres.scviewer.e4.application.parts.PartListener;
|
||||
import com.minres.scviewer.e4.application.parts.WaveformViewerPart;
|
||||
import com.minres.scviewer.e4.application.parts.WaveformViewer;
|
||||
|
||||
/**
|
||||
* The Class RelationTypeToolControl allowing to control which TX relation is used for navigation.
|
||||
*/
|
||||
public class RelationTypeToolControl extends PartListener implements ISelectionChangedListener {
|
||||
|
||||
/** The part service. */
|
||||
EPartService partService;
|
||||
|
||||
/** The combo viewer. */
|
||||
ComboViewer comboViewer;
|
||||
|
||||
WaveformViewerPart waveformViewerPart;
|
||||
/** The waveform viewer part. */
|
||||
WaveformViewer waveformViewerPart;
|
||||
|
||||
/** The dummy. */
|
||||
RelationType dummy = RelationType.create("------------");
|
||||
|
||||
/**
|
||||
* Instantiates a new relation type tool control.
|
||||
*
|
||||
* @param partService the part service
|
||||
*/
|
||||
@Inject
|
||||
public RelationTypeToolControl(EPartService partService) {
|
||||
this.partService=partService;
|
||||
partService.addPartListener(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the gui.
|
||||
*
|
||||
* @param parent the parent
|
||||
*/
|
||||
@PostConstruct
|
||||
public void createGui(Composite parent) {
|
||||
comboViewer = new ComboViewer(parent, SWT.NONE);
|
||||
@ -62,10 +79,13 @@ public class RelationTypeToolControl extends PartListener implements ISelectionC
|
||||
comboViewer.addSelectionChangedListener(this);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.minres.scviewer.e4.application.parts.PartListener#partActivated(org.eclipse.e4.ui.model.application.ui.basic.MPart)
|
||||
*/
|
||||
@Override
|
||||
public void partActivated(MPart part) {
|
||||
if(part.getObject() instanceof WaveformViewerPart){
|
||||
waveformViewerPart=(WaveformViewerPart) part.getObject();
|
||||
if(part.getObject() instanceof WaveformViewer){
|
||||
waveformViewerPart=(WaveformViewer) part.getObject();
|
||||
checkSelection(waveformViewerPart.getSelection());
|
||||
} else {
|
||||
waveformViewerPart=null;
|
||||
@ -73,14 +93,25 @@ public class RelationTypeToolControl extends PartListener implements ISelectionC
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the selection.
|
||||
*
|
||||
* @param selection the selection
|
||||
* @param partService the part service
|
||||
*/
|
||||
@Inject
|
||||
public void setSelection(@Named(IServiceConstants.ACTIVE_SELECTION) @Optional IStructuredSelection selection, EPartService partService){
|
||||
MPart part = partService.getActivePart();
|
||||
if(part!=null && part.getObject() instanceof WaveformViewerPart && comboViewer!=null){
|
||||
if(part!=null && part.getObject() instanceof WaveformViewer && comboViewer!=null){
|
||||
checkSelection(selection);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check selection.
|
||||
*
|
||||
* @param selection the selection
|
||||
*/
|
||||
protected void checkSelection(ISelection selection) {
|
||||
if( selection instanceof IStructuredSelection) {
|
||||
Object object= ((IStructuredSelection)selection).getFirstElement();
|
||||
@ -94,11 +125,14 @@ public class RelationTypeToolControl extends PartListener implements ISelectionC
|
||||
comboViewer.getCombo().setEnabled(false);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
|
||||
*/
|
||||
@Override
|
||||
public void selectionChanged(SelectionChangedEvent event) {
|
||||
MPart part = partService.getActivePart();
|
||||
if(part!=null && part.getObject() instanceof WaveformViewerPart && !event.getSelection().isEmpty()){
|
||||
WaveformViewerPart waveformViewerPart=(WaveformViewerPart) part.getObject();
|
||||
if(part!=null && part.getObject() instanceof WaveformViewer && !event.getSelection().isEmpty()){
|
||||
WaveformViewer waveformViewerPart=(WaveformViewer) part.getObject();
|
||||
if(event.getSelection() instanceof IStructuredSelection){
|
||||
waveformViewerPart.setNavigationRelationType(
|
||||
(RelationType)((IStructuredSelection)event.getSelection()).getFirstElement());
|
||||
|
@ -11,15 +11,19 @@
|
||||
package com.minres.scviewer.e4.application.handlers;
|
||||
|
||||
import org.eclipse.e4.core.di.annotations.Execute;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.e4.ui.model.application.MApplication;
|
||||
import org.eclipse.e4.ui.model.application.ui.basic.MDialog;
|
||||
import org.eclipse.e4.ui.model.application.ui.basic.MWindow;
|
||||
import org.eclipse.e4.ui.workbench.modeling.EModelService;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
import com.minres.scviewer.e4.application.parts.AboutDialog;
|
||||
|
||||
public class AboutHandler {
|
||||
|
||||
@Execute
|
||||
public void execute(Shell shell) {
|
||||
AboutDialog.open(shell, SWT.NONE);
|
||||
public void execute(Shell shell, MApplication app, MWindow window, EModelService ms /*@Named("mdialog01.dialog.0") MDialog dialog*/) {
|
||||
MDialog dialog = (MDialog) ms.find("com.minres.scviewer.e4.application.dialog.aboutscviewer", app);
|
||||
dialog.setToBeRendered(true);
|
||||
dialog.setToBeRendered(false);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ import org.eclipse.e4.ui.workbench.modeling.ESelectionService;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
|
||||
import com.minres.scviewer.database.IWaveform;
|
||||
import com.minres.scviewer.e4.application.parts.WaveformViewerPart;
|
||||
import com.minres.scviewer.e4.application.parts.WaveformViewer;
|
||||
|
||||
public class DeleteWaveformHandler {
|
||||
|
||||
@ -32,8 +32,8 @@ public class DeleteWaveformHandler {
|
||||
public void execute(ESelectionService selectionService, MPart activePart) {
|
||||
Object o = activePart.getObject();
|
||||
Object sel = selectionService.getSelection();
|
||||
if(o instanceof WaveformViewerPart && ((IStructuredSelection)sel).getFirstElement() instanceof IWaveform<?>){
|
||||
((WaveformViewerPart)o).removeStreamFromList((IWaveform<?>) ((IStructuredSelection)sel).getFirstElement());
|
||||
if(o instanceof WaveformViewer && ((IStructuredSelection)sel).getFirstElement() instanceof IWaveform<?>){
|
||||
((WaveformViewer)o).removeStreamFromList((IWaveform<?>) ((IStructuredSelection)sel).getFirstElement());
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2015 MINRES Technologies GmbH and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* MINRES Technologies GmbH - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package com.minres.scviewer.e4.application.handlers;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.eclipse.e4.core.di.annotations.CanExecute;
|
||||
import org.eclipse.e4.core.di.annotations.Execute;
|
||||
import org.eclipse.e4.ui.model.application.MApplication;
|
||||
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
|
||||
import org.eclipse.e4.ui.workbench.modeling.EModelService;
|
||||
import org.eclipse.e4.ui.workbench.modeling.EPartService;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.widgets.FileDialog;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
import com.minres.scviewer.e4.application.parts.WaveformViewer;
|
||||
public class LoadStoreSettingsHandler {
|
||||
|
||||
static final String PARAMETER_ID="com.minres.scviewer.e4.application.commandparameter.loadStore";
|
||||
|
||||
@CanExecute
|
||||
public boolean canExecute(EPartService partService) {
|
||||
MPart part = partService.getActivePart();
|
||||
if(part==null) return false;
|
||||
return (part.getObject() instanceof WaveformViewer);
|
||||
}
|
||||
|
||||
@Execute
|
||||
public void execute(@Named(PARAMETER_ID) String param, Shell shell, MApplication app, EModelService modelService,
|
||||
EPartService partService){
|
||||
boolean load = "load".equals(param);
|
||||
FileDialog dialog = new FileDialog(shell, load?SWT.OPEN:SWT.SAVE);
|
||||
dialog.setFilterExtensions (new String []{"*.scview"});
|
||||
if(!load) dialog.setFileName("SCViewer.scview");
|
||||
String res = dialog.open();
|
||||
MPart part = partService.getActivePart();
|
||||
if(res!=null && part!=null){
|
||||
Object obj = part.getObject();
|
||||
if(obj instanceof WaveformViewer){
|
||||
if(load)
|
||||
((WaveformViewer)obj).loadState(res);
|
||||
else
|
||||
((WaveformViewer)obj).saveState(res);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -22,7 +22,7 @@ import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
|
||||
import com.minres.scviewer.database.ITx;
|
||||
import com.minres.scviewer.database.IWaveform;
|
||||
import com.minres.scviewer.e4.application.parts.WaveformViewerPart;
|
||||
import com.minres.scviewer.e4.application.parts.WaveformViewer;
|
||||
|
||||
public class MoveWaveformHandler {
|
||||
|
||||
@ -42,11 +42,11 @@ public class MoveWaveformHandler {
|
||||
public void execute(@Named(PARAMETER_ID) String param, EPartService partService) {
|
||||
MPart part = partService.getActivePart();
|
||||
Object obj = part.getObject();
|
||||
if(obj instanceof WaveformViewerPart){
|
||||
if(obj instanceof WaveformViewer){
|
||||
if("up".equalsIgnoreCase(param))
|
||||
((WaveformViewerPart)obj).moveSelected(-1);
|
||||
((WaveformViewer)obj).moveSelected(-1);
|
||||
else if("down".equalsIgnoreCase(param))
|
||||
((WaveformViewerPart)obj).moveSelected(1);
|
||||
((WaveformViewer)obj).moveSelected(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import com.minres.scviewer.database.ITx;
|
||||
import com.minres.scviewer.database.IWaveform;
|
||||
import com.minres.scviewer.database.ui.GotoDirection;
|
||||
import com.minres.scviewer.e4.application.parts.WaveformViewerPart;
|
||||
import com.minres.scviewer.e4.application.parts.WaveformViewer;
|
||||
|
||||
public class NavigateEvent {
|
||||
|
||||
@ -45,11 +45,11 @@ public class NavigateEvent {
|
||||
// String param="next";
|
||||
MPart part = partService.getActivePart();
|
||||
Object obj = part.getObject();
|
||||
if(obj instanceof WaveformViewerPart){
|
||||
if(obj instanceof WaveformViewer){
|
||||
if("next".equalsIgnoreCase(param))
|
||||
((WaveformViewerPart)obj).moveCursor(GotoDirection.NEXT);
|
||||
((WaveformViewer)obj).moveCursor(GotoDirection.NEXT);
|
||||
else if("prev".equalsIgnoreCase(param))
|
||||
((WaveformViewerPart)obj).moveCursor(GotoDirection.PREV);
|
||||
((WaveformViewer)obj).moveCursor(GotoDirection.PREV);
|
||||
}
|
||||
}
|
||||
}
|
@ -22,7 +22,7 @@ import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
|
||||
import com.minres.scviewer.database.ITx;
|
||||
import com.minres.scviewer.database.ui.GotoDirection;
|
||||
import com.minres.scviewer.e4.application.parts.WaveformViewerPart;
|
||||
import com.minres.scviewer.e4.application.parts.WaveformViewer;
|
||||
|
||||
public class NavigateTrans {
|
||||
|
||||
@ -42,11 +42,11 @@ public class NavigateTrans {
|
||||
public void execute(@Named(PARAMTER_ID) String param, EPartService partService) {
|
||||
MPart part = partService.getActivePart();
|
||||
Object obj = part.getObject();
|
||||
if(obj instanceof WaveformViewerPart){
|
||||
if(obj instanceof WaveformViewer){
|
||||
if("next".equalsIgnoreCase(param))
|
||||
((WaveformViewerPart)obj).moveSelection(GotoDirection.NEXT);
|
||||
((WaveformViewer)obj).moveSelection(GotoDirection.NEXT);
|
||||
else if("prev".equalsIgnoreCase(param))
|
||||
((WaveformViewerPart)obj).moveSelection(GotoDirection.PREV);
|
||||
((WaveformViewer)obj).moveSelection(GotoDirection.PREV);
|
||||
}
|
||||
}
|
||||
}
|
@ -27,8 +27,9 @@ public class OpenHandler {
|
||||
|
||||
@Execute
|
||||
public void execute(Shell shell, MApplication app, EModelService modelService, EPartService partService){
|
||||
FileDialog dialog = new FileDialog(shell, SWT.MULTI);
|
||||
dialog.setFilterExtensions (new String []{"vcd", "txdb", "txlog"});
|
||||
FileDialog dialog = new FileDialog(shell, SWT.OPEN | SWT.MULTI);
|
||||
// dialog.setFilterExtensions (new String []{"vcd", "txdb", "txlog"});
|
||||
dialog.setFilterExtensions (new String []{"*.vcd;*.txdb;*.txlog"});
|
||||
dialog.open();
|
||||
String path = dialog.getFilterPath();
|
||||
for(String fileName: dialog.getFileNames()){
|
||||
@ -36,8 +37,7 @@ public class OpenHandler {
|
||||
if(file.exists()){
|
||||
// MPart part = MBasicFactory.INSTANCE.createPart();
|
||||
// part.setLabel(fileName);
|
||||
// part.setContributionURI("bundleclass://com.minres.scviewer.e4.application/"+
|
||||
// WaveformViewerPart.class.getName());
|
||||
// part.setContributionURI("bundleclass://com.minres.scviewer.e4.application/"+ WaveformViewerPart.class.getName());
|
||||
MPart part = partService .createPart("com.minres.scviewer.e4.application.partdescriptor.waveformviewer");
|
||||
part.setLabel(file.getName());
|
||||
|
||||
|
@ -17,7 +17,7 @@ import org.eclipse.e4.core.di.annotations.Execute;
|
||||
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
|
||||
import org.eclipse.e4.ui.workbench.modeling.EPartService;
|
||||
|
||||
import com.minres.scviewer.e4.application.parts.WaveformViewerPart;
|
||||
import com.minres.scviewer.e4.application.parts.WaveformViewer;
|
||||
|
||||
public class SetRelationTypeHandler {
|
||||
final static String PARAMTER_ID="com.minres.scviewer.e4.application.commandparameter.relationName";
|
||||
@ -26,8 +26,8 @@ public class SetRelationTypeHandler {
|
||||
public void execute(@Named(PARAMTER_ID) String relationName, EPartService partService) {
|
||||
MPart part = partService.getActivePart();
|
||||
Object obj = part.getObject();
|
||||
if(obj instanceof WaveformViewerPart){
|
||||
WaveformViewerPart waveformViewerPart = (WaveformViewerPart) obj;
|
||||
if(obj instanceof WaveformViewer){
|
||||
WaveformViewer waveformViewerPart = (WaveformViewer) obj;
|
||||
waveformViewerPart.setNavigationRelationType(relationName);
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ import org.eclipse.e4.core.di.annotations.Execute;
|
||||
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
|
||||
import org.eclipse.e4.ui.workbench.modeling.EPartService;
|
||||
|
||||
import com.minres.scviewer.e4.application.parts.WaveformViewerPart;
|
||||
import com.minres.scviewer.e4.application.parts.WaveformViewer;
|
||||
|
||||
public class ZoomHandler {
|
||||
|
||||
@ -33,8 +33,8 @@ public class ZoomHandler {
|
||||
public void execute(@Named(PARAMTER_ID) String level, EPartService partService) {
|
||||
MPart part = partService.getActivePart();
|
||||
Object obj = part.getObject();
|
||||
if(obj instanceof WaveformViewerPart){
|
||||
WaveformViewerPart waveformViewerPart = (WaveformViewerPart) obj;
|
||||
if(obj instanceof WaveformViewer){
|
||||
WaveformViewer waveformViewerPart = (WaveformViewer) obj;
|
||||
int zoomLevel = waveformViewerPart.getZoomLevel();
|
||||
if("in".equalsIgnoreCase(level))
|
||||
waveformViewerPart.setZoomLevel(zoomLevel-1);
|
||||
|
@ -38,35 +38,75 @@ import org.osgi.service.prefs.Preferences;
|
||||
|
||||
/**
|
||||
* The Heap Status control, which shows the heap usage statistics in the window trim.
|
||||
*
|
||||
* @since 3.1
|
||||
* Part of the code is taken from the eclipse internal implementation
|
||||
*/
|
||||
public class HeapStatus extends Composite {
|
||||
|
||||
/** The armed. */
|
||||
private boolean armed;
|
||||
|
||||
/** The gc image. */
|
||||
private Image gcImage;
|
||||
|
||||
/** The disabled gc image. */
|
||||
private Image disabledGcImage;
|
||||
|
||||
/** The arm col. */
|
||||
private Color bgCol, usedMemCol, lowMemCol, freeMemCol, topLeftCol, bottomRightCol, sepCol, textCol, markCol, armCol;
|
||||
|
||||
/** The button. */
|
||||
private Canvas button;
|
||||
|
||||
/** The preferences. */
|
||||
private Preferences preferences;
|
||||
|
||||
/** The update interval. */
|
||||
private int updateInterval;
|
||||
|
||||
/** The show max. */
|
||||
private boolean showMax;
|
||||
|
||||
/** The total mem. */
|
||||
private long totalMem;
|
||||
|
||||
/** The prev total mem. */
|
||||
private long prevTotalMem = -1L;
|
||||
|
||||
/** The prev used mem. */
|
||||
private long prevUsedMem = -1L;
|
||||
|
||||
/** The has changed. */
|
||||
private boolean hasChanged;
|
||||
|
||||
/** The used mem. */
|
||||
private long usedMem;
|
||||
|
||||
/** The mark. */
|
||||
private long mark = -1;
|
||||
|
||||
/** The img bounds. */
|
||||
// start with 12x12
|
||||
private Rectangle imgBounds = new Rectangle(0,0,12,12);
|
||||
|
||||
/** The max mem. */
|
||||
private long maxMem = Long.MAX_VALUE;
|
||||
|
||||
/** The max mem known. */
|
||||
private boolean maxMemKnown;
|
||||
|
||||
/** The low mem threshold. */
|
||||
private float lowMemThreshold = 0.05f;
|
||||
|
||||
/** The show low mem threshold. */
|
||||
private boolean showLowMemThreshold = true;
|
||||
|
||||
/** The update tooltip. */
|
||||
private boolean updateTooltip = false;
|
||||
|
||||
/** The is in gc. */
|
||||
protected volatile boolean isInGC = false;
|
||||
|
||||
/** The timer. */
|
||||
private final Runnable timer = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -84,6 +124,7 @@ public class HeapStatus extends Composite {
|
||||
}
|
||||
};
|
||||
|
||||
/** The pref listener. */
|
||||
private final IPreferenceChangeListener prefListener = new IPreferenceChangeListener() {
|
||||
@Override
|
||||
public void preferenceChange(PreferenceChangeEvent event) {
|
||||
@ -215,6 +256,9 @@ public class HeapStatus extends Composite {
|
||||
});
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.swt.widgets.Control#setBackground(org.eclipse.swt.graphics.Color)
|
||||
*/
|
||||
@Override
|
||||
public void setBackground(Color color) {
|
||||
bgCol = color;
|
||||
@ -222,6 +266,9 @@ public class HeapStatus extends Composite {
|
||||
button.update();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.swt.widgets.Control#setForeground(org.eclipse.swt.graphics.Color)
|
||||
*/
|
||||
@Override
|
||||
public void setForeground(Color color) {
|
||||
if (color == null) {
|
||||
@ -234,6 +281,9 @@ public class HeapStatus extends Composite {
|
||||
button.update();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.swt.widgets.Control#getForeground()
|
||||
*/
|
||||
@Override
|
||||
public Color getForeground() {
|
||||
if (usedMemCol != null) {
|
||||
@ -244,6 +294,8 @@ public class HeapStatus extends Composite {
|
||||
|
||||
/**
|
||||
* Returns the maximum memory limit, or Long.MAX_VALUE if the max is not known.
|
||||
*
|
||||
* @return the max mem
|
||||
*/
|
||||
private long getMaxMem() {
|
||||
long max = Long.MAX_VALUE;
|
||||
@ -261,10 +313,18 @@ public class HeapStatus extends Composite {
|
||||
return max;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the update interval in ms.
|
||||
*
|
||||
* @param interval the new update interval in ms
|
||||
*/
|
||||
private void setUpdateIntervalInMS(int interval) {
|
||||
updateInterval = Math.max(100, interval);
|
||||
}
|
||||
|
||||
/**
|
||||
* Do dispose.
|
||||
*/
|
||||
private void doDispose() {
|
||||
if(preferences instanceof IEclipsePreferences)
|
||||
((IEclipsePreferences)preferences).removePreferenceChangeListener(prefListener);
|
||||
@ -276,6 +336,9 @@ public class HeapStatus extends Composite {
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.swt.widgets.Composite#computeSize(int, int, boolean)
|
||||
*/
|
||||
@Override
|
||||
public Point computeSize(int wHint, int hHint, boolean changed) {
|
||||
GC gc = new GC(this);
|
||||
@ -291,6 +354,11 @@ public class HeapStatus extends Composite {
|
||||
return new Point(p.x + 15, height);
|
||||
}
|
||||
|
||||
/**
|
||||
* Arm.
|
||||
*
|
||||
* @param armed the armed
|
||||
*/
|
||||
private void arm(boolean armed) {
|
||||
if (this.armed == armed) {
|
||||
return;
|
||||
@ -300,6 +368,11 @@ public class HeapStatus extends Composite {
|
||||
button.update();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gc running.
|
||||
*
|
||||
* @param isInGC the is in gc
|
||||
*/
|
||||
private void gcRunning(boolean isInGC) {
|
||||
if (this.isInGC == isInGC) {
|
||||
return;
|
||||
@ -310,7 +383,7 @@ public class HeapStatus extends Composite {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the context menu
|
||||
* Creates the context menu.
|
||||
*/
|
||||
private void createContextMenu() {
|
||||
MenuManager menuMgr = new MenuManager();
|
||||
@ -325,6 +398,11 @@ public class HeapStatus extends Composite {
|
||||
setMenu(menu);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill menu.
|
||||
*
|
||||
* @param menuMgr the menu mgr
|
||||
*/
|
||||
private void fillMenu(IMenuManager menuMgr) {
|
||||
menuMgr.add(new SetMarkAction());
|
||||
menuMgr.add(new ClearMarkAction());
|
||||
@ -354,6 +432,9 @@ public class HeapStatus extends Composite {
|
||||
redraw();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gc.
|
||||
*/
|
||||
private void gc() {
|
||||
gcRunning(true);
|
||||
Thread t = new Thread() {
|
||||
@ -373,6 +454,9 @@ public class HeapStatus extends Composite {
|
||||
t.start();
|
||||
}
|
||||
|
||||
/**
|
||||
* Busy gc.
|
||||
*/
|
||||
private void busyGC() {
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
System.gc();
|
||||
@ -380,6 +464,11 @@ public class HeapStatus extends Composite {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Paint button.
|
||||
*
|
||||
* @param gc the gc
|
||||
*/
|
||||
private void paintButton(GC gc) {
|
||||
Rectangle rect = button.getClientArea();
|
||||
if (isInGC) {
|
||||
@ -399,6 +488,11 @@ public class HeapStatus extends Composite {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Paint composite.
|
||||
*
|
||||
* @param gc the gc
|
||||
*/
|
||||
private void paintComposite(GC gc) {
|
||||
if (showMax && maxMemKnown) {
|
||||
paintCompositeMaxKnown(gc);
|
||||
@ -407,6 +501,11 @@ public class HeapStatus extends Composite {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Paint composite max unknown.
|
||||
*
|
||||
* @param gc the gc
|
||||
*/
|
||||
private void paintCompositeMaxUnknown(GC gc) {
|
||||
Rectangle rect = getClientArea();
|
||||
int x = rect.x;
|
||||
@ -449,6 +548,11 @@ public class HeapStatus extends Composite {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Paint composite max known.
|
||||
*
|
||||
* @param gc the gc
|
||||
*/
|
||||
private void paintCompositeMaxKnown(GC gc) {
|
||||
Rectangle rect = getClientArea();
|
||||
int x = rect.x;
|
||||
@ -509,6 +613,14 @@ public class HeapStatus extends Composite {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Paint mark.
|
||||
*
|
||||
* @param gc the gc
|
||||
* @param x the x
|
||||
* @param y the y
|
||||
* @param h the h
|
||||
*/
|
||||
private void paintMark(GC gc, int x, int y, int h) {
|
||||
gc.setForeground(markCol);
|
||||
gc.drawLine(x, y+1, x, y+h-2);
|
||||
@ -516,6 +628,9 @@ public class HeapStatus extends Composite {
|
||||
gc.drawLine(x-1, y+h-2, x+1, y+h-2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update stats.
|
||||
*/
|
||||
private void updateStats() {
|
||||
Runtime runtime = Runtime.getRuntime();
|
||||
totalMem = runtime.totalMemory();
|
||||
@ -533,6 +648,9 @@ public class HeapStatus extends Composite {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update tool tip.
|
||||
*/
|
||||
private void updateToolTip() {
|
||||
String usedStr = convertToMegString(usedMem);
|
||||
String totalStr = convertToMegString(totalMem);
|
||||
@ -546,6 +664,9 @@ public class HeapStatus extends Composite {
|
||||
|
||||
/**
|
||||
* Converts the given number of bytes to a printable number of megabytes (rounded up).
|
||||
*
|
||||
* @param numBytes the num bytes
|
||||
* @return the string
|
||||
*/
|
||||
private String convertToMegString(long numBytes) {
|
||||
return new Long(convertToMeg(numBytes)).toString()+"M";
|
||||
@ -553,41 +674,74 @@ public class HeapStatus extends Composite {
|
||||
|
||||
/**
|
||||
* Converts the given number of bytes to the corresponding number of megabytes (rounded up).
|
||||
*
|
||||
* @param numBytes the num bytes
|
||||
* @return the long
|
||||
*/
|
||||
private long convertToMeg(long numBytes) {
|
||||
return (numBytes + (512 * 1024)) / (1024 * 1024);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The Class SetMarkAction.
|
||||
*/
|
||||
class SetMarkAction extends Action {
|
||||
|
||||
/**
|
||||
* Instantiates a new sets the mark action.
|
||||
*/
|
||||
SetMarkAction() {
|
||||
super("&Set Mark");
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.action.Action#run()
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
setMark();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The Class ClearMarkAction.
|
||||
*/
|
||||
class ClearMarkAction extends Action {
|
||||
|
||||
/**
|
||||
* Instantiates a new clear mark action.
|
||||
*/
|
||||
ClearMarkAction() {
|
||||
super("&Clear Mark");
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.action.Action#run()
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
clearMark();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The Class ShowMaxAction.
|
||||
*/
|
||||
class ShowMaxAction extends Action {
|
||||
ShowMaxAction() {
|
||||
|
||||
/**
|
||||
* Instantiates a new show max action.
|
||||
*/
|
||||
ShowMaxAction() {
|
||||
super("Show &Max Heap", IAction.AS_CHECK_BOX);
|
||||
setEnabled(maxMemKnown);
|
||||
setChecked(showMax);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.action.Action#run()
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
preferences.putBoolean(IHeapStatusConstants.PREF_SHOW_MAX, isChecked());
|
||||
@ -595,13 +749,22 @@ public class HeapStatus extends Composite {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The Class CloseHeapStatusAction.
|
||||
*/
|
||||
class CloseHeapStatusAction extends Action{
|
||||
|
||||
CloseHeapStatusAction(){
|
||||
/**
|
||||
* Instantiates a new close heap status action.
|
||||
*/
|
||||
CloseHeapStatusAction(){
|
||||
super("&Close");
|
||||
}
|
||||
|
||||
@Override
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.action.Action#run()
|
||||
*/
|
||||
@Override
|
||||
public void run(){
|
||||
// WorkbenchWindow wbw = (WorkbenchWindow) PlatformUI.getWorkbench()
|
||||
// .getActiveWorkbenchWindow();
|
||||
|
@ -11,8 +11,6 @@
|
||||
package com.minres.scviewer.e4.application.internal.status;
|
||||
/**
|
||||
* Preference constants for the heap status.
|
||||
*
|
||||
* @since 3.1
|
||||
*/
|
||||
public interface IHeapStatusConstants {
|
||||
|
||||
|
@ -32,21 +32,37 @@ import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.ProgressBar;
|
||||
import org.osgi.service.prefs.PreferencesService;
|
||||
|
||||
/**
|
||||
* The Class StatusBarControl.
|
||||
*/
|
||||
public class StatusBarControl {
|
||||
|
||||
/** The Constant STATUS_UPDATE. */
|
||||
public static final String STATUS_UPDATE="StatusUpdate";
|
||||
|
||||
/** The model service. */
|
||||
@Inject EModelService modelService;
|
||||
|
||||
/** The osgi preverences. */
|
||||
@Inject @Optional PreferencesService osgiPreverences;
|
||||
|
||||
/** The sync. */
|
||||
private final UISynchronize sync;
|
||||
|
||||
/** The manager. */
|
||||
protected StatusLineManager manager;
|
||||
|
||||
/** The monitor. */
|
||||
private SyncedProgressMonitor monitor;
|
||||
|
||||
/** The progress bar. */
|
||||
private ProgressBar progressBar;
|
||||
|
||||
/**
|
||||
* Instantiates a new status bar control.
|
||||
*
|
||||
* @param sync the sync
|
||||
*/
|
||||
@Inject
|
||||
public StatusBarControl(UISynchronize sync) {
|
||||
this.sync=sync;
|
||||
@ -54,6 +70,12 @@ public class StatusBarControl {
|
||||
manager.update(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the widget.
|
||||
*
|
||||
* @param parent the parent
|
||||
* @param toolControl the tool control
|
||||
*/
|
||||
@PostConstruct
|
||||
void createWidget(Composite parent, MToolControl toolControl) {
|
||||
if (toolControl.getElementId().equals("org.eclipse.ui.StatusLine")) { //$NON-NLS-1$
|
||||
@ -65,6 +87,9 @@ public class StatusBarControl {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy.
|
||||
*/
|
||||
@PreDestroy
|
||||
void destroy() {
|
||||
if (manager != null) {
|
||||
@ -74,8 +99,10 @@ public class StatusBarControl {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param parent
|
||||
* @param toolControl
|
||||
* Creates the progress bar.
|
||||
*
|
||||
* @param parent the parent
|
||||
* @param toolControl the tool control
|
||||
*/
|
||||
private void createProgressBar(Composite parent, MToolControl toolControl) {
|
||||
new Label(parent, SWT.NONE);
|
||||
@ -92,22 +119,32 @@ public class StatusBarControl {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param parent
|
||||
* @param toolControl
|
||||
* Creates the heap status.
|
||||
*
|
||||
* @param parent the parent
|
||||
* @param toolControl the tool control
|
||||
*/
|
||||
private void createHeapStatus(Composite parent, MToolControl toolControl) {
|
||||
new HeapStatus(parent, osgiPreverences.getSystemPreferences());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param parent
|
||||
* @param toolControl
|
||||
* Creates the status line.
|
||||
*
|
||||
* @param parent the parent
|
||||
* @param toolControl the tool control
|
||||
*/
|
||||
private void createStatusLine(Composite parent, MToolControl toolControl) {
|
||||
// IEclipseContext context = modelService.getContainingContext(toolControl);
|
||||
manager.createControl(parent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the status event.
|
||||
*
|
||||
* @param text the text
|
||||
* @return the status event
|
||||
*/
|
||||
@Inject @Optional
|
||||
public void getStatusEvent(@UIEventTopic(STATUS_UPDATE) String text) {
|
||||
if(manager!=null ){
|
||||
@ -115,13 +152,24 @@ public class StatusBarControl {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The Class SyncedProgressMonitor.
|
||||
*/
|
||||
private final class SyncedProgressMonitor extends NullProgressMonitor {
|
||||
|
||||
// thread-Safe via thread confinement of the UI-Thread
|
||||
/** The running tasks. */
|
||||
// (means access only via UI-Thread)
|
||||
private long runningTasks = 0L;
|
||||
|
||||
/** The progress bar. */
|
||||
private ProgressBar progressBar;
|
||||
|
||||
/**
|
||||
* Instantiates a new synced progress monitor.
|
||||
*
|
||||
* @param progressBar the progress bar
|
||||
*/
|
||||
public SyncedProgressMonitor(ProgressBar progressBar) {
|
||||
super();
|
||||
this.progressBar = progressBar;
|
||||
@ -130,6 +178,9 @@ public class StatusBarControl {
|
||||
progressBar.setEnabled(false);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.core.runtime.NullProgressMonitor#beginTask(java.lang.String, int)
|
||||
*/
|
||||
@Override
|
||||
public void beginTask(final String name, final int totalWork) {
|
||||
sync.syncExec(new Runnable() {
|
||||
@ -148,6 +199,9 @@ public class StatusBarControl {
|
||||
});
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.core.runtime.NullProgressMonitor#worked(int)
|
||||
*/
|
||||
@Override
|
||||
public void worked(final int work) {
|
||||
sync.syncExec(new Runnable() {
|
||||
@ -158,6 +212,9 @@ public class StatusBarControl {
|
||||
});
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.core.runtime.NullProgressMonitor#done()
|
||||
*/
|
||||
@Override
|
||||
public void done() {
|
||||
sync.syncExec(new Runnable() {
|
||||
@ -169,6 +226,13 @@ public class StatusBarControl {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the job.
|
||||
*
|
||||
* @param job the job
|
||||
* @return the i progress monitor
|
||||
*/
|
||||
/*
|
||||
@Override
|
||||
public boolean isCanceled() {
|
||||
|
@ -24,8 +24,6 @@ import org.eclipse.swt.widgets.ToolItem;
|
||||
/**
|
||||
* Simple class to provide some common internal Trim support.
|
||||
*
|
||||
* @since 3.2
|
||||
*
|
||||
*/
|
||||
public class TrimUtil {
|
||||
|
||||
|
@ -27,23 +27,50 @@ import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
|
||||
/**
|
||||
* The Class WaveStatusBarControl.
|
||||
*/
|
||||
public class WaveStatusBarControl extends StatusBarControl {
|
||||
|
||||
/** The Constant ZOOM_LEVEL. */
|
||||
public static final String ZOOM_LEVEL="ZoomLevelUpdate";
|
||||
|
||||
/** The Constant CURSOR_TIME. */
|
||||
public static final String CURSOR_TIME="CursorPosUpdate";
|
||||
|
||||
/** The Constant MARKER_TIME. */
|
||||
public static final String MARKER_TIME="MarkerPosUpdate";
|
||||
|
||||
/** The Constant MARKER_DIFF. */
|
||||
public static final String MARKER_DIFF="MarlerDiffUpdate";
|
||||
|
||||
/** The model service. */
|
||||
@Inject
|
||||
EModelService modelService;
|
||||
|
||||
/**
|
||||
* The Class TextContributionItem.
|
||||
*/
|
||||
class TextContributionItem extends ContributionItem {
|
||||
|
||||
/** The label string. */
|
||||
final String labelString;
|
||||
|
||||
/** The width. */
|
||||
final int width;
|
||||
|
||||
/** The text. */
|
||||
CLabel label, text;
|
||||
|
||||
/** The content. */
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* Instantiates a new text contribution item.
|
||||
*
|
||||
* @param labelString the label string
|
||||
* @param width the width
|
||||
*/
|
||||
public TextContributionItem(String labelString, int width) {
|
||||
super();
|
||||
this.labelString = labelString;
|
||||
@ -51,6 +78,9 @@ public class WaveStatusBarControl extends StatusBarControl {
|
||||
content="";
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.action.ContributionItem#fill(org.eclipse.swt.widgets.Composite)
|
||||
*/
|
||||
@Override
|
||||
public void fill(Composite parent) {
|
||||
Composite box=new Composite(parent, SWT.NONE);
|
||||
@ -63,11 +93,19 @@ public class WaveStatusBarControl extends StatusBarControl {
|
||||
text.setLayoutData(layoutData);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.action.ContributionItem#isDynamic()
|
||||
*/
|
||||
@Override
|
||||
public boolean isDynamic() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the text.
|
||||
*
|
||||
* @param message the new text
|
||||
*/
|
||||
public void setText(String message){
|
||||
this.content=message;
|
||||
if(text!=null && !text.isDisposed()) text.setText(content);
|
||||
@ -75,8 +113,14 @@ public class WaveStatusBarControl extends StatusBarControl {
|
||||
|
||||
}
|
||||
|
||||
/** The zoom contribution. */
|
||||
TextContributionItem cursorContribution, markerContribution, markerDiffContribution, zoomContribution;
|
||||
|
||||
/**
|
||||
* Instantiates a new wave status bar control.
|
||||
*
|
||||
* @param sync the sync
|
||||
*/
|
||||
@Inject
|
||||
public WaveStatusBarControl(UISynchronize sync) {
|
||||
super(sync);
|
||||
@ -90,6 +134,11 @@ public class WaveStatusBarControl extends StatusBarControl {
|
||||
manager.appendToGroup(StatusLineManager.BEGIN_GROUP, zoomContribution);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the selection.
|
||||
*
|
||||
* @param selection the new selection
|
||||
*/
|
||||
@Inject
|
||||
public void setSelection(@Named(IServiceConstants.ACTIVE_SELECTION)@Optional IStructuredSelection selection){
|
||||
if(manager!=null && selection!=null){
|
||||
@ -107,21 +156,45 @@ public class WaveStatusBarControl extends StatusBarControl {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the zoom event.
|
||||
*
|
||||
* @param text the text
|
||||
* @return the zoom event
|
||||
*/
|
||||
@Inject @Optional
|
||||
public void getZoomEvent(@UIEventTopic(ZOOM_LEVEL) String text) {
|
||||
zoomContribution.setText(text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the cursor event.
|
||||
*
|
||||
* @param text the text
|
||||
* @return the cursor event
|
||||
*/
|
||||
@Inject @Optional
|
||||
public void getCursorEvent(@UIEventTopic(CURSOR_TIME) String text) {
|
||||
cursorContribution.setText(text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the marker event.
|
||||
*
|
||||
* @param text the text
|
||||
* @return the marker event
|
||||
*/
|
||||
@Inject @Optional
|
||||
public void getMarkerEvent(@UIEventTopic(MARKER_TIME) String text) {
|
||||
markerContribution.setText(text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the diff event.
|
||||
*
|
||||
* @param text the text
|
||||
* @return the diff event
|
||||
*/
|
||||
@Inject @Optional
|
||||
public void getDiffEvent(@UIEventTopic(MARKER_DIFF) String text) {
|
||||
markerDiffContribution.setText(text);
|
||||
|
@ -21,12 +21,16 @@ import java.util.TimerTask;
|
||||
/**
|
||||
* Class monitoring a {@link File} for changes.
|
||||
*
|
||||
* @author Pascal Essiembre
|
||||
*/
|
||||
public class FileMonitor {
|
||||
|
||||
/** The timer. */
|
||||
private Timer timer;
|
||||
|
||||
/** The enabled. */
|
||||
private boolean enabled;
|
||||
|
||||
/** The timer entries. */
|
||||
private Hashtable<String, FileSetMonitorTask> timerEntries;
|
||||
|
||||
/**
|
||||
@ -36,17 +40,16 @@ public class FileMonitor {
|
||||
// Create timer, run timer thread as daemon.
|
||||
timer = new Timer(true);
|
||||
timerEntries = new Hashtable<String, FileSetMonitorTask>();
|
||||
enabled=true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a monitored file with a FileChangeListener.
|
||||
*
|
||||
* @param listener
|
||||
* listener to notify when the file changed.
|
||||
* @param fileName
|
||||
* name of the file to monitor.
|
||||
* @param period
|
||||
* polling period in milliseconds.
|
||||
*
|
||||
* @param listener listener to notify when the file changed.
|
||||
* @param file the file
|
||||
* @param period polling period in milliseconds.
|
||||
* @return the i modification checker
|
||||
*/
|
||||
public IModificationChecker addFileChangeListener(IFileChangeListener listener, File file, long period) {
|
||||
return addFileChangeListener(listener, Arrays.asList(new File[]{file}), period);
|
||||
@ -55,12 +58,11 @@ public class FileMonitor {
|
||||
/**
|
||||
* Adds a monitored file with a FileChangeListener.
|
||||
* List<File> filesToLoad
|
||||
* @param listener
|
||||
* listener to notify when the file changed.
|
||||
* @param fileName
|
||||
* name of the file to monitor.
|
||||
* @param period
|
||||
* polling period in milliseconds.
|
||||
*
|
||||
* @param listener listener to notify when the file changed.
|
||||
* @param files the files
|
||||
* @param period polling period in milliseconds.
|
||||
* @return the i modification checker
|
||||
*/
|
||||
public IModificationChecker addFileChangeListener(IFileChangeListener listener, List<File> files, long period) {
|
||||
removeFileChangeListener(listener);
|
||||
@ -90,7 +92,25 @@ public class FileMonitor {
|
||||
* the file that changed
|
||||
*/
|
||||
protected void fireFileChangeEvent(IFileChangeListener listener, List<File> file) {
|
||||
listener.fileChanged(file);
|
||||
if(enabled) listener.fileChanged(file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is enabled.
|
||||
*
|
||||
* @return true, if is enabled
|
||||
*/
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the enabled.
|
||||
*
|
||||
* @param enabled the new enabled
|
||||
*/
|
||||
public void setEnabled(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -98,14 +118,25 @@ public class FileMonitor {
|
||||
*/
|
||||
class FileSetMonitorTask extends TimerTask implements IModificationChecker{
|
||||
|
||||
/** The listener. */
|
||||
IFileChangeListener listener;
|
||||
|
||||
/** The monitored files. */
|
||||
private List<File> monitoredFiles;
|
||||
|
||||
/** The last modified times. */
|
||||
private List<Long> lastModifiedTimes;
|
||||
|
||||
/** The period. */
|
||||
public final long period;
|
||||
|
||||
/**
|
||||
* Instantiates a new file set monitor task.
|
||||
*
|
||||
* @param listener the listener
|
||||
* @param monitoredFiles the monitored files
|
||||
* @param period the period
|
||||
*/
|
||||
public FileSetMonitorTask(IFileChangeListener listener, List<File> monitoredFiles, long period) {
|
||||
this.period=period;
|
||||
this.monitoredFiles = monitoredFiles;
|
||||
@ -120,10 +151,16 @@ public class FileMonitor {
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.util.TimerTask#run()
|
||||
*/
|
||||
public void run() {
|
||||
check();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.minres.scviewer.e4.application.internal.util.IModificationChecker#check()
|
||||
*/
|
||||
public void check() {
|
||||
boolean res = false;
|
||||
for(int i=0; i<monitoredFiles.size(); ++i){
|
||||
|
@ -18,14 +18,13 @@ import java.util.List;
|
||||
/**
|
||||
* Listener interested in {@link File} changes.
|
||||
*
|
||||
* @author Pascal Essiembre
|
||||
*/
|
||||
public interface IFileChangeListener {
|
||||
|
||||
/**
|
||||
* Invoked when a file changes.
|
||||
*
|
||||
* @param fileName
|
||||
* name of changed file.
|
||||
*
|
||||
* @param file the file
|
||||
*/
|
||||
public void fileChanged(List<File> file);
|
||||
}
|
@ -10,8 +10,14 @@
|
||||
*******************************************************************************/
|
||||
package com.minres.scviewer.e4.application.internal.util;
|
||||
|
||||
/**
|
||||
* The Interface IModificationChecker. Allows to trigger a check independent of the timer
|
||||
*/
|
||||
public interface IModificationChecker {
|
||||
|
||||
/**
|
||||
* Check.
|
||||
*/
|
||||
public void check();
|
||||
|
||||
}
|
||||
|
@ -16,91 +16,78 @@ import java.net.URISyntaxException;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.eclipse.jface.dialogs.Dialog;
|
||||
import org.eclipse.jface.dialogs.IDialogConstants;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.custom.StyleRange;
|
||||
import org.eclipse.swt.custom.StyledText;
|
||||
import org.eclipse.swt.events.PaintEvent;
|
||||
import org.eclipse.swt.events.PaintListener;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.graphics.Color;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
import org.eclipse.swt.graphics.Point;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Canvas;
|
||||
import org.eclipse.swt.widgets.Dialog;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.swt.widgets.Event;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Link;
|
||||
import org.eclipse.swt.widgets.Listener;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.wb.swt.ResourceManager;
|
||||
import org.eclipse.wb.swt.SWTResourceManager;
|
||||
|
||||
/**
|
||||
* The Class AboutDialog.
|
||||
*/
|
||||
public class AboutDialog extends Dialog {
|
||||
|
||||
protected int result;
|
||||
protected Shell shell;
|
||||
private Color white;
|
||||
protected StyledText styledText;
|
||||
/*
|
||||
Eclipse IDE for Java Developers
|
||||
|
||||
Version: Mars.1 Release (4.5.1)
|
||||
Build id: 20150924-1200
|
||||
(c) Copyright Eclipse contributors and others 2000, 2015. All rights reserved. Eclipse and the Eclipse logo are trademarks of the Eclipse Foundation, Inc., https://www.eclipse.org/. The Eclipse logo cannot be altered without Eclipse's permission. Eclipse logos are provided for use under the Eclipse logo and trademark guidelines, https://www.eclipse.org/logotm/. Oracle and Java are trademarks or registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
|
||||
*/
|
||||
/** The product title. */
|
||||
private String productTitle=
|
||||
"\nSCViewer - a SystemC waveform viewer\n\nVersion: 1.0\n";
|
||||
|
||||
/** The copyright text. */
|
||||
private String copyrightText="\nCopyright (c) 2015 MINRES Technologies GmbH and others.\n"+
|
||||
"\n"+
|
||||
"All rights reserved. MINRES and the MINRES logo are trademarks of MINRES Technologies GmbH, http://www.minres.com/ . "+
|
||||
"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\n";
|
||||
"which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html\n"+
|
||||
"\n\nSources code is hosted at GitHub: https://github.com/eyck/txviewer\n";
|
||||
|
||||
/**
|
||||
* Create the dialog.
|
||||
* @param parent
|
||||
* @param style
|
||||
*
|
||||
* @param parentShell the parent shell
|
||||
*/
|
||||
public AboutDialog(Shell parent, int style) {
|
||||
super(parent, style);
|
||||
setText("SWT Dialog");
|
||||
white=SWTResourceManager.getColor(SWT.COLOR_WHITE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Open the dialog.
|
||||
* @return the result
|
||||
*/
|
||||
public int open() {
|
||||
createContents();
|
||||
shell.open();
|
||||
shell.layout();
|
||||
Display display = getParent().getDisplay();
|
||||
while (!shell.isDisposed()) {
|
||||
if (!display.readAndDispatch()) {
|
||||
display.sleep();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@Inject
|
||||
public AboutDialog(Shell parentShell) {
|
||||
super(parentShell);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create contents of the dialog.
|
||||
*
|
||||
* @param parent the parent
|
||||
* @return the control
|
||||
*/
|
||||
private void createContents() {
|
||||
shell = new Shell(getParent(), getStyle());
|
||||
shell.setSize(600, 300);
|
||||
shell.setText(getText());
|
||||
shell.setLayout(new GridLayout(2, false));
|
||||
@Override
|
||||
protected Control createDialogArea(Composite parent) {
|
||||
Composite composite = new Composite(parent, SWT.NONE);
|
||||
GridData gd_composite = new GridData(SWT.LEFT, SWT.FILL, true, true);
|
||||
gd_composite.widthHint = 600;
|
||||
gd_composite.heightHint =250;
|
||||
composite.setLayoutData(gd_composite);
|
||||
composite.setLayout(new GridLayout(2, false));
|
||||
|
||||
final Color white=SWTResourceManager.getColor(SWT.COLOR_WHITE);
|
||||
final Image scviewerLogo=ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/SCViewer_logo.png");
|
||||
final Image minresLogo=ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/Minres_logo.png");
|
||||
|
||||
Canvas canvas = new Canvas(shell,SWT.NO_REDRAW_RESIZE);
|
||||
Canvas canvas = new Canvas(composite,SWT.NO_REDRAW_RESIZE);
|
||||
GridData gd_canvas = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
|
||||
gd_canvas.widthHint = 200;
|
||||
gd_canvas.heightHint =250;
|
||||
@ -114,7 +101,7 @@ Build id: 20150924-1200
|
||||
}
|
||||
});
|
||||
|
||||
styledText = new StyledText(shell, SWT.BORDER);
|
||||
StyledText styledText = new StyledText(composite, SWT.BORDER);
|
||||
styledText.setEditable(false);
|
||||
GridData gd_styledText = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
|
||||
styledText.setLayoutData(gd_styledText);
|
||||
@ -150,8 +137,8 @@ Build id: 20150924-1200
|
||||
// links are activated on mouse down when the control key is held down
|
||||
// if ((event.stateMask & SWT.MOD1) != 0) {
|
||||
try {
|
||||
int offset = styledText.getOffsetAtLocation(new Point (event.x, event.y));
|
||||
StyleRange style = styledText.getStyleRangeAtOffset(offset);
|
||||
int offset = ((StyledText)event.widget).getOffsetAtLocation(new Point (event.x, event.y));
|
||||
StyleRange style = ((StyledText)event.widget).getStyleRangeAtOffset(offset);
|
||||
if (style != null && style.underline && style.underlineStyle == SWT.UNDERLINE_LINK) {
|
||||
Desktop.getDesktop().browse(new java.net.URI(style.data.toString()));
|
||||
}
|
||||
@ -161,23 +148,25 @@ Build id: 20150924-1200
|
||||
});
|
||||
|
||||
styleRange.start = 0;
|
||||
new Label(shell, SWT.NONE);
|
||||
|
||||
Button okButton = new Button(shell, SWT.NONE);
|
||||
okButton.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
|
||||
okButton.setBounds(0, 0, 94, 28);
|
||||
okButton.setText("Close");
|
||||
okButton.setFocus();
|
||||
okButton.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
if(!shell.isDisposed()) shell.dispose();
|
||||
}
|
||||
});
|
||||
return composite;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
|
||||
*/
|
||||
protected void createButtonsForButtonBar(Composite parent) {
|
||||
// create OK button
|
||||
createButton(parent, IDialogConstants.OK_ID, IDialogConstants.CLOSE_LABEL, true);
|
||||
}
|
||||
|
||||
public static boolean open(Shell parent, int style) {
|
||||
AboutDialog dialog = new AboutDialog(parent, style | SWT.SHEET);
|
||||
return dialog.open() == 0;
|
||||
/**
|
||||
* Open the dialog.
|
||||
* @return the result
|
||||
*/
|
||||
@PostConstruct
|
||||
@Override
|
||||
public int open() {
|
||||
return super.open();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -72,36 +72,55 @@ import com.minres.scviewer.e4.application.handlers.AddWaveformHandler;
|
||||
import com.minres.scviewer.e4.application.provider.TxDbContentProvider;
|
||||
import com.minres.scviewer.e4.application.provider.TxDbLabelProvider;
|
||||
|
||||
/**
|
||||
* The Class DesignBrowser. It contains the design tree, a list of Streams & signals and a few buttons to
|
||||
* add them them to the waveform view
|
||||
*/
|
||||
public class DesignBrowser {
|
||||
|
||||
/** The Constant POPUP_ID. */
|
||||
private static final String POPUP_ID="com.minres.scviewer.e4.application.parts.DesignBrowser.popupmenu";
|
||||
|
||||
/** The event broker. */
|
||||
@Inject IEventBroker eventBroker;
|
||||
|
||||
/** The selection service. */
|
||||
@Inject ESelectionService selectionService;
|
||||
|
||||
/** The menu service. */
|
||||
@Inject EMenuService menuService;
|
||||
|
||||
/** The eclipse ctx. */
|
||||
@Inject IEclipseContext eclipseCtx;
|
||||
|
||||
/** The sash form. */
|
||||
private SashForm sashForm;
|
||||
|
||||
/** The top. */
|
||||
Composite top;
|
||||
|
||||
/** The bottom. */
|
||||
private Composite bottom;
|
||||
|
||||
/** The tree viewer. */
|
||||
private TreeViewer treeViewer;
|
||||
|
||||
/** The name filter. */
|
||||
private Text nameFilter;
|
||||
|
||||
/** The tx table viewer. */
|
||||
private TableViewer txTableViewer;
|
||||
|
||||
/** The append all item. */
|
||||
ToolItem appendItem, insertItem, insertAllItem, appendAllItem;
|
||||
|
||||
/** The attribute filter. */
|
||||
WaveformAttributeFilter attributeFilter;
|
||||
|
||||
/** The other selection count. */
|
||||
int thisSelectionCount=0, otherSelectionCount=0;
|
||||
|
||||
/** The tree viewer pcl. */
|
||||
private PropertyChangeListener treeViewerPCL = new PropertyChangeListener() {
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent evt) {
|
||||
@ -116,8 +135,10 @@ public class DesignBrowser {
|
||||
}
|
||||
};
|
||||
|
||||
private WaveformViewerPart waveformViewerPart;
|
||||
/** The waveform viewer part. */
|
||||
private WaveformViewer waveformViewerPart;
|
||||
|
||||
/** The sash paint listener. */
|
||||
protected PaintListener sashPaintListener=new PaintListener() {
|
||||
@Override
|
||||
public void paintControl(PaintEvent e) {
|
||||
@ -132,6 +153,11 @@ public class DesignBrowser {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Creates the composite.
|
||||
*
|
||||
* @param parent the parent
|
||||
*/
|
||||
@PostConstruct
|
||||
public void createComposite(Composite parent) {
|
||||
sashForm = new SashForm(parent, SWT.BORDER | SWT.SMOOTH | SWT.VERTICAL);
|
||||
@ -151,6 +177,11 @@ public class DesignBrowser {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the tree viewer composite.
|
||||
*
|
||||
* @param parent the parent
|
||||
*/
|
||||
public void createTreeViewerComposite(Composite parent) {
|
||||
parent.setLayout(new GridLayout(1, false));
|
||||
treeViewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
|
||||
@ -175,6 +206,11 @@ public class DesignBrowser {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the table composite.
|
||||
*
|
||||
* @param parent the parent
|
||||
*/
|
||||
public void createTableComposite(Composite parent) {
|
||||
parent.setLayout(new GridLayout(1, false));
|
||||
|
||||
@ -293,6 +329,9 @@ public class DesignBrowser {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the focus.
|
||||
*/
|
||||
@Focus
|
||||
public void setFocus() {
|
||||
txTableViewer.getTable().setFocus();
|
||||
@ -305,9 +344,15 @@ public class DesignBrowser {
|
||||
updateButtons();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the status event.
|
||||
*
|
||||
* @param waveformViewerPart the waveform viewer part
|
||||
* @return the status event
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Inject @Optional
|
||||
public void getStatusEvent(@UIEventTopic(WaveformViewerPart.ACTIVE_WAVEFORMVIEW) WaveformViewerPart waveformViewerPart) {
|
||||
public void getActiveWaveformViewerEvent(@UIEventTopic(WaveformViewer.ACTIVE_WAVEFORMVIEW) WaveformViewer waveformViewerPart) {
|
||||
if(this.waveformViewerPart!=null)
|
||||
this.waveformViewerPart.storeDesignBrowerState(new DBState());
|
||||
this.waveformViewerPart=waveformViewerPart;
|
||||
@ -318,7 +363,7 @@ public class DesignBrowser {
|
||||
if(db==database) return; // do nothing if old and new daabase is the same
|
||||
((List<IWaveformDb>)input).get(0).removePropertyChangeListener(treeViewerPCL);
|
||||
}
|
||||
treeViewer.setInput(database.isLoaded()?Arrays.asList(new IWaveformDb[]{database}):null);
|
||||
treeViewer.setInput(Arrays.asList(database.isLoaded()?new IWaveformDb[]{database}:new IWaveformDb[]{new LoadingWaveformDb()}));
|
||||
Object state=this.waveformViewerPart.retrieveDesignBrowerState();
|
||||
if(state!=null && state instanceof DBState)
|
||||
((DBState)state).apply();
|
||||
@ -328,6 +373,12 @@ public class DesignBrowser {
|
||||
database.addPropertyChangeListener(treeViewerPCL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the selection.
|
||||
*
|
||||
* @param selection the selection
|
||||
* @param partService the part service
|
||||
*/
|
||||
@Inject
|
||||
public void setSelection(@Named(IServiceConstants.ACTIVE_SELECTION) @Optional IStructuredSelection selection, EPartService partService){
|
||||
MPart part = partService.getActivePart();
|
||||
@ -342,6 +393,9 @@ public class DesignBrowser {
|
||||
updateButtons();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update buttons.
|
||||
*/
|
||||
private void updateButtons() {
|
||||
if(txTableViewer!=null && !insertItem.isDisposed() && !appendItem.isDisposed() &&
|
||||
!appendAllItem.isDisposed() && !insertAllItem.isDisposed()){
|
||||
@ -357,14 +411,26 @@ public class DesignBrowser {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The Class WaveformAttributeFilter.
|
||||
*/
|
||||
public class WaveformAttributeFilter extends ViewerFilter {
|
||||
|
||||
/** The search string. */
|
||||
private String searchString;
|
||||
|
||||
/**
|
||||
* Sets the search text.
|
||||
*
|
||||
* @param s the new search text
|
||||
*/
|
||||
public void setSearchText(String s) {
|
||||
this.searchString = ".*" + s + ".*";
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean select(Viewer viewer, Object parentElement, Object element) {
|
||||
if (searchString == null || searchString.length() == 0) {
|
||||
@ -378,6 +444,12 @@ public class DesignBrowser {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the filtered children.
|
||||
*
|
||||
* @param viewer the viewer
|
||||
* @return the filtered children
|
||||
*/
|
||||
protected Object[] getFilteredChildren(TableViewer viewer){
|
||||
Object parent = viewer.getInput();
|
||||
if(parent==null) return new Object[0];
|
||||
@ -402,32 +474,60 @@ public class DesignBrowser {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run command.
|
||||
*
|
||||
* @param handler the handler
|
||||
* @param annotation the annotation
|
||||
* @param where the where
|
||||
* @param all the all
|
||||
* @return the object
|
||||
*/
|
||||
protected Object runCommand(AddWaveformHandler handler, Class<? extends Annotation> annotation, String where, Boolean all) {
|
||||
ContextInjectionFactory.inject(handler, eclipseCtx);
|
||||
eclipseCtx.set(AddWaveformHandler.PARAM_WHERE_ID, where);
|
||||
eclipseCtx.set(AddWaveformHandler.PARAM_ALL_ID, all.toString());
|
||||
eclipseCtx.set(DesignBrowser.class, this);
|
||||
eclipseCtx.set(WaveformViewerPart.class, waveformViewerPart);
|
||||
eclipseCtx.set(WaveformViewer.class, waveformViewerPart);
|
||||
Object result = ContextInjectionFactory.invoke(handler, annotation, eclipseCtx);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the filtered children.
|
||||
*
|
||||
* @return the filtered children
|
||||
*/
|
||||
public Object[] getFilteredChildren() {
|
||||
return getFilteredChildren(txTableViewer);
|
||||
}
|
||||
|
||||
public WaveformViewerPart getActiveWaveformViewerPart() {
|
||||
/**
|
||||
* Gets the active waveform viewer part.
|
||||
*
|
||||
* @return the active waveform viewer part
|
||||
*/
|
||||
public WaveformViewer getActiveWaveformViewerPart() {
|
||||
return waveformViewerPart;
|
||||
}
|
||||
|
||||
/**
|
||||
* The Class DBState.
|
||||
*/
|
||||
class DBState {
|
||||
|
||||
/**
|
||||
* Instantiates a new DB state.
|
||||
*/
|
||||
public DBState() {
|
||||
this.expandedElements=treeViewer.getExpandedElements();
|
||||
this.treeSelection=treeViewer.getSelection();
|
||||
this.tableSelection=txTableViewer.getSelection();
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply.
|
||||
*/
|
||||
public void apply() {
|
||||
treeViewer.setExpandedElements(expandedElements);
|
||||
treeViewer.setSelection(treeSelection, true);
|
||||
@ -435,8 +535,13 @@ public class DesignBrowser {
|
||||
|
||||
}
|
||||
|
||||
/** The expanded elements. */
|
||||
private Object[] expandedElements;
|
||||
|
||||
/** The tree selection. */
|
||||
private ISelection treeSelection;
|
||||
|
||||
/** The table selection. */
|
||||
private ISelection tableSelection;
|
||||
}
|
||||
};
|
@ -0,0 +1,88 @@
|
||||
package com.minres.scviewer.e4.application.parts;
|
||||
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.minres.scviewer.database.IHierNode;
|
||||
import com.minres.scviewer.database.IWaveform;
|
||||
import com.minres.scviewer.database.IWaveformDb;
|
||||
import com.minres.scviewer.database.IWaveformEvent;
|
||||
import com.minres.scviewer.database.RelationType;
|
||||
|
||||
public class LoadingWaveformDb implements IWaveformDb {
|
||||
|
||||
private final String label = "Database loading...";
|
||||
|
||||
@Override
|
||||
public void addPropertyChangeListener(PropertyChangeListener l) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePropertyChangeListener(PropertyChangeListener l) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFullName() {
|
||||
return label;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return label;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setName(String name) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParentName(String name) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IHierNode> getChildNodes() {
|
||||
return new ArrayList<IHierNode>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(IHierNode o) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getMaxTime() {
|
||||
return new Long(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWaveform<? extends IWaveformEvent> getStreamByName(String name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IWaveform<?>> getAllWaves() {
|
||||
return new ArrayList<IWaveform<?>>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RelationType> getAllRelationTypes() {
|
||||
return new ArrayList<RelationType>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean load(File inp) throws Exception {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLoaded() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
}
|
||||
|
||||
}
|
@ -13,19 +13,46 @@ package com.minres.scviewer.e4.application.parts;
|
||||
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
|
||||
import org.eclipse.e4.ui.workbench.modeling.IPartListener;
|
||||
|
||||
/**
|
||||
* The default implementation of a {@link IPartListener}.
|
||||
* The class that is interested in processing a part
|
||||
* event extends this class overriding the respective method, and the object created
|
||||
* with that class is registered with a component using the
|
||||
* component's <code>addPartListener<code> method. When
|
||||
* the part event occurs, that object's appropriate
|
||||
* method is invoked.
|
||||
*
|
||||
* @see PartEvent
|
||||
*/
|
||||
public class PartListener implements IPartListener {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.e4.ui.workbench.modeling.IPartListener#partBroughtToTop(org.eclipse.e4.ui.model.application.ui.basic.MPart)
|
||||
*/
|
||||
@Override
|
||||
public void partBroughtToTop(MPart part) {}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.e4.ui.workbench.modeling.IPartListener#partActivated(org.eclipse.e4.ui.model.application.ui.basic.MPart)
|
||||
*/
|
||||
@Override
|
||||
public void partActivated(MPart part) {}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.e4.ui.workbench.modeling.IPartListener#partDeactivated(org.eclipse.e4.ui.model.application.ui.basic.MPart)
|
||||
*/
|
||||
@Override
|
||||
public void partDeactivated(MPart part) {}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.e4.ui.workbench.modeling.IPartListener#partHidden(org.eclipse.e4.ui.model.application.ui.basic.MPart)
|
||||
*/
|
||||
@Override
|
||||
public void partHidden(MPart part) {}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.e4.ui.workbench.modeling.IPartListener#partVisible(org.eclipse.e4.ui.model.application.ui.basic.MPart)
|
||||
*/
|
||||
@Override
|
||||
public void partVisible(MPart part) {}
|
||||
}
|
@ -57,32 +57,51 @@ import com.minres.scviewer.database.ITxAttribute;
|
||||
import com.minres.scviewer.database.ITxRelation;
|
||||
import com.minres.scviewer.e4.application.provider.TxPropertiesLabelProvider;
|
||||
|
||||
/**
|
||||
* The Class TransactionDetails shows the details of a selected transaction.
|
||||
*/
|
||||
public class TransactionDetails {
|
||||
|
||||
/** The Constant COLUMN_FIRST. */
|
||||
// Column constants
|
||||
public static final int COLUMN_FIRST = 0;
|
||||
|
||||
/** The Constant COLUMN_SECOND. */
|
||||
public static final int COLUMN_SECOND = 1;
|
||||
|
||||
/** The Constant COLUMN_THIRD. */
|
||||
public static final int COLUMN_THIRD = 2;
|
||||
|
||||
/** The event broker. */
|
||||
@Inject IEventBroker eventBroker;
|
||||
|
||||
/** The selection service. */
|
||||
@Inject ESelectionService selectionService;
|
||||
|
||||
/** The name filter. */
|
||||
private Text nameFilter;
|
||||
|
||||
/** The tree viewer. */
|
||||
private TreeViewer treeViewer;
|
||||
|
||||
/** The col3. */
|
||||
private TreeViewerColumn col1, col2, col3;
|
||||
|
||||
/** The attribute filter. */
|
||||
TxAttributeFilter attributeFilter;
|
||||
|
||||
/** The view sorter. */
|
||||
TxAttributeViewerSorter viewSorter;
|
||||
|
||||
private WaveformViewerPart waveformViewerPart;
|
||||
/** The waveform viewer part. */
|
||||
private WaveformViewer waveformViewerPart;
|
||||
|
||||
|
||||
/**
|
||||
* Creates the composite.
|
||||
*
|
||||
* @param parent the parent
|
||||
*/
|
||||
@PostConstruct
|
||||
public void createComposite(final Composite parent) {
|
||||
parent.setLayout(new GridLayout(1, false));
|
||||
@ -207,16 +226,30 @@ public class TransactionDetails {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the focus.
|
||||
*/
|
||||
@Focus
|
||||
public void setFocus() {
|
||||
treeViewer.getTree().setFocus();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the status event.
|
||||
*
|
||||
* @param part the part
|
||||
* @return the status event
|
||||
*/
|
||||
@Inject @Optional
|
||||
public void getStatusEvent(@UIEventTopic(WaveformViewerPart.ACTIVE_WAVEFORMVIEW) WaveformViewerPart part) {
|
||||
public void getStatusEvent(@UIEventTopic(WaveformViewer.ACTIVE_WAVEFORMVIEW) WaveformViewer part) {
|
||||
this.waveformViewerPart=part;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the selection.
|
||||
*
|
||||
* @param selection the new selection
|
||||
*/
|
||||
@Inject
|
||||
public void setSelection(@Named(IServiceConstants.ACTIVE_SELECTION) @Optional IStructuredSelection selection){
|
||||
if(treeViewer!=null && selection!=null && !treeViewer.getTree().isDisposed()){
|
||||
@ -231,10 +264,22 @@ public class TransactionDetails {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Time to string.
|
||||
*
|
||||
* @param time the time
|
||||
* @return the string
|
||||
*/
|
||||
String timeToString(Long time){
|
||||
return waveformViewerPart.getScaledTime(time);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tx to string.
|
||||
*
|
||||
* @param tx the tx
|
||||
* @return the string
|
||||
*/
|
||||
String txToString(ITx tx){
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("tx#").append(tx.getId()).append("[").append(timeToString(tx.getBeginTime())).
|
||||
@ -242,21 +287,29 @@ public class TransactionDetails {
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* The Class TxAttributeViewerSorter.
|
||||
*/
|
||||
class TxAttributeViewerSorter extends ViewerSorter {
|
||||
|
||||
/** The Constant ASCENDING. */
|
||||
private static final int ASCENDING = 0;
|
||||
|
||||
/** The Constant DESCENDING. */
|
||||
private static final int DESCENDING = 1;
|
||||
|
||||
/** The column. */
|
||||
private int column;
|
||||
|
||||
/** The direction. */
|
||||
private int direction;
|
||||
|
||||
/**
|
||||
* Does the sort. If it's a different column from the previous sort, do an
|
||||
* ascending sort. If it's the same column as the last sort, toggle the sort
|
||||
* direction.
|
||||
*
|
||||
* @param column
|
||||
*
|
||||
* @param column the column
|
||||
*/
|
||||
public void doSort(int column) {
|
||||
if (column == this.column) {
|
||||
@ -270,7 +323,12 @@ public class TransactionDetails {
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares the object for sorting
|
||||
* Compares the object for sorting.
|
||||
*
|
||||
* @param viewer the viewer
|
||||
* @param e1 the e1
|
||||
* @param e2 the e2
|
||||
* @return the int
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public int compare(Viewer viewer, Object e1, Object e2) {
|
||||
@ -297,14 +355,26 @@ public class TransactionDetails {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The Class TxAttributeFilter.
|
||||
*/
|
||||
class TxAttributeFilter extends ViewerFilter {
|
||||
|
||||
/** The search string. */
|
||||
private String searchString;
|
||||
|
||||
/**
|
||||
* Sets the search text.
|
||||
*
|
||||
* @param s the new search text
|
||||
*/
|
||||
public void setSearchText(String s) {
|
||||
this.searchString = ".*" + s + ".*";
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean select(Viewer viewer, Object parentElement, Object element) {
|
||||
if (searchString == null || searchString.length() == 0) {
|
||||
@ -321,17 +391,40 @@ public class TransactionDetails {
|
||||
}
|
||||
}
|
||||
|
||||
enum Type {PROPS, ATTRS, IN_REL, OUT_REL}
|
||||
/**
|
||||
* The Enum Type.
|
||||
*/
|
||||
enum Type {/** The props. */
|
||||
PROPS, /** The attrs. */
|
||||
ATTRS, /** The in rel. */
|
||||
IN_REL, /** The out rel. */
|
||||
OUT_REL}
|
||||
|
||||
/**
|
||||
* The Class TreeNode.
|
||||
*/
|
||||
class TreeNode{
|
||||
|
||||
/** The type. */
|
||||
public Type type;
|
||||
|
||||
/** The element. */
|
||||
public ITx element;
|
||||
|
||||
/**
|
||||
* Instantiates a new tree node.
|
||||
*
|
||||
* @param element the element
|
||||
* @param type the type
|
||||
*/
|
||||
public TreeNode(ITx element, Type type){
|
||||
this.element=element;
|
||||
this.type=type;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
public String toString(){
|
||||
switch(type){
|
||||
case PROPS: return "Properties";
|
||||
@ -343,15 +436,27 @@ public class TransactionDetails {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The Class TransactionTreeContentProvider.
|
||||
*/
|
||||
class TransactionTreeContentProvider implements ITreeContentProvider {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.IContentProvider#dispose()
|
||||
*/
|
||||
@Override
|
||||
public void dispose() { }
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.ITreeContentProvider#getElements(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public Object[] getElements(Object element) {
|
||||
return new Object[]{
|
||||
@ -362,6 +467,9 @@ public class TransactionDetails {
|
||||
};
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public Object[] getChildren(Object element) {
|
||||
if(element instanceof TreeNode){
|
||||
@ -398,11 +506,17 @@ public class TransactionDetails {
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public Object getParent(Object element) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean hasChildren(Object element) {
|
||||
return getChildren(element)!=null;
|
||||
@ -410,16 +524,35 @@ public class TransactionDetails {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The Class AttributeLabelProvider.
|
||||
*/
|
||||
class AttributeLabelProvider extends LabelProvider implements IStyledLabelProvider {
|
||||
|
||||
/** The field. */
|
||||
final int field;
|
||||
|
||||
/** The Constant NAME. */
|
||||
public static final int NAME=0;
|
||||
|
||||
/** The Constant TYPE. */
|
||||
public static final int TYPE=1;
|
||||
|
||||
/** The Constant VALUE. */
|
||||
public static final int VALUE=2;
|
||||
|
||||
/**
|
||||
* Instantiates a new attribute label provider.
|
||||
*
|
||||
* @param field the field
|
||||
*/
|
||||
public AttributeLabelProvider(int field) {
|
||||
this.field=field;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider#getStyledText(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public StyledString getStyledText(Object element) {
|
||||
switch(field){
|
||||
|
@ -13,12 +13,17 @@ package com.minres.scviewer.e4.application.parts;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Properties;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@ -76,66 +81,112 @@ import com.minres.scviewer.e4.application.internal.util.IModificationChecker;
|
||||
import com.minres.scviewer.e4.application.preferences.DefaultValuesInitializer;
|
||||
import com.minres.scviewer.e4.application.preferences.PreferenceConstants;
|
||||
|
||||
/**
|
||||
* The Class WaveformViewerPart.
|
||||
*/
|
||||
@SuppressWarnings("restriction")
|
||||
public class WaveformViewerPart implements IFileChangeListener, IPreferenceChangeListener {
|
||||
public class WaveformViewer implements IFileChangeListener, IPreferenceChangeListener {
|
||||
|
||||
/** The Constant ACTIVE_WAVEFORMVIEW. */
|
||||
public static final String ACTIVE_WAVEFORMVIEW = "Active_Waveform_View";
|
||||
|
||||
/** The Constant ADD_WAVEFORM. */
|
||||
public static final String ADD_WAVEFORM = "AddWaveform";
|
||||
|
||||
/** The Constant DATABASE_FILE. */
|
||||
protected static final String DATABASE_FILE = "DATABASE_FILE";
|
||||
|
||||
/** The Constant SHOWN_WAVEFORM. */
|
||||
protected static final String SHOWN_WAVEFORM = "SHOWN_WAVEFORM";
|
||||
|
||||
/** The Constant SHOWN_CURSOR. */
|
||||
protected static final String SHOWN_CURSOR = "SHOWN_CURSOR";
|
||||
|
||||
/** The Constant ZOOM_LEVEL. */
|
||||
protected static final String ZOOM_LEVEL = "ZOOM_LEVEL";
|
||||
|
||||
/** The Constant BASE_LINE_TIME. */
|
||||
protected static final String BASE_LINE_TIME = "BASE_LINE_TIME";
|
||||
|
||||
/** The Constant FILE_CHECK_INTERVAL. */
|
||||
protected static final long FILE_CHECK_INTERVAL = 60000;
|
||||
|
||||
/** The zoom level. */
|
||||
private String[] zoomLevel;
|
||||
|
||||
/** The Constant ID. */
|
||||
public static final String ID = "com.minres.scviewer.ui.TxEditorPart"; //$NON-NLS-1$
|
||||
|
||||
/** The Constant WAVE_ACTION_ID. */
|
||||
public static final String WAVE_ACTION_ID = "com.minres.scviewer.ui.action.AddToWave";
|
||||
|
||||
/** The factory. */
|
||||
WaveformViewerFactory factory = new WaveformViewerFactory();
|
||||
|
||||
/** The waveform pane. */
|
||||
private IWaveformViewer waveformPane;
|
||||
|
||||
/** The event broker. */
|
||||
@Inject
|
||||
private IEventBroker eventBroker;
|
||||
|
||||
/** The menu service. */
|
||||
@Inject
|
||||
EMenuService menuService;
|
||||
|
||||
/** The selection service. */
|
||||
@Inject
|
||||
ESelectionService selectionService;
|
||||
|
||||
/** The e part service. */
|
||||
@Inject
|
||||
EPartService ePartService;
|
||||
|
||||
/** The prefs. */
|
||||
@Inject
|
||||
@Preference(nodePath = PreferenceConstants.PREFERENCES_SCOPE)
|
||||
IEclipsePreferences prefs;
|
||||
|
||||
/** The database. */
|
||||
private IWaveformDb database;
|
||||
|
||||
/** The check for updates. */
|
||||
private boolean checkForUpdates;
|
||||
|
||||
/** The my part. */
|
||||
private MPart myPart;
|
||||
|
||||
/** The my parent. */
|
||||
private Composite myParent;
|
||||
|
||||
/** The files to load. */
|
||||
ArrayList<File> filesToLoad;
|
||||
|
||||
/** The persisted state. */
|
||||
Map<String, String> persistedState;
|
||||
|
||||
/** The browser state. */
|
||||
private Object browserState;
|
||||
|
||||
/** The details settings. */
|
||||
private Object detailsSettings;
|
||||
|
||||
/** The navigation relation type. */
|
||||
private RelationType navigationRelationType=IWaveformViewer.NEXT_PREV_IN_STREAM ;
|
||||
|
||||
/** The file monitor. */
|
||||
FileMonitor fileMonitor = new FileMonitor();
|
||||
|
||||
/** The file checker. */
|
||||
IModificationChecker fileChecker;
|
||||
|
||||
/**
|
||||
* Creates the composite.
|
||||
*
|
||||
* @param part the part
|
||||
* @param parent the parent
|
||||
* @param dbFactory the db factory
|
||||
*/
|
||||
@PostConstruct
|
||||
public void createComposite(MPart part, Composite parent, IWaveformDbFactory dbFactory) {
|
||||
myPart = part;
|
||||
@ -161,7 +212,7 @@ public class WaveformViewerPart implements IFileChangeListener, IPreferenceChang
|
||||
public void propertyChange(PropertyChangeEvent evt) {
|
||||
Long time = (Long) evt.getNewValue();
|
||||
eventBroker.post(WaveStatusBarControl.CURSOR_TIME, waveformPane.getScaledTime(time));
|
||||
long marker = waveformPane.getSelectedMarkerTime();
|
||||
long marker = waveformPane.getMarkerTime(waveformPane.getSelectedMarkerId());
|
||||
eventBroker.post(WaveStatusBarControl.MARKER_DIFF, waveformPane.getScaledTime(time - marker));
|
||||
|
||||
}
|
||||
@ -214,13 +265,16 @@ public class WaveformViewerPart implements IFileChangeListener, IPreferenceChang
|
||||
prefs.addPreferenceChangeListener(this);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener#preferenceChange(org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent)
|
||||
*/
|
||||
@Override
|
||||
public void preferenceChange(PreferenceChangeEvent event) {
|
||||
if (PreferenceConstants.DATABASE_RELOAD.equals(event.getKey())) {
|
||||
checkForUpdates = (Boolean) event.getNewValue();
|
||||
fileChecker = null;
|
||||
if (checkForUpdates)
|
||||
fileChecker = fileMonitor.addFileChangeListener(WaveformViewerPart.this, filesToLoad,
|
||||
fileChecker = fileMonitor.addFileChangeListener(WaveformViewer.this, filesToLoad,
|
||||
FILE_CHECK_INTERVAL);
|
||||
else
|
||||
fileMonitor.removeFileChangeListener(this);
|
||||
@ -229,6 +283,9 @@ public class WaveformViewerPart implements IFileChangeListener, IPreferenceChang
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup colors.
|
||||
*/
|
||||
protected void setupColors() {
|
||||
DefaultValuesInitializer initializer = new DefaultValuesInitializer();
|
||||
HashMap<WaveformColors, RGB> colorPref = new HashMap<>();
|
||||
@ -241,24 +298,28 @@ public class WaveformViewerPart implements IFileChangeListener, IPreferenceChang
|
||||
waveformPane.setColors(colorPref);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load database.
|
||||
*
|
||||
* @param state the state
|
||||
*/
|
||||
protected void loadDatabase(final Map<String, String> state) {
|
||||
fileMonitor.removeFileChangeListener(this);
|
||||
Job job = new Job(" My Job") {
|
||||
Job job = new Job("Database Load Job") {
|
||||
@Override
|
||||
protected IStatus run(IProgressMonitor monitor) {
|
||||
// convert to SubMonitor and set total number of work units
|
||||
SubMonitor subMonitor = SubMonitor.convert(monitor, filesToLoad.size());
|
||||
subMonitor.setTaskName("Loading database");
|
||||
SubMonitor subMonitor = SubMonitor.convert(monitor, filesToLoad.size()+1);
|
||||
try {
|
||||
subMonitor.worked(1);
|
||||
for (File file : filesToLoad) {
|
||||
// TimeUnit.SECONDS.sleep(2);
|
||||
subMonitor.setTaskName("Loading "+file.getName());
|
||||
database.load(file);
|
||||
database.addPropertyChangeListener(waveformPane);
|
||||
subMonitor.worked(1);
|
||||
if (monitor.isCanceled())
|
||||
return Status.CANCEL_STATUS;
|
||||
}
|
||||
// sleep a second
|
||||
} catch (Exception e) {
|
||||
database = null;
|
||||
e.printStackTrace();
|
||||
@ -281,7 +342,7 @@ public class WaveformViewerPart implements IFileChangeListener, IPreferenceChang
|
||||
restoreWaveformViewerState(state);
|
||||
fileChecker = null;
|
||||
if (checkForUpdates)
|
||||
fileChecker = fileMonitor.addFileChangeListener(WaveformViewerPart.this, filesToLoad,
|
||||
fileChecker = fileMonitor.addFileChangeListener(WaveformViewer.this, filesToLoad,
|
||||
FILE_CHECK_INTERVAL);
|
||||
}
|
||||
});
|
||||
@ -290,6 +351,9 @@ public class WaveformViewerPart implements IFileChangeListener, IPreferenceChang
|
||||
job.schedule(0);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.minres.scviewer.e4.application.internal.util.IFileChangeListener#fileChanged(java.util.List)
|
||||
*/
|
||||
@Override
|
||||
public void fileChanged(List<File> file) {
|
||||
final Display display = myParent.getDisplay();
|
||||
@ -307,8 +371,14 @@ public class WaveformViewerPart implements IFileChangeListener, IPreferenceChang
|
||||
}
|
||||
}
|
||||
});
|
||||
fileMonitor.removeFileChangeListener(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the part input.
|
||||
*
|
||||
* @param partInput the new part input
|
||||
*/
|
||||
@Inject
|
||||
@Optional
|
||||
public void setPartInput(@Named("input") Object partInput) {
|
||||
@ -338,11 +408,19 @@ public class WaveformViewerPart implements IFileChangeListener, IPreferenceChang
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the focus.
|
||||
*/
|
||||
@Focus
|
||||
public void setFocus() {
|
||||
myParent.setFocus();
|
||||
}
|
||||
|
||||
/**
|
||||
* Save state.
|
||||
*
|
||||
* @param part the part
|
||||
*/
|
||||
@PersistState
|
||||
public void saveState(MPart part) {
|
||||
// save changes
|
||||
@ -356,6 +434,45 @@ public class WaveformViewerPart implements IFileChangeListener, IPreferenceChang
|
||||
saveWaveformViewerState(persistedState);
|
||||
}
|
||||
|
||||
public void saveState(String fileName){
|
||||
Map<String, String> persistedState = new HashMap<>();
|
||||
persistedState.put(DATABASE_FILE + "S", Integer.toString(filesToLoad.size()));
|
||||
Integer index = 0;
|
||||
for (File file : filesToLoad) {
|
||||
persistedState.put(DATABASE_FILE + index, file.getAbsolutePath());
|
||||
index++;
|
||||
}
|
||||
saveWaveformViewerState(persistedState);
|
||||
Properties props = new Properties();
|
||||
props.putAll(persistedState);
|
||||
try {
|
||||
FileOutputStream out = new FileOutputStream(fileName);
|
||||
props.store(out, "Written by SCViewer");
|
||||
out.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void loadState(String fileName){
|
||||
Properties props = new Properties();
|
||||
try {
|
||||
FileInputStream in = new FileInputStream(fileName);
|
||||
props.load(in);
|
||||
in.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
HashMap<String, String> propMap = new HashMap<String, String>((Map) props);
|
||||
restoreWaveformViewerState(propMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save waveform viewer state.
|
||||
*
|
||||
* @param persistedState the persisted state
|
||||
*/
|
||||
protected void saveWaveformViewerState(Map<String, String> persistedState) {
|
||||
Integer index;
|
||||
persistedState.put(SHOWN_WAVEFORM + "S", Integer.toString(waveformPane.getStreamList().size()));
|
||||
@ -372,11 +489,16 @@ public class WaveformViewerPart implements IFileChangeListener, IPreferenceChang
|
||||
index++;
|
||||
}
|
||||
persistedState.put(ZOOM_LEVEL, Integer.toString(waveformPane.getZoomLevel()));
|
||||
persistedState.put(BASE_LINE_TIME, Long.toString(waveformPane.getBaselineTime()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore waveform viewer state.
|
||||
*
|
||||
* @param state the state
|
||||
*/
|
||||
protected void restoreWaveformViewerState(Map<String, String> state) {
|
||||
updateAll();
|
||||
Integer waves = state.containsKey(SHOWN_WAVEFORM + "S") ? Integer.parseInt(state.get(SHOWN_WAVEFORM + "S")) : 0;
|
||||
Integer waves = state.containsKey(SHOWN_WAVEFORM+"S") ? Integer.parseInt(state.get(SHOWN_WAVEFORM + "S")):0;
|
||||
List<TrackEntry> res = new LinkedList<>();
|
||||
for (int i = 0; i < waves; i++) {
|
||||
IWaveform<? extends IWaveformEvent> waveform = database.getStreamByName(state.get(SHOWN_WAVEFORM + i));
|
||||
@ -385,8 +507,7 @@ public class WaveformViewerPart implements IFileChangeListener, IPreferenceChang
|
||||
}
|
||||
if (res.size() > 0)
|
||||
waveformPane.getStreamList().addAll(res);
|
||||
Integer cursorLength = state.containsKey(SHOWN_CURSOR + "S") ? Integer.parseInt(state.get(SHOWN_CURSOR + "S"))
|
||||
: 0;
|
||||
Integer cursorLength = state.containsKey(SHOWN_CURSOR+"S")?Integer.parseInt(state.get(SHOWN_CURSOR + "S")):0;
|
||||
List<ICursor> cursors = waveformPane.getCursorList();
|
||||
if (cursorLength == cursors.size()) {
|
||||
for (int i = 0; i < cursorLength; i++) {
|
||||
@ -401,21 +522,38 @@ public class WaveformViewerPart implements IFileChangeListener, IPreferenceChang
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
}
|
||||
if (state.containsKey(BASE_LINE_TIME)) {
|
||||
try {
|
||||
Long scale = Long.parseLong(state.get(BASE_LINE_TIME));
|
||||
waveformPane.setBaselineTime(scale);
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
}
|
||||
updateAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update all status elements by posting respective events.
|
||||
*/
|
||||
private void updateAll() {
|
||||
eventBroker.post(ACTIVE_WAVEFORMVIEW, this);
|
||||
eventBroker.post(WaveStatusBarControl.ZOOM_LEVEL, zoomLevel[waveformPane.getZoomLevel()]);
|
||||
long cursor = waveformPane.getCursorTime();
|
||||
long marker = waveformPane.getSelectedMarkerTime();
|
||||
long marker = waveformPane.getMarkerTime(waveformPane.getSelectedMarkerId());
|
||||
eventBroker.post(WaveStatusBarControl.CURSOR_TIME, waveformPane.getScaledTime(cursor));
|
||||
eventBroker.post(WaveStatusBarControl.MARKER_TIME, waveformPane.getScaledTime(marker));
|
||||
eventBroker.post(WaveStatusBarControl.MARKER_DIFF, waveformPane.getScaledTime(cursor - marker));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the adds the waveform event.
|
||||
*
|
||||
* @param o the o
|
||||
* @return the adds the waveform event
|
||||
*/
|
||||
@Inject
|
||||
@Optional
|
||||
public void getAddWaveformEvent(@UIEventTopic(WaveformViewerPart.ADD_WAVEFORM) Object o) {
|
||||
public void getAddWaveformEvent(@UIEventTopic(WaveformViewer.ADD_WAVEFORM) Object o) {
|
||||
Object sel = o == null ? selectionService.getSelection() : o;
|
||||
if (sel instanceof IStructuredSelection)
|
||||
for (Object el : ((IStructuredSelection) sel).toArray()) {
|
||||
@ -424,6 +562,12 @@ public class WaveformViewerPart implements IFileChangeListener, IPreferenceChang
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ask if to load.
|
||||
*
|
||||
* @param txFile the tx file
|
||||
* @return true, if successful
|
||||
*/
|
||||
protected boolean askIfToLoad(File txFile) {
|
||||
if (txFile.exists() && MessageDialog.openQuestion(myParent.getDisplay().getActiveShell(), "Database open",
|
||||
"Would you like to open the adjacent database " + txFile.getName() + " as well?")) {
|
||||
@ -432,6 +576,13 @@ public class WaveformViewerPart implements IFileChangeListener, IPreferenceChang
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rename file extension.
|
||||
*
|
||||
* @param source the source
|
||||
* @param newExt the new ext
|
||||
* @return the string
|
||||
*/
|
||||
protected static String renameFileExtension(String source, String newExt) {
|
||||
String target;
|
||||
String currentExt = getFileExtension(source);
|
||||
@ -443,6 +594,12 @@ public class WaveformViewerPart implements IFileChangeListener, IPreferenceChang
|
||||
return target;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the file extension.
|
||||
*
|
||||
* @param f the f
|
||||
* @return the file extension
|
||||
*/
|
||||
protected static String getFileExtension(String f) {
|
||||
String ext = "";
|
||||
int i = f.lastIndexOf('.');
|
||||
@ -452,18 +609,40 @@ public class WaveformViewerPart implements IFileChangeListener, IPreferenceChang
|
||||
return ext;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the model.
|
||||
*
|
||||
* @return the model
|
||||
*/
|
||||
public IWaveformDb getModel() {
|
||||
return database;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the database.
|
||||
*
|
||||
* @return the database
|
||||
*/
|
||||
public IWaveformDb getDatabase() {
|
||||
return database;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the stream to list.
|
||||
*
|
||||
* @param obj the obj
|
||||
* @param insert the insert
|
||||
*/
|
||||
public void addStreamToList(IWaveform<? extends IWaveformEvent> obj, boolean insert) {
|
||||
addStreamsToList(new IWaveform<?>[] { obj }, insert);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the streams to list.
|
||||
*
|
||||
* @param iWaveforms the i waveforms
|
||||
* @param insert the insert
|
||||
*/
|
||||
public void addStreamsToList(IWaveform<? extends IWaveformEvent>[] iWaveforms, boolean insert) {
|
||||
List<TrackEntry> streams = new LinkedList<>();
|
||||
for (IWaveform<? extends IWaveformEvent> stream : iWaveforms)
|
||||
@ -482,33 +661,69 @@ public class WaveformViewerPart implements IFileChangeListener, IPreferenceChang
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the stream from list.
|
||||
*
|
||||
* @param stream the stream
|
||||
*/
|
||||
public void removeStreamFromList(IWaveform<? extends IWaveformEvent> stream) {
|
||||
TrackEntry trackEntry = waveformPane.getEntryForStream(stream);
|
||||
waveformPane.getStreamList().remove(trackEntry);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the streams from list.
|
||||
*
|
||||
* @param iWaveforms the i waveforms
|
||||
*/
|
||||
public void removeStreamsFromList(IWaveform<? extends IWaveformEvent>[] iWaveforms) {
|
||||
for (IWaveform<? extends IWaveformEvent> stream : iWaveforms)
|
||||
removeStreamFromList(stream);
|
||||
}
|
||||
|
||||
/**
|
||||
* Move selected.
|
||||
*
|
||||
* @param i the i
|
||||
*/
|
||||
public void moveSelected(int i) {
|
||||
waveformPane.moveSelectedTrack(i);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Move selection.
|
||||
*
|
||||
* @param direction the direction
|
||||
*/
|
||||
public void moveSelection(GotoDirection direction ) {
|
||||
moveSelection(direction, navigationRelationType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Move selection.
|
||||
*
|
||||
* @param direction the direction
|
||||
* @param relationType the relation type
|
||||
*/
|
||||
public void moveSelection(GotoDirection direction, RelationType relationType) {
|
||||
waveformPane.moveSelection(direction, relationType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Move cursor.
|
||||
*
|
||||
* @param direction the direction
|
||||
*/
|
||||
public void moveCursor(GotoDirection direction) {
|
||||
waveformPane.moveCursor(direction);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the zoom level.
|
||||
*
|
||||
* @param level the new zoom level
|
||||
*/
|
||||
public void setZoomLevel(Integer level) {
|
||||
if (level < 0)
|
||||
level = 0;
|
||||
@ -518,35 +733,92 @@ public class WaveformViewerPart implements IFileChangeListener, IPreferenceChang
|
||||
updateAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the zoom fit.
|
||||
*/
|
||||
public void setZoomFit() {
|
||||
waveformPane.setZoomLevel(6);
|
||||
updateAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the zoom level.
|
||||
*
|
||||
* @return the zoom level
|
||||
*/
|
||||
public int getZoomLevel() {
|
||||
return waveformPane.getZoomLevel();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the selection.
|
||||
*
|
||||
* @return the selection
|
||||
*/
|
||||
public ISelection getSelection() {
|
||||
return waveformPane.getSelection();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the selection.
|
||||
*
|
||||
* @param structuredSelection the new selection
|
||||
*/
|
||||
public void setSelection(IStructuredSelection structuredSelection) {
|
||||
waveformPane.setSelection(structuredSelection, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the scaled time.
|
||||
*
|
||||
* @param time the time
|
||||
* @return the scaled time
|
||||
*/
|
||||
public String getScaledTime(Long time) {
|
||||
return waveformPane.getScaledTime(time);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store design brower state.
|
||||
*
|
||||
* @param browserState the browser state
|
||||
*/
|
||||
public void storeDesignBrowerState(Object browserState) {
|
||||
this.browserState=browserState;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve design brower state.
|
||||
*
|
||||
* @return the object
|
||||
*/
|
||||
public Object retrieveDesignBrowerState() {
|
||||
return browserState;
|
||||
}
|
||||
|
||||
/**
|
||||
* Store transaction details settings
|
||||
*
|
||||
* @param detailsSettings the details settings
|
||||
*/
|
||||
public void storeDetailsSettings(Object detailsSettings) {
|
||||
this.detailsSettings=detailsSettings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve design details settings.
|
||||
*
|
||||
* @return the details settings
|
||||
*/
|
||||
public Object retrieveDetailsSettings() {
|
||||
return detailsSettings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the all relation types.
|
||||
*
|
||||
* @return the all relation types
|
||||
*/
|
||||
public List<RelationType> getAllRelationTypes() {
|
||||
List<RelationType> res =new ArrayList<>();
|
||||
res.add(IWaveformViewer.NEXT_PREV_IN_STREAM);
|
||||
@ -554,6 +826,11 @@ public class WaveformViewerPart implements IFileChangeListener, IPreferenceChang
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the selection relation types.
|
||||
*
|
||||
* @return the selection relation types
|
||||
*/
|
||||
public List<RelationType> getSelectionRelationTypes() {
|
||||
List<RelationType> res =new ArrayList<>();
|
||||
res.add(IWaveformViewer.NEXT_PREV_IN_STREAM);
|
||||
@ -575,14 +852,29 @@ public class WaveformViewerPart implements IFileChangeListener, IPreferenceChang
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the relation type filter.
|
||||
*
|
||||
* @return the relation type filter
|
||||
*/
|
||||
public RelationType getRelationTypeFilter() {
|
||||
return navigationRelationType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the navigation relation type.
|
||||
*
|
||||
* @param relationName the new navigation relation type
|
||||
*/
|
||||
public void setNavigationRelationType(String relationName) {
|
||||
setNavigationRelationType(RelationType.create(relationName));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the navigation relation type.
|
||||
*
|
||||
* @param relationType the new navigation relation type
|
||||
*/
|
||||
public void setNavigationRelationType(RelationType relationType) {
|
||||
if(navigationRelationType!=relationType) waveformPane.setHighliteRelation(relationType);
|
||||
navigationRelationType=relationType;
|
@ -21,10 +21,17 @@ import org.eclipse.wb.swt.SWTResourceManager;
|
||||
import com.minres.scviewer.database.ui.WaveformColors;
|
||||
import com.opcoach.e4.preferences.ScopedPreferenceStore;
|
||||
|
||||
/**
|
||||
* The Class DefaultValuesInitializer.
|
||||
*/
|
||||
public class DefaultValuesInitializer extends AbstractPreferenceInitializer {
|
||||
|
||||
/** The default colors. */
|
||||
public final Color[] colors = new Color[WaveformColors.values().length];
|
||||
|
||||
/**
|
||||
* Instantiates a new default values initializer.
|
||||
*/
|
||||
public DefaultValuesInitializer() {
|
||||
colors[WaveformColors.LINE.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED);
|
||||
colors[WaveformColors.LINE_HIGHLITE.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_CYAN);
|
||||
@ -48,6 +55,9 @@ public class DefaultValuesInitializer extends AbstractPreferenceInitializer {
|
||||
colors[WaveformColors.REL_ARROW_HIGHLITE.ordinal()] = SWTResourceManager.getColor(255, 128, 255);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
|
||||
*/
|
||||
@Override
|
||||
public void initializeDefaultPreferences() {
|
||||
IPreferenceStore store = new ScopedPreferenceStore(InstanceScope.INSTANCE, PreferenceConstants.PREFERENCES_SCOPE);
|
||||
|
@ -10,27 +10,69 @@
|
||||
*******************************************************************************/
|
||||
package com.minres.scviewer.e4.application.preferences;
|
||||
|
||||
/**
|
||||
* The Class PreferenceConstants for the preferences dialog & setting.
|
||||
*/
|
||||
public class PreferenceConstants {
|
||||
|
||||
/** The Constant PREFERENCES_SCOPE. */
|
||||
public static final String PREFERENCES_SCOPE="com.minres.scviewer.e4.application";
|
||||
|
||||
/** The Constant DATABASE_RELOAD. */
|
||||
public static final String DATABASE_RELOAD="databaseReload";
|
||||
|
||||
/** The Constant LINE_COLOR. */
|
||||
public static final String LINE_COLOR="LINE_COLOR";
|
||||
|
||||
/** The Constant LINE_HIGHLITE_COLOR. */
|
||||
public static final String LINE_HIGHLITE_COLOR="LINE_HIGHLITE_COLOR";
|
||||
|
||||
/** The Constant TRACK_BG_EVEN_COLOR. */
|
||||
public static final String TRACK_BG_EVEN_COLOR="TRACK_BG_EVEN_COLOR";
|
||||
|
||||
/** The Constant TRACK_BG_ODD_COLOR. */
|
||||
public static final String TRACK_BG_ODD_COLOR="TRACK_BG_ODD_COLOR";
|
||||
|
||||
/** The Constant TRACK_BG_HIGHLITE_COLOR. */
|
||||
public static final String TRACK_BG_HIGHLITE_COLOR="TRACK_BG_HIGHLITE_COLOR";
|
||||
|
||||
/** The Constant TX_BG_COLOR. */
|
||||
public static final String TX_BG_COLOR="TX_BG_COLOR";
|
||||
|
||||
/** The Constant TX_BG_HIGHLITE_COLOR. */
|
||||
public static final String TX_BG_HIGHLITE_COLOR="TX_BG_HIGHLITE_COLOR";
|
||||
|
||||
/** The Constant TX_BORDER_COLOR. */
|
||||
public static final String TX_BORDER_COLOR="TX_BORDER_COLOR";
|
||||
|
||||
/** The Constant SIGNAL0_COLOR. */
|
||||
public static final String SIGNAL0_COLOR="SIGNAL0_COLOR";
|
||||
|
||||
/** The Constant SIGNAL1_COLOR. */
|
||||
public static final String SIGNAL1_COLOR="SIGNAL1_COLOR";
|
||||
|
||||
/** The Constant SIGNALZ_COLOR. */
|
||||
public static final String SIGNALZ_COLOR="SIGNALZ_COLOR";
|
||||
|
||||
/** The Constant SIGNALX_COLOR. */
|
||||
public static final String SIGNALX_COLOR="SIGNALX_COLOR";
|
||||
|
||||
/** The Constant SIGNAL_TEXT_COLOR. */
|
||||
public static final String SIGNAL_TEXT_COLOR="SIGNAL_TEXT_COLOR";
|
||||
|
||||
/** The Constant CURSOR_COLOR. */
|
||||
public static final String CURSOR_COLOR="CURSOR_COLOR";
|
||||
|
||||
/** The Constant CURSOR_DRAG_COLOR. */
|
||||
public static final String CURSOR_DRAG_COLOR="CURSOR_DRAG_COLOR";
|
||||
|
||||
/** The Constant CURSOR_TEXT_COLOR. */
|
||||
public static final String CURSOR_TEXT_COLOR="CURSOR_TEXT_COLOR";
|
||||
|
||||
/** The Constant MARKER_COLOR. */
|
||||
public static final String MARKER_COLOR="MARKER_COLOR";
|
||||
|
||||
/** The Constant MARKER_TEXT_COLOR. */
|
||||
public static final String MARKER_TEXT_COLOR="MARKER_TEXT_COLOR";
|
||||
|
||||
|
||||
|
@ -13,13 +13,22 @@ package com.minres.scviewer.e4.application.preferences;
|
||||
import org.eclipse.jface.preference.BooleanFieldEditor;
|
||||
import org.eclipse.jface.preference.FieldEditorPreferencePage;
|
||||
|
||||
/** A sample preference page to show how it works */
|
||||
|
||||
/**
|
||||
* The Class SCViewerPreferencesPage showing the SCViewer top preferences.
|
||||
*/
|
||||
public class SCViewerPreferencesPage extends FieldEditorPreferencePage {
|
||||
|
||||
/**
|
||||
* Instantiates a new SC viewer preferences page.
|
||||
*/
|
||||
public SCViewerPreferencesPage() {
|
||||
super(GRID);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors()
|
||||
*/
|
||||
@Override
|
||||
protected void createFieldEditors() {
|
||||
|
||||
|
@ -15,13 +15,21 @@ import org.eclipse.jface.preference.FieldEditorPreferencePage;
|
||||
|
||||
import com.minres.scviewer.database.ui.WaveformColors;
|
||||
|
||||
/** A sample preference page to show how it works */
|
||||
/**
|
||||
* The WaveformView preference page to show the colors to use.
|
||||
*/
|
||||
public class WaveformPreferencesPage extends FieldEditorPreferencePage {
|
||||
|
||||
/**
|
||||
* Instantiates a new waveform preferences page.
|
||||
*/
|
||||
public WaveformPreferencesPage() {
|
||||
super(GRID);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors()
|
||||
*/
|
||||
@Override
|
||||
protected void createFieldEditors() {
|
||||
|
||||
|
@ -20,30 +20,52 @@ import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.Collections2;
|
||||
import com.minres.scviewer.database.IHierNode;
|
||||
import com.minres.scviewer.database.IWaveform;
|
||||
import com.minres.scviewer.database.IWaveformDb;
|
||||
|
||||
/**
|
||||
* The Class TxDbContentProvider providing the tree content of a database for the respective viewer.
|
||||
*/
|
||||
public class TxDbContentProvider implements ITreeContentProvider {
|
||||
|
||||
/** The show nodes. */
|
||||
// private List<HierNode> nodes;
|
||||
private boolean showNodes;
|
||||
|
||||
/**
|
||||
* Instantiates a new tx db content provider.
|
||||
*/
|
||||
public TxDbContentProvider() {
|
||||
super();
|
||||
this.showNodes = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new tx db content provider.
|
||||
*
|
||||
* @param showNodes the show nodes
|
||||
*/
|
||||
public TxDbContentProvider(boolean showNodes) {
|
||||
super();
|
||||
this.showNodes = showNodes;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.IContentProvider#dispose()
|
||||
*/
|
||||
@Override
|
||||
public void dispose() { }
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
|
||||
// showNodes=!(newInput instanceof IHierNode);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.ITreeContentProvider#getElements(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public Object[] getElements(Object inputElement) {
|
||||
if(inputElement instanceof IHierNode){
|
||||
@ -58,22 +80,33 @@ public class TxDbContentProvider implements ITreeContentProvider {
|
||||
}
|
||||
});
|
||||
return res.toArray();
|
||||
}else if(inputElement instanceof List<?>)
|
||||
}else if(inputElement instanceof List<?>){
|
||||
return ((List<?>)inputElement).toArray();
|
||||
else
|
||||
}else if(inputElement instanceof IWaveformDb){
|
||||
return new Object[]{};
|
||||
} else
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public Object[] getChildren(Object parentElement) {
|
||||
return getElements(parentElement);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public Object getParent(Object element) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean hasChildren(Object element) {
|
||||
Object[] obj = getElements(element);
|
||||
|
@ -23,16 +23,26 @@ import com.minres.scviewer.database.ISignal;
|
||||
import com.minres.scviewer.database.ISignalChangeMulti;
|
||||
import com.minres.scviewer.database.ITxStream;
|
||||
import com.minres.scviewer.database.IWaveformDb;
|
||||
import com.minres.scviewer.e4.application.parts.LoadingWaveformDb;
|
||||
|
||||
/**
|
||||
* The Class TxDbLabelProvider providing the labels for the respective viewers.
|
||||
*/
|
||||
public class TxDbLabelProvider implements ILabelProvider {
|
||||
|
||||
/** The listeners. */
|
||||
private List<ILabelProviderListener> listeners = new ArrayList<ILabelProviderListener>();
|
||||
|
||||
private Image database, stream, signal, folder, wave;
|
||||
/** The wave. */
|
||||
private Image loadinDatabase, database, stream, signal, folder, wave;
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates a new tx db label provider.
|
||||
*/
|
||||
public TxDbLabelProvider() {
|
||||
super();
|
||||
loadinDatabase=ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/database_go.png");
|
||||
database=ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/database.png");
|
||||
stream=ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/stream.png");
|
||||
folder=ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/folder.png");
|
||||
@ -40,13 +50,20 @@ public class TxDbLabelProvider implements ILabelProvider {
|
||||
wave=ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/wave.png");
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener)
|
||||
*/
|
||||
@Override
|
||||
public void addListener(ILabelProviderListener listener) {
|
||||
listeners.add(listener);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose()
|
||||
*/
|
||||
@Override
|
||||
public void dispose() {
|
||||
if(loadinDatabase!=null) database.dispose();
|
||||
if(database!=null) database.dispose();
|
||||
if(stream!=null) stream.dispose();
|
||||
if(folder!=null) folder.dispose();
|
||||
@ -54,20 +71,32 @@ public class TxDbLabelProvider implements ILabelProvider {
|
||||
if(wave!=null) wave.dispose();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public boolean isLabelProperty(Object element, String property) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener)
|
||||
*/
|
||||
@Override
|
||||
public void removeListener(ILabelProviderListener listener) {
|
||||
listeners.remove(listener);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public Image getImage(Object element) {
|
||||
if(element instanceof IWaveformDb){
|
||||
return database;
|
||||
if(element instanceof LoadingWaveformDb)
|
||||
return loadinDatabase;
|
||||
else
|
||||
return database;
|
||||
}else if(element instanceof ITxStream){
|
||||
return stream;
|
||||
}else if(element instanceof ISignal<?>){
|
||||
@ -82,6 +111,9 @@ public class TxDbLabelProvider implements ILabelProvider {
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public String getText(Object element) {
|
||||
return ((IHierNode)element).getName();
|
||||
|
@ -21,19 +21,32 @@ import com.minres.scviewer.database.IHierNode;
|
||||
import com.minres.scviewer.database.ITx;
|
||||
import com.minres.scviewer.database.ITxAttribute;
|
||||
|
||||
/**
|
||||
* The Class TxPropertiesContentProvider. Not used atm
|
||||
*/
|
||||
public class TxPropertiesContentProvider implements IStructuredContentProvider {
|
||||
|
||||
/** The show nodes. */
|
||||
// private List<HierNode> nodes;
|
||||
private boolean showNodes=false;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.IContentProvider#dispose()
|
||||
*/
|
||||
@Override
|
||||
public void dispose() { }
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
|
||||
showNodes=!(newInput instanceof IHierNode);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public Object[] getElements(Object inputElement) {
|
||||
if(inputElement instanceof ITx){
|
||||
|
@ -20,38 +20,63 @@ import org.eclipse.swt.graphics.Image;
|
||||
import com.minres.scviewer.database.ITxAttribute;
|
||||
import com.minres.scviewer.e4.application.parts.TransactionDetails;
|
||||
|
||||
/**
|
||||
* The Class TxPropertiesLabelProvider providing the labels of a property to the respective viewer.
|
||||
*/
|
||||
public class TxPropertiesLabelProvider implements ITableLabelProvider {
|
||||
|
||||
/** The listeners. */
|
||||
private List<ILabelProviderListener> listeners = new ArrayList<ILabelProviderListener>();
|
||||
|
||||
/**
|
||||
* Instantiates a new tx properties label provider.
|
||||
*/
|
||||
public TxPropertiesLabelProvider() {
|
||||
super();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose()
|
||||
*/
|
||||
@Override
|
||||
public void dispose() {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener)
|
||||
*/
|
||||
@Override
|
||||
public void addListener(ILabelProviderListener listener) {
|
||||
listeners.add(listener);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener)
|
||||
*/
|
||||
@Override
|
||||
public void removeListener(ILabelProviderListener listener) {
|
||||
listeners.remove(listener);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public boolean isLabelProperty(Object element, String property) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
|
||||
*/
|
||||
@Override
|
||||
public Image getColumnImage(Object element, int columnIndex) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
|
||||
*/
|
||||
@Override
|
||||
public String getColumnText(Object element, int columnIndex) {
|
||||
ITxAttribute attribute = (ITxAttribute) element;
|
||||
|
@ -1,34 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<launchConfiguration type="org.eclipse.pde.ui.RuntimeWorkbench">
|
||||
<booleanAttribute key="append.args" value="true"/>
|
||||
<stringAttribute key="application" value="org.eclipse.e4.ui.workbench.swt.E4Application"/>
|
||||
<booleanAttribute key="askclear" value="false"/>
|
||||
<booleanAttribute key="automaticAdd" value="false"/>
|
||||
<booleanAttribute key="automaticValidate" value="false"/>
|
||||
<stringAttribute key="bootstrap" value=""/>
|
||||
<stringAttribute key="checked" value="[NONE]"/>
|
||||
<booleanAttribute key="clearConfig" value="false"/>
|
||||
<booleanAttribute key="clearws" value="true"/>
|
||||
<booleanAttribute key="clearwslog" value="false"/>
|
||||
<stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/SCViewer"/>
|
||||
<booleanAttribute key="default" value="false"/>
|
||||
<booleanAttribute key="includeOptional" value="true"/>
|
||||
<stringAttribute key="location" value="${workspace_loc}/../runtime-com.minres.scviewer.e4.application.product"/>
|
||||
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog -clearPersistedState /Users/eyck/Workspaces/cpp/tlm_router01/top.txlog"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms40m -Xmx512m -Xdock:icon=../Resources/Eclipse.icns -XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts"/>
|
||||
<stringAttribute key="pde.version" value="3.3"/>
|
||||
<stringAttribute key="product" value="com.minres.scviewer.e4.application.product"/>
|
||||
<stringAttribute key="productFile" value="/com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.product"/>
|
||||
<stringAttribute key="selected_target_plugins" value="com.google.guava@default:default,com.ibm.icu@default:default,javax.annotation@default:default,javax.inject@default:default,javax.servlet@default:default,javax.xml@default:default,org.apache.ant@default:default,org.apache.batik.css@default:default,org.apache.batik.util.gui@default:default,org.apache.batik.util@default:default,org.apache.commons.jxpath@default:default,org.apache.commons.logging@default:default,org.apache.felix.gogo.command@default:default,org.apache.felix.gogo.runtime@default:default,org.apache.felix.gogo.shell@default:default,org.codehaus.groovy@default:default,org.eclipse.ant.core@default:default,org.eclipse.compare.core@default:default,org.eclipse.core.commands@default:default,org.eclipse.core.contenttype@default:default,org.eclipse.core.databinding.beans@default:default,org.eclipse.core.databinding.observable@default:default,org.eclipse.core.databinding.property@default:default,org.eclipse.core.databinding@default:default,org.eclipse.core.expressions@default:default,org.eclipse.core.filesystem.java7@default:false,org.eclipse.core.filesystem.macosx@default:false,org.eclipse.core.filesystem@default:default,org.eclipse.core.jobs@default:default,org.eclipse.core.resources@default:default,org.eclipse.core.runtime.compatibility.registry@default:false,org.eclipse.core.runtime@default:true,org.eclipse.core.variables@default:default,org.eclipse.e4.core.commands@default:default,org.eclipse.e4.core.contexts@default:default,org.eclipse.e4.core.di.annotations@default:default,org.eclipse.e4.core.di.extensions@default:default,org.eclipse.e4.core.di@default:default,org.eclipse.e4.core.services@default:default,org.eclipse.e4.emf.xpath@default:default,org.eclipse.e4.ui.bindings@default:default,org.eclipse.e4.ui.css.core@default:default,org.eclipse.e4.ui.css.swt.theme@default:default,org.eclipse.e4.ui.css.swt@default:default,org.eclipse.e4.ui.di@default:default,org.eclipse.e4.ui.model.workbench@default:default,org.eclipse.e4.ui.services@default:default,org.eclipse.e4.ui.widgets@default:default,org.eclipse.e4.ui.workbench.addons.swt@default:default,org.eclipse.e4.ui.workbench.renderers.swt.cocoa@default:false,org.eclipse.e4.ui.workbench.renderers.swt@default:default,org.eclipse.e4.ui.workbench.swt@default:default,org.eclipse.e4.ui.workbench3@default:default,org.eclipse.e4.ui.workbench@default:default,org.eclipse.emf.common@default:default,org.eclipse.emf.ecore.change@default:default,org.eclipse.emf.ecore.xmi@default:default,org.eclipse.emf.ecore@default:default,org.eclipse.equinox.app@default:default,org.eclipse.equinox.bidi@default:default,org.eclipse.equinox.common@2:true,org.eclipse.equinox.concurrent@default:default,org.eclipse.equinox.console@default:default,org.eclipse.equinox.ds@1:true,org.eclipse.equinox.event@default:default,org.eclipse.equinox.preferences@default:default,org.eclipse.equinox.registry@default:default,org.eclipse.equinox.util@default:default,org.eclipse.help@default:default,org.eclipse.jface.databinding@default:default,org.eclipse.jface.text@default:default,org.eclipse.jface@default:default,org.eclipse.osgi.compatibility.state@default:false,org.eclipse.osgi.services@default:default,org.eclipse.osgi@-1:true,org.eclipse.swt.cocoa.macosx.x86_64@default:false,org.eclipse.swt@default:default,org.eclipse.team.core@default:default,org.eclipse.text@default:default,org.hamcrest.core@default:default,org.junit@default:default,org.w3c.css.sac@default:default,org.w3c.dom.events@default:default,org.w3c.dom.smil@default:default,org.w3c.dom.svg@default:default"/>
|
||||
<stringAttribute key="selected_workspace_plugins" value="com.minres.scviewer.database.sqlite@default:default,com.minres.scviewer.database.text@default:default,com.minres.scviewer.database.ui.swt@default:default,com.minres.scviewer.database.ui@default:default,com.minres.scviewer.database.vcd@default:default,com.minres.scviewer.database@default:default,com.minres.scviewer.e4.application@default:default,com.opcoach.e4.preferences@default:default"/>
|
||||
<booleanAttribute key="show_selected_only" value="false"/>
|
||||
<booleanAttribute key="tracing" value="false"/>
|
||||
<booleanAttribute key="useCustomFeatures" value="false"/>
|
||||
<booleanAttribute key="useDefaultConfig" value="true"/>
|
||||
<booleanAttribute key="useDefaultConfigArea" value="true"/>
|
||||
<booleanAttribute key="useProduct" value="true"/>
|
||||
<booleanAttribute key="usefeatures" value="false"/>
|
||||
</launchConfiguration>
|
@ -7,7 +7,7 @@
|
||||
</configIni>
|
||||
|
||||
<launcherArgs>
|
||||
<programArgs>-clearPersistedState
|
||||
<programArgs>-clearPersistedState -data @none
|
||||
</programArgs>
|
||||
<vmArgsMac>-XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts
|
||||
</vmArgsMac>
|
||||
|
722
scv_tr_sqlite/scv4tlm/tlm2_recorder.h
Normal file
722
scv_tr_sqlite/scv4tlm/tlm2_recorder.h
Normal file
@ -0,0 +1,722 @@
|
||||
/*
|
||||
* tlm_recording.h
|
||||
*
|
||||
* Created on: 07.11.2015
|
||||
* Author: eyck
|
||||
*/
|
||||
|
||||
#ifndef TLM2_RECORDER_H_
|
||||
#define TLM2_RECORDER_H_
|
||||
|
||||
#include <scv.h>
|
||||
#include <tlm>
|
||||
#include "tlm_gp_data_ext.h"
|
||||
#include "tlm_recording_extension.h"
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace scv4tlm {
|
||||
|
||||
/*! \brief The TLM2 transaction extensions recorder interface
|
||||
*
|
||||
* This interface is used by the TLM2 transaction recorder. It can be used to register custom recorder functionality
|
||||
* to also record the payload extensions
|
||||
*/
|
||||
template< typename TYPES = tlm::tlm_base_protocol_types>
|
||||
struct tlm2_extensions_recording_if {
|
||||
/*! \brief recording attributes in extensions at the beginning, it is intended to be overload as it does nothing
|
||||
*
|
||||
*/
|
||||
virtual void recordBeginTx(scv_tr_handle& handle, typename TYPES::tlm_payload_type& payload) = 0;
|
||||
|
||||
/*! \brief recording attributes in extensions at the end, it is intended to be overload as it does nothing
|
||||
*
|
||||
*/
|
||||
virtual void recordEndTx(scv_tr_handle& handle, typename TYPES::tlm_payload_type& payload) = 0;
|
||||
|
||||
virtual ~tlm2_extensions_recording_if(){}
|
||||
};
|
||||
/*! \brief The TLM2 transaction recorder
|
||||
*
|
||||
* This module records all TLM transaction to a SCV transaction stream for further viewing and analysis.
|
||||
* The handle of the created transaction is storee in an tlm_extension so that another instance of the scv_tlm2_recorder
|
||||
* e.g. further down the opath can link to it.
|
||||
*/
|
||||
template< typename TYPES = tlm::tlm_base_protocol_types>
|
||||
class tlm2_recorder:
|
||||
public virtual tlm::tlm_fw_transport_if<TYPES>,
|
||||
public virtual tlm::tlm_bw_transport_if<TYPES>,
|
||||
public sc_core::sc_object {
|
||||
public:
|
||||
SC_HAS_PROCESS(tlm2_recorder<TYPES>);
|
||||
|
||||
//! \brief the attribute to selectively enable/disable recording
|
||||
sc_core::sc_attribute<bool> enable;
|
||||
|
||||
//! \brief the attribute to selectively enable/disable timed recording
|
||||
sc_core::sc_attribute<bool> enableTimed;
|
||||
|
||||
//! \brief the port where fw accesses are forwarded to
|
||||
sc_core::sc_port<tlm::tlm_fw_transport_if<TYPES> > fw_port;
|
||||
|
||||
//! \brief the port where bw accesses are forwarded to
|
||||
sc_core::sc_port<tlm::tlm_bw_transport_if<TYPES> > bw_port;
|
||||
|
||||
/*! \brief The constructor of the component
|
||||
*
|
||||
* \param name is the SystemC module name of the recorder
|
||||
* \param tr_db is a pointer to a transaction recording database. If none is provided the default one is retrieved.
|
||||
* If this database is not initialized (e.g. by not calling scv_tr_db::set_default_db() ) recording is disabled.
|
||||
*/
|
||||
tlm2_recorder(bool recording_enabled = true, scv_tr_db* tr_db = scv_tr_db::get_default_db()){
|
||||
this->tlm2_recorder::tlm2_recorder(sc_core::sc_gen_unique_name("tlm2_recorder"), recording_enabled, tr_db);
|
||||
}
|
||||
/*! \brief The constructor of the component
|
||||
*
|
||||
* \param name is the SystemC module name of the recorder
|
||||
* \param tr_db is a pointer to a transaction recording database. If none is provided the default one is retrieved.
|
||||
* If this database is not initialized (e.g. by not calling scv_tr_db::set_default_db() ) recording is disabled.
|
||||
*/
|
||||
tlm2_recorder(const char* name, bool recording_enabled = true, scv_tr_db* tr_db = scv_tr_db::get_default_db())
|
||||
: sc_core::sc_object(name)
|
||||
, enable("enable", recording_enabled)
|
||||
, enableTimed("enableTimed", recording_enabled)
|
||||
, fw_port(sc_core::sc_gen_unique_name("fw"))
|
||||
, bw_port(sc_core::sc_gen_unique_name("bw"))
|
||||
, mm(new RecodingMemoryManager())
|
||||
, b_timed_peq(this, &tlm2_recorder::btx_cb)
|
||||
, nb_timed_peq(this, &tlm2_recorder::nbtx_cb)
|
||||
, m_db(tr_db)
|
||||
, b_streamHandle(NULL)
|
||||
, b_streamHandleTimed(NULL)
|
||||
, b_trTimedHandle(3)
|
||||
, nb_streamHandle(2)
|
||||
, nb_streamHandleTimed(2)
|
||||
, nb_fw_trHandle(3)
|
||||
, nb_txReqHandle(3)
|
||||
, nb_bw_trHandle(3)
|
||||
, nb_txRespHandle(3)
|
||||
, dmi_streamHandle(NULL)
|
||||
, dmi_trGetHandle(NULL)
|
||||
, dmi_trInvalidateHandle(NULL)
|
||||
, extensionRecording(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~tlm2_recorder(){
|
||||
delete b_streamHandle;
|
||||
delete b_streamHandleTimed;
|
||||
for(size_t i = 0; i<b_trTimedHandle.size(); ++i) delete b_trTimedHandle[i];
|
||||
for(size_t i = 0; i<nb_streamHandle.size(); ++i) delete nb_streamHandle[i];
|
||||
for(size_t i = 0; i<nb_streamHandleTimed.size(); ++i) delete nb_streamHandleTimed[i];
|
||||
for(size_t i = 0; i<nb_fw_trHandle.size(); ++i) delete nb_fw_trHandle[i];
|
||||
for(size_t i = 0; i<nb_txReqHandle.size(); ++i) delete nb_txReqHandle[i];
|
||||
for(size_t i = 0; i<nb_bw_trHandle.size(); ++i) delete nb_bw_trHandle[i];
|
||||
for(size_t i = 0; i<nb_txRespHandle.size(); ++i) delete nb_txRespHandle[i];
|
||||
delete dmi_streamHandle;
|
||||
delete dmi_trGetHandle;
|
||||
delete dmi_trInvalidateHandle;
|
||||
delete extensionRecording;
|
||||
}
|
||||
|
||||
// TLM-2.0 interface methods for initiator and target sockets, surrounded with Tx Recording
|
||||
/*! \brief The non-blocking forward transport function
|
||||
*
|
||||
* This type of transaction is forwarded and recorded to a transaction stream named "nb_fw" with current timestamps.
|
||||
* \param trans is the generic payload of the transaction
|
||||
* \param phase is the current phase of the transaction
|
||||
* \param delay is the annotated delay
|
||||
* \return the sync state of the transaction
|
||||
*/
|
||||
virtual tlm::tlm_sync_enum nb_transport_fw(typename TYPES::tlm_payload_type& trans, typename TYPES::tlm_phase_type& phase,
|
||||
sc_core::sc_time& delay);
|
||||
|
||||
/*! \brief The non-blocking backward transport function
|
||||
*
|
||||
* This type of transaction is forwarded and recorded to a transaction stream named "nb_bw" with current timestamps.
|
||||
* \param trans is the generic payload of the transaction
|
||||
* \param phase is the current phase of the transaction
|
||||
* \param delay is the annotated delay
|
||||
* \return the sync state of the transaction
|
||||
*/
|
||||
virtual tlm::tlm_sync_enum nb_transport_bw(typename TYPES::tlm_payload_type& trans, typename TYPES::tlm_phase_type& phase,
|
||||
sc_core::sc_time& delay);
|
||||
|
||||
/*! \brief The blocking transport function
|
||||
*
|
||||
* This type of transaction is forwarded and recorded to a transaction stream named "b_tx" with current timestamps. Additionally a "b_tx_timed"
|
||||
* is been created recording the transactions at their annotated delay
|
||||
* \param trans is the generic payload of the transaction
|
||||
* \param delay is the annotated delay
|
||||
*/
|
||||
virtual void b_transport(typename TYPES::tlm_payload_type& trans, sc_core::sc_time& delay);
|
||||
|
||||
/*! \brief The direct memory interface forward function
|
||||
*
|
||||
* This type of transaction is just forwarded and not recorded.
|
||||
* \param trans is the generic payload of the transaction
|
||||
* \param dmi_data is the structure holding the dmi information
|
||||
* \return if the dmi structure is valid
|
||||
*/
|
||||
virtual bool get_direct_mem_ptr(typename TYPES::tlm_payload_type& trans, tlm::tlm_dmi& dmi_data);
|
||||
/*! \brief The direct memory interface backward function
|
||||
*
|
||||
* This type of transaction is just forwarded and not recorded.
|
||||
* \param start_addr is the start address of the memory area being invalid
|
||||
* \param end_addr is the end address of the memory area being invalid
|
||||
*/
|
||||
virtual void invalidate_direct_mem_ptr(sc_dt::uint64 start_addr, sc_dt::uint64 end_addr);
|
||||
/*! \brief The debug transportfunction
|
||||
*
|
||||
* This type of transaction is just forwarded and not recorded.
|
||||
* \param trans is the generic payload of the transaction
|
||||
* \return the sync state of the transaction
|
||||
*/
|
||||
virtual unsigned int transport_dbg(typename TYPES::tlm_payload_type& trans);
|
||||
/*! \brief get the current state of transaction recording
|
||||
*
|
||||
* \return if true transaction recording is enabled otherwise transaction recording is bypassed
|
||||
*/
|
||||
const bool isRecordingEnabled() const {
|
||||
return m_db != NULL && enable.value;
|
||||
}
|
||||
|
||||
void setExtensionRecording(tlm2_extensions_recording_if<TYPES>* extensionRecording){
|
||||
this->extensionRecording=extensionRecording;
|
||||
}
|
||||
private:
|
||||
//! \brief the struct to hold the information to be recorded on the timed streams
|
||||
struct tlm_recording_payload: public TYPES::tlm_payload_type {
|
||||
scv_tr_handle parent;
|
||||
uint64 id;
|
||||
tlm_recording_payload& operator=(const typename TYPES::tlm_payload_type& x){
|
||||
id=(uint64)&x;
|
||||
set_command(x.get_command());
|
||||
set_address(x.get_address());
|
||||
set_data_ptr(x.get_data_ptr());
|
||||
set_data_length(x.get_data_length());
|
||||
set_response_status(x.get_response_status());
|
||||
set_byte_enable_ptr(x.get_byte_enable_ptr());
|
||||
set_byte_enable_length(x.get_byte_enable_length());
|
||||
set_streaming_width(x.get_streaming_width());
|
||||
return (*this);
|
||||
|
||||
}
|
||||
explicit tlm_recording_payload(tlm::tlm_mm_interface* mm) :
|
||||
TYPES::tlm_payload_type(mm), parent(), id(0) {
|
||||
}
|
||||
};
|
||||
//! \brief Memory manager for the tlm_recording_payload
|
||||
struct RecodingMemoryManager: public tlm::tlm_mm_interface {
|
||||
RecodingMemoryManager() :
|
||||
free_list(0), empties(0) {
|
||||
}
|
||||
tlm_recording_payload* allocate() {
|
||||
typename TYPES::tlm_payload_type* ptr;
|
||||
if (free_list) {
|
||||
ptr = free_list->trans;
|
||||
empties = free_list;
|
||||
free_list = free_list->next;
|
||||
} else {
|
||||
ptr = new tlm_recording_payload(this);
|
||||
}
|
||||
return (tlm_recording_payload*) ptr;
|
||||
}
|
||||
void free(typename TYPES::tlm_payload_type* trans) {
|
||||
trans->reset();
|
||||
if (!empties) {
|
||||
empties = new access;
|
||||
empties->next = free_list;
|
||||
empties->prev = 0;
|
||||
if (free_list)
|
||||
free_list->prev = empties;
|
||||
}
|
||||
free_list = empties;
|
||||
free_list->trans = trans;
|
||||
empties = free_list->prev;
|
||||
}
|
||||
private:
|
||||
struct access {
|
||||
typename TYPES::tlm_payload_type* trans;
|
||||
access* next;
|
||||
access* prev;
|
||||
};
|
||||
access *free_list, *empties;
|
||||
};
|
||||
RecodingMemoryManager* mm;
|
||||
//! peq type definition
|
||||
struct recording_types {
|
||||
typedef tlm_recording_payload tlm_payload_type;
|
||||
typedef typename TYPES::tlm_phase_type tlm_phase_type;
|
||||
};
|
||||
//! event queue to hold time points of blocking transactions
|
||||
tlm_utils::peq_with_cb_and_phase<tlm2_recorder, recording_types> b_timed_peq;
|
||||
//! event queue to hold time points of non-blocking transactions
|
||||
tlm_utils::peq_with_cb_and_phase<tlm2_recorder, recording_types> nb_timed_peq;
|
||||
/*! \brief The thread processing the blocking accesses with their annotated times
|
||||
* to generate the timed view of blocking tx
|
||||
*/
|
||||
void btx_cb(tlm_recording_payload& rec_parts, const typename TYPES::tlm_phase_type& phase);
|
||||
/*! \brief The thread processing the non-blocking requests with their annotated times
|
||||
* to generate the timed view of non-blocking tx
|
||||
*/
|
||||
void nbtx_cb(tlm_recording_payload& rec_parts, const typename TYPES::tlm_phase_type& phase);
|
||||
//! transaction recording database
|
||||
scv_tr_db* m_db;
|
||||
//! blocking transaction recording stream handle
|
||||
scv_tr_stream* b_streamHandle;
|
||||
//! transaction generator handle for blocking transactions
|
||||
scv_tr_generator<sc_dt::uint64, sc_dt::uint64>* b_trHandle[3];
|
||||
//! timed blocking transaction recording stream handle
|
||||
scv_tr_stream* b_streamHandleTimed;
|
||||
//! transaction generator handle for blocking transactions with annotated delays
|
||||
std::vector<scv_tr_generator<tlm::tlm_command, tlm::tlm_response_status>*> b_trTimedHandle;
|
||||
std::map<uint64, scv_tr_handle> btx_handle_map;
|
||||
|
||||
enum DIR{FW, BW};
|
||||
//! non-blocking transaction recording stream handle
|
||||
std::vector<scv_tr_stream*> nb_streamHandle;
|
||||
//! non-blocking transaction recording stream handle
|
||||
std::vector<scv_tr_stream*> nb_streamHandleTimed;
|
||||
//! transaction generator handle for forward non-blocking transactions
|
||||
std::vector<scv_tr_generator<tlm::tlm_phase_enum, tlm::tlm_sync_enum>*> nb_fw_trHandle;
|
||||
//! transaction generator handle for forward non-blocking transactions with annotated delays
|
||||
std::vector<scv_tr_generator<>*> nb_txReqHandle;
|
||||
map<uint64, scv_tr_handle> nbtx_req_handle_map;
|
||||
//! transaction generator handle for backward non-blocking transactions
|
||||
std::vector<scv_tr_generator<tlm::tlm_phase_enum, tlm::tlm_sync_enum>*> nb_bw_trHandle;
|
||||
//! transaction generator handle for backward non-blocking transactions with annotated delays
|
||||
std::vector<scv_tr_generator<>*> nb_txRespHandle;
|
||||
map<uint64, scv_tr_handle> nbtx_last_req_handle_map;
|
||||
|
||||
//! dmi transaction recording stream handle
|
||||
scv_tr_stream* dmi_streamHandle;
|
||||
//! transaction generator handle for DMI transactions
|
||||
scv_tr_generator<tlm_gp_data, tlm_dmi_data>* dmi_trGetHandle;
|
||||
scv_tr_generator<sc_dt::uint64, sc_dt::uint64>* dmi_trInvalidateHandle;
|
||||
|
||||
tlm2_extensions_recording_if<TYPES>* extensionRecording;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// implementations of functions
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
template< typename TYPES>
|
||||
void tlm2_recorder<TYPES>::b_transport(typename TYPES::tlm_payload_type& trans, sc_core::sc_time& delay) {
|
||||
tlm_recording_payload* req;
|
||||
if (!isRecordingEnabled()) {
|
||||
fw_port->b_transport(trans, delay);
|
||||
return;
|
||||
}
|
||||
if (b_streamHandle == NULL) {
|
||||
string basename(this->name());
|
||||
b_streamHandle = new scv_tr_stream((basename + ".blocking").c_str(), "TRANSACTOR", m_db);
|
||||
b_trHandle[tlm::TLM_READ_COMMAND] = new scv_tr_generator<sc_dt::uint64, sc_dt::uint64>("read", *b_streamHandle, "start_delay",
|
||||
"end_delay");
|
||||
b_trHandle[tlm::TLM_WRITE_COMMAND] = new scv_tr_generator<sc_dt::uint64, sc_dt::uint64>("write", *b_streamHandle, "start_delay",
|
||||
"end_delay");
|
||||
b_trHandle[tlm::TLM_IGNORE_COMMAND] = new scv_tr_generator<sc_dt::uint64, sc_dt::uint64>("ignore", *b_streamHandle, "start_delay",
|
||||
"end_delay");
|
||||
}
|
||||
// Get a handle for the new transaction
|
||||
scv_tr_handle h = b_trHandle[trans.get_command()]->begin_transaction(delay.value(), sc_time_stamp());
|
||||
tlm_gp_data tgd(trans);
|
||||
|
||||
/*************************************************************************
|
||||
* do the timed notification
|
||||
*************************************************************************/
|
||||
if (enableTimed.value) {
|
||||
req = mm->allocate();
|
||||
req->acquire();
|
||||
(*req) = trans;
|
||||
req->parent = h;
|
||||
req->id=h.get_id();
|
||||
#ifdef DEBUG
|
||||
cout<<"notify addition of parent with id "<<req->id<<" to btx_handle_map with delay "<<delay<<std::endl;
|
||||
#endif
|
||||
b_timed_peq.notify(*req, tlm::BEGIN_REQ, delay);
|
||||
}
|
||||
|
||||
if(extensionRecording) extensionRecording->recordBeginTx(h, trans);
|
||||
tlm_recording_extension* preExt = NULL;
|
||||
|
||||
trans.get_extension(preExt);
|
||||
if (preExt == NULL) { // we are the first recording this transaction
|
||||
preExt = new tlm_recording_extension(h, this);
|
||||
trans.set_extension(preExt);
|
||||
} else {
|
||||
h.add_relation(rel_str(PREDECESSOR_SUCCESSOR), preExt->txHandle);
|
||||
}
|
||||
scv_tr_handle preTx(preExt->txHandle);
|
||||
|
||||
fw_port->b_transport(trans, delay);
|
||||
trans.get_extension(preExt);
|
||||
if (preExt->get_creator() == this) {
|
||||
// clean-up the extension if this is the original creator
|
||||
delete preExt;
|
||||
trans.set_extension((tlm_recording_extension*) NULL);
|
||||
} else {
|
||||
preExt->txHandle=preTx;
|
||||
}
|
||||
|
||||
tgd.set_response_status(trans.get_response_status());
|
||||
h.record_attribute("trans", tgd);
|
||||
h.record_attribute("trans.data_value", *(uint64_t*)trans.get_data_ptr());
|
||||
if(extensionRecording) extensionRecording->recordEndTx(h, trans);
|
||||
// End the transaction
|
||||
b_trHandle[trans.get_command()]->end_transaction(h, delay.value(), sc_time_stamp());
|
||||
// and now the stuff for the timed tx
|
||||
if (enableTimed.value){
|
||||
#ifdef DEBUG
|
||||
cout<<"notify removal of parent with id "<<req->id<<" to btx_handle_map with delay "<<delay<<std::endl;
|
||||
#endif
|
||||
b_timed_peq.notify(*req, tlm::END_RESP, delay);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
template< typename TYPES>
|
||||
void tlm2_recorder<TYPES>::btx_cb(tlm_recording_payload& rec_parts, const typename TYPES::tlm_phase_type& phase) {
|
||||
scv_tr_handle h;
|
||||
if (b_trTimedHandle[0] == NULL) {
|
||||
std::string basename(this->name());
|
||||
b_streamHandleTimed = new scv_tr_stream((basename + ".blocking_annotated").c_str(), "TRANSACTOR", m_db);
|
||||
b_trTimedHandle[0] = new scv_tr_generator<tlm::tlm_command, tlm::tlm_response_status>("read", *b_streamHandleTimed);
|
||||
b_trTimedHandle[1] = new scv_tr_generator<tlm::tlm_command, tlm::tlm_response_status>("write", *b_streamHandleTimed);
|
||||
b_trTimedHandle[2] = new scv_tr_generator<tlm::tlm_command, tlm::tlm_response_status>("ignore", *b_streamHandleTimed);
|
||||
}
|
||||
// Now process outstanding recordings
|
||||
switch (phase) {
|
||||
case tlm::BEGIN_REQ:
|
||||
{
|
||||
tlm_gp_data tgd(rec_parts);
|
||||
h = b_trTimedHandle[rec_parts.get_command()]->begin_transaction(rec_parts.get_command());
|
||||
h.record_attribute("trans", tgd);
|
||||
h.add_relation(rel_str(PARENT_CHILD), rec_parts.parent);
|
||||
#ifdef DEBUG
|
||||
cout<<"adding parent with id "<<rec_parts.id<<" to btx_handle_map"<<std::endl;
|
||||
#endif
|
||||
btx_handle_map[rec_parts.id] = h;
|
||||
}
|
||||
break;
|
||||
case tlm::END_RESP: {
|
||||
#ifdef DEBUG
|
||||
cout<<"retrieving parent with id "<<rec_parts.id<<" from btx_handle_map"<<std::endl;
|
||||
#endif
|
||||
std::map<uint64, scv_tr_handle>::iterator it = btx_handle_map.find(rec_parts.id);
|
||||
sc_assert(it != btx_handle_map.end());
|
||||
h = it->second;
|
||||
btx_handle_map.erase(it);
|
||||
h.end_transaction(h, rec_parts.get_response_status());
|
||||
rec_parts.release();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
sc_assert(!"phase not supported!");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
template< typename TYPES>
|
||||
tlm::tlm_sync_enum tlm2_recorder<TYPES>::nb_transport_fw(
|
||||
typename TYPES::tlm_payload_type& trans,
|
||||
typename TYPES::tlm_phase_type& phase,
|
||||
sc_core::sc_time& delay) {
|
||||
if (!isRecordingEnabled())
|
||||
return fw_port->nb_transport_fw(trans, phase, delay);
|
||||
// initialize stream and generator if not yet done
|
||||
if (nb_streamHandle[FW] == NULL) {
|
||||
string basename(this->name());
|
||||
nb_streamHandle[FW] = new scv_tr_stream((basename + ".nb_forward").c_str(), "TRANSACTOR", m_db);
|
||||
nb_fw_trHandle[tlm::TLM_READ_COMMAND] = new scv_tr_generator<tlm::tlm_phase_enum, tlm::tlm_sync_enum>("read", *nb_streamHandle[FW], "tlm_phase", "tlm_sync");
|
||||
nb_fw_trHandle[tlm::TLM_WRITE_COMMAND] = new scv_tr_generator<tlm::tlm_phase_enum, tlm::tlm_sync_enum>("write", *nb_streamHandle[FW], "tlm_phase", "tlm_sync");
|
||||
nb_fw_trHandle[tlm::TLM_IGNORE_COMMAND] = new scv_tr_generator<tlm::tlm_phase_enum, tlm::tlm_sync_enum>("ignore", *nb_streamHandle[FW], "tlm_phase", "tlm_sync");
|
||||
}
|
||||
/*************************************************************************
|
||||
* prepare recording
|
||||
*************************************************************************/
|
||||
// Get a handle for the new transaction
|
||||
scv_tr_handle h = nb_fw_trHandle[trans.get_command()]->begin_transaction((tlm::tlm_phase_enum) (unsigned) phase);
|
||||
tlm_recording_extension* preExt = NULL;
|
||||
trans.get_extension(preExt);
|
||||
if (phase == tlm::BEGIN_REQ && preExt == NULL) { // we are the first recording this transaction
|
||||
preExt = new tlm_recording_extension(h, this);
|
||||
trans.set_extension(preExt);
|
||||
} else if (preExt != NULL) {
|
||||
// link handle if we have a predecessor
|
||||
h.add_relation(rel_str(PREDECESSOR_SUCCESSOR), preExt->txHandle);
|
||||
} else {
|
||||
sc_assert(preExt!=NULL && "ERROR on forward path in phase other than tlm::BEGIN_REQ");
|
||||
}
|
||||
// update the extension
|
||||
preExt->txHandle = h;
|
||||
h.record_attribute("delay", delay.to_string());
|
||||
if(extensionRecording) extensionRecording->recordBeginTx(h, trans);
|
||||
tlm_gp_data tgd(trans);
|
||||
/*************************************************************************
|
||||
* do the timed notification
|
||||
*************************************************************************/
|
||||
if (enableTimed.value) {
|
||||
tlm_recording_payload* req = mm->allocate();
|
||||
req->acquire();
|
||||
(*req) = trans;
|
||||
req->parent = h;
|
||||
nb_timed_peq.notify(*req, phase, delay);
|
||||
}
|
||||
/*************************************************************************
|
||||
* do the access
|
||||
*************************************************************************/
|
||||
tlm::tlm_sync_enum status = fw_port->nb_transport_fw(trans, phase, delay);
|
||||
/*************************************************************************
|
||||
* handle recording
|
||||
*************************************************************************/
|
||||
tgd.set_response_status(trans.get_response_status());
|
||||
h.record_attribute("trans", tgd);
|
||||
if(extensionRecording) extensionRecording->recordEndTx(h, trans);
|
||||
h.record_attribute("tlm_phase[return_path]", (tlm::tlm_phase_enum) (unsigned) phase);
|
||||
h.record_attribute("delay[return_path]", delay.to_string());
|
||||
// get the extension and free the memory if it was mine
|
||||
if (status == tlm::TLM_COMPLETED || (status == tlm::TLM_ACCEPTED && phase == tlm::END_RESP)) {
|
||||
trans.get_extension(preExt);
|
||||
if (preExt->get_creator() == this) {
|
||||
delete preExt;
|
||||
trans.set_extension((tlm_recording_extension*) NULL);
|
||||
}
|
||||
/*************************************************************************
|
||||
* do the timed notification if req. finished here
|
||||
*************************************************************************/
|
||||
tlm_recording_payload* req = mm->allocate();
|
||||
req->acquire();
|
||||
(*req) = trans;
|
||||
req->parent = h;
|
||||
nb_timed_peq.notify(*req, (status == tlm::TLM_COMPLETED && phase == tlm::BEGIN_REQ) ? tlm::END_RESP : phase,
|
||||
delay);
|
||||
} else if (status == tlm::TLM_UPDATED) {
|
||||
tlm_recording_payload* req = mm->allocate();
|
||||
req->acquire();
|
||||
(*req) = trans;
|
||||
req->parent = h;
|
||||
nb_timed_peq.notify(*req, phase, delay);
|
||||
}
|
||||
// End the transaction
|
||||
nb_fw_trHandle[trans.get_command()]->end_transaction(h, status);
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
template< typename TYPES>
|
||||
tlm::tlm_sync_enum tlm2_recorder<TYPES>::nb_transport_bw(typename TYPES::tlm_payload_type& trans, typename TYPES::tlm_phase_type& phase,
|
||||
sc_core::sc_time& delay) {
|
||||
if (!isRecordingEnabled())
|
||||
return bw_port->nb_transport_bw(trans, phase, delay);
|
||||
if (nb_streamHandle[BW] == NULL) {
|
||||
string basename(this->name());
|
||||
nb_streamHandle[BW] = new scv_tr_stream((basename + ".nb_backward").c_str(), "TRANSACTOR", m_db);
|
||||
nb_bw_trHandle[0] = new scv_tr_generator<tlm::tlm_phase_enum, tlm::tlm_sync_enum>("read", *nb_streamHandle[BW], "tlm_phase", "tlm_sync");
|
||||
nb_bw_trHandle[1] = new scv_tr_generator<tlm::tlm_phase_enum, tlm::tlm_sync_enum>("write", *nb_streamHandle[BW], "tlm_phase", "tlm_sync");
|
||||
nb_bw_trHandle[2] = new scv_tr_generator<tlm::tlm_phase_enum, tlm::tlm_sync_enum>("ignore", *nb_streamHandle[BW], "tlm_phase", "tlm_sync");
|
||||
}
|
||||
/*************************************************************************
|
||||
* prepare recording
|
||||
*************************************************************************/
|
||||
tlm_recording_extension* preExt = NULL;
|
||||
trans.get_extension(preExt);
|
||||
sc_assert(preExt!=NULL && "ERROR on backward path");
|
||||
// Get a handle for the new transaction
|
||||
scv_tr_handle h = nb_bw_trHandle[trans.get_command()]->begin_transaction((tlm::tlm_phase_enum) (unsigned) phase);
|
||||
// link handle if we have a predecessor and that's not ourself
|
||||
h.add_relation(rel_str(PREDECESSOR_SUCCESSOR), preExt->txHandle);
|
||||
// and set the extension handle to this transaction
|
||||
preExt->txHandle = h;
|
||||
h.record_attribute("delay", delay.to_string());
|
||||
if(extensionRecording) extensionRecording->recordBeginTx(h, trans);
|
||||
tlm_gp_data tgd(trans);
|
||||
/*************************************************************************
|
||||
* do the timed notification
|
||||
*************************************************************************/
|
||||
if (enableTimed.value) {
|
||||
tlm_recording_payload* req = mm->allocate();
|
||||
req->acquire();
|
||||
(*req) = trans;
|
||||
req->parent = h;
|
||||
nb_timed_peq.notify(*req, phase, delay);
|
||||
}
|
||||
/*************************************************************************
|
||||
* do the access
|
||||
*************************************************************************/
|
||||
tlm::tlm_sync_enum status = bw_port->nb_transport_bw(trans, phase, delay);
|
||||
/*************************************************************************
|
||||
* handle recording
|
||||
*************************************************************************/
|
||||
tgd.set_response_status(trans.get_response_status());
|
||||
h.record_attribute("trans", tgd);
|
||||
if(extensionRecording) extensionRecording->recordEndTx(h, trans);
|
||||
// phase and delay are already recorded
|
||||
h.record_attribute("phase_upd", (tlm::tlm_phase_enum) (unsigned) phase);
|
||||
h.record_attribute("delay_upd", delay.to_string());
|
||||
// End the transaction
|
||||
nb_bw_trHandle[trans.get_command()]->end_transaction(h, status);
|
||||
if (status == tlm::TLM_COMPLETED || (status == tlm::TLM_UPDATED && phase == tlm::END_RESP)) {
|
||||
// the transaction is finished
|
||||
trans.get_extension(preExt);
|
||||
if (preExt->get_creator() == this) {
|
||||
// clean-up the extension if this is the original creator
|
||||
delete preExt;
|
||||
trans.set_extension((tlm_recording_extension*) NULL);
|
||||
}
|
||||
/*************************************************************************
|
||||
* do the timed notification if req. finished here
|
||||
*************************************************************************/
|
||||
tlm_recording_payload* req = mm->allocate();
|
||||
req->acquire();
|
||||
(*req) = trans;
|
||||
req->parent = h;
|
||||
nb_timed_peq.notify(*req, phase, delay);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
template< typename TYPES>
|
||||
void tlm2_recorder<TYPES>::nbtx_cb(tlm_recording_payload& rec_parts, const typename TYPES::tlm_phase_type& phase) {
|
||||
scv_tr_handle h;
|
||||
std::map<uint64, scv_tr_handle>::iterator it;
|
||||
if (nb_streamHandleTimed[FW] == NULL) {
|
||||
std::string basename(this->name());
|
||||
nb_streamHandleTimed[FW] = new scv_tr_stream((basename + ".nb_request_annotated").c_str(), "TRANSACTOR", m_db);
|
||||
nb_txReqHandle[0] = new scv_tr_generator<>("read", *nb_streamHandleTimed[FW]);
|
||||
nb_txReqHandle[1] = new scv_tr_generator<>("write", *nb_streamHandleTimed[FW]);
|
||||
nb_txReqHandle[2] = new scv_tr_generator<>("ignore", *nb_streamHandleTimed[FW]);
|
||||
}
|
||||
if (nb_streamHandleTimed[BW] == NULL) {
|
||||
std::string basename(this->name());
|
||||
nb_streamHandleTimed[BW] = new scv_tr_stream((basename + ".nb_response_annotated").c_str(), "TRANSACTOR", m_db);
|
||||
nb_txRespHandle[0] = new scv_tr_generator<>("read", *nb_streamHandleTimed[BW]);
|
||||
nb_txRespHandle[1] = new scv_tr_generator<>("write", *nb_streamHandleTimed[BW]);
|
||||
nb_txRespHandle[2] = new scv_tr_generator<>("ignore", *nb_streamHandleTimed[BW]);
|
||||
}
|
||||
tlm_gp_data tgd(rec_parts);
|
||||
switch (phase) { // Now process outstanding recordings
|
||||
case tlm::BEGIN_REQ:
|
||||
h = nb_txReqHandle[rec_parts.get_command()]->begin_transaction();
|
||||
h.record_attribute("trans", tgd);
|
||||
h.add_relation(rel_str(PARENT_CHILD), rec_parts.parent);
|
||||
#ifdef NBDEBUG
|
||||
cout<<"adding parent with id "<<rec_parts.id<<" to nbtx_req_handle_map"<<std::endl;
|
||||
#endif
|
||||
nbtx_req_handle_map[rec_parts.id] = h;
|
||||
break;
|
||||
case tlm::END_REQ:
|
||||
#ifdef NBDEBUG
|
||||
cout<<"retrieving parent with id "<<rec_parts.id<<" from nbtx_req_handle_map"<<std::endl;
|
||||
#endif
|
||||
it = nbtx_req_handle_map.find(rec_parts.id);
|
||||
sc_assert(it != nbtx_req_handle_map.end());
|
||||
h = it->second;
|
||||
nbtx_req_handle_map.erase(it);
|
||||
h.end_transaction();
|
||||
nbtx_last_req_handle_map[rec_parts.id] = h;
|
||||
break;
|
||||
case tlm::BEGIN_RESP:
|
||||
#ifdef NBDEBUG
|
||||
cout<<"retrieving parent with id "<<rec_parts.id<<" from nbtx_req_handle_map"<<std::endl;
|
||||
#endif
|
||||
it = nbtx_req_handle_map.find(rec_parts.id);
|
||||
if (it != nbtx_req_handle_map.end()) {
|
||||
h = it->second;
|
||||
nbtx_req_handle_map.erase(it);
|
||||
h.end_transaction();
|
||||
nbtx_last_req_handle_map[rec_parts.id] = h;
|
||||
}
|
||||
h = nb_txRespHandle[rec_parts.get_command()]->begin_transaction();
|
||||
h.record_attribute("trans", tgd);
|
||||
h.add_relation(rel_str(PARENT_CHILD), rec_parts.parent);
|
||||
nbtx_req_handle_map[rec_parts.id] = h;
|
||||
it = nbtx_last_req_handle_map.find(rec_parts.id);
|
||||
if (it != nbtx_last_req_handle_map.end()) {
|
||||
scv_tr_handle pred = it->second;
|
||||
nbtx_last_req_handle_map.erase(it);
|
||||
h.add_relation(rel_str(PREDECESSOR_SUCCESSOR), pred);
|
||||
}
|
||||
break;
|
||||
case tlm::END_RESP:
|
||||
#ifdef NBDEBUG
|
||||
cout<<"retrieving parent with id "<<rec_parts.id<<" from nbtx_req_handle_map"<<std::endl;
|
||||
#endif
|
||||
it = nbtx_req_handle_map.find(rec_parts.id);
|
||||
if (it != nbtx_req_handle_map.end()) {
|
||||
h = it->second;
|
||||
nbtx_req_handle_map.erase(it);
|
||||
h.end_transaction();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
sc_assert(!"phase not supported!");
|
||||
}
|
||||
rec_parts.release();
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
template< typename TYPES>
|
||||
bool tlm2_recorder<TYPES>::get_direct_mem_ptr(typename TYPES::tlm_payload_type& trans, tlm::tlm_dmi& dmi_data) {
|
||||
if (!isRecordingEnabled()) {
|
||||
return fw_port->get_direct_mem_ptr(trans, dmi_data);
|
||||
}
|
||||
if (dmi_streamHandle == NULL) {
|
||||
string basename(this->name());
|
||||
dmi_streamHandle = new scv_tr_stream((basename + ".dmi").c_str(), "TRANSACTOR", m_db);
|
||||
dmi_trGetHandle = new scv_tr_generator<tlm_gp_data, tlm_dmi_data>("get_dmi_ptr", *b_streamHandle, "trans",
|
||||
"dmi_data");
|
||||
dmi_trInvalidateHandle = new scv_tr_generator<sc_dt::uint64, sc_dt::uint64>("invalidate", *b_streamHandle, "start_delay",
|
||||
"end_delay");
|
||||
}
|
||||
scv_tr_handle h = dmi_trGetHandle->begin_transaction(tlm_gp_data(trans));
|
||||
bool status= fw_port->get_direct_mem_ptr(trans, dmi_data);
|
||||
dmi_trGetHandle->end_transaction(h, tlm_dmi_data(dmi_data));
|
||||
return status;
|
||||
}
|
||||
/*! \brief The direct memory interface backward function
|
||||
*
|
||||
* This type of transaction is just forwarded and not recorded.
|
||||
* \param start_addr is the start address of the memory area being invalid
|
||||
* \param end_addr is the end address of the memory area being invalid
|
||||
*/
|
||||
template< typename TYPES>
|
||||
void tlm2_recorder<TYPES>::invalidate_direct_mem_ptr(sc_dt::uint64 start_addr, sc_dt::uint64 end_addr) {
|
||||
if (!isRecordingEnabled()) {
|
||||
bw_port->invalidate_direct_mem_ptr(start_addr, end_addr);
|
||||
return;
|
||||
}
|
||||
if (dmi_streamHandle == NULL) {
|
||||
string basename(this->name());
|
||||
dmi_streamHandle = new scv_tr_stream((basename + ".dmi").c_str(), "TRANSACTOR", m_db);
|
||||
dmi_trGetHandle = new scv_tr_generator<tlm_gp_data, tlm_dmi_data>("get_dmi_ptr", *b_streamHandle, "trans",
|
||||
"dmi_data");
|
||||
dmi_trInvalidateHandle = new scv_tr_generator<sc_dt::uint64, sc_dt::uint64>("invalidate", *b_streamHandle, "start_delay",
|
||||
"end_delay");
|
||||
}
|
||||
scv_tr_handle h = dmi_trInvalidateHandle->begin_transaction(start_addr);
|
||||
bw_port->invalidate_direct_mem_ptr(start_addr, end_addr);
|
||||
dmi_trInvalidateHandle->end_transaction(h, end_addr);
|
||||
return;
|
||||
}
|
||||
/*! \brief The debug transportfunction
|
||||
*
|
||||
* This type of transaction is just forwarded and not recorded.
|
||||
* \param trans is the generic payload of the transaction
|
||||
* \return the sync state of the transaction
|
||||
*/
|
||||
template< typename TYPES>
|
||||
unsigned int tlm2_recorder<TYPES>::transport_dbg(typename TYPES::tlm_payload_type& trans) {
|
||||
unsigned int count = fw_port->transport_dbg(trans);
|
||||
return count;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
|
||||
#endif /* TLM2_RECORDER_H_ */
|
61
scv_tr_sqlite/scv4tlm/tlm2_recorder_module.h
Normal file
61
scv_tr_sqlite/scv4tlm/tlm2_recorder_module.h
Normal file
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* tlm_recorder.h
|
||||
*
|
||||
* Created on: 07.11.2015
|
||||
* Author: eyck
|
||||
*/
|
||||
|
||||
#ifndef TLM2_RECORDER_MODULE_H_
|
||||
#define TLM2_RECORDER_MODULE_H_
|
||||
|
||||
#include <tlm_utils/simple_initiator_socket.h>
|
||||
#include <tlm_utils/simple_target_socket.h>
|
||||
#include "tlm2_recorder.h"
|
||||
|
||||
namespace scv4tlm {
|
||||
/*! \brief The TLM2 transaction recorder
|
||||
*
|
||||
* This module records all TLM transaction to a SCV transaction stream for further viewing and analysis.
|
||||
* The handle of the created transaction is storee in an tlm_extension so that another instance of the scv_tlm2_recorder
|
||||
* e.g. further down the opath can link to it.
|
||||
* The transaction recorder is simply bound between an existing pair of initiator and target sockets
|
||||
*/
|
||||
template<unsigned int BUSWIDTH = 32, typename TYPES=tlm::tlm_base_protocol_types>
|
||||
class tlm2_recorder_module: public sc_core::sc_module, public tlm2_recorder<TYPES> {
|
||||
public:
|
||||
SC_HAS_PROCESS(tlm2_recorder_module);
|
||||
//! The target socket of the recorder to be bound to the initiator
|
||||
tlm::tlm_target_socket<BUSWIDTH, TYPES, 1> target;
|
||||
//! The initiator to be bound to the target socket
|
||||
tlm::tlm_initiator_socket<BUSWIDTH, TYPES, 1> initiator;
|
||||
|
||||
|
||||
/*! \brief The constructor of the component
|
||||
*
|
||||
* \param name is the SystemC module name of the recorder
|
||||
* \param tr_db is a pointer to a transaction recording database. If none is provided the default one is retrieved.
|
||||
* If this database is not initialized (e.g. by not calling scv_tr_db::set_default_db() ) recording is disabled.
|
||||
*/
|
||||
tlm2_recorder_module(sc_core::sc_module_name name, bool recording_enabled = true, scv_tr_db* tr_db = scv_tr_db::get_default_db())
|
||||
: sc_module(name)
|
||||
, tlm2_recorder<TYPES>(recording_enabled, tr_db)
|
||||
{
|
||||
// bind the sockets to the module
|
||||
target.bind(*this);
|
||||
initiator.bind(*this);
|
||||
}
|
||||
|
||||
virtual ~tlm2_recorder_module(){}
|
||||
|
||||
virtual tlm::tlm_fw_transport_if<tlm::tlm_base_protocol_types>* get_fw_if() {
|
||||
return initiator.get_base_port().operator->();
|
||||
}
|
||||
virtual tlm::tlm_bw_transport_if<tlm::tlm_base_protocol_types>* get_bw_if() {
|
||||
return target.get_base_port().operator->();
|
||||
}
|
||||
|
||||
};
|
||||
} // namespace
|
||||
|
||||
|
||||
#endif /* TLM2_RECORDER_MODULE_H_ */
|
557
scv_tr_sqlite/scv4tlm/tlm_gp_data.h
Normal file
557
scv_tr_sqlite/scv4tlm/tlm_gp_data.h
Normal file
@ -0,0 +1,557 @@
|
||||
/*
|
||||
* tlm_gp_data.h
|
||||
*
|
||||
* Created on: 07.11.2015
|
||||
* Author: eyck
|
||||
*/
|
||||
|
||||
#ifndef TLM_GP_DATA_H_
|
||||
#define TLM_GP_DATA_H_
|
||||
|
||||
#include <tlm>
|
||||
#include <assert.h>
|
||||
|
||||
namespace scv4tlm {
|
||||
|
||||
struct tlm_gp_data {
|
||||
//---------------
|
||||
// Constructors
|
||||
//---------------
|
||||
|
||||
// Default constructor
|
||||
tlm_gp_data()
|
||||
: address(0)
|
||||
, command(tlm::TLM_IGNORE_COMMAND)
|
||||
, data(0)
|
||||
, data_length(0)
|
||||
, response_status(tlm::TLM_INCOMPLETE_RESPONSE)
|
||||
, dmi(false)
|
||||
, byte_enable(0)
|
||||
, byte_enable_length(0)
|
||||
, streaming_width(0)
|
||||
, gp_option(tlm::TLM_MIN_PAYLOAD)
|
||||
, m_extensions(tlm::max_num_extensions())
|
||||
, m_ref_count(0)
|
||||
{
|
||||
}
|
||||
|
||||
explicit tlm_gp_data(tlm::tlm_mm_interface* mm)
|
||||
: address(0)
|
||||
, command(tlm::TLM_IGNORE_COMMAND)
|
||||
, data(0)
|
||||
, data_length(0)
|
||||
, response_status(tlm::TLM_INCOMPLETE_RESPONSE)
|
||||
, dmi(false)
|
||||
, byte_enable(0)
|
||||
, byte_enable_length(0)
|
||||
, streaming_width(0)
|
||||
, gp_option(tlm::TLM_MIN_PAYLOAD)
|
||||
, m_extensions(tlm::max_num_extensions())
|
||||
, m_ref_count(0) {
|
||||
}
|
||||
|
||||
int get_ref_count() const {
|
||||
return m_ref_count;
|
||||
}
|
||||
|
||||
void reset() {
|
||||
//should the other members be reset too?
|
||||
gp_option = tlm::TLM_MIN_PAYLOAD;
|
||||
m_extensions.free_entire_cache();
|
||||
}
|
||||
;
|
||||
|
||||
tlm_gp_data(const tlm::tlm_generic_payload& x)
|
||||
: address(x.get_address())
|
||||
, command(x.get_command())
|
||||
, data(x.get_data_ptr())
|
||||
, data_length(x.get_data_length())
|
||||
, response_status(x.get_response_status())
|
||||
, dmi(x.is_dmi_allowed())
|
||||
, byte_enable(x.get_byte_enable_ptr())
|
||||
, byte_enable_length(x.get_byte_enable_length())
|
||||
, streaming_width(x.get_streaming_width())
|
||||
, gp_option(x.get_gp_option())
|
||||
, m_extensions(tlm::max_num_extensions())
|
||||
, m_ref_count(0)
|
||||
{
|
||||
}
|
||||
private:
|
||||
//disabled copy ctor and assignment operator.
|
||||
// Copy constructor
|
||||
tlm_gp_data(const tlm_gp_data& x)
|
||||
: address(x.get_address())
|
||||
, command(x.get_command())
|
||||
, data(x.get_data_ptr())
|
||||
, data_length(x.get_data_length())
|
||||
, response_status(x.get_response_status())
|
||||
, dmi(x.is_dmi_allowed())
|
||||
, byte_enable(x.get_byte_enable_ptr())
|
||||
, byte_enable_length(x.get_byte_enable_length())
|
||||
, streaming_width(x.get_streaming_width())
|
||||
, gp_option(x.gp_option)
|
||||
, m_extensions(tlm::max_num_extensions())
|
||||
, m_ref_count(0)
|
||||
{
|
||||
}
|
||||
public:
|
||||
// Assignment operator needed for SCV introspection
|
||||
tlm_gp_data& operator=(const tlm_gp_data& x) {
|
||||
command = x.get_command();
|
||||
address = x.get_address();
|
||||
data = x.get_data_ptr();
|
||||
data_length = x.get_data_length();
|
||||
response_status = x.get_response_status();
|
||||
byte_enable = x.get_byte_enable_ptr();
|
||||
byte_enable_length = x.get_byte_enable_length();
|
||||
streaming_width = x.get_streaming_width();
|
||||
gp_option = x.get_gp_option();
|
||||
dmi = x.is_dmi_allowed();
|
||||
|
||||
// extension copy: all extension arrays must be of equal size by
|
||||
// construction (i.e. it must either be constructed after C++
|
||||
// static construction time, or the resize_extensions() method must
|
||||
// have been called prior to using the object)
|
||||
for (unsigned int i = 0; i < m_extensions.size(); i++) {
|
||||
m_extensions[i] = x.get_extension(i);
|
||||
}
|
||||
return (*this);
|
||||
}
|
||||
|
||||
// non-virtual deep-copying of the object
|
||||
void deep_copy_from(const scv4tlm::tlm_gp_data & other) {
|
||||
command = other.get_command();
|
||||
address = other.get_address();
|
||||
data_length = other.get_data_length();
|
||||
response_status = other.get_response_status();
|
||||
byte_enable_length = other.get_byte_enable_length();
|
||||
streaming_width = other.get_streaming_width();
|
||||
gp_option = other.get_gp_option();
|
||||
dmi = other.is_dmi_allowed();
|
||||
|
||||
// deep copy data
|
||||
// there must be enough space in the target transaction!
|
||||
if (data && other.get_data_ptr()) {
|
||||
memcpy(data, other.get_data_ptr(), data_length);
|
||||
}
|
||||
// deep copy byte enables
|
||||
// there must be enough space in the target transaction!
|
||||
if (byte_enable && other.get_byte_enable_ptr()) {
|
||||
memcpy(byte_enable, other.get_byte_enable_ptr(), byte_enable_length);
|
||||
}
|
||||
// deep copy extensions (sticky and non-sticky)
|
||||
for (unsigned int i = 0; i < other.m_extensions.size(); i++) {
|
||||
if (other.get_extension(i)) { //original has extension i
|
||||
if (!m_extensions[i]) { //We don't: clone.
|
||||
tlm::tlm_extension_base *ext = other.get_extension(i)->clone();
|
||||
if (ext) //extension may not be clonable.
|
||||
{
|
||||
set_extension(i, ext);
|
||||
}
|
||||
} else { //We already have such extension. Copy original over it.
|
||||
m_extensions[i]->copy_from(*other.get_extension(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// To update the state of the original generic payload from a deep copy
|
||||
// Assumes that "other" was created from the original by calling deep_copy_from
|
||||
// Argument use_byte_enable_on_read determines whether to use or ignores byte enables
|
||||
// when copying back the data array on a read command
|
||||
|
||||
void update_original_from(const tlm::tlm_generic_payload & other, bool use_byte_enable_on_read = true) {
|
||||
// Copy back extensions that are present on the original
|
||||
// update_extensions_from(other);
|
||||
|
||||
// Copy back the response status and DMI hint attributes
|
||||
response_status = other.get_response_status();
|
||||
dmi = other.is_dmi_allowed();
|
||||
|
||||
// Copy back the data array for a read command only
|
||||
// deep_copy_from allowed null pointers, and so will we
|
||||
// We assume the arrays are the same size
|
||||
// We test for equal pointers in case the original and the copy share the same array
|
||||
|
||||
if (is_read() && data && other.get_data_ptr() && data != other.get_data_ptr()) {
|
||||
if (byte_enable && use_byte_enable_on_read) {
|
||||
if (byte_enable_length == 8 && data_length % 8 == 0) {
|
||||
// Optimized implementation copies 64-bit words by masking
|
||||
for (unsigned int i = 0; i < data_length; i += 8) {
|
||||
typedef sc_dt::uint64* u;
|
||||
*reinterpret_cast<u>(&data[i]) &= ~*reinterpret_cast<u>(byte_enable);
|
||||
*reinterpret_cast<u>(&data[i]) |= *reinterpret_cast<u>(&other.get_data_ptr()[i])
|
||||
& *reinterpret_cast<u>(byte_enable);
|
||||
}
|
||||
} else if (byte_enable_length == 4 && data_length % 4 == 0) {
|
||||
// Optimized implementation copies 32-bit words by masking
|
||||
for (unsigned int i = 0; i < data_length; i += 4) {
|
||||
typedef unsigned int* u;
|
||||
*reinterpret_cast<u>(&data[i]) &= ~*reinterpret_cast<u>(byte_enable);
|
||||
*reinterpret_cast<u>(&data[i]) |= *reinterpret_cast<u>(&other.get_data_ptr()[i])
|
||||
& *reinterpret_cast<u>(byte_enable);
|
||||
}
|
||||
} else
|
||||
// Unoptimized implementation
|
||||
for (unsigned int i = 0; i < data_length; i++)
|
||||
if (byte_enable[i % byte_enable_length])
|
||||
data[i] = other.get_data_ptr()[i];
|
||||
} else
|
||||
memcpy(data, other.get_data_ptr(), data_length);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
void update_extensions_from(const tlm::tlm_generic_payload & other) {
|
||||
// deep copy extensions that are already present
|
||||
for (unsigned int i = 0; i < tlm::max_num_extensions(); i++) {
|
||||
if (other.get_extension(i)) { //original has extension i
|
||||
if (m_extensions[i]) { //We have it too. copy.
|
||||
m_extensions[i]->copy_from(*other.get_extension(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// Free all extensions. Useful when reusing a cloned transaction that doesn't have memory manager.
|
||||
// normal and sticky extensions are freed and extension array cleared.
|
||||
void free_all_extensions() {
|
||||
m_extensions.free_entire_cache();
|
||||
for (unsigned int i = 0; i < m_extensions.size(); i++) {
|
||||
if (m_extensions[i]) {
|
||||
m_extensions[i]->free();
|
||||
m_extensions[i] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
//--------------
|
||||
// Destructor
|
||||
//--------------
|
||||
virtual ~tlm_gp_data() {
|
||||
for(unsigned int i=0; i<m_extensions.size(); i++)
|
||||
if(m_extensions[i]) m_extensions[i]->free();
|
||||
}
|
||||
|
||||
//----------------
|
||||
// API (including setters & getters)
|
||||
//---------------
|
||||
|
||||
// Command related method
|
||||
bool is_read() const {
|
||||
return (command == tlm::TLM_READ_COMMAND);
|
||||
}
|
||||
void set_read() {
|
||||
command = tlm::TLM_READ_COMMAND;
|
||||
}
|
||||
bool is_write() const {
|
||||
return (command == tlm::TLM_WRITE_COMMAND);
|
||||
}
|
||||
void set_write() {
|
||||
command = tlm::TLM_WRITE_COMMAND;
|
||||
}
|
||||
tlm::tlm_command get_command() const {
|
||||
return command;
|
||||
}
|
||||
void set_command(const tlm::tlm_command command) {
|
||||
this->command = command;
|
||||
}
|
||||
|
||||
// Address related methods
|
||||
sc_dt::uint64 get_address() const {
|
||||
return address;
|
||||
}
|
||||
void set_address(const sc_dt::uint64 address) {
|
||||
this->address = address;
|
||||
}
|
||||
|
||||
// Data related methods
|
||||
unsigned char* get_data_ptr() const {
|
||||
return data;
|
||||
}
|
||||
void set_data_ptr(unsigned char* data) {
|
||||
this->data = data;
|
||||
}
|
||||
|
||||
// Transaction length (in bytes) related methods
|
||||
unsigned int get_data_length() const {
|
||||
return data_length;
|
||||
}
|
||||
void set_data_length(const unsigned int length) {
|
||||
data_length = length;
|
||||
}
|
||||
|
||||
// Response status related methods
|
||||
bool is_response_ok() const {
|
||||
return (response_status > 0);
|
||||
}
|
||||
bool is_response_error() const {
|
||||
return (response_status <= 0);
|
||||
}
|
||||
tlm::tlm_response_status get_response_status() const {
|
||||
return response_status;
|
||||
}
|
||||
void set_response_status(const tlm::tlm_response_status response_status) {
|
||||
this->response_status = response_status;
|
||||
}
|
||||
std::string get_response_string() const {
|
||||
switch (response_status) {
|
||||
case tlm::TLM_OK_RESPONSE:
|
||||
return "TLM_OK_RESPONSE";
|
||||
case tlm::TLM_INCOMPLETE_RESPONSE:
|
||||
return "TLM_INCOMPLETE_RESPONSE";
|
||||
case tlm::TLM_GENERIC_ERROR_RESPONSE:
|
||||
return "TLM_GENERIC_ERROR_RESPONSE";
|
||||
case tlm::TLM_ADDRESS_ERROR_RESPONSE:
|
||||
return "TLM_ADDRESS_ERROR_RESPONSE";
|
||||
case tlm::TLM_COMMAND_ERROR_RESPONSE:
|
||||
return "TLM_COMMAND_ERROR_RESPONSE";
|
||||
case tlm::TLM_BURST_ERROR_RESPONSE:
|
||||
return "TLM_BURST_ERROR_RESPONSE";
|
||||
case tlm::TLM_BYTE_ENABLE_ERROR_RESPONSE:
|
||||
return "TLM_BYTE_ENABLE_ERROR_RESPONSE";
|
||||
}
|
||||
return "TLM_UNKNOWN_RESPONSE";
|
||||
}
|
||||
|
||||
// Streaming related methods
|
||||
unsigned int get_streaming_width() const {
|
||||
return streaming_width;
|
||||
}
|
||||
void set_streaming_width(const unsigned int streaming_width) {
|
||||
this->streaming_width = streaming_width;
|
||||
}
|
||||
|
||||
// Byte enable related methods
|
||||
unsigned char* get_byte_enable_ptr() const {
|
||||
return byte_enable;
|
||||
}
|
||||
void set_byte_enable_ptr(unsigned char* byte_enable) {
|
||||
this->byte_enable = byte_enable;
|
||||
}
|
||||
unsigned int get_byte_enable_length() const {
|
||||
return byte_enable_length;
|
||||
}
|
||||
void set_byte_enable_length(const unsigned int byte_enable_length) {
|
||||
this->byte_enable_length = byte_enable_length;
|
||||
}
|
||||
|
||||
// This is the "DMI-hint" a slave can set this to true if it
|
||||
// wants to indicate that a DMI request would be supported:
|
||||
void set_dmi_allowed(bool dmi_allowed) {
|
||||
dmi = dmi_allowed;
|
||||
}
|
||||
bool is_dmi_allowed() const {
|
||||
return dmi;
|
||||
}
|
||||
|
||||
// Use full set of attributes in DMI/debug?
|
||||
tlm::tlm_gp_option get_gp_option() const {
|
||||
return gp_option;
|
||||
}
|
||||
void set_gp_option(const tlm::tlm_gp_option gp_opt) {
|
||||
gp_option = gp_opt;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
/* --------------------------------------------------------------------- */
|
||||
/* Generic Payload attributes: */
|
||||
/* --------------------------------------------------------------------- */
|
||||
/* - m_command : Type of transaction. Three values supported: */
|
||||
/* - TLM_WRITE_COMMAND */
|
||||
/* - TLM_READ_COMMAND */
|
||||
/* - TLM_IGNORE_COMMAND */
|
||||
/* - m_address : Transaction base address (byte-addressing). */
|
||||
/* - m_data : When m_command = TLM_WRITE_COMMAND contains a */
|
||||
/* pointer to the data to be written in the target.*/
|
||||
/* When m_command = TLM_READ_COMMAND contains a */
|
||||
/* pointer where to copy the data read from the */
|
||||
/* target. */
|
||||
/* - m_length : Total number of bytes of the transaction. */
|
||||
/* - m_response_status : This attribute indicates whether an error has */
|
||||
/* occurred during the transaction. */
|
||||
/* Values supported are: */
|
||||
/* - TLM_OK_RESP */
|
||||
/* - TLM_INCOMPLETE_RESP */
|
||||
/* - TLM_GENERIC_ERROR_RESP */
|
||||
/* - TLM_ADDRESS_ERROR_RESP */
|
||||
/* - TLM_COMMAND_ERROR_RESP */
|
||||
/* - TLM_BURST_ERROR_RESP */
|
||||
/* - TLM_BYTE_ENABLE_ERROR_RESP */
|
||||
/* */
|
||||
/* - m_byte_enable : It can be used to create burst transfers where */
|
||||
/* the address increment between each beat is greater */
|
||||
/* than the word length of each beat, or to place */
|
||||
/* words in selected byte lanes of a bus. */
|
||||
/* - m_byte_enable_length : For a read or a write command, the target */
|
||||
/* interpret the byte enable length attribute as the */
|
||||
/* number of elements in the bytes enable array. */
|
||||
/* - m_streaming_width : */
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
sc_dt::uint64 address;
|
||||
tlm::tlm_command command;
|
||||
unsigned char* data;
|
||||
unsigned int data_length;
|
||||
tlm::tlm_response_status response_status;
|
||||
bool dmi;
|
||||
unsigned char* byte_enable;
|
||||
unsigned int byte_enable_length;
|
||||
unsigned int streaming_width;
|
||||
tlm::tlm_gp_option gp_option;
|
||||
|
||||
public:
|
||||
|
||||
/* --------------------------------------------------------------------- */
|
||||
/* Dynamic extension mechanism: */
|
||||
/* --------------------------------------------------------------------- */
|
||||
/* The extension mechanism is intended to enable initiator modules to */
|
||||
/* optionally and transparently add data fields to the */
|
||||
/* tlm_generic_payload. Target modules are free to check for extensions */
|
||||
/* and may or may not react to the data in the extension fields. The */
|
||||
/* definition of the extensions' semantics is solely in the */
|
||||
/* responsibility of the user. */
|
||||
/* */
|
||||
/* The following rules apply: */
|
||||
/* */
|
||||
/* - Every extension class must be derived from tlm_extension, e.g.: */
|
||||
/* class my_extension : public tlm_extension<my_extension> { ... } */
|
||||
/* */
|
||||
/* - A tlm_generic_payload object should be constructed after C++ */
|
||||
/* static initialization time. This way it is guaranteed that the */
|
||||
/* extension array is of sufficient size to hold all possible */
|
||||
/* extensions. Alternatively, the initiator module can enforce a valid */
|
||||
/* extension array size by calling the resize_extensions() method */
|
||||
/* once before the first transaction with the payload object is */
|
||||
/* initiated. */
|
||||
/* */
|
||||
/* - Initiators should use the the set_extension(e) or clear_extension(e)*/
|
||||
/* methods for manipulating the extension array. The type of the */
|
||||
/* argument must be a pointer to the specific registered extension */
|
||||
/* type (my_extension in the above example) and is used to */
|
||||
/* automatically locate the appropriate index in the array. */
|
||||
/* */
|
||||
/* - Targets can check for a specific extension by calling */
|
||||
/* get_extension(e). e will point to zero if the extension is not */
|
||||
/* present. */
|
||||
/* */
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
// Stick the pointer to an extension into the vector, return the
|
||||
// previous value:
|
||||
template<typename T> T* set_extension(T* ext) {
|
||||
return static_cast<T*>(set_extension(T::ID, ext));
|
||||
}
|
||||
|
||||
// non-templatized version with manual index:
|
||||
tlm::tlm_extension_base* set_extension(unsigned int index, tlm::tlm_extension_base* ext) {
|
||||
tlm::tlm_extension_base* tmp = m_extensions[index];
|
||||
m_extensions[index] = ext;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
// Check for an extension, ext will point to 0 if not present
|
||||
template<typename T> void get_extension(T*& ext) const {
|
||||
ext = get_extension<T>();
|
||||
}
|
||||
template<typename T> T* get_extension() const {
|
||||
return static_cast<T*>(get_extension(T::ID));
|
||||
}
|
||||
// Non-templatized version with manual index:
|
||||
tlm::tlm_extension_base* get_extension(unsigned int index) const {
|
||||
return m_extensions[index];
|
||||
}
|
||||
|
||||
//this call just removes the extension from the txn but does not
|
||||
// call free() or tells the MM to do so
|
||||
// it return false if there was active MM so you are now in an unsafe situation
|
||||
// recommended use: when 100% sure there is no MM
|
||||
template<typename T> void clear_extension(const T* ext) {
|
||||
clear_extension<T>();
|
||||
}
|
||||
|
||||
//this call just removes the extension from the txn but does not
|
||||
// call free() or tells the MM to do so
|
||||
// it return false if there was active MM so you are now in an unsafe situation
|
||||
// recommended use: when 100% sure there is no MM
|
||||
template<typename T> void clear_extension() {
|
||||
clear_extension(T::ID);
|
||||
}
|
||||
|
||||
//this call removes the extension from the txn and does
|
||||
// call free() or tells the MM to do so when the txn is finally done
|
||||
// recommended use: when not sure there is no MM
|
||||
template<typename T> void release_extension(T* ext) {
|
||||
release_extension<T>();
|
||||
}
|
||||
|
||||
//this call removes the extension from the txn and does
|
||||
// call free() or tells the MM to do so when the txn is finally done
|
||||
// recommended use: when not sure there is no MM
|
||||
template<typename T> void release_extension() {
|
||||
release_extension(T::ID);
|
||||
}
|
||||
|
||||
private:
|
||||
// Non-templatized version with manual index
|
||||
void clear_extension(unsigned int index) {
|
||||
m_extensions[index] = static_cast<tlm::tlm_extension_base*>(0);
|
||||
}
|
||||
// Non-templatized version with manual index
|
||||
void release_extension(unsigned int index) {
|
||||
m_extensions[index]->free();
|
||||
m_extensions[index] = static_cast<tlm::tlm_extension_base*>(0);
|
||||
}
|
||||
|
||||
public:
|
||||
// Make sure the extension array is large enough. Can be called once by
|
||||
// an initiator module (before issuing the first transaction) to make
|
||||
// sure that the extension array is of correct size. This is only needed
|
||||
// if the initiator cannot guarantee that the generic payload object is
|
||||
// allocated after C++ static construction time.
|
||||
void resize_extensions() {
|
||||
m_extensions.expand(tlm::max_num_extensions());
|
||||
}
|
||||
|
||||
private:
|
||||
tlm::tlm_array<tlm::tlm_extension_base*> m_extensions;
|
||||
unsigned int m_ref_count;
|
||||
};
|
||||
|
||||
|
||||
struct tlm_dmi_data {
|
||||
tlm_dmi_data()
|
||||
:dmi_ptr(0)
|
||||
,dmi_start_address(0)
|
||||
,dmi_end_address(0)
|
||||
,dmi_access(tlm::tlm_dmi::DMI_ACCESS_NONE)
|
||||
,dmi_read_latency(0)
|
||||
,dmi_write_latency(0)
|
||||
{}
|
||||
|
||||
tlm_dmi_data(tlm::tlm_dmi& dmi_data)
|
||||
:dmi_ptr(dmi_data.get_dmi_ptr())
|
||||
,dmi_start_address(dmi_data.get_start_address())
|
||||
,dmi_end_address(dmi_data.get_end_address())
|
||||
,dmi_access(dmi_data.get_granted_access())
|
||||
,dmi_read_latency(dmi_data.get_read_latency().value())
|
||||
,dmi_write_latency(dmi_data.get_write_latency().value())
|
||||
{}
|
||||
//--------------
|
||||
// Destructor
|
||||
//--------------
|
||||
virtual ~tlm_dmi_data() {}
|
||||
|
||||
unsigned char* dmi_ptr;
|
||||
sc_dt::uint64 dmi_start_address;
|
||||
sc_dt::uint64 dmi_end_address;
|
||||
tlm::tlm_dmi::dmi_access_e dmi_access;
|
||||
sc_dt::uint64 dmi_read_latency;
|
||||
sc_dt::uint64 dmi_write_latency;
|
||||
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
#endif /* TLM_GP_DATA_H_ */
|
131
scv_tr_sqlite/scv4tlm/tlm_gp_data_ext.h
Normal file
131
scv_tr_sqlite/scv4tlm/tlm_gp_data_ext.h
Normal file
@ -0,0 +1,131 @@
|
||||
/*
|
||||
* tlm_gp_data_ext.h
|
||||
*
|
||||
* Created on: 07.11.2015
|
||||
* Author: eyck
|
||||
*/
|
||||
|
||||
#ifndef TLM_GP_DATA_EXT_H_
|
||||
#define TLM_GP_DATA_EXT_H_
|
||||
|
||||
#include "scv.h"
|
||||
#include "tlm_gp_data.h"
|
||||
|
||||
template<>
|
||||
class scv_extensions<tlm::tlm_command> : public scv_enum_base<tlm::tlm_command> {
|
||||
public:
|
||||
SCV_ENUM_CTOR(tlm::tlm_command) {
|
||||
SCV_ENUM(tlm::TLM_READ_COMMAND);
|
||||
SCV_ENUM(tlm::TLM_WRITE_COMMAND);
|
||||
SCV_ENUM(tlm::TLM_IGNORE_COMMAND);
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
class scv_extensions<tlm::tlm_response_status> : public scv_enum_base<tlm::tlm_response_status> {
|
||||
public:
|
||||
SCV_ENUM_CTOR(tlm::tlm_response_status) {
|
||||
SCV_ENUM(tlm::TLM_OK_RESPONSE);
|
||||
SCV_ENUM(tlm::TLM_INCOMPLETE_RESPONSE);
|
||||
SCV_ENUM(tlm::TLM_GENERIC_ERROR_RESPONSE);
|
||||
SCV_ENUM(tlm::TLM_ADDRESS_ERROR_RESPONSE);
|
||||
SCV_ENUM(tlm::TLM_COMMAND_ERROR_RESPONSE);
|
||||
SCV_ENUM(tlm::TLM_BURST_ERROR_RESPONSE);
|
||||
SCV_ENUM(tlm::TLM_BYTE_ENABLE_ERROR_RESPONSE);
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
class scv_extensions<tlm::tlm_gp_option> : public scv_enum_base<tlm::tlm_gp_option> {
|
||||
public:
|
||||
SCV_ENUM_CTOR(tlm::tlm_gp_option) {
|
||||
SCV_ENUM(tlm::TLM_MIN_PAYLOAD);
|
||||
SCV_ENUM(tlm::TLM_FULL_PAYLOAD);
|
||||
SCV_ENUM(tlm::TLM_FULL_PAYLOAD_ACCEPTED);
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
class scv_extensions<tlm::tlm_phase_enum> : public scv_enum_base<tlm::tlm_phase_enum> {
|
||||
public:
|
||||
SCV_ENUM_CTOR(tlm::tlm_phase_enum) {
|
||||
SCV_ENUM(tlm::UNINITIALIZED_PHASE);
|
||||
SCV_ENUM(tlm::BEGIN_REQ);
|
||||
SCV_ENUM(tlm::END_REQ);
|
||||
SCV_ENUM(tlm::BEGIN_RESP);
|
||||
SCV_ENUM(tlm::END_RESP);
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
class scv_extensions<tlm::tlm_sync_enum> : public scv_enum_base<tlm::tlm_sync_enum> {
|
||||
public:
|
||||
SCV_ENUM_CTOR(tlm::tlm_sync_enum) {
|
||||
SCV_ENUM(tlm::TLM_ACCEPTED);
|
||||
SCV_ENUM(tlm::TLM_UPDATED);
|
||||
SCV_ENUM(tlm::TLM_COMPLETED);
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
class scv_extensions<scv4tlm::tlm_gp_data> : public scv_extensions_base<scv4tlm::tlm_gp_data> {
|
||||
public:
|
||||
scv_extensions<sc_dt::uint64> address;
|
||||
scv_extensions<tlm::tlm_command> command;
|
||||
scv_extensions<unsigned char*> data;
|
||||
scv_extensions<unsigned int> data_length;
|
||||
scv_extensions<tlm::tlm_response_status> response_status;
|
||||
scv_extensions<bool> dmi;
|
||||
scv_extensions<unsigned char*> byte_enable;
|
||||
scv_extensions<unsigned int> byte_enable_length;
|
||||
scv_extensions<unsigned int> streaming_width;
|
||||
scv_extensions<tlm::tlm_gp_option> gp_option;
|
||||
|
||||
SCV_EXTENSIONS_CTOR(scv4tlm::tlm_gp_data) {
|
||||
//must be in order
|
||||
SCV_FIELD(address);
|
||||
SCV_FIELD(command);
|
||||
SCV_FIELD(data);
|
||||
SCV_FIELD(data_length);
|
||||
SCV_FIELD(response_status);
|
||||
SCV_FIELD(dmi);
|
||||
SCV_FIELD(byte_enable);
|
||||
SCV_FIELD(byte_enable_length);
|
||||
SCV_FIELD(streaming_width);
|
||||
SCV_FIELD(gp_option);
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
class scv_extensions<tlm::tlm_dmi::dmi_access_e> : public scv_enum_base<tlm::tlm_dmi::dmi_access_e> {
|
||||
public:
|
||||
SCV_ENUM_CTOR(tlm::tlm_dmi::dmi_access_e) {
|
||||
SCV_ENUM(tlm::tlm_dmi::DMI_ACCESS_NONE);
|
||||
SCV_ENUM(tlm::tlm_dmi::DMI_ACCESS_READ);
|
||||
SCV_ENUM(tlm::tlm_dmi::DMI_ACCESS_WRITE);
|
||||
SCV_ENUM(tlm::tlm_dmi::DMI_ACCESS_READ_WRITE);
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
class scv_extensions<scv4tlm::tlm_dmi_data> : public scv_extensions_base<scv4tlm::tlm_dmi_data> {
|
||||
public:
|
||||
scv_extensions<unsigned char*> dmi_ptr;
|
||||
scv_extensions<sc_dt::uint64> dmi_start_address;
|
||||
scv_extensions<sc_dt::uint64> dmi_end_address;
|
||||
scv_extensions<tlm::tlm_dmi::dmi_access_e> dmi_access;
|
||||
scv_extensions<sc_dt::uint64> dmi_read_latency;
|
||||
scv_extensions<sc_dt::uint64> dmi_write_latency;
|
||||
SCV_EXTENSIONS_CTOR(scv4tlm::tlm_dmi_data) {
|
||||
//must be in order
|
||||
SCV_FIELD(dmi_ptr);
|
||||
SCV_FIELD(dmi_start_address);
|
||||
SCV_FIELD(dmi_end_address);
|
||||
SCV_FIELD(dmi_access);
|
||||
SCV_FIELD(dmi_read_latency);
|
||||
SCV_FIELD(dmi_write_latency);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif /* TLM_GP_DATA_EXT_H_ */
|
125
scv_tr_sqlite/scv4tlm/tlm_rec_initiator_socket.h
Normal file
125
scv_tr_sqlite/scv4tlm/tlm_rec_initiator_socket.h
Normal file
@ -0,0 +1,125 @@
|
||||
/*
|
||||
* tlm_rec_target_socket.h
|
||||
*
|
||||
* Created on: 08.11.2015
|
||||
* Author: eyck
|
||||
*/
|
||||
|
||||
#ifndef TLM_REC_INITIATOR_SOCKET_H_
|
||||
#define TLM_REC_INITIATOR_SOCKET_H_
|
||||
|
||||
#include <tlm_core/tlm_2/tlm_sockets/tlm_initiator_socket.h>
|
||||
|
||||
#include "tlm2_recorder.h"
|
||||
|
||||
namespace scv4tlm {
|
||||
template<unsigned int BUSWIDTH = 32, typename TYPES = tlm::tlm_base_protocol_types, int N = 1
|
||||
#if !(defined SYSTEMC_VERSION & SYSTEMC_VERSION <= 20050714)
|
||||
, sc_core::sc_port_policy POL = sc_core::SC_ONE_OR_MORE_BOUND
|
||||
#endif
|
||||
>
|
||||
class tlm_rec_initiator_socket: public tlm::tlm_initiator_socket<BUSWIDTH
|
||||
, TYPES
|
||||
, N
|
||||
#if !(defined SYSTEMC_VERSION & SYSTEMC_VERSION <= 20050714)
|
||||
, POL
|
||||
#endif
|
||||
> {
|
||||
static std::string gen_name(const char* first, const char* second){
|
||||
std::stringstream ss;
|
||||
ss<<first<<"_"<<second;
|
||||
return ss.str();
|
||||
}
|
||||
public:
|
||||
typedef tlm::tlm_fw_transport_if<TYPES> fw_interface_type;
|
||||
typedef tlm::tlm_bw_transport_if<TYPES> bw_interface_type;
|
||||
typedef sc_core::sc_port<fw_interface_type, N
|
||||
#if !(defined SYSTEMC_VERSION & SYSTEMC_VERSION <= 20050714)
|
||||
, POL
|
||||
#endif
|
||||
> port_type;
|
||||
typedef sc_core::sc_export<bw_interface_type> export_type;
|
||||
typedef tlm::tlm_base_target_socket_b<BUSWIDTH,
|
||||
fw_interface_type,
|
||||
bw_interface_type> base_target_socket_type;
|
||||
typedef tlm::tlm_base_initiator_socket_b<BUSWIDTH,
|
||||
fw_interface_type,
|
||||
bw_interface_type> base_type;
|
||||
|
||||
tlm_rec_initiator_socket() :
|
||||
tlm::tlm_initiator_socket<BUSWIDTH
|
||||
, TYPES
|
||||
, N
|
||||
#if !(defined SYSTEMC_VERSION & SYSTEMC_VERSION <= 20050714)
|
||||
, POL
|
||||
#endif
|
||||
>()
|
||||
,recorder()
|
||||
{
|
||||
}
|
||||
|
||||
explicit tlm_rec_initiator_socket(const char* name) :
|
||||
tlm::tlm_initiator_socket<BUSWIDTH
|
||||
, TYPES
|
||||
, N
|
||||
#if !(defined SYSTEMC_VERSION & SYSTEMC_VERSION <= 20050714)
|
||||
, POL
|
||||
#endif
|
||||
>(name)
|
||||
,recorder(gen_name(name, "rec").c_str())
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~tlm_rec_initiator_socket(){}
|
||||
|
||||
virtual const char* kind() const {
|
||||
return "tlm_rec_target_socket";
|
||||
}
|
||||
//
|
||||
// Bind initiator socket to target socket
|
||||
// - Binds the port of the initiator socket to the export of the target
|
||||
// socket
|
||||
// - Binds the port of the target socket to the export of the initiator
|
||||
// socket
|
||||
//
|
||||
virtual void bind(base_target_socket_type& s) {
|
||||
// initiator.port -> target.export
|
||||
(this->get_base_port())(recorder);
|
||||
recorder.fw_port(s.get_base_interface());
|
||||
// target.port -> initiator.export
|
||||
(s.get_base_port())(recorder);
|
||||
recorder.bw_port(this->get_base_interface());
|
||||
}
|
||||
//
|
||||
// Bind initiator socket to initiator socket (hierarchical bind)
|
||||
// - Binds both the export and the port
|
||||
//
|
||||
virtual void bind(base_type& s){
|
||||
// port
|
||||
(this->get_base_port())(recorder);
|
||||
recorder.fw_port(s.get_base_port());
|
||||
// export
|
||||
(s.get_base_export())(recorder);
|
||||
recorder.bw_port(this->get_base_export());
|
||||
}
|
||||
|
||||
//
|
||||
// Bind interface to socket
|
||||
// - Binds the interface to the export of this socket
|
||||
//
|
||||
virtual void bind(bw_interface_type& ifs) {
|
||||
(this->get_base_export())(ifs);
|
||||
}
|
||||
|
||||
void setExtensionRecording(tlm_extensions_recording_if<TYPES>* extensionRecording){
|
||||
recorder.setExtensionRecording(extensionRecording);
|
||||
}
|
||||
|
||||
protected:
|
||||
scv4tlm::tlm2_recorder<TYPES> recorder;
|
||||
};
|
||||
|
||||
}
|
||||
// namespace scv4tlm
|
||||
|
||||
#endif /* TLM_REC_TARGET_SOCKET_H_ */
|
119
scv_tr_sqlite/scv4tlm/tlm_rec_target_socket.h
Normal file
119
scv_tr_sqlite/scv4tlm/tlm_rec_target_socket.h
Normal file
@ -0,0 +1,119 @@
|
||||
/*
|
||||
* tlm_rec_target_socket.h
|
||||
*
|
||||
* Created on: 08.11.2015
|
||||
* Author: eyck
|
||||
*/
|
||||
|
||||
#ifndef TLM_REC_TARGET_SOCKET_H_
|
||||
#define TLM_REC_TARGET_SOCKET_H_
|
||||
|
||||
#include <tlm_core/tlm_2/tlm_sockets/tlm_target_socket.h>
|
||||
|
||||
#include "tlm2_recorder.h"
|
||||
|
||||
namespace scv4tlm {
|
||||
template<unsigned int BUSWIDTH = 32, typename TYPES = tlm::tlm_base_protocol_types, int N = 1
|
||||
#if !(defined SYSTEMC_VERSION & SYSTEMC_VERSION <= 20050714)
|
||||
, sc_core::sc_port_policy POL = sc_core::SC_ONE_OR_MORE_BOUND
|
||||
#endif
|
||||
>
|
||||
class tlm_rec_target_socket: public tlm::tlm_target_socket<BUSWIDTH
|
||||
, TYPES
|
||||
, N
|
||||
#if !(defined SYSTEMC_VERSION & SYSTEMC_VERSION <= 20050714)
|
||||
, POL
|
||||
#endif
|
||||
> {
|
||||
static std::string gen_name(const char* first, const char* second){
|
||||
std::stringstream ss;
|
||||
ss<<first<<"_"<<second;
|
||||
return ss.str();
|
||||
}
|
||||
public:
|
||||
typedef tlm::tlm_fw_transport_if<TYPES> fw_interface_type;
|
||||
typedef tlm::tlm_bw_transport_if<TYPES> bw_interface_type;
|
||||
typedef sc_core::sc_port<bw_interface_type, N
|
||||
#if !(defined SYSTEMC_VERSION & SYSTEMC_VERSION <= 20050714)
|
||||
, POL
|
||||
#endif
|
||||
> port_type;
|
||||
|
||||
typedef sc_core::sc_export<fw_interface_type> export_type;
|
||||
typedef tlm::tlm_base_initiator_socket_b<BUSWIDTH, fw_interface_type, bw_interface_type> base_initiator_socket_type;
|
||||
|
||||
typedef tlm::tlm_base_target_socket_b<BUSWIDTH, fw_interface_type, bw_interface_type> base_type;
|
||||
|
||||
tlm_rec_target_socket() :
|
||||
tlm::tlm_target_socket<BUSWIDTH
|
||||
, TYPES
|
||||
, N
|
||||
#if !(defined SYSTEMC_VERSION & SYSTEMC_VERSION <= 20050714)
|
||||
, POL
|
||||
#endif
|
||||
>()
|
||||
,recorder()
|
||||
{
|
||||
}
|
||||
|
||||
explicit tlm_rec_target_socket(const char* name) :
|
||||
tlm::tlm_target_socket<BUSWIDTH
|
||||
, TYPES
|
||||
, N
|
||||
#if !(defined SYSTEMC_VERSION & SYSTEMC_VERSION <= 20050714)
|
||||
, POL
|
||||
#endif
|
||||
>(name)
|
||||
,recorder(gen_name(name, "rec").c_str())
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~tlm_rec_target_socket(){}
|
||||
|
||||
virtual const char* kind() const {
|
||||
return "tlm_rec_target_socket";
|
||||
}
|
||||
//
|
||||
// Bind target socket to target socket (hierarchical bind)
|
||||
// - Binds both the export and the port
|
||||
//
|
||||
virtual void bind(base_type& s) {
|
||||
// export
|
||||
(this->get_base_export())(s.get_base_export()); // will be handled by bind(fw_interface_type& ifs)
|
||||
// port
|
||||
(s.get_base_port())(recorder); // bind the recording interface to the port, recording will use the m_port
|
||||
}
|
||||
//
|
||||
// Bind interface to socket
|
||||
// - Binds the interface to the export
|
||||
//
|
||||
virtual void bind(fw_interface_type& ifs){
|
||||
export_type* exp = &this->get_base_export();
|
||||
if( this == exp ) {
|
||||
export_type::bind(recorder); // non-virtual function call
|
||||
recorder.fw_port(ifs);
|
||||
recorder.bw_port(this->get_base_port());
|
||||
} else {
|
||||
exp->bind( ifs );
|
||||
}
|
||||
|
||||
}
|
||||
//
|
||||
// Forward to 'operator->()' of port class
|
||||
//
|
||||
bw_interface_type* operator->() {
|
||||
return &recorder;
|
||||
}
|
||||
|
||||
scv4tlm::tlm2_recorder<TYPES>& get_recorder(){
|
||||
return recorder;
|
||||
}
|
||||
|
||||
protected:
|
||||
scv4tlm::tlm2_recorder<TYPES> recorder;
|
||||
};
|
||||
|
||||
}
|
||||
// namespace scv4tlm
|
||||
|
||||
#endif /* TLM_REC_TARGET_SOCKET_H_ */
|
77
scv_tr_sqlite/scv4tlm/tlm_recording_extension.h
Normal file
77
scv_tr_sqlite/scv4tlm/tlm_recording_extension.h
Normal file
@ -0,0 +1,77 @@
|
||||
/*
|
||||
* tlm2_tx_record_extension.h
|
||||
*
|
||||
* Created on: 07.11.2015
|
||||
* Author: eyck
|
||||
*/
|
||||
|
||||
#ifndef TLM_RECORDING_EXTENSION_H_
|
||||
#define TLM_RECORDING_EXTENSION_H_
|
||||
|
||||
#include <scv.h>
|
||||
|
||||
namespace scv4tlm {
|
||||
|
||||
//! transaction relationships
|
||||
enum tx_rel {
|
||||
PARENT_CHILD = 0, /*!< indicates parent child relationship */
|
||||
PREDECESSOR_SUCCESSOR /*!< indicates predecessor successor relationship */
|
||||
};
|
||||
//! the string representation of the tx_rel
|
||||
static char const* tx_rel_str[] = { "PARENT/CHILD", "PRED/SUCC" };
|
||||
/*! \brief cast the tx_rel enum to a string
|
||||
*
|
||||
* \param tc_rel is the relationship enum
|
||||
*/
|
||||
inline const char* rel_str(tx_rel rel) {
|
||||
return (tx_rel_str[rel]);
|
||||
}
|
||||
|
||||
/*! \brief generic payload extension class holding the handle of the last recorded SCV transaction
|
||||
*
|
||||
* This extension is been used in the \ref scv_tlm2_recorder. The recorder stores the handle to the generated SCV transaction and
|
||||
* forwrds it along with the generic payload. If the recorder finds an extension containing a valid handle it links the generated
|
||||
* SCV transdaction to the found one using the \ref PREDECESSOR releationship
|
||||
*/
|
||||
struct tlm_recording_extension: public tlm::tlm_extension<tlm_recording_extension> {
|
||||
/*! \brief clone the given extension and duplicate the SCV transaction handle.
|
||||
*
|
||||
*/
|
||||
virtual tlm_extension_base* clone() const {
|
||||
tlm_recording_extension* t = new tlm_recording_extension(this->txHandle, this->creator);
|
||||
return t;
|
||||
}
|
||||
/*! \brief copy data between extensions.
|
||||
*
|
||||
* \param from is the source extension.
|
||||
*/
|
||||
virtual void copy_from(tlm_extension_base const& from) {
|
||||
txHandle = static_cast<tlm_recording_extension const &>(from).txHandle;
|
||||
creator = static_cast<tlm_recording_extension const &>(from).creator;
|
||||
}
|
||||
/*! \brief constructor storing the handle of the transaction and the owner of this extension
|
||||
*
|
||||
* \param handle is the handle of the created SCV transaction.
|
||||
* \param creator_ is the pointer to the owner of this extension (usually an instance of scv_tlm2_recorder).
|
||||
*/
|
||||
tlm_recording_extension(scv_tr_handle handle, void* creator_) :
|
||||
txHandle(handle), creator(creator_) {
|
||||
}
|
||||
/*! \brief accessor to the owner, the property is read only.
|
||||
*
|
||||
*/
|
||||
void* get_creator() {
|
||||
return creator;
|
||||
}
|
||||
/*! \brief accessor to the SCV transaction handle.
|
||||
*
|
||||
*/
|
||||
scv_tr_handle txHandle;
|
||||
private:
|
||||
//! the owner of this transaction
|
||||
void* creator;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* TLM_RECORDING_EXTENSION_H_ */
|
Reference in New Issue
Block a user