From adac51154a80722c3df99fdf7da328bd3b6efa59 Mon Sep 17 00:00:00 2001 From: "yu.dongliang" <18588496441@163.com> Date: Thu, 20 Jul 2023 10:32:20 +0800 Subject: [PATCH] ses_step_battery.c --- ses_core.h | 2 +- ses_step_battery.c | 33 +++++++++++++++++++++++++++++++++ ses_step_dc_input.c | 30 ++++++++++++++++++++++++++++-- ses_steps.c | 7 +++++-- 4 files changed, 67 insertions(+), 5 deletions(-) create mode 100644 ses_step_battery.c diff --git a/ses_core.h b/ses_core.h index ca83fd2..1f28f05 100644 --- a/ses_core.h +++ b/ses_core.h @@ -44,6 +44,6 @@ int ses_layout_board (ScfEboard* b); int ses_loop_function(ScfEfunction* f, scf_vector_t* loops); -int ses_analyse_function(ScfEfunction* f, int64_t ns, int64_t count); +int ses_steps_analyse(ScfEfunction* f, int64_t ns, int64_t count); #endif diff --git a/ses_step_battery.c b/ses_step_battery.c new file mode 100644 index 0000000..b8256b6 --- /dev/null +++ b/ses_step_battery.c @@ -0,0 +1,33 @@ +#include"ses_core.h" + +static int _battery_handler(ScfEfunction* f, int64_t ns, int64_t count) +{ + ScfEcomponent* c; + ScfEfunction* f; + ScfEline* el; + ScfEpin* p; + + size_t i; + size_t j; + size_t k; + + c = f->components[0]; + c->V = 5; + + p = c->pins[SCF_EDA_Battery_POS]; + el = f->elines[p->lid]; + el->V = 5; + + p = c->pins[SCF_EDA_Battery_NEG]; + el = f->elines[p->lid]; + el->V = 0; + + return 0; +} + +ses_step_t ses_step_battery = +{ + .name = "battery", + + .handler = _battery_handler, +}; diff --git a/ses_step_dc_input.c b/ses_step_dc_input.c index d52f2c5..f27e1f3 100644 --- a/ses_step_dc_input.c +++ b/ses_step_dc_input.c @@ -1,8 +1,34 @@ #include"ses_core.h" +static int _dc_input_handler(ScfEfunction* f, int64_t ns, int64_t count) +{ + ScfEcomponent* c; + ScfEfunction* f; + ScfEline* el; + ScfEpin* p; + + size_t i; + size_t j; + size_t k; + + for (i = 0; i < f->n_elines; i++) { + el = f->elines[i]; + + 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_PIN_IN & p->flags) { + } + } + } + +} -ses_step_t ses_step_dc_input = +ses_step_t ses_step_dc_input = { - .name = "dc_input", + .name = "dc_input", + .handler = _dc_input_handler, }; diff --git a/ses_steps.c b/ses_steps.c index 4e1b1f9..05ae5bc 100644 --- a/ses_steps.c +++ b/ses_steps.c @@ -1,5 +1,7 @@ #include"ses_core.h" +extern ses_step_t ses_step_battery; + extern ses_step_t ses_step_dc_input; //extern ses_step_t ses_step_ac_start; @@ -18,8 +20,9 @@ extern ses_step_t ses_step_output; static ses_step_t* ses_steps[] = { - &ses_step_dc_input, + &ses_step_battery, + &ses_step_dc_input, &ses_step_dc_diode, &ses_step_dc_transistor, @@ -31,7 +34,7 @@ static ses_step_t* ses_steps[] = }; -int ses_analyse_function(ScfEfunction* f, int64_t ns, int64_t count) +int ses_steps_analyse(ScfEfunction* f, int64_t ns, int64_t count) { if (!f || ns <= 0 || count < 0) return -EINVAL; -- 2.25.1