Subversion Repositories DashDisplay

Rev

Rev 40 | 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;
76
 
77
                                        default:
78
                                                break;
79
                                }
80
 
81
                                if(col == 1)
82
                                {
83
                                        row++;
84
                                }
85
 
86
                        //      printf("%3d %3d %10d\n", key,index,value);
87
 
88
                                }
89
                        }
90
 
91
}
92
 
93
        // having gathered all the data print it
94
 
95
        for(auto it = headings.begin(); it != headings.end() ;it++)
96
        {
97
                printf("%s,",*it);
98
        }
99
                printf("\n");
100
 
101
        for(size_t print = 0; print < row ; print++)
102
        {
103
 
104
 
105
        for(auto it = store.begin(); it != store.end() ;it++)
106
 
107
 
108
                  {
109
 
110
                               double val = 0.0;
111
                                if(*it != nullptr)
112
                                                  {
113
                                                  std::vector<double>  vec =  **it;
114
                                if(print < vec.size())
115
                              val = vec[print];
116
                                                        }
117
                                printf("%0.2f," ,val);
118
                             }
119
 
120
                printf("\n");
121
 
122
        }
123
 
124
 
125
        return 0;
126
}
127