libRASCH: ra.c File Reference
ra.c File Reference
Include dependency graph for ra.c:
Go to the source code of this file.
Defines
#define _LIBRASCH_BUILD
Functions
LIBRAAPI ra_handle ra_lib_init (void)
init libRASCH
void set_endian_type ()
set endian of current system
void init_i18n (struct librasch *ra)
call functions and set variables needed for i18n
LIBRAAPI int get_endian_type ()
returns endian type
int read_config (struct librasch *ra)
read libRASCH configuration
void init_config (struct config_info *conf)
set configuration to values which work when no config-file is found
int find_config_file (char *fn)
read libRASCH configuration from Registry (only on Win32) look for libRASCH configuration file
LIBRAAPI void ra_lib_close (ra_handle h)
close libRASCH
LIBRAAPI long ra_lib_get_error (ra_handle h, char *text, int len)
get last error
void get_error_text_ra (long err, char *text, int len)
returns error-string for OS specific errors returns error-string for libRASCH errors
LIBRAAPI void _ra_set_error_int (any_handle h, long error, const char *error_from, const char *file, int line)
set error number
LIBRAAPI ra_handle ra_lib_handle_from_any_handle (any_handle h)
retrive handle of libRASCH instance from any handle
LIBRAAPI meas_handle ra_meas_handle_from_any_handle (any_handle h)
retrive measurement-handle from any handle
LIBRAAPI int ra_lib_use_plugin (ra_handle h, int plugin_index, int use_it)
set using a plugin (or not)
plugin_struct * get_plugin (struct librasch *ra, int number)
returns plugin-handle
plugin_struct * get_plugin_by_name (struct librasch *ra, const char *name)
returns plugin-handle
LIBRAAPI plugin_handle ra_plugin_get_by_num (ra_handle h, int plugin_num, int search_all)
get plugin-handle
LIBRAAPI plugin_handle ra_plugin_get_by_name (ra_handle h, const char *name, int search_all)
get plugin-handle
LIBRAAPI ra_find_handle ra_meas_find_first (ra_handle h, const char *dir, struct ra_find_struct *rfs)
find libRASCH-handled measurements (return first one)
LIBRAAPI int ra_meas_find_next (ra_find_handle h, struct ra_find_struct *rfs)
find libRASCH-handled measurements (returns next)
LIBRAAPI void ra_meas_close_find (ra_find_handle h)
close the search for libRASCH-handled measurements
LIBRAAPI meas_handle ra_meas_open (ra_handle h, const char *file, const char *eval_file, int fast)
open a measurement
int calc_x_scales (struct ra_meas *meas)
do scaling calculations
LIBRAAPI meas_handle ra_meas_new (ra_handle h, const char *dir, const char *name)
creates a new measurement
LIBRAAPI int ra_meas_save (meas_handle mh)
saves a measurement
LIBRAAPI void ra_meas_close (meas_handle mh)
close a measurement
LIBRAAPI int ra_info_get (any_handle h, int id, value_handle vh)
get infos
int check_handle_type (any_handle h, int id)
check handle type
int get_lib_info (ra_handle ra, int id, value_handle vh)
returns informations about the core
int get_plugin_info (plugin_handle pl, int id, value_handle vh)
returns informations about plugins
int get_meas_general_info (meas_handle mh, int id, value_handle vh)
returns informations about a measurement
int get_session_info (any_handle h, int id, value_handle vh)
returns informations about a session
int get_proc_info (any_handle h, int id, value_handle vh)
returns informations about processing results
plugin_struct * get_plugin_from_handle (any_handle h)
returns plugin-handle
LIBRAAPI int ra_info_get_by_name (any_handle h, const char *name, value_handle vh)
get infos
LIBRAAPI int ra_info_get_by_idx (any_handle h, int info_type, int idx, value_handle vh)
get infos
LIBRAAPI int ra_info_set (any_handle h, value_handle vh)
set info
LIBRAAPI rec_handle ra_rec_get_first (meas_handle mh, long session)
get root-recording
LIBRAAPI rec_handle ra_rec_get_next (rec_handle rh)
get next recording
LIBRAAPI rec_handle ra_rec_get_first_child (rec_handle rh)
get first sub-recording
LIBRAAPI rec_handle ra_rec_add (meas_handle mh, rec_handle parent)
add a recording
LIBRAAPI int ra_dev_add (rec_handle rh)
add a recording-device
LIBRAAPI int ra_ch_add (rec_handle rh)
add a recording-channel
LIBRAAPI int ra_session_new (meas_handle mh)
start a new recording session
LIBRAAPI size_t ra_raw_add (meas_handle mh, unsigned int ch, value_handle vh)
add raw data
LIBRAAPI size_t ra_raw_get (rec_handle rh, unsigned int ch, size_t start, size_t num_data, DWORD *data, DWORD *data_high)
get raw-signal data
LIBRAAPI size_t ra_raw_get_unit (rec_handle rh, unsigned int ch, size_t start, size_t num_data, double *data)
get raw-signal data scaled to 'unit'-values
LIBRAAPI int ra_gui_call (any_handle h, plugin_handle pl)
shows GUI-element of a plugin (if avail.)
LIBRAAPI proc_handle ra_proc_get (meas_handle mh, plugin_handle pl, void(*callback)(const char *, int))
get a processing handle
LIBRAAPI void ra_proc_free (proc_handle proc)
free a processing handle
LIBRAAPI int ra_proc_do (proc_handle proc)
process the signal
LIBRAAPI int ra_proc_get_result (proc_handle proc, long res_num, long res_set, value_handle vh)
get the processing results
LIBRAAPI int ra_view_get (view_handle vh)
create/show view of view-plugin
LIBRAAPI int ra_lib_get_option (any_handle h, const char *opt_name, value_handle vh)
returns an option value
int find_option (const char *name, struct ra_option_infos *infos, int num_opt)
returns index of an option
int get_option (void *options, struct ra_option_infos *opt_info, value_handle vh, long num_offset)
returns option value
LIBRAAPI int ra_lib_set_option (any_handle h, const char *opt_name, value_handle vh)
set an option
int set_option (void *options, struct ra_option_infos *opt_info, value_handle vh, long num_offset)
set option value
LIBRAAPI int ra_meas_copy (meas_handle mh, const char *dest_dir)
copy measurement
LIBRAAPI meas_handle ra_meas_move (meas_handle mh, const char *dest_dir)
move measurement
int copy_move_meas (meas_handle mh, const char *dest_dir, int copy)
do a copy or move of a measurement
LIBRAAPI int ra_meas_delete (meas_handle mh)
delete measurement
Variables
int ra_print_debug_infos
int ra_in_error
int ra_endian_type
char ra_i18n_codeset [MAX_I18N_LEN]
Detailed Description
This file provides most part of the libRASCH-API (the evaluation-API can be found in ./eval/eval.c).
Author: Raphael Schneider (rasch@med1.med.tum.de )
Definition in file ra.c .
Define Documentation
Definition at line 30 of file ra.c .
Function Documentation
LIBRAAPI void _ra_set_error_int
(
any_handle
h ,
long
error ,
const char *
error_from ,
const char *
file ,
int
line
)
int calc_x_scales
(
struct ra_meas *
meas
)
Parameters:
<meas> pointer to a measurement struct
Function gets maximum samplerate used in a measurement and calculate for each recording channel the scaling factor to the max. samplerate.
Definition at line 1059 of file ra.c .
References ra_meas::max_samplerate , ra_meas::num_ch , ra_info_get() , RA_INFO_REC_CH_SAMPLERATE_D , RA_INFO_REC_GEN_NUM_CHANNEL_L , ra_rec_get_first() , ra_value_free() , ra_value_get_double() , ra_value_get_long() , ra_value_malloc() , ra_value_set_number() , and ra_meas::x_scale .
Referenced by ra_meas_new() , and ra_meas_open() .
Parameters:
<h> any libRASCH handle
<id> name of plugin
Function checks if the type handle 'h' is correct for the info-id 'id'.
Definition at line 1299 of file ra.c .
References _ra_set_error , RA_ERR_UNKNOWN_HANDLE , RA_ERR_UNSUPPORTED , RA_HANDLE_EVAL , RA_HANDLE_EVAL_CLASS , RA_HANDLE_EVAL_PROP , RA_HANDLE_EVAL_SUMMARY , RA_HANDLE_FIND , RA_HANDLE_LIB , RA_HANDLE_MEAS , RA_HANDLE_PLUGIN , RA_HANDLE_PROC , RA_HANDLE_REC , RA_HANDLE_VIEW , RA_INFO_CLASS_END , RA_INFO_CLASS_START , RA_INFO_EVAL_END , RA_INFO_EVAL_START , RA_INFO_LIB_END , RA_INFO_LIB_START , RA_INFO_MEASUREMENT_START , RA_INFO_OBJECT_END , RA_INFO_PLUGIN_END , RA_INFO_PLUGIN_START , RA_INFO_PROCESSING_END , RA_INFO_PROCESSING_START , RA_INFO_PROP_END , RA_INFO_PROP_START , RA_INFO_RECORDING_END , RA_INFO_RECORDING_START , RA_INFO_SUM_END , and RA_INFO_SUM_START .
Referenced by ra_info_get() .
int copy_move_meas
(
meas_handle
mh ,
const char *
dest_dir ,
int
copy
)
Parameters:
<mh> measurement-handle
<dest_dir> destination directory
<copy> flag if a copy (!= 0) or a move (== 0) should be done
Function copy or move a measurement.
Definition at line 2719 of file ra.c .
References copy_move_file() , delete_file() , make_dir() , MAX_PATH_RA , RA_INFO_DIR_L , RA_INFO_FILES_CA , ra_info_get() , RA_INFO_PATH_C , ra_value_free() , ra_value_get_num_elem() , ra_value_get_string() , ra_value_get_string_array() , and ra_value_malloc() .
Referenced by ra_meas_copy() , and ra_meas_move() .
int find_config_file
(
char *
fn
)
Parameters:
<fn> contains path of config file if function ended successful
This function looks for the libRASCH configuration file. For the config file is first looked in the current directory. If there is none than it looks in '/etc'(Linux) resp. in the system directory (Win32). If not found, on Linux the $HOME directory is searched also.
Definition at line 346 of file ra.c .
References MAX_PATH_RA .
Referenced by read_config() .
int find_option
(
const char *
name ,
struct ra_option_infos *
infos ,
int
num_opt
)
Parameters:
<name> name of the option looked for
<infos> array of available options
<num_opt> number of the available options
Functions looks in the array 'infos' for the option named 'name'.
Definition at line 2395 of file ra.c .
Referenced by ra_lib_get_option() , and ra_lib_set_option() .
LIBRAAPI int get_endian_type
(
)
This function returns the endian type for the running system.
Definition at line 190 of file ra.c .
References ra_endian_type .
void get_error_text_ra
(
long
err ,
char *
text ,
int
len
)
Parameters:
<err> libRASCH error number
<text> array in which error-string will be set
<len> length of array 'text'
Function gets error-string for libRASCH error numbers.
Definition at line 521 of file ra.c .
References RA_WARNING .
Parameters:
<ra> handle to library instance
<id> info id
<vh> value-handle (will receive info)
Function returns informations about the library core.
Definition at line 1367 of file ra.c .
References _ra_set_error , meta_info::desc , get_meta_info() , meta_info::id , meta_info::name , RA_ERR_UNKNOWN_INFO , RA_INFO_LIB_END , RA_INFO_NUM_PLUGINS_L , RA_INFO_VERSION_C , ra_value_set_long() , ra_value_set_string_utf8() , and set_meta_info() .
Referenced by ra_info_get() .
Parameters:
<mh> handle to a measurement
<id> info id
<vh> value-handle (will receive info)
Function returns informations about a measurement.
Definition at line 1545 of file ra.c .
Referenced by ra_info_get() .
Parameters:
<options> pointer to an option struct
<opt_info> option looked for
<vh> value-handle (will receive option value)
<num_offset> offset where number of array elements is stored (only for array values needed)
Function returns the value for the option in 'vh'.
Definition at line 2422 of file ra.c .
References ra_option_infos::desc , ra_option_infos::name , ra_option_infos::offset , RA_INFO_NONE , ra_value_set_double() , ra_value_set_double_array() , ra_value_set_long() , ra_value_set_long_array() , ra_value_set_short() , ra_value_set_short_array() , ra_value_set_string_utf8() , RA_VALUE_TYPE_CHAR , RA_VALUE_TYPE_CHAR_ARRAY , RA_VALUE_TYPE_DOUBLE , RA_VALUE_TYPE_DOUBLE_ARRAY , RA_VALUE_TYPE_LONG , RA_VALUE_TYPE_LONG_ARRAY , RA_VALUE_TYPE_SHORT , RA_VALUE_TYPE_SHORT_ARRAY , set_meta_info() , and ra_option_infos::type .
Referenced by ra_lib_get_option() .
Parameters:
<pl> handle to plugin
<id> info id
<vh> value-handle (will receive info)
Function returns informations about library plugins.
Definition at line 1420 of file ra.c .
References _ra_set_error , plugin_infos::build_ts , meta_info::desc , plugin_infos::desc , plugin_infos::file , get_meta_info() , meta_info::id , plugin_struct::info , plugin_infos::license , plugin_infos::name , meta_info::name , plugin_infos::num_options , plugin_infos::num_results , ra_value::number , plugin_infos::opt , RA_ERR_UNKNOWN_INFO , RA_INFO_PL_OPT_NAME_C , RA_INFO_PL_OPT_TYPE_L , RA_INFO_PL_RES_DEFAULT_L , RA_INFO_PL_RES_NAME_C , RA_INFO_PLUGIN_END , ra_value_set_long() , ra_value_set_string_utf8() , plugin_infos::res , set_meta_info() , plugin_infos::type , plugin_infos::use_plugin , and plugin_infos::version .
Referenced by ra_info_get() .
Parameters:
<h> processing-handle or view-handle
<pl> plugin-handle
If the plugin pl provides a GUI-element, this function shows this GUI-element and transfer control to it. The h variable contains some information, needed by the plugin. For more information if a plugin provides a GUI-element and what type/information is needed, please see the plugin specific documentation.
Definition at line 2126 of file ra.c .
References _ra_set_error , plugin_struct::call_gui , RA_ERR_ERROR , and RA_ERR_PL_API_NOT_AVAIL .
Parameters:
<h> handle
<id> id of information wanted
<vh> value_handle receiving the info
Returns 0 if the wanted information was found and != 0 if not. The information will be in vh. For usage of the function please see user-manual.
Definition at line 1244 of file ra.c .
References _ra_set_error , plugin_struct::access , check_handle_type() , eval_get_info() , plugin_access_func::get_info_id , get_lib_info() , get_meas_general_info() , get_plugin_from_handle() , get_plugin_info() , get_proc_info() , get_session_info() , RA_ERR_PL_API_NOT_AVAIL , RA_HANDLE_LIB , RA_HANDLE_MEAS , RA_HANDLE_PLUGIN , RA_INFO_EVALUATION , RA_INFO_EVALUATION_END , RA_INFO_MEASUREMENT_END , RA_INFO_MEASUREMENT_START , RA_INFO_PROCESSING_END , RA_INFO_PROCESSING_START , RA_INFO_SESSION_END , RA_INFO_SESSION_START , and ra_value_reset() .
Referenced by calc_x_scales() , copy_move_meas() , get_eval_file() , get_eval_file_xml() , ra_info_get_by_name() , ra_meas_delete() , ra_meas_move() , and write_evals_xml() .
Parameters:
<h> handle
<vh> value_handle with the info
Not implemented !!!
Definition at line 1783 of file ra.c .
References _ra_set_error , plugin_struct::access , meta_info::desc , get_meta_info() , get_plugin_from_handle() , ra_value::id , meta_info::id , meta_info::name , RA_ERR_PL_API_NOT_AVAIL , RA_ERR_UNKNOWN_INFO , plugin_access_func::set_info , and set_meta_info() .
LIBRAAPI long ra_lib_get_error
(
ra_handle
h ,
char *
text ,
int
len
)
Parameters:
<h> handle to ra instance
<text> character buffer which receives error text
<len> size of character buffer text
This function returns the last error occured in libRASCH (or in one of the plugins). See 'ra_error.h' for meaning of returned number. If the number is negative, the last error was an OS specific error and the error number comes from the OS (just remove the minus sign). If text is not NULL, a short error description will be returned in text.
Definition at line 423 of file ra.c .
References librasch::error_from , librasch::error_number , get_error_text() , and utf8_to_local_inplace() .
Referenced by _ra_set_error_int() .
Parameters:
<h> return option from this object
<opt_name> name of the option
<vh> after function-call, contains option value
The function tries to return the option opt_name from the object h. At the moment only options for process-plugins (h needs to be a process-handle) are supported.
Definition at line 2327 of file ra.c .
References _ra_set_error , find_option() , get_option() , plugin_struct::info , local_to_utf8() , ra_option_infos::num_offset , plugin_infos::num_options , ra_option_infos::offset , plugin_infos::opt , proc_info::options , proc_info::plugin , RA_ERR_ERROR , RA_ERR_OPTION_NO_OFFSET , RA_ERR_OPTION_UNKNOWN , RA_ERR_UNSUPPORTED , RA_HANDLE_PROC , and ra_value_reset() .
Parameters:
Returns handle of libRASCH instance from any handle.
Definition at line 639 of file ra.c .
References ra_meas::ra , RA_HANDLE_EVAL , RA_HANDLE_EVAL_CLASS , RA_HANDLE_EVAL_PROP , RA_HANDLE_EVAL_SUMMARY , RA_HANDLE_FIND , RA_HANDLE_LIB , RA_HANDLE_MEAS , RA_HANDLE_PLUGIN , RA_HANDLE_PROC , RA_HANDLE_REC , RA_HANDLE_VIEW , and ra_meas_handle_from_any_handle() .
Referenced by _ra_set_error_int() , post_process_ecg() , and ra_meas_move() .
Init libRASCH, read config-file and init plugins; returns ra_handle.
Definition at line 71 of file ra.c .
References _ra_set_error , close_plugins() , get_plugin_by_name() , init_i18n() , RA_ERR_LOAD_PLUGINS , RA_ERR_NONE , RA_ERR_READ_CONFIG , RA_HANDLE_LIB , ra_in_error , ra_print_debug_infos , RA_WARN_NO_CONFIG_FILE , read_config() , read_plugins() , and set_endian_type() .
Parameters:
<h> option will be set in this object
<opt_name> name of the option
<vh> option value
The function set the option opt_name in object h. At the moment only options for process-plugins (h needs to be a process-handle) are supported.
Definition at line 2478 of file ra.c .
References _ra_set_error , find_option() , plugin_struct::info , local_to_utf8() , ra_option_infos::num_offset , plugin_infos::num_options , ra_option_infos::offset , plugin_infos::opt , proc_info::options , proc_info::plugin , RA_ERR_ERROR , RA_ERR_OPTION_NO_OFFSET , RA_ERR_OPTION_UNKNOWN , RA_ERR_UNSUPPORTED , RA_HANDLE_PROC , and set_option() .
Referenced by post_process_ecg() .
LIBRAAPI int ra_lib_use_plugin
(
ra_handle
h ,
int
plugin_index ,
int
use_it
)
Parameters:
<mh> handle to measurement
Close a measurement.
Definition at line 1203 of file ra.c .
References plugin_struct::access , plugin_access_func::close_meas , ra_meas::eval , free_eval_infos() , free_session_rec() , ra_meas::num_sessions , ra_meas::p , ra_free_mem , ra_session::root_rec , ra_meas::sessions , and ra_meas::x_scale .
Referenced by ra_meas_delete() , and ra_meas_move() .
LIBRAAPI int ra_meas_copy
(
meas_handle
mh ,
const char *
dest_dir
)
Parameters:
<mh> handle of measurement which should be copied
<dest_dir> destination directory
The function copy the files of measurement mh to directory dest_dir.
IMPORTANT!!! Function _not_ completely tested. Use at your own risk.
Definition at line 2642 of file ra.c .
References copy_move_meas() , local_to_utf8() , and MAX_PATH_RA .
Parameters:
<mh> handle of measurement which should be deleted
The function deletes the files of measurement mh. The measurement mh will be closed after the deletion. Therefore mh is no longer a valid measurement-handle.
IMPORTANT!!! Function _not_ completely tested. Use at your own risk.
Definition at line 2818 of file ra.c .
References delete_file() , MAX_PATH_RA , RA_INFO_DIR_L , RA_INFO_FILES_CA , ra_info_get() , RA_INFO_PATH_C , ra_meas_close() , ra_value_free() , ra_value_get_long() , ra_value_get_num_elem() , ra_value_get_string() , ra_value_get_string_array() , and ra_value_malloc() .
Parameters:
<h> handle to libRASCH
<dir> directory which should be scanned for measurements
<rfs> pointer to ra_find_struct which will held the infos for the found measurement.
Search for libRASCH-handled measurements in dir. If at least on measurement was found a valid (!NULL) ra_find_handle will be returned and the infos about the measurement is in mfs.
Definition at line 865 of file ra.c .
References plugin_struct::access , find_meas::curr , plugin_access_func::find_meas , find_meas::handle_id , plugin_struct::info , local_to_utf8() , MAX_PATH_RA , ra_find_struct::name , find_meas::names , plugin_struct::next , find_meas::num , RA_HANDLE_FIND , plugin_infos::use_plugin , and utf8_to_local_inplace() .