From: yu.dongliang <18588496441@163.com> Date: Wed, 6 Sep 2023 06:52:22 +0000 (+0800) Subject: ses_step_va_diode.c X-Git-Url: http://baseworks.info/?a=commitdiff_plain;h=aeecafb806619f98b13ef1607443316eb261d4a5;p=ses.git ses_step_va_diode.c --- diff --git a/ses_step_va_diode.c b/ses_step_va_diode.c index 7986b07..bcc433c 100644 --- a/ses_step_va_diode.c +++ b/ses_step_va_diode.c @@ -43,6 +43,8 @@ static int __ses_path_va_diode(ScfEfunction* f, ses_path_t* path) double r; double jr; + scf_logi("path->type: %d\n", path->type); + for (i = 0; i < path->pins->size; i++) { p = path->pins->data[i]; @@ -72,6 +74,12 @@ static int __ses_path_va_diode(ScfEfunction* f, ses_path_t* path) el->ja = ja; el->aconst = 1; + scf_loge("i: %d, c%ldp%ld, v: %lg + j%lg, p->v: %lg + j%lg, r: %lg + j%lg, el->a: %lg + j%lg\n\n", i, p->cid, p->id, + v, jv, p->v, p->jv, r, jr, el->a, el->ja); + + v = p->v - p1->v; + jv = p->jv - p1->jv; + if (path->childs) { for (j = 0; j < path->childs->size; j++) { child = path->childs->data[j]; @@ -84,12 +92,18 @@ static int __ses_path_va_diode(ScfEfunction* f, ses_path_t* path) ses_split_i(&child->a, &child->ja, el->a, el->ja, child->r, child->jr, r, jr); + a -= child->a; + ja -= child->ja; + + scf_loge("j: %d, c%ldp%ld, v: %lg + j%lg, child->r: %lg + j%lg, child->a: %lg + j%lg\n\n", j, cp0->cid, cp0->id, + v, jv, child->r, child->jr, child->a, child->ja); + + cp0->a = child->a; + cp0->ja = child->ja; + double cr; double jcr; - v = p->v - p1->v; - jv = p->jv - p1->jv; - ses_ui_r(&cr, &jcr, v, jv, child->a, child->ja); for (k = 0; k < child->pins->size; k++) { @@ -106,6 +120,9 @@ static int __ses_path_va_diode(ScfEfunction* f, ses_path_t* path) } } + p->a = a; + p->ja = ja; + } else { v = p->v - p1->v; jv = p->jv - p1->jv; @@ -116,16 +133,14 @@ static int __ses_path_va_diode(ScfEfunction* f, ses_path_t* path) el->ja = ja; el->aconst = 1; } - } printf("\n"); return 0; } -static int _va_diode_handler(ScfEfunction* f, int64_t ns, int64_t count, ses_ctx_t* ctx) +static int _ses_path_va_diode(ScfEfunction* f, ses_path_t* path) { - ses_path_t* path; ScfEcomponent* B; ScfEpin* p0; ScfEpin* p1; @@ -136,27 +151,49 @@ static int _va_diode_handler(ScfEfunction* f, int64_t ns, int64_t count, ses_ctx size_t j; size_t k; + if (path->pins->size < 2) { + scf_loge("\n"); + return -EINVAL; + } + B = f->components[0]; Bp = B->pins[SCF_EDA_Battery_POS]; Bn = B->pins[SCF_EDA_Battery_NEG]; - for (i = 0; i < ctx->paths->size; i++) { - path = ctx->paths->data[i]; + p0 = path->pins->data[0]; + p1 = path->pins->data[path->pins->size - 1]; - scf_logi("i: %ld, path->type: %d\n", i, path->type); + if (p0->lid != Bp->lid || p1->lid != Bn->lid) + return 0; + + int ret = __ses_path_va_diode(f, path); + if (ret < 0) + return ret; + + if (path->childs) { + for (j = 0; j < path->childs->size; j++) { - if (path->pins->size < 2) { - scf_loge("\n"); - return -EINVAL; + ret = _ses_path_va_diode(f, path->childs->data[j]); + if (ret < 0) + return ret; } + } - p0 = path->pins->data[0]; - p1 = path->pins->data[path->pins->size - 1]; + return 0; +} - if (p0->lid != Bp->lid || p1->lid != Bn->lid) - continue; +static int _va_diode_handler(ScfEfunction* f, int64_t ns, int64_t count, ses_ctx_t* ctx) +{ + ses_path_t* path; + + size_t i; + + for (i = 0; i < ctx->paths->size; i++) { + path = ctx->paths->data[i]; + + scf_logi("i: %ld, path->type: %d\n", i, path->type); - int ret = __ses_path_va_diode(f, path); + int ret = _ses_path_va_diode(f, path); if (ret < 0) return ret; diff --git a/ses_step_va_transistor.c b/ses_step_va_transistor.c index f773d58..38118ed 100644 --- a/ses_step_va_transistor.c +++ b/ses_step_va_transistor.c @@ -86,7 +86,7 @@ static int _va_transistor_handler(ScfEfunction* f, int64_t ns, int64_t count, se B = f->components[0]; Bp = B->pins[SCF_EDA_Battery_POS]; Bn = B->pins[SCF_EDA_Battery_NEG]; - +#if 0 for (i = 0; i < ctx->paths->size; i++) { path = ctx->paths->data[i]; @@ -109,7 +109,7 @@ static int _va_transistor_handler(ScfEfunction* f, int64_t ns, int64_t count, se printf("\n"); } - +#endif return 0; }