Changeset 88
- Timestamp:
- May 29, 2003, 7:52:19 AM (23 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/imregister/src/imstatreg.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/imregister/src/imstatreg.c
r81 r88 1 1 # include "imregister.h" 2 2 # include "imreg.h" 3 static char *version = "imstatreg $Revision: 3. 4$";3 static char *version = "imstatreg $Revision: 3.5 $"; 4 4 5 5 int main (int argc, char **argv) { … … 8 8 float *dtime; 9 9 int i, *match, Nmatch, status, child, Nentry; 10 char *TempDB, *LogFile ;10 char *TempDB, *LogFile, *ccdname; 11 11 FILE *f; 12 12 … … 24 24 SetSignals (); 25 25 26 /* fork in background */ 26 27 if (child = fork ()) { 27 28 if (child == -1) { … … 40 41 if (f == (FILE *) NULL) { 41 42 fprintf (stderr, "can't open log file %s, writing to stderr\n", LogFile); 43 } else { 44 /* an error here will be missed, but is unlikely since we have access in the above test */ 45 f = freopen (LogFile, "a", stderr); 42 46 } 43 f = freopen (LogFile, "a", stderr);44 /* an error here will be missed, but is unlikely since we have access in the above test */45 47 46 48 /* start loop */ 47 49 while (1) { 48 50 51 /* check / load temporary database */ 49 52 set_db (TempDB); 50 53 status = load_db (); 51 54 if (!status) { 52 fprintf (stderr, "temporary database is empty\n");55 print_db_status ("temporary database empty"); 53 56 close_db (); 54 fflush (stderr); 55 fflush (stdout); 56 sleep (60); 57 continue; 57 goto next; 58 58 } 59 59 image = get_images (&Nentry); 60 close_lock_db (); /* file closed, hardlock on temp db remains */ 60 print_db_status ("temporary database read"); 61 close_lock_db (); 62 /* temp DB closed, hardlock on temp DB remains */ 61 63 64 /* check / load main database */ 62 65 set_db (ImageDB); 63 66 status = load_db (); 64 67 if (!status) { 65 fprintf (stderr, "database is empty\n"); 66 close_db (); sleep (60); continue; 68 print_db_status ("main database empty"); 69 close_db (); 70 goto next; 67 71 } 72 73 /* match temp image with main images / update main DB */ 74 match = match_images (image, Nentry, &Nmatch); 75 if (Nmatch != Nentry) fprintf (stderr, "WARNING: some images missed\n"); 76 print_db_status ("main database read"); 77 update_db (match, Nmatch); 78 free (match); 68 79 69 match = match_images (image, Nentry, &Nmatch); 70 if (!Nmatch) { 71 close_db (); 72 fprintf (stderr, "ERROR: no matched images found\n"); 73 fprintf (stderr, "image: %s %s (%d) %s (%d)\n", image[0].filename, sec_to_date (image[0].obstime), image[0].obstime, ccds[image[0].ccd], image[0].ccd); 74 exit (2); 75 } 76 update_db (match, Nmatch); 77 78 /* clear temp db hardlock */ 79 unlink (TempDB); 80 /* clear temp DB hardlock */ 81 unlink (TempDB); 80 82 clearlockfile2 (TempDB, -1, LCK_HARD, &status); 83 84 next: 81 85 fflush (stderr); 82 86 fflush (stdout); 83 sleep ( 60);87 sleep (LOOP_DELAY); 84 88 } 85 89 }
Note:
See TracChangeset
for help on using the changeset viewer.
