00001 /* 00002 * DBSETUP.C 00003 * 00004 * GUI data base setup script. 00005 * Should be run once for every data base (data set) used in 00006 * the processing. 00007 * Initializes the data base, defines the default X axis variable for 00008 * X-Y plots and initializes these variables. 00009 * Takes the number of samples, sampling frequency and time/frequency 00010 * domain flag parameters form the context. 00011 * No input/output data propagation. 00012 * Deactivates itself after first run 00013 */ 00014 #include "scripts.h" 00015 00016 void dbsetup_script(void) 00017 { 00018 mgk_data_type type; 00019 dbsetup_script_context *cxt = mgk_node_context(mgk_current_node(),&type); 00020 if(cxt && (type & T_BUFFER)) { 00021 int i; 00022 int size = cxt->IsFrequency ? 00023 cxt->Size / 2 : 00024 cxt->Size; 00025 char *xname = cxt->IsFrequency ? 00026 "Frequency" : 00027 "Time"; 00028 double step = cxt->IsFrequency ? 00029 cxt->SampRate / cxt->Size : 00030 1.0 / cxt->SampRate; 00031 float *data = mgk_allocate_buffer((sizeof(float) * size),FALSE); 00032 for(i = 0; i < size; i++) { 00033 data[i] = (float)i * (float)step; 00034 } 00035 gui_setup_database(cxt->Name,xname); 00036 gui_clear_database(cxt->Name); 00037 gui_append_data(xname, cxt->Name, data, size); 00038 } 00039 mgk_set_node_priority(mgk_current_node(),0); 00040 } 00041