From 749be37f5d06da33e089abdb3345ce2cd3b0b1f2 Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Mon, 16 Feb 2026 21:32:39 +0100 Subject: [PATCH] Add a command 'plainsim': Throw out the circuit struct, recreate it from the local storage, remove the deg monitors, no change to device instances. --- src/frontend/commands.c | 10 +++++++--- src/frontend/inpdeg.c | 41 ++++++++++++++++++++++++++++++++++++----- src/frontend/runcoms2.c | 22 +++++++++++++++++++++- src/frontend/runcoms2.h | 1 + 4 files changed, 65 insertions(+), 9 deletions(-) diff --git a/src/frontend/commands.c b/src/frontend/commands.c index 41a127c34..4cdd85124 100644 --- a/src/frontend/commands.c +++ b/src/frontend/commands.c @@ -444,15 +444,19 @@ struct comm spcp_coms[] = { { "remcirc", com_remcirc, TRUE, TRUE, { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, NULL, - ": Remove current citcuit." } , + ": Remove current circuit." } , { "reset", com_rset, TRUE, TRUE, { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, NULL, - ": Remove current ciuit, reload circuit from internal storage." } , + ": Remove current circuit, reload circuit from internal storage." } , { "degsim", com_degsim, TRUE, TRUE, { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, NULL, - ": Remove current circuit, reload and modify circuit." } , + ": Remove current circuit, reload, remove deg monitors, and modify circuit." } , + { "plainsim", com_plainsim, TRUE, TRUE, + { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, + NULL, + ": Remove current circuit, reload, remove deg monitors, do not modify circuit." }, { "run", com_run, TRUE, TRUE, { 0, 0, 0, 0 }, E_DEFHMASK, 0, 1, NULL, diff --git a/src/frontend/inpdeg.c b/src/frontend/inpdeg.c index ecda1726e..6c78b27d2 100644 --- a/src/frontend/inpdeg.c +++ b/src/frontend/inpdeg.c @@ -17,6 +17,7 @@ License: Modified BSD #include "inpcom.h" int prepare_degsim(struct card* deck); +int prepare_plainsim(struct card* deck); int clear_degsim(void); static int add_degmodel(struct card* deck, double* result); @@ -71,7 +72,7 @@ int readdegparams (struct card *deck) { agemods[ageindex].devmodel = copy(ftok); else { fprintf(stderr, "Error: bad .agemodel syntax in line\n %s", card->line); - controlled_exit(1); + continue; } tfree(dftok); tfree(f1); @@ -81,7 +82,7 @@ int readdegparams (struct card *deck) { agemods[ageindex].simmodel = copy(ftok); else { fprintf(stderr, "Error: bad .agemodel syntax in line\n %s", card->line); - controlled_exit(1); + continue; } tfree(dftok); tfree(f1); @@ -97,11 +98,16 @@ int readdegparams (struct card *deck) { char* f2 = NULL; int err = 0; ftok = dftok = gettok(&cut_line); + if (!dftok) { + fprintf(stderr, "Error: bad .agemodel syntax in line\n % s", card->line); + continue; + } /* parameter name */ f1 = gettok_char(&ftok, '=', FALSE, FALSE); if (!f1) { fprintf(stderr, "Error: bad .agemodel syntax in line\n % s", card->line); - controlled_exit(1); + tfree(dftok); + continue; } /* parameter value */ f2 = copy(ftok + 1); @@ -125,7 +131,7 @@ int readdegparams (struct card *deck) { } } - return 0; + return ageindex; } /* Look for an X line. @@ -302,8 +308,33 @@ int remsqrbra(struct card* deck) { return 0; } +/* Remove the degradation monitors. */ +int prepare_plainsim(struct card* deck) { + struct card* ldeck; + /* skip the title line */ + for (ldeck = deck->nextcard; ldeck; ldeck = ldeck->nextcard) { + char* line = ldeck->line; + + if (*line == '*') { + continue; + } + + /* remove the remnants of the first run */ + if (ciprefix(".model", line) && search_plain_identifier(line, "degmon")) { + struct card* nextdeck = ldeck->nextcard; + if (nextdeck) { + char* nextline = nextdeck->line; + if (*nextline == 'a' && strstr(nextline, "degmon")) { + *nextline = '*'; + } + } + } + } + return 0; +} + /* Remove the degradation monitors. - Add current measurement, delta_vg and current source. + Add instance parameters delvto and factuo. Use the data retrieved from degdatahash */ int prepare_degsim(struct card* deck) { struct card* prevcard = deck, *ldeck; diff --git a/src/frontend/runcoms2.c b/src/frontend/runcoms2.c index e06d3501d..fb126b822 100644 --- a/src/frontend/runcoms2.c +++ b/src/frontend/runcoms2.c @@ -37,6 +37,7 @@ extern INPmodel *modtab; extern NGHASHPTR modtabhash; extern void setdegsim(void); +extern void setplainsim(void); #ifdef SHARED_MODULE extern void exec_controls(wordlist *newcontrols); @@ -171,7 +172,8 @@ com_resume(wordlist *wl) } -/* Throw out the circuit struct and recreate it from the deck. */ +/* Throw out the circuit struct, recreate it from the deck, + remove the deg monitors, add degradation to instances. */ void com_degsim(wordlist* wl) { @@ -188,6 +190,24 @@ com_degsim(wordlist* wl) } +/* Throw out the circuit struct, recreate it from the deck, + remove the deg monitors, no change to device instances. */ +void +com_plainsim(wordlist* wl) +{ + NG_IGNORE(wl); + + if (ft_curckt == NULL) { + fprintf(cp_err, "Warning: there is no circuit loaded.\n"); + fprintf(cp_err, " Command 'reset' is ignored.\n"); + return; + } + com_remcirc(NULL); + setplainsim(); + inp_source_recent(); +} + + /* Throw out the circuit struct and recreate it from the deck. */ void com_rset(wordlist *wl) diff --git a/src/frontend/runcoms2.h b/src/frontend/runcoms2.h index 7c52e5776..0c268fdab 100644 --- a/src/frontend/runcoms2.h +++ b/src/frontend/runcoms2.h @@ -10,5 +10,6 @@ void com_resume(wordlist *wl); void com_rset(wordlist *wl); void com_remcirc(wordlist *wl); void com_degsim(wordlist* wl); +void com_plainsim(wordlist* wl); #endif