-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_fribourg_remote.cc
87 lines (73 loc) · 2.36 KB
/
main_fribourg_remote.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
/**
*
*
* @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_fribourg 160.98.X.X fribourg_remote.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 fribourg.json" << popcendl;
POPSensor popFribourg(argv[1], argv[2],0);
POPSensorData fribourgData;
popFribourg.Broadcast(MSR_LED, UNT_NONE, LED_ALL_OFF); // MSR_LED=notify for led, all off
cout << "Broadcast green LED ON" << popcendl;
popFribourg.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 << "Gather temperatures..." << popcendl;
for(int i = 0 ; i < 3000 ; i++)
{
fribourgData = popFribourg.Gather();
popFribourg.Clear();
printf("\n-------------------------------------------------------------------------\n");
fribourgData.Print();
printf("\n-------------------------------------------------------------------------\n");
popFribourg.Broadcast(MSR_LED, UNT_NONE, LED_GREEN_TOGGLE); // PUB_LED=publish for led, green toggle
sleep(6);
}
cout << "Finished gathering temperatures" << popcendl;
cout << "Broadcast green LED OFF" << popcendl;
popFribourg.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;
}