Index: trunk/src_plugins/export_openems/export_openems.c =================================================================== --- trunk/src_plugins/export_openems/export_openems.c (revision 32009) +++ trunk/src_plugins/export_openems/export_openems.c (revision 32010) @@ -63,6 +63,7 @@ #define PRIO_SUBSTRATE 1 #define PRIO_COPPER 2 +#define PRIO_PORT 999 typedef struct rnd_hid_gc_s { rnd_core_gc_t core_gc; @@ -378,6 +379,8 @@ fprintf(ctx->f, "[CSX, port{%ld}] = AddLumpedPort(CSX, 999, %ld, %f, start%s, stop%s, [0 0 -1]%s);\n", ctx->port_id, ctx->port_id, resistance, safe_name, safe_name, act ? ", true" : ""); } +static void openems_wr_xml_vport(wctx_t *ctx, pcb_any_obj_t *o, rnd_coord_t x, rnd_coord_t y, rnd_layergrp_id_t gid1, rnd_layergrp_id_t gid2, const char *safe_name, double resistance, int act); + static void openems_vport_write(wctx_t *ctx, pcb_any_obj_t *o, rnd_coord_t x, rnd_coord_t y, rnd_layergrp_id_t gid1, rnd_layergrp_id_t gid2, const char *port_name) { char *end, *s, *safe_name = rnd_strdup(port_name); @@ -410,8 +413,8 @@ if (ctx->fmt_matlab) openems_wr_m_vport(ctx, o, x, y, gid1, gid2, safe_name, resistance, act); -/* else - openems_wr_xml_vport(ctx, o, x, y, gid1, gid2, safe_name, resistance, act);*/ + else + openems_wr_xml_vport(ctx, o, x, y, gid1, gid2, safe_name, resistance, act); free(safe_name); } Index: trunk/src_plugins/export_openems/openems_xml.c =================================================================== --- trunk/src_plugins/export_openems/openems_xml.c (revision 32009) +++ trunk/src_plugins/export_openems/openems_xml.c (revision 32010) @@ -31,6 +31,7 @@ TODO("remove this once the function is moved and published in core") extern const char *pcb_layergrp_thickness_attr(pcb_layergrp_t *grp, const char *namespace); + static void openems_wr_xml_layergrp_end(wctx_t *ctx) { if (ctx->cond_sheet_open) { @@ -218,6 +219,55 @@ fprintf(ctx->f, " \n"); } +static void openems_wr_xml_vport(wctx_t *ctx, pcb_any_obj_t *o, rnd_coord_t x, rnd_coord_t y, rnd_layergrp_id_t gid1, rnd_layergrp_id_t gid2, const char *safe_name, double resistance, int act) +{ + pcb_layergrp_t *g1, *g2; + rnd_coord_t e1, e2, em; + + g1 = pcb_get_layergrp(ctx->pcb, gid1); + g2 = pcb_get_layergrp(ctx->pcb, gid2); + if ((g1 == NULL) || (g2 == NULL)) { + rnd_message(RND_MSG_ERROR, "openems_wr_xml_vport: invalid layer groups"); + return 0; + } + e1 = get_grp_elev(ctx, g1); + e2 = get_grp_elev(ctx, g2); + if ((e1 < 0) || (e2 < 0)) { + rnd_message(RND_MSG_ERROR, "openems_wr_xml_vport: can not determine layer group elevations"); + return 0; + } + em = rnd_round((double)(e1+e2)/2.0); + + ctx->port_id++; + + rnd_fprintf(ctx->f, " \n", ctx->port_id, resistance); + rnd_fprintf(ctx->f, " \n"); + rnd_fprintf(ctx->f, " \n", PRIO_PORT); + rnd_fprintf(ctx->f, " \n", x, -y, e1); + rnd_fprintf(ctx->f, " \n", x, -y, e2); + rnd_fprintf(ctx->f, " \n"); + rnd_fprintf(ctx->f, " \n"); + rnd_fprintf(ctx->f, " \n"); + + rnd_fprintf(ctx->f, " \n", ctx->port_id); + rnd_fprintf(ctx->f, " \n"); + rnd_fprintf(ctx->f, " \n"); + rnd_fprintf(ctx->f, " \n", x, -y, e1); + rnd_fprintf(ctx->f, " \n", x, -y, e2); + rnd_fprintf(ctx->f, " \n"); + rnd_fprintf(ctx->f, " \n"); + rnd_fprintf(ctx->f, " \n"); + rnd_fprintf(ctx->f, " \n", ctx->port_id); + rnd_fprintf(ctx->f, " \n"); + rnd_fprintf(ctx->f, " \n"); + rnd_fprintf(ctx->f, " \n", x, -y, em); + rnd_fprintf(ctx->f, " \n", x, -y, em); + rnd_fprintf(ctx->f, " \n"); + rnd_fprintf(ctx->f, " \n"); + rnd_fprintf(ctx->f, " \n"); +} + + static int openems_wr_xml(wctx_t *ctx) { pcb_mesh_t *mesh = pcb_mesh_get(MESH_NAME);