/** * Returns Analog Pin value in volts to SCPI context * @param context SCPI context * @return success or failure */ scpi_result_t RP_AnalogPinValueQ(scpi_t * context) { int32_t choice; /* Read first parameter - APIN */ if (!SCPI_ParamChoice(context, scpi_RpApin, &choice, true)) { RP_LOG(LOG_ERR, "*ANALOG:PIN? is missing first parameter.\n"); return SCPI_RES_ERR; } // Convert port into pin id rp_apin_t pin = choice; // Now get the pin value float value; int result = rp_ApinGetValue(pin, &value); if (RP_OK != result){ RP_LOG(LOG_ERR, "*ANALOG:PIN? Failed to get pin value: %s\n", rp_GetError(result)); return SCPI_RES_ERR; } // Return back result SCPI_ResultDouble(context, value); RP_LOG(LOG_INFO, "*ANALOG:PIN? Successfully returned port value.\n"); return SCPI_RES_OK; }
/** * Sets Analog Pin value in volts * @param context SCPI context * @return success or failure */ scpi_result_t RP_AnalogPinValue(scpi_t * context) { int32_t choice; double value; /* Read first parameter - APIN */ if (!SCPI_ParamChoice(context, scpi_RpApin, &choice, true)) { RP_LOG(LOG_ERR, "*ANALOG:PIN is missing first parameter.\n"); return SCPI_RES_ERR; } /* Read second parameter - VALUE */ if (!SCPI_ParamDouble(context, &value, true)) { RP_LOG(LOG_ERR, "*ANALOG:PIN is missing second parameter.\n"); return SCPI_RES_ERR; } // Convert port into pin id rp_apin_t pin = choice; /* Set pin value */ int result = rp_ApinSetValue(pin, (float) value); if (RP_OK != result){ RP_LOG(LOG_ERR, "*ANALOG:PIN Failed to set pin value: %s\n", rp_GetError(result)); return SCPI_RES_ERR; } RP_LOG(LOG_INFO, "*ANALOG:PIN Successfully set port value.\n"); return SCPI_RES_OK; }
static scpi_result_t get_source_value(scpi_t * context, float value, float min, float max, float def) { int32_t spec; if (!SCPI_ParamChoice(context, scpi_special_numbers_def, &spec, false)) { if (SCPI_ParamErrorOccurred(context)) { return SCPI_RES_ERR; } } else { if (spec == SCPI_NUM_MIN) { value = min; } else if (spec == SCPI_NUM_MAX) { value = max; } else if (spec == SCPI_NUM_DEF) { value = def; } else { SCPI_ErrorPush(context, SCPI_ERROR_ILLEGAL_PARAMETER_VALUE); return SCPI_RES_ERR; } } return result_float(context, value); }
scpi_result_t SCPIMM_trigger_source(scpi_t* context) { static const scpimm_trig_src_t values[] = {SCPIMM_TRIG_BUS, SCPIMM_TRIG_IMM, SCPIMM_TRIG_EXT}; int32_t choice; if (!SCPI_ParamChoice(context, options, &choice, TRUE)) { return SCPI_RES_ERR; } SCPIMM_CONTEXT(context)->trigger_src = values[choice]; return SCPI_RES_OK; }
scpi_result_t scpi_syst_TempProtectionLevelQ(scpi_t * context) { int32_t sensor; if (!SCPI_ParamChoice(context, main_temp_sensor_choice, &sensor, false)) { if (SCPI_ParamErrorOccurred(context)) { return SCPI_RES_ERR; } sensor = temp_sensor::MAIN; } return result_float(context, temperature::prot_conf[sensor].level); }
scpi_result_t scpi_syst_TempProtectionTrippedQ(scpi_t * context) { int32_t sensor; if (!SCPI_ParamChoice(context, main_temp_sensor_choice, &sensor, false)) { if (SCPI_ParamErrorOccurred(context)) { return SCPI_RES_ERR; } sensor = temp_sensor::MAIN; } SCPI_ResultBool(context, temperature::isSensorTripped((temp_sensor::Type)sensor)); return SCPI_RES_OK; }
scpi_result_t scpi_syst_TempProtectionStateQ(scpi_t * context) { int32_t sensor; if (!SCPI_ParamChoice(context, main_temp_sensor_choice, &sensor, false)) { if (SCPI_ParamErrorOccurred(context)) { return SCPI_RES_ERR; } sensor = temp_sensor::MAIN; } SCPI_ResultBool(context, temperature::prot_conf[sensor].state); return SCPI_RES_OK; }
scpi_result_t scpi_syst_TempProtectionClear(scpi_t * context) { int32_t sensor; if (!SCPI_ParamChoice(context, main_temp_sensor_choice, &sensor, false)) { if (SCPI_ParamErrorOccurred(context)) { return SCPI_RES_ERR; } sensor = temp_sensor::MAIN; } temperature::clearProtection((temp_sensor::Type)sensor); return SCPI_RES_OK; }
scpi_result_t TEST_ChoiceQ(scpi_t * context) { int32_t param; if (!SCPI_ParamChoice(context, trigger_source, ¶m, true)) { return SCPI_RES_ERR; } fprintf(stderr, "\tP1=%s (%d)\r\n", trigger_source[param], param); SCPI_ResultInt(context, param); return SCPI_RES_OK; }
scpi_result_t scpi_meas_TemperatureQ(scpi_t * context) { int32_t sensor; if (!SCPI_ParamChoice(context, all_temp_sensor_choice, &sensor, FALSE)) { if (SCPI_ParamErrorOccurred(context)) { return SCPI_RES_ERR; } sensor = temp_sensor::MAIN; } char buffer[256] = { 0 }; util::strcatFloat(buffer, temperature::measure((temp_sensor::Type)sensor)); SCPI_ResultCharacters(context, buffer, strlen(buffer)); return SCPI_RES_OK; }
static scpi_result_t TEST_ChoiceQ(scpi_t * context) { int32_t param; const char * name; if (!SCPI_ParamChoice(context, trigger_source, ¶m, TRUE)) { return SCPI_RES_ERR; } SCPI_ChoiceToName(trigger_source, param, &name); printf( "\tP1=%s (%ld)\r\n", name, (long int)param); SCPI_ResultInt(context, param); return SCPI_RES_OK; }
scpi_result_t scpi_syst_TempProtectionDelay(scpi_t * context) { float delay; if (!get_duration_param(context, delay, OTP_MAIN_MIN_DELAY, OTP_MAIN_MAX_DELAY, OTP_MAIN_DEFAULT_DELAY)) { return SCPI_RES_ERR; } int32_t sensor; if (!SCPI_ParamChoice(context, main_temp_sensor_choice, &sensor, false)) { if (SCPI_ParamErrorOccurred(context)) { return SCPI_RES_ERR; } sensor = temp_sensor::MAIN; } temperature::prot_conf[sensor].delay = delay; profile::save(); return SCPI_RES_OK; }
scpi_result_t scpi_syst_TempProtectionState(scpi_t * context) { bool state; if (!SCPI_ParamBool(context, &state, TRUE)) { return SCPI_RES_ERR; } int32_t sensor; if (!SCPI_ParamChoice(context, main_temp_sensor_choice, &sensor, false)) { if (SCPI_ParamErrorOccurred(context)) { return SCPI_RES_ERR; } sensor = temp_sensor::MAIN; } temperature::prot_conf[sensor].state = state; profile::save(); return SCPI_RES_OK; }
scpi_result_t scpi_syst_TempProtectionLevel(scpi_t * context) { float level; if (!get_temperature_param(context, level, OTP_MAIN_MIN_LEVEL, OTP_MAIN_MAX_LEVEL, OTP_MAIN_DEFAULT_LEVEL)) { return SCPI_RES_ERR; } int32_t sensor; if (!SCPI_ParamChoice(context, main_temp_sensor_choice, &sensor, false)) { if (SCPI_ParamErrorOccurred(context)) { return SCPI_RES_ERR; } sensor = temp_sensor::MAIN; } temperature::prot_conf[sensor].level = level; profile::save(); return SCPI_RES_OK; }