#include"ses_core.h"
+int __ses_path_jr(ses_path_t* path)
+{
+ if (!path)
+ return -EINVAL;
+
+ ses_path_t* child;
+ ScfEpin* p;
+
+ int i;
+
+ path->r0 = 0;
+ path->jr0 = 0;
+
+ for (i = 0; i < path->pins->size; i++) {
+ p = path->pins->data[i];
+
+ path->r0 += p->r;
+ path->jr0 += p->jr;
+ }
+
+ double R = path->r0 * path->r0 + path->jr0 * path->jr0;
+ double r = path->r0 / R;
+ double jr = -path->jr0 / R;
+
+ scf_loge("path: %d, r0: %lg, jr0: %lg, r: %lg, jr: %lg\n", path->index, path->r0, path->jr0, r, jr);
+
+ if (path->childs) {
+ for (i = 0; i < path->childs->size; i++) {
+ child = path->childs->data[i];
+
+ int ret = __ses_path_jr(child);
+ if (ret < 0)
+ return ret;
+
+ R = child->r * child->r + child->jr * child->jr;
+
+ double _r = child->r / R;
+ double _jr = -child->jr / R;
+
+ r += _r;
+ jr += _jr;
+
+ scf_loge("child: %d, r: %lg, jr: %lg, r0: %lg, jr0: %lg, _r: %lg, _jr: %lg\n\n",
+ child->index, child->r, child->jr, child->r0, child->jr0, _r, _jr);
+ }
+ }
+
+ R = r * r + jr * jr;
+ r = r / R;
+ jr = -jr / R;
+
+ path->r = r;
+ path->jr = jr;
+
+ 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;
- ScfEline* el2;
- ScfEline* elp;
- ScfEline* eln;
ScfEpin* p;
size_t i;
B = f->components[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);
+
+ int ret = __ses_path_jr(path);
+ if (ret < 0)
+ return ret;
+
+ printf("\n");
+ }
+
return 0;
}