-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
85 lines (60 loc) · 1.77 KB
/
main.cpp
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
#include <stdlib.h>
#include <stdio.h>
#include "ServerPere/GhomeDatabase.h"
#include "Sensors/SensorsCenter.h"
#include "Actuators/ActuatorsCenter.h"
#include "config.h"
#include "tache_mere.h"
#ifdef TESTING
#include "tests.h"
#endif
int main()
{
#ifdef TESTING
Test* test = new Test();
GmemTests(test);
InferenceTests(test);
//ServerPereTests(test);
SensorsTests(test);
//ActuatorsTests(test);
return test->run();
#else
//========================================
// PHASE D'INITIALISATION DE LA TACHE MERE
//========================================
int sensorServerBox = msgget (IPC_PRIVATE, IPC_CREAT | DROITS );
int actuatorServerBox = msgget (IPC_PRIVATE, IPC_CREAT | DROITS );
//Creation des taches filles
ServerPere * papa = new ServerPere(sensorServerBox, actuatorServerBox);
papa->Start();
SensorBoxReader sb(sensorServerBox, actuatorServerBox);
ActuatorsCenter *actuatorCenter = new ActuatorsCenter(actuatorServerBox, "src/etc/actuators.xml");
actuatorCenter->Start();
SensorsCenter *center = new SensorsCenter(sensorServerBox, "src/etc/sensors.xml");
center->Start();
//ghome_database::open_database();
//=====================================
//PHASE DE DESTRUCTION DE LA TACHE MERE
//=====================================
sb.Wait();
papa->Wait();
delete papa;
center->Stop();
delete center;
actuatorCenter->Stop();
delete actuatorCenter;
//Destruction des ressources
msgctl(sensorServerBox,IPC_RMID,0);
msgctl(actuatorServerBox,IPC_RMID,0);
//Terminaison de la tâche mère avec une autodestruction
pthread_exit(0);
return 0;
#endif
}
/*int main () {
ghome_database* log_ecriture = new ghome_database("localhost", "root", "mysql", "GHOME");
log_ecriture->open_database();
log_ecriture->add_tuple("log", 1, 21, 42);
return 0;
}
*/