for (j = 0; j < f->n_elines; j++) {
el = f->elines[j];
- if (el->v == B->pins[SCF_EDA_Battery_POS]->v)
+ if ((SCF_EDA_PIN_POS & el->flags) || el->v == B->pins[SCF_EDA_Battery_POS]->v)
cairo_set_source_rgb(cr, 1, 0, 0);
- else if (el->v == B->pins[SCF_EDA_Battery_NEG]->v)
+ else if ((SCF_EDA_PIN_NEG & el->flags) || el->v == B->pins[SCF_EDA_Battery_NEG]->v)
cairo_set_source_rgb(cr, 0, 0, 1);
else if (SCF_EDA_PIN_IN & el->flags)
static size_t __ses_line_update(ScfEfunction* f, ScfEline* el)
{
ScfEcomponent* c;
+ ScfEline* el2;
ScfEpin* p;
ScfEpin* p2;
if (SCF_EDA_Diode_POS == p->id) {
- p2 = c->pins[SCF_EDA_Diode_NEG];
+ p2 = c->pins[SCF_EDA_Diode_NEG];
+ el2 = f->elines[p2->lid];
+ p2->v = el2->v;
if (p->v - p2->v < SCF_EDA_V_Diode_ON) {
c->status = SCF_EDA_Status_OFF;
n++;
+
+ scf_loge("c%ld off, p%ld->v: %lg, p%ld->v: %lg, diff: %lg\n", c->id, p->id, p->v, p2->id, p2->v, p->v - p2->v);
}
} else {
- p2 = c->pins[SCF_EDA_Diode_POS];
+ p2 = c->pins[SCF_EDA_Diode_POS];
+ el2 = f->elines[p2->lid];
+ p2->v = el2->v;
if (p2->v - p->v < SCF_EDA_V_Diode_ON) {
c->status = SCF_EDA_Status_OFF;
n++;
+
+ scf_loge("c%ld off, p%ld->v: %lg, p%ld->v: %lg, diff: %lg\n", c->id, p->id, p->v, p2->id, p2->v, p2->v - p->v);
}
}
if (SCF_EDA_Transistor_B == p->id) {
- p2 = c->pins[SCF_EDA_Transistor_E];
+ p2 = c->pins[SCF_EDA_Transistor_E];
+ el2 = f->elines[p2->lid];
+ p2->v = el2->v;
if (p->v - p2->v < SCF_EDA_V_Diode_ON) {
c->status = SCF_EDA_Status_OFF;
n++;
+
+ scf_loge("c%ld off, p%ld->v: %lg, p%ld->v: %lg, diff: %lg\n", c->id, p->id, p->v, p2->id, p2->v, p->v - p2->v);
}
} else if (SCF_EDA_Transistor_E == p->id) {
- p2 = c->pins[SCF_EDA_Transistor_B];
+ p2 = c->pins[SCF_EDA_Transistor_B];
+ el2 = f->elines[p2->lid];
+ p2->v = el2->v;
if (p2->v - p->v < SCF_EDA_V_Diode_ON) {
c->status = SCF_EDA_Status_OFF;
n++;
+
+ scf_loge("c%ld off, p%ld->v: %lg, p%ld->v: %lg, diff: %lg\n", c->id, p->id, p->v, p2->id, p2->v, p2->v - p->v);
}
}
}
scf_loge("v0: %lg, v1: %lg, v4: %lg, v1 - v0: %lg\n", v0, v1, v4, v1 - v0);
el = f->elines[p0->lid];
- el->v = v0;
+ el->v = v1;
el = f->elines[p1->lid];
- el->v = v1;
+ el->v = v0;
size_t n0 = __ses_line_update(f, f->elines[p0->lid]);
size_t n1 = __ses_line_update(f, f->elines[p1->lid]);