Commit 1e6f257d531798181156a5b874c2fdb5b59f91d9
Exists in
clean_real
:Merge branch 'clean_real' of https://gitlab.irap.omp.eu/CDPP/DDServer into clean_real
Showing
4 changed files
with
89 additions
and
55 deletions
Show diff stats
src/SERVER/DD_Access_sr.c
... | ... | @@ -39,39 +39,48 @@ int * get_ticket_field_ids(int ncid, int n, char ** fields) { |
39 | 39 | return a; |
40 | 40 | } |
41 | 41 | int GetTicket(int user_id, char * hostname, int DD_user_id) { |
42 | - //printf("GetTicket uid:%i, hostname:%s, ddid:%i\n", user_id, hostname, DD_user_id); | |
42 | + printf("GetTicket uid:%i, hostname:%s, ddid:%i\n", user_id, hostname, DD_user_id); | |
43 | 43 | time_t expiration_time; |
44 | 44 | time_t clock_value; |
45 | 45 | int permission = NOPERMISSION; |
46 | + printf("NOPERMISSION value : %i\n", permission); | |
46 | 47 | |
47 | 48 | clock_value = time(NULL); |
48 | - // expiration_time= clock_value+16200; // 4.5 hours | |
49 | + // expiration_time= clock_value+16200; // 4.5 hours | |
49 | 50 | expiration_time = clock_value+172800; // 48 hours |
51 | + expiration_time = clock_value + 16200; | |
52 | + printf("Expiration time : %ld\n", expiration_time); | |
50 | 53 | |
51 | 54 | // selection query |
52 | 55 | char * q = malloc(1024 * sizeof(char)); |
53 | 56 | memset(q, 0, 1024); |
54 | - sprintf(q, "SELECT ddid,hostname,time FROM user_ticket WHERE userid='%s' AND hostname='%s';", hostname); | |
57 | + sprintf(q, "SELECT ddid,hostname,time FROM user_ticket WHERE userid=%i AND hostname='%s';",user_id, hostname); | |
58 | + printf("GetTicket select : -%s-\n", q); | |
55 | 59 | sqlite3 * db; |
56 | 60 | sqlite3_stmt * res; |
57 | 61 | sqlite3_open("amda.db", &db); |
58 | 62 | int rc; rc = sqlite3_prepare_v2(db, q, -1, &res, 0); |
59 | 63 | int step; step = sqlite3_step(res); |
60 | 64 | if(step != SQLITE_ROW) { |
65 | + printf("No user ticket row found\n"); | |
61 | 66 | // create a new entry in the database |
62 | 67 | char * q = malloc(1024 * sizeof(char)); |
63 | 68 | memset(q, 0, 1024); |
69 | + printf("\tinsert user_id: %i, host: %s, time: %ld, ddid: %i\n", user_id, hostname, expiration_time, DD_user_id); | |
64 | 70 | sprintf(q, "INSERT INTO user_ticket (userid,hostname,time,ddid) VALUES (%i,'%s',%i,%i);",user_id,hostname,expiration_time,DD_user_id); |
65 | 71 | execute_query(q); |
66 | 72 | permission = 0; |
67 | 73 | free(q); |
68 | 74 | } |
69 | 75 | else { |
76 | + printf("Row found\n"); | |
70 | 77 | while(step == SQLITE_ROW) { |
71 | 78 | int time_tmp; time_tmp = sqlite3_column_int(res, 2); |
72 | 79 | int ddid_tmp; ddid_tmp = sqlite3_column_int(res, 0); |
80 | + printf("\ttime_tmp: %i, ddid_tmp: %i, DD_user_id: %i\n", time_tmp, ddid_tmp, DD_user_id); | |
73 | 81 | if(ddid_tmp==DD_user_id) { |
74 | - if(time_tmp<expiration_time) { | |
82 | + printf("Expiration time : %ld, t_diff: %ld\n", expiration_time, time_tmp - expiration_time); | |
83 | + if(clock_value<time_tmp) { | |
75 | 84 | // update expiration time |
76 | 85 | char * q = malloc(1024 * sizeof(char)); |
77 | 86 | memset(q,0,1024); |
... | ... | @@ -79,6 +88,7 @@ int GetTicket(int user_id, char * hostname, int DD_user_id) { |
79 | 88 | execute_query(q); |
80 | 89 | free(q); |
81 | 90 | } |
91 | + | |
82 | 92 | permission = 0; |
83 | 93 | break; |
84 | 94 | } |
... | ... | @@ -88,6 +98,7 @@ int GetTicket(int user_id, char * hostname, int DD_user_id) { |
88 | 98 | |
89 | 99 | sqlite3_finalize(res); |
90 | 100 | sqlite3_close(db); |
101 | + printf("Permission val : %i\n", permission); | |
91 | 102 | return permission; |
92 | 103 | } |
93 | 104 | |
... | ... | @@ -160,7 +171,7 @@ int CheckTicket(char * username, char * ticket) { |
160 | 171 | * It IS DD_Check ! |
161 | 172 | */ |
162 | 173 | int ShowTicket_old(int user_id, char *hostname, char * ddname) { |
163 | - //printf("ShowTicket : user_id:%i, hostname:'%s', ddname:'%s'\n", user_id, hostname, ddname); | |
174 | + printf("ShowTicket : user_id:%i, hostname:'%s', ddname:'%s'\n", user_id, hostname, ddname); | |
164 | 175 | char * ddbase; |
165 | 176 | char refname[PATHLENGTH]; |
166 | 177 | int ticket_id; /* Ticket file ID */ |
... | ... | @@ -241,7 +252,7 @@ int ShowTicket_old(int user_id, char *hostname, char * ddname) { |
241 | 252 | |
242 | 253 | |
243 | 254 | int ShowTicket(int user_id, char *hostname, char * ddname) { |
244 | - //printf("ShowTicket2 : uid:%i, hostname:%s, ddname:%s\n", user_id, hostname, ddname); | |
255 | + printf("ShowTicket2 : uid:%i, hostname:%s, ddname:%s\n", user_id, hostname, ddname); | |
245 | 256 | time_t expiration_time; |
246 | 257 | time_t clock_value; |
247 | 258 | int permission = NOPERMISSION; |
... | ... | @@ -251,35 +262,50 @@ int ShowTicket(int user_id, char *hostname, char * ddname) { |
251 | 262 | |
252 | 263 | clock_value = time(NULL); |
253 | 264 | // expiration_time= clock_value+16200; // 4.5 hours |
254 | - expiration_time = clock_value+172800; // 48 hours | |
265 | + //expiration_time = clock_value+172800; // 48 hours | |
266 | + expiration_time = clock_value + 16200; | |
255 | 267 | |
256 | 268 | // selection query |
257 | 269 | char * q = malloc(1024 * sizeof(char)); |
258 | 270 | memset(q, 0, 1024); |
259 | 271 | sprintf(q, "SELECT ddid,hostname,time FROM user_ticket WHERE userid=%i AND hostname='%s';", user_id,hostname); |
260 | - //printf("query : %s\n", q); | |
272 | + printf("query : -%s-\n", q); | |
261 | 273 | sqlite3 * db; |
262 | 274 | sqlite3_stmt * res; |
263 | 275 | sqlite3_open("amda.db", &db); |
264 | 276 | int rc; rc = sqlite3_prepare_v2(db, q, -1, &res, 0); |
265 | 277 | int step; step = sqlite3_step(res); |
266 | 278 | if(step != SQLITE_ROW) { |
279 | + printf("\tno row found\n"); | |
267 | 280 | // create a new entry in the database |
268 | - //printf("STEP FAIL\n"); | |
269 | 281 | permission = NOPERMISSION; |
270 | 282 | } |
271 | 283 | else { |
284 | + printf("\trow found\n"); | |
272 | 285 | while(step == SQLITE_ROW) { |
273 | 286 | int time_tmp; time_tmp = sqlite3_column_int(res, 2); |
274 | 287 | int ddid_tmp; ddid_tmp = sqlite3_column_int(res, 0); |
275 | - //printf("\t->row found : ddid %i, time %i, cv: %i\n", ddid_tmp, time_tmp, clock_value); | |
276 | - //printf("\tdduserid : %i\n", DD_user_id); | |
288 | + printf("\t->row found : ddid %i, time %i, cv: %i\n", ddid_tmp, time_tmp, clock_value); | |
289 | + printf("\tdduserid : %i\n", DD_user_id); | |
277 | 290 | if(ddid_tmp==DD_user_id) { |
278 | 291 | if(clock_value < time_tmp) { |
279 | 292 | // update expiration time |
293 | + printf("\tclock_value < time_tmp : %ld < %ld\n", clock_value, time_tmp); | |
294 | + printf("\tdiff : %ld\n", clock_value - time_tmp); | |
280 | 295 | permission = 0; |
281 | 296 | } |
282 | 297 | else { |
298 | + printf("\tExpired ticket ?? %ld < %ld\n", clock_value, time_tmp); | |
299 | + printf("\t%ld\n", clock_value - time_tmp); | |
300 | + // remove ticket entry from table | |
301 | + char * qq = malloc(1024 * sizeof(char)); | |
302 | + memset(qq, 0, 1024); | |
303 | + sprintf(qq, "DELETE FROM user_ticket WHERE userid=%i AND hostname='%s' AND time=%ld;", user_id,hostname,time_tmp); | |
304 | + printf("DELETE q : -%s-\n", qq); | |
305 | + sqlite3_exec(db, qq, 0, 0, NULL); | |
306 | + printf("FREEEEEEEEE\n"); | |
307 | + free(qq); | |
308 | + | |
283 | 309 | permission = NOPERMISSION; |
284 | 310 | } |
285 | 311 | break; | ... | ... |
src/SERVER/DD_GetData.c
... | ... | @@ -19,6 +19,7 @@ extern LocalOrigSync(DD_Var_t *Local, DD_Var_t *Orig); |
19 | 19 | * Fill General attributes fron the INFO file |
20 | 20 | */ |
21 | 21 | int OpenInstr(char *VInstrName) { |
22 | + //printf("OpenInstr : Vi name : %s\n", VInstrName); | |
22 | 23 | char refname[PATHLENGTH]; /* full name of the reference file */ |
23 | 24 | char *ddbase; /* Environment variable DDBASE (path to the DDBASE ROOT)*/ |
24 | 25 | char RInstrName[MAXSETLENGTH]; /* Requested virtual instrument name */ |
... | ... | @@ -41,6 +42,7 @@ int OpenInstr(char *VInstrName) { |
41 | 42 | for(id = 0; id < MaxIDNumber; id++) { |
42 | 43 | if(DD_Var[id] != NULL) { |
43 | 44 | if(strcmp(RInstrName, DD_Var[id]->InstrName) == 0) { |
45 | + //printf("VI is open at id : %i\n", id); | |
44 | 46 | return(id); |
45 | 47 | } |
46 | 48 | } |
... | ... | @@ -50,12 +52,14 @@ int OpenInstr(char *VInstrName) { |
50 | 52 | id =0; |
51 | 53 | while((DD_Var[id] != NULL) && (id < MaxIDNumber)) id++; |
52 | 54 | if(id >= MaxIDNumber) { |
55 | + //printf("TOO many instruments open\n"); | |
53 | 56 | return(TOOMANYREQ); /* No room */ |
54 | 57 | } |
55 | 58 | /* Open reference NC file */ |
56 | 59 | if((ddbase = getenv("DDBASE")) == NULL) return(NOREFFILE); |
57 | 60 | strcpy(refname,ddbase); |
58 | 61 | strcat(refname,REFNAME); |
62 | + //printf("Openning nc file %s\n", refname); | |
59 | 63 | |
60 | 64 | status = nc_open(refname, NC_NOWRITE|NC_SHARE,&refID); |
61 | 65 | |
... | ... | @@ -176,7 +180,7 @@ int OpenInstr(char *VInstrName) { |
176 | 180 | * Closes this ID and return number of IDs remained in use |
177 | 181 | */ |
178 | 182 | int CloseID(int ID) { |
179 | - printf("\tclosing instrument %i\n", ID); | |
183 | + //printf("\tclosing instrument %i\n", ID); | |
180 | 184 | // TODO |
181 | 185 | return 1; |
182 | 186 | int status; | ... | ... |
src/SERVER/DD_Server.c
... | ... | @@ -257,7 +257,7 @@ void pack_variables(XDR * xdrs, const DD_data_t * data, const u_int max_number) |
257 | 257 | } |
258 | 258 | |
259 | 259 | int send_var_data(const DD_data_t * data, const int socket_id, int last_flag) { |
260 | - printf("\tDEBUG : send_var_data\n"); | |
260 | + //printf("\tDEBUG : send_var_data\n"); | |
261 | 261 | XDR xdrs; |
262 | 262 | caddr_t buff; |
263 | 263 | int max_number, packet_size; |
... | ... | @@ -265,9 +265,9 @@ int send_var_data(const DD_data_t * data, const int socket_id, int last_flag) { |
265 | 265 | u_int n; |
266 | 266 | |
267 | 267 | max_number = get_max_number(data); |
268 | - printf("\t\tmax_number : %i\n", max_number); | |
268 | + //printf("\t\tmax_number : %i\n", max_number); | |
269 | 269 | packet_size = get_packet_size(data); |
270 | - printf("\t\tpacket_size : %i\n", packet_size); | |
270 | + //printf("\t\tpacket_size : %i\n", packet_size); | |
271 | 271 | |
272 | 272 | if((error = PutHeader(data->type, |
273 | 273 | data->DimNumber+1, |
... | ... | @@ -429,12 +429,12 @@ int get_table_name(char * instrument_name, char * out) { |
429 | 429 | } |
430 | 430 | |
431 | 431 | int datatable_has_data(char * table_name, double start, double stop) { |
432 | - printf("in datatable_has_data : table_name: %s, start: %f, stop : %f\n", table_name, start, stop); | |
432 | + //printf("in datatable_has_data : table_name: %s, start: %f, stop : %f\n", table_name, start, stop); | |
433 | 433 | int ans = 0, rc; |
434 | 434 | char * query = malloc( 1024 * sizeof(char) ); |
435 | 435 | memset(query, 0, 1024); |
436 | 436 | sprintf(query, "SELECT count(Time) FROM %s WHERE Time>=%f AND Time<%f;", table_name, start, stop); |
437 | - printf("\t\t has data query : %s\n", query); | |
437 | + //printf("\t\t has data query : %s\n", query); | |
438 | 438 | sqlite3 * db; |
439 | 439 | sqlite3_stmt * res; |
440 | 440 | sqlite3_open("amda.db", &db); |
... | ... | @@ -442,15 +442,15 @@ int datatable_has_data(char * table_name, double start, double stop) { |
442 | 442 | rc=sqlite3_step(res); |
443 | 443 | if(rc==SQLITE_ROW) { |
444 | 444 | ans = sqlite3_column_int(res, 0); |
445 | - printf("row found : %i\n", ans); | |
445 | + //printf("row found : %i\n", ans); | |
446 | 446 | } |
447 | 447 | else { |
448 | - printf("no row found\n"); | |
448 | + //printf("no row found\n"); | |
449 | 449 | } |
450 | 450 | sqlite3_finalize(res); |
451 | 451 | sqlite3_close(db); |
452 | 452 | free(query); |
453 | - printf("before return : %i\n", ans); | |
453 | + //printf("before return : %i\n", ans); | |
454 | 454 | return ans; |
455 | 455 | } |
456 | 456 | |
... | ... | @@ -524,8 +524,7 @@ void log_ddvar(DD_Var_t * ddvar, char * filename) { |
524 | 524 | int k; for(k=0;k<m;k++) { |
525 | 525 | fprintf(ptr, "%f,", ((double*)ddvar->VarData[i].Variables[j])[k]); |
526 | 526 | } |
527 | - fprintf(ptr, "\n"); | |
528 | - } | |
527 | + fprintf(ptr, "\n"); } | |
529 | 528 | fprintf(ptr, "\n"); |
530 | 529 | } |
531 | 530 | |
... | ... | @@ -534,8 +533,8 @@ void log_ddvar(DD_Var_t * ddvar, char * filename) { |
534 | 533 | |
535 | 534 | int get_data_from_table(char * table_name, struct RequestData * request) { |
536 | 535 | int rc; |
537 | - printf("\t\tinstrument start time : %f\n", get_instrument_time(request->instrument_id)); | |
538 | - printf("\t\tinterval value : %f\n", DD_Time2Double(request->time)); | |
536 | + //printf("\t\tinstrument start time : %f\n", get_instrument_time(request->instrument_id)); | |
537 | + //printf("\t\tinterval value : %f\n", DD_Time2Double(request->time)); | |
539 | 538 | double start_time = get_instrument_time(request->instrument_id); |
540 | 539 | double stop_time, dt; dt = DD_Time2Double(request->time); |
541 | 540 | stop_time = start_time + dt + 10; |
... | ... | @@ -562,7 +561,7 @@ int get_data_from_table(char * table_name, struct RequestData * request) { |
562 | 561 | |
563 | 562 | int i;for(i=0;i<request->variable_count;i++) { |
564 | 563 | char * var_name = request->variable_names[i]; |
565 | - printf("\tVariable name: %s\n", var_name); | |
564 | + //printf("\tVariable name: %s\n", var_name); | |
566 | 565 | if( strcmp(var_name, "Time") != 0) { |
567 | 566 | IntArray * p_dim=NULL; p_dim = get_parameter_dimension(var_name, table_name); |
568 | 567 | if(p_dim!=NULL) { |
... | ... | @@ -580,8 +579,8 @@ int get_data_from_table(char * table_name, struct RequestData * request) { |
580 | 579 | |
581 | 580 | } |
582 | 581 | else { |
583 | - printf("MUTLTIDIM DATA : Come back to this later\n"); | |
584 | - printf("\tp_dim : %i\n", p_dim->size); | |
582 | + //printf("MUTLTIDIM DATA : Come back to this later\n"); | |
583 | + //printf("\tp_dim : %i\n", p_dim->size); | |
585 | 584 | } |
586 | 585 | |
587 | 586 | // set parameter data dimensions |
... | ... | @@ -708,13 +707,13 @@ void create_instrument_time_table() { |
708 | 707 | } |
709 | 708 | |
710 | 709 | double get_instrument_time(int instrument_id) { |
711 | - printf("in get_instrument_time id : %i\n", instrument_id); | |
710 | + //printf("in get_instrument_time id : %i\n", instrument_id); | |
712 | 711 | // selection query |
713 | 712 | char * q = malloc(1024 * sizeof(char)); |
714 | 713 | double ans = -1; |
715 | 714 | int rc; |
716 | 715 | sprintf(q, "SELECT start FROM instrument_time WHERE id=%i LIMIT 1;", instrument_id); |
717 | - printf("query : -%s-\n", q); | |
716 | + //printf("query : -%s-\n", q); | |
718 | 717 | sqlite3 * db; |
719 | 718 | sqlite3_stmt * res; |
720 | 719 | sqlite3_open("amda.db", &db); |
... | ... | @@ -722,15 +721,15 @@ double get_instrument_time(int instrument_id) { |
722 | 721 | rc=sqlite3_step(res); |
723 | 722 | if(rc==SQLITE_ROW) { |
724 | 723 | ans = sqlite3_column_double(res, 0); |
725 | - printf("Row found : %f\n", ans); | |
724 | + //printf("Row found : %f\n", ans); | |
726 | 725 | } |
727 | 726 | else { |
728 | - printf("No row found\n"); | |
727 | + //printf("No row found\n"); | |
729 | 728 | } |
730 | 729 | sqlite3_finalize(res); |
731 | 730 | sqlite3_close(db); |
732 | 731 | free(q); |
733 | - printf("before return :%f\n", ans); | |
732 | + //printf("before return :%f\n", ans); | |
734 | 733 | return ans; |
735 | 734 | } |
736 | 735 | int set_instrument_time(int instrument_id, double time) { |
... | ... | @@ -838,7 +837,7 @@ void Serv(int socket_id) { |
838 | 837 | *----------------------------------------------*/ |
839 | 838 | err=request_call(&r, socket_id, &done_flag, &TicketID, &RemainID); |
840 | 839 | |
841 | - } while(done_flag== 0);/* end while(done_flag) */ | |
840 | + } while(!done_flag);/* end while(done_flag) */ | |
842 | 841 | |
843 | 842 | |
844 | 843 | endend: | ... | ... |
src/SERVER/request.c
... | ... | @@ -257,11 +257,11 @@ int request_call_close_instrument(struct RequestData * request, int socket_id, i |
257 | 257 | } |
258 | 258 | |
259 | 259 | int request_call_set_time(struct RequestData * request, DD_Var_t * ddvar, int socket_id) { |
260 | - printf("\tinstrument id : %i\n", request->instrument_id); | |
261 | - printf("\tstart ddtime : %s\n", request->time); | |
260 | + //printf("\tinstrument id : %i\n", request->instrument_id); | |
261 | + //printf("\tstart ddtime : %s\n", request->time); | |
262 | 262 | double time_s; |
263 | 263 | time_s = DD_Time2Double(request->time); |
264 | - printf("\tstart double : %f\n", time_s); | |
264 | + //printf("\tstart double : %f\n", time_s); | |
265 | 265 | int err; |
266 | 266 | if(request->instrument_id < 0) err = NOID; |
267 | 267 | if(err >= 0) err = SetTime(ddvar,DD_Time2Double(request->time)); |
... | ... | @@ -300,22 +300,26 @@ int request_call_data_info(struct RequestData * request, DD_Var_t * ddvar, int s |
300 | 300 | |
301 | 301 | int request_call_get_ticket(struct RequestData * request, int socket_id, int * done_flag, int * ticket_id) { |
302 | 302 | int err; |
303 | + printf("Checking ticket : login: %s, tick: %s\n", request->login, request->ticket); | |
303 | 304 | err= CheckTicket(request->login, request->ticket); |
305 | + printf("err: %i\n", err); | |
304 | 306 | Put2Log(request->user_id,request->host,request->login,err); /* Log file */ |
307 | + printf("Getting ticket : user_id: %i, host: %s, err: %i\n", request->user_id, request->host, err); | |
305 | 308 | if(err>= 0) *ticket_id = GetTicket(request->user_id,request->host,err); |
309 | + printf("\tticket id : %i\n", *ticket_id); | |
306 | 310 | PutHeader(*ticket_id,0,0,socket_id); |
307 | 311 | *done_flag= 1; |
308 | 312 | return err; |
309 | 313 | } |
310 | 314 | |
311 | 315 | double get_instrument_time2(int instrument_id) { |
312 | - printf("in get_instrument_time2 id : %i\n", instrument_id); | |
316 | + //printf("in get_instrument_time2 id : %i\n", instrument_id); | |
313 | 317 | // selection query |
314 | 318 | char * q = malloc(1024 * sizeof(char)); |
315 | 319 | double ans = -1; |
316 | 320 | int rc; |
317 | 321 | sprintf(q, "SELECT start FROM instrument_time WHERE id=%i LIMIT 1;", instrument_id); |
318 | - printf("query : -%s-\n", q); | |
322 | + //printf("query : -%s-\n", q); | |
319 | 323 | sqlite3 * db; |
320 | 324 | sqlite3_stmt * res; |
321 | 325 | sqlite3_open("amda.db", &db); |
... | ... | @@ -323,25 +327,25 @@ double get_instrument_time2(int instrument_id) { |
323 | 327 | rc=sqlite3_step(res); |
324 | 328 | if(rc==SQLITE_ROW) { |
325 | 329 | ans = sqlite3_column_double(res, 0); |
326 | - printf("Row found : %f\n", ans); | |
330 | + //printf("Row found : %f\n", ans); | |
327 | 331 | } |
328 | 332 | else { |
329 | - printf("No row found\n"); | |
333 | + //printf("No row found\n"); | |
330 | 334 | } |
331 | 335 | sqlite3_finalize(res); |
332 | 336 | sqlite3_close(db); |
333 | 337 | free(q); |
334 | - printf("before return :%f\n", ans); | |
338 | + //printf("before return :%f\n", ans); | |
335 | 339 | return ans; |
336 | 340 | } |
337 | 341 | |
338 | 342 | int datatable_has_data2(char * table_name, double start, double stop) { |
339 | - printf("in datatable_has_data2 : table_name:%s, start:%f, stop:%f\n", table_name, start, stop); | |
343 | + //printf("in datatable_has_data2 : table_name:%s, start:%f, stop:%f\n", table_name, start, stop); | |
340 | 344 | int ans = 0, rc; |
341 | 345 | char * query = malloc( 1024 * sizeof(char) ); |
342 | 346 | memset(query, 0, 1024); |
343 | 347 | sprintf(query, "SELECT count(Time) FROM %s WHERE Time>=%f AND Time<%f;", table_name, start, stop); |
344 | - printf("\t\t has data query : %s\n", query); | |
348 | + //printf("\t\t has data query : %s\n", query); | |
345 | 349 | sqlite3 * db; |
346 | 350 | sqlite3_stmt * res; |
347 | 351 | sqlite3_open("amda.db", &db); |
... | ... | @@ -349,21 +353,21 @@ int datatable_has_data2(char * table_name, double start, double stop) { |
349 | 353 | rc=sqlite3_step(res); |
350 | 354 | if(rc==SQLITE_ROW) { |
351 | 355 | ans = sqlite3_column_int(res, 0); |
352 | - printf("row found :%i\n", ans); | |
356 | + //printf("row found :%i\n", ans); | |
353 | 357 | } |
354 | 358 | else { |
355 | - printf("no row found\n"); | |
359 | + //printf("no row found\n"); | |
356 | 360 | } |
357 | 361 | sqlite3_finalize(res); |
358 | 362 | sqlite3_close(db); |
359 | 363 | free(query); |
360 | - printf("before return : %i\n", ans); | |
364 | + //printf("before return : %i\n", ans); | |
361 | 365 | return ans; |
362 | 366 | } |
363 | 367 | int request_call_data_get(struct RequestData * request, int socket_id, int * done_flag, int * ticket_id) { |
364 | 368 | int err,serr; |
365 | - printf("\tparameters : "); | |
366 | - print_string_array(request->variable_names, request->variable_count); | |
369 | + //printf("\tparameters : "); | |
370 | + //print_string_array(request->variable_names, request->variable_count); | |
367 | 371 | // note the time at this point |
368 | 372 | struct timespec t0, t1; |
369 | 373 | clock_gettime(CLOCK_MONOTONIC_RAW, &t0); |
... | ... | @@ -386,15 +390,15 @@ int request_call_data_get(struct RequestData * request, int socket_id, int * don |
386 | 390 | has_vi=has_virtual_instrument(table_name); |
387 | 391 | if(has_vi) { |
388 | 392 | // try to get data for this instrument between start and stop dates |
389 | - printf("Instrument id : %i\n", request->instrument_id); | |
393 | + //printf("Instrument id : %i\n", request->instrument_id); | |
390 | 394 | double start_time; start_time = get_instrument_time(request->instrument_id); |
391 | - printf("start_time %f\n", start_time); | |
392 | - printf("request time str : %s\n", request->time); | |
395 | + //printf("start_time %f\n", start_time); | |
396 | + //printf("request time str : %s\n", request->time); | |
393 | 397 | double stop_time; stop_time = start_time + DD_Time2Double(request->time); |
394 | - printf("before datatable_has_data2 call : table_name:%s, start_time:%f, stop_time:%f\n", table_name, start_time,stop_time); | |
398 | + //printf("before datatable_has_data2 call : table_name:%s, start_time:%f, stop_time:%f\n", table_name, start_time,stop_time); | |
395 | 399 | int has_data; |
396 | 400 | has_data = datatable_has_data(table_name, start_time, stop_time); |
397 | - printf("in request_call_data_get : has_data : %i\n", has_data); | |
401 | + //printf("in request_call_data_get : has_data : %i\n", has_data); | |
398 | 402 | if(has_data || 1) { |
399 | 403 | err = get_data_from_table(table_name, request); |
400 | 404 | } |
... | ... | @@ -416,8 +420,8 @@ int request_call_data_get(struct RequestData * request, int socket_id, int * don |
416 | 420 | // note time at this point |
417 | 421 | clock_gettime(CLOCK_MONOTONIC_RAW, &t1); |
418 | 422 | uint64_t ns = (t1.tv_sec - t0.tv_sec) * 1000000 + (t1.tv_nsec - t0.tv_nsec) / 1000; |
419 | - printf("\t\t\tREQUEST TIME :%" PRIu64 "\n", ns); | |
420 | - printf("\t\t\t\t %f ms\n", ns / 1000.); | |
423 | + //printf("\t\t\tREQUEST TIME :%" PRIu64 "\n", ns); | |
424 | + //printf("\t\t\t\t %f ms\n", ns / 1000.); | |
421 | 425 | // TODO - free DD_Var_t object |
422 | 426 | //DD_Var[r.instrument_id] = NULL; |
423 | 427 | return err; |
... | ... | @@ -438,6 +442,7 @@ int request_call(struct RequestData * request, int socket_id, int * done_flag, i |
438 | 442 | case TIMESETREQ: |
439 | 443 | printf("REQUEST : TIMESETREQ\n"); |
440 | 444 | err=request_call_set_time(request, DD_Var[request->instrument_id], socket_id); |
445 | + printf("SetTime err : %i\n", err); | |
441 | 446 | set_instrument_time(request->instrument_id, DD_Time2Double(request->time)); |
442 | 447 | break; |
443 | 448 | case DATAINFOREQ: | ... | ... |