Tscope5
|
Definitions of timer functions. More...
Go to the source code of this file.
Functions | |
Program priority functions | |
You can increase your program's priority to get better timing accuracy. | |
int | ts5_set_priority (int priority) |
Set the program's priority. More... | |
int | ts5_get_priority () |
Get the program's priority. More... | |
General timing functions | |
The general timing functions are mainly used to control stimulus timing. You can either wait for a given amount of time, or until some time in the future. | |
double | ts5_get_time () |
Get the number of seconds since the program started. More... | |
void | ts5_wait (double waittime) |
Wait for a number of seconds. More... | |
void | ts5_wait_until (double deadline) |
Wait until a deadline. More... | |
Response registration | |
The response registration functions require you to define response buttons first using ts5_define_mouse_button(), ts5_define_keyboard_button(), ts5_define_joystick_button(), ts5_define_cedrusbox_button() or ts5_define_parport_button(). Each response button will get a response value. The first button that is defined will get number 1, etc. Registration of responses is done asynchronously. All button presses that are defined will be buffered continuously during the program. Waiting for a response to a stimulus will typically involve flushing all buffered responses that occurred before stimulus onset using ts5_flush_responses() and then checking for new responses using ts5_check_response(), ts5_wait_for_response(), ts5_wait_for_response_timed() or ts5_wait_for_response_until(). The response definition can be altered during the program using ts5_hide_response_button() or ts5_remove_response_buttons(). | |
int | ts5_hide_response_button (int button) |
Temporarily deactivates a response button. More... | |
void | ts5_remove_response_buttons () |
Completely removes the response button definition. More... | |
void | ts5_flush_responses () |
Flush the response queue. More... | |
int | ts5_check_response (double *resptime, double *timing_error) |
Check for a reponse. More... | |
int | ts5_wait_for_response (double *resptime, double *timing_error) |
Wait for a response. More... | |
int | ts5_wait_for_response_timed (double *resptime, double *timing_error, double maxtime) |
Wait for a response for a given time. More... | |
int | ts5_wait_for_response_until (double *resptime, double *timing_error, double deadline) |
Wait for a response until a deadline. More... | |
Trigger input/output | |
The trigger input functions require you to define trigger devices using ts5_define_parport_trigger_input() or ts5_define_serialport_trigger_input(). Registration of trigger input is done asynchronously. All triggers received on the parallel and/or serial port(s) will be buffered continuously during the program. Waiting for a trigger is similar to waiting for a reponse. Old triggers that were not processed yet can be flushed using ts5_flush_triggers(). One can either wait for a trigger indefinitely, for a given amount of time or until some deadline has passed. The value of the trigger is defined by the computer that sends the trigger. During the development of the program it is not necessary to connect a computer that sends the triggers. Trigger input can be simulated using ts5_simulate_parport_trigger_input() or ts5_simulate_serialport_trigger_input(). At the end of the program all triggers can be written to a logfile using ts5_write_all_triggers(). Trigger output is simple, call ts5_send_parport_trigger() or ts5_send_serialport_trigger() each time you want to send a trigger. | |
void | ts5_flush_triggers () |
Flush the trigger queue. More... | |
int | ts5_check_trigger (double *trigtime, double *timing_error) |
Check for a trigger. More... | |
int | ts5_wait_for_trigger (double *trigtime, double *timing_error) |
Wait for a trigger. More... | |
int | ts5_wait_for_trigger_timed (double *trigtime, double *timing_error, double maxtime) |
Wait for a trigger for a given time. More... | |
int | ts5_wait_for_trigger_until (double *trigtime, double *timing_error, double deadline) |
Wait for a trigger until a deadline. More... | |
void | ts5_write_all_triggers (char *filename) |
Write all triggers to an output file. More... | |
Definitions of timer functions.
Definition in file timer.c.
int ts5_set_priority | ( | int | priority | ) |
Set the program's priority.
priority | Priority. |
There are five possible settings:
The default priority is TS5_NORMAL_PRIORITY.
int ts5_get_priority | ( | ) |
double ts5_get_time | ( | ) |
Get the number of seconds since the program started.
void ts5_wait | ( | double | waittime | ) |
Wait for a number of seconds.
void ts5_wait_until | ( | double | deadline | ) |
Wait until a deadline.
int ts5_hide_response_button | ( | int | button | ) |
Temporarily deactivates a response button.
button | The button that has to be deactivated. |
This function also checks whether there are any active response left. Aborts if necessary.
Reactivating all defined buttons is possible by calling ts5_hide_response_button(0).
void ts5_remove_response_buttons | ( | ) |
void ts5_flush_responses | ( | ) |
Flush the response queue.
int ts5_check_response | ( | double * | resptime, |
double * | timing_error | ||
) |
Check for a reponse.
resptime | Variable that will store the response time. |
timing_error | Variable that will store the timing error (works only for cedrusboxes and parallel port boxes). |
This function checks for a response and returns immediately.
int ts5_wait_for_response | ( | double * | resptime, |
double * | timing_error | ||
) |
int ts5_wait_for_response_timed | ( | double * | resptime, |
double * | timing_error, | ||
double | maxtime | ||
) |
Wait for a response for a given time.
resptime | Variable that will store the response time. |
timing_error | Variable that will store the timing error (works only for cedrusboxes and parallel port boxes). |
maxtime | Maximum time for a response. |
int ts5_wait_for_response_until | ( | double * | resptime, |
double * | timing_error, | ||
double | deadline | ||
) |
Wait for a response until a deadline.
resptime | Variable that will store the response time. |
timing_error | Variable that will store the timing error (works only for cedrusboxes and parallel port boxes). |
deadline | Deadline for a response. |
int ts5_check_trigger | ( | double * | trigtime, |
double * | timing_error | ||
) |
int ts5_wait_for_trigger | ( | double * | trigtime, |
double * | timing_error | ||
) |
Wait for a trigger.
trigtime | Variable that will store the trigger time. |
timing_error | Variable that will store the timing error (works only for cedrusboxes and parallel port boxes). |
int ts5_wait_for_trigger_timed | ( | double * | trigtime, |
double * | timing_error, | ||
double | maxtime | ||
) |
Wait for a trigger for a given time.
trigtime | Variable that will store the trigger time. |
timing_error | Variable that will store the timing error (works only for cedrusboxes and parallel port boxes). |
maxtime | Maximum time for a trigger. |
int ts5_wait_for_trigger_until | ( | double * | trigtime, |
double * | timing_error, | ||
double | deadline | ||
) |
Wait for a trigger until a deadline.
trigtime | Variable that will store the trigger time. |
timing_error | Variable that will store the timing error (works only for cedrusboxes and parallel port boxes). |
deadline | Deadline for a trigger. |
void ts5_write_all_triggers | ( | char * | filename | ) |
Write all triggers to an output file.
filename | Path to the output file |