Skip to content

Commit 8b736c2

Browse files
committed
wip
1 parent 4f9cf0e commit 8b736c2

File tree

2 files changed

+207
-7
lines changed

2 files changed

+207
-7
lines changed

local-libs/traceviewer-libs/react-components/src/components/data-providers/tsp-data-provider.ts

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,133 @@ export class TspDataProvider {
179179
* Get data for sync analysis mode - fetches full range but normalizes time coordinates
180180
* to map selection range to 0 to delta_t
181181
*/
182+
// async getDataForSyncAnalysis(
183+
// ids: number[],
184+
// entries: TimeGraphEntry[],
185+
// fetchArrows: boolean,
186+
// totalTimeRange: TimeRange,
187+
// worldRange?: TimelineChart.TimeGraphRange,
188+
// nbTimes?: number,
189+
// annotationMarkers?: string[],
190+
// markerSetId?: string,
191+
// additionalProperties?: { [key: string]: any }
192+
// ): Promise<TimelineChart.TimeGraphModel> {
193+
// this.timeGraphEntries = [...entries];
194+
// if (!this.timeGraphEntries.length || !worldRange || !nbTimes) {
195+
// return {
196+
// id: 'model',
197+
// totalLength: this.totalRange,
198+
// rows: [],
199+
// rangeEvents: [],
200+
// arrows: [],
201+
// data: {}
202+
// };
203+
// }
204+
205+
// // Fire all TSP requests
206+
// this.totalRange = totalTimeRange.getEnd() - totalTimeRange.getStart();
207+
// const start = totalTimeRange.getStart() + worldRange.start;
208+
// const end = totalTimeRange.getStart() + worldRange.end;
209+
// const timeGraphStateParams = QueryHelper.selectionTimeRangeQuery(
210+
// start,
211+
// end,
212+
// nbTimes,
213+
// ids,
214+
// additionalProperties ? additionalProperties : {}
215+
// );
216+
// const statesPromise = this.client.fetchTimeGraphStates(this.traceUUID, this.outputId, timeGraphStateParams);
217+
218+
// const additionalProps: { [key: string]: any } = {};
219+
// if (annotationMarkers) {
220+
// additionalProps['requested_marker_categories'] = annotationMarkers;
221+
// }
222+
// if (markerSetId) {
223+
// additionalProps['requested_marker_set'] = markerSetId;
224+
// }
225+
// const annotationParams = QueryHelper.selectionTimeRangeQuery(start, end, nbTimes, ids, additionalProps);
226+
// const annotations: Map<number, TimelineChart.TimeGraphAnnotation[]> = new Map();
227+
// const annotationsPromise = this.client.fetchAnnotations(this.traceUUID, this.outputId, annotationParams);
228+
229+
// const arrowStart = worldRange.start + this.timeGraphEntries[0].start;
230+
// const arrowEnd = worldRange.end + this.timeGraphEntries[0].start;
231+
// const fetchParameters = QueryHelper.timeRangeQuery(arrowStart, arrowEnd, nbTimes);
232+
233+
// // Wait for responses
234+
// const [tspClientAnnotationsResponse, tspClientStatesResponse] = await Promise.all([
235+
// annotationsPromise,
236+
// statesPromise
237+
// ]);
238+
239+
// // the start time which is normalized to logical 0 in timeline chart.
240+
// const chartStart = totalTimeRange.getStart();
241+
242+
// const annotationsResponse = tspClientAnnotationsResponse.getModel();
243+
// const rangeEvents: TimelineChart.TimeGraphAnnotation[] = [];
244+
// if (tspClientAnnotationsResponse.isOk() && annotationsResponse) {
245+
// Object.entries(annotationsResponse.model.annotations).forEach(([category, categoryArray]) => {
246+
// categoryArray.forEach(annotation => {
247+
// if (annotation.type === Type.CHART) {
248+
// if (annotation.entryId === -1) {
249+
// rangeEvents.push(this.getAnnotation(category, annotation, rangeEvents.length, chartStart));
250+
// } else {
251+
// let entryArray = annotations.get(annotation.entryId);
252+
// if (entryArray === undefined) {
253+
// entryArray = [];
254+
// annotations.set(annotation.entryId, entryArray);
255+
// }
256+
// entryArray.push(this.getAnnotation(category, annotation, entryArray.length, chartStart));
257+
// }
258+
// }
259+
// });
260+
// });
261+
// }
262+
263+
// const stateResponse = tspClientStatesResponse.getModel();
264+
265+
// if (tspClientStatesResponse.isOk() && stateResponse) {
266+
// this.timeGraphRows = stateResponse.model.rows;
267+
// this.timeGraphRowsOrdering(ids);
268+
// } else {
269+
// this.timeGraphRows = [];
270+
// }
271+
272+
// const rows: TimelineChart.TimeGraphRowModel[] = [];
273+
// this.timeGraphRows.forEach((row: TimeGraphRow) => {
274+
// const rowId: number = row.entryId;
275+
// const entry = this.timeGraphEntries.find(tgEntry => tgEntry.id === rowId);
276+
// if (entry) {
277+
// rows.push(this.getRowModel(row, chartStart, rowId, entry));
278+
// }
279+
// });
280+
281+
// for (const [entryId, entryArray] of annotations.entries()) {
282+
// const row = rows.find(tgEntry => tgEntry.id === entryId);
283+
// if (row) {
284+
// row.annotations = entryArray;
285+
// }
286+
// }
287+
288+
// let arrows: TimelineChart.TimeGraphArrow[] = [];
289+
// if (fetchArrows) {
290+
// const tspClientArrowsResponse = await this.client.fetchTimeGraphArrows(
291+
// this.traceUUID,
292+
// this.outputId,
293+
// fetchParameters
294+
// );
295+
// arrows = this.getArrows(tspClientArrowsResponse, worldRange, nbTimes);
296+
// }
297+
298+
// return {
299+
// id: 'model',
300+
// totalLength: this.totalRange,
301+
// rows,
302+
// arrows,
303+
// rangeEvents,
304+
// data: {
305+
// originalStart: chartStart
306+
// }
307+
// };
308+
// }
182309
async getDataForSyncAnalysis(
183310
ids: number[],
184311
entries: TimeGraphEntry[],

local-libs/traceviewer-libs/react-components/src/components/gantt-chart-output-component.tsx

Lines changed: 80 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,72 @@ export class GanttChartOutputComponent extends AbstractGanttOutputComponent<
114114
await super.componentDidMount();
115115
}
116116

117+
async fetchTreeForSyncAnalysis(): Promise<ResponseStatus> {
118+
if (!this.isSyncedRangeValid(this.props.syncedRange)) {
119+
return ResponseStatus.FAILED;
120+
}
121+
122+
const resolution = Math.ceil(
123+
Number(this.props.range.getEnd() - this.props.range.getStart()) / this.COARSE_RESOLUTION_FACTOR
124+
);
125+
126+
const parameters = QueryHelper.timeRangeQuery(
127+
this.props.range.getStart(),
128+
this.props.range.getEnd(),
129+
resolution,
130+
{
131+
selection_range: [
132+
this.props.selectionRange?.getStart() ??
133+
BigInt(0) + (this.props.selectionRange?.getOffset() ?? BigInt(0)),
134+
this.props.selectionRange?.getEnd() ??
135+
BigInt(0) + (this.props.selectionRange?.getOffset() ?? BigInt(0))
136+
]
137+
}
138+
);
139+
const tspClientResponse = await this.props.tspClient.fetchTimeGraphTree(
140+
this.props.traceId,
141+
this.props.outputDescriptor.id,
142+
parameters
143+
);
144+
const treeResponse = tspClientResponse.getModel();
145+
if (tspClientResponse.isOk() && treeResponse) {
146+
if (treeResponse.model) {
147+
const headers = treeResponse.model.headers;
148+
const columns: ColumnHeader[] = [];
149+
if (headers && headers.length > 0) {
150+
headers.forEach(header => {
151+
columns.push({ title: header.name, sortable: true, resizable: true, tooltip: header.tooltip });
152+
});
153+
} else {
154+
columns.push({ title: '', sortable: true, resizable: true });
155+
}
156+
const autoCollapsedNodes = getCollapsedNodesFromAutoExpandLevel(
157+
listToTree(treeResponse.model.entries, columns),
158+
treeResponse.model.autoExpandLevel
159+
);
160+
this.setState(
161+
{
162+
outputStatus: treeResponse.status,
163+
chartTree: treeResponse.model.entries,
164+
defaultOrderedIds: treeResponse.model.entries.map(entry => entry.id),
165+
collapsedNodes: autoCollapsedNodes,
166+
columns
167+
},
168+
this.updateTotalHeight
169+
);
170+
} else {
171+
this.setState({
172+
outputStatus: treeResponse.status
173+
});
174+
}
175+
return treeResponse.status;
176+
}
177+
this.setState({
178+
outputStatus: ResponseStatus.FAILED
179+
});
180+
return ResponseStatus.FAILED;
181+
}
182+
117183
async fetchTree(): Promise<ResponseStatus> {
118184
const parameters = QueryHelper.timeRangeQuery(this.props.range.getStart(), this.props.range.getEnd());
119185
const tspClientResponse = await this.props.tspClient.fetchTimeGraphTree(
@@ -275,11 +341,6 @@ export class GanttChartOutputComponent extends AbstractGanttOutputComponent<
275341
end: BIMath.max(relativeStart, relativeEnd)
276342
};
277343

278-
// fetch the full range but we'll normalize the time coordinates
279-
newRange = {
280-
start: BigInt(0),
281-
end: this.props.range.getEnd() - this.props.range.getStart()
282-
};
283344
syncAnalysisMode = true;
284345
} else {
285346
newRange = range;
@@ -288,6 +349,18 @@ export class GanttChartOutputComponent extends AbstractGanttOutputComponent<
288349

289350
let timeGraphData: TimelineChart.TimeGraphModel;
290351
if (syncAnalysisMode && selectionRange) {
352+
console.log(this.props.selectionRange?.getStart(), this.props.selectionRange?.getEnd());
353+
354+
const _additionalProperties = {
355+
...additionalProperties,
356+
selection_range: [
357+
this.props.selectionRange?.getStart() ??
358+
BigInt(0) + (this.props.selectionRange?.getOffset() ?? BigInt(0)),
359+
this.props.selectionRange?.getEnd() ??
360+
BigInt(0) + (this.props.selectionRange?.getOffset() ?? BigInt(0))
361+
]
362+
};
363+
291364
// Full range with normalized time coordinates in sync mode
292365
timeGraphData = await this.tspDataProvider.getDataForSyncAnalysis(
293366
ids,
@@ -298,7 +371,7 @@ export class GanttChartOutputComponent extends AbstractGanttOutputComponent<
298371
nbTimes,
299372
this.props.markerCategories,
300373
this.props.markerSetId,
301-
additionalProperties
374+
_additionalProperties
302375
);
303376
} else {
304377
// Use normal mode
@@ -415,13 +488,13 @@ export class GanttChartOutputComponent extends AbstractGanttOutputComponent<
415488
const syncedRangeChanged = !isEqual(prevProps.syncedRange, this.props.syncedRange);
416489

417490
if (syncModeChanged || syncedRangeChanged) {
418-
this.fetchTree();
419491
if (this.chartLayer) {
420492
this.chartLayer.updateChart();
421493
}
422494

423495
if (this.state.isSyncRange && this.isSyncedRangeValid(this.props.syncedRange)) {
424496
// In sync mode, set the view range to start from 0 with the selection duration
497+
this.fetchTreeForSyncAnalysis();
425498
const fullRangeWidth = this.props.range.getEnd() - this.props.range.getStart();
426499
this.props.unitController.absoluteRange = fullRangeWidth;
427500
const normalized = this.normalizeRange(this.props.syncedRange.start, this.props.syncedRange.end);

0 commit comments

Comments
 (0)