Subversion Repositories f9daq

Compare Revisions

Regard whitespace Rev 241 → Rev 242

/cvi/RedPitaya/soccli/README.md
0,0 → 1,23
Client for the RedPitaya board
Start the server on the RedPitaya First, then start the client
 
 
rok@f9rok ~$ ssh root@rp-f04f77.local
Welcome to Ubuntu 16.04.2 LTS (GNU/Linux 4.4.0-xilinx armv7l)
 
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
##############################################################################
# Red Pitaya GNU/Linux Ecosystem
# Version: 0.97
# Build: 336
# Branch:
# Commit: 4506f6e20ad2d2c8a45184383302331b6bf4a501
# U-Boot: "redpitaya-v2016.4"
# Linux Kernel: "redpitaya-v2016.2"
# Pro Applications: 40d8c17c18aac3ea6416257603c4c8dcd208d109 Applications (v0.96-RC3-134-g40d8c17)
##############################################################################
Last login: Wed Mar 22 09:47:35 2017 from fe80::117e:99ca:51f3:7af2%eth0
root@rp-f04f77:~# cd sockserv/
root@rp-f04f77:~/sockserv# ./sockserv.sh
/cvi/RedPitaya/soccli/redpitaya_gui.h
20,52 → 20,51
#define PANEL_EXPORT_3 5 /* control type: command, callback function: ExportCB */
#define PANEL_HRESET 6 /* control type: command, callback function: ResetCB */
#define PANEL_EXIT 7 /* control type: command, callback function: ExitCB */
#define PANEL_DISCONNECT 8 /* control type: command, callback function: StartCB */
#define PANEL_CONNECT 9 /* control type: command, callback function: StartCB */
#define PANEL_START 10 /* control type: command, callback function: StartCB */
#define PANEL_END 11 /* control type: command, callback function: StartCB */
#define PANEL_IP 12 /* control type: string, callback function: (none) */
#define PANEL_FILENAME 13 /* control type: string, callback function: (none) */
#define PANEL_TIMER 14 /* control type: timer, callback function: (none) */
#define PANEL_TWIN1 15 /* control type: numeric, callback function: (none) */
#define PANEL_TWIN0 16 /* control type: numeric, callback function: (none) */
#define PANEL_ITRGLEVEL 17 /* control type: numeric, callback function: (none) */
#define PANEL_TRGLEVEL 18 /* control type: numeric, callback function: (none) */
#define PANEL_EXPORTNAME 19 /* control type: string, callback function: (none) */
#define PANEL_FILETYPE 20 /* control type: ring, callback function: (none) */
#define PANEL_PFREQ 21 /* control type: numeric, callback function: (none) */
#define PANEL_NBEFORE 22 /* control type: numeric, callback function: (none) */
#define PANEL_SAMPLES 23 /* control type: numeric, callback function: (none) */
#define PANEL_NTOTAL 24 /* control type: numeric, callback function: (none) */
#define PANEL_NEVE 25 /* control type: numeric, callback function: (none) */
#define PANEL_CEVE 26 /* control type: numeric, callback function: (none) */
#define PANEL_ADC2 27 /* control type: graph, callback function: (none) */
#define PANEL_TDC2 28 /* control type: graph, callback function: (none) */
#define PANEL_ADC1 29 /* control type: graph, callback function: (none) */
#define PANEL_TDC1 30 /* control type: graph, callback function: (none) */
#define PANEL_DECIMATION 31 /* control type: ring, callback function: (none) */
#define PANEL_TRIGGER 32 /* control type: ring, callback function: (none) */
#define PANEL_ENABLEDOUTPUT 33 /* control type: radioButton, callback function: (none) */
#define PANEL_DEBUG 34 /* control type: radioButton, callback function: (none) */
#define PANEL_CH1 35 /* control type: radioButton, callback function: (none) */
#define PANEL_GRAPH 36 /* control type: graph, callback function: (none) */
#define PANEL_CH0 37 /* control type: radioButton, callback function: (none) */
#define PANEL_TEXTMSG 38 /* control type: textMsg, callback function: (none) */
#define PANEL_STDIO 39 /* control type: textBox, callback function: (none) */
#define PANEL_MAXX_3 40 /* control type: numeric, callback function: (none) */
#define PANEL_MINX_3 41 /* control type: numeric, callback function: (none) */
#define PANEL_NCH_3 42 /* control type: numeric, callback function: (none) */
#define PANEL_MAXX_4 43 /* control type: numeric, callback function: (none) */
#define PANEL_MINX_4 44 /* control type: numeric, callback function: (none) */
#define PANEL_NCH_4 45 /* control type: numeric, callback function: (none) */
#define PANEL_MAXX_2 46 /* control type: numeric, callback function: (none) */
#define PANEL_MINX_2 47 /* control type: numeric, callback function: (none) */
#define PANEL_NCH_2 48 /* control type: numeric, callback function: (none) */
#define PANEL_MAXX_5 49 /* control type: numeric, callback function: (none) */
#define PANEL_MINX_5 50 /* control type: numeric, callback function: (none) */
#define PANEL_MAXX_1 51 /* control type: numeric, callback function: (none) */
#define PANEL_MINX_1 52 /* control type: numeric, callback function: (none) */
#define PANEL_NCH_1 53 /* control type: numeric, callback function: (none) */
#define PANEL_IP 8 /* control type: string, callback function: (none) */
#define PANEL_FILENAME 9 /* control type: string, callback function: (none) */
#define PANEL_TIMER 10 /* control type: timer, callback function: (none) */
#define PANEL_TWIN1 11 /* control type: numeric, callback function: (none) */
#define PANEL_TWIN0 12 /* control type: numeric, callback function: (none) */
#define PANEL_ITRGLEVEL 13 /* control type: numeric, callback function: (none) */
#define PANEL_TRGLEVEL 14 /* control type: numeric, callback function: (none) */
#define PANEL_EXPORTNAME 15 /* control type: string, callback function: (none) */
#define PANEL_FILETYPE 16 /* control type: ring, callback function: (none) */
#define PANEL_PFREQ 17 /* control type: numeric, callback function: (none) */
#define PANEL_NBEFORE 18 /* control type: numeric, callback function: (none) */
#define PANEL_SAMPLES 19 /* control type: numeric, callback function: (none) */
#define PANEL_NTOTAL 20 /* control type: numeric, callback function: (none) */
#define PANEL_NEVE 21 /* control type: numeric, callback function: (none) */
#define PANEL_CEVE 22 /* control type: numeric, callback function: (none) */
#define PANEL_ADC2 23 /* control type: graph, callback function: (none) */
#define PANEL_TDC2 24 /* control type: graph, callback function: (none) */
#define PANEL_ADC1 25 /* control type: graph, callback function: (none) */
#define PANEL_TDC1 26 /* control type: graph, callback function: (none) */
#define PANEL_DECIMATION 27 /* control type: ring, callback function: (none) */
#define PANEL_TRIGGER 28 /* control type: ring, callback function: (none) */
#define PANEL_ENABLEDOUTPUT 29 /* control type: radioButton, callback function: (none) */
#define PANEL_DEBUG 30 /* control type: radioButton, callback function: (none) */
#define PANEL_CH1 31 /* control type: radioButton, callback function: (none) */
#define PANEL_GRAPH 32 /* control type: graph, callback function: (none) */
#define PANEL_CH0 33 /* control type: radioButton, callback function: (none) */
#define PANEL_TEXTMSG 34 /* control type: textMsg, callback function: (none) */
#define PANEL_STDIO 35 /* control type: textBox, callback function: (none) */
#define PANEL_MAXX_3 36 /* control type: numeric, callback function: (none) */
#define PANEL_MINX_3 37 /* control type: numeric, callback function: (none) */
#define PANEL_NCH_3 38 /* control type: numeric, callback function: (none) */
#define PANEL_MAXX_4 39 /* control type: numeric, callback function: (none) */
#define PANEL_MINX_4 40 /* control type: numeric, callback function: (none) */
#define PANEL_NCH_4 41 /* control type: numeric, callback function: (none) */
#define PANEL_MAXX_2 42 /* control type: numeric, callback function: (none) */
#define PANEL_MINX_2 43 /* control type: numeric, callback function: (none) */
#define PANEL_NCH_2 44 /* control type: numeric, callback function: (none) */
#define PANEL_MAXX_5 45 /* control type: numeric, callback function: (none) */
#define PANEL_MINX_5 46 /* control type: numeric, callback function: (none) */
#define PANEL_MAXX_1 47 /* control type: numeric, callback function: (none) */
#define PANEL_MINX_1 48 /* control type: numeric, callback function: (none) */
#define PANEL_NCH_1 49 /* control type: numeric, callback function: (none) */
#define PANEL_CONNECT 50 /* control type: textButton, callback function: StartCB */
#define PANEL_START 51 /* control type: textButton, callback function: StartCB */
#define PANEL_ADCTYPE 52 /* control type: binary, callback function: (none) */
 
 
/* Control Arrays: */
/cvi/RedPitaya/soccli/redpitaya_gui.uir
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/cvi/RedPitaya/soccli/soccli.c
26,7 → 26,8
int initialized = 0;
#define MAX_THREADS 10
int nsamples=0;
float athreshold;
int adctype;
float athreshold, twin0,twin1;
float timebins[0XFFFF];
 
