📄 scope_files.c
字号:
case HAL_S32: data_value = dptr->d_s32; break; case HAL_U32: data_value = dptr->d_u32; break; default: data_value = 0.0; break; } /*actually write the data to disk */ /* this should look something like CHAN1 1.234 */ fprintf(fp, "%s %f ", label, data_value );}/************************************************************************ LOCAL FUNCTION CODE *************************************************************************/static int parse_command(char *in){ int n; char *cp1, *cp2, *rv; int arg_int; double arg_float; char *arg_string; n = -1; do { cp1 = in; cp2 = cmd_lut[++n].name; /* skip all matching chars */ while (( *cp2 != '\0') && (tolower(*cp1) == *cp2 )) { cp1++; cp2++; } } while ( *cp2 != '\0' ); /* either a match, or zero length name (last entry) */ if ( cp1 == in ) { /* zero length name, last entry, no match */ if ( *in != '#' ) { /* not a comment, must be a mistake */ fprintf (stderr, "halscope: unknown config command: '%s'\n", in ); return -1; } } switch ( cmd_lut[n].arg_type ) { case STRING: while ( isspace(*cp1) ) { cp1++; } arg_string = cp1; /* find and replace newline at end */ while (( *cp1 != '\n' ) && ( *cp1 != '\0' )) { cp1++; } *cp1 = '\0'; /* call command handler, it returns NULL on success, or an error message on failure */ rv = cmd_lut[n].handler(arg_string); break; case FLOAT: arg_float = strtod(cp1, &cp1); rv = cmd_lut[n].handler(&arg_float); break; case INT: arg_int = strtol(cp1, &cp1, 10); rv = cmd_lut[n].handler(&arg_int); break; default: return -1; break; } /* commands return NULL on success, an error msg on fail */ if ( rv != NULL ) { fprintf(stderr, "halscope: %s: '%s'\n", rv, in ); return -1; } return 0;} static char *dummy_cmd(void * arg){ return "command not implemented";}static char *thread_cmd(void * arg){ char *name; int rv; name = (char *)(arg); rv = set_sample_thread(name); if ( rv < 0 ) { return "could not find thread"; } return NULL;}static char *maxchan_cmd(void * arg){ int *argp, rv; argp = (int *)(arg); rv = set_rec_len(*argp); if ( rv < 0 ) { return "could not set record length"; } return NULL;}static char *hzoom_cmd(void * arg){ int *argp, rv; argp = (int *)(arg); rv = set_horiz_zoom(*argp); if ( rv < 0 ) { return "could not set horizontal zoom"; } return NULL;} static char *hpos_cmd(void * arg){ double *argp; int rv; argp = (double *)(arg); rv = set_horiz_pos(*argp); if ( rv < 0 ) { return "could not set horizontal position"; } return NULL;} static char *hmult_cmd(void * arg){ int *argp, rv; argp = (int *)(arg); rv = set_horiz_mult(*argp); if ( rv < 0 ) { return "could not set horizontal multiplier"; } return NULL;}static char *chan_cmd(void * arg){ int *argp, chan_num, rv; argp = (int *)(arg); chan_num = *argp; deferred_channel = 0; rv = set_active_channel(chan_num); switch (rv) { case 0: // successfull return return NULL; case -1: return "illegal channel number"; case -2: return "too many active channels"; case -3: // no source for channel, OK as long as we get // a subsequent command that specifies a source deferred_channel = chan_num; return NULL; default: return "unknown result"; }} static char *choff_cmd(void * arg){ int chan_num; if ( deferred_channel != 0 ) { deferred_channel = 0; return NULL; } chan_num = ctrl_usr->vert.selected; set_channel_off(chan_num); return NULL;} static char *chan_src_cmd(int src_type, char *src_name){ int chan_num, rv; if ( deferred_channel == 0 ) { // changing currently active channel chan_num = ctrl_usr->vert.selected; rv = set_channel_source(chan_num, src_type, src_name); } else { // setting source for previously empty channel chan_num = deferred_channel; rv = set_channel_source(chan_num, src_type, src_name); if ( rv == 0 ) { // got a source now, select the channel return chan_cmd(&chan_num); } } if ( rv < 0 ) { return "object not found"; } return NULL;}static char *pin_cmd(void * arg){ return chan_src_cmd(0, (char *)(arg));}static char *sig_cmd(void * arg){ return chan_src_cmd(1, (char *)(arg));}static char *param_cmd(void * arg){ return chan_src_cmd(2, (char *)(arg));}static char *vscale_cmd(void * arg){ int *argp, rv; argp = (int *)(arg); rv = set_vert_scale(*argp); if ( rv < 0 ) { return "could not set vertical scale"; } return NULL;} static char *vpos_cmd(void * arg){ double *argp; int rv; argp = (double *)(arg); rv = set_vert_pos(*argp); if ( rv < 0 ) { return "could not set vertical position"; } return NULL;} static char *voff_cmd(void * arg){ double *argp; int rv; argp = (double *)(arg); rv = set_vert_offset(*argp); if ( rv < 0 ) { return "could not set vertical offset"; } return NULL;} static char *tsource_cmd(void * arg){ int *argp, rv; argp = (int *)(arg); rv = set_trigger_source(*argp); if ( rv < 0 ) { return "could not set trigger source"; } return NULL;}static char *tlevel_cmd(void * arg){ double *argp; int rv; argp = (double *)(arg); rv = set_trigger_level(*argp); if ( rv < 0 ) { return "could not set trigger level"; } return NULL;} static char *tpos_cmd(void * arg){ double *argp; int rv; argp = (double *)(arg); rv = set_trigger_pos(*argp); if ( rv < 0 ) { return "could not set trigger position"; } return NULL;} static char *tpolar_cmd(void * arg){ int *argp; int rv; argp = (int *)(arg); rv = set_trigger_polarity(*argp); if ( rv < 0 ) { return "could not set trigger polarity"; } return NULL;} static char *tmode_cmd(void * arg){ int *argp; int rv; argp = (int *)(arg); rv = set_trigger_mode(*argp); if ( rv < 0 ) { return "could not set trigger mode"; } return NULL;} static char *rmode_cmd(void * arg){ int *argp; int rv; argp = (int *)(arg); rv = set_run_mode(*argp); if ( rv < 0 ) { return "could not set run mode"; } return NULL;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -