Changeset 162 for SH_SHM/trunk


Ignore:
Timestamp:
10/13/2009 03:10:46 PM (14 years ago)
Author:
marcus
Message:

r96 | svn | 2009-10-08 21:52:13 +0200 (Do, 08 Okt 2009) | 1 line

implemented high sample rates and non-integer start times

File:
1 edited

Legend:

Unmodified
Added
Removed
  • SH_SHM/trunk/source/gcf/gcflib.c

    r160 r162  
    255255        int           i;           /* counter */ 
    256256        NTIME         ntime;       /* numeric start time */ 
     257        int           offset;      /* time offset */ 
     258        int           denom;       /* denominator of fraction of seconds */ 
     259        float         secoff;      /* offset in seconds */ 
    257260 
    258261        /* executable code */ 
     
    287290        /* data format bytes */ 
    288291        hdr->smprate = (rhdr->data_format & 0x00ff0000) >> 16; 
    289         hdr->cmpcode = (rhdr->data_format & 0x0000ff00) >>  8; 
     292        hdr->cmpcode = (rhdr->data_format & 0x00000f00) >>  8; 
    290293        hdr->numrec  = (rhdr->data_format & 0x000000ff); 
     294 
     295        /* extended settings */ 
     296        offset       = (rhdr->data_format & 0x0000f000) >> 12; /* time offset */ 
     297        switch (hdr->smprate) { 
     298        case 157:   hdr->smprate =    0; /* should be 0.1   */ denom=0;  break; 
     299        case 161:   hdr->smprate =    0; /* should be 0.125 */ denom=0;  break; 
     300        case 162:   hdr->smprate =    0; /* should be 0.2   */ denom=0;  break; 
     301        case 164:   hdr->smprate =    0; /* should be 0.25  */ denom=0;  break; 
     302        case 167:   hdr->smprate =    0; /* should be 0.5   */ denom=0;  break; 
     303        case 171:   hdr->smprate =  400;                       denom=8;  break; 
     304        case 174:   hdr->smprate =  500;                       denom=2;  break; 
     305        case 176:   hdr->smprate = 1000;                       denom=4;  break; 
     306        case 179:   hdr->smprate = 2000;                       denom=8;  break; 
     307        case 181:   hdr->smprate = 4000;                       denom=16; break; 
     308        } /*endswitch*/ 
     309 
     310        /* add fraction of seconds to start time, if specified */ 
     311        if  (denom != 0 && offset > 0)  { 
     312                NTIME     corrtime;    /* corrected time */ 
     313                secoff = (float)offset / (float)denom; 
     314                tc_nadd( &ntime, secoff, &corrtime, status ); 
     315                if  (SySevere(status))  return; 
     316                tc_n2t( &corrtime, hdr->blktime, status ); 
     317        } /*endif*/ 
    291318 
    292319} /* end of GcfDecodeHeader */ 
     
    522549 
    523550        if  (samples[j-1] != block[numrec+1]) 
    524                 *status = GcfERR_CHKSUM; 
     551                /* *status = GcfERR_CHKSUM; */ 
     552                printf( "Gcf checksum error (%d != %d)\n", samples[j-1], block[numrec+1] ); 
    525553 
    526554} /* GcfDecodeBlock */ 
     
    774802                tdiff_start = tc_ndiff( &req_ntime, &cur_ntime, status ); 
    775803                if  (SySevere(status))  return; 
    776                 cur_span = (float)(hdr.numrec*hdr.cmpcode/hdr.smprate); 
     804                cur_span = (hdr.smprate == 0) 
     805                        ? 0.0 : (float)(hdr.numrec*hdr.cmpcode/hdr.smprate); 
    777806                if  (tdiff_start >= 0.0)  { 
    778807                        if  (cur_span > tdiff_start)  { 
     
    886915                tdiff_start = tc_ndiff( &req_ntime, &cur_ntime, status ); 
    887916                if  (Severe(status))  return; 
    888                 cur_span = (float)(hdr.numrec*hdr.cmpcode/hdr.smprate); 
     917                cur_span = (hdr.smprate == 0) 
     918                        ? 0.0 : (float)(hdr.numrec*hdr.cmpcode/hdr.smprate); 
    889919        } /*endwhile*/ 
    890920 
Note: See TracChangeset for help on using the changeset viewer.