00001 /* 00002 * PLOTTER.C 00003 * 00004 * Data plotter script. 00005 * It just enters its input data into the data base of the GUI toolkit. 00006 * The actual plot updades will be done under the control of the GUI event 00007 * loop. 00008 * The script requires a preset character string context which contains the 00009 * (space separated) names for the GUI variable and data set. 00010 */ 00011 #include "scripts.h" 00012 00013 void plotter_script(void) 00014 { 00015 char varname[100]; 00016 mgk_data_type type; 00017 plotter_script_context *cxt = mgk_node_context(mgk_current_node(),&type); 00018 printf("plot\n"); 00019 fflush(stdout); 00020 if(cxt && (type & T_BUFFER)) { 00021 int size; 00022 float *data = mgk_receive(0,&type); 00023 if((data) && 00024 (type == (T_FLOAT | T_BUFFER)) && 00025 ((size = mgk_buffer_size(data) / sizeof(float)) > 0)) { 00026 sprintf(varname,"Chan%02d",cxt->Channel); 00027 gui_clear_data(varname,cxt->DBase); 00028 gui_append_data(varname,cxt->DBase,data,size); 00029 } 00030 } 00031 } 00032