From: yu.dongliang <18588496441@163.com>
Date: Mon, 23 Oct 2023 14:20:33 +0000 (+0800)
Subject: __ses_status_check()
X-Git-Url: http://baseworks.info/?a=commitdiff_plain;h=9e315ee6cdbdb751a23c8ff90557d36ac98b5199;p=ses.git

__ses_status_check()
---

diff --git a/ses_step_va_transistor.c b/ses_step_va_transistor.c
index ec93c57..07c054f 100644
--- a/ses_step_va_transistor.c
+++ b/ses_step_va_transistor.c
@@ -25,6 +25,7 @@ void __ses_path_dr_transistor(ScfEfunction* f, ses_path_t* path, int i, int j)
 int __ses_status_check(ScfEfunction* f, ScfEcomponent* c, ScfEpin* pb, ScfEpin* pe)
 {
 	ScfEcomponent* B  = f->components[0];
+	ScfEpin*       Bp = B->pins[SCF_EDA_Battery_POS];
 	ScfEpin*       Bn = B->pins[SCF_EDA_Battery_NEG];
 
 	double DV = SCF_EDA_V_NPN_OFF;
@@ -35,7 +36,23 @@ int __ses_status_check(ScfEfunction* f, ScfEcomponent* c, ScfEpin* pb, ScfEpin*
 	pb->v = f->elines[pb->lid]->v;
 	pe->v = f->elines[pe->lid]->v;
 
-	if (pe->v < SCF_EDA_V_MIN) {
+	if (pb->v < SCF_EDA_V_MIN) {
+
+		if (pe->v < SCF_EDA_V_MIN)
+			return 0;
+
+		pb->v = pe->v + DV;
+
+		if (pb->v > Bp->v) {
+			pb->v = Bp->v;
+			c->status = SCF_EDA_Status_OFF;
+		} else
+			c->status = SCF_EDA_Status_ON;
+
+		scf_loge("\033[34mc%ld, status: %d\033[0m\n", c->id, c->status);
+		return 1;
+
+	} else if (pe->v < SCF_EDA_V_MIN) {
 		pe->v = pb->v - DV;
 
 		if (pe->v < Bn->v) {