// filename: get_ecg_waveform.c // copyright Massachusetts Institute of Technology // author: Matt Oefinger #include #include char DB_PATH[] = "http://physionet.org/physiobank/database"; char ABSOLUTE_PATH[150]; char RECORD_ID[50]; WFDB_Time string2int(char* digit); int string2int_2(char *digit); WFDB_Time string2int(char* digit) { WFDB_Time result = 0; //--- Convert each digit char and add into result. while (*digit >= '0' && *digit <='9') { result = (result * 10) + (*digit - '0'); digit++; } //--- Check that there were no non-digits at end. if (*digit != 0) { return 0; } return result; } int string2int_2(char* digit) { int result = 0; //--- Convert each digit char and add into result. while (*digit >= '0' && *digit <='9') { result = (result * 10) + (*digit - '0'); digit++; } //--- Check that there were no non-digits at end. if (*digit != 0) { return 0; } return result; } main(int argc, char* argv[]) { int i, j, nsig, screenwidth, CMDcode; WFDB_Siginfo *siarray; WFDB_Sample *v; WFDB_Time start_t_index, abstime; WFDB_Anninfo a; WFDB_Annotation annot; char annotator[50]; start_t_index = string2int(argv[3]); screenwidth = string2int_2(argv[4]); CMDcode = string2int_2(argv[5]); sprintf(annotator,argv[6]); sprintf(ABSOLUTE_PATH,"%s/%s",DB_PATH,argv[1]); setwfdb(ABSOLUTE_PATH); switch(CMDcode) { //This case handels all get signal requests... case 0: nsig = isigopen(argv[2], NULL, 0); if (nsig < 1) exit(1); siarray = (WFDB_Siginfo *)malloc(nsig * sizeof(WFDB_Siginfo)); nsig = isigopen(argv[2], siarray, nsig); v = (WFDB_Sample *)malloc(nsig * sizeof(WFDB_Sample)); if(isigsettime(start_t_index) != 0) exit(1); for(j=0; j < screenwidth; j++) { if(getvec(v) <= 0) exit(1); else { for(i=0; i (start_t_index+screenwidth)) break; abstime = annot.time; printf("%d\n%s\n", abstime, annstr(annot.anntyp)); } break; default: exit(1); break; } wfdbquit(); exit(0); }