use of org.eclipse.tracecompass.tmf.core.signal.TmfSignal in project tracecompass by tracecompass.
the class PcapTraceTest method testBroadcast.
/**
* Run the void broadcast(TmfSignal) method test.
*/
@Test
public void testBroadcast() {
TmfSignal signal = new TmfEndSynchSignal(1);
fFixture.broadcast(signal);
}
use of org.eclipse.tracecompass.tmf.core.signal.TmfSignal in project tracecompass by tracecompass.
the class CtfTmfTraceTest method testBroadcast.
/**
* Run the void broadcast(TmfSignal) method test.
*/
@Test
public void testBroadcast() {
TmfSignal signal = new TmfEndSynchSignal(1);
fixture.broadcast(signal);
}
use of org.eclipse.tracecompass.tmf.core.signal.TmfSignal in project tracecompass by tracecompass.
the class StreamListView method createPartControl.
@Override
public void createPartControl(@Nullable Composite parent) {
// Initialize
final Map<TmfPcapProtocol, Table> tables = new HashMap<>();
fTableMap = tables;
fCurrentTrace = TmfTraceManager.getInstance().getActiveTrace();
fCurrentStream = null;
// Add a tab folder
fTabFolder = new CTabFolder(parent, SWT.NONE);
fTabFolder.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(@Nullable SelectionEvent e) {
if (e == null) {
return;
}
TmfPcapProtocol protocol = (TmfPcapProtocol) e.item.getData(KEY_PROTOCOL);
final Table table = tables.get(protocol);
if (table != null) {
table.deselectAll();
}
fCurrentStream = null;
}
});
// Add items and tables for each protocol
for (TmfPcapProtocol protocol : TmfPcapProtocol.values()) {
if (protocol.supportsStream()) {
CTabItem item = new CTabItem(fTabFolder, SWT.NONE);
item.setText(protocol.getName());
item.setData(KEY_PROTOCOL, protocol);
Table table = new Table(fTabFolder, SWT.NONE);
table.setHeaderVisible(true);
table.setLinesVisible(true);
// Add columns to table
for (int i = 0; i < COLUMN_NAMES.length || i < COLUMN_SIZES.length; i++) {
TableColumn column = new TableColumn(table, SWT.NONE);
column.setText(COLUMN_NAMES[i]);
column.setWidth(COLUMN_SIZES[i]);
}
item.setControl(table);
table.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(@Nullable SelectionEvent e) {
if (e == null) {
return;
}
fCurrentStream = (TmfPacketStream) e.item.getData(KEY_STREAM);
}
});
tables.put(protocol, table);
// Add right click menu
Menu menu = new Menu(table);
MenuItem menuItem = new MenuItem(menu, SWT.PUSH);
menuItem.setText(Messages.StreamListView_FollowStream);
menuItem.addListener(SWT.Selection, (@Nullable Event event) -> {
TmfSignal signal = new TmfPacketStreamSelectedSignal(this, 0, fCurrentStream);
TmfSignalManager.dispatchSignal(signal);
});
menuItem = new MenuItem(menu, SWT.PUSH);
menuItem.setText(Messages.StreamListView_Clear);
menuItem.addListener(SWT.Selection, (@Nullable Event event) -> {
TmfSignal signal = new TmfPacketStreamSelectedSignal(this, 0, null);
TmfSignalManager.dispatchSignal(signal);
});
menuItem = new MenuItem(menu, SWT.PUSH);
menuItem.setText(Messages.StreamListView_ExtractAsFilter);
menuItem.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(@Nullable Event event) {
// Generate filter.
ITmfFilterTreeNode filter = generateFilter();
// Update view and XML
updateFilters(filter);
}
private void updateFilters(@Nullable ITmfFilterTreeNode filter) {
if (filter == null) {
return;
}
// Update XML
List<ITmfFilterTreeNode> filters = Lists.newArrayList(FilterManager.getSavedFilters());
boolean newFilter = true;
for (ITmfFilterTreeNode savedFilter : filters) {
// Use toString(explicit) equality because equals() is not implemented
if (savedFilter.toString(true).equals(filter.toString(true))) {
newFilter = false;
break;
}
}
if (newFilter) {
filters.add(filter);
FilterManager.setSavedFilters(filters.toArray(new ITmfFilterTreeNode[filters.size()]));
}
// Update Filter View
try {
final IWorkbench wb = PlatformUI.getWorkbench();
final IWorkbenchPage activePage = wb.getActiveWorkbenchWindow().getActivePage();
IViewPart view = activePage.showView(FilterView.ID);
FilterView filterView = (FilterView) view;
filterView.addFilter(filter);
} catch (final PartInitException e) {
// $NON-NLS-1$
TraceUtils.displayErrorMsg(Messages.StreamListView_ExtractAsFilter, "Error opening view " + FilterView.ID + e.getMessage());
// $NON-NLS-1$
Activator.logError("Error opening view " + FilterView.ID, e);
return;
}
}
@Nullable
private ITmfFilterTreeNode generateFilter() {
TmfPacketStream stream = fCurrentStream;
if (stream == null) {
return null;
}
// First stage - root
String name = Messages.StreamListView_FilterName_Stream + ' ' + stream.getProtocol().getShortName() + ' ' + stream.getFirstEndpoint() + " <--> " + // $NON-NLS-1$
stream.getSecondEndpoint();
TmfFilterNode root = new TmfFilterNode(name);
// Second stage - and
TmfFilterAndNode and = new TmfFilterAndNode(root);
// Third stage - protocol + or
TmfFilterContainsNode protocolFilter = new TmfFilterContainsNode(and);
protocolFilter.setEventAspect(TmfBaseAspects.getContentsAspect().forField(stream.getProtocol().getName()));
protocolFilter.setTraceTypeId(TmfFilterAspectNode.BASE_ASPECT_ID);
protocolFilter.setValue(EMPTY_STRING);
TmfFilterOrNode or = new TmfFilterOrNode(and);
// Fourth stage - and
TmfFilterAndNode andA = new TmfFilterAndNode(or);
TmfFilterAndNode andB = new TmfFilterAndNode(or);
// Fourth stage - endpoints
TmfFilterContainsNode endpointAAndA = new TmfFilterContainsNode(andA);
endpointAAndA.setEventAspect(PcapSourceAspect.INSTANCE);
endpointAAndA.setTraceTypeId(PcapTrace.TRACE_TYPE_ID);
endpointAAndA.setValue(stream.getFirstEndpoint());
TmfFilterContainsNode endpointBAndA = new TmfFilterContainsNode(andA);
endpointBAndA.setEventAspect(PcapDestinationAspect.INSTANCE);
endpointBAndA.setTraceTypeId(PcapTrace.TRACE_TYPE_ID);
endpointBAndA.setValue(stream.getSecondEndpoint());
TmfFilterContainsNode endpointAAndB = new TmfFilterContainsNode(andB);
endpointAAndB.setEventAspect(PcapSourceAspect.INSTANCE);
endpointAAndB.setTraceTypeId(PcapTrace.TRACE_TYPE_ID);
endpointAAndB.setValue(stream.getSecondEndpoint());
TmfFilterContainsNode endpointBAndB = new TmfFilterContainsNode(andB);
endpointBAndB.setEventAspect(PcapDestinationAspect.INSTANCE);
endpointBAndB.setTraceTypeId(PcapTrace.TRACE_TYPE_ID);
endpointBAndB.setValue(stream.getFirstEndpoint());
return root;
}
});
table.setMenu(menu);
}
}
// Ask the analysis for data.
queryAnalysis();
}
Aggregations