-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_geneve.cc
97 lines (83 loc) · 2.41 KB
/
main_geneve.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/**
*
*
* @author Laurent Winkler based on work by Valentin Bourqui
* @date May 2015
* @brief Example executable for the POPWIN project: The main routine shows the usage of the different C++ class of the POPWIN project.
*
*
*/
// #include <unistd.h>
// #include <termios.h>
// #include <map>
#include <fstream>
#include "POPSensor.ph"
using namespace std;
int main(int argc, char** argv)
{
if(argc != 3)
{
cout << "usage: popcrun <obj.map> ./main_geneve localhost geneve.json" << popcendl;
exit(0);
}
// Input a list of commands
cout << popcendl;
cout << "=======================================================================================" <<popcendl;
cout << " POPWin demo: Launching the demo " <<popcendl;
cout << "=======================================================================================" <<popcendl;
try
{
cout << "Creating POPSensor from geneve.json" << popcendl;
POPSensor popGeneve(argv[1], argv[2],0);
POPSensorData geneveData;
popGeneve.Broadcast(MSR_LED, UNT_NONE, LED_ALL_OFF); // MSR_LED=notify for led, all off
cout << "Broadcast green LED ON" << popcendl;
popGeneve.Broadcast(MSR_LED, UNT_NONE, LED_GREEN_TOGGLE); // MSR_LED=notify for led, green toggle
char c = '\n';
while(true)
{
cout << "\nPress key to continue\n" << popcendl;
//while(c == '\n')
c = getchar();
break;
}
cout << "Gathering sensor data..." << popcendl;
printf("Doing DRW...");
for(int i = 0 ; i < 3000 ; i++)
{
geneveData = popGeneve.Gather();
//printf("%d",geneveData.GetSize());
if(geneveData.GetSize() == 0)
{
printf(".");
}
else
{
popGeneve.Clear();
//printf("\n-------------------------------------------------------------------------\n");
printf("\n");
geneveData.Print();
printf("\n");
//printf("\n-------------------------------------------------------------------------\n");
}
sleep(5);
}
cout << "Finished gathering temperatures" << popcendl;
cout << "Broadcast green LED OFF" << popcendl;
popGeneve.Broadcast(MSR_LED, UNT_NONE, LED_GREEN_TOGGLE); // PUB_LED=publish for led, green toggle
printf("end of main\n");
}
catch(std::exception &e)
{
cerr<<"Exception caught in popwin main loop: " << e.what() << popcendl;
exit(0);
return 1;
}
catch(...)
{
cerr<<"Exception caught in popwin main loop" << popcendl;
exit(0);
return 1;
}
return 0;
}