From 30102a15a65e2a7c229c246e6fe41b0441e6a439 Mon Sep 17 00:00:00 2001 From: "yu.dongliang" <18588496441@163.com> Date: Thu, 20 Jul 2023 11:49:44 +0800 Subject: [PATCH] ses_step_dc_diode.c --- scf_eda_pb.h | 5 +++++ ses_layout.c | 2 +- ses_step_battery.c | 4 ++-- ses_step_dc_diode.c | 16 +++++++++++++++- 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/scf_eda_pb.h b/scf_eda_pb.h index 16aeafc..0a30f52 100644 --- a/scf_eda_pb.h +++ b/scf_eda_pb.h @@ -35,6 +35,11 @@ enum { SCF_EDA_Diode_NB, }; +enum { + SCF_EDA_Status_ON, + SCF_EDA_Status_OFF, +}; + enum { SCF_EDA_Transistor_B, SCF_EDA_Transistor_E, diff --git a/ses_layout.c b/ses_layout.c index eeebc8c..7cdc524 100644 --- a/ses_layout.c +++ b/ses_layout.c @@ -980,7 +980,7 @@ int ses_layout_board(ScfEboard* b) return ret; } - ses_steps_analyse(f, 5, 5); + ses_steps_analyse(f, 5, 1); x = f->x; y = f->y; diff --git a/ses_step_battery.c b/ses_step_battery.c index 8bdf125..2357bc6 100644 --- a/ses_step_battery.c +++ b/ses_step_battery.c @@ -11,11 +11,11 @@ static int _battery_handler(ScfEfunction* f, int64_t ns, int64_t count) size_t k; c = f->components[0]; - c->v = 5; + c->v = 6; p = c->pins[SCF_EDA_Battery_POS]; el = f->elines[p->lid]; - el->v = 5; + el->v = 6; p = c->pins[SCF_EDA_Battery_NEG]; el = f->elines[p->lid]; diff --git a/ses_step_dc_diode.c b/ses_step_dc_diode.c index 78506b5..245af84 100644 --- a/ses_step_dc_diode.c +++ b/ses_step_dc_diode.c @@ -5,7 +5,8 @@ static int _dc_diode_handler(ScfEfunction* f, int64_t ns, int64_t count) ScfEcomponent* c; ScfEcomponent* B; ScfEline* el; - ScfEpin* p; + ScfEpin* p0; + ScfEpin* p1; size_t i; size_t j; @@ -27,6 +28,19 @@ static int _dc_diode_handler(ScfEfunction* f, int64_t ns, int64_t count) if (SCF_EDA_Diode != c->type) continue; + p0 = c->pins[ el->pins[j + 1]]; + p1 = c->pins[!p0->id]; + p0->v = el->v; + + if (SCF_EDA_Diode_NEG == p0->id) + p1->v = p0->v + 0.7; + else + p1->v = p0->v - 0.7; + + if (p1->v > B->v || p1->v < 0) + c->status = SCF_EDA_Status_OFF; + + scf_loge("Diode c%ld, status: %d\n", c->id, c->status); } } -- 2.25.1