Exemple #1
0
static scpi_result_t DMM_MeasureVoltageAcQ(scpi_t * context) {
    scpi_number_t param1, param2;
    char bf[15];
    // read first parameter if present
    if (!SCPI_ParamNumber(context, scpi_special_numbers_def, &param1, FALSE)) {
        // do something, if parameter not present
    }

    // read second paraeter if present
    if (!SCPI_ParamNumber(context, scpi_special_numbers_def, &param2, FALSE)) {
        // do something, if parameter not present
    }

    
    SCPI_NumberToStr(context, scpi_special_numbers_def, &param1, bf, 15);
    printf( "\tP1=%s\r\n", bf);

    
    SCPI_NumberToStr(context, scpi_special_numbers_def, &param2, bf, 15);
    printf( "\tP2=%s\r\n", bf);

    SCPI_ResultDouble(context, 0);
    
    return SCPI_RES_OK;
}
Exemple #2
0
static scpi_result_t DMM_MeasureVoltageAcQ(scpi_t * context) {
    scpi_number_t param1, param2;
    char bf[15];
    fprintf(stderr, "meas:volt:ac\r\n"); /* debug command name */

    /* read first parameter if present */
    if (!SCPI_ParamNumber(context, scpi_special_numbers_def, &param1, FALSE)) {
        /* do something, if parameter not present */
    }

    /* read second paraeter if present */
    if (!SCPI_ParamNumber(context, scpi_special_numbers_def, &param2, FALSE)) {
        /* do something, if parameter not present */
    }


    SCPI_NumberToStr(context, scpi_special_numbers_def, &param1, bf, 15);
    fprintf(stderr, "\tP1=%s\r\n", bf);


    SCPI_NumberToStr(context, scpi_special_numbers_def, &param2, bf, 15);
    fprintf(stderr, "\tP2=%s\r\n", bf);

    SCPI_ResultDouble(context, 0);

    return SCPI_RES_OK;
}
Exemple #3
0
scpi_result_t DMM_MeasureVoltageAcQ(scpi_t * context) {
    scpi_number_t param1, param2;
    char bf[15];
    fprintf(stderr, "meas:volt:ac\r\n"); // debug command name   

    // read first parameter if present
    if (!SCPI_ParamNumber(context, &param1, false)) {
        // do something, if parameter not present
    }

    // read second paraeter if present
    if (!SCPI_ParamNumber(context, &param2, false)) {
        // do something, if parameter not present
    }

    
    SCPI_NumberToStr(context, &param1, bf, 15);
    fprintf(stderr, "\tP1=%s\r\n", bf);

    
    SCPI_NumberToStr(context, &param2, bf, 15);
    fprintf(stderr, "\tP2=%s\r\n", bf);

    SCPI_ResultDouble(context, 0);
    
    return SCPI_RES_OK;
}
Exemple #4
0
//===============================================================
// Configure system database
// normal_matrix[arg1][arg2][arg3]=arg4
// arg1 & arg2 is interger
// arg4 is float32.
static scpi_result_t CFG_MatrixQ(scpi_t *context)
{
    scpi_number_t param;
    UINT8 i,j,k;
    
    // read first parameter if present
    if (SCPI_ParamNumber(context, scpi_special_numbers_def, &param, FALSE)) {
        i = (UINT8)param.value;
    }else{
        return SCPI_RES_ERR;
    }

    // read second paraeter if present
    if (SCPI_ParamNumber(context,scpi_special_numbers_def, &param, FALSE)) {
        j = (UINT8)param.value;
    }else{
        return SCPI_RES_ERR;
    }

    // read third paraeter if present
    if (SCPI_ParamNumber(context,scpi_special_numbers_def, &param, FALSE)) {
        k = (UINT8)param.value;
    }else{
        return SCPI_RES_ERR;
    }
	SCPI_ResultDouble(context,gMatrix[i][j][k]);
    return SCPI_RES_OK;
}
Exemple #5
0
static scpi_result_t DMM_MeasureTemperature(scpi_t* context){
    scpi_number_t param1, param2;
    // read first parameter if present
    if (!SCPI_ParamNumber(context, scpi_special_numbers_def, &param1, FALSE)) {
        // do something, if parameter not present
    }
    // read second paraeter if present
    if (!SCPI_ParamNumber(context, scpi_special_numbers_def, &param2, FALSE)) {
        // do something, if parameter not present
    }
    SCPI_ResultDouble(context, system_read_temp());    
    return SCPI_RES_OK;    
}
scpi_result_t SCPIMM_trigger_delay(scpi_t* context) {
	scpimm_context_t* const ctx = SCPIMM_CONTEXT(context);
	scpi_number_t num;

    if (!SCPI_ParamNumber(context, &num, TRUE)) {
		return SCPI_RES_ERR;
	}

	switch (num.type) {
		case SCPI_NUM_MIN:
			ctx->trigger_delay = TRIGGER_DELAY_MIN;
			break;

		case SCPI_NUM_MAX:
			ctx->trigger_delay = TRIGGER_DELAY_MAX;
			break;

		case SCPI_NUM_NUMBER:
			if (num.value < TRIGGER_DELAY_MIN || num.value > TRIGGER_DELAY_MAX) {
				SCPI_ErrorPush(context, SCPIMM_ERROR_DATA_OUT_OF_RANGE);
				return SCPI_RES_ERR;
			}
			ctx->trigger_delay = num.value;
			break;

		default:
			SCPI_ErrorPush(context, SCPIMM_ERROR_ILLEGAL_PARAMETER_VALUE);
			return SCPI_RES_ERR;
	}

	return SCPI_RES_OK;
}
scpi_result_t SCPIMM_trigger_countQ(scpi_t* context) {
	scpimm_context_t* const ctx = SCPIMM_CONTEXT(context);
    scpi_number_t num = {0.0, SCPI_UNIT_NONE, SCPI_NUM_NUMBER};
	int32_t lnum;

    if (!SCPI_ParamNumber(context, &num, FALSE)) {
		return SCPI_RES_ERR;
	}

	switch (num.type) {
		case SCPI_NUM_MIN:
			lnum = 1;
			break;

		case SCPI_NUM_MAX:
			lnum = max_trigger_count();
			break;

		case SCPI_NUM_DEF:
			if (ctx->infinite_trigger_count) {
				SCPI_ResultDouble(context, INF_TRIGGER_COUNT);
				return SCPI_RES_OK;
			}
			lnum = ctx->trigger_count_num;
			break;

		default:
			SCPI_ErrorPush(context, SCPIMM_ERROR_ILLEGAL_PARAMETER_VALUE);
			return SCPI_RES_ERR;
	}

	SCPI_ResultInt(context, lnum);
	return SCPI_RES_OK;
}
scpi_result_t SCPIMM_trigger_delayQ(scpi_t* context) {
    scpi_number_t num;
	double res;

    if (!SCPI_ParamNumber(context, &num, FALSE)) {
		return SCPI_RES_ERR;
	}

	switch (num.type) {
		case SCPI_NUM_MIN:
			res = TRIGGER_DELAY_MIN;
			break;

		case SCPI_NUM_MAX:
			res = TRIGGER_DELAY_MAX;
			break;

		case SCPI_NUM_DEF:
			res = SCPIMM_CONTEXT(context)->trigger_delay;
			break;

		default:
			SCPI_ErrorPush(context, SCPIMM_ERROR_ILLEGAL_PARAMETER_VALUE);
			return SCPI_RES_ERR;
	}

	SCPI_ResultDouble(context, res);
	return SCPI_RES_OK;
}
Exemple #9
0
int dscpi_output_load_inner(scpi_t *context, int output)
{
    scpi_number_t load;
    if (!SCPI_ParamNumber(context, &load, true)) {
        return SCPI_RES_ERR;
    }
    /* gw instek actually only allows a choice, but I haven't tried using number params */
    if (output) {
        SCPI_ResultString(context, "output2_load");
    } else {
        SCPI_ResultString(context, "output1_load");
    }
    if (load.type == SCPI_NUM_INF) {
        SCPI_ResultString(context, "infinite");
    } else if (load.type == SCPI_NUM_DEF) {
        SCPI_ResultString(context, "default");
    } else if (load.type == SCPI_NUM_NUMBER) {
        if (load.unit == SCPI_UNIT_NONE) {
            load.unit = SCPI_UNIT_OHM;
        }
        SCPI_NumberToStr(context, &load, numbuf, sizeof (numbuf));
        printf("setting load %d to %s\n", output + 1, numbuf);
        SCPI_ResultString(context, numbuf);
    } else {
        printf("invalid number argument\n");
        return SCPI_RES_ERR;
    }
    return SCPI_RES_OK;
}
Exemple #10
0
static scpi_result_t DMM_MeasureVoltageDcQ(scpi_t * context) {
    scpi_number_t param1, param2;
    if (!SCPI_ParamNumber(context, scpi_special_numbers_def, &param1, FALSE)) {
        // do something, if parameter not present
    }
    // read second paraeter if present
    if (!SCPI_ParamNumber(context, scpi_special_numbers_def, &param2, FALSE)) {
        // do something, if parameter not present
    }
    system_flags_t flags;
    double value = system_read_input(&flags);
    if(flags & SYS_FLAG_OVERFLOW){
        value = 9.999999999e99;
    }else if(flags & SYS_FLAG_UNDERFLOW){
        value = -9.999999999e99;
    }
    SCPI_ResultDouble(context, value);
    return SCPI_RES_OK;
}
Exemple #11
0
static scpi_result_t CFG_Matrix(scpi_t *context)
{
    scpi_number_t param;
    FLOAT32 value;
    UINT8 i,j,k;
    
    // read first parameter if present
    if (SCPI_ParamNumber(context,scpi_special_numbers_def, &param, FALSE)) {
        i = (UINT8)param.value;
    }else{
        return SCPI_RES_ERR;
    }

    // read second paraeter if present
    if (SCPI_ParamNumber(context,scpi_special_numbers_def, &param, FALSE)) {
        j = (UINT8)param.value;
    }else{
        return SCPI_RES_ERR;
    }

    // read third paraeter if present
    if (SCPI_ParamNumber(context,scpi_special_numbers_def, &param, FALSE)) {
        k = (UINT8)param.value;
    }else{
        return SCPI_RES_ERR;
    }

    // read fourth paraeter if present
    if (SCPI_ParamNumber(context,scpi_special_numbers_def, &param, FALSE)) {
        value =(FLOAT32) param.value;
    }else{
        return SCPI_RES_ERR;
    }
    gMatrix[i][j][k]=value;
    printf("%s:%d --->[%d][%d][%d]=%f\r\n",__FUNCTION__,__LINE__,i,j,k,gMatrix[i][j][k]);
    return SCPI_RES_OK;
}
scpi_result_t SCPIMM_trigger_count(scpi_t* context) {
	const long lmax = max_trigger_count();
	scpimm_context_t* const ctx = SCPIMM_CONTEXT(context);
    scpi_number_t num;
	long lnum;

    if (!SCPI_ParamNumber(context, &num, TRUE)) {
		return SCPI_RES_ERR;
	}
	
	switch (num.type) {
		case SCPI_NUM_MIN:
			lnum = 1;
			ctx->infinite_trigger_count = FALSE;
			break;

		case SCPI_NUM_MAX:
			lnum = lmax;
			ctx->infinite_trigger_count = FALSE;
			break;

		case SCPI_NUM_INF:
			lnum = 0;
			ctx->infinite_trigger_count = TRUE;
			break;

		case SCPI_NUM_NUMBER:
			lnum = (long) num.value;
			ctx->infinite_trigger_count = FALSE;
			break;

		default:
			SCPI_ErrorPush(context, SCPIMM_ERROR_ILLEGAL_PARAMETER_VALUE);
			return SCPI_RES_ERR;
	}

	if (!ctx->infinite_trigger_count && (lnum < 1 || lnum > lmax)) {
	    SCPI_ErrorPush(context, SCPIMM_ERROR_DATA_OUT_OF_RANGE);
    	return SCPI_RES_ERR;
	}

	ctx->trigger_count_num = (unsigned) lnum;
	return SCPI_RES_OK;
}
Exemple #13
0
static scpi_result_t set_step(scpi_t * context, Channel::Value *cv, float min_value, float max_value, float def, _scpi_unit_t unit) {
    scpi_number_t step_param;
    if (!SCPI_ParamNumber(context, scpi_special_numbers_def, &step_param, true)) {
        return SCPI_RES_ERR;
    }

    float step;

    if (step_param.special) {
        if (step_param.tag == SCPI_NUM_DEF) {
            step = def;
        }
        else {
            SCPI_ErrorPush(context, SCPI_ERROR_ILLEGAL_PARAMETER_VALUE);
            return SCPI_RES_ERR;
        }
    }
    else {
        if (step_param.unit != SCPI_UNIT_NONE && step_param.unit != unit) {
            SCPI_ErrorPush(context, SCPI_ERROR_INVALID_SUFFIX);
            return SCPI_RES_ERR;
        }

        step = (float)step_param.value;
        if (step < min_value || step > max_value) {
            SCPI_ErrorPush(context, SCPI_ERROR_DATA_OUT_OF_RANGE);
            return SCPI_RES_ERR;
        }
    }

    cv->step = step;
    profile::save();

    return SCPI_RES_OK;

}
Exemple #14
0
int dscpi_apply_sin_inner(scpi_t *context, int output)
{
    scpi_number_t freq;
    scpi_number_t ampl;
    scpi_number_t offset;
    if (!SCPI_ParamNumber(context, &freq, false)) {
        /* you can only get here if you gave it a bad pointer */
    } else {
        if (freq.type == SCPI_NUM_DEF) {
            freq.value = 1000;
            freq.type = SCPI_NUM_NUMBER;
            freq.unit = SCPI_UNIT_HERTZ;
        }
        if (freq.unit == SCPI_UNIT_NONE) {
            freq.unit = SCPI_UNIT_HERTZ;
        }
        /* handle minimum, maximum, regular*/
    }
    if (!SCPI_ParamNumber(context, &ampl, false)) {
        /* bad pointers */
    } else {
        if (ampl.type == SCPI_NUM_DEF) {
            ampl.type = SCPI_NUM_NUMBER;
            ampl.unit = SCPI_UNIT_VOLT;
            ampl.value = 0.1; // 100 mV by default
        }
        if (ampl.unit == SCPI_UNIT_NONE) {
            ampl.unit = SCPI_UNIT_VOLT;
        }
        /* handle minimum, maximum, */
        /* TODO somehow work out how to handle Vrms units here ?*/
    }
    if (!SCPI_ParamNumber(context, &offset, false)) {
        /* bad pointers */
    } else {
        if (offset.type == SCPI_NUM_DEF) {
            offset.type = SCPI_NUM_NUMBER;
            offset.unit = SCPI_UNIT_VOLT;
            offset.value = 0;
        }
        if (offset.unit == SCPI_UNIT_NONE) {
            offset.unit = SCPI_UNIT_VOLT;
        }
        /* handle minimum, maximum */
    }
    if (output) {
        SCPI_ResultString(context, "source_apply2_sin");
    } else {
        SCPI_ResultString(context, "source_apply1_sin");
    }
    SCPI_NumberToStr(context, &freq, numbuf, sizeof (numbuf));
    printf("setting output %d to sin wave freq: %s", output + 1, numbuf);
    SCPI_ResultString(context, numbuf);
    SCPI_NumberToStr(context, &ampl, numbuf, sizeof (numbuf));
    printf("ampl: %s", numbuf);
    SCPI_ResultString(context, numbuf);
    SCPI_NumberToStr(context, &offset, numbuf, sizeof (numbuf));
    printf("offset: %s", numbuf);
    SCPI_ResultString(context, numbuf);
    return SCPI_RES_OK;
}