|
From: Stefan J. <ste...@mu...> - 2003-03-28 18:02:00
|
On Thu, 2003-03-27 at 20:46, cfk wrote: > The invocation of "magic -w" creates a magic window, a tkcon and a tclspice > graph that is blank. A "load /usr/lib/libspice" does get access to spice and > I can spice an inverter extracted from magic with exttospice and plot it > with ";spice::asciiplot v(out)", I just cant do a ";spice::plot v(out)" from > within magic (works outside of magic with ngspice directly from a bash > prompt, draws the output voltage with blt, no problem). > > Now it gets interesting. I can tell that the plot procedure in pkgIndex.tcl > is being called as a consequence of the default loading of magic's tcl stuff > even though magic knows nothing about spice at this point. It appears after > reading mucho documentation that the tcl interpreter goes looking for all > the "pkgIndex.tcl" files when it needs a procedure called for instance > "plot". And there is one in ../spice/pkgIndex.tcl, and it is called. > So, I recompiled magic without the plot module, still same effect. Next, I > renamed the plot as xplot in pkgIndex.tcl and voila, no blank plot anymore. > I also put a puts inside pkgIndex.tcl so I would be told it was executing, > and it is executing when I think it is executing. This is a namespace conflict which I have known for quite a while. In the pkgIndex.tcl there are a lot of global variables which get in the way of quite a few packages. Ideally it needs to be cleaned up with all the functions / variables in pkgIndex.tcl being in a namespace and only sourced from a seperate file when the user runs "package require spice" This would also speed up the execution time of tclsh as at the moment every time it runs it sources the entire pkgIndex.tcl file. I am not the author of the current pkgIndex.tcl but I have CCed him (Adrian Dawe). I think he may have done some work on the clean ups already. > Perhaps some hints on the care and feeding of pkgIndex.tcl:plot could be > suggested?? I only really look after the C-code stuff. But it is good to see that that part works. Ok here are the mods I did to get it to work: Edit your .magic file normally found at $CAD_HOME/lib/magic/sys/.magic and remove the plot commands at the bottom of the file: ------ # additions for plot package #plot parameter spoolCommand "echo use 'lpr -P%s -v -s -JMagic %s' to print plot" #plot parameter directory "." ------ This will stop the blank plot window appearing when you start magic, as when you start magic wish sources /usr/lib/spice/pkgIndex.tcl which creates a "plot" command whether you want to use spice or not, which overwrites the magic plot command. .magic is then sourced by magic and invokes the spice plot command which creates the blank plot. Now the pkgIndex.tcl file needs some fixes, in particular the options lines which you found before. I commented these out. I also removed the package require Tclx line as it is not required. Now I can do the following (PS. magic plot is compiled in but it seems /usr/lib/spice/pkgIndex.tcl overwrites it with it's own function) magic -w [ wait for the magic tcl prompt ] [ at the magic prompt we get ] [ snip .... ] Main console display active (Tcl8.3.4 / Tk8.3.4) % package require spice 0.2.7 % spice::source array.spice % spice::step 10 % plot 3019 list add : 3019 2 [ The plot pops up! ] And thus we are done! Attached it the patch I used to /usr/lib/spice/pkgIndex.tcl to get it working here. This if for tclspice-0.2.7. Hope this helps, Stefan -- Stefan Jones <ste...@mu...> Multigig Ltd |