kicad-developers team mailing list archive
Mailing list archive
Re: New library file format
Mon, 09 Nov 2009 16:52:15 -0000
--- In kicad-devel@xxxxxxxxxxxxxxx, Dick Hollenbeck <dick@...> wrote:
> Wayne Stambaugh wrote:
> > phinitnan_c wrote:
> >> --- In kicad-devel@xxxxxxxxxxxxxxx, Wayne Stambaugh <stambaughw@> wrote:
> >>> phinitnan_c wrote:
> >>>> Hello,
> >>>> Refer to my previous thread,
> >>>> http://tech.groups.yahoo.com/group/kicad-devel/message/3625
> >>>> and a wiki page about new library system spec,
> >>>> http://kicad.sourceforge.net/wiki/index.php/New_Library_System_Spec
> >>>> I'd like to ask a few questions.
> >>>> 1) Is there developers working on the new library file format specification? I may be able to help.
> >>> The only proposed change to the library file format that I am aware of
> >>> is the one I proposed which is to merge the document file *.dcm with the
> >>> library file *.lib. I held off to see what additional information may
> >>> be required by the library updates that some of the other developers are
> >>> working on.
> >>>> 2) Is there the document for the current file format? I tried to find it with no luck.
> >>> Yes. You can check it out of SVN. The Kicad wiki has all the
> >>> information you need. It is in an OpenOffice.org format.
> >>>> 3) Would it be possible to use an existing database engine (eg. sqlite) to store library/module information?
> >>> Yes it would be possible. I think you will find most developers on this
> >>> list (this one include) prefer text file formats so that they can be
> >>> created, manipulated, and viewed with their favorite editor and command
> >>> line tools. I for one do not want the component definitions themselves
> >>> to be saved in a database. Tagging and file path information could be
> >>> put in a database for searching purposes but not the actual component
> >>> definitions themselves. If an acceptable search solution using tags in
> >>> plain text files cannot be developed, then a database may be an option.
> >>> I don't believe we have actually gotten to that point yet.
> >>> Wayne
> >> Thank you Wayne, the documents are lied in kicad-doc directory. I alsoprefer text. Some folks here think that it would be good if the file is more readable by human. I would like to propose a new file format based on anexisting tool such as JSON (wxJSON, http://wxcode.sourceforge.net/docs/wxjson/). I think this will make the file more readable, flexible and extensible.
> > I agree that the current library and schematic file formats are not very
> > human readable. I believe they are legacy file formats that have been
> > with the project for some time. I am not familiar with JSON so I cannot
> > comment on how effective it would be. One thing I think it should
> > support is wxInputStream and wxOutputStream ( or C++ library istream and
> > ostream ). This way you only have to write one parser and one output
> > format to support streams from any of the derived input and output
> > stream classes. If you us wxInputStream to write you parser, you get
> > socket, file, zip, and tar input streams for very little extra effort.
> > With all of the new library discussions, I could see where any one of
> > the derived input and/or output streams would be useful.
> > Wayne
> "Existing tools" can be found in many places. I vote for the parser we
> already have in the specctra import, and its LineReader input
> abstraction which can easily be adapted to grab lines from any source,
> including wxInputStream.
> I find the specctra dsn style more agreeable than JSON.
> The specctra parsing technique is easily adapted to any DSN like
> grammar, and the lexer only needs a new table of token keywords and
> matching enums to handle any task we could throw at it. And it reports
> errors down the line number and character offset, and those errors use
> text that we control, and the error reporting is kept out of the library
> by use of exceptions.
> It is *still* what I would use for any new work involving structural
> text data files.
> But what about the user experience?
> Having a well defined API for part retrieval,
> serialization/deserialization (in a java like sense), browsing,
> searching, and adoption, means that Kicad could have any one of a number
> of competing libraries.
> If you separate the notion of library maintenance from library usage, in
> the same way that you can be a visitor to a physical library yet don't
> have to work there like the actual librarian does to keep the place
> orderly, then you as a library user can be positioned to pick from a
> number of competing libraries. My suggestion is to define the *usage
> API*, not the management API. The librarian may be in python on the
> other side of a DBUS bridge, or on the other side of the world.
> By having a well defined library usage API which is implemented by any
> number of *competing* C++ classes derived from a common C++ *usage API*
> definition class using virtual functions, those derived classes can live
> in any number of DSOs and give the user choices. The librarians can do
> things the way they want, but the usage API is a contract that they all
> have to honor.
> This is why I don't think the file format is even remotely important to
> the usage API. Because such an API should not concern itself with file
> formats, but in memory structures, tags, pins, parts, serialized byte
> streams, and the like. And more than one usage API implementation can
> be active in the Kicad program concurrently via an array of plugins.
> The competing implementations would be called plugins, and would be
> under the control of a plugin manager which can seamlessly blend
> together these separate sources into one cohesive user experience.
> This is a divide and conquer strategy. We divide *part maintenance*
> from *part usage* tasks, with the hope and vision that we can spin off
> competing implementations, and competing library communities. One
> community could be website based, one could be python local, a 3rd could
> be C++ local. In each case those librarian communities would need to
> implement as a minimum a C++ plugin which honors the "usage API", from
> there they could go over the web, through DBUS to python, or to a local
> disk directory directly.
> Some of these libraries could even be commercial, and require you to pay
> a subscription fee for the work required to maintain them, or tap into
> existing commercial libraries. I think the concept of creating a
> business domain under Kicad in which competing implementations can
> co-exist would be healthy for Kicad. And it is not unreasonable for all
> existing libraries to be spun off into one or more separate projects,
> although the licensing of those spin-offs would be important details
> that would need to respect existing license terms with continuity. But
> lets remember that the licenses used by Kicad currently involve code
> *ownership*, not fees for service oriented labor or work.
> Also remember that certain geda parts can already be imported into
> Kicad, but my vision formalizes that basic first step into a much
> broader strategy. The problem gets simpler if you start with the usage
> API, and this is why I suggested we focus on the user experience. The
> usage API could even go so far as to describe a modification that you
> need to an existing part, such as a pin count change, etc.
> Think about it.
I like the vision of dividing part maintenance away from part usage.
But part of the vision needs to be that, if I tar up a project and then untar it two years later to make a board revision, I can still do that revision even if one of my library sources is off-line or even out of business. Xilinx's licensing model is pretty good. Nothing you buy from them ever stops working; you just promise not to use it for anything new after your one-year subscription is up. (And open source is fundamentally incompatible with DRM in any case, because a determined programmer can "free" his data quite easily.)
So, if I can tar/untar a project and have it work, that means that KiCad needs (as it has now) some sort of "cache" library format (and, preferably, the ability to read cache files from older versions).
And, while it's not really necessary to expose that format to the rest of the world, if it's reasonably readable text and well-documented, and the base KiCad needs to have a reader for the format anyway, you can make a case that the cache library format (for a given version of KiCad) is the "canonical" form of the library, and you could advance various arguments for keeping it relatively stable, or making a few minor enhancements in the format, etc.
But you are absolutely right that making the file format itself the focus of the effort to clean up the library management user experience is putting the cart before the horse, although some decisions made in determining the library management architecture will undoubtedly impact the cached file format by, for example, requiring the storage of additional metadata.
I think the plug-in architecture you describe could go a long way toward solving the library management problem, but for it to be used, the very firstreleased version has to have really good support for moving parts and evenentire libraries around from plugin to plugin. (And I have been involved in lots of grandiose overarching designs that only ever got one or two plugins written for them.)
So I absolutely agree with you that user experience is paramount, but in sodoing I put the plugin manager in the same category as the file format -- a nice piece of technology that might solve part of the problem.
Personally, if I were doing this, though (but of course I'm not, and I knowthat doesn't give me a vote :) being the lazy programmer that I am, I would eschew the plugin support for a much simpler architecture, and try to leverage existing web infrastructure as much as possible. For example, it would be relatively easy to add the ability to open a socket to read a web page, and the ability to parse HTML and look for special tags that indicated avalid library was inside.
Now, you've got google finding your parts for you, you've got a web page with pinouts and text and 3D models, or however fancy the designer wants to get in communicating his library to humans, and KiCad can load it from the same URL the user uses to look at it.
Your documentation needs shift. Sure, you're documenting a file format (which you really should do anyway for the cache file), but instead of documenting an API, you are documenting how you containerize your file inside an HTML document with a few tags.
A guy who uses the library editor to make one part can now share it with the world without having to write or understand a KiCad plugin -- he just needs basic HTML skills. And when he *does* share it on the web, and some random Joe Schmoe googles for a particular weird connector part number and stumbles across the page with the fancy 3D models, that will give him pause, and increase KiCad mindshare, in a way that no number of postings of "Download this and try the new plugin manager!" could possibly touch.
Just my two cents -- do with it what you will.