FILE *foutput;
174,6 → 175,11
SetCtrlAttribute (panelHandle, PANEL_GRAPH, ATTR_LABEL_TEXT , "sampling adc data");
SetCtrlAttribute (panelHandle, PANEL_GRAPH, ATTR_XNAME, "t(us)" );
SetCtrlAttribute (panelHandle, PANEL_GRAPH, ATTR_YNAME, "U(V)" );
 
GetCtrlVal(panelHandle,PANEL_TWIN0, &twin0);
GetCtrlVal(panelHandle,PANEL_TWIN1, &twin1);
GetCtrlVal(panelHandle,PANEL_ADCTYPE, &adctype);
GetCtrlVal(panelHandle,PANEL_ITRGLEVEL , &athreshold);
return 0;
}
 
184,7 → 190,9
int neve=0;
int *data = (ibuf+3);
int nr=0;
printf("Run HDR LEN=%d NEVE=%d dt=%f\n", ibuf[0],ibuf[1],fbuf[2]);
static float adc = 10000;
static float qdc = 0;
printf("Run HDR LEN=%d NEVE=%d dt=%f adc=%f qdc=%f\n", ibuf[0],ibuf[1],fbuf[2],adc,qdc);
while (nr<nb) {
 
int recid = *data++;
224,15 → 232,28
}
nr+=8;
float adcdata = 10000;
adc=10000;
qdc=0;
int nqdc;
for (int k=1; k<nsamples; k++) {
if (fdata[k] < adcdata) adcdata = fdata[k];
float t =timebins[k];
float tp=timebins[k-1];
if (fdata[k] < adc) adc = fdata[k];
if (t>twin0 && t<twin1 ) {
nqdc++;
qdc+=fdata[k];
}
if (fdata[k]< athreshold && fdata[k-1]> athreshold) {
double t0= timebins[k-1]+(athreshold-fdata[k-1])/(fdata[k]-fdata[k-1])* (timebins[k]-timebins[k-1]);
double t0= tp+(athreshold-fdata[k-1])/(fdata[k]-fdata[k-1])* (t-tp);
H1D_Fill(3+id, t0,1);
}
}
H1D_Fill(1+id, -adcdata,1);
if (nqdc) qdc/=nqdc;
//printf("adc %f qdc %f\n", adc,qdc);
if (adctype)
H1D_Fill(1+id, -adc,1);
else
H1D_Fill(1+id, -qdc,1);
nr+=4*nsamples;
data+=nsamples;
241,7 → 262,7
int event = *data++;
nr+=8;
neve++;
//printf("recid %d event %d\n",recid, event );
if (debug) printf("recid %d event %d\n",recid, event );
}
 
