SetAnalyse output extended

This commit is contained in:
h_vogt 2009-09-13 19:42:19 +00:00
parent 07b2828a4b
commit c25d028cbf
10 changed files with 202 additions and 118 deletions

View File

@ -1,3 +1,12 @@
2009-09-09 Holger Vogt
* inp.c: comments added, .TEMP evaluation before numparam parsing
* inpcom.c: comments added, inp_casefix() bug removed
* winmain.c: SetAnalyse() now writes to task bar, progress in 0.0%,
more ouput added for different phases during start up
(Start, Prepare Deck, Circuit2, Device Setup, op, tran ...)
* acan.c, cktsetup.c, dctran.c, dctrcurv.c, inp.c, inpas2.c, spec.c:
SetAnalyse() modified
2009-09-09 Holger Vogt
* com_measure2.c: some comments added
* windisp.c: white backgrond in plot with set color0=white, thicker

View File

@ -117,23 +117,20 @@ com_listing(wordlist *wl)
return;
}
/* returns inp_casefix() or NULL */
static char *
upper(char *string)
{
static char buf[BSIZE_SP];
static char buf[BSIZE_SP];
if (string) {
strncpy(buf, string, BSIZE_SP - 1);
buf[BSIZE_SP - 1] = 0;
inp_casefix(buf);
} else {
strcpy(buf, "<null>");
}
return buf;
if (string) {
strncpy(buf, string, BSIZE_SP - 1);
buf[BSIZE_SP - 1] = 0;
inp_casefix(buf);
} else {
strcpy(buf, "<null>");
}
return buf;
}
@ -329,6 +326,7 @@ inp_spsource(FILE *fp, bool comfile, char *filename)
struct line *deck, *dd, *ld, *prev_param = NULL, *prev_card = NULL;
struct line *realdeck, *options = NULL, *curr_meas = NULL;
char *tt = NULL, name[BSIZE_SP], *s, *t, *temperature = NULL;
double testemp = 0.0;
bool nosubckts, commands = FALSE;
wordlist *wl = NULL, *end = NULL, *wl_first = NULL;
wordlist *controls = NULL;
@ -399,7 +397,15 @@ inp_spsource(FILE *fp, bool comfile, char *filename)
else { /* must be regular deck . . . . */
/* loop through deck and handle control cards */
for (dd = deck->li_next; dd; dd = ld->li_next) {
/* get temp from deck */
if ( ciprefix(".temp", dd->li_line) ) {
s = dd->li_line + 5;
while ( isspace(*s) ) s++;
if ( temperature != NULL ) {
txfree(temperature);
}
temperature = strdup(s);
}
/* Ignore comment lines, but not lines begining with '*#' */
s = dd->li_line;
while(isspace(*s)) s++;
@ -500,13 +506,24 @@ inp_spsource(FILE *fp, bool comfile, char *filename)
}
} /* end for(dd=deck->li_next . . . . */
/* set temperature if defined to a preliminary variable which may be used in numparam
evaluation */
if ( temperature != NULL ) {
temperature_value = atof(temperature);
s = (char *) &temperature_value;
cp_vset("pretemp", VT_REAL, s );
// txfree(temperature);
}
#if defined(OUTDECK)
cp_getvar( "pretemp", VT_REAL, (double *) &testemp );
printf("test temperature %f\n", testemp);
#endif
/* We are done handling the control stuff. Now process remainder of deck.
Go on if there is something left after the controls.*/
if (deck->li_next) {
fprintf(cp_out, "\nCircuit: %s\n\n", tt);
#ifdef HAS_WINDOWS
SetAnalyse( "Circuit", 0);
SetAnalyse( "Prepare Deck", 0);
#endif
/* Now expand subcircuit macros and substitute numparams.*/
if (!cp_getvar("nosubckt", VT_BOOL, (char *) &nosubckts))
@ -538,7 +555,7 @@ inp_spsource(FILE *fp, bool comfile, char *filename)
}
for (dd = deck; dd; dd = dd->li_next) {
/* get temp after numparam run on deck */
/* get temp after numparam run on deck
if ( ciprefix(".temp", dd->li_line) ) {
s = dd->li_line + 5;
while ( isspace(*s) ) s++;
@ -546,7 +563,7 @@ inp_spsource(FILE *fp, bool comfile, char *filename)
txfree(temperature);
}
temperature = strdup(s);
}
}*/
/*
all parameter lines should be sequentially ordered and placed at
beginning of deck
@ -581,7 +598,7 @@ inp_spsource(FILE *fp, bool comfile, char *filename)
dd = prev_card;
}
prev_card = dd;
}
} //end of for-loop
/* set temperature if defined */
if ( temperature != NULL ) {
@ -964,85 +981,83 @@ com_edit(wordlist *wl)
static bool
doedit(char *filename)
{
char buf[BSIZE_SP], buf2[BSIZE_SP], *editor;
if (cp_getvar("editor", VT_STRING, buf2)) {
editor = buf2;
} else {
if (!(editor = getenv("EDITOR"))) {
if (Def_Editor && *Def_Editor)
editor = Def_Editor;
else
editor = "/usr/bin/vi";
}
}
sprintf(buf, "%s %s", editor, filename);
return (system(buf) ? FALSE : TRUE);
char buf[BSIZE_SP], buf2[BSIZE_SP], *editor;
if (cp_getvar("editor", VT_STRING, buf2)) {
editor = buf2;
} else {
if (!(editor = getenv("EDITOR"))) {
if (Def_Editor && *Def_Editor)
editor = Def_Editor;
else
editor = "/usr/bin/vi";
}
}
sprintf(buf, "%s %s", editor, filename);
return (system(buf) ? FALSE : TRUE);
}
void
com_source(wordlist *wl)
{
FILE *fp, *tp;
char buf[BSIZE_SP];
bool inter;
char *tempfile = NULL;
wordlist *owl = wl;
int i;
FILE *fp, *tp;
char buf[BSIZE_SP];
bool inter;
char *tempfile = NULL;
wordlist *owl = wl;
int i;
inter = cp_interactive;
cp_interactive = FALSE;
if (wl->wl_next) {
/* There are several files -- put them into a temp file */
tempfile = smktemp("sp");
if (!(fp = inp_pathopen(tempfile, "w+"))) {
perror(tempfile);
inter = cp_interactive;
cp_interactive = FALSE;
if (wl->wl_next) {
/* There are several files -- put them into a temp file */
tempfile = smktemp("sp");
if (!(fp = inp_pathopen(tempfile, "w+"))) {
perror(tempfile);
cp_interactive = TRUE;
return;
}
while (wl) {
if (!(tp = inp_pathopen(wl->wl_word, "r"))) {
perror(wl->wl_word);
fclose(fp);
cp_interactive = TRUE;
unlink(tempfile);
return;
}
while (wl) {
if (!(tp = inp_pathopen(wl->wl_word, "r"))) {
perror(wl->wl_word);
fclose(fp);
cp_interactive = TRUE;
unlink(tempfile);
return;
}
while ((i = fread(buf, 1, BSIZE_SP, tp)) > 0)
fwrite(buf, 1, i, fp);
}
while ((i = fread(buf, 1, BSIZE_SP, tp)) > 0)
fwrite(buf, 1, i, fp);
fclose(tp);
wl = wl->wl_next;
}
fseek(fp, (long) 0, 0);
} else
fp = inp_pathopen(wl->wl_word, "r");
if (fp == NULL) {
perror(wl->wl_word);
cp_interactive = TRUE;
return;
}
}
fseek(fp, (long) 0, 0);
} else
fp = inp_pathopen(wl->wl_word, "r");
if (fp == NULL) {
perror(wl->wl_word);
cp_interactive = TRUE;
return;
}
/* Don't print the title if this is a spice initialisation file. */
if (ft_nutmeg || substring(INITSTR, owl->wl_word) || substring(ALT_INITSTR, owl->wl_word)) {
inp_spsource(fp, TRUE, tempfile ? (char *) NULL : wl->wl_word);
}
else {
inp_spsource(fp, FALSE, tempfile ? (char *) NULL : wl->wl_word);
}
cp_interactive = inter;
if (tempfile)
unlink(tempfile);
return;
if (ft_nutmeg || substring(INITSTR, owl->wl_word) || substring(ALT_INITSTR, owl->wl_word)) {
inp_spsource(fp, TRUE, tempfile ? (char *) NULL : wl->wl_word);
}
else {
inp_spsource(fp, FALSE, tempfile ? (char *) NULL : wl->wl_word);
}
cp_interactive = inter;
if (tempfile)
unlink(tempfile);
return;
}
void
inp_source(char *file)
{
static struct wordlist wl = { NULL, NULL, NULL } ;
wl.wl_word = file;
com_source(&wl);
return;
static struct wordlist wl = { NULL, NULL, NULL } ;
wl.wl_word = file;
com_source(&wl);
return;
}

View File

@ -1613,32 +1613,34 @@ inp_readall(FILE *fp, struct line **data, int call_depth, char *dir_name)
}
/*-------------------------------------------------------------------------*
* *
removes " " quotes, returns lower case letters,
replaces non-printable characterss with '_' *
*-------------------------------------------------------------------------*/
void
inp_casefix(char *string)
{
#ifdef HAVE_CTYPE_H
if (string)
while (*string) {
/* Let's make this really idiot-proof. */
if (string)
while (*string) {
#ifdef HAS_ASCII
*string = strip(*string);
/* ((*string) & 0177): mask off all but the first seven bits, 0177: octal */
*string = strip(*string);
#endif
if (*string == '"') {
*string++ = ' ';
while (*string && *string != '"')
string++;
if (*string == '"')
*string = ' ';
}
if (!isspace(*string) && !isprint(*string))
*string = '_';
if (isupper(*string))
*string = tolower(*string);
string++;
}
return;
if (*string == '"') {
*string++ = ' ';
while (*string && *string != '"')
string++;
if (*string== '\0') continue; /* needed if string is "something ! */
if (*string == '"')
*string = ' ';
}
if (!isspace(*string) && !isprint(*string))
*string = '_';
if (isupper(*string))
*string = tolower(*string);
string++;
}
return;
#endif
}

View File

@ -258,7 +258,7 @@ com_spec(wordlist *wl)
}
}
#ifdef HAS_WINDOWS
SetAnalyse( "spec", (int)(j * 100/ fpts));
SetAnalyse( "spec", (int)(j * 1000./ fpts));
#endif
}
if (startf==0) {

View File

@ -321,7 +321,7 @@ ACan(CKTcircuit *ckt, int restart)
startfreq = log(startfreq);
if (freq > 0.0)
SetAnalyse( "ac", (log(freq)-startfreq) * 100.0 / (endfreq-startfreq));
SetAnalyse( "ac", (log(freq)-startfreq) * 1000.0 / (endfreq-startfreq));
}
#endif
@ -334,7 +334,7 @@ ACan(CKTcircuit *ckt, int restart)
{
double endfreq = ((ACAN*)ckt->CKTcurJob)->ACstopFreq;
double startfreq = ((ACAN*)ckt->CKTcurJob)->ACstartFreq;
SetAnalyse( "ac", (freq - startfreq)* 100.0 / (endfreq-startfreq));
SetAnalyse( "ac", (freq - startfreq)* 1000.0 / (endfreq-startfreq));
}
#endif

