static int _dc_input_handler(ScfEfunction* f, int64_t ns, int64_t count, ses_ctx_t* ctx)
{
ScfEcomponent* B;
+ ScfEcomponent* c;
ScfEline* el;
+ ScfEline* el2;
ScfEpin* p;
size_t i;
+ size_t j;
+ int k;
B = f->components[0];
for (i = 0; i < f->n_elines; i++) {
el = f->elines[i];
- if (SCF_EDA_PIN_IN & el->flags) {
+ if (!(SCF_EDA_PIN_IN & el->flags))
+ continue;
- el->v = (0x0) * B->v;
- el->vconst = 1;
+ k = SCF_EDA_Battery_POS;
+ el2 = f->elines[B->pins[k]->lid];
- scf_logw("IN el: %ld, V: %lg\n", el->id, el->v);
+ el->v = k * B->v;
+ el->vconst = 1;
+
+ for (j = 0; j + 1 < el->n_pins; j += 2) {
+
+ c = f->components[el->pins[j]];
+ p = c->pins [el->pins[j + 1]];
+
+ int ret = scf_eline__add_pin(el2, c->id, p->id);
+ if (ret < 0)
+ return ret;
+
+ p->lid = el2->id;
+ scf_logw("c%ld, p%ld, l%ld --> l%ld\n", c->id, p->id, p->c_lid, p->lid);
}
+
+ scf_logw("IN el: %ld, V: %lg\n", el->id, el->v);
}
return 0;
for (j = 0; j < f->n_components; j++) {
c = f->components[j];
- if ((SCF_EDA_Diode == c->type || SCF_EDA_NPN == c->type)
- && SCF_EDA_Status_OFF == c->status)
- continue;
-
cairo_set_line_width(cr, 2);
uint8_t text[64];
cairo_show_text (cr, text);
cairo_stroke(cr);
- cairo_set_source_rgb(cr, 0.6, 0.6, 0.0);
+ if ((SCF_EDA_Diode == c->type || SCF_EDA_NPN == c->type)
+ && SCF_EDA_Status_OFF == c->status)
+ cairo_set_source_rgb(cr, 0.0, 0.6, 0.6);
+ else
+ cairo_set_source_rgb(cr, 0.6, 0.6, 0.0);
for (k = 0; k < c->n_pins; k++) {
p = c->pins[k];
static int _simplify_handler(ScfEfunction* f, int64_t ns, int64_t count, ses_ctx_t* ctx)
{
- ScfEcomponent* c;
- ScfEcomponent* B;
- ScfEline* el;
- ScfEline* el2;
- ScfEline* elp;
- ScfEline* eln;
- ScfEpin* p;
-
- size_t i;
- size_t j;
- size_t k;
-
- B = f->components[0];
-
- elp = f->elines[B->pins[SCF_EDA_Battery_POS]->lid];
- eln = f->elines[B->pins[SCF_EDA_Battery_NEG]->lid];
-
- for (i = 0; i < f->n_elines; i++) {
- el = f->elines[i];
-
- if (!(SCF_EDA_PIN_IN & el->flags))
- continue;
-
- if (el->v == elp->v)
- el2 = elp;
- else if (el->v == eln->v)
- el2 = eln;
- else
- continue;
-
- for (j = 0; j + 1 < el->n_pins; j += 2) {
-
- c = f->components[el->pins[j]];
- p = c->pins [el->pins[j + 1]];
-
- if (SCF_EDA_Status_OFF == c->status)
- continue;
-
- int ret = scf_eline__add_pin(el2, c->id, p->id);
- if (ret < 0)
- return ret;
-
- p->lid = el2->id;
-
- scf_logw("c%ld, p%ld, l%ld --> l%ld\n", c->id, p->id, p->c_lid, p->lid);
- }
- }
-
_simplify_draw(f, f->x, f->y, f->w, f->h);
-
- printf("\n");
return 0;
}