package org.eclipse.linuxtools.tmf.ui.views.statesystem;
import java.io.File;
+import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.linuxtools.internal.tmf.ui.Activator;
+import org.eclipse.linuxtools.tmf.core.analysis.IAnalysisModule;
import org.eclipse.linuxtools.tmf.core.exceptions.AttributeNotFoundException;
import org.eclipse.linuxtools.tmf.core.exceptions.StateSystemDisposedException;
import org.eclipse.linuxtools.tmf.core.exceptions.StateValueTypeException;
import org.eclipse.linuxtools.tmf.core.signal.TmfTraceOpenedSignal;
import org.eclipse.linuxtools.tmf.core.signal.TmfTraceSelectedSignal;
import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateSystem;
+import org.eclipse.linuxtools.tmf.core.statesystem.ITmfAnalysisModuleWithStateSystems;
import org.eclipse.linuxtools.tmf.core.statevalue.ITmfStateValue;
import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
* We will first do all the queries for this trace, then update that
* sub-tree in the UI thread.
*/
- final Map<String, ITmfStateSystem> sss = currentTrace.getStateSystems();
+ Map<String, ITmfAnalysisModuleWithStateSystems> modules = currentTrace.getAnalysisModules(ITmfAnalysisModuleWithStateSystems.class);
+ final Map<String, ITmfStateSystem> sss = new HashMap<>();
final Map<String, List<ITmfStateInterval>> fullStates =
- new LinkedHashMap<String, List<ITmfStateInterval>>();
- for (Map.Entry<String, ITmfStateSystem> entry : sss.entrySet()) {
- String ssName = entry.getKey();
- ITmfStateSystem ss = entry.getValue();
- ss.waitUntilBuilt();
- if (ts == -1 || ts < ss.getStartTime() || ts > ss.getCurrentEndTime()) {
- ts = ss.getStartTime();
+ new LinkedHashMap<>();
+ for (Entry<String, ITmfAnalysisModuleWithStateSystems> entry : modules.entrySet()) {
+ /*
+ * FIXME: For now, this view is a way to execute and display
+ * state system. But with phase 2 of analysis API, we won't want
+ * to run state system that have not been requested. We will
+ * leave the title, but there won't be anything underneath.
+ */
+ ITmfAnalysisModuleWithStateSystems module = entry.getValue();
+ if (module instanceof IAnalysisModule) {
+ IAnalysisModule mod = (IAnalysisModule) module;
+ mod.schedule();
+ mod.waitForCompletion(new NullProgressMonitor());
}
- try {
- fullStates.put(ssName, ss.queryFullState(ts));
- } catch (TimeRangeException e) {
- /* We already checked the limits ourselves */
- throw new RuntimeException();
- } catch (StateSystemDisposedException e) {
- /* Probably shutting down, cancel and return */
- return;
+ for (ITmfStateSystem ss : module.getStateSystems()) {
+ if (ss == null) {
+ continue;
+ }
+ String ssName = module.getStateSystemId(ss);
+ sss.put(ssName, ss);
+
+ if (ts == -1 || ts < ss.getStartTime() || ts > ss.getCurrentEndTime()) {
+ ts = ss.getStartTime();
+ }
+ try {
+ fullStates.put(ssName, ss.queryFullState(ts));
+ } catch (TimeRangeException e) {
+ /* We already checked the limits ourselves */
+ throw new IllegalStateException();
+ } catch (StateSystemDisposedException e) {
+ /* Probably shutting down, cancel and return */
+ return;
+ }
}
}
* Calling with quark '-1' here to start with the root
* attribute, then it will be called recursively.
*/
- addChildren(ss, fullState, -1, item);
+ if (ss != null) {
+ addChildren(ss, fullState, -1, item);
+ }
}
/* Expand the first-level tree items */
/* For each trace... */
for (int traceNb = 0; traceNb < traces.length; traceNb++) {
- Map<String, ITmfStateSystem> sss = traces[traceNb].getStateSystems();
+ Map<String, ITmfAnalysisModuleWithStateSystems> modules = traces[traceNb].getAnalysisModules(ITmfAnalysisModuleWithStateSystems.class);
/* For each state system associated with this trace... */
int ssNb = 0;
- for (Map.Entry<String, ITmfStateSystem> entry : sss.entrySet()) {
+ for (Entry<String, ITmfAnalysisModuleWithStateSystems> module : modules.entrySet()) {
+
/*
* Even though we only use the value, it just feels safer to
* iterate the same way as before to keep the order the same.
*/
- final ITmfStateSystem ss = entry.getValue();
- final int traceNb1 = traceNb;
- final int ssNb1 = ssNb;
- ts = (ts == -1 ? ss.getStartTime() : ts);
- try {
- final List<ITmfStateInterval> fullState = ss.queryFullState(ts);
- fTree.getDisplay().asyncExec(new Runnable() {
- @Override
- public void run() {
- /* Get the tree item of the relevant state system */
- TreeItem traceItem = fTree.getItem(traceNb1);
- TreeItem item = traceItem.getItem(ssNb1);
- /* Update it, then its children, recursively */
- item.setText(VALUE_COL, emptyString);
- updateChildren(ss, fullState, -1, item);
- }
- });
-
- } catch (TimeRangeException e) {
- /*
- * This can happen in an experiment, if the user selects a
- * range valid in the experiment, but this specific does not
- * exist. Print "out-of-range" into all the values.
- */
- fTree.getDisplay().asyncExec(new Runnable() {
- @Override
- public void run() {
- TreeItem traceItem = fTree.getItem(traceNb1);
- TreeItem item = traceItem.getItem(ssNb1);
- markOutOfRange(item);
+ for (final ITmfStateSystem ss : module.getValue().getStateSystems()) {
+ final int traceNb1 = traceNb;
+ final int ssNb1 = ssNb;
+ if (ss != null) {
+ ts = (ts == -1 ? ss.getStartTime() : ts);
+ try {
+ final List<ITmfStateInterval> fullState = ss.queryFullState(ts);
+ fTree.getDisplay().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ /*
+ * Get the tree item of the relevant state
+ * system
+ */
+ TreeItem traceItem = fTree.getItem(traceNb1);
+ TreeItem item = traceItem.getItem(ssNb1);
+ /* Update it, then its children, recursively */
+ item.setText(VALUE_COL, emptyString);
+ updateChildren(ss, fullState, -1, item);
+ }
+ });
+
+ } catch (TimeRangeException e) {
+ /*
+ * This can happen in an experiment, if the user
+ * selects a range valid in the experiment, but this
+ * specific does not exist. Print "out-of-range"
+ * into all the values.
+ */
+ fTree.getDisplay().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ TreeItem traceItem = fTree.getItem(traceNb1);
+ TreeItem item = traceItem.getItem(ssNb1);
+ markOutOfRange(item);
+ }
+ });
+ } catch (StateSystemDisposedException e) {
+ return;
}
- });
- } catch (StateSystemDisposedException e) {
- return;
- }
+ }
- ssNb++;
+ ssNb++;
+ }
}
}
}
value = String.valueOf(state.unboxLong());
item.setText(TYPE_COL, Messages.TypeLong);
break;
+ case DOUBLE:
+ value = String.valueOf(state.unboxDouble());
+ item.setText(TYPE_COL, Messages.TypeDouble);
+ break;
case STRING:
value = state.unboxStr();
item.setText(TYPE_COL, Messages.TypeString);
Thread thread = new Thread("State system visualizer update") { //$NON-NLS-1$
@Override
public void run() {
- ITmfTimestamp currentTime = signal.getCurrentTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE);
+ ITmfTimestamp currentTime = signal.getBeginTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE);
fCurrentTimestamp = currentTime.getValue();
if (filterStatus) {
};
thread.start();
}
-
+
/**
* Update the display to use the updated timestamp format
*