(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",
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,
},
{
"jdr",
- 16,
+ 17,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_DOUBLE,
0, /* quantifier_offset */
},
{
"sr",
- 17,
+ 18,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_DOUBLE,
0, /* quantifier_offset */
},
{
"jsr",
- 18,
+ 19,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_DOUBLE,
0, /* quantifier_offset */
},
{
"pr",
- 19,
+ 20,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_DOUBLE,
0, /* quantifier_offset */
},
{
"jpr",
- 20,
+ 21,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_DOUBLE,
0, /* quantifier_offset */
},
{
"x",
- 21,
+ 22,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_INT32,
0, /* quantifier_offset */
},
{
"y",
- 22,
+ 23,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_INT32,
0, /* quantifier_offset */
},
{
"vflag",
- 23,
+ 24,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_BOOL,
0, /* quantifier_offset */
},
{
"pflag",
- 24,
+ 25,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_BOOL,
0, /* quantifier_offset */
},
{
"vconst",
- 25,
+ 26,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_BOOL,
0, /* quantifier_offset */
},
{
"aconst",
- 26,
+ 27,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_BOOL,
0, /* quantifier_offset */
};
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 =
{
"ScfEpin",
"",
sizeof(ScfEpin),
- 26,
+ 27,
scf_epin__field_descriptors,
scf_epin__field_indices_by_name,
1, scf_epin__number_ranges,
double jr;
double uf;
double uh;
+ double hfe;
double dr;
double jdr;
double sr;
};
#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
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
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));
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;
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++) {
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;
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);