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)
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;
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)