visca_cli.c

来自「visca lib, for camera control」· C语言 代码 · 共 2,398 行 · 第 1/5 页

C
2,398
字号
  char *command;  char *arg1;  char *arg2;  char *arg3;  char *arg4;  char *arg5;  int intarg1=0;  int intarg2=0;  int intarg3=0;  int intarg4=0;  int intarg5=0;  int boolarg;  VISCATitleData_t *temptitle;    /*Variables that hold return values from VISCA routines*/  UInt8_t value8, value8b, value8c;  UInt16_t value16;    /*tokenize the commandline*/  command = strtok(commandline, " ");  arg1 = strtok(NULL, " ");  arg2 = strtok(NULL, " ");  arg3 = strtok(NULL, " ");  arg4 = strtok(NULL, " ");  arg5 = strtok(NULL, " ");    /*Try to convert the arguments to integers*/  if (arg1 != NULL) {    intarg1 = atoi(arg1);  }  if (arg2 != NULL) {    intarg2 = atoi(arg2);  }  if (arg3 != NULL) {    intarg3 = atoi(arg3);  }  if (arg4 != NULL) {    intarg4 = atoi(arg4);  }  if (arg5 != NULL) {    intarg5 = atoi(arg5);  }    /*Try to find a boolean value*/  if ((arg1 != NULL) && (strcmp(arg1, "true") == 0)) {    boolarg = 2;  } else if ((arg1 != NULL) && (strcmp(arg1, "false") == 0)) {    boolarg = 3;  } else if ((arg1 != NULL) && (strcmp(arg1, "1") == 0)) {    boolarg = 2;  } else if ((arg1 != NULL) && (strcmp(arg1, "0") == 0)) {    boolarg = 3;  } else {    boolarg = -1;  }  #if DEBUG  fprintf(stderr, "command: %s\n", command);  fprintf(stderr, "arg1: %s\narg2: %s\narg3: %s\narg4: %s\narg5: %s\n",           arg1, arg2, arg3, arg4, arg5);  fprintf(stderr,           "intarg1: %i\nintarg2: %i\nintarg3: %i\nintarg4:%i\nintarg5:%i\n",           intarg1, intarg2, intarg3, intarg4, intarg5);  fprintf(stderr, "boolarg: %i\n", boolarg);#endif  if (strcmp(command, "set_zoom_tele") == 0) {    if (VISCA_set_zoom_tele(&interface, &camera)!=VISCA_SUCCESS) {      return 46;    }    return 10;  }  if (strcmp(command, "set_zoom_wide") == 0) {    if (VISCA_set_zoom_wide(&interface, &camera)!=VISCA_SUCCESS) {      return 46;    }    return 10;  }  if (strcmp(command, "set_zoom_stop") == 0) {    if (VISCA_set_zoom_stop(&interface, &camera)!=VISCA_SUCCESS) {      return 46;    }    return 10;  }  if (strcmp(command, "set_focus_far") == 0) {    if (VISCA_set_focus_far(&interface, &camera)!=VISCA_SUCCESS) {      return 46;    }    return 10;  }  if (strcmp(command, "set_focus_near") == 0) {    if (VISCA_set_focus_near(&interface, &camera)!=VISCA_SUCCESS) {      return 46;    }    return 10;  }  if (strcmp(command, "set_focus_stop") == 0) {    if (VISCA_set_focus_stop(&interface, &camera)!=VISCA_SUCCESS) {      return 46;    }    return 10;  }#if !D30ONLY  if (strcmp(command, "set_focus_one_push") == 0) {    if (VISCA_set_focus_one_push(&interface, &camera)!=VISCA_SUCCESS) {      return 46;    }    return 10;  }#endif#if !D30ONLY  if (strcmp(command, "set_focus_infinity") == 0) {    if (VISCA_set_focus_infinity(&interface, &camera)!=VISCA_SUCCESS) {      return 46;    }    return 10;  }#endif#if !D30ONLY  if (strcmp(command, "set_focus_autosense_high") == 0) {    if (VISCA_set_focus_autosense_high(&interface, &camera)!=VISCA_SUCCESS) {      return 46;    }    return 10;  }#endif#if !D30ONLY  if (strcmp(command, "set_focus_autosense_low") == 0) {    if (VISCA_set_focus_autosense_low(&interface, &camera)!=VISCA_SUCCESS) {      return 46;    }    return 10;  }#endif  if (strcmp(command, "set_whitebal_one_push") == 0) {    if (VISCA_set_whitebal_one_push(&interface, &camera)!=VISCA_SUCCESS) {      return 46;    }    return 10;  }#if !D30ONLY  if (strcmp(command, "set_rgain_up") == 0) {    if (VISCA_set_rgain_up(&interface, &camera)!=VISCA_SUCCESS) {      return 46;    }    return 10;  }#endif#if !D30ONLY  if (strcmp(command, "set_rgain_down") == 0) {    if (VISCA_set_rgain_down(&interface, &camera)!=VISCA_SUCCESS) {      return 46;    }    return 10;  }#endif#if !D30ONLY  if (strcmp(command, "set_rgain_reset") == 0) {    if (VISCA_set_rgain_reset(&interface, &camera)!=VISCA_SUCCESS) {      return 46;    }    return 10;  }#endif#if !D30ONLY  if (strcmp(command, "set_bgain_up") == 0) {    if (VISCA_set_bgain_up(&interface, &camera)!=VISCA_SUCCESS) {      return 46;    }    return 10;  }#endif#if !D30ONLY  if (strcmp(command, "set_bgain_down") == 0) {    if (VISCA_set_bgain_down(&interface, &camera)!=VISCA_SUCCESS) {      return 46;    }    return 10;  }#endif#if !D30ONLY  if (strcmp(command, "set_bgain_reset") == 0) {    if (VISCA_set_bgain_reset(&interface, &camera)!=VISCA_SUCCESS) {      return 46;    }    return 10;  }#endif  if (strcmp(command, "set_shutter_up") == 0) {    if (VISCA_set_shutter_up(&interface, &camera)!=VISCA_SUCCESS) {      return 46;    }    return 10;  }  if (strcmp(command, "set_shutter_down") == 0) {    if (VISCA_set_shutter_down(&interface, &camera)!=VISCA_SUCCESS) {      return 46;    }    return 10;  }  if (strcmp(command, "set_shutter_reset") == 0) {    if (VISCA_set_shutter_reset(&interface, &camera)!=VISCA_SUCCESS) {      return 46;    }    return 10;  }  if (strcmp(command, "set_iris_up") == 0) {    if (VISCA_set_iris_up(&interface, &camera)!=VISCA_SUCCESS) {      return 46;    }    return 10;  }  if (strcmp(command, "set_iris_down") == 0) {    if (VISCA_set_iris_down(&interface, &camera)!=VISCA_SUCCESS) {      return 46;    }    return 10;  }  if (strcmp(command, "set_iris_reset") == 0) {    if (VISCA_set_iris_reset(&interface, &camera)!=VISCA_SUCCESS) {      return 46;    }    return 10;  }  if (strcmp(command, "set_gain_up") == 0) {    if (VISCA_set_gain_up(&interface, &camera)!=VISCA_SUCCESS) {      return 46;    }    return 10;  }  if (strcmp(command, "set_gain_down") == 0) {    if (VISCA_set_gain_down(&interface, &camera)!=VISCA_SUCCESS) {      return 46;    }    return 10;  }  if (strcmp(command, "set_gain_reset") == 0) {    if (VISCA_set_gain_reset(&interface, &camera)!=VISCA_SUCCESS) {      return 46;    }    return 10;  }  if (strcmp(command, "set_bright_up") == 0) {    if (VISCA_set_bright_up(&interface, &camera)!=VISCA_SUCCESS) {      return 46;    }    return 10;  }  if (strcmp(command, "set_bright_down") == 0) {    if (VISCA_set_bright_down(&interface, &camera)!=VISCA_SUCCESS) {      return 46;    }    return 10;  }  if (strcmp(command, "set_bright_reset") == 0) {    if (VISCA_set_bright_reset(&interface, &camera)!=VISCA_SUCCESS) {      return 46;    }    return 10;  }#if !D30ONLY  if (strcmp(command, "set_aperture_up") == 0) {    if (VISCA_set_aperture_up(&interface, &camera)!=VISCA_SUCCESS) {      return 46;    }    return 10;  }#endif#if !D30ONLY  if (strcmp(command, "set_aperture_down") == 0) {    if (VISCA_set_aperture_down(&interface, &camera)!=VISCA_SUCCESS) {      return 46;    }    return 10;  }#endif#if !D30ONLY  if (strcmp(command, "set_aperture_reset") == 0) {    if (VISCA_set_aperture_reset(&interface, &camera)!=VISCA_SUCCESS) {      return 46;    }    return 10;  }#endif#if !D30ONLY  if (strcmp(command, "set_exp_comp_up") == 0) {    if (VISCA_set_exp_comp_up(&interface, &camera)!=VISCA_SUCCESS) {      return 46;    }    return 10;  }#endif#if !D30ONLY  if (strcmp(command, "set_exp_comp_down") == 0) {    if (VISCA_set_exp_comp_down(&interface, &camera)!=VISCA_SUCCESS) {      return 46;    }    return 10;  }#endif#if !D30ONLY  if (strcmp(command, "set_exp_comp_reset") == 0) {    if (VISCA_set_exp_comp_reset(&interface, &camera)!=VISCA_SUCCESS) {      return 46;    }    return 10;  }#endif#if !D30ONLY  if (strcmp(command, "set_title_clear") == 0) {    if (VISCA_set_title_clear(&interface, &camera)!=VISCA_SUCCESS) {      return 46;    }    return 10;  }#endif  if (strcmp(command, "set_irreceive_on") == 0) {    if (VISCA_set_irreceive_on(&interface, &camera)!=VISCA_SUCCESS) {      return 46;    }    return 10;  }  if (strcmp(command, "set_irreceive_off") == 0) {    if (VISCA_set_irreceive_off(&interface, &camera)!=VISCA_SUCCESS) {      return 46;    }    return 10;  }  if (strcmp(command, "set_irreceive_onoff") == 0) {    if (VISCA_set_irreceive_onoff(&interface, &camera)!=VISCA_SUCCESS) {      return 46;    }    return 10;  }  if (strcmp(command, "set_pantilt_home") == 0) {    if (VISCA_set_pantilt_home(&interface, &camera)!=VISCA_SUCCESS) {      return 46;    }    return 10;  }  if (strcmp(command, "set_pantilt_reset") == 0) {    if (VISCA_set_pantilt_reset(&interface, &camera)!=VISCA_SUCCESS) {      return 46;    }    return 10;  }  if (strcmp(command, "set_pantilt_limit_downleft_clear") == 0) {    if (VISCA_set_pantilt_limit_downleft_clear(&interface, &camera)        != VISCA_SUCCESS) {      return 46;    }    return 10;  }  if (strcmp(command, "set_pantilt_limit_upright_clear") == 0) {    if (VISCA_set_pantilt_limit_upright_clear(&interface, &camera)        != VISCA_SUCCESS) {      return 46;    }    return 10;  }  if (strcmp(command, "set_datascreen_on") == 0) {    if (VISCA_set_datascreen_on(&interface, &camera)!=VISCA_SUCCESS) {      return 46;    }    return 10;  }  if (strcmp(command, "set_datascreen_off") == 0) {    if (VISCA_set_datascreen_off(&interface, &camera)!=VISCA_SUCCESS) {      return 46;    }    return 10;  }    if (strcmp(command, "set_datascreen_onoff") == 0) {    if (VISCA_set_datascreen_onoff(&interface, &camera)!=VISCA_SUCCESS) {      return 46;    }    return 10;  }    if (strcmp(command, "set_power") == 0) {    if ((arg1 == NULL) || (boolarg == -1)) {      return 41;    }    if (VISCA_set_power(&interface, &camera, boolarg)!=VISCA_SUCCESS) {      return 46;    }    return 10;  }    if (strcmp(command, "set_keylock") == 0) {    if ((arg1 == NULL) || (boolarg == -1)) {      return 41;    }    if (boolarg == 03) {      boolarg = 0;    }    if (VISCA_set_keylock (&interface, &camera, boolarg)!=VISCA_SUCCESS) {      return 46;    }    return 10;  }#if !D30ONLY  if (strcmp(command, "set_dzoom") == 0) {    if ((arg1 == NULL) || (boolarg == -1)) {      return 41;    }    if (VISCA_set_dzoom (&interface, &camera, boolarg)!=VISCA_SUCCESS) {      return 46;    }    return 10;  }#endif  if (strcmp(command, "set_focus_auto") == 0) {    if ((arg1 == NULL) || (boolarg == -1)) {      return 41;    }    if (VISCA_set_focus_auto (&interface, &camera, boolarg)!=VISCA_SUCCESS) {      return 46;    }    return 10;  }#if !D30ONLY  if (strcmp(command, "set_exp_comp_power") == 0) {    if ((arg1 == NULL) || (boolarg == -1)) {      return 41;    }    if (VISCA_set_exp_comp_power (&interface, &camera, boolarg)        != VISCA_SUCCESS) {      return 46;    }    return 10;  }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?