OpenCores
URL https://opencores.org/ocsvn/spacewiresystemc/spacewiresystemc/trunk

Subversion Repositories spacewiresystemc

[/] [spacewiresystemc/] [trunk/] [gladicapi/] [data_recorder.h] - Blame information for rev 30

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 redbear
class data_recorder
2
{
3
        private:
4
                string block_name;
5
                string html_title;
6
                vector<string> columns;
7
                string path_to_save;
8
                FILE * pFile;
9
        public:
10
        data_recorder(string nameblock,vector<string> data_col,string path,string title)
11
        {
12
                block_name   = nameblock;
13
                path_to_save = path;
14
                columns      = data_col;
15
                html_title   = title;
16
        }
17
 
18
        void initialize()
19
        {
20
                string aux;
21
                pFile = fopen (path_to_save.c_str(),"w");
22
                fprintf (pFile,"<!DOCTYPE html>\n");
23
                fprintf (pFile,"<html>\n");
24
                fprintf (pFile,"<head>\n");
25
                fprintf (pFile,"<title>\n");
26
                fprintf (pFile,html_title.c_str());
27
                fprintf (pFile,"</title>\n");
28
                fprintf (pFile,"<style>\n");
29
                fprintf (pFile,"table, th, td\n");
30
                fprintf (pFile,"{\n");
31
                fprintf (pFile,"                border: 1px solid black;\n");
32
                fprintf (pFile,"                border-collapse: collapse;}\n");
33
                fprintf (pFile,"th, td {\n");
34
                fprintf (pFile,"                padding: 5px;\n");
35
                fprintf (pFile,"}\n");
36
                fprintf (pFile,"</style>\n");
37
                fprintf (pFile,"</head>\n");
38
                fprintf (pFile,"<body>\n");
39
                fprintf (pFile,"<table align = \"center\" style=\"width:65%\">\n");
40
                fprintf (pFile,"<tr>\n");
41
                for(unsigned int a = 0; a < columns.size();a++)
42
                {
43
                        aux = columns[a];
44
                        fprintf (pFile,"<th align = \"center\">%s\n</th>\n",aux.c_str());
45
                }
46
                fprintf (pFile,"</tr>\n");
47
        }
48
 
49
        void storedata(vector<string> data_line_store)
50
        {
51
                string aux;
52
                fprintf (pFile,"<tr>\n");
53
                for(unsigned int a = 0; a < columns.size();a++)
54
                {
55
                        aux = data_line_store[a];
56
                        fprintf (pFile,"<td align = \"center\">\n");
57
                        fprintf (pFile,"%s\n",aux.c_str());
58
                        fprintf (pFile,"</td>\n");
59
                }
60
                fprintf (pFile,"</tr>\n");
61
        }
62
 
63
        void endsimulation()
64
        {
65
                fprintf (pFile,"</table>\n");
66
                fprintf (pFile,"</body>\n");
67
                fprintf (pFile,"</html>\n");
68
                fclose (pFile);
69
        }
70
 
71
};

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.