View File

@ -22,6 +22,10 @@ Author: 1985 Thomas L. Quarles
return(E_NOMEM);\
}
#ifdef HAS_WINDOWS
extern void SetAnalyse( char * Analyse, int Percent);
#endif
extern SPICEdev **DEVices;
@ -57,6 +61,9 @@ CKTsetup(CKTcircuit *ckt)
matrix = ckt->CKTmatrix;
for (i=0;i<DEVmaxnum;i++) {
#ifdef HAS_WINDOWS
SetAnalyse( "Device Setup", 0 );
#endif
if ( DEVices[i] && ((*DEVices[i]).DEVsetup != NULL) && (ckt->CKThead[i] != NULL) ){
error = (*((*DEVices[i]).DEVsetup))(matrix,ckt->CKThead[i],ckt,
&ckt->CKTnumStates);

View File

@ -529,7 +529,7 @@ resume:
}
#endif
#ifdef HAS_WINDOWS
SetAnalyse( "tran", (int)((ckt->CKTtime * 100) / ckt->CKTfinalTime));
SetAnalyse( "tran", (int)((ckt->CKTtime * 1000.) / ckt->CKTfinalTime));
#endif
ckt->CKTdelta =
MIN(ckt->CKTdelta,ckt->CKTmaxStep);

View File

@ -517,7 +517,7 @@ nextstep:;
#ifdef HAS_WINDOWS
if (i == cv->TRCVnestLevel) {
actval += cv->TRCVvStep[cv->TRCVnestLevel];
SetAnalyse( "dc", (int)abs(((actval * 100.) / actdiff)));
SetAnalyse( "dc", (int)abs(((actval * 1000.) / actdiff)));
}
#endif
}

