use of org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphEntryModel in project tracecompass by tracecompass.
the class XmlDataProviderManagerTest method testOneTraceWithExperimentAnalysis.
/**
* Test getting the XML data provider for one trace, with an analysis that
* applies to an experiment
*/
@Test
public void testOneTraceWithExperimentAnalysis() {
ITmfTrace trace = null;
try {
// Initialize the trace and module
trace = XmlUtilsTest.initializeTrace(TEST_TRACE);
TmfTraceOpenedSignal signal = new TmfTraceOpenedSignal(this, trace, null);
((TmfTrace) trace).traceOpened(signal);
// The data provider manager uses opened traces from the manager
TmfTraceManager.getInstance().traceOpened(signal);
// Get the view element from the file
Element viewElement = TmfXmlUtils.getElementInFile(TmfXmlTestFiles.EXPERIMENT.getPath().toOSString(), TmfXmlStrings.TIME_GRAPH_VIEW, EXPERIMENT_VIEW_ID);
assertNotNull(viewElement);
ITimeGraphDataProvider<@NonNull TimeGraphEntryModel> timeGraphProvider = XmlDataProviderManager.getInstance().getTimeGraphProvider(trace, viewElement);
assertNull(timeGraphProvider);
} finally {
if (trace != null) {
trace.dispose();
TmfTraceManager.getInstance().traceClosed(new TmfTraceClosedSignal(this, trace));
}
}
}
use of org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphEntryModel in project tracecompass by tracecompass.
the class StateSystemDataProvider method fetchTree.
@Override
@NonNull
public TmfModelResponse<TmfTreeModel<TimeGraphEntryModel>> fetchTree(Map<String, Object> fetchParameters, @Nullable IProgressMonitor monitor) {
// need to create the tree
boolean fetchTreeIsComplete;
synchronized (fEntryBuilder) {
fModuleEntryModelList.clear();
fetchTreeIsComplete = addTrace(monitor);
if (monitor != null && monitor.isCanceled()) {
return new TmfModelResponse<>(null, Status.CANCELLED, CommonStatusMessage.TASK_CANCELLED);
}
}
List<TimeGraphEntryModel> entryList = buildEntryList(monitor);
Status status = fetchTreeIsComplete ? Status.COMPLETED : Status.RUNNING;
String msg = fetchTreeIsComplete ? CommonStatusMessage.COMPLETED : CommonStatusMessage.RUNNING;
return new TmfModelResponse<>(new TmfTreeModel<>(Collections.emptyList(), entryList), status, msg);
}
use of org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphEntryModel in project tracecompass by tracecompass.
the class ExampleTimeGraphDataProvider method fetchTree.
@Override
public TmfModelResponse<TmfTreeModel<@NonNull ITimeGraphEntryModel>> fetchTree(Map<String, Object> fetchParameters, @Nullable IProgressMonitor monitor) {
fModule.waitForInitialization();
ITmfStateSystem ss = fModule.getStateSystem();
if (ss == null) {
return new TmfModelResponse<>(null, ITmfResponse.Status.FAILED, CommonStatusMessage.ANALYSIS_INITIALIZATION_FAILED);
}
boolean isComplete = ss.waitUntilBuilt(0);
long endTime = ss.getCurrentEndTime();
// Make an entry for each base quark
List<ITimeGraphEntryModel> entryList = new ArrayList<>();
for (Integer quark : ss.getQuarks("CPUs", "*")) {
// $NON-NLS-1$ //$NON-NLS-2$
Long id = fIDToDisplayQuark.inverse().computeIfAbsent(quark, q -> sfAtomicId.getAndIncrement());
entryList.add(new TimeGraphEntryModel(id, -1, ss.getAttributeName(quark), ss.getStartTime(), endTime));
}
Status status = isComplete ? Status.COMPLETED : Status.RUNNING;
String msg = isComplete ? CommonStatusMessage.COMPLETED : CommonStatusMessage.RUNNING;
return new TmfModelResponse<>(new TmfTreeModel<>(Collections.emptyList(), entryList), status, msg);
}
use of org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphEntryModel in project tracecompass by tracecompass.
the class ActiveThreadsFilter method getOnCpuThreads.
@NonNull
private static Set<Long> getOnCpuThreads(@NonNull List<Range<Long>> cpuRanges, TmfTimeRange winRange, @NonNull ITmfTrace trace) {
ThreadStatusDataProvider threadStatusProvider = DataProviderManager.getInstance().getDataProvider(trace, ThreadStatusDataProvider.ID, ThreadStatusDataProvider.class);
if (threadStatusProvider == null) {
return Collections.emptySet();
}
long beginTS = winRange.getStartTime().getValue();
long endTS = winRange.getEndTime().getValue();
@NonNull Set<@NonNull Long> cpus = new HashSet<>();
for (Range<Long> range : cpuRanges) {
for (long cpu = range.lowerEndpoint(); cpu <= range.upperEndpoint(); cpu++) {
cpus.add(cpu);
}
}
SelectionTimeQueryFilter filter = new SelectionTimeQueryFilter(beginTS, endTS, 2, cpus);
Map<@NonNull String, @NonNull Object> parameters = FetchParametersUtils.selectionTimeQueryToMap(filter);
parameters.put(ThreadStatusDataProvider.ACTIVE_THREAD_FILTER_KEY, true);
TmfModelResponse<TmfTreeModel<@NonNull TimeGraphEntryModel>> response = threadStatusProvider.fetchTree(parameters, null);
TmfTreeModel<@NonNull TimeGraphEntryModel> model = response.getModel();
if (model == null) {
return Collections.emptySet();
}
HashSet<Long> onCpuThreads = Sets.newHashSet(Iterables.transform(model.getEntries(), TimeGraphEntryModel::getId));
return onCpuThreads == null ? Collections.emptySet() : onCpuThreads;
}
use of org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphEntryModel in project tracecompass by tracecompass.
the class FlameChartView method getNextEventAction.
/**
* Get the the next event action.
*
* @return The action object
*/
private Action getNextEventAction() {
Action nextAction = fNextEventAction;
if (nextAction == null) {
Action superNextAction = getTimeGraphViewer().getNextEventAction();
nextAction = new Action() {
@Override
public void run() {
TimeGraphViewer viewer = getTimeGraphViewer();
ITimeGraphEntry entry = viewer.getSelection();
if (entry instanceof TimeGraphEntry) {
TimeGraphEntry callStackEntry = (TimeGraphEntry) entry;
ITimeGraphDataProvider<? extends TimeGraphEntryModel> provider = getProvider(callStackEntry);
long selectionBegin = viewer.getSelectionBegin();
SelectionTimeQueryFilter filter = new SelectionTimeQueryFilter(selectionBegin, Long.MAX_VALUE, 2, Collections.singleton(callStackEntry.getEntryModel().getId()));
TmfModelResponse<@NonNull TimeGraphModel> response = provider.fetchRowModel(FetchParametersUtils.selectionTimeQueryToMap(filter), null);
TimeGraphModel model = response.getModel();
if (model == null || model.getRows().size() != 1) {
return;
}
List<@NonNull ITimeGraphState> row = model.getRows().get(0).getStates();
if (row.size() != 1) {
return;
}
ITimeGraphState stackInterval = row.get(0);
if (stackInterval.getStartTime() <= selectionBegin && selectionBegin <= stackInterval.getStartTime() + stackInterval.getDuration()) {
viewer.setSelectedTimeNotify(stackInterval.getStartTime() + stackInterval.getDuration() + 1, true);
} else {
viewer.setSelectedTimeNotify(stackInterval.getStartTime(), true);
}
int stackLevel = stackInterval.getValue();
ITimeGraphEntry selectedEntry = callStackEntry.getParent().getChildren().get(Integer.max(0, stackLevel - 1));
viewer.setSelection(selectedEntry, true);
viewer.getTimeGraphControl().fireSelectionChanged();
startZoomThread(viewer.getTime0(), viewer.getTime1());
}
}
};
nextAction.setText(superNextAction.getText());
nextAction.setToolTipText(superNextAction.getToolTipText());
nextAction.setImageDescriptor(superNextAction.getImageDescriptor());
fNextEventAction = nextAction;
}
return nextAction;
}
Aggregations