Index: trunk/scconfig/Rev.h =================================================================== --- trunk/scconfig/Rev.h (revision 32316) +++ trunk/scconfig/Rev.h (revision 32317) @@ -1 +1 @@ -static const int myrev = 32311; +static const int myrev = 32317; Index: trunk/scconfig/Rev.tab =================================================================== --- trunk/scconfig/Rev.tab (revision 32316) +++ trunk/scconfig/Rev.tab (revision 32317) @@ -1,4 +1,4 @@ -32311 configure new netlist import plugins: pads ascii netlist, orcad pcb II netlist +32317 configure new netlist import plugins: pads ascii netlist, orcad pcb II netlist, accel net 32284 configure io_tedax: file format support for autorouters 32216 configure cleanup: eahc plugin shall register its own menus 32187 configure librnd: infra for menu patching Index: trunk/scconfig/plugins.h =================================================================== --- trunk/scconfig/plugins.h (revision 32316) +++ trunk/scconfig/plugins.h (revision 32317) @@ -72,6 +72,7 @@ plugin_def("fp_wget", "web footprints", sbuildin, 1, 0) plugin_header("\nImport plugins:\n") +plugin_def("import_accel_net", "import Accel netlist", sbuildin, 1, 0) plugin_def("import_calay", "import calay .net", sbuildin, 1, 0) plugin_def("import_dsn", "specctra .dsn importer", sbuildin, 1, 0) plugin_def("import_edif", "import edif", sbuildin, 1, 0) @@ -169,6 +170,7 @@ plugin_dep("hid_gtk2_gl", "lib_gtk_common", 01) plugin_dep("hid_gtk2_gl", "lib_hid_gl", 01) plugin_dep("hid_lesstif", "lib_hid_common", 01) +plugin_dep("import_accel_net", "lib_gensexpr", 0) plugin_dep("import_dsn", "lib_compat_help", 0) plugin_dep("import_dsn", "lib_gensexpr", 0) plugin_dep("import_ipcd356", "lib_compat_help", 0) Index: trunk/src_plugins/import_accel_net/Makefile =================================================================== --- trunk/src_plugins/import_accel_net/Makefile (nonexistent) +++ trunk/src_plugins/import_accel_net/Makefile (revision 32317) @@ -0,0 +1,5 @@ +all: + cd ../../src && $(MAKE) mod_import_accel_net + +clean: + rm *.o *.so 2>/dev/null ; true Index: trunk/src_plugins/import_accel_net/Plug.tmpasm =================================================================== --- trunk/src_plugins/import_accel_net/Plug.tmpasm (nonexistent) +++ trunk/src_plugins/import_accel_net/Plug.tmpasm (revision 32317) @@ -0,0 +1,10 @@ +put /local/pcb/mod {import_accel_net} +put /local/pcb/mod/OBJS [@ $(PLUGDIR)/import_accel_net/accel_net.o @] +put /local/pcb/mod/MENUFILE {accel_net-menu.lht} +put /local/pcb/mod/MENUVAR {accel_net_menu} + +switch /local/pcb/import_accel_net/controls + case {buildin} include /local/pcb/tmpasm/buildin; end; + case {plugin} include /local/pcb/tmpasm/plugin; end; + case {disable} include /local/pcb/tmpasm/disable; end; +end Index: trunk/src_plugins/import_accel_net/accel_net-menu.lht =================================================================== --- trunk/src_plugins/import_accel_net/accel_net-menu.lht (nonexistent) +++ trunk/src_plugins/import_accel_net/accel_net-menu.lht (revision 32317) @@ -0,0 +1,9 @@ +ha:rnd-menu-v1 { + li:anchored { + ha:@import_sch { + li:submenu { + ha:Load Accel netlist file = { action=LoadAccelNetFrom() } + } + } + } +} Index: trunk/src_plugins/import_accel_net/accel_net.c =================================================================== --- trunk/src_plugins/import_accel_net/accel_net.c (nonexistent) +++ trunk/src_plugins/import_accel_net/accel_net.c (revision 32317) @@ -0,0 +1,245 @@ +/* + * COPYRIGHT + * + * pcb-rnd, interactive printed circuit board design + * + * sch import: PADS netlist ASCII (powerpcb?) + * pcb-rnd Copyright (C) 2020 Tibor 'Igor2' Palinkas + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Contact: + * Project page: http://repo.hu/projects/pcb-rnd + * lead developer: http://repo.hu/projects/pcb-rnd/contact.html + * mailing list: pcb-rnd (at) list.repo.hu (send "subscribe") + */ + +#include "config.h" + +#include +#include +#include + +#include "board.h" +#include "data.h" +#include "plug_import.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "menu_internal.c" + +static const char *accel_net_cookie = "accel_net importer"; + +static int accel_net_parse_net(FILE *fn) +{ + gsxl_dom_t dom; + gsxl_node_t *n, *footprint, *refdes, *noise, *net; + int res, c, restore; + gds_t tmp; + char line[1024]; + + gds_init(&tmp); + gsxl_init(&dom, gsxl_node_t); + + fgets(line, sizeof(line), fn); /* eat up the header line, not part of the s-expr */ + + dom.parse.line_comment_char = '#'; + dom.parse.brace_quote = 1; + do { + c = fgetc(fn); + } while((res = gsxl_parse_char(&dom, c)) == GSX_RES_NEXT); + + if (res != GSX_RES_EOE) { + rnd_message(RND_MSG_ERROR, "accel: s-expression parse error\n"); + return -1; + } + + /* compact and simplify the tree */ + gsxl_compact_tree(&dom); + + + rnd_actionva(&PCB->hidlib, "ElementList", "start", NULL); + rnd_actionva(&PCB->hidlib, "Netlist", "Freeze", NULL); + rnd_actionva(&PCB->hidlib, "Netlist", "Clear", NULL); + +#if 0 + for(n = dom.root->children; n != NULL; n = n->next) { + footprint = n->children; + if ((footprint == NULL) || (footprint->next == NULL) || (footprint->next->next == NULL)) { + rnd_message(RND_MSG_ERROR, "accel: missing footprint or refdes in %d:%d\n", n->line, n->col); + continue; + } + refdes = footprint->next; + noise = refdes->next; + +/*pcb_trace("@ '%s' '%s'\n", footprint->str, refdes->str);*/ + rnd_actionva(&PCB->hidlib, "ElementList", "Need", refdes->str, footprint->str, "", NULL); + + tmp.used = 0; + gds_append_str(&tmp, refdes->str); + gds_append(&tmp, '-'); + restore = tmp.used; + + for(net = noise->next; net != NULL; net = net->next) { + if (net->children == NULL) { + rnd_message(RND_MSG_ERROR, "accel: missing terminal ID in %d:%d\n", n->line, n->col); + continue; + } + + tmp.used = restore; + gds_append_str(&tmp, net->str); + rnd_actionva(&PCB->hidlib, "Netlist", "Add", net->children->str, tmp.array, NULL); +/*pcb_trace(" net %s %s\n", tmp.array, net->children->str);*/ + } + } +#endif + + rnd_actionva(&PCB->hidlib, "Netlist", "Sort", NULL); + rnd_actionva(&PCB->hidlib, "Netlist", "Thaw", NULL); + rnd_actionva(&PCB->hidlib, "ElementList", "Done", NULL); + + gsxl_uninit(&dom); + gds_uninit(&tmp); + return 0; +} + + +static int accel_net_load(const char *fname_net) +{ + FILE *fn; + int ret = 0; + + fn = rnd_fopen(&PCB->hidlib, fname_net, "r"); + if (fn == NULL) { + rnd_message(RND_MSG_ERROR, "can't open file '%s' for read\n", fname_net); + return -1; + } + + ret = accel_net_parse_net(fn); + + fclose(fn); + return ret; +} + +static const char pcb_acts_LoadAccelNetFrom[] = "LoadAccelNetFrom(filename)"; +static const char pcb_acth_LoadAccelNetFrom[] = "Loads the specified pads ascii netlist .net file."; +fgw_error_t pcb_act_LoadAccelNetFrom(fgw_arg_t *res, int argc, fgw_arg_t *argv) +{ + const char *fname = NULL; + static char *default_file = NULL; + + RND_ACT_MAY_CONVARG(1, FGW_STR, LoadAccelNetFrom, fname = argv[1].val.str); + + if (!fname || !*fname) { + fname = rnd_gui->fileselect(rnd_gui, "Load pads ascii netlist file...", + "Picks a pads ascii netlist file to load.\n", + default_file, ".net", NULL, "accel_net", RND_HID_FSD_READ, NULL); + if (fname == NULL) + return 1; + if (default_file != NULL) { + free(default_file); + default_file = NULL; + } + } + + RND_ACT_IRES(0); + return accel_net_load(fname); +} + +static int accel_net_support_prio(pcb_plug_import_t *ctx, unsigned int aspects, const char **args, int numargs) +{ + FILE *f; + unsigned int good = 0, limit; + + if ((aspects != IMPORT_ASPECT_NETLIST) || (numargs != 1)) + return 0; /* only pure netlist import is supported from a single file*/ + + f = rnd_fopen(&PCB->hidlib, args[0], "r"); + if (f == NULL) + return 0; + + for(limit = 0; limit < 4; limit++) { + char *s, line[1024]; + s = fgets(line, sizeof(line), f); + if (s == NULL) + break; + while(isspace(*s)) s++; + if (strncmp(s, "ACCEL_ASCII", 11) == 0) { + fclose(f); + return 100; + } + } + + fclose(f); + + return 0; +} + + +static int accel_net_import(pcb_plug_import_t *ctx, unsigned int aspects, const char **fns, int numfns) +{ + if (numfns != 1) { + rnd_message(RND_MSG_ERROR, "import_accel_net: requires exactly 1 input file name\n"); + return -1; + } + return accel_net_load(fns[0]); +} + +static pcb_plug_import_t import_accel_net; + +rnd_action_t accel_net_action_list[] = { + {"LoadAccelNetFrom", pcb_act_LoadAccelNetFrom, pcb_acth_LoadAccelNetFrom, pcb_acts_LoadAccelNetFrom} +}; + +int pplg_check_ver_import_accel_net(int ver_needed) { return 0; } + +void pplg_uninit_import_accel_net(void) +{ + rnd_remove_actions_by_cookie(accel_net_cookie); + RND_HOOK_UNREGISTER(pcb_plug_import_t, pcb_plug_import_chain, &import_accel_net); + rnd_hid_menu_unload(rnd_gui, accel_net_cookie); +} + +int pplg_init_import_accel_net(void) +{ + RND_API_CHK_VER; + + /* register the IO hook */ + import_accel_net.plugin_data = NULL; + + import_accel_net.fmt_support_prio = accel_net_support_prio; + import_accel_net.import = accel_net_import; + import_accel_net.name = "accel_net"; + import_accel_net.desc = "schamtics from pads ascii netlist"; + import_accel_net.ui_prio = 50; + import_accel_net.single_arg = 1; + import_accel_net.all_filenames = 1; + import_accel_net.ext_exec = 0; + + RND_HOOK_REGISTER(pcb_plug_import_t, pcb_plug_import_chain, &import_accel_net); + + RND_REGISTER_ACTIONS(accel_net_action_list, accel_net_cookie) + rnd_hid_menu_load(rnd_gui, NULL, accel_net_cookie, 175, NULL, 0, accel_net_menu, "plugin: import accel_net"); + return 0; +} Index: trunk/src_plugins/import_accel_net/import_accel_net.pup =================================================================== --- trunk/src_plugins/import_accel_net/import_accel_net.pup (nonexistent) +++ trunk/src_plugins/import_accel_net/import_accel_net.pup (revision 32317) @@ -0,0 +1,10 @@ +$class import +$short import Accel netlist +$long Import the netlist and footprints from a Accel netlist. +$state works +$fmt-native no +$fmt-feature-r import netlist and footprint info from Accel ASCII netlists +$package import-net +default buildin +dep lib_gensexpr +autoload 1 Index: trunk/src_plugins/import_accel_net/menu_internal.c =================================================================== --- trunk/src_plugins/import_accel_net/menu_internal.c (nonexistent) +++ trunk/src_plugins/import_accel_net/menu_internal.c (revision 32317) @@ -0,0 +1,21 @@ +/* Autogenerated by cquote.c - DO NOT EDIT */ +/* (Using character array instead of string literal for long strings) */ +const char accel_net_menu_arr[] = { + 'h','a',':','r','n','d','-','m','e','n','u','-','v','1',' ','{', + '\n', + '\t','l','i',':','a','n','c','h','o','r','e','d',' ','{','\n', + '\t','\t','h','a',':','@','i','m','p','o','r','t','_','s','c', + 'h',' ','{','\n', + '\t','\t','\t','l','i',':','s','u','b','m','e','n','u',' ','{', + '\n', + '\t','\t','\t','\t','h','a',':','L','o','a','d',' ','O','r','c', + 'a','d',' ','P','C','B',' ','I','I',' ','n','e','t','l','i','s', + 't',' ','f','i','l','e',' ','=',' ','{',' ','a','c','t','i','o', + 'n','=','L','o','a','d','O','r','c','a','d','N','e','t','F','r', + 'o','m','(',')',' ','}','\n', + '\t','\t','\t','}','\n', + '\t','\t','}','\n', + '\t','}','\n', + '}','\n', + 0}; +const char *accel_net_menu = accel_net_menu_arr; Index: trunk/src_plugins/plugins_ALL.tmpasm =================================================================== --- trunk/src_plugins/plugins_ALL.tmpasm (revision 32316) +++ trunk/src_plugins/plugins_ALL.tmpasm (revision 32317) @@ -50,6 +50,7 @@ include {../src_plugins/hid_gtk2_gl/Plug.tmpasm} include {../src_plugins/hid_lesstif/Plug.tmpasm} include {../src_plugins/hid_remote/Plug.tmpasm} +include {../src_plugins/import_accel_net/Plug.tmpasm} include {../src_plugins/import_calay/Plug.tmpasm} include {../src_plugins/import_dsn/Plug.tmpasm} include {../src_plugins/import_edif/Plug.tmpasm}