ITS
ParameterUpperTester.cpp
Go to the documentation of this file.
1 #include "ParameterUpperTester.h"
2 
4 {
5  read();
6  //readDebug();
7 }
8 
10 {
11 }
12 
14 {
15  cfg_opt_t destinationArea_opt[] =
16  {
17  CFG_INT("shape", 0, CFGF_NONE),
18  CFG_INT("geoAreaPosLatitude", 429416147, CFGF_NONE),
19  CFG_INT("geoAreaPosLongitude", 40636518, CFGF_NONE),
20  CFG_INT("distanceA", 500, CFGF_NONE),
21  CFG_INT("distanceB", 0, CFGF_NONE),
22  CFG_INT("angle", 0, CFGF_NONE),
23  CFG_END()
24  };
25 
26  cfg_opt_t opts[] =
27  {
28  CFG_INT("upperTesterListenPort", 4200, CFGF_NONE),
29  CFG_INT("upperTesterWritePort", 4201, CFGF_NONE),
30  CFG_INT("upperTesterEventIndicationListenPort", 4210, CFGF_NONE),
31  CFG_INT("upperTesterEventIndicationWritePort", 4211, CFGF_NONE),
32  CFG_SEC("destinationArea", destinationArea_opt, CFGF_NONE),
33  CFG_END()
34  };
35 
36  cfg_t *cfg;
37  cfg_t *cfg_destinationArea;
38 
39  cfg = cfg_init(opts, CFGF_NONE);
40 
41  cfg_set_validate_func(cfg, "upperTesterListenPort", validate_unsigned_int);
42  cfg_set_validate_func(cfg, "upperTesterWritePort", validate_unsigned_int);
43  cfg_set_validate_func(cfg, "upperTesterEventIndicationListenPort", validate_unsigned_int);
44  cfg_set_validate_func(cfg, "upperTesterEventIndicationWritePort", validate_unsigned_int);
45 
46  cfg_add_searchpath(cfg, "/etc/its/config");
47  if(cfg_parse(cfg, "upperTester.conf") == CFG_PARSE_ERROR)
48  printf("PARSE_ERROR\n");
49 
50  m_upperTesterListenPort = cfg_getint(cfg, "upperTesterListenPort");
51  m_upperTesterWritePort = cfg_getint(cfg, "upperTesterWritePort");
52  m_upperTesterEventIndicationListenPort = cfg_getint(cfg, "upperTesterEventIndicationListenPort");
53  m_upperTesterEventIndicationWritePort = cfg_getint(cfg, "upperTesterEventIndicationWritePort");
54 
55  cfg_destinationArea = cfg_getsec(cfg, "destinationArea");
56 
57  m_destinationArea = DestinationAreaData((DestinationAreaData::e_shape)cfg_getint(cfg_destinationArea, "shape"),
58  cfg_getint(cfg_destinationArea, "geoAreaPosLatitude"),
59  cfg_getint(cfg_destinationArea, "geoAreaPosLongitude"),
60  cfg_getint(cfg_destinationArea, "distanceA"),
61  cfg_getint(cfg_destinationArea, "distanceB"),
62  cfg_getint(cfg_destinationArea, "angle")
63  );
64  //foo;
65 
66  cfg_free(cfg);
67 }
68 
70 {
71  printf("-----------------------------------------------------------------\n\t\tReadUpperTester\n\n");
72  printf("upperTesterListenPort = %d\n\n", m_upperTesterListenPort);
73  printf("upperTesterWritePort = %d\n\n", m_upperTesterWritePort);
74  printf("upperTesterEventIndicationListenPort = %d\n\n", m_upperTesterEventIndicationListenPort);
75  printf("upperTesterEventIndicationWritePort = %d\n\n", m_upperTesterEventIndicationWritePort);
76 }
77 
78 
80 {
85 
86  return *this;
87 }
int validate_unsigned_int(cfg_t *cfg, cfg_opt_t *opt)
validate_unsigned_int Check if an option is an unsigned int
Definition: api.cpp:186
DestinationAreaData m_destinationArea
ParameterUpperTester()
ParameterUpperTester ParameterUpperTester constructor.
void read()
read Configuration file reading.
void readDebug()
readDebug Configuration printing.
e_shape
The e_shape enum defines the shape types.
ParameterUpperTester & operator=(const ParameterUpperTester &other)
operator= ParameterUpperTester affectation operator.
UpperTester configuration.