add vectors to meas

This commit is contained in:
h_vogt 2009-12-21 00:27:15 +00:00
parent 248e44b883
commit d6350ca86d
3 changed files with 64 additions and 6 deletions

View File

@ -1,3 +1,6 @@
2009-12-21 Holger Vogt
* com_measure2.com, measure.c: add vector to the meas command
2009-12-20 Holger Vogt
* fixing the time 0 value of sine in isrc, vsrc
* fteext.h, com_measure2.c, measure.c, commands.c:

View File

@ -91,7 +91,9 @@ void correct_vec(MEASUREPTR meas)
char *vec2, newvec2[BSIZE_SP];
vec = meas->m_vec;
/* return if not of type VM() etc */
if ((*vec != 'v') || (!strstr(vec, "("))) return;
if (*(++vec) != '(') {
vecfirst = copy(meas->m_vec);
vecfirst[1] = '\0';
@ -275,7 +277,7 @@ int measure_extract_variables( char *line )
* .MEASURE {DC|AC|TRAN} result FIND out_variable AT=val
* + <FROM=val> <TO=val>
*
* .MEASURE {DC|AC|TRAN} result {AVG|MIN|MAX|PP|RMS} out_variable
* .MEASURE {DC|AC|TRAN} result {AVG|MIN|MAX|MIN_AT|MAX_AT|PP|RMS} out_variable
* + <TD=td> <FROM=val> <TO=val>
*
* .MEASURE {DC|AC|TRAN} result INTEG<RAL> out_variable
@ -393,7 +395,10 @@ static void com_measure_when(
timeValue = dTime->v_compdata[i].cx_real;
}
else if (cieq (meas->m_analysis,"sp")) {
value = get_value(meas, d, i); //d->v_compdata[i].cx_real;
if (d->v_compdata)
value = get_value(meas, d, i); //d->v_compdata[i].cx_real;
else
value = d->v_realdata[i];
timeValue = dTime->v_realdata[i];
}
else {

View File

@ -42,16 +42,66 @@ extern bool rflag;
void
com_meas(wordlist *wl) {
/* wl: in, input line of meas command */
char *line_in, *outvar, newvec[1000];
wordlist * wl_count, *wl_let;
int fail;
char *line_in, *outvar, newvec[1000], *vec_found, *token, *equal_ptr, newval[256];
wordlist * wl_count, *wl_let, *wl_index;
int fail, err=0;
double result = 0;
struct dvec *d;
if (!wl) {
com_display((wordlist *) NULL);
return;
}
wl_count = wl;
/* check each wl entry, if it contain '=' and if the following token is
a vector. If yes, replace this vector by its value */
wl_index = wl;
while ( wl_index) {
token = wl_index->wl_word;
/* find the vector vec_found, next token after each '=' sign.
May be in the next wl_word */
if ( *(token + strlen(token) - 1) == '=' ) {
wl_index = wl_index->wl_next;
vec_found = wl_index->wl_word;
/* token may be already a value, maybe 'LAST', which we have to keep, or maybe a vector */
if (!cieq(vec_found, "LAST")) {
INPevaluate( &vec_found, &err, 1 );
/* if not a valid number */
if (err) {
/* check if vec_found is a valid vector */
d = vec_get(vec_found);
if (d) {
/* get its value */
sprintf(newval, "%f\0", d->v_realdata[0]);
tfree(vec_found);
wl_index->wl_word = copy(newval);
}
}
}
}
/* may be inside the same wl_word */
else if ( (equal_ptr = strstr( token, "=" )) ) {
vec_found = equal_ptr + 1;
if (!cieq(vec_found, "LAST")) {
INPevaluate( &vec_found, &err, 1 );
if (err) {
d = vec_get(vec_found);
if (d) {
*equal_ptr = '\0';
sprintf(newval, "%s=%f\0", token, d->v_realdata[0]);
// memory leak with first part of vec_found ?
tfree(token);
wl_index->wl_word = copy(newval);
}
}
}
} else {
;// nothing
}
wl_index = wl_index->wl_next;
}
line_in = wl_flatten(wl);
/* get output var name */