From: yu.dongliang <18588496441@163.com> Date: Sat, 22 Jul 2023 07:08:43 +0000 (+0800) Subject: _simplify_handler X-Git-Url: http://baseworks.info/?a=commitdiff_plain;h=6e42d93b7e5dcf45cfcddc7a2955defc3c5d7ac3;p=ses.git _simplify_handler --- diff --git a/ses_step_simplify.c b/ses_step_simplify.c index d9880a1..0bf922d 100644 --- a/ses_step_simplify.c +++ b/ses_step_simplify.c @@ -224,14 +224,51 @@ static int _simplify_handler(ScfEfunction* f, int64_t ns, int64_t count) ScfEcomponent* c; ScfEcomponent* B; ScfEline* el; - ScfEpin* pb; - ScfEpin* pc; - ScfEpin* pe; + 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); return 0;