7
7
// controle do banco de dados.
8
8
9
9
char idFile [] = " ID" ;
10
- char nsrFile [] = " NSR " ;
10
+ char idPontoFile [] = " PONTO/ID " ;
11
11
12
12
char pastaCol [] = " COLAB/" ;
13
13
char pastaRfid [] = " RFID/" ;
@@ -45,7 +45,7 @@ setNsrInFile();
45
45
}
46
46
*/
47
47
48
- void ArquivosClass::getIdFromFile ()
48
+ void ArquivosClass::getIdColaboradorFromFile ()
49
49
{
50
50
char buffer[20 ];
51
51
@@ -55,25 +55,51 @@ void ArquivosClass::getIdFromFile()
55
55
file.read (buffer, tamanho);
56
56
file.close ();
57
57
58
- id = atol (buffer);
58
+ idColaborador = atol (buffer);
59
59
}
60
60
61
- void ArquivosClass::setIdInFile ()
61
+ void ArquivosClass::setIdColaboradorInFile ()
62
62
{
63
63
SD.remove (idFile);
64
64
65
65
File file = SD.open (idFile, FILE_WRITE);
66
- file.print (id );
66
+ file.print (idColaborador );
67
67
file.close ();
68
68
}
69
69
70
- void ArquivosClass::incrementId ()
70
+ void ArquivosClass::incrementIdColaborador ()
71
71
{
72
- id += 1 ;
73
- setIdInFile ();
72
+ idColaborador += 1 ;
73
+ setIdColaboradorInFile ();
74
74
}
75
75
76
+ void ArquivosClass::getIdPontoFromFile ()
77
+ {
78
+ char buffer[20 ];
79
+
80
+ File file = SD.open (idFile, FILE_READ);
81
+ uint8_t tamanho = file.available ();
82
+
83
+ file.read (buffer, tamanho);
84
+ file.close ();
85
+
86
+ idPonto = atol (buffer);
87
+ }
88
+
89
+ void ArquivosClass::setIdPontoInFile ()
90
+ {
91
+ SD.remove (idFile);
92
+
93
+ File file = SD.open (idFile, FILE_WRITE);
94
+ file.print (idPonto);
95
+ file.close ();
96
+ }
76
97
98
+ void ArquivosClass::incrementIdPonto ()
99
+ {
100
+ idPonto += 1 ;
101
+ setIdColaboradorInFile ();
102
+ }
77
103
78
104
void ArquivosClass::addint (int i, char * c)
79
105
{
@@ -149,16 +175,12 @@ void ArquivosClass::init(RTC_DS1307* rtc)
149
175
{
150
176
_rtc = rtc;
151
177
152
- // nsr = 0;
153
- id = 0 ;
178
+ idColaborador = idPonto = 0 ;
154
179
155
- SD.remove (nsrFile);
156
180
SD.remove (idFile);
181
+ SD.remove (idPontoFile);
157
182
158
-
159
-
160
183
File file = SD.open (" COLAB/" );
161
-
162
184
File entry;
163
185
164
186
while (entry = file.openNextFile ())
@@ -196,13 +218,20 @@ void ArquivosClass::init(RTC_DS1307* rtc)
196
218
file.close ();
197
219
}
198
220
199
- uint32_t ArquivosClass::getId ()
221
+ uint32_t ArquivosClass::getIdColaborador ()
200
222
{
201
- return id;
223
+ return idColaborador;
224
+ }
225
+
226
+ uint32_t ArquivosClass::getIdPonto ()
227
+ {
228
+ return idPonto;
202
229
}
203
230
204
231
void ArquivosClass::marcarPonto (uint32_t id)
205
232
{
233
+ incrementIdPonto ();
234
+
206
235
char caminhoPonto[40 ];
207
236
char aux[20 ];
208
237
@@ -233,6 +262,8 @@ void ArquivosClass::marcarPonto(uint32_t id)
233
262
234
263
char ponto[10 ] = " " ;
235
264
265
+ addint (idPonto, ponto);
266
+ strcat (ponto, " ;" );
236
267
addint (now.day (), ponto);
237
268
strcat (ponto, " ;" );
238
269
addint (now.hour (), ponto);
@@ -253,8 +284,8 @@ uint32_t ArquivosClass::incluirColaborador(char* pessoa){
253
284
254
285
strcpy (fullpath, pastaCol);
255
286
256
- incrementId ();
257
- ltoa (id , path, 16 );
287
+ incrementIdColaborador ();
288
+ ltoa (idColaborador , path, 16 );
258
289
259
290
strcat (fullpath, path);
260
291
@@ -263,7 +294,7 @@ uint32_t ArquivosClass::incluirColaborador(char* pessoa){
263
294
file.print (pessoa);
264
295
file.close ();
265
296
266
- return id ;
297
+ return idColaborador ;
267
298
}
268
299
269
300
bool ArquivosClass::consultarColaborador (char * out, uint32_t thisid)
0 commit comments