__ses_status_check()
authoryu.dongliang <18588496441@163.com>
Tue, 24 Oct 2023 05:38:16 +0000 (13:38 +0800)
committeryu.dongliang <18588496441@163.com>
Tue, 24 Oct 2023 05:38:16 +0000 (13:38 +0800)
ses_step_va_transistor.c

index 07c054f83b1b02895fcf6e9f74c2637b3840e386..b83619557c9861dcfb4507887db612110e60bff0 100644 (file)
@@ -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)