00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef APP_PEAKFIND__H
00029 #define APP_PEAKFIND__H
00030
00031 #include "peakfind_scan.h"
00032 #include "app_databox.h"
00033 #include "gxsm/remote.h"
00034
00035 enum SKL_MODE { SKL_LIN, SKL_LOG, SKL_SQRT };
00036 #define FCOLMAX 256
00037
00038 class PeakFindScan;
00039
00040 class DSPPeakFindControl : public AppBase{
00041 public:
00042 DSPPeakFindControl(XSM_Hardware *Hard, GSList **RemoteEntryList, int InWindow=TRUE);
00043 virtual ~DSPPeakFindControl();
00044
00045 void update();
00046
00047
00048 static void ExecCmd(int cmd);
00049 static void ChangedNotify(Param_Control* pcs, gpointer data);
00050 static void CmdAction(GtkWidget *widget, gpointer pc);
00051
00052
00053 static void delete_pfp_cb(SPA_PeakFind_p *pfp, gpointer pc) { delete pfp; };
00054 static void PFenable(GtkWidget *widget, gpointer pc);
00055 static void PFremove(GtkWidget *widget, gpointer pc);
00056 static void PFadd(GtkWidget *widget, gpointer pc);
00057 static void PFExpandView(GtkWidget *widget, gpointer pc);
00058 static void PFcpyorg(GtkWidget *widget, gpointer pc);
00059 static void PFcpyFromM(GtkWidget *widget, gpointer pc);
00060 static void PFcpyEfromM(GtkWidget *widget, gpointer pc);
00061 static void PFcpyToM(GtkWidget *widget, gpointer pc);
00062 static void PFfollow(GtkButton *button, gpointer pc);
00063 static void PFrunI0pfp(SPA_PeakFind_p *pfp, gpointer pc);
00064 static void PFreset(SPA_PeakFind_p *pfp, gpointer pc);
00065
00066 static void PFsetmode(GtkWidget *widget, SPA_PeakFind_p *pfp);
00067 static void on_mX_clicked(GtkWidget *button, SPA_PeakFind_p *pfp);
00068 static void on_mY_clicked(GtkWidget *button, SPA_PeakFind_p *pfp);
00069
00070 static gint PFtmoutfkt(DSPPeakFindControl *pc);
00071
00072 void addPFtmout(){
00073 if(!IdPFtmout)
00074 IdPFtmout = gtk_timeout_add(PFtmoutms, (GtkFunction) PFtmoutfkt, this);
00075 };
00076 void rmPFtmout(){
00077 if(IdPFtmout){
00078 gtk_timeout_remove(IdPFtmout);
00079 IdPFtmout=0;
00080 }
00081 };
00082
00083 void addPFfolder();
00084 void addPFcontrol(GtkWidget *box);
00085 int PFtmoutms;
00086
00087 UnitObj *Unity, *Volt;
00088 UnitObj *TimeUnitms, *TimeUnit, *CPSUnit, *EnergyUnit;
00089 XSM_Hardware *hard;
00090 PeakFindScan *pfscan;
00091
00092 private:
00093 GtkWidget *notebook;
00094 int itab;
00095 gint IdPFtmout;
00096
00097 GSList *PfpList;
00098
00099 };
00100
00101 #define FPIXTYP long
00102
00103 #define FOCUS_MODE_0D 1
00104 #define FOCUS_MODE_1D 2
00105 #define FOCUS_MODE_2D 4
00106
00107
00108 class Focus : public DataBox {
00109 public:
00110 Focus( DSPPeakFindControl *Pfc, SPA_PeakFind_p *Pfp,
00111 GtkWidget *Vbox, GtkWidget *Hbox);
00112 virtual ~Focus();
00113
00114 static void on_rdecads_changed (GtkEditable *spin, Focus *foc);
00115 static void on_rfirstdecad_changed (GtkEditable *spin, Focus *foc);
00116 static void on_SetAuto_clicked (GtkButton *button, Focus *foc);
00117 static void on_LinLog_clicked (GtkButton *button, Focus *foc);
00118 static void on_Invers_clicked (GtkButton *button, Focus *foc);
00119 static void on_cps_changed(Param_Control* pcs, gpointer data);
00120 static void on_0d_clicked (GtkButton *button, Focus *foc);
00121 static void on_1d_clicked (GtkButton *button, Focus *foc);
00122 static void on_2d_clicked (GtkButton *button, Focus *foc);
00123 static void on_EXYprint_clicked (GtkButton *button, Focus *foc);
00124 static gint item_event(GnomeCanvasItem *item, GdkEvent *event, Focus *foc);
00125 virtual void addheader(ofstream &out){
00126 out << "# gatetime [ms]: " << pfp->gate2d << endl;
00127 out << "# energy [eV]: " << pfp->energy << endl;
00128 out << "# len [V]: " << (pfp->radius*2.) << endl;
00129 }
00130
00131 void ratemeter_changed();
00132
00133 void setmode(int m, int state){
00134 if (state)
00135 mode = (mode & ~m) | m;
00136 else
00137 mode = (mode & ~m);
00138
00139 if(mode)
00140 run();
00141 else
00142 stop();
00143 };
00144 gint atrun();
00145 void getdata();
00146
00147 int xymode, autoskl, mode;
00148 double cnthi, cntlo, cpshi, cpslo, cps;
00149
00150 GtkWidget* RateMeter[5];
00151 int rateleds, ratedecades, firstdecade;
00152 double l10maxrate, l10minrate, ledstep, leds_decade;
00153
00154 GtkWidget* canvas;
00155 GdkPixbuf* focuspixbuf;
00156 GnomeCanvasItem *focuspixbufitem;
00157 GnomeCanvasItem *hline, *vline;
00158 gint bpp, rowstride;
00159 guchar *pixels;
00160
00161 DataBox *xbox, *ybox;
00162
00163 private:
00164 void AutoHiLo();
00165 void CalcLookUp(int SklMode = SKL_LOG);
00166
00167 int LookUp(FPIXTYP x){
00168 int i,j;
00169 j=(i=FCOLMAX>>1)>>1;
00170 do{
00171 if(x < LookupTbl[i])
00172 i -= j;
00173 else
00174 i += j;
00175 }while(j>>=1);
00176 return i;
00177 };
00178
00179 int nnx, nnx2d;
00180 float *yn, *xn, *xx, *yy;
00181
00182 FPIXTYP LookupTbl[FCOLMAX];
00183 int invers, linlog;
00184
00185 SPA_PeakFind_p *pfp;
00186 DSPPeakFindControl *pfc;
00187 };
00188
00189 #endif