From c89ae6e9f5d7666437283e1fe03543a162aace06 Mon Sep 17 00:00:00 2001 From: stefanjones Date: Mon, 12 Jul 2004 18:11:38 +0000 Subject: [PATCH] 2004-07-12 Stefan Jones * src/tclspice.c: New commands: plot_typename plot_defaultscale Mod: spice_data can be passed the plot number --- ChangeLog | 6 +++ src/tclspice.c | 113 +++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 96 insertions(+), 23 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7664158d1..24987162d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2004-07-12 Stefan Jones + + * src/tclspice.c: + New commands: plot_typename plot_defaultscale + Mod: spice_data can be passed the plot number + 2004-07-07 Stefan Jones * src/tclspice.c: diff --git a/src/tclspice.c b/src/tclspice.c index 5278e76eb..a102a2b61 100755 --- a/src/tclspice.c +++ b/src/tclspice.c @@ -151,6 +151,18 @@ do {\ /* BLT and data routines */ /****************************************************************************/ +/*helper function*/ +inline static struct plot * get_plot(int plot){ + struct plot *pl; + pl = plot_list; + for(;0 < plot;plot--){ + pl = pl->pl_next; + if(!pl) + return (struct plot *)NULL; + } + return pl; +} + /*this holds the number of time points done (altered by spice)*/ int steps_completed; /* number of bltvectors*/ @@ -182,10 +194,12 @@ static int spice_data TCL_CMDPROCARGS(clientData,interp,argc,argv) { char buf[256]; int i, type; char *name; - if (argc != 1) { - Tcl_SetResult(interp, "Wrong # args. spice::spice_data",TCL_STATIC); + if (argc > 2) { + Tcl_SetResult(interp, "Wrong # args. spice::spice_data ?plot?", + TCL_STATIC); return TCL_ERROR; } + if(argc == 1) { if(blt_vnum){ Tcl_ResetResult(interp); for(i = 0; i < blt_vnum;i++){ @@ -204,6 +218,29 @@ static int spice_data TCL_CMDPROCARGS(clientData,interp,argc,argv) { } return TCL_OK; }else return TCL_ERROR; + } else { + struct plot *pl; + struct dvec *v; + if(!(pl = get_plot(atoi(argv[1])))){ + Tcl_SetResult(interp, "Bad plot number", TCL_STATIC); + return TCL_ERROR; + } + for(v = pl->pl_dvecs;v;v = v->v_next) { + name = v->v_name; + if (substring("#branch", name)) + type = SV_CURRENT; + else if (cieq(name, "time")) + type = SV_TIME; + else if (cieq(name, "frequency")) + type = SV_FREQUENCY; + else + type = SV_VOLTAGE; + sprintf(buf,"{%s %s} ",name, + ft_typenames(type)); + Tcl_AppendResult(interp, (char *)buf, TCL_STATIC); + } + return TCL_OK; + } } static int resetTriggers(); @@ -601,18 +638,6 @@ static int running TCL_CMDPROCARGS(clientData,interp,argc,argv) { /* only usefull if plots are saved */ /**************************************/ -/*helper function*/ -inline static struct plot * get_plot(int plot){ - struct plot *pl; - pl = plot_list; - for(;0 < plot;plot--){ - pl = pl->pl_next; - if(!pl) - return (struct plot *)NULL; - } - return pl; -} - /*Outputs the names of all variables in the plot */ static int plot_variables TCL_CMDPROCARGS(clientData,interp,argc,argv) { struct plot *pl; @@ -627,7 +652,7 @@ static int plot_variables TCL_CMDPROCARGS(clientData,interp,argc,argv) { plot = atoi(argv[1]); if(!(pl = get_plot(plot))){ - Tcl_SetResult(interp,"bad plot given",TCL_STATIC); + Tcl_SetResult(interp,"Bad plot given",TCL_STATIC); return TCL_ERROR; } @@ -654,7 +679,7 @@ static int plot_get_value TCL_CMDPROCARGS(clientData,interp,argc,argv) { index = atoi(argv[3]); if(!(pl = get_plot(plot))){ - Tcl_SetResult(interp, "bad plot",TCL_STATIC); + Tcl_SetResult(interp, "Bad plot",TCL_STATIC); return TCL_ERROR; } for(v = pl->pl_dvecs;v;v = v->v_next) @@ -663,7 +688,7 @@ static int plot_get_value TCL_CMDPROCARGS(clientData,interp,argc,argv) { Tcl_SetObjResult(interp,Tcl_NewDoubleObj((double) v->v_realdata[index])); return TCL_OK; } else { - Tcl_SetResult(interp, "bad index",TCL_STATIC); + Tcl_SetResult(interp, "Bad index",TCL_STATIC); return TCL_ERROR; } } @@ -686,7 +711,7 @@ static int plot_datapoints TCL_CMDPROCARGS(clientData,interp,argc,argv) { plot = atoi(argv[1]); if(!(pl = get_plot(plot))){ - Tcl_SetResult(interp, "bad plot", TCL_STATIC); + Tcl_SetResult(interp, "Bad plot", TCL_STATIC); return TCL_ERROR; } @@ -709,7 +734,7 @@ static int plot_title TCL_CMDPROCARGS(clientData,interp,argc,argv) { plot = atoi(argv[1]); if(!(pl = get_plot(plot))){ - Tcl_SetResult(interp, "bad plot", TCL_STATIC); + Tcl_SetResult(interp, "Bad plot", TCL_STATIC); return TCL_ERROR; } Tcl_SetObjResult(interp,Tcl_NewStringObj(pl->pl_title,-1)); @@ -728,7 +753,7 @@ static int plot_date TCL_CMDPROCARGS(clientData,interp,argc,argv) { plot = atoi(argv[1]); if(!(pl = get_plot(plot))){ - Tcl_SetResult(interp, "bad plot", TCL_STATIC); + Tcl_SetResult(interp, "Bad plot", TCL_STATIC); return TCL_ERROR; } Tcl_SetObjResult(interp,Tcl_NewStringObj(pl->pl_date,-1)); @@ -746,13 +771,31 @@ static int plot_name TCL_CMDPROCARGS(clientData,interp,argc,argv) { plot = atoi(argv[1]); if(!(pl = get_plot(plot))){ - Tcl_SetResult(interp, "bad plot", TCL_STATIC); + Tcl_SetResult(interp, "Bad plot", TCL_STATIC); return TCL_ERROR; } Tcl_SetObjResult(interp,Tcl_NewStringObj(pl->pl_name,-1)); return TCL_OK; } +static int plot_typename TCL_CMDPROCARGS(clientData,interp,argc,argv) { + struct plot *pl; + int plot; + if (argc != 2) { + Tcl_SetResult(interp, "Wrong # args. spice::plot_typename plot",TCL_STATIC); + return TCL_ERROR; + } + + plot = atoi(argv[1]); + + if(!(pl = get_plot(plot))){ + Tcl_SetResult(interp, "Bad plot", TCL_STATIC); + return TCL_ERROR; + } + Tcl_SetObjResult(interp,Tcl_NewStringObj(pl->pl_typename,-1)); + return TCL_OK; +} + /*number of variables in a plot*/ static int plot_nvars TCL_CMDPROCARGS(clientData,interp,argc,argv){ @@ -769,7 +812,7 @@ static int plot_nvars TCL_CMDPROCARGS(clientData,interp,argc,argv){ plot = atoi(argv[1]); if(!(pl = get_plot(plot))){ - Tcl_SetResult(interp, "bad plot",TCL_STATIC); + Tcl_SetResult(interp, "Bad plot",TCL_STATIC); return TCL_ERROR; } for(v = pl->pl_dvecs;v;v = v->v_next) @@ -778,6 +821,28 @@ static int plot_nvars TCL_CMDPROCARGS(clientData,interp,argc,argv){ return TCL_OK; } +static int plot_defaultscale TCL_CMDPROCARGS(clientData,interp,argc,argv){ + struct plot *pl; + int plot; + + if (argc != 2) { + Tcl_SetResult(interp, "Wrong # args. spice::plot_defaultscale plot", + TCL_STATIC); + return TCL_ERROR; + } + + plot = atoi(argv[1]); + + if(!(pl = get_plot(plot))){ + Tcl_SetResult(interp, "Bad plot",TCL_STATIC); + return TCL_ERROR; + } + + if(pl->pl_scale) + Tcl_SetObjResult(interp,Tcl_NewStringObj(pl->pl_scale->v_name,-1)); + return TCL_OK; +} + /*agr1: plot index *agr2: spice variable name *arg3: blt_vector @@ -802,7 +867,7 @@ static int plot_getvector TCL_CMDPROCARGS(clientData,interp,argc,argv) { plot = atoi(argv[1]); if(!(pl = get_plot(plot))){ - Tcl_SetResult(interp, "bad plot",TCL_STATIC); + Tcl_SetResult(interp, "Bad plot",TCL_STATIC); return TCL_ERROR; } @@ -1982,7 +2047,9 @@ bot: Tcl_CreateCommand(interp, TCLSPICE_prefix "plot_title", plot_title, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); Tcl_CreateCommand(interp, TCLSPICE_prefix "plot_date", plot_date, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); Tcl_CreateCommand(interp, TCLSPICE_prefix "plot_name", plot_name, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, TCLSPICE_prefix "plot_typename", plot_typename, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); Tcl_CreateCommand(interp, TCLSPICE_prefix "plot_nvars", plot_nvars, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, TCLSPICE_prefix "plot_defaultscale", plot_defaultscale, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); Tcl_CreateCommand(interp, TCLSPICE_prefix "plot_getvector", plot_getvector, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); Tcl_CreateCommand(interp, TCLSPICE_prefix "registerTrigger", registerTrigger, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);