use of org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule in project tracecompass by tracecompass.
the class XmlTimeGraphDataProvider method create.
/**
* {@link XmlTimeGraphDataProvider} create method
*
* @param trace
* the trace for which the provider will return data
* @param viewElement
* the XML view {@link Element}.
* @return the relevant {@link XmlTimeGraphDataProvider}
*/
public static XmlTimeGraphDataProvider create(@NonNull ITmfTrace trace, Element viewElement) {
Set<@NonNull String> analysisIds = TmfXmlUtils.getViewAnalysisIds(viewElement);
List<Element> entries = TmfXmlUtils.getChildElements(viewElement, TmfXmlStrings.ENTRY_ELEMENT);
Set<@NonNull ITmfAnalysisModuleWithStateSystems> stateSystemModules = new HashSet<>();
if (analysisIds.isEmpty()) {
/*
* No analysis specified, take all state system analysis modules
*/
Iterables.addAll(stateSystemModules, TmfTraceUtils.getAnalysisModulesOfClass(trace, ITmfAnalysisModuleWithStateSystems.class));
} else {
for (String moduleId : analysisIds) {
// Get the module for the current trace only. The caller will take care of
// generating composite providers with experiments
IAnalysisModule module = trace.getAnalysisModule(moduleId);
if (module instanceof ITmfAnalysisModuleWithStateSystems) {
stateSystemModules.add((ITmfAnalysisModuleWithStateSystems) module);
}
}
}
List<ITmfStateSystem> sss = new ArrayList<>();
for (ITmfAnalysisModuleWithStateSystems module : stateSystemModules) {
if (module.schedule().isOK() && module.waitForInitialization()) {
module.getStateSystems().forEach(sss::add);
}
}
return (sss.isEmpty() ? null : new XmlTimeGraphDataProvider(trace, sss, entries));
}
use of org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule in project tracecompass by tracecompass.
the class DataDrivenXYProviderFactory method create.
/**
* Create an XY data provider for a trace
*
* @param trace
* The trace for which to create the data provider
* @return The XY data provider or <code>null</code> if no such provider is
* available for that trace
*/
@Nullable
public ITmfTreeXYDataProvider<ITmfTreeDataModel> create(ITmfTrace trace) {
Set<@NonNull ITmfAnalysisModuleWithStateSystems> stateSystemModules = new HashSet<>();
List<ITmfStateSystem> sss = new ArrayList<>();
if (fAnalysisIds.isEmpty()) {
/*
* No analysis specified, take all state system analysis modules
*/
Iterables.addAll(stateSystemModules, TmfTraceUtils.getAnalysisModulesOfClass(trace, ITmfAnalysisModuleWithStateSystems.class));
} else {
for (String moduleId : fAnalysisIds) {
// Get the module for the current trace only. The caller will
// take care of
// generating composite providers with experiments
IAnalysisModule module = trace.getAnalysisModule(moduleId);
if (module instanceof ITmfAnalysisModuleWithStateSystems) {
stateSystemModules.add((ITmfAnalysisModuleWithStateSystems) module);
}
}
}
for (ITmfAnalysisModuleWithStateSystems module : stateSystemModules) {
if (module.schedule().isOK() && module.waitForInitialization()) {
module.getStateSystems().forEach(sss::add);
}
}
return (sss.isEmpty() ? null : create(trace, sss, fEntries, null));
}
use of org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule in project tracecompass by tracecompass.
the class TmfAnalysisModuleHelperXml method newModule.
@Override
@Nullable
public final IAnalysisModule newModule(ITmfTrace trace) throws TmfAnalysisException {
String analysisid = getId();
IAnalysisModule module = null;
switch(fType) {
case STATE_SYSTEM:
TmfXmlStateProviderCu compile = TmfXmlStateProviderCu.compile(fSourceFile.toPath(), analysisid);
if (compile == null) {
return null;
}
module = new DataDrivenAnalysisModule(analysisid, compile);
module.setName(getName());
break;
case PATTERN:
TmfXmlPatternCu patternCu = TmfXmlPatternCu.compile(fSourceFile.toPath(), analysisid);
if (patternCu == null) {
return null;
}
module = new XmlPatternAnalysis(analysisid, patternCu);
module.setName(getName());
XmlPatternAnalysis paModule = (XmlPatternAnalysis) module;
paModule.setViewLabelPrefix(getViewLabelPrefix());
break;
case OTHER:
String name = getName();
module = createOtherModule(analysisid, name);
break;
default:
break;
}
if (module != null) {
if (module.setTrace(trace)) {
TmfAnalysisManager.analysisModuleCreated(module);
} else {
/*
* The analysis does not apply to the trace, dispose of the
* module
*/
module.dispose();
module = null;
}
}
return module;
}
use of org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule in project tracecompass by tracecompass.
the class XmlAnalysisOutputSourceTest method testBuiltinOutput.
/**
* Test the
* {@link TmfXmlAnalysisOutputSource#moduleCreated(IAnalysisModule)} method
*/
@Test
public void testBuiltinOutput() {
TmfTrace trace = new TmfXmlTraceStubNs();
try {
trace.traceOpened(new TmfTraceOpenedSignal(this, trace, null));
IAnalysisModule module = trace.getAnalysisModule(BUILTIN_MODULE);
assertNotNull(module);
Iterator<IAnalysisOutput> iterator = module.getOutputs().iterator();
assertTrue(iterator.hasNext());
IAnalysisOutput output = iterator.next();
assertEquals(BUILTIN_OUTPUT, output.getName());
} finally {
trace.dispose();
}
}
use of org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule in project tracecompass by tracecompass.
the class TmfExperimentUtilsTest method testGetModuleByClass.
/**
* Test the
* {@link TmfExperimentUtils#getAnalysisModuleOfClassForHost(TmfExperiment, String, Class)}
* method
*/
@Test
public void testGetModuleByClass() {
Class<@NonNull TestAnalysis> commonClass = TestAnalysis.class;
Class<@NonNull TestAnalysis2> notCommonClass = TestAnalysis2.class;
String host1 = TmfTestTrace.A_TEST_10K.getPath();
String host2 = TmfTestTrace.A_TEST_10K2.getPath();
TmfExperiment experiment = fExperiment;
assertNotNull(experiment);
/* Common module for trace 1 */
TestAnalysis module1 = TmfExperimentUtils.getAnalysisModuleOfClassForHost(experiment, host1, commonClass);
assertNotNull(module1);
/* Make sure this module belongs to the trace */
IAnalysisModule sameModule = null;
for (IAnalysisModule mod : fTraces[0].getAnalysisModules()) {
if (mod == module1) {
sameModule = mod;
}
}
assertNotNull(sameModule);
/* Uncommon module from trace 1 */
TestAnalysis2 module2 = TmfExperimentUtils.getAnalysisModuleOfClassForHost(experiment, host1, notCommonClass);
assertNull(module2);
/* Common module for trace 1 */
module1 = TmfExperimentUtils.getAnalysisModuleOfClassForHost(experiment, host2, commonClass);
assertNotNull(module1);
/* Make sure this module belongs to the trace */
sameModule = null;
for (IAnalysisModule mod : fTraces[1].getAnalysisModules()) {
if (mod == module1) {
sameModule = mod;
}
}
assertNotNull(sameModule);
/* Uncommon module from trace 1 */
module2 = TmfExperimentUtils.getAnalysisModuleOfClassForHost(experiment, host2, notCommonClass);
assertNotNull(module2);
/* Make sure this module belongs to the trace */
sameModule = null;
for (IAnalysisModule mod : fTraces[1].getAnalysisModules()) {
if (mod == module1) {
sameModule = mod;
}
}
assertNotNull(sameModule);
}
Aggregations