View File

@ -16,6 +16,10 @@ Author: 1985 Thomas L. Quarles
/* gtri - end - wbk - 11/9/90 */
#endif
#ifdef HAS_WINDOWS
extern void SetAnalyse( char * Analyse, int Percent);
#endif
/* uncomment to trace in this file */
/*#define TRACE*/
@ -31,6 +35,7 @@ void INPpas2(void *ckt, card * data, INPtables * tab, void *task)
char *gname;
void *gnode;
int error; /* used by the macros defined above */
int linecount = 0, actcount = 0;
#ifdef TRACE
/* SDB debug statement */
@ -59,6 +64,12 @@ void INPpas2(void *ckt, card * data, INPtables * tab, void *task)
printf("\n");
#endif
#ifdef HAS_WINDOWS
for (current = data; current != NULL; current = current->nextcard)
linecount++;
#endif
for (current = data; current != NULL; current = current->nextcard) {
#ifdef TRACE
@ -66,6 +77,13 @@ void INPpas2(void *ckt, card * data, INPtables * tab, void *task)
printf("In INPpas2, examining card %s . . .\n", current->line);
#endif
#ifdef HAS_WINDOWS
if (linecount > 0) {
SetAnalyse( "Circuit2", (int) (1000.*actcount/linecount));
actcount++;
}
#endif
c = *(current->line);
c = islower(c) ? toupper(c) : c;

View File

@ -29,8 +29,11 @@
#include <signal.h>
#include <ctype.h>
#include <sys/types.h>
#include <sys/timeb.h>
#include "bool.h" // bool defined as unsigned char
#include "misc/misc_time.h" /* timediff */
/* Constants */
#define TBufSize 8192 // Groesze des Textbuffers
#define CR VK_RETURN // Carriage Return
@ -196,22 +199,52 @@ void SetSource( char * Name)
// ------------------------------<Analyse-Fenster>-----------------------------
// Neuer Text ins Analysefenster
void SetAnalyse( char * Analyse, int Percent)
{
/* New progress report into analysis window.
Update only every DELTATIME milliseconds */
#define DELTATIME 150
void SetAnalyse(
char * Analyse, /*in: analysis type */
int DecaPercent /*in: 10 times the progress [%]*/
/*HWND hwAnalyse, in: global handle to analysis window */
) {
static int OldPercent = -2;
static char Olds[128];
char s[128];
char s[128], t[128];
static struct timeb timebefore; /* previous time stamp */
struct timeb timenow;
int diffsec, diffmillisec;
if ((Percent == OldPercent) && !strcmp(Olds, Analyse)) return;
OldPercent = Percent;
strncpy(Olds, Analyse, 127);
if (hwAnalyse) {
if (Percent < 0)
if ((DecaPercent == OldPercent) && !strcmp(Olds, Analyse)) return;
/* get actual time */
ftime(&timenow);
timediff(&timenow, &timebefore, &diffsec, &diffmillisec);
OldPercent = DecaPercent;
/* output only into correct window and if time elapsed is larger than
given value, or if analysis has changed, else return */
if (hwAnalyse && ((diffsec > 0) || (diffmillisec > DELTATIME) || strcmp(Olds, Analyse))) {
if (DecaPercent < 0) {
sprintf( s, "--ready--");
else
sprintf( s, "%s : %3u%%", Analyse, Percent);
sprintf( t, "%s", PACKAGE_STRING);
}
else if (DecaPercent == 0) {
sprintf( s, "%s", Analyse);
sprintf( t, "%s %s", PACKAGE_STRING, Analyse);
}
else {
sprintf( s, "%s: %3.1f%%", Analyse, (double)DecaPercent/10.);
// sprintf( t, "%s %s: %3.1f%%", PACKAGE_STRING, Analyse, (double)DecaPercent/10.);
sprintf( t, "%s %3.1f%%", PACKAGE_STRING, (double)DecaPercent/10.);
}
/*sprintf( s, "%s : %3u%%", Analyse, (int)(DecaPercent/10));*/
timebefore.dstflag = timenow.dstflag;
timebefore.millitm = timenow.millitm;
timebefore.time = timenow.time;
timebefore.timezone = timenow.timezone;
strncpy(Olds, Analyse, 127);
SetWindowText( hwAnalyse, s);
SetWindowText( hwMain, t);
InvalidateRgn( hwAnalyse, NULL, TRUE);
WaitForIdle();
}