Exemple #1
0
/* This function not only seeks to the specified point, but also reads
 * the point into the buffer if necessary. The get_singlepoint function
 * then only transfers the data. */
LOCAL void
read_synamps_seek_point(transform_info_ptr tinfo, long point) {
 struct read_synamps_storage *local_arg=(struct read_synamps_storage *)tinfo->methods->local_storage;

 switch(local_arg->SubType) {
  case NST_CONT0:
  case NST_DCMES:
  case NST_CONTINUOUS:
  case NST_SYNAMPS: {
   /*{{{  */
   const int points_per_buf=local_arg->EEG.ChannelOffset/local_arg->bytes_per_sample; /* Note a value of 1 is fixed in read_synamps_init */
   long const buffer_boundary=(point/points_per_buf)*points_per_buf;
   long const new_last_point_in_buffer=buffer_boundary+points_per_buf-1;
   /* This format is neither points fastest nor channels fastest, but
    * points fastest in blocks. No idea why they didn't do channels fastest,
    * it would have rendered the whole file in one order, no matter what buffer
    * size is used internally in programs. This way we MUST use the given buffers. */
   if (new_last_point_in_buffer!=local_arg->last_point_in_buffer) {
    fseek(local_arg->SCAN,point2offset(tinfo,buffer_boundary),SEEK_SET);
    if (fread(local_arg->buffer,1,local_arg->BufferCount,local_arg->SCAN)!=local_arg->BufferCount) {
     ERREXIT(tinfo->emethods, "read_synamps_seek_point: Error reading data\n");
    }
    local_arg->first_point_in_buffer=buffer_boundary;
    local_arg->last_point_in_buffer=new_last_point_in_buffer;
    /*{{{  Swap byte order if necessary*/
#    ifndef LITTLE_ENDIAN
    {uint16_t *pdata=(uint16_t *)local_arg->buffer, *p_end=(uint16_t *)((char *)local_arg->buffer+local_arg->BufferCount);
     while (pdata<p_end) Intel_int16(pdata++);
    }
#    endif
    /*}}}  */
   }
   /*}}}  */
  }
  break;
 default:
  ERREXIT1(tinfo->emethods, "read_synamps_seek_point: Format `%s' is not yet supported\n", MSGPARM(neuroscan_subtype_names[local_arg->SubType]));
  break;
 }
 local_arg->current_point=point;
}
Exemple #2
0
    } else {
     resp=(-intrig->code)&0xf;
     if (resp==0) {
      keyboard=(-intrig->code)>>4;
      if (keyboard==0) {
       TRACEMS1(tinfo->emethods, 1, "write_synamps_exit: Can't decipher event code %d\n", MSGPARM(intrig->code));
      } else {
       keyboard--;
      }
     }
    }
   }
   event.StimType=type; event.KeyBoard=keyboard;
   Event_KeyPad_set(event, resp);
   Event_Accept_set(event, acc);
   event.Offset=point2offset(tinfo, intrig->position);
#  ifndef LITTLE_ENDIAN
   change_byteorder((char *)&event, sm_EVENT1);
#  endif
   write_struct((char *)&event, sm_EVENT1, local_arg->SCAN);
  }

  if (local_arg->triggers.buffer_start!=NULL) {
   clear_triggers(&local_arg->triggers);
   growing_buf_free(&local_arg->triggers);
  }

  /* Write the end event */
  event.StimType=0;	event.KeyBoard=0;
  Event_KeyPad_set(event, 0);
  Event_Accept_set(event, NAV_STARTSTOP);