00001 #include <tcl.h>
00002 #include <tk.h>
00003 #include <stdio.h>
00004 #include <string.h>
00005
00006 extern Tcl_Interp* MainTclInterp;
00007
00008 int ProgMeter_Create(char *title)
00009 {
00010 char tclstr[200];
00011 Tcl_Obj *tclcommand=NULL;
00012 int gaugenum;
00013 Tcl_Obj *objectresult=NULL;
00014
00015
00016 sprintf(tclstr, "gauge_gui_add \"%s\"",title);
00017 tclcommand = Tcl_NewStringObj(tclstr, -1);
00018
00019 if(Tcl_EvalObj(MainTclInterp, tclcommand) != TCL_OK ) {
00020 Tcl_BackgroundError(MainTclInterp);
00021 return 0;
00022 }
00023
00024 objectresult = Tcl_GetObjResult(MainTclInterp);
00025 if (Tcl_GetIntFromObj(MainTclInterp, objectresult, &gaugenum) != TCL_OK) {
00026 Tcl_BackgroundError(MainTclInterp);
00027 return 0;
00028 } else {
00029 return gaugenum;
00030 }
00031 }
00032
00033
00034
00035 int ProgMeter_Update(int gaugenum, double value)
00036 {
00037 char tclstr[200];
00038 Tcl_Obj *tclcommand=NULL;
00039 Tcl_Obj *objectresult=NULL;
00040 int cancelval;
00041
00042 sprintf(tclstr, "gauge_gui_update %d %f",gaugenum,value);
00043 if( Tcl_Eval(MainTclInterp, tclstr) != TCL_OK ) {
00044 Tcl_BackgroundError(MainTclInterp);
00045 return -1;
00046 }
00047
00048 objectresult = Tcl_GetObjResult(MainTclInterp);
00049 if (Tcl_GetIntFromObj(MainTclInterp, objectresult, &cancelval) != TCL_OK) {
00050 Tcl_BackgroundError(MainTclInterp);
00051 return -1;
00052 } else {
00053 return cancelval;
00054 }
00055
00056 }
00057
00058
00059 int ProgMeter_Destroy(int gaugenum)
00060 {
00061 char tclstr[200];
00062
00063 sprintf(tclstr, "gauge_gui_delete %d",gaugenum);
00064 if( Tcl_Eval(MainTclInterp, tclstr) != TCL_OK ) {
00065 Tcl_BackgroundError(MainTclInterp);
00066 return 0;
00067 } else {
00068 return 1;
00069 }
00070 }