#define SCF_EDA_PIN_POS 4
#define SCF_EDA_PIN_NEG 8
+#define SCF_EDA_V_INIT -10001001.0
+#define SCF_EDA_V_MIN -10000000.0
+#define SCF_EDA_V_MAX 10000000.0
+
enum {
SCF_EDA_Battery_NEG,
SCF_EDA_Battery_POS,
ScfEpin* p;
size_t i;
- size_t j;
- size_t k;
+
+ for (i = 0; i < f->n_elines; i++) {
+ el = f->elines[i];
+ el->v = SCF_EDA_V_INIT;
+ }
c = f->components[0];
c->v = 6;
p = c->pins[SCF_EDA_Battery_POS];
+ p->v = 6;
el = f->elines[p->lid];
el->v = 6;
p = c->pins[SCF_EDA_Battery_NEG];
+ p ->v = 0;
el = f->elines[p->lid];
el->v = 0;
ScfEcomponent* c;
ScfEcomponent* B;
ScfEline* el;
+ ScfEline* el1;
ScfEpin* p0;
ScfEpin* p1;
size_t k;
B = f->components[0];
- k = 0;
for (i = 0; i < f->n_elines; i++) {
el = f->elines[i];
if (p1->v > B->v || p1->v < 0)
c->status = SCF_EDA_Status_OFF;
+ else {
+ el1 = f->elines[p1->lid];
+
+ if (el1->v < SCF_EDA_V_MIN || el1->v > p1->v) {
+ el1->v = p1->v;
+ c->status = SCF_EDA_Status_ON;
+ } else
+ c->status = SCF_EDA_Status_OFF;
+ }
+
scf_loge("Diode c%ld, status: %d\n", c->id, c->status);
}
}
#include"ses_core.h"
+static int _dc_transistor_handler(ScfEfunction* f, int64_t ns, int64_t count)
+{
+ ScfEcomponent* c;
+ ScfEcomponent* B;
+ ScfEline* el;
+ ScfEpin* pb;
+ ScfEpin* pc;
+ ScfEpin* pe;
+
+ size_t i;
+ size_t j;
+ size_t k;
+
+ B = f->components[0];
+
+ for (i = 0; i < f->n_components; i++) {
+ c = f->components[i];
+
+ if (SCF_EDA_Transistor != c->type)
+ continue;
+
+ pb = c->pins[SCF_EDA_Transistor_B];
+ pc = c->pins[SCF_EDA_Transistor_C];
+ pe = c->pins[SCF_EDA_Transistor_E];
+
+ el = f->elines[pe->lid];
+ if (el->v < SCF_EDA_V_MIN)
+ continue;
+ pe->v = el->v;
+
+ el = f->elines[pb->lid];
+ if (el->v < SCF_EDA_V_MIN)
+ continue;
+ pb->v = el->v;
+
+ if (pb->v > pe->v + 0.7) {
+ pb->v = pe->v + 0.7;
+ el->v = pb->v;
+
+ c->status = SCF_EDA_Status_ON;
+ } else
+ c->status = SCF_EDA_Status_OFF;
+
+ scf_loge("Transistor c%ld, status: %d\n", c->id, c->status);
+ }
+
+ return 0;
+}
-ses_step_t ses_step_dc_transistor =
+ses_step_t ses_step_dc_transistor =
{
- .name = "dc_transistor",
+ .name = "dc_transistor",
+ .handler = _dc_transistor_handler,
};