Index: trunk/src_plugins/export_openems/export_openems.c =================================================================== --- trunk/src_plugins/export_openems/export_openems.c (revision 32006) +++ trunk/src_plugins/export_openems/export_openems.c (revision 32007) @@ -639,7 +639,8 @@ openems_wr_m_testpoints(&wctx, wctx.pcb->Data); } else { /* xml */ - openems_wr_xml(&wctx); + if (openems_wr_xml(&wctx) != 0) + rnd_message(RND_MSG_ERROR, "openEMS: Due to errors, the exported file is invalid.\n"); } rnd_conf_update(NULL, -1); /* restore forced sets */ @@ -719,7 +720,8 @@ if (flags & PCB_LYT_COPPER) { /* export copper layers only */ ems_ctx->clayer = ems_ctx->lg_pcb2ems[group]; if ((!ems_ctx->fmt_matlab) && (!is_empty)) - openems_wr_xml_layergrp_begin(ems_ctx, &ems_ctx->pcb->LayerGroups.grp[group]); + if (openems_wr_xml_layergrp_begin(ems_ctx, &ems_ctx->pcb->LayerGroups.grp[group]) != 0) + return 0; return 1; } return 0; Index: trunk/src_plugins/export_openems/openems_xml.c =================================================================== --- trunk/src_plugins/export_openems/openems_xml.c (revision 32006) +++ trunk/src_plugins/export_openems/openems_xml.c (revision 32007) @@ -55,7 +55,7 @@ return pcb_stack_thickness(ctx->pcb, "openems", PCB_BRDTHICK_PRINT_ERROR, from, 1, to, 0, PCB_LYT_SUBSTRATE|PCB_LYT_COPPER); } -static void openems_wr_xml_layergrp_begin(wctx_t *ctx, pcb_layergrp_t *g) +static int openems_wr_xml_layergrp_begin(wctx_t *ctx, pcb_layergrp_t *g) { rnd_coord_t th; pcb_layer_t *ly = NULL; @@ -80,8 +80,10 @@ fprintf(ctx->f, " \n"); ctx->cond_sheet_open = 1; th = get_grp_elev(ctx, g); -TODO("check for -1 and return error"); + if (th < 0) + return -1; ctx->elevation = RND_COORD_TO_MM(th); + return 0; } static int openems_wr_xml_outline(wctx_t *ctx, pcb_layergrp_t *g) @@ -124,10 +126,12 @@ } -static void openems_wr_xml_grp_substrate(wctx_t *ctx, pcb_layergrp_t *g) +static int openems_wr_xml_grp_substrate(wctx_t *ctx, pcb_layergrp_t *g) { rnd_coord_t th = get_grp_elev(ctx, g); -TODO("check for -1 and return error"); + + if (th < 0) + return -1; ctx->elevation = RND_COORD_TO_MM(th); TODO("Fix hardwired constants"); @@ -139,12 +143,14 @@ openems_wr_xml_outline(ctx, g); fprintf(ctx->f, " \n"); fprintf(ctx->f, " \n"); + return 0; } -static void openems_wr_xml_layers(wctx_t *ctx) +static int openems_wr_xml_layers(wctx_t *ctx) { rnd_hid_expose_ctx_t ectx = {0}; rnd_cardinal_t gid; + int err = 0; fprintf(ctx->f, " \n"); @@ -160,11 +166,12 @@ for(gid = 0; gid < ctx->pcb->LayerGroups.len; gid++) { pcb_layergrp_t *g = &ctx->pcb->LayerGroups.grp[gid]; if (g->ltype & PCB_LYT_SUBSTRATE) - openems_wr_xml_grp_substrate(ctx, g); + err |= openems_wr_xml_grp_substrate(ctx, g); } fprintf(ctx->f, " \n"); + return err; } static void openems_wr_xml_mesh_lines(wctx_t *ctx, pcb_mesh_t *mesh, char axis, pcb_mesh_lines_t *l, rnd_coord_t scale) @@ -187,12 +194,12 @@ fprintf(ctx->f, " \n"); } -static void openems_wr_xml(wctx_t *ctx) +static int openems_wr_xml(wctx_t *ctx) { pcb_mesh_t *mesh = pcb_mesh_get(MESH_NAME); char *exc; + int err = 0; - fprintf(ctx->f, "\n"); fprintf(ctx->f, "\n"); fprintf(ctx->f, " \n", def_num_timesteps, def_end_crit, def_f_max); @@ -217,11 +224,12 @@ fprintf(ctx->f, " \n"); fprintf(ctx->f, " \n", ctx->options[HA_void_epsilon].dbl, ctx->options[HA_void_mue].dbl); - openems_wr_xml_layers(ctx); + err |= openems_wr_xml_layers(ctx); openems_wr_xml_grid(ctx, mesh); fprintf(ctx->f, " \n"); fprintf(ctx->f, "\n"); + return err; }