@@ -29,14 +29,14 @@ export const ForceFeedbackPanel: React.FC<Props> = ({ options, data, width, heig
2929 nodeProcess = d3 . select ( '#ThreadMapMain' ) . select ( 'text[class="Forcegraph"' ) . attr ( 'ProcessID' ) ;
3030 }
3131
32- //Get old Nodes
32+ //Get old Nodes & Links
3333 if ( JSON . parse ( sessionStorage . getItem ( 'nodes' ) ! ) !== null ) {
3434 nodes = JSON . parse ( sessionStorage . getItem ( 'nodes' ) ! ) ;
35+ nodesLinks = JSON . parse ( sessionStorage . getItem ( 'links' ) ! ) ;
3536 //If PID changes, dont use old nodes => clear sessionStorage
3637 if ( ! ( nodes [ 0 ] . name === nodeProcess ) ) {
3738 nodes = [ ] ;
3839 sessionStorage . clear ( ) ;
39- console . log ( 'NODES' , nodes , 'Links' , nodesLinks , 'Storage' , sessionStorage ) ;
4040 }
4141 }
4242
@@ -165,44 +165,44 @@ export const ForceFeedbackPanel: React.FC<Props> = ({ options, data, width, heig
165165 addingNodes = true ;
166166 }
167167
168- //Get all Threads of the Process
169- for ( let i = 0 ; i < nodeThreads . length ; i ++ ) {
170- //Check for existing nodes w/o ProcessNode, skip existing nodes
171- if (
172- ! nodes
173- . slice ( 1 )
174- . map ( ( a : any ) => a . name )
175- . includes ( nodeThreads [ i ] )
176- ) {
177- //Assign Colour
178- let nodeColour : any ;
179- //Amount Read/Write
180- let amountReadWrite : any = [ 0 , 0 ] ;
181- for ( let j = 0 ; j < attributeFileName [ i ] . length ; j ++ ) {
182- if ( attributeFileName [ i ] [ j ] !== undefined ) {
183- if ( attributeFileName [ i ] [ j ] === 'Read' ) {
184- amountReadWrite [ 0 ] ++ ;
185- } else if ( attributeFileName [ i ] [ j ] === 'Write' ) {
186- amountReadWrite [ 1 ] ++ ;
187- }
168+ //Get all Threads of the Process
169+ for ( let i = 0 ; i < nodeThreads . length ; i ++ ) {
170+ //Check for existing nodes w/o ProcessNode, skip existing nodes
171+ if (
172+ ! nodes
173+ . slice ( 1 )
174+ . map ( ( a : any ) => a . name )
175+ . includes ( nodeThreads [ i ] )
176+ ) {
177+ //Assign Colour
178+ let nodeColour : any ;
179+ //Amount Read/Write
180+ let amountReadWrite : any = [ 0 , 0 ] ;
181+ for ( let j = 0 ; j < attributeFileName [ i ] . length ; j ++ ) {
182+ if ( attributeFileName [ i ] [ j ] !== undefined ) {
183+ if ( attributeFileName [ i ] [ j ] === 'Read' ) {
184+ amountReadWrite [ 0 ] ++ ;
185+ } else if ( attributeFileName [ i ] [ j ] === 'Write' ) {
186+ amountReadWrite [ 1 ] ++ ;
188187 }
189188 }
190- nodeColour = ColourMix ( amountReadWrite ) ;
191- nodes . push ( {
192- index : nodeNumber ,
193- prefix : 'ThreadID: ' ,
194- name : nodeThreads [ i ] ,
195- affiliatedPrefix : 'File Access: ' ,
196- affiliated : 'Read: ' + amountReadWrite [ 0 ] ,
197- affiliated2 : 'Write: ' + amountReadWrite [ 1 ] ,
198- r : 5 ,
199- writtenBytes : data . series [ ProcessIndex - nodeThreads . length + i ] . fields [ 1 ] . values . get ( 0 ) ,
200- colour : nodeColour ,
201- } ) ;
202- nodeNumber += 1 ;
203- addingNodes = true ;
204189 }
190+ nodeColour = ColourMix ( amountReadWrite ) ;
191+ nodes . push ( {
192+ index : nodeNumber ,
193+ prefix : 'ThreadID: ' ,
194+ name : nodeThreads [ i ] ,
195+ affiliatedPrefix : 'File Access: ' ,
196+ affiliated : 'Read: ' + amountReadWrite [ 0 ] ,
197+ affiliated2 : 'Write: ' + amountReadWrite [ 1 ] ,
198+ r : 5 ,
199+ writtenBytes : data . series [ ProcessIndex - nodeThreads . length + i ] . fields [ 1 ] . values . get ( 0 ) ,
200+ colour : nodeColour ,
201+ } ) ;
202+ nodeNumber += 1 ;
203+ addingNodes = true ;
205204 }
205+ }
206206
207207 //Get all traced_filenames for each process
208208 let IndexFilenamePerThread = nodeFileName . length + 1 ; //helpNodes to check the filenames of each thread instead of all filenames
@@ -283,13 +283,6 @@ export const ForceFeedbackPanel: React.FC<Props> = ({ options, data, width, heig
283283 //TODO
284284 //Link colour depending on wether last action was read or write? => Needed for Threads?
285285 let link_colour = '#003f5c' ;
286- // if (data.series[i].fields[1].labels?.functionname === 'fwrite') {
287- // link_colour = '#ef5675';
288- // } else if (data.series[i].fields[1].labels?.functionname === 'write') {
289- // link_colour = '#ffa600';
290- // } else if (data.series[i].fields[1].labels?.functionname === 'writev') {
291- // link_colour = '#ff0000';
292- // }
293286 nodesLinks . push ( {
294287 source : sourceT . index ,
295288 target : targetT . index ,
@@ -311,59 +304,59 @@ export const ForceFeedbackPanel: React.FC<Props> = ({ options, data, width, heig
311304 target : targetFn . index - 1 ,
312305 colour : targetFn . colour ,
313306 } ) ;
314- }
315- }
316307 }
308+ }
309+ }
317310
318- //Colourmix
319- function ColourMix ( lAmountReadWrite : any ) {
320- //Colour selection
321- let colourNode : string ;
322- let RdWrtPercentage = 0 ;
323- //Check for 0
324- if ( ! ( lAmountReadWrite [ 0 ] === 0 && lAmountReadWrite [ 1 ] === 0 ) ) {
325- if ( lAmountReadWrite [ 1 ] === 0 && lAmountReadWrite [ 0 ] !== 0 ) {
326- //onlyread
327- RdWrtPercentage = 1 ;
328- } else if ( lAmountReadWrite [ 1 ] !== 0 ) {
329- //only writes & mixed
330- RdWrtPercentage = lAmountReadWrite [ 0 ] / lAmountReadWrite [ 1 ] ;
331- }
332- //build mixture of those Read = #323264, Write = #643232
333- let redprop = ( 32 + 100 * ( 1 - RdWrtPercentage ) ) . toString ( 16 ) . substring ( 0 , 2 ) ;
334- let blueprop = ( 32 + 132 * RdWrtPercentage ) . toString ( 16 ) . substring ( 0 , 2 ) ;
335- colourNode = '#' + redprop + '20' + blueprop ;
336- return colourNode ;
337- } else {
338- return '#888888' ;
339- }
311+ //Colourmix
312+ function ColourMix ( lAmountReadWrite : any ) {
313+ //Colour selection
314+ let colourNode : string ;
315+ let RdWrtPercentage = 0 ;
316+ //Check for 0
317+ if ( ! ( lAmountReadWrite [ 0 ] === 0 && lAmountReadWrite [ 1 ] === 0 ) ) {
318+ if ( lAmountReadWrite [ 1 ] === 0 && lAmountReadWrite [ 0 ] !== 0 ) {
319+ //onlyread
320+ RdWrtPercentage = 1 ;
321+ } else if ( lAmountReadWrite [ 1 ] !== 0 ) {
322+ //only writes & mixed
323+ RdWrtPercentage = lAmountReadWrite [ 0 ] / lAmountReadWrite [ 1 ] ;
340324 }
325+ //build mixture of those Read = #323264, Write = #643232
326+ let redprop = ( 32 + 100 * ( 1 - RdWrtPercentage ) ) . toString ( 16 ) . substring ( 0 , 2 ) ;
327+ let blueprop = ( 32 + 132 * RdWrtPercentage ) . toString ( 16 ) . substring ( 0 , 2 ) ;
328+ colourNode = '#' + redprop + '20' + blueprop ;
329+ return colourNode ;
330+ } else {
331+ return '#888888' ;
332+ }
333+ }
341334
342- //Process and Threads
343- function forceSimulation ( _callback : ( ) => void ) {
344- //Draw Threads and Process
345- let simulationThread = d3
346- . forceSimulation ( nodes . slice ( 0 , nodeThreads . length + 1 ) )
347- . force ( 'charge' , d3 . forceManyBody ( ) . strength ( - 200 ) )
348- . force ( 'link' , d3 . forceLink ( ) . links ( nodesLinks . slice ( 0 , nodeThreads . length ) ) . distance ( 100 ) . strength ( 4 ) )
349- . stop ( ) ;
350- simulationThread . tick ( 500 ) ;
335+ //Process and Threads
336+ function forceSimulation ( _callback : ( ) => void ) {
337+ //Draw Threads and Process
338+ let simulationThread = d3
339+ . forceSimulation ( nodes . slice ( 0 , nodeThreads . length + 1 ) )
340+ . force ( 'charge' , d3 . forceManyBody ( ) . strength ( - 200 ) )
341+ . force ( 'link' , d3 . forceLink ( ) . links ( nodesLinks . slice ( 0 , nodeThreads . length ) ) . distance ( 100 ) . strength ( 4 ) )
342+ . stop ( ) ;
343+ simulationThread . tick ( 500 ) ;
351344
352- //Draw Filenames
353- const otherThreads = Array . from ( { length : nodeThreads . length - 1 } , ( ) => [ ] ) ;
354- const lData = [ nodes . slice ( 0 , nodeThreads . length + 1 ) , ...otherThreads ] . concat (
355- nodes . slice ( nodeThreads . length + 1 )
356- ) ;
357- const lLinks = nodesLinks . slice ( nodeThreads . length ) ;
358- let simulationFilename = d3
359- . forceSimulation ( lData )
360- . force ( 'charge' , d3 . forceManyBody ( ) . strength ( - 40 ) )
361- . force ( 'link' , d3 . forceLink ( ) . links ( lLinks ) . distance ( 50 ) . strength ( 4 ) )
362- . stop ( ) ;
363- simulationFilename . tick ( 500 ) ;
345+ //Draw Filenames
346+ const otherThreads = Array . from ( { length : nodeThreads . length - 1 } , ( ) => [ ] ) ;
347+ const lData = [ nodes . slice ( 0 , nodeThreads . length + 1 ) , ...otherThreads ] . concat (
348+ nodes . slice ( nodeThreads . length + 1 )
349+ ) ;
350+ const lLinks = nodesLinks . slice ( nodeThreads . length ) ;
351+ let simulationFilename = d3
352+ . forceSimulation ( lData )
353+ . force ( 'charge' , d3 . forceManyBody ( ) . strength ( - 40 ) )
354+ . force ( 'link' , d3 . forceLink ( ) . links ( lLinks ) . distance ( 50 ) . strength ( 4 ) )
355+ . stop ( ) ;
356+ simulationFilename . tick ( 500 ) ;
364357
365- _callback ( ) ;
366- }
358+ _callback ( ) ;
359+ }
367360
368361 function drawForceGraph ( ) {
369362 const margin = { left : 20 , top : 10 , right : 20 , bottom : 10 } ;
@@ -549,13 +542,14 @@ export const ForceFeedbackPanel: React.FC<Props> = ({ options, data, width, heig
549542 }
550543 }
551544
552- function runSimulation ( ) {
553- addNodes ( ( ) => addLinks ( ) ) ;
554- forceSimulation ( drawForceGraph ) ;
555- fixateNodes ( ) ;
556- //Add Links to sS?
557- sessionStorage . setItem ( 'nodes' , JSON . stringify ( nodes ) ) ;
558- }
545+ function runSimulation ( ) {
546+ addNodes ( ( ) => addLinks ( ) ) ;
547+ forceSimulation ( drawForceGraph ) ;
548+ fixateNodes ( ) ;
549+ //Add Links to sS?
550+ sessionStorage . setItem ( 'nodes' , JSON . stringify ( nodes ) ) ;
551+ sessionStorage . setItem ( 'links' , JSON . stringify ( nodesLinks ) ) ;
552+ }
559553
560554 if ( data . series . length === 0 ) {
561555 d3 . select ( '#area' ) . selectAll ( '*' ) . remove ( ) ;
0 commit comments