Commit 4cd9bc22297b1f8065f8bc6020bd889b23313be8

Authored by Arnaud Blanchard
1 parent a0a0b23e

Manage all blc_array types (i.e. UI32)

Showing 1 changed file with 37 additions and 41 deletions
@@ -31,37 +31,33 @@ void create_graph(blc_channel *input, char const *title, int refresh_period, flo @@ -31,37 +31,33 @@ void create_graph(blc_channel *input, char const *title, int refresh_period, flo
31 SYSTEM_ERROR_CHECK(pipef=popen("gnuplot", "w"), NULL, "Calling gnuplot"); 31 SYSTEM_ERROR_CHECK(pipef=popen("gnuplot", "w"), NULL, "Calling gnuplot");
32 32
33 switch (input->dims_nb){ 33 switch (input->dims_nb){
34 - case 0:  
35 - columns_nb=1;  
36 - rows_nb=1;  
37 - break;  
38 - case 1:  
39 - columns_nb=input->dims[0].length;  
40 - rows_nb=1;  
41 - break;  
42 - case 2:  
43 - columns_nb=input->dims[0].length;  
44 - rows_nb=input->dims[1].length;  
45 - break;  
46 - default:  
47 - EXIT_ON_ARRAY_ERROR(input, "Too many dims");  
48 - break; 34 + case 0:
  35 + columns_nb=1;
  36 + rows_nb=1;
  37 + break;
  38 + case 1:
  39 + columns_nb=input->dims[0].length;
  40 + rows_nb=1;
  41 + break;
  42 + case 2:
  43 + columns_nb=input->dims[0].length;
  44 + rows_nb=input->dims[1].length;
  45 + break;
  46 + default:
  47 + EXIT_ON_ARRAY_ERROR(input, "Too many dims");
  48 + break;
49 } 49 }
50 - 50 + element_size=input->get_type_size();
51 switch (input->type){ 51 switch (input->type){
52 - case 'UIN8':  
53 - gnuplot_format="%uchar";  
54 - element_size=sizeof(uchar);  
55 - break;  
56 - case 'INT8':  
57 - gnuplot_format="%char";  
58 - element_size=sizeof(char);  
59 - break;  
60 - case 'FL32':  
61 - gnuplot_format="%float";  
62 - element_size=sizeof(float);  
63 - break;  
64 - default: EXIT_ON_ARRAY_ERROR(input, "The type is not managed"); 52 + case 'UIN8':gnuplot_format="%uchar";break;
  53 + case 'INT8':gnuplot_format="%char";break;
  54 + case 'IN16':gnuplot_format="%int16";break;
  55 + case 'UI16':gnuplot_format="%uint16";break;
  56 + case 'IN32':gnuplot_format="%int32";break;
  57 + case 'UI32':gnuplot_format="%uint32";break;
  58 + case 'FL32':gnuplot_format="%float32";break;
  59 + case 'FL64':gnuplot_format="%float64";break;
  60 + default: EXIT_ON_ARRAY_ERROR(input, "The type is not managed");
65 } 61 }
66 62
67 init_term(pipef, title, verbatim); 63 init_term(pipef, title, verbatim);
@@ -71,20 +67,20 @@ void create_graph(blc_channel *input, char const *title, int refresh_period, flo @@ -71,20 +67,20 @@ void create_graph(blc_channel *input, char const *title, int refresh_period, flo
71 if (xmin!=xmax) fprintf(pipef, "set xrange [%f:%f]\n", xmin, xmax); 67 if (xmin!=xmax) fprintf(pipef, "set xrange [%f:%f]\n", xmin, xmax);
72 68
73 if (input->dims_nb==2){ 69 if (input->dims_nb==2){
74 - fprintf(pipef, "set xrange [%f:%f]\n", 0.f, 10.f);  
75 - fprintf(pipef, "set yrange [%f:%f]\n", 0.f, 10.f);  
76 - fprintf(pipef, "set zrange [%f:%f]\n", min, max);  
77 - fprintf(pipef, "set view 30,190\n");  
78 - offset=snprintf(command, LINE_MAX, "splot '-' binary format='%s' array=%dx%d title 'values' with pm3d ", gnuplot_format, columns_nb, rows_nb); 70 + fprintf(pipef, "set xrange [%f:%f]\n", 0.f, 10.f);
  71 + fprintf(pipef, "set yrange [%f:%f]\n", 0.f, 10.f);
  72 + fprintf(pipef, "set zrange [%f:%f]\n", min, max);
  73 + fprintf(pipef, "set view 30,190\n");
  74 + offset=snprintf(command, LINE_MAX, "splot '-' binary format='%s' array=%dx%d title 'values' with pm3d ", gnuplot_format, columns_nb, rows_nb);
79 } 75 }
80 else{ 76 else{
81 - offset=snprintf(command, LINE_MAX, "plot '-' binary format='%s' record=%d using ($0*%f):1 title '%d' with %s", gnuplot_format, columns_nb, label_max/(float)columns_nb, 0, with_option);  
82 -  
83 - for(i=1; i!=rows_nb; i++){  
84 - if (i<10) code=48+i;  
85 - else code=97+i-10;  
86 - offset+=snprintf(command+offset, LINE_MAX-offset, ", '-' binary format='%s' record=%d title '%c' with %s", gnuplot_format, columns_nb, code, with_option);  
87 - } 77 + offset=snprintf(command, LINE_MAX, "plot '-' binary format='%s' record=%d using ($0*%f):1 title '%d' with %s", gnuplot_format, columns_nb, label_max/(float)columns_nb, 0, with_option);
  78 +
  79 + for(i=1; i!=rows_nb; i++){
  80 + if (i<10) code=48+i;
  81 + else code=97+i-10;
  82 + offset+=snprintf(command+offset, LINE_MAX-offset, ", '-' binary format='%s' record=%d title '%c' with %s", gnuplot_format, columns_nb, code, with_option);
  83 + }
88 } 84 }
89 85
90 buffer=MANY_ALLOCATIONS(input->size, char); 86 buffer=MANY_ALLOCATIONS(input->size, char);