From e4b1230e8819f452dfc5a93abca75bdebffa1fdb Mon Sep 17 00:00:00 2001 From: "yu.dongliang" <18588496441@163.com> Date: Thu, 7 Sep 2023 22:30:35 +0800 Subject: [PATCH] scf_eda.proto --- scf_eda.pb-c.c | 67 ++++++++++++++++++++++++++------------------ scf_eda.pb-c.h | 3 +- scf_eda.proto | 25 +++++++++-------- scf_eda_pb.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++++- scf_eda_pb.h | 15 ++++++++++ 5 files changed, 144 insertions(+), 41 deletions(-) diff --git a/scf_eda.pb-c.c b/scf_eda.pb-c.c index 3ab69bd..ff59055 100644 --- a/scf_eda.pb-c.c +++ b/scf_eda.pb-c.c @@ -385,7 +385,7 @@ const ProtobufCMessageDescriptor scf_line__descriptor = (ProtobufCMessageInit) scf_line__init, NULL,NULL,NULL /* reserved[123] */ }; -static const ProtobufCFieldDescriptor scf_epin__field_descriptors[26] = +static const ProtobufCFieldDescriptor scf_epin__field_descriptors[27] = { { "id", @@ -556,11 +556,23 @@ static const ProtobufCFieldDescriptor scf_epin__field_descriptors[26] = 0,NULL,NULL /* reserved1,reserved2, etc */ }, { - "dr", + "hfe", 15, PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_DOUBLE, 0, /* quantifier_offset */ + offsetof(ScfEpin, hfe), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "dr", + 16, + PROTOBUF_C_LABEL_REQUIRED, + PROTOBUF_C_TYPE_DOUBLE, + 0, /* quantifier_offset */ offsetof(ScfEpin, dr), NULL, NULL, @@ -569,7 +581,7 @@ static const ProtobufCFieldDescriptor scf_epin__field_descriptors[26] = }, { "jdr", - 16, + 17, PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_DOUBLE, 0, /* quantifier_offset */ @@ -581,7 +593,7 @@ static const ProtobufCFieldDescriptor scf_epin__field_descriptors[26] = }, { "sr", - 17, + 18, PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_DOUBLE, 0, /* quantifier_offset */ @@ -593,7 +605,7 @@ static const ProtobufCFieldDescriptor scf_epin__field_descriptors[26] = }, { "jsr", - 18, + 19, PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_DOUBLE, 0, /* quantifier_offset */ @@ -605,7 +617,7 @@ static const ProtobufCFieldDescriptor scf_epin__field_descriptors[26] = }, { "pr", - 19, + 20, PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_DOUBLE, 0, /* quantifier_offset */ @@ -617,7 +629,7 @@ static const ProtobufCFieldDescriptor scf_epin__field_descriptors[26] = }, { "jpr", - 20, + 21, PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_DOUBLE, 0, /* quantifier_offset */ @@ -629,7 +641,7 @@ static const ProtobufCFieldDescriptor scf_epin__field_descriptors[26] = }, { "x", - 21, + 22, PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_INT32, 0, /* quantifier_offset */ @@ -641,7 +653,7 @@ static const ProtobufCFieldDescriptor scf_epin__field_descriptors[26] = }, { "y", - 22, + 23, PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_INT32, 0, /* quantifier_offset */ @@ -653,7 +665,7 @@ static const ProtobufCFieldDescriptor scf_epin__field_descriptors[26] = }, { "vflag", - 23, + 24, PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_BOOL, 0, /* quantifier_offset */ @@ -665,7 +677,7 @@ static const ProtobufCFieldDescriptor scf_epin__field_descriptors[26] = }, { "pflag", - 24, + 25, PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_BOOL, 0, /* quantifier_offset */ @@ -677,7 +689,7 @@ static const ProtobufCFieldDescriptor scf_epin__field_descriptors[26] = }, { "vconst", - 25, + 26, PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_BOOL, 0, /* quantifier_offset */ @@ -689,7 +701,7 @@ static const ProtobufCFieldDescriptor scf_epin__field_descriptors[26] = }, { "aconst", - 26, + 27, PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_BOOL, 0, /* quantifier_offset */ @@ -702,36 +714,37 @@ static const ProtobufCFieldDescriptor scf_epin__field_descriptors[26] = }; static const unsigned scf_epin__field_indices_by_name[] = { 8, /* field[8] = a */ - 25, /* field[25] = aconst */ + 26, /* field[26] = aconst */ 5, /* field[5] = c_lid */ 1, /* field[1] = cid */ - 14, /* field[14] = dr */ + 15, /* field[15] = dr */ 3, /* field[3] = flags */ + 14, /* field[14] = hfe */ 0, /* field[0] = id */ 9, /* field[9] = ja */ - 15, /* field[15] = jdr */ - 19, /* field[19] = jpr */ + 16, /* field[16] = jdr */ + 20, /* field[20] = jpr */ 11, /* field[11] = jr */ - 17, /* field[17] = jsr */ + 18, /* field[18] = jsr */ 7, /* field[7] = jv */ 2, /* field[2] = lid */ - 23, /* field[23] = pflag */ - 18, /* field[18] = pr */ + 24, /* field[24] = pflag */ + 19, /* field[19] = pr */ 10, /* field[10] = r */ - 16, /* field[16] = sr */ + 17, /* field[17] = sr */ 4, /* field[4] = tos */ 12, /* field[12] = uF */ 13, /* field[13] = uH */ 6, /* field[6] = v */ - 24, /* field[24] = vconst */ - 22, /* field[22] = vflag */ - 20, /* field[20] = x */ - 21, /* field[21] = y */ + 25, /* field[25] = vconst */ + 23, /* field[23] = vflag */ + 21, /* field[21] = x */ + 22, /* field[22] = y */ }; static const ProtobufCIntRange scf_epin__number_ranges[1 + 1] = { { 1, 0 }, - { 0, 26 } + { 0, 27 } }; const ProtobufCMessageDescriptor scf_epin__descriptor = { @@ -741,7 +754,7 @@ const ProtobufCMessageDescriptor scf_epin__descriptor = "ScfEpin", "", sizeof(ScfEpin), - 26, + 27, scf_epin__field_descriptors, scf_epin__field_indices_by_name, 1, scf_epin__number_ranges, diff --git a/scf_eda.pb-c.h b/scf_eda.pb-c.h index ac1448f..db9998a 100644 --- a/scf_eda.pb-c.h +++ b/scf_eda.pb-c.h @@ -60,6 +60,7 @@ struct _ScfEpin double jr; double uf; double uh; + double hfe; double dr; double jdr; double sr; @@ -75,7 +76,7 @@ struct _ScfEpin }; #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, 0, 0, 0 } + , 0, 0, 0, 0, 0,NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } struct _ScfEconn diff --git a/scf_eda.proto b/scf_eda.proto index fb2091b..e4d6fd3 100644 --- a/scf_eda.proto +++ b/scf_eda.proto @@ -26,23 +26,24 @@ message scf_epin required double jr = 12; required double uF = 13; required double uH = 14; + required double hfe = 15; - required double dr = 15; - required double jdr = 16; + required double dr = 16; + required double jdr = 17; - required double sr = 17; - required double jsr = 18; + required double sr = 18; + required double jsr = 19; - required double pr = 19; - required double jpr = 20; + required double pr = 20; + required double jpr = 21; - required int32 x = 21; - required int32 y = 22; - required bool vflag = 23; - required bool pflag = 24; + required int32 x = 22; + required int32 y = 23; + required bool vflag = 24; + required bool pflag = 25; - required bool vconst = 25; - required bool aconst = 26; + required bool vconst = 26; + required bool aconst = 27; } message scf_econn diff --git a/scf_eda_pb.c b/scf_eda_pb.c index 044cfde..c5ec14c 100644 --- a/scf_eda_pb.c +++ b/scf_eda_pb.c @@ -14,6 +14,55 @@ static int component_pins[SCF_EDA_Components_NB] = SCF_EDA_Transistor_NB, }; +static scf_edata_t component_datas[] = +{ + {SCF_EDA_None, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {SCF_EDA_Battery, 0, SCF_EDA_Battery_POS, 0, 0, 0, 0, 0, 0, 0}, + + {SCF_EDA_Resistor, 0, 0, 0, 0, 10 * 1000, 0, 0, 0, 0}, + {SCF_EDA_Capacitor, 0, 0, 0, 0, 0, 0, 0.1, 0, 0}, + {SCF_EDA_Inductor, 0, 0, 0, 0, 0, 0, 0, 1000, 0}, +}; + +static scf_edata_t pin_datas[] = +{ + {SCF_EDA_None, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + + {SCF_EDA_Diode, 0, SCF_EDA_Diode_NEG, 0, 0, 750, 0, 0, 0, 0}, + {SCF_EDA_Transistor, 0, SCF_EDA_Transistor_B, 0, 0, 750, 0, 0, 0, 0}, + {SCF_EDA_Transistor, 0, SCF_EDA_Transistor_C, 0, 0, 750, 0, 0, 0, 100}, +}; + +static scf_edata_t* _pin_find_data(const uint64_t type, const uint64_t model, const uint64_t pid) +{ + scf_edata_t* ed; + + int i; + for (i = 0; i < sizeof(pin_datas) / sizeof(pin_datas[0]); i++) { + ed = &pin_datas[i]; + + if (ed->type == type && ed->model == model && ed->pid == pid) + return ed; + } + + return NULL; +} + +static scf_edata_t* _component_find_data(const uint64_t type, const uint64_t model) +{ + scf_edata_t* ed; + + int i; + for (i = 0; i < sizeof(component_datas) / sizeof(component_datas[0]); i++) { + ed = &component_datas[i]; + + if (ed->type == type && ed->model == model) + return ed; + } + + return NULL; +} + ScfEconn* scf_econn__alloc() { ScfEconn* ec = malloc(sizeof(ScfEconn)); @@ -344,10 +393,13 @@ void scf_epin__free(ScfEpin* pin) ScfEcomponent* scf_ecomponent__alloc(uint64_t type) { + ScfEcomponent* c; + scf_edata_t* ed; + if (type >= SCF_EDA_Components_NB) return NULL; - ScfEcomponent* c = malloc(sizeof(ScfEcomponent)); + c = malloc(sizeof(ScfEcomponent)); if (!c) return NULL; @@ -355,6 +407,16 @@ ScfEcomponent* scf_ecomponent__alloc(uint64_t type) c->type = type; + ed = _component_find_data(c->type, c->model); + if (ed) { + c->v = ed->v; + c->a = ed->a; + c->r = ed->r; + c->jr = ed->jr; + c->uf = ed->uf; + c->uh = ed->uh; + } + int i; for (i = 0; i < component_pins[type]; i++) { @@ -371,6 +433,17 @@ ScfEcomponent* scf_ecomponent__alloc(uint64_t type) scf_epin__free(pin); return NULL; } + + ed = _pin_find_data(c->type, c->model, pin->id); + if (ed) { + pin->v = ed->v; + pin->a = ed->a; + pin->r = ed->r; + pin->jr = ed->jr; + pin->uf = ed->uf; + pin->uh = ed->uh; + pin->hfe = ed->hfe; + } } return c; diff --git a/scf_eda_pb.h b/scf_eda_pb.h index 75e92a3..8f2aecf 100644 --- a/scf_eda_pb.h +++ b/scf_eda_pb.h @@ -53,6 +53,21 @@ enum { SCF_EDA_Transistor_NB, }; +typedef struct { + uint64_t type; + uint64_t model; + uint64_t pid; + + double v; + double a; + double r; + double jr; + double uf; + double uh; + double hfe; +} scf_edata_t; + + ScfEconn* scf_econn__alloc(); int scf_econn__add_cid(ScfEconn* ec, uint64_t cid); int scf_econn__del_cid(ScfEconn* ec, uint64_t cid); -- 2.25.1