MCPcopy Create free account
hub / github.com/Marus/cortex-debug / init

Function init

src/grapher/main.ts:22–89  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

20}
21
22function init() {
23 // let datasource: GraphDataSource = null;
24 const graphs: Graph[] = [];
25
26 function processConfiguration(message: GrapherConfigurationMessage) {
27 window.datasource = new GraphDataSource();
28
29 message.graphs.forEach((config: any) => {
30 if (config.type === 'realtime') {
31 const graph = new TimeseriesGraph(config as TimeseriesGraphConfiguration, window.datasource);
32 graphs.push(graph);
33 if (message.status === 'stopped' || message.status === 'terminated') { graph.stop(); }
34 }
35 else if (config.type === 'x-y-plot') {
36 const graph = new XYGraph(config as XYGraphConfiguration, window.datasource);
37 graphs.push(graph);
38 if (message.status === 'stopped' || message.status === 'terminated') { graph.stop(); }
39 }
40 });
41
42 // const psg: ProgramStatsGraph = new ProgramStatsGraph(window.datasource);
43 // if (message.status === 'stopped' || message.status === 'terminated') { psg.stop(); }
44 // graphs.push(psg);
45 }
46
47 function processStatus(message: GrapherStatusMessage) {
48 if (message.status === 'stopped' || message.status === 'terminated') {
49 graphs.forEach((g) => g.stop());
50 }
51 else if (message.status === 'continued') {
52 graphs.forEach((g) => g.continue());
53 }
54 }
55
56 function processData(message: GrapherDataMessage) {
57 if (window.datasource) {
58 window.datasource.receiveDataMessage(message);
59 }
60 }
61
62 function processProgramCounter(message: GrapherProgramCounterMessage) {
63 window.datasource.receivedProgramCounterMessage(message);
64 }
65
66 window.addEventListener('message', (event) => {
67 const message: GrapherMessage = event.data;
68 switch (message.type) {
69 case 'configure':
70 processConfiguration(message as GrapherConfigurationMessage);
71 break;
72 case 'data':
73 processData(message as GrapherDataMessage);
74 break;
75 case 'status':
76 processStatus(message as GrapherStatusMessage);
77 break;
78 case 'program-counter':
79 processProgramCounter(message as GrapherProgramCounterMessage);

Callers 1

main.tsFile · 0.85

Calls 7

processConfigurationFunction · 0.85
processDataFunction · 0.85
processStatusFunction · 0.85
processProgramCounterFunction · 0.85
logMethod · 0.80
postMessageMethod · 0.80
addEventListenerMethod · 0.65

Tested by

no test coverage detected