From fd0e6e3aa0e7523a36011a2f0264737772aa5e24 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Sun, 7 Aug 2016 22:20:45 +0200 Subject: templates: nodemcu-arduino: NodeMCU with Arduino. o Moving headers so they match the namespace they declare. o Reducing debug logging. --- core/include/trygvis/kicad.h | 94 -------------------------------------------- core/kicad.cpp | 14 ++----- 2 files changed, 4 insertions(+), 104 deletions(-) (limited to 'core') diff --git a/core/include/trygvis/kicad.h b/core/include/trygvis/kicad.h index bae250b..4b76868 100644 --- a/core/include/trygvis/kicad.h +++ b/core/include/trygvis/kicad.h @@ -1,10 +1,6 @@ #pragma once #include -#include -#include -#include -#include namespace trygvis { namespace kicad { @@ -13,93 +9,3 @@ using opt = std::experimental::optional; using std::experimental::nullopt; } // namespace kicad } // namespace trygvis - -namespace trygvis { -namespace kicad { -namespace netlist { - -struct lib_source { - const std::string lib; - const std::string part; - - lib_source(const std::string &lib, const std::string &part) : lib(lib), part(part) {} -}; - -struct component { - const std::string ref; - const std::string value; - const lib_source _lib_source; - - component(const std::string &ref, const std::string &value, const lib_source &_lib_source) : - ref(ref), value(value), _lib_source(_lib_source) {} -}; - -struct pin { - int num; - std::string name; - std::string type; -}; - -struct part { - std::vector pins; -}; - -class node { -public: - const std::string ref; - const int pin; - - node(const std::string &ref, int pin) : ref(ref), pin(pin) {} -}; - -class net { -public: - const int code; - const std::string name; - const std::vector nodes; - - net(int code, const std::string &name, const std::vector &nodes) : code(code), name(name), nodes(nodes) {} - - const node *node_for_ref(const std::string &ref) const; -}; - -struct netlist { - std::vector components; - std::vector parts; - std::vector nets; - - opt find_component(const std::string &ref) const; - - std::vector find_usage_of(const std::string &ref) const; -}; - -class kicad_parse_exception : public std::runtime_error { -public: - explicit kicad_parse_exception(const std::vector &messages) : - runtime_error("Parse error"), messages(messages) {} - - explicit kicad_parse_exception(const std::string &message) : - runtime_error("Parse error"), messages({message}) {} - - ~kicad_parse_exception() {} - - const std::vector messages; -}; - -class kicad_net_loader { -public: - kicad_net_loader(); - - virtual ~kicad_net_loader(); - - netlist load(std::string path, std::ostream &err); - - void setDebug(bool debug); - -private: - bool debug_; -}; - -} // namespace netlist -} // namespace kicad -} // namespace trygvis diff --git a/core/kicad.cpp b/core/kicad.cpp index a553b62..c0315e6 100644 --- a/core/kicad.cpp +++ b/core/kicad.cpp @@ -1,4 +1,4 @@ -#include "trygvis/kicad.h" +#include "trygvis/kicad/netlist.h" #include "trygvis/antlr.h" #include "trygvis/string_utils.h" #include @@ -35,7 +35,7 @@ opt netlist::find_component(const string &ref) const { return std::experimental::nullopt; } -vector netlist::find_usage_of(const string &ref) const { +vector netlist::find_nets_using_ref(const string &ref) const { vector usage; for (auto &net : nets) { @@ -91,15 +91,9 @@ public: name = name.substr(1); } -// cerr << "exitNet: " << "code=" << code << ", name=" << name << ", nodes=" << nodes.size() << endl; + bool hasName = !startsWith(name, "Net-("); -// if (nodes.size() > 1) { -// cerr << "Net#" << code << ": " << name << endl; -// for (auto &node: nodes) { -// cerr << " Node: " << node.ref << "#" << node.pin << endl; -// } -// } - nets.emplace_back(code, name, nodes); + nets.emplace_back(code, hasName ? opt(name) : nullopt, nodes); nodes.clear(); } -- cgit v1.2.3