Browse Source

add vectors to meas

pre-master-46
h_vogt 17 years ago
parent
commit
d6350ca86d
  1. 3
      ChangeLog
  2. 11
      src/frontend/com_measure2.c
  3. 56
      src/frontend/measure.c

3
ChangeLog

@ -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 2009-12-20 Holger Vogt
* fixing the time 0 value of sine in isrc, vsrc * fixing the time 0 value of sine in isrc, vsrc
* fteext.h, com_measure2.c, measure.c, commands.c: * fteext.h, com_measure2.c, measure.c, commands.c:

11
src/frontend/com_measure2.c

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

56
src/frontend/measure.c

@ -42,16 +42,66 @@ extern bool rflag;
void void
com_meas(wordlist *wl) { com_meas(wordlist *wl) {
/* wl: in, input line of meas command */ /* 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; double result = 0;
struct dvec *d;
if (!wl) { if (!wl) {
com_display((wordlist *) NULL); com_display((wordlist *) NULL);
return; return;
} }
wl_count = wl; 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); line_in = wl_flatten(wl);
/* get output var name */ /* get output var name */

Loading…
Cancel
Save