Subversion Repositories DashDisplay

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
39 mjames 1
#include <iostream>
2
#include <stdio.h>
3
#include <map>
4
#include <vector>
5
 
6
#include "../plx_lib/plx.h"
7
 
8
 
9
 
10
 
11
 
12
 
13
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
14
 
15
 
16
 
17
int main(int argc, char** argv) {
18
 
19
        int nextcol = 1;
20
        int row = 0;
21
        std::map<int,int> mapping;
22
        std::vector<std::vector<double> *> store;
23
        std::vector<const char *> headings;
24
 
25
        FILE  * f;
26
        if(argc > 1) {
27
 
28
           f=fopen(argv[1],"r");
29
           if(f){
30
                  while (!feof(f))
31
                                {
32
                                int key;
33
                                int index;
34
                          int value;
35
 
36
 
37
                                int c = fscanf(f,"%d,%d,%d\n",&key,&index,&value);
38
 
39
 
40
                                int search = key * 10 + index;
41
 
42
                                int & col = mapping[search];
43
 
44
                                if(col == 0)
45
                                {
46
                                        col = nextcol++;
47
                                        mapping[search] = col;
48
                                }
49
 
50
 
51
 
52
       if (col > store.size())
53
        {
54
                headings.push_back( PLX_Obs_Names [key]); // save column heading 
55
                store.push_back( new std::vector<double> ); // save value 
56
                printf("Alloc heading %s\n",headings[col-1]);
57
                                }
58
              std::vector<double> * vec = store[col-1];
59
 
60
 
61
                                // decode scaling 
62
                                double res = 0;
63
                                switch (key)
64
                                {
65
 
66
                                        case PLX_AFR:
67
                                 vec->push_back(ConveriMFDRaw2Data(key , AFR_Gasoline, value)) ;
68
                                                 break;
69
                                  case PLX_RPM:
70
                                                 vec->push_back( ConveriMFDRaw2Data(key ,0, value)) ;
71
                         break;
72
 
73
          case PLX_X_CHT:
74
             vec->push_back(ConveriMFDRaw2Data(key ,TEMP_Celsius, value));
75
                                                                                         break;
40 mjames 76
                                        case PLX_FluidPressure:
77
                                            vec->push_back(ConveriMFDRaw2Data(key ,PRESSURE_PSI_Oil, value));  
78
                                                        break;                                   
39 mjames 79
                                        default:
80
                                                break;
81
                                }
82
 
83
                                if(col == 1)
84
                                {
85
                                        row++;
86
                                }
87
 
88
                        //      printf("%3d %3d %10d\n", key,index,value);
89
 
90
                                }
91
                        }
92
 
93
}
94
 
95
        // having gathered all the data print it
96
 
97
        for(auto it = headings.begin(); it != headings.end() ;it++)
98
        {
99
                printf("%s,",*it);
100
        }
101
                printf("\n");
102
 
103
        for(size_t print = 0; print < row ; print++)
104
        {
105
 
106
 
107
        for(auto it = store.begin(); it != store.end() ;it++)
108
 
109
 
110
                  {
111
 
112
                               double val = 0.0;
113
                                if(*it != nullptr)
114
                                                  {
115
                                                  std::vector<double>  vec =  **it;
116
                                if(print < vec.size())
117
                              val = vec[print];
118
                                                        }
119
                                printf("%0.2f," ,val);
120
                             }
121
 
122
                printf("\n");
123
 
124
        }
125
 
126
 
127
        return 0;
128
}
129