(ProtobufCMessageInit) scf_line__init,
NULL,NULL,NULL /* reserved[123] */
};
-static const ProtobufCFieldDescriptor scf_epin__field_descriptors[18] =
+static const ProtobufCFieldDescriptor scf_epin__field_descriptors[20] =
{
{
"id",
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
- "V",
+ "v",
7,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_DOUBLE,
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
- "A",
+ "jv",
8,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_DOUBLE,
0, /* quantifier_offset */
- offsetof(ScfEpin, a),
+ offsetof(ScfEpin, jv),
NULL,
NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
- "R",
+ "a",
9,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_DOUBLE,
0, /* quantifier_offset */
- offsetof(ScfEpin, r),
+ offsetof(ScfEpin, a),
NULL,
NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
- "jR",
+ "ja",
10,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_DOUBLE,
0, /* quantifier_offset */
+ offsetof(ScfEpin, ja),
+ NULL,
+ NULL,
+ 0, /* flags */
+ 0,NULL,NULL /* reserved1,reserved2, etc */
+ },
+ {
+ "r",
+ 11,
+ PROTOBUF_C_LABEL_REQUIRED,
+ PROTOBUF_C_TYPE_DOUBLE,
+ 0, /* quantifier_offset */
+ offsetof(ScfEpin, r),
+ NULL,
+ NULL,
+ 0, /* flags */
+ 0,NULL,NULL /* reserved1,reserved2, etc */
+ },
+ {
+ "jr",
+ 12,
+ PROTOBUF_C_LABEL_REQUIRED,
+ PROTOBUF_C_TYPE_DOUBLE,
+ 0, /* quantifier_offset */
offsetof(ScfEpin, jr),
NULL,
NULL,
},
{
"uF",
- 11,
+ 13,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_DOUBLE,
0, /* quantifier_offset */
},
{
"uH",
- 12,
+ 14,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_DOUBLE,
0, /* quantifier_offset */
},
{
"tr",
- 13,
+ 15,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_DOUBLE,
0, /* quantifier_offset */
},
{
"jtr",
- 14,
+ 16,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_DOUBLE,
0, /* quantifier_offset */
},
{
"x",
- 15,
+ 17,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_INT32,
0, /* quantifier_offset */
},
{
"y",
- 16,
+ 18,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_INT32,
0, /* quantifier_offset */
},
{
"vflag",
- 17,
+ 19,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_BOOL,
0, /* quantifier_offset */
},
{
"pflag",
- 18,
+ 20,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_BOOL,
0, /* quantifier_offset */
},
};
static const unsigned scf_epin__field_indices_by_name[] = {
- 7, /* field[7] = A */
- 8, /* field[8] = R */
- 6, /* field[6] = V */
+ 8, /* field[8] = a */
5, /* field[5] = c_lid */
1, /* field[1] = cid */
3, /* field[3] = flags */
0, /* field[0] = id */
- 9, /* field[9] = jR */
- 13, /* field[13] = jtr */
+ 9, /* field[9] = ja */
+ 11, /* field[11] = jr */
+ 15, /* field[15] = jtr */
+ 7, /* field[7] = jv */
2, /* field[2] = lid */
- 17, /* field[17] = pflag */
+ 19, /* field[19] = pflag */
+ 10, /* field[10] = r */
4, /* field[4] = tos */
- 12, /* field[12] = tr */
- 10, /* field[10] = uF */
- 11, /* field[11] = uH */
- 16, /* field[16] = vflag */
- 14, /* field[14] = x */
- 15, /* field[15] = y */
+ 14, /* field[14] = tr */
+ 12, /* field[12] = uF */
+ 13, /* field[13] = uH */
+ 6, /* field[6] = v */
+ 18, /* field[18] = vflag */
+ 16, /* field[16] = x */
+ 17, /* field[17] = y */
};
static const ProtobufCIntRange scf_epin__number_ranges[1 + 1] =
{
{ 1, 0 },
- { 0, 18 }
+ { 0, 20 }
};
const ProtobufCMessageDescriptor scf_epin__descriptor =
{
"ScfEpin",
"",
sizeof(ScfEpin),
- 18,
+ 20,
scf_epin__field_descriptors,
scf_epin__field_indices_by_name,
1, scf_epin__number_ranges,
(ProtobufCMessageInit) scf_econn__init,
NULL,NULL,NULL /* reserved[123] */
};
-static const ProtobufCFieldDescriptor scf_eline__field_descriptors[10] =
+static const ProtobufCFieldDescriptor scf_eline__field_descriptors[12] =
{
{
"id",
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
- "V",
+ "v",
8,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_DOUBLE,
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
- "A",
+ "jv",
9,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_DOUBLE,
0, /* quantifier_offset */
+ offsetof(ScfEline, jv),
+ NULL,
+ NULL,
+ 0, /* flags */
+ 0,NULL,NULL /* reserved1,reserved2, etc */
+ },
+ {
+ "a",
+ 10,
+ PROTOBUF_C_LABEL_REQUIRED,
+ PROTOBUF_C_TYPE_DOUBLE,
+ 0, /* quantifier_offset */
offsetof(ScfEline, a),
NULL,
NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
+ {
+ "ja",
+ 11,
+ PROTOBUF_C_LABEL_REQUIRED,
+ PROTOBUF_C_TYPE_DOUBLE,
+ 0, /* quantifier_offset */
+ offsetof(ScfEline, ja),
+ NULL,
+ NULL,
+ 0, /* flags */
+ 0,NULL,NULL /* reserved1,reserved2, etc */
+ },
{
"vflag",
- 10,
+ 12,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_BOOL,
0, /* quantifier_offset */
},
};
static const unsigned scf_eline__field_indices_by_name[] = {
- 8, /* field[8] = A */
- 7, /* field[7] = V */
+ 9, /* field[9] = a */
2, /* field[2] = c_pins */
5, /* field[5] = conns */
4, /* field[4] = dfo */
3, /* field[3] = flags */
0, /* field[0] = id */
+ 10, /* field[10] = ja */
+ 8, /* field[8] = jv */
6, /* field[6] = lines */
1, /* field[1] = pins */
- 9, /* field[9] = vflag */
+ 7, /* field[7] = v */
+ 11, /* field[11] = vflag */
};
static const ProtobufCIntRange scf_eline__number_ranges[1 + 1] =
{
{ 1, 0 },
- { 0, 10 }
+ { 0, 12 }
};
const ProtobufCMessageDescriptor scf_eline__descriptor =
{
"ScfEline",
"",
sizeof(ScfEline),
- 10,
+ 12,
scf_eline__field_descriptors,
scf_eline__field_indices_by_name,
1, scf_eline__number_ranges,
(ProtobufCMessageInit) scf_eline__init,
NULL,NULL,NULL /* reserved[123] */
};
-static const ProtobufCFieldDescriptor scf_ecomponent__field_descriptors[17] =
+static const ProtobufCFieldDescriptor scf_ecomponent__field_descriptors[19] =
{
{
"id",
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
- "V",
+ "v",
5,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_DOUBLE,
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
- "A",
+ "jv",
6,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_DOUBLE,
0, /* quantifier_offset */
- offsetof(ScfEcomponent, a),
+ offsetof(ScfEcomponent, jv),
NULL,
NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
- "R",
+ "a",
7,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_DOUBLE,
0, /* quantifier_offset */
- offsetof(ScfEcomponent, r),
+ offsetof(ScfEcomponent, a),
NULL,
NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
- "jR",
+ "ja",
8,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_DOUBLE,
0, /* quantifier_offset */
+ offsetof(ScfEcomponent, ja),
+ NULL,
+ NULL,
+ 0, /* flags */
+ 0,NULL,NULL /* reserved1,reserved2, etc */
+ },
+ {
+ "r",
+ 9,
+ PROTOBUF_C_LABEL_REQUIRED,
+ PROTOBUF_C_TYPE_DOUBLE,
+ 0, /* quantifier_offset */
+ offsetof(ScfEcomponent, r),
+ NULL,
+ NULL,
+ 0, /* flags */
+ 0,NULL,NULL /* reserved1,reserved2, etc */
+ },
+ {
+ "jr",
+ 10,
+ PROTOBUF_C_LABEL_REQUIRED,
+ PROTOBUF_C_TYPE_DOUBLE,
+ 0, /* quantifier_offset */
offsetof(ScfEcomponent, jr),
NULL,
NULL,
},
{
"uF",
- 9,
+ 11,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_DOUBLE,
0, /* quantifier_offset */
},
{
"uH",
- 10,
+ 12,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_DOUBLE,
0, /* quantifier_offset */
},
{
"dfo",
- 11,
+ 13,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_INT64,
0, /* quantifier_offset */
},
{
"status",
- 12,
+ 14,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_INT32,
0, /* quantifier_offset */
},
{
"x",
- 13,
+ 15,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_INT32,
0, /* quantifier_offset */
},
{
"y",
- 14,
+ 16,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_INT32,
0, /* quantifier_offset */
},
{
"w",
- 15,
+ 17,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_INT32,
0, /* quantifier_offset */
},
{
"h",
- 16,
+ 18,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_INT32,
0, /* quantifier_offset */
},
{
"vflag",
- 17,
+ 19,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_BOOL,
0, /* quantifier_offset */
},
};
static const unsigned scf_ecomponent__field_indices_by_name[] = {
- 5, /* field[5] = A */
- 6, /* field[6] = R */
- 4, /* field[4] = V */
- 10, /* field[10] = dfo */
- 15, /* field[15] = h */
+ 6, /* field[6] = a */
+ 12, /* field[12] = dfo */
+ 17, /* field[17] = h */
0, /* field[0] = id */
- 7, /* field[7] = jR */
+ 7, /* field[7] = ja */
+ 9, /* field[9] = jr */
+ 5, /* field[5] = jv */
2, /* field[2] = model */
3, /* field[3] = pins */
- 11, /* field[11] = status */
+ 8, /* field[8] = r */
+ 13, /* field[13] = status */
1, /* field[1] = type */
- 8, /* field[8] = uF */
- 9, /* field[9] = uH */
- 16, /* field[16] = vflag */
- 14, /* field[14] = w */
- 12, /* field[12] = x */
- 13, /* field[13] = y */
+ 10, /* field[10] = uF */
+ 11, /* field[11] = uH */
+ 4, /* field[4] = v */
+ 18, /* field[18] = vflag */
+ 16, /* field[16] = w */
+ 14, /* field[14] = x */
+ 15, /* field[15] = y */
};
static const ProtobufCIntRange scf_ecomponent__number_ranges[1 + 1] =
{
{ 1, 0 },
- { 0, 17 }
+ { 0, 19 }
};
const ProtobufCMessageDescriptor scf_ecomponent__descriptor =
{
"ScfEcomponent",
"",
sizeof(ScfEcomponent),
- 17,
+ 19,
scf_ecomponent__field_descriptors,
scf_ecomponent__field_indices_by_name,
1, scf_ecomponent__number_ranges,
uint64_t *tos;
uint64_t c_lid;
double v;
+ double jv;
double a;
+ double ja;
double r;
double jr;
double uf;
};
#define SCF_EPIN__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&scf_epin__descriptor) \
- , 0, 0, 0, 0, 0,NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
+ , 0, 0, 0, 0, 0,NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
struct _ScfEconn
size_t n_lines;
ScfLine **lines;
double v;
+ double jv;
double a;
+ double ja;
protobuf_c_boolean vflag;
};
#define SCF_ELINE__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&scf_eline__descriptor) \
- , 0, 0,NULL, 0, 0, 0, 0,NULL, 0,NULL, 0, 0, 0 }
+ , 0, 0,NULL, 0, 0, 0, 0,NULL, 0,NULL, 0, 0, 0, 0, 0 }
struct _ScfEcomponent
size_t n_pins;
ScfEpin **pins;
double v;
+ double jv;
double a;
+ double ja;
double r;
double jr;
double uf;
};
#define SCF_ECOMPONENT__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&scf_ecomponent__descriptor) \
- , 0, 0, 0, 0,NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
+ , 0, 0, 0, 0,NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
struct _ScfEfunction
int _ses_path_cmp(const void* v0, const void* v1);
-int __ses_path_jr(ScfEfunction* f, ses_path_t* path)
+static int __ses_path_jr(ScfEfunction* f, ses_path_t* path)
{
if (!path)
return -EINVAL;
return 0;
}
+static int __ses_path_va(ScfEfunction* f, ses_path_t* path)
+{
+ if (!path)
+ return -EINVAL;
+
+ if (path->pins->size < 2) {
+ scf_loge("\n");
+ return -EINVAL;
+ }
+
+ ses_path_t* child;
+ ScfEcomponent* c;
+ ScfEpin* p;
+ ScfEpin* p0;
+ ScfEpin* p1;
+ ScfEpin* cp0;
+ ScfEpin* cp1;
+
+ double R;
+ double r;
+ double jr;
+
+ int i;
+ int j;
+
+ r = 0;
+ jr = 0;
+
+ for (i = 0; i < path->pins->size; i++) {
+ p = path->pins->data[i];
+ scf_loge("i: %d, c%ldp%ld, p->tr: %lg, p->jtr: %lg\n", i, p->cid, p->id, p->tr, p->jtr);
+ }
+ printf("\n");
+
+ if (path->childs) {
+
+ scf_vector_qsort(path->childs, _ses_path_cmp);
+
+ for (i = path->childs->size - 1; i >= 0; i--) {
+ child = path->childs->data[i];
+
+ if (child->pins->size < 2) {
+ scf_loge("\n");
+ return -EINVAL;
+ }
+
+ int ret = __ses_path_jr(f, child);
+ if (ret < 0)
+ return ret;
+
+ }
+ }
+
+ p = path->pins->data[path->pins->size - 1];
+
+ path->r = p->tr;
+ path->jr = p->jtr;
+
+ scf_loge("path: %d, r: %lg, jr: %lg, r0: %lg, jr0: %lg\n",
+ path->index, path->r, path->jr, path->r0, path->jr0);
+ return 0;
+}
+
static int _va_handler(ScfEfunction* f, int64_t ns, int64_t count, ses_ctx_t* ctx)
{
- ses_path_t* path;
- ScfEcomponent* c;
- ScfEcomponent* B;
- ScfEline* el;
- ScfEpin* p;
+ ses_path_t* path;
+ ScfEcomponent* c;
+ ScfEcomponent* B;
+ ScfEline* el;
+ ScfEpin* p0;
+ ScfEpin* p1;
+ ScfEpin* Bp;
+ ScfEpin* Bn;
size_t i;
size_t j;
size_t k;
- B = f->components[0];
-
for (i = 0; i < ctx->paths->size; i++) {
path = ctx->paths->data[i];
printf("\n");
}
+ 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];
+
+ scf_logi("i: %ld, path->type: %d\n", i, path->type);
+
+ if (path->pins->size < 2) {
+ scf_loge("\n");
+ return -EINVAL;
+ }
+
+ p0 = path->pins->data[0];
+ p1 = path->pins->data[path->pins->size - 1];
+
+ if (p0->lid != Bp->lid || p1->lid != Bn->lid)
+ continue;
+
+ double v = Bp->v - Bn->v;
+
+ double R = path->r * path->r + path->jr * path->jr;
+
+ double a = v * path->r / R;
+ double ja = -v * path->jr / R;
+
+ for (i = 0; i < path->pins->size; i++) {
+// p = path->pins->data[i];
+// scf_loge("i: %d, c%ldp%ld, p->tr: %lg, p->jtr: %lg\n", i, p->cid, p->id, p->tr, p->jtr);
+ }
+
+
+ int ret = __ses_path_va(f, path);
+ if (ret < 0)
+ return ret;
+
+ printf("\n");
+ }
+#endif
return 0;
}