From d8b1e639be96f0d484971d9c3e429735063b53c2 Mon Sep 17 00:00:00 2001 From: "yu.dongliang" <18588496441@163.com> Date: Tue, 24 Oct 2023 13:38:16 +0800 Subject: [PATCH] __ses_status_check() --- ses_step_va_transistor.c | 40 ++++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/ses_step_va_transistor.c b/ses_step_va_transistor.c index 07c054f..b836195 100644 --- a/ses_step_va_transistor.c +++ b/ses_step_va_transistor.c @@ -24,10 +24,15 @@ void __ses_path_dr_transistor(ScfEfunction* f, ses_path_t* path, int i, int j) int __ses_status_check(ScfEfunction* f, ScfEcomponent* c, ScfEpin* pb, ScfEpin* pe) { + ScfEcomponent* c2; + ScfEline* el; + ScfEpin* p2; + ScfEcomponent* B = f->components[0]; ScfEpin* Bp = B->pins[SCF_EDA_Battery_POS]; ScfEpin* Bn = B->pins[SCF_EDA_Battery_NEG]; + size_t i; double DV = SCF_EDA_V_NPN_OFF; if (SCF_EDA_Diode == c->type) @@ -48,9 +53,7 @@ int __ses_status_check(ScfEfunction* f, ScfEcomponent* c, ScfEpin* pb, ScfEpin* c->status = SCF_EDA_Status_OFF; } else c->status = SCF_EDA_Status_ON; - - scf_loge("\033[34mc%ld, status: %d\033[0m\n", c->id, c->status); - return 1; + goto _changed; } else if (pe->v < SCF_EDA_V_MIN) { pe->v = pb->v - DV; @@ -60,24 +63,41 @@ int __ses_status_check(ScfEfunction* f, ScfEcomponent* c, ScfEpin* pb, ScfEpin* c->status = SCF_EDA_Status_OFF; } else c->status = SCF_EDA_Status_ON; - - scf_loge("\033[34mc%ld, status: %d\033[0m\n", c->id, c->status); - return 1; + goto _changed; } else if (pb->v - pe->v < DV) { if (c->status != SCF_EDA_Status_OFF) { c->status = SCF_EDA_Status_OFF; - scf_loge("\033[34mc%ld, status: %d\033[0m\n", c->id, c->status); - return 1; + goto _changed; } } else if (SCF_EDA_Status_ON != c->status) { c->status = SCF_EDA_Status_ON; - scf_loge("\033[34mc%ld, status: %d\033[0m\n", c->id, c->status); - return 1; + goto _changed; } return 0; + +_changed: + if (SCF_EDA_NPN == c->type) { + p2 = c->pins[SCF_EDA_NPN_C]; + el = f->elines[p2->lid]; + + for (i = 0; i + 1 < el->n_pins; i += 2) { + + c2 = f->components[el->pins[i]]; + p2 = c->pins [el->pins[i + 1]]; + + if (SCF_EDA_NPN == c2->type && SCF_EDA_NPN_B == p2->id) { + c2->status = SCF_EDA_Status_ON; + + scf_loge("\033[35mc%ld, status: %d\033[0m\n", c2->id, c2->status); + } + } + } + + scf_loge("\033[34mc%ld, status: %d\033[0m\n", c->id, c->status); + return 1; } static int __ses_status_change(ScfEfunction* f, ScfEline* el) -- 2.25.1