return neve;
278,7 → 299,7
if (retval<1) break;
nb += retval;
}
printf("Received RECID %d HDRLEN %d == read %d\n", hdr[0], size, nb);
if (debug) printf("Received RECID %d HDRLEN %d == read %d\n", hdr[0], size, nb);
switch (hdr[0]) {
294,7 → 315,7
if (foutput) fwrite(data, 1, nb, foutput);
SetCtrlVal(panelHandle,PANEL_CEVE , event);
if (event>=ncalls) StartCB (panelHandle, PANEL_END, EVENT_COMMIT, NULL,0,0);
if (event>=ncalls) StartCB (panelHandle, PANEL_START, EVENT_COMMIT, NULL,1,0);
break;
default:
350,18 → 371,26
 
double level =0;
GetCtrlVal(panel,PANEL_TRGLEVEL , &level);
GetCtrlVal(panel,PANEL_ITRGLEVEL , &athreshold);
 
 
switch (control) {
case PANEL_CONNECT:
case PANEL_CONNECT: {
int state;
GetCtrlVal(panel,PANEL_CONNECT, &state);
if (state) {
ConnectToTCPServerEx (&chandle, 9930, ip, SocketCB, NULL, 0, TCP_ANY_LOCAL_PORT);
break;
case PANEL_DISCONNECT:
} else {
if (chandle!=0) DisconnectFromTCPServer (chandle);
chandle = 0;
}
}
break;
case PANEL_START:
case PANEL_START: {
int state;
GetCtrlVal(panel,PANEL_START, &state);
if (state && eventData1==0) {
histoinit();
for (int i=0; i<nsamples; i++) timebins[i]=(i-nbefore)*8*decimation/1000.;
if (output) foutput = fopen(filename, "wb");
SetCtrlVal(panel,PANEL_CEVE , 0);
377,9 → 406,7
cbuff[0] = trigger;
cbuff[1] = mask;
ClientTCPWrite(chandle,&hdr[0],hdr[1],5000); // acquire
break;
 
case PANEL_END:
} else {
hdr[0] = 1;
hdr[1] = 2*sizeof(int);
ClientTCPWrite(chandle,&hdr[0],hdr[1],5000); // stop the transfer
386,8 → 413,9
if (foutput) fclose(foutput);
foutput=NULL;
}
break;
}
default:
printf("Unknown command\n");
break;
394,8 → 422,8
}
 
 
for (int i=0; i<nsamples; i++) timebins[i]=i*8*decimation/1000.;
 
 
ProcessSystemEvents ();
break;
}
422,10 → 450,18
switch (event) {
case EVENT_COMMIT:
switch (control){
case PANEL_EXPORT_1: hid=1; break;
case PANEL_EXPORT_2: hid=2; break;
case PANEL_EXPORT_3: hid=3; break;
case PANEL_EXPORT_4: hid=4; break;
case PANEL_EXPORT_1:
hid=1;
break;
case PANEL_EXPORT_2:
hid=2;
break;
case PANEL_EXPORT_3:
hid=3;
break;
case PANEL_EXPORT_4:
hid=4;
break;
}
export_data(hid);
/cvi/RedPitaya/soccli/soccli.cws
66,23 → 66,23
[File 0002]
Path = "/c/home/CVI/RedPitaya/soccli/soccli.c"
File Type = "CSource"
Disk Date = 3573039184
Disk Date = 3573111222
In Projects = "1,"
Window Top = 33
Window Left = 10
Window Z-Order = 1
Source Window State = "0,344,344,344,0,39,39,0,0,152,29,409,0,430,28,2,72,0,373,0,349,595,1,9601,"
Source Window State = "0,232,233,232,6,22,6,0,0,152,29,290,0,301,15,2,103,0,404,0,349,595,1,9601,"
 
[File 0003]
Path = "/c/home/CVI/RedPitaya/soccli/redpitaya_gui.uir"
File Type = "User Interface Resource"
Disk Date = 3573035574
Disk Date = 3573110898
In Projects = "1,"
Window Top = 64
Window Left = 26
Window Height = 232
Window Width = 595
Window Z-Order = 5
Window Z-Order = 2
 
[File 0004]
Path = "/c/home/CVI/RedPitaya/RedPitaya_ui.uir"
142,7 → 142,7
In Projects = ""
Window Top = 64
Window Left = 26
Window Z-Order = 3
Window Z-Order = 4
Source Window State = "1,31,31,31,2,13,13,0,0,80,0,0,0,0,0,23,13,0,37,144,323,683,1,0,"
 
[File 0010]
152,7 → 152,7
In Projects = ""
Window Top = 95
Window Left = 42
Window Z-Order = 2
Window Z-Order = 3
Source Window State = "1,712,712,712,2,66,2,0,3,80,0,0,0,0,0,19,697,0,712,66,271,683,1,0,"
 
[File 0011]
162,7 → 162,7
In Projects = ""
Window Top = 64
Window Left = 26
Window Z-Order = 4
Window Z-Order = 5
Source Window State = "1,21,21,21,12,15,15,0,0,80,0,0,0,0,0,19,6,0,26,21,271,683,1,0,"
 
[File 0012]