/cvi/instr/DRS/drs4.c |
---|
1,3 → 1,4 |
#include <tcpsupp.h> |
#include "H1D.h" |
#include "H2D.h" |
#include <formatio.h> |
6,18 → 7,34 |
#include <cvirte.h> |
#include <userint.h> |
#include "drs4.h" |
#include "scaler.h" |
#include "drsread.h" |
#include "K6517.h" |
#define MIKRO |
K6517STATUS K6517Stat; |
static int K6517_Interface,K6517_Port,K6517_Gdev; |
//#define MIKRO |
#ifdef MIKRO |
#include "MIKRO.h" |
#endif |
static int daq_on; |
static int ph, p2,plothandle[4]= {0,0,0,0}; |
/*---------------------------------------------------------------------------*/ |
/* Module-globals */ |
/*---------------------------------------------------------------------------*/ |
static unsigned int g_hconversation; |
static int g_hmainPanel; |
static int g_connected = 0; |
static int g_TCPError = 0; |
int daq_on; |
int ph, p2,p3,p4, plothandle[4]= {0,0,0,0}; |
static int qdcplothandle[4]= {0,0,0,0}; |
static int scanplothandle; |
static int tfID; |
static int rID; |
static int controlID; |
#define MAX_THREADS 10 |
25,6 → 42,13 |
static CmtThreadPoolHandle poolHandle = 0; |
static float gSum[4]={0,0,0,0}; |
int gActive[4]= {0,0,0,0}; |
double gTwinMin[4]= {0,0,0,0}; |
double gTwinMax[4]= {0,0,0,0}; |
double gFx[4]= {0,0,0,0}; |
int main (int argc, char *argv[]) { |
short port; |
if (InitCVIRTE (0, argv, 0) == 0) |
33,6 → 57,12 |
return -1; |
if ((p2 = LoadPanel (0, "drs4.uir", SCAN)) < 0) |
return -1; |
if ((p3 = LoadPanel (0, "drs4.uir", QDC)) < 0) |
return -1; |
if ((p4 = LoadPanel (0, "scaler.uir", SCALER)) < 0) |
return -1; |
DisableBreakOnLibraryErrors(); |
SetStdioPort (CVI_STDIO_WINDOW); |
SetSleepPolicy(VAL_SLEEP_MORE); |
CmtNewThreadPool (MAX_THREADS, &poolHandle); |
39,7 → 69,8 |
DisplayPanel (ph); |
DisplayPanel (p2); |
DisplayPanel (p3); |
DisplayPanel (p4); |
#ifdef MIKRO |
GetCtrlVal(p2, SCAN_PORT, &port); |
if (MIKRO_Open (port)) MessagePopup ("Error", "Mikro Port Not found !\n Change in the GUI") ; |
47,11 → 78,17 |
MIKRO_Init(2,0); |
#endif |
K6517_open (1,4,3,0,13); |
RunUserInterface (); |
DiscardPanel (ph); |
DiscardPanel (p2); |
DiscardPanel (p3); |
DiscardPanel (p4); |
CmtDiscardThreadPool (poolHandle); |
MIKRO_Close (); |
#ifdef MIKRO |
MIKRO_Close (); |
#endif |
return 0; |
} |
92,7 → 129,14 |
void CVICALLBACK EndOfThresholdScanThread ( CmtThreadPoolHandle poolhandle, |
CmtThreadFunctionID functionID, unsigned int event, |
int value, void *callbackData ) { |
printf("End of Threshold Scan Thread \n"); |
return ; |
} |
void CVICALLBACK EndOfThread ( CmtThreadPoolHandle poolhandle, |
CmtThreadFunctionID functionID, unsigned int event, |
int value, void *callbackData ) { |
106,6 → 150,7 |
static float xs[4][1024]; |
int CVICALLBACK daq(void *functionData) { |
126,20 → 171,28 |
int neveold = 0; |
double rate; |
int *args = (int *) functionData; |
double twin[2]; |
int wfm=0; |
const int init[4] = { QDC_INIT_1 ,QDC_INIT_2 ,QDC_INIT_3 ,QDC_INIT_4 }; |
const int fx[4] = { PANEL_SCALE_1 ,PANEL_SCALE_2 ,PANEL_SCALE_3 ,PANEL_SCALE_4 }; |
const int active[4] = { QDC_ACTIVE_1 ,QDC_ACTIVE_2 ,QDC_ACTIVE_3 ,QDC_ACTIVE_4 }; |
GetCtrlVal(ph, PANEL_CH0, &imask[0] ); |
GetCtrlVal(ph, PANEL_CH1, &imask[1] ); |
GetCtrlVal(ph, PANEL_CH2, &imask[2] ); |
GetCtrlVal(ph, PANEL_CH3, &imask[3] ); |
GetCtrlVal(p3, QDC_WFM, &wfm ); |
mask = 0; |
for (int i=0; i<4; i++) { |
if (imask[i]) mask |= (1<<i); |
if (imask[i]) { |
mask |= (1<<i); |
ScaleCB(ph,fx[i],EVENT_COMMIT,NULL, 0,0); |
SetActiveCB(p3,active[i],EVENT_COMMIT,NULL, 0,0); |
InitQdcHistogramCB(p3, init[i],EVENT_COMMIT,NULL, 0,0); |
} |
} |
LogScaleCB(p3, QDC_LOGY,EVENT_COMMIT,NULL, 0,0); |
GetCtrlVal(ph,PANEL_NEVE, &neve); |
GetCtrlVal(ph,PANEL_DEBUG, &verbose); |
156,8 → 209,7 |
GetCtrlVal(ph,PANEL_TRGPOLARITY, &trgpolarity); |
GetCtrlVal(ph,PANEL_RANGE, &range); |
GetCtrlVal(ph,PANEL_TWIN0, &twin[0]); |
GetCtrlVal(ph,PANEL_TWIN1, &twin[1]); |
//printf("mask=0x%x\n",mask); |
DRSSetMask( (unsigned char)( mask & 0xF ) ); |
176,12 → 228,14 |
FILE *fp= NULL; |
if (enabledoutput) { |
if (args[0]) { |
if (1==1) { |
GetCtrlVal(ph, PANEL_FILENAME, filename ); |
printf("%s\n", filename); |
fp = fopen(filename,"wb"); |
} else { |
GetCtrlVal(p2, SCAN_FILENAME, filename ); |
fp = fopen(filename,"ab"); |
printf("%s\n", filename); |
} |
} |
219,6 → 273,7 |
if (!daq_on) break; |
time(&t); |
if (t!=told ) { |
PlotQdcHistogramCB(0,0,EVENT_COMMIT,NULL, 0,0); |
rate = (i-neveold); |
printf("%d events in %2.2f min (%d s) Rate %f Hz %s ",i+1, (double)(t-tstart)/60.,(t-tstart), rate , ctime(&t)); |
GetCtrlVal(ph,PANEL_PFREQ, &pfreq); |
226,23 → 281,37 |
} |
told=t; |
// Save data |
if (nb>0 && fp) fwrite(buffer, 1,nb ,fp); |
// Plot Data |
for (int k=0; k<4; k++) { |
if ( (mask & ( 0x1<<k )) ){ |
double fSum= 0; |
float *t=DRSGetTime(k); |
float *x=DRSGetWave(k); |
; |
for (int j=0 ; j<1024 ; j++) { |
xs[k][j]= x[j]*1e-3; |
xs[k][j]= x[j]*1e-3*gFx[k]; |
if (gActive[k]){ |
if (t[j]> gTwinMin[k] && t[j] < gTwinMax[k]) { |
fSum+= fabs(xs[k][j]); |
} |
if (wfm){ |
H2D_Fill(200+k,t[j], xs[k][j],1); |
} |
//if (verbose) printf("[%d] %d. x= %3.2f y=%3.2f\n", k, i, t[j], x[j] ); |
} |
} |
if (verbose) printf("qdc[%d] %3.2f active=%d\n", k, fSum ,gActive[k]); |
if (gActive[k]) { |
if (!wfm) { |
H1D_Fill(200+k,fSum,1.); |
} |
} |
gSum[k]+=fSum; |
if (t[j]> twin[0] && t[j] < twin[1]) gSum[k]+= fabs(xs[k][j]); |
if (verbose) printf("[%d] %d. x= %3.2f y=%3.2f\n", k, i, t[j], x[j] ); |
//h[k]->Fill( t[i], x[i]*1e-3); |
} |
if (i % pfreq == 0) { |
const int col[4]= {VAL_WHITE,VAL_RED,VAL_GREEN,VAL_BLUE}; |
if (plothandle[k]) DeleteGraphPlot (ph, PANEL_GRAPH, plothandle[k], VAL_IMMEDIATE_DRAW); |
plothandle[k] = PlotXY (ph, PANEL_GRAPH, t, xs[k], 1024, VAL_FLOAT, VAL_FLOAT, VAL_THIN_LINE, VAL_NO_POINT, VAL_SOLID, 1, col[k]); |
267,7 → 336,271 |
} |
void CVICALLBACK EndOfThrScan ( CmtThreadPoolHandle poolhandle, |
CmtThreadFunctionID functionID, unsigned int event, |
int value, void *callbackData ) { |
//SetDimming(0); |
printf("End of thrscan \n"); |
return ; |
} |
int scaler(int min, int max, int dx, int time_set, char *filename); |
int CVICALLBACK thrscan(void *functionData) { |
char str[0xFF]; |
char path[0xFF]; |
int step,min,max, mtime; |
GetCtrlVal(p4, SCALER_STEP,&step); |
GetCtrlVal(p4, SCALER_TIME,&mtime); |
GetCtrlVal(p4, SCALER_MAX,&max); |
GetCtrlVal(p4, SCALER_MIN,&min); |
GetCtrlVal(ph, PANEL_FILENAME,path); |
sprintf(str, "%s.thr", path); |
scaler(min,max,step,mtime,str); |
return 0; |
} |
int CVICALLBACK acquire_data (void *arg) { |
char *sarg = (char *) arg; |
printf("sarg %s\n", sarg); |
char str[0xFF]; |
char path[0xFF]; |
GetCtrlVal(ph,PANEL_PATH,path); |
sprintf(str, "%s%s.dat", path, sarg); |
SetCtrlVal(ph, PANEL_FILENAME,str); |
int flag=0; |
ThreadFunctionPtr mythread = thrscan; |
int data; |
int threadhandle; |
CmtScheduleThreadPoolFunctionAdv (poolHandle, mythread, &data, |
DEFAULT_THREAD_PRIORITY, |
EndOfThresholdScanThread, |
EVENT_TP_THREAD_FUNCTION_END, |
NULL, RUN_IN_SCHEDULED_THREAD, |
&threadhandle); |
daq(&flag); |
CmtWaitForThreadPoolFunctionCompletionEx (poolHandle, threadhandle, OPT_TP_PROCESS_EVENTS_WHILE_WAITING, CMT_WAIT_FOREVER); |
return 0; |
} |
int CVICALLBACK SwitchOnOffCB (int panel, int control, int event, |
void *callbackData, int eventData1, int eventData2) |
{ |
unsigned char state; |
switch (event) |
{ |
case EVENT_COMMIT: |
GetCtrlVal(panel, control, &state); |
K6517_vsource_operate (state); |
break; |
} |
return 0; |
} |
int CVICALLBACK SetVoltageCB (int panel, int control, int event, |
void *callbackData, int eventData1, int eventData2) { |
double vbr; |
switch (event) { |
case EVENT_COMMIT: |
GetCtrlVal (ph, PANEL_VBR, &vbr ); |
K6517_vsource_set (vbr+2); |
break; |
} |
return 0; |
} |
int TScan () { |
double temp; |
double volt,vbr; |
int n=0; |
int led; |
GetNumTableRows (ph, PANEL_TABLE, &n ); |
daq_on = 1; |
for(int i=0; i<n; i++) { |
if (!daq_on) break; |
GetTableCellVal (ph, PANEL_TABLE, MakePoint (1,i+1), &temp); |
GetTableCellVal (ph, PANEL_TABLE, MakePoint (2,i+1), &vbr); |
if (temp>100) break; |
char transmitBuf[512]= {0}; |
sprintf(transmitBuf, "1 %f\n", temp); |
if (g_connected) |
if ( ClientTCPWrite (g_hconversation, transmitBuf, strlen (transmitBuf), 1000) < 0) printf("Transmit Error\n"); else printf("%s\n", transmitBuf); |
SetCtrlVal(ph,PANEL_LED, 0); |
do { |
time_t t0 = time(NULL); |
SetCtrlVal(ph,PANEL_TIME, ctime(&t0)); |
Delay(1); |
GetCtrlVal(ph,PANEL_LED, &led); |
if (led) { |
for (int k=0;k<10;k++){ |
Delay(1); |
if (!daq_on) break; |
} |
GetCtrlVal(ph,PANEL_LED, &led); |
} |
if (!daq_on) break; |
} while (!led); |
if (!daq_on) break; |
int itemp = (int) temp; |
int n1=0; |
GetNumTableRows (ph, PANEL_VTABLE, &n1 ); |
for(int k=0; k<n1; k++) { |
if (!daq_on) break; |
GetTableCellVal (ph, PANEL_VTABLE, MakePoint (1,k+1), &volt); |
if (volt<-100) break; |
double voltage = vbr + volt; |
int ivolt=(int)(volt*100); |
K6517_vsource_set (voltage); |
K6517_vsource_operate (1); |
char str[0xFF]; |
sprintf(str,"%d_%d", itemp, ivolt); |
printf("%d %d %s\n",i,k, str); |
acquire_data(str); |
K6517_vsource_operate (0); |
} |
} |
return 0; |
} |
int CVICALLBACK TScanCB (int panel, int control, int event, |
void *callbackData, int eventData1, int eventData2) { |
switch (event) { |
case EVENT_COMMIT:{ |
ThreadFunctionPtr mythread = TScan; |
CmtScheduleThreadPoolFunctionAdv (poolHandle, mythread, &rID, |
DEFAULT_THREAD_PRIORITY, |
EndOfThread, |
EVENT_TP_THREAD_FUNCTION_END, |
NULL, RUN_IN_SCHEDULED_THREAD, |
&tfID); |
} |
break; |
} |
return 0; |
} |
int CVICALLBACK LogScaleCB (int panel, int control, int event, |
void *callbackData, int eventData1, int eventData2) { |
const unsigned int gr[4] = { QDC_GRAPH_1 ,QDC_GRAPH_2 ,QDC_GRAPH_3 ,QDC_GRAPH_4 }; |
int wfm=0; |
int attr, logy, selected; |
switch (event) { |
case EVENT_COMMIT: |
GetCtrlVal(p3,QDC_WFM,&wfm); |
GetCtrlVal(panel, control, &selected); |
attr= ATTR_YMAP_MODE; |
if(selected) logy=VAL_LOG; else logy=VAL_LINEAR; |
if (wfm) logy=VAL_LINEAR; |
for (int i=0;i<4;i++) SetCtrlAttribute (panel, gr[i],attr, logy); |
break; |
} |
return 0; |
} |
int CVICALLBACK ExecRootCB (int panel, int control, int event, |
void *callbackData, int eventData1, int eventData2) { |
switch (event) { |
case EVENT_COMMIT:{ |
char fileName[100]; |
char fname[100]; |
char path[100]; |
int trgchannel; |
GetCtrlVal(panel, PANEL_FILENAME, fileName); |
GetCtrlVal(panel,PANEL_TRGCHANNEL, &trgchannel); |
GetCtrlVal(panel, PANEL_PATH, path); |
sprintf(fname, "%s/%s", path, fileName); |
//sprintf(fname, "%s", fileName); |
int status; |
char name[MAX_PATHNAME_LEN]; |
// char dfile[MAX_PATHNAME_LEN]; |
// char efile[MAX_PATHNAME_LEN]; |
// status = FileSelectPopup ("dat", "*.dat", ".dat", |
// "Izberi datoteko s podatki", |
// VAL_LOAD_BUTTON, 0, 0, 1, 0, efile); |
// EscapeString(efile,dfile); |
sprintf(name ,"C:/home/dominik/runroot.bat \"C:/home/dominik/AnalyseWaveForms.cxx(-1,1000,\\\"%s\\\",%d)\" ", fname, trgchannel); |
printf("%s\n",name); |
LaunchExecutable(name); |
break; |
} |
} |
return 0; |
} |
int CVICALLBACK TempTableCB (int panel, int control, int event, |
void *callbackData, int eventData1, int eventData2) { |
switch (event) { |
case EVENT_COMMIT: { |
int status; |
char name[MAX_PATHNAME_LEN]; |
char dfile[MAX_PATHNAME_LEN]; |
char efile[MAX_PATHNAME_LEN]; |
status = FileSelectPopup ("dat", "*.dat", ".dat", |
"Izberi datoteko s podatki", |
VAL_LOAD_BUTTON, 0, 0, 1, 0, efile); |
printf("%s", efile); |
FILE *fp=fopen(efile,"r"); |
float I; |
float V; |
int temp; |
int ndim=400; |
char line[400]; |
if (fp) { |
int k=0; |
while (fgets(line,ndim,fp)!=NULL) { |
k++; |
sscanf(line,"%*s%d%f%f",&temp,&I,&V); |
printf("%d %f %f\n", temp, I, V); |
SetTableCellVal (ph, PANEL_TABLE, MakePoint (1,k), (double)temp); |
SetTableCellVal (ph, PANEL_TABLE, MakePoint (2,k), V); |
} |
SetTableCellVal (ph, PANEL_TABLE, MakePoint (1,k+1), 1000.0); |
fclose(fp); |
} |
break; |
} |
} |
return 0; |
} |
int CVICALLBACK scan(void *functionData) { |
int dx[3]={0,0,0}; |
372,6 → 705,8 |
} |
int CVICALLBACK StartCB (int panel, int control, int event, |
void *callbackData, int eventData1, int eventData2) { |
ThreadFunctionPtr mythread = NULL; |
385,6 → 720,12 |
controlID= control; |
} |
if (panel == p2 && control == SCAN_SCAN) mythread = scan; |
if (panel == p4 && control == SCALER_START) mythread = thrscan; |
if (panel == ph && control == PANEL_ACQUIRE) { |
mythread = acquire_data; |
controlID=50; |
} |
if (mythread!=NULL) { |
printf("New Thread panel=%d button=%d\n", panel, control); |
534,6 → 875,61 |
return 0; |
} |
int CVICALLBACK InitQdcHistogramCB (int panel, int control, int event, |
void *callbackData, int eventData1, int eventData2) { |
const int min[4] = { QDC_MIN_1 ,QDC_MIN_2 ,QDC_MIN_3 ,QDC_MIN_4 }; |
const int max[4] = { QDC_MAX_1 ,QDC_MAX_2 ,QDC_MAX_3 ,QDC_MAX_4 }; |
const int nbin[4] = { QDC_NBIN_1 ,QDC_NBIN_2 ,QDC_NBIN_3 ,QDC_NBIN_4 }; |
const int init[4] = { QDC_INIT_1 ,QDC_INIT_2 ,QDC_INIT_3 ,QDC_INIT_4 }; |
char title[0xFF]; |
char name[0xFF]; |
switch (event) { |
case EVENT_COMMIT:{ |
int ctrl=-1; |
for (int k=0;k<4;k++) if ( init[k]==control & panel==p3 ) ctrl=k; |
if (ctrl<0) break; |
double minx; |
double maxx; |
int nbins; |
int wfm; |
int frq; |
GetCtrlVal(p3,min[ctrl],&minx); |
GetCtrlVal(p3,max[ctrl],&maxx); |
GetCtrlVal(p3,nbin[ctrl],&nbins); |
GetCtrlVal(p3,QDC_WFM,&wfm); |
GetCtrlVal(ph,PANEL_FREQUENCY,&frq); |
sprintf(name,"qdc%d", ctrl); |
sprintf(title,"QDC ch %d", ctrl); |
H1D_Init(200+ctrl, name, title, nbins, minx,maxx); |
sprintf(name,"avgwfm%d", ctrl); |
sprintf(title,"Average waveform ch %d", ctrl); |
H2D_Init(200+ctrl, name, title, 1024, 0,1024/frq, 100, -0.5,0.5); |
break; |
} |
} |
return 0; |
} |
int CVICALLBACK PlotQdcHistogramCB (int panel, int control, int event, |
void *callbackData, int eventData1, int eventData2) { |
int hid=0; |
int nx; |
int ny; |
const unsigned int gr[4] = { QDC_GRAPH_1 ,QDC_GRAPH_2 ,QDC_GRAPH_3 ,QDC_GRAPH_4 }; |
int wfm=0; |
switch (event) { |
case EVENT_COMMIT: |
GetCtrlVal(p3,QDC_WFM,&wfm); |
for (int i=0;i<4;i++) if (wfm) H2D_Draw(200+i,p3,gr[i],&qdcplothandle[i]); else H1D_Draw(200+i,p3,gr[i],&qdcplothandle[i]); |
break; |
} |
return 0; |
} |
int CVICALLBACK PlotScanHistogramCB (int panel, int control, int event, |
void *callbackData, int eventData1, int eventData2) { |
int hid=0; |
573,6 → 969,19 |
return 0; |
} |
int CVICALLBACK OpenQdcCB (int panel, int control, int event, |
void *callbackData, int eventData1, int eventData2) { |
switch (event) { |
case EVENT_COMMIT: |
DisplayPanel (ph); |
DisplayPanel (p3); |
break; |
} |
return 0; |
} |
int CVICALLBACK CalibrateCB (int panel, int control, int event, |
void *callbackData, int eventData1, int eventData2) { |
int status = 0; |
584,3 → 993,162 |
} |
return 0; |
} |
int CVICALLBACK SetActiveCB (int panel, int control, int event, |
void *callbackData, int eventData1, int eventData2) { |
const int c[4] = { QDC_ACTIVE_1 ,QDC_ACTIVE_2 ,QDC_ACTIVE_3 ,QDC_ACTIVE_4 }; |
const double twin0[4] = { QDC_TWIN0_1 ,QDC_TWIN0_2 ,QDC_TWIN0_3 ,QDC_TWIN0_4 }; |
const double twin1[4] = { QDC_TWIN1_1 ,QDC_TWIN1_2 ,QDC_TWIN1_3 ,QDC_TWIN1_4 }; |
int val=0; |
switch (event) { |
case EVENT_COMMIT: |
GetCtrlVal(panel, control, &val); |
int ctrl=-1; |
for (int k=0;k<4;k++) if ( c[k]==control & panel==p3 ) ctrl=k; |
if (ctrl<0) break; |
gActive[ctrl] = val; |
GetCtrlVal(panel, twin0[ctrl], &gTwinMin[ctrl]); |
GetCtrlVal(panel, twin1[ctrl], &gTwinMax[ctrl]); |
printf("Channel gActive[%d]=%d tmin %f tmax %f\n", ctrl,gActive[ctrl], gTwinMin[ctrl], gTwinMax[ctrl]); |
break; |
} |
return 0; |
} |
int CVICALLBACK ScaleCB (int panel, int control, int event, |
void *callbackData, int eventData1, int eventData2) { |
const int c[4] = { PANEL_SCALE_1 ,PANEL_SCALE_2 ,PANEL_SCALE_3 ,PANEL_SCALE_4 }; |
switch (event) { |
case EVENT_COMMIT: { |
double val; |
GetCtrlVal(panel, control, &val); |
int ctrl=-1; |
for (int k=0;k<4;k++) if ( c[k]==control & panel==ph ) ctrl=k; |
if (ctrl<0) break; |
gFx[ctrl] = val; |
printf("Scaling factor gFx[%d]=%f\n", ctrl,gFx[ctrl]); |
break; |
} |
} |
return 0; |
} |
/*---------------------------------------------------------------------------*/ |
/* Macros */ |
/*---------------------------------------------------------------------------*/ |
#define tcpChk(f) if ((g_TCPError=(f)) < 0) {ReportTCPError();} |
/*---------------------------------------------------------------------------*/ |
/* Internal function prototypes */ |
/*---------------------------------------------------------------------------*/ |
int CVICALLBACK ClientTCPCB (unsigned handle, int event, int error, |
void *callbackData); |
static void ReportTCPError (void); |
/*---------------------------------------------------------------------------*/ |
/* Report TCP Errors if any */ |
/*---------------------------------------------------------------------------*/ |
static void ReportTCPError(void) |
{ |
if (g_TCPError < 0) |
{ |
char messageBuffer[1024]; |
sprintf(messageBuffer, |
"TCP library error message: %s\nSystem error message: %s", |
GetTCPErrorString (g_TCPError), GetTCPSystemErrorString()); |
MessagePopup ("Error", messageBuffer); |
g_TCPError = 0; |
} |
} |
/*---------------------------------------------------------------------------*/ |
int CVICALLBACK DisconnectCB (int panel, int control, int event, |
void *callbackData, int eventData1, int eventData2) { |
switch (event) { |
case EVENT_COMMIT: |
if (g_connected) |
DisconnectFromTCPServer (g_hconversation); |
g_hconversation = 0; |
g_connected = 0; |
break; |
} |
return 0; |
} |
int CVICALLBACK ConnectCB (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { |
int portNum=10000; |
char tempBuf[512]; |
sprintf(tempBuf,"localhost"); |
switch (event) { |
case EVENT_COMMIT: |
if (g_connected) return 0; |
if (ConnectToTCPServer (&g_hconversation, portNum, tempBuf, ClientTCPCB, NULL, 5000) < 0) |
MessagePopup("TCP Client", "Connection to server failed !"); |
else |
{ |
SetWaitCursor (0); |
g_connected = 1; |
/* We are successfully connected -- gather info */ |
if (GetTCPHostAddr (tempBuf, 256) >= 0) printf("%s\n" ,tempBuf); |
if (GetTCPHostName (tempBuf, 256) >= 0) printf("%s\n" ,tempBuf); |
tcpChk (GetTCPPeerAddr (g_hconversation, tempBuf, 256)); |
printf("%s\n" ,tempBuf); |
tcpChk (GetTCPPeerName (g_hconversation, tempBuf, 256)); |
printf("%s\n" ,tempBuf); |
} |
break; |
} |
return 0; |
} |
int CVICALLBACK ClientTCPCB (unsigned handle, int event, int error, void *callbackData) |
{ |
char receiveBuf[256] = {0}; |
ssize_t dataSize = sizeof (receiveBuf) - 1; |
switch (event) |
{ |
case TCP_DATAREADY: |
if ((dataSize = ClientTCPRead (g_hconversation, receiveBuf, |
dataSize, 1000)) |
< 0) |
{ |
printf( "Receive Error\n"); |
} |
else |
{ |
receiveBuf[dataSize] = '\0'; |
//printf("%s", receiveBuf); |
float temp = 0; |
float humidity = 0; |
float dt=0; |
float tdiff=0; |
int t0 = 0; |
sscanf(receiveBuf, "%d%f%f%f%f", &t0,&humidity,&temp, &tdiff, &dt); |
SetCtrlVal(ph,PANEL_TMON, temp); |
SetCtrlVal(ph,PANEL_HUMIDITY, humidity); |
if (fabs(tdiff)<0.2 && fabs(dt) < 0.05) SetCtrlVal(ph,PANEL_LED, 1); |
else SetCtrlVal(ph,PANEL_LED, 0); |
} |
break; |
case TCP_DISCONNECT: |
MessagePopup ("TCP Client", "Server has closed connection!"); |
g_connected = 0; |
break; |
} |
return 0; |
} |
/cvi/instr/DRS/drs4.cws |
---|
1,6 → 1,6 |
[Workspace Header] |
Version = 1302 |
Pathname = "/c/home/rok/DRS/drs4.cws" |
Pathname = "/c/home/CVI/instr/DRS/drs4.cws" |
CVI Dir = "/c/program files/national instruments/cvi2013" |
CVI Shared Dir = "/C/Program Files/National Instruments/Shared/CVI" |
CVI Pub Local Dir = "/C/ProgramData/National Instruments/CVI2013" |
9,15 → 9,16 |
IVI Standard Root 64-bit Dir = "/C/Program Files/IVI Foundation/IVI" |
VXIplug&play Framework Dir = "/C/Program Files/IVI Foundation/VISA/winnt" |
VXIplug&play Framework 64-bit Dir = "/C/Program Files/IVI Foundation/VISA/win64" |
Number of Projects = 1 |
Number of Projects = 2 |
Active Project = 1 |
Project 0001 = "drs4.prj" |
Drag Bar Left = 280 |
Window Top = 31 |
Window Left = 105 |
Window Bottom = 853 |
Window Right = 1554 |
Maximized = True |
Project 0002 = "/c/home/CVI/apps/TempCtrl/TempCtrl.prj" |
Drag Bar Left = 245 |
Window Top = 65 |
Window Left = 31 |
Window Bottom = 795 |
Window Right = 1432 |
Maximized = False |
Maximized Children = True |
Max32 Number Of Errors = 20 |
Track Include File Dependencies = True |
30,9 → 31,9 |
Hide Windows = False |
Break At First Statement = False |
Sort Type = "File Name" |
Number of Opened Files = 3 |
Number of Opened Files = 15 |
Window Confinement Region Enabled = True |
MainColumnWidth = 263 |
MainColumnWidth = 228 |
FileDateColumnWidth = 70 |
FileSizeColumnWidth = 70 |
45,65 → 46,227 |
Batch Build Release = False |
Batch Build Debug = False |
[Project Header 0002] |
Version = 1302 |
Don't Update DistKit = False |
Platform Code = 4 |
Build Configuration = "Debug" |
Warn User If Debugging Release = 1 |
Batch Build Release = False |
Batch Build Debug = False |
[File 0001] |
Path = "/c/home/cvi/instr/HISTO/H1D.fp" |
Path = "/c/home/CVI/instr/HISTO/H1D.fp" |
File Type = "Function Panel" |
Disk Date = 3568268329 |
Disk Date = 3568705022 |
In Projects = "1," |
[File 0002] |
Path = "/c/home/cvi/instr/HISTO/H2D.fp" |
Path = "/c/home/CVI/instr/HISTO/H2D.fp" |
File Type = "Function Panel" |
Disk Date = 3568268329 |
Disk Date = 3568705022 |
In Projects = "1," |
[File 0003] |
Path = "/c/home/cvi/instr/MIKRO/MIKRO.fp" |
Path = "/c/home/CVI/instr/K6517/K6517.fp" |
File Type = "Function Panel" |
Disk Date = 3555480934 |
Disk Date = 3603694414 |
In Projects = "1," |
[File 0004] |
Path = "/c/home/rok/DRS/drs4.c" |
Path = "/c/home/CVI/instr/MIKRO/MIKRO.fp" |
File Type = "Function Panel" |
Disk Date = 3228639698 |
In Projects = "1," |
[File 0005] |
Path = "/c/home/CVI/instr/PROLOGIX/prologix.fp" |
File Type = "Function Panel" |
Disk Date = 3596087345 |
In Projects = "1," |
[File 0006] |
Path = "/c/home/CVI/instr/pw18-1.8aq/pw18-1.8aq.fp" |
File Type = "Function Panel" |
Disk Date = 3606995791 |
In Projects = "2," |
[File 0007] |
Path = "/c/home/CVI/instr/DRS/drs4.c" |
File Type = "CSource" |
Disk Date = 3577693051 |
Disk Date = 3622171186 |
In Projects = "1," |
Window Top = 33 |
Window Left = 10 |
Window Z-Order = 1 |
Source Window State = "1,580,580,580,15,35,15,0,0,160,0,0,0,0,0,37,537,0,581,59,349,683,1,0," |
Source Window State = "1,389,389,389,40,49,49,0,0,140,0,291,0,1,0,30,393,0,403,42,349,683,1,15," |
[File 0005] |
Path = "/c/home/rok/DRS/drs4.uir" |
[File 0008] |
Path = "/c/home/CVI/instr/DRS/drs4.uir" |
File Type = "User Interface Resource" |
Disk Date = 3577692711 |
Disk Date = 3622173437 |
In Projects = "1," |
Window Top = 132 |
Window Left = 49 |
Window Height = 349 |
Window Width = 811 |
Window Z-Order = 3 |
Window Z-Order = 4 |
[File 0006] |
Path = "/c/home/rok/DRS/drsread.lib" |
File Type = "Library" |
Disk Date = 3577692972 |
In Projects = "1," |
[File 0009] |
Path = "/c/home/CVI/instr/DRS/drsread.h" |
File Type = "Include" |
Disk Date = 3596087344 |
In Projects = "" |
Window Top = 219 |
Window Left = 106 |
Window Z-Order = 6 |
Source Window State = "1,11,11,11,15,30,30,0,3,80,0,0,0,0,0,25,0,0,11,15,349,683,1,0," |
[File 0007] |
Path = "/c/home/rok/DRS/drsread.h" |
[File 0010] |
Path = "/c/home/CVI/instr/HISTO/H1D.c" |
File Type = "CSource" |
Disk Date = 3621685621 |
In Projects = "" |
Window Top = 374 |
Window Left = 186 |
Window Z-Order = 14 |
Source Window State = "1,118,118,118,15,89,15,0,0,86,0,0,0,0,0,25,28,0,32,28,349,731,1,0," |
[File 0011] |
Path = "/c/home/CVI/instr/HISTO/H2D.c" |
File Type = "CSource" |
Disk Date = 3621932547 |
In Projects = "" |
Window Top = 250 |
Window Left = 122 |
Window Z-Order = 12 |
Source Window State = "1,340,350,340,0,0,0,0,0,86,0,0,0,0,0,25,326,0,340,0,349,731,1,0," |
[File 0012] |
Path = "/c/home/CVI/instr/HISTO/H1D.h" |
File Type = "Include" |
Disk Date = 3577691433 |
Disk Date = 3596087344 |
In Projects = "" |
Window Top = 64 |
Window Left = 26 |
Window Z-Order = 15 |
Source Window State = "1,48,48,48,14,22,22,0,3,86,0,0,0,0,0,25,0,0,48,14,349,731,1,0," |
[File 0013] |
Path = "/c/home/CVI/instr/HISTO/H2D.h" |
File Type = "Include" |
Disk Date = 3621840179 |
In Projects = "" |
Window Top = 312 |
Window Left = 154 |
Window Z-Order = 13 |
Source Window State = "1,65,65,65,0,36,36,0,0,86,0,0,0,0,0,25,33,0,65,44,349,731,1,0," |
[File 0014] |
Path = "/c/home/CVI/instr/K6517/K6517.c" |
File Type = "CSource" |
Disk Date = 3615357025 |
In Projects = "" |
Window Top = 33 |
Window Left = 10 |
Window Z-Order = 7 |
Source Window State = "1,675,675,675,2,32,2,0,0,80,0,0,0,0,0,15,658,0,675,9,219,683,1,0," |
[File 0015] |
Path = "/c/home/CVI/instr/K6517/K6517-ctrl.uir" |
File Type = "User Interface Resource" |
Disk Date = 3621934230 |
In Projects = "" |
Window Top = 126 |
Window Left = 58 |
Window Height = 219 |
Window Width = 683 |
Window Z-Order = 11 |
[File 0016] |
Path = "/c/home/CVI/apps/TempCtrl/TempCtrl.c" |
File Type = "CSource" |
Disk Date = 3621915607 |
In Projects = "2," |
Window Top = 64 |
Window Left = 26 |
Window Z-Order = 5 |
Source Window State = "1,387,387,387,81,91,81,0,0,80,0,0,0,0,0,25,345,0,387,43,349,683,1,0," |
[File 0017] |
Path = "/c/home/CVI/apps/TempCtrl/TempCtrl.uir" |
File Type = "User Interface Resource" |
Disk Date = 3614830800 |
In Projects = "2," |
Window Top = 250 |
Window Left = 122 |
Window Height = 349 |
Window Width = 731 |
Window Z-Order = 8 |
[File 0018] |
Path = "/c/home/CVI/instr/pw18-1.8aq/pw18-1.8aq.c" |
File Type = "CSource" |
Disk Date = 3607489935 |
In Projects = "" |
Window Top = 188 |
Window Left = 90 |
Window Z-Order = 10 |
Source Window State = "1,191,191,191,10,16,16,0,0,86,0,0,0,0,0,25,154,0,190,15,349,731,1,0," |
[File 0019] |
Path = "/c/home/CVI/instr/pw18-1.8aq/TMI_Api.h" |
File Type = "Include" |
Disk Date = 3596105599 |
In Projects = "" |
Window Top = 219 |
Window Left = 106 |
Window Z-Order = 9 |
Source Window State = "1,122,122,122,30,32,30,0,0,86,0,0,0,0,0,25,80,0,123,32,349,731,1,0," |
[File 0020] |
Path = "/c/home/CVI/instr/DRS/scaler.c" |
File Type = "CSource" |
Disk Date = 3622174227 |
In Projects = "1," |
Window Top = 64 |
Window Left = 26 |
Window Z-Order = 2 |
Source Window State = "1,0,0,0,0,0,0,0,0,80,0,0,0,0,0,25,0,0,0,0,349,683,1,0," |
Source Window State = "1,257,257,257,4,15,15,0,0,80,0,0,0,0,0,21,238,0,259,18,297,683,1,0," |
[File 0021] |
Path = "/c/home/CVI/instr/DRS/scaler.uir" |
File Type = "User Interface Resource" |
Disk Date = 3622173696 |
In Projects = "1," |
Window Top = 64 |
Window Left = 26 |
Window Height = 297 |
Window Width = 683 |
Window Z-Order = 3 |
[File 0022] |
Path = "/c/home/CVI/instr/DRS/drsread.lib" |
File Type = "Library" |
Disk Date = 3596087344 |
In Projects = "1," |
[Tab Order] |
Tab 0001 = "/c/home/rok/DRS/drs4.c" |
Tab 0002 = "/c/home/rok/DRS/drs4.uir" |
Tab 0003 = "/c/home/rok/DRS/drsread.h" |
Tab 0001 = "/c/home/CVI/instr/DRS/drs4.uir" |
Tab 0002 = "/c/home/CVI/instr/DRS/drsread.h" |
Tab 0003 = "/c/home/CVI/instr/DRS/drs4.c" |
Tab 0004 = "/c/home/CVI/instr/HISTO/H1D.c" |
Tab 0005 = "/c/home/CVI/instr/HISTO/H1D.h" |
Tab 0006 = "/c/home/CVI/instr/K6517/K6517.c" |
Tab 0007 = "/c/home/CVI/instr/K6517/K6517-ctrl.uir" |
Tab 0008 = "/c/home/CVI/instr/HISTO/H2D.c" |
Tab 0009 = "/c/home/CVI/instr/HISTO/H2D.h" |
Tab 0010 = "/c/home/CVI/apps/TempCtrl/TempCtrl.c" |
Tab 0011 = "/c/home/CVI/instr/pw18-1.8aq/pw18-1.8aq.c" |
Tab 0012 = "/c/home/CVI/instr/pw18-1.8aq/TMI_Api.h" |
Tab 0013 = "/c/home/CVI/apps/TempCtrl/TempCtrl.uir" |
Tab 0014 = "/c/home/CVI/instr/DRS/scaler.c" |
Tab 0015 = "/c/home/CVI/instr/DRS/scaler.uir" |
[Default Build Config 0001 Debug] |
Generate Browse Info = True |
193,3 → 356,91 |
Working Directory = "" |
Environment Options = "" |
[Default Build Config 0002 Debug] |
Generate Browse Info = True |
Enable Uninitialized Locals Runtime Warning = True |
Batch Build = False |
Profile = "Disabled" |
Debugging Level = "Standard" |
Execution Trace = "Disabled" |
Command Line Args = "" |
Working Directory = "" |
Environment Options = "" |
External Process Path = "" |
[Default Build Config 0002 Release] |
Generate Browse Info = True |
Enable Uninitialized Locals Runtime Warning = True |
Batch Build = False |
Profile = "Disabled" |
Debugging Level = "Standard" |
Execution Trace = "Disabled" |
Command Line Args = "" |
Working Directory = "" |
Environment Options = "" |
External Process Path = "" |
[Default Build Config 0002 Debug64] |
Generate Browse Info = True |
Enable Uninitialized Locals Runtime Warning = True |
Batch Build = False |
Profile = "Disabled" |
Debugging Level = "Standard" |
Execution Trace = "Disabled" |
Command Line Args = "" |
Working Directory = "" |
Environment Options = "" |
External Process Path = "" |
[Default Build Config 0002 Release64] |
Generate Browse Info = True |
Enable Uninitialized Locals Runtime Warning = True |
Batch Build = False |
Profile = "Disabled" |
Debugging Level = "Standard" |
Execution Trace = "Disabled" |
Command Line Args = "" |
Working Directory = "" |
Environment Options = "" |
External Process Path = "" |
[Build Dependencies 0002] |
Number of Dependencies = 0 |
[Build Options 0002] |
Generate Browse Info = True |
Enable Uninitialized Locals Runtime Warning = True |
Execution Trace = "Disabled" |
Profile = "Disabled" |
Debugging Level = "Standard" |
Break On Library Errors = True |
Break On First Chance Exceptions = False |
[Execution Target 0002] |
Execution Target Address = "Local desktop computer" |
Execution Target Port = 0 |
Execution Target Type = 0 |
[SCC Options 0002] |
Use global settings = True |
SCC Provider = "" |
SCC Project = "" |
Local Path = "" |
Auxiliary Path = "" |
Perform Same Action For .h File As For .uir File = "Ask" |
Perform Same Action For .cds File As For .prj File = "Ask" |
Username = "" |
Comment = "" |
Use Default Username = False |
Use Default Comment = False |
Suppress CVI Error Messages = False |
Always show confirmation dialog = True |
[DLL Debugging Support 0002] |
External Process Path = "" |
[Command Line Args 0002] |
Command Line Args = "" |
Working Directory = "" |
Environment Options = "" |
/cvi/instr/DRS/drs4.h |
---|
14,36 → 14,93 |
/* Panels and Controls: */ |
#define PANEL 1 |
#define PANEL_OPENGUI 2 /* control type: command, callback function: OpenGuiCB */ |
#define PANEL_EXIT 3 /* control type: command, callback function: ExitCB */ |
#define PANEL_STOP 4 /* control type: command, callback function: StopCB */ |
#define PANEL_CALIBRATE 5 /* control type: command, callback function: CalibrateCB */ |
#define PANEL_START 6 /* control type: command, callback function: StartCB */ |
#define PANEL_FILENAME 7 /* control type: string, callback function: (none) */ |
#define PANEL_TIMER 8 /* control type: timer, callback function: (none) */ |
#define PANEL_TWIN1 9 /* control type: numeric, callback function: (none) */ |
#define PANEL_TWIN0 10 /* control type: numeric, callback function: (none) */ |
#define PANEL_TRGLEVEL 11 /* control type: numeric, callback function: (none) */ |
#define PANEL_TRGDELAY 12 /* control type: numeric, callback function: (none) */ |
#define PANEL_RANGE 13 /* control type: numeric, callback function: (none) */ |
#define PANEL_TRGCHANNEL 14 /* control type: numeric, callback function: (none) */ |
#define PANEL_PFREQ 15 /* control type: numeric, callback function: (none) */ |
#define PANEL_FREQUENCY 16 /* control type: numeric, callback function: (none) */ |
#define PANEL_NEVE 17 /* control type: numeric, callback function: (none) */ |
#define PANEL_CEVE 18 /* control type: numeric, callback function: (none) */ |
#define PANEL_TRGTYPE 19 /* control type: ring, callback function: (none) */ |
#define PANEL_ENABLEDOUTPUT 20 /* control type: radioButton, callback function: (none) */ |
#define PANEL_DEBUG 21 /* control type: radioButton, callback function: (none) */ |
#define PANEL_CH3 22 /* control type: radioButton, callback function: (none) */ |
#define PANEL_CH2 23 /* control type: radioButton, callback function: (none) */ |
#define PANEL_CH1 24 /* control type: radioButton, callback function: (none) */ |
#define PANEL_GRAPH 25 /* control type: graph, callback function: (none) */ |
#define PANEL_CH0 26 /* control type: radioButton, callback function: (none) */ |
#define PANEL_TRGPOLARITY 27 /* control type: binary, callback function: (none) */ |
#define PANEL_TEXTMSG 28 /* control type: textMsg, callback function: (none) */ |
#define PANEL_STDIO 29 /* control type: textBox, callback function: (none) */ |
#define PANEL_OPENGUI_2 2 /* control type: command, callback function: OpenQdcCB */ |
#define PANEL_OPENGUI 3 /* control type: command, callback function: OpenGuiCB */ |
#define PANEL_EXIT 4 /* control type: command, callback function: ExitCB */ |
#define PANEL_STOP 5 /* control type: command, callback function: StopCB */ |
#define PANEL_ACQUIRE 6 /* control type: command, callback function: StartCB */ |
#define PANEL_TEMPTABLE 7 /* control type: command, callback function: TempTableCB */ |
#define PANEL_ANA 8 /* control type: command, callback function: ExecRootCB */ |
#define PANEL_CALIBRATE 9 /* control type: command, callback function: CalibrateCB */ |
#define PANEL_SETVOLTAGE 10 /* control type: command, callback function: SetVoltageCB */ |
#define PANEL_START 11 /* control type: command, callback function: StartCB */ |
#define PANEL_PATH 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_SCALE_4 15 /* control type: numeric, callback function: ScaleCB */ |
#define PANEL_DISCONNECT 16 /* control type: command, callback function: DisconnectCB */ |
#define PANEL_ONOFF 17 /* control type: binary, callback function: SwitchOnOffCB */ |
#define PANEL_TSCAN 18 /* control type: command, callback function: TScanCB */ |
#define PANEL_CONNECT 19 /* control type: command, callback function: ConnectCB */ |
#define PANEL_SCALE_3 20 /* control type: numeric, callback function: ScaleCB */ |
#define PANEL_SCALE_2 21 /* control type: numeric, callback function: ScaleCB */ |
#define PANEL_SCALE_1 22 /* control type: numeric, callback function: ScaleCB */ |
#define PANEL_TRGLEVEL 23 /* control type: numeric, callback function: (none) */ |
#define PANEL_TRGDELAY 24 /* control type: numeric, callback function: (none) */ |
#define PANEL_RANGE 25 /* control type: numeric, callback function: (none) */ |
#define PANEL_TRGCHANNEL 26 /* control type: numeric, callback function: (none) */ |
#define PANEL_PFREQ 27 /* control type: numeric, callback function: (none) */ |
#define PANEL_FREQUENCY 28 /* control type: numeric, callback function: (none) */ |
#define PANEL_VBR 29 /* control type: numeric, callback function: (none) */ |
#define PANEL_NEVE 30 /* control type: numeric, callback function: (none) */ |
#define PANEL_CEVE 31 /* control type: numeric, callback function: (none) */ |
#define PANEL_TRGTYPE 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_CH3 35 /* control type: radioButton, callback function: (none) */ |
#define PANEL_CH2 36 /* control type: radioButton, callback function: (none) */ |
#define PANEL_CH1 37 /* control type: radioButton, callback function: (none) */ |
#define PANEL_GRAPH 38 /* control type: graph, callback function: (none) */ |
#define PANEL_TIME 39 /* control type: string, callback function: (none) */ |
#define PANEL_CH0 40 /* control type: radioButton, callback function: (none) */ |
#define PANEL_TRGPOLARITY 41 /* control type: binary, callback function: (none) */ |
#define PANEL_TEXTMSG 42 /* control type: textMsg, callback function: (none) */ |
#define PANEL_STDIO 43 /* control type: textBox, callback function: (none) */ |
#define PANEL_LED 44 /* control type: LED, callback function: (none) */ |
#define PANEL_TMON 45 /* control type: numeric, callback function: (none) */ |
#define PANEL_HUMIDITY 46 /* control type: numeric, callback function: (none) */ |
#define PANEL_VTABLE 47 /* control type: table, callback function: (none) */ |
#define PANEL_TABLE 48 /* control type: table, callback function: (none) */ |
#define SCAN 2 |
#define QDC 2 |
#define QDC_REDRAW 2 /* control type: command, callback function: PlotQdcHistogramCB */ |
#define QDC_OPENGUI_2 3 /* control type: command, callback function: OpenQdcCB */ |
#define QDC_GRAPH_4 4 /* control type: graph, callback function: (none) */ |
#define QDC_GRAPH_3 5 /* control type: graph, callback function: (none) */ |
#define QDC_GRAPH_2 6 /* control type: graph, callback function: (none) */ |
#define QDC_GRAPH_1 7 /* control type: graph, callback function: (none) */ |
#define QDC_INIT_4 8 /* control type: command, callback function: InitQdcHistogramCB */ |
#define QDC_INIT_3 9 /* control type: command, callback function: InitQdcHistogramCB */ |
#define QDC_INIT_2 10 /* control type: command, callback function: InitQdcHistogramCB */ |
#define QDC_INIT_1 11 /* control type: command, callback function: InitQdcHistogramCB */ |
#define QDC_TWIN0_4 12 /* control type: numeric, callback function: (none) */ |
#define QDC_TWIN1_4 13 /* control type: numeric, callback function: (none) */ |
#define QDC_TWIN0_3 14 /* control type: numeric, callback function: (none) */ |
#define QDC_TWIN1_3 15 /* control type: numeric, callback function: (none) */ |
#define QDC_TWIN0_2 16 /* control type: numeric, callback function: (none) */ |
#define QDC_TWIN1_2 17 /* control type: numeric, callback function: (none) */ |
#define QDC_NBIN_4 18 /* control type: numeric, callback function: (none) */ |
#define QDC_MAX_4 19 /* control type: numeric, callback function: (none) */ |
#define QDC_MIN_4 20 /* control type: numeric, callback function: (none) */ |
#define QDC_NBIN_3 21 /* control type: numeric, callback function: (none) */ |
#define QDC_ACTIVE_4 22 /* control type: radioButton, callback function: SetActiveCB */ |
#define QDC_ACTIVE_3 23 /* control type: radioButton, callback function: SetActiveCB */ |
#define QDC_ACTIVE_2 24 /* control type: radioButton, callback function: SetActiveCB */ |
#define QDC_LOGY 25 /* control type: radioButton, callback function: LogScaleCB */ |
#define QDC_WFM 26 /* control type: radioButton, callback function: (none) */ |
#define QDC_ACTIVE_1 27 /* control type: radioButton, callback function: SetActiveCB */ |
#define QDC_MAX_3 28 /* control type: numeric, callback function: (none) */ |
#define QDC_MIN_3 29 /* control type: numeric, callback function: (none) */ |
#define QDC_NBIN_2 30 /* control type: numeric, callback function: (none) */ |
#define QDC_MAX_2 31 /* control type: numeric, callback function: (none) */ |
#define QDC_MIN_2 32 /* control type: numeric, callback function: (none) */ |
#define QDC_NBIN_1 33 /* control type: numeric, callback function: (none) */ |
#define QDC_MAX_1 34 /* control type: numeric, callback function: (none) */ |
#define QDC_MIN_1 35 /* control type: numeric, callback function: (none) */ |
#define QDC_TWIN0_1 36 /* control type: numeric, callback function: (none) */ |
#define QDC_TWIN1_1 37 /* control type: numeric, callback function: (none) */ |
#define SCAN 3 |
#define SCAN_OPENGUI 2 /* control type: command, callback function: OpenGuiCB */ |
#define SCAN_BD 3 /* control type: command, callback function: MoveStageCB */ |
#define SCAN_BR 4 /* control type: command, callback function: MoveStageCB */ |
85,16 → 142,29 |
/* Callback Prototypes: */ |
int CVICALLBACK CalibrateCB(int panel, int control, int event, void *callbackData, int eventData1, int eventData2); |
int CVICALLBACK ConnectCB(int panel, int control, int event, void *callbackData, int eventData1, int eventData2); |
int CVICALLBACK DisconnectCB(int panel, int control, int event, void *callbackData, int eventData1, int eventData2); |
int CVICALLBACK ExecRootCB(int panel, int control, int event, void *callbackData, int eventData1, int eventData2); |
int CVICALLBACK ExitCB(int panel, int control, int event, void *callbackData, int eventData1, int eventData2); |
int CVICALLBACK GetCurrentPositionCB(int panel, int control, int event, void *callbackData, int eventData1, int eventData2); |
int CVICALLBACK GoXCB(int panel, int control, int event, void *callbackData, int eventData1, int eventData2); |
int CVICALLBACK GoYCB(int panel, int control, int event, void *callbackData, int eventData1, int eventData2); |
int CVICALLBACK HomeCB(int panel, int control, int event, void *callbackData, int eventData1, int eventData2); |
int CVICALLBACK InitQdcHistogramCB(int panel, int control, int event, void *callbackData, int eventData1, int eventData2); |
int CVICALLBACK LogScaleCB(int panel, int control, int event, void *callbackData, int eventData1, int eventData2); |
int CVICALLBACK MoveStageCB(int panel, int control, int event, void *callbackData, int eventData1, int eventData2); |
int CVICALLBACK OpenGuiCB(int panel, int control, int event, void *callbackData, int eventData1, int eventData2); |
int CVICALLBACK OpenQdcCB(int panel, int control, int event, void *callbackData, int eventData1, int eventData2); |
int CVICALLBACK PlotQdcHistogramCB(int panel, int control, int event, void *callbackData, int eventData1, int eventData2); |
int CVICALLBACK PlotScanHistogramCB(int panel, int control, int event, void *callbackData, int eventData1, int eventData2); |
int CVICALLBACK ScaleCB(int panel, int control, int event, void *callbackData, int eventData1, int eventData2); |
int CVICALLBACK SetActiveCB(int panel, int control, int event, void *callbackData, int eventData1, int eventData2); |
int CVICALLBACK SetVoltageCB(int panel, int control, int event, void *callbackData, int eventData1, int eventData2); |
int CVICALLBACK StartCB(int panel, int control, int event, void *callbackData, int eventData1, int eventData2); |
int CVICALLBACK StopCB(int panel, int control, int event, void *callbackData, int eventData1, int eventData2); |
int CVICALLBACK SwitchOnOffCB(int panel, int control, int event, void *callbackData, int eventData1, int eventData2); |
int CVICALLBACK TempTableCB(int panel, int control, int event, void *callbackData, int eventData1, int eventData2); |
int CVICALLBACK TScanCB(int panel, int control, int event, void *callbackData, int eventData1, int eventData2); |
#ifdef __cplusplus |
/cvi/instr/DRS/drs4.prj |
---|
1,6 → 1,6 |
[Project Header] |
Version = 1302 |
Pathname = "/c/home/rok/DRS/drs4.prj" |
Pathname = "/c/home/CVI/instr/DRS/drs4.prj" |
CVI Dir = "/c/program files/national instruments/cvi2013" |
CVI Shared Dir = "/C/Program Files/National Instruments/Shared/CVI" |
CVI Pub Local Dir = "/C/ProgramData/National Instruments/CVI2013" |
9,7 → 9,7 |
VXIplug&play Framework Dir = "/C/Program Files/IVI Foundation/VISA/winnt" |
IVI Standard Root 64-bit Dir = "/C/Program Files/IVI Foundation/IVI" |
VXIplug&play Framework 64-bit Dir = "/C/Program Files/IVI Foundation/VISA/win64" |
Number of Files = 6 |
Number of Files = 10 |
Target Type = "Executable" |
Flags = 2064 |
Copied From Locked InstrDrv Directory = False |
34,7 → 34,7 |
Path Is Rel = True |
Path Rel To = "Project" |
Path Rel Path = "drs4.uir" |
Path = "/c/home/rok/DRS/drs4.uir" |
Path = "/c/home/CVI/instr/DRS/drs4.uir" |
Exclude = False |
Project Flags = 0 |
Folder = "User Interface Files" |
41,12 → 41,24 |
Folder Id = 0 |
[File 0002] |
File Type = "CSource" |
File Type = "User Interface Resource" |
Res Id = 2 |
Path Is Rel = True |
Path Rel To = "Project" |
Path Rel Path = "scaler.uir" |
Path = "/c/home/CVI/instr/DRS/scaler.uir" |
Exclude = False |
Project Flags = 0 |
Folder = "User Interface Files" |
Folder Id = 0 |
[File 0003] |
File Type = "CSource" |
Res Id = 3 |
Path Is Rel = True |
Path Rel To = "Project" |
Path Rel Path = "drs4.c" |
Path = "/c/home/rok/DRS/drs4.c" |
Path = "/c/home/CVI/instr/DRS/drs4.c" |
Exclude = False |
Compile Into Object File = False |
Project Flags = 0 |
53,54 → 65,91 |
Folder = "Source Files" |
Folder Id = 1 |
[File 0003] |
[File 0004] |
File Type = "CSource" |
Res Id = 4 |
Path Is Rel = True |
Path Rel To = "Project" |
Path Rel Path = "scaler.c" |
Path = "/c/home/CVI/instr/DRS/scaler.c" |
Exclude = False |
Compile Into Object File = False |
Project Flags = 0 |
Folder = "Source Files" |
Folder Id = 1 |
[File 0005] |
File Type = "Library" |
Res Id = 3 |
Res Id = 5 |
Path Is Rel = True |
Path Rel To = "Project" |
Path Rel Path = "drsread.lib" |
Path = "/c/home/rok/DRS/drsread.lib" |
Path = "/c/home/CVI/instr/DRS/drsread.lib" |
Exclude = False |
Project Flags = 0 |
Folder = "Library Files" |
Folder Id = 2 |
[File 0004] |
[File 0006] |
File Type = "Function Panel" |
Res Id = 4 |
Res Id = 6 |
Path Is Rel = True |
Path Rel To = "Project" |
Path Rel Path = "../../cvi/instr/HISTO/H1D.fp" |
Path = "/c/home/cvi/instr/HISTO/H1D.fp" |
Path Rel Path = "../HISTO/H1D.fp" |
Path = "/c/home/CVI/instr/HISTO/H1D.fp" |
Exclude = False |
Project Flags = 0 |
Folder = "Instrument Files" |
Folder Id = 3 |
[File 0005] |
[File 0007] |
File Type = "Function Panel" |
Res Id = 5 |
Res Id = 7 |
Path Is Rel = True |
Path Rel To = "Project" |
Path Rel Path = "../../cvi/instr/HISTO/H2D.fp" |
Path = "/c/home/cvi/instr/HISTO/H2D.fp" |
Path Rel Path = "../HISTO/H2D.fp" |
Path = "/c/home/CVI/instr/HISTO/H2D.fp" |
Exclude = False |
Project Flags = 0 |
Folder = "Instrument Files" |
Folder Id = 3 |
[File 0006] |
[File 0008] |
File Type = "Function Panel" |
Res Id = 6 |
Res Id = 8 |
Path Is Rel = True |
Path Rel To = "Project" |
Path Rel Path = "../../cvi/instr/MIKRO/MIKRO.fp" |
Path = "/c/home/cvi/instr/MIKRO/MIKRO.fp" |
Path Rel Path = "../K6517/K6517.fp" |
Path = "/c/home/CVI/instr/K6517/K6517.fp" |
Exclude = False |
Project Flags = 0 |
Folder = "Instrument Files" |
Folder Id = 3 |
[File 0009] |
File Type = "Function Panel" |
Res Id = 9 |
Path Is Rel = True |
Path Rel To = "Project" |
Path Rel Path = "../MIKRO/MIKRO.fp" |
Path = "/c/home/CVI/instr/MIKRO/MIKRO.fp" |
Exclude = False |
Project Flags = 0 |
Folder = "Instrument Files" |
Folder Id = 3 |
[File 0010] |
File Type = "Function Panel" |
Res Id = 10 |
Path Is Rel = True |
Path Rel To = "Project" |
Path Rel Path = "../PROLOGIX/prologix.fp" |
Path = "/c/home/CVI/instr/PROLOGIX/prologix.fp" |
Exclude = False |
Project Flags = 0 |
Folder = "Instrument Files" |
Folder Id = 3 |
[Custom Build Configs] |
Num Custom Build Configs = 0 |
169,7 → 218,7 |
File Version Ex = "%f1.%f2" |
Internal Name = "drs4" |
Internal Name Ex = "%basename" |
Legal Copyright = "Copyright © 2017" |
Legal Copyright = "Copyright © 2018" |
Legal Copyright Ex = "Copyright © %company %Y" |
Legal Trademarks = "" |
Legal Trademarks Ex = "" |
389,23 → 438,33 |
[Compiler Defines] |
Compiler Defines = "/DWIN32_LEAN_AND_MEAN" |
[Include Paths] |
Include Path 1 Is Rel = True |
Include Path 1 Rel To = "Project" |
Include Path 1 Rel Path = "../PROLOGIX" |
Include Path 1 = "/c/home/CVI/instr/PROLOGIX" |
Include Path 2 Is Rel = True |
Include Path 2 Rel To = "Project" |
Include Path 2 Rel Path = "" |
Include Path 2 = "/c/home/CVI/instr/DRS" |
[Create Executable] |
Executable File_Debug Is Rel = True |
Executable File_Debug Rel To = "Project" |
Executable File_Debug Rel Path = "drs4.exe" |
Executable File_Debug = "/c/home/rok/DRS/drs4.exe" |
Executable File_Debug = "/c/home/CVI/instr/DRS/drs4.exe" |
Executable File_Release Is Rel = True |
Executable File_Release Rel To = "Project" |
Executable File_Release Rel Path = "drs4.exe" |
Executable File_Release = "/c/home/rok/DRS/drs4.exe" |
Executable File_Release = "/c/home/CVI/instr/DRS/drs4.exe" |
Executable File_Debug64 Is Rel = True |
Executable File_Debug64 Rel To = "Project" |
Executable File_Debug64 Rel Path = "drs4.exe" |
Executable File_Debug64 = "/c/home/rok/DRS/drs4.exe" |
Executable File_Debug64 = "/c/home/CVI/instr/DRS/drs4.exe" |
Executable File_Release64 Is Rel = True |
Executable File_Release64 Rel To = "Project" |
Executable File_Release64 Rel Path = "drs4.exe" |
Executable File_Release64 = "/c/home/rok/DRS/drs4.exe" |
Executable File_Release64 = "/c/home/CVI/instr/DRS/drs4.exe" |
Icon File Is Rel = False |
Icon File = "" |
Application Title = "" |
/cvi/instr/DRS/drs4.uir |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/cvi/instr/DRS/libxxusb.dll |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/cvi/instr/DRS/scaler.c |
---|
0,0 → 1,299 |
#include <windows.h> |
#include <userint.h> |
#include <utility.h> |
//#include <userint.h> |
#include <stdlib.h> |
//#include <formatio.h> |
#include <ansi_c.h> |
#include "usb.h" |
#include "xxusbdll.h" |
#include "scaler.h" |
#include <cvirte.h> /* Needed if linking in external compiler; harmless otherwise */ |
extern int p4; |
extern int daq_on; |
#define NDIS 21 |
#define NSCA 22 |
#define NTGG 23 |
#define C_I CAMAC_I |
#define C_Z CAMAC_Z |
#define C_C CAMAC_C |
//#define C_write WUSBXX_CAMAC_write |
//#define C_read WUSBXX_CAMAC_read |
#define C_write CAMAC_write |
#define C_read CAMAC_read |
//******************************************************************** |
usb_dev_handle *udev; |
int Q; |
int X; |
static HINSTANCE DLLHandle; |
int WUSBXX_load (char *module_path) { |
if (module_path == NULL) |
DLLHandle = LoadLibrary("libxxusb.dll"); |
else |
DLLHandle = LoadLibrary(module_path); |
if (!(xxusb_register_read_Ptr = (void *) GetProcAddress(DLLHandle,"xxusb_register_read"))) return __LINE__; |
if (!(xxusb_stack_read_Ptr = (void *) GetProcAddress(DLLHandle,"xxusb_stack_read"))) return __LINE__; |
if (!(xxusb_stack_write_Ptr = (void *) GetProcAddress(DLLHandle,"xxusb_stack_write"))) return __LINE__; |
if (!(xxusb_stack_execute_Ptr = (void *) GetProcAddress(DLLHandle,"xxusb_stack_execute"))) return __LINE__; |
if (!(xxusb_register_write_Ptr = (void *) GetProcAddress(DLLHandle,"xxusb_register_write"))) return __LINE__; |
if (!(xxusb_usbfifo_read_Ptr = (void *) GetProcAddress(DLLHandle,"xxusb_usbfifo_read"))) return __LINE__; |
if (!(xxusb_bulk_read_Ptr = (void *) GetProcAddress(DLLHandle,"xxusb_bulk_read"))) return __LINE__; |
if (!(xxusb_bulk_write_Ptr = (void *) GetProcAddress(DLLHandle,"xxusb_bulk_write"))) return __LINE__; |
if (!(xxusb_reset_toggle_Ptr = (void *) GetProcAddress(DLLHandle,"xxusb_reset_toggle"))) return __LINE__; |
if (!(xxusb_devices_find_Ptr = (void *) GetProcAddress(DLLHandle,"xxusb_devices_find"))) return __LINE__; |
if (!(xxusb_device_close_Ptr = (void *) GetProcAddress(DLLHandle,"xxusb_device_close"))) return __LINE__; |
if (!(xxusb_device_open_Ptr = (void *) GetProcAddress(DLLHandle,"xxusb_device_open"))) return __LINE__; |
if (!(xxusb_flash_program_Ptr = (void *) GetProcAddress(DLLHandle,"xxusb_flash_program"))) return __LINE__; |
if (!(xxusb_flashblock_program_Ptr = (void *) GetProcAddress(DLLHandle,"xxusb_flashblock_program"))) return __LINE__; |
if (!(xxusb_serial_open_Ptr = (void *) GetProcAddress(DLLHandle,"xxusb_serial_open"))) return __LINE__; |
if (!(VME_register_write_Ptr = (void *) GetProcAddress(DLLHandle,"VME_register_write"))) return __LINE__; |
if (!(VME_register_read_Ptr = (void *) GetProcAddress(DLLHandle,"VME_register_read"))) return __LINE__; |
if (!(VME_LED_settings_Ptr = (void *) GetProcAddress(DLLHandle,"VME_LED_settings"))) return __LINE__; |
if (!(VME_DGG_Ptr = (void *) GetProcAddress(DLLHandle,"VME_DGG"))) return __LINE__; |
if (!(VME_Output_settings_Ptr = (void *) GetProcAddress(DLLHandle,"VME_Output_settings"))) return __LINE__; |
if (!(VME_read_16_Ptr = (void *) GetProcAddress(DLLHandle,"VME_read_16"))) return __LINE__; |
if (!(VME_read_32_Ptr = (void *) GetProcAddress(DLLHandle,"VME_read_32"))) return __LINE__; |
if (!(VME_BLT_read_32_Ptr = (void *) GetProcAddress(DLLHandle,"VME_BLT_read_32"))) return __LINE__; |
if (!(VME_write_16_Ptr = (void *) GetProcAddress(DLLHandle,"VME_write_16"))) return __LINE__; |
if (!(VME_write_32_Ptr = (void *) GetProcAddress(DLLHandle,"VME_write_32"))) return __LINE__; |
if (!(CAMAC_DGG_Ptr = (void *) GetProcAddress(DLLHandle,"CAMAC_DGG"))) return __LINE__; |
if (!(CAMAC_register_read_Ptr = (void *) GetProcAddress(DLLHandle,"CAMAC_register_read"))) return __LINE__; |
if (!(CAMAC_register_write_Ptr = (void *) GetProcAddress(DLLHandle,"CAMAC_register_write"))) return __LINE__; |
if (!(CAMAC_LED_settings_Ptr = (void *) GetProcAddress(DLLHandle,"CAMAC_LED_settings"))) return __LINE__; |
if (!(CAMAC_Output_settings_Ptr = (void *) GetProcAddress(DLLHandle,"CAMAC_Output_settings"))) return __LINE__; |
if (!(CAMAC_read_LAM_mask_Ptr = (void *) GetProcAddress(DLLHandle,"CAMAC_read_LAM_mask"))) return __LINE__; |
if (!(CAMAC_write_LAM_mask_Ptr = (void *) GetProcAddress(DLLHandle,"CAMAC_write_LAM_mask"))) return __LINE__; |
if (!(CAMAC_write_Ptr = (void *) GetProcAddress(DLLHandle,"CAMAC_write"))) return __LINE__; |
if (!(CAMAC_read_Ptr = (void *) GetProcAddress(DLLHandle,"CAMAC_read"))) return __LINE__; |
if (!(CAMAC_Z_Ptr = (void *) GetProcAddress(DLLHandle,"CAMAC_Z"))) return __LINE__; |
if (!(CAMAC_C_Ptr = (void *) GetProcAddress(DLLHandle,"CAMAC_C"))) return __LINE__; |
if (!(CAMAC_I_Ptr = (void *) GetProcAddress(DLLHandle,"CAMAC_I"))) return __LINE__; |
return 0; |
} |
void WUSBXX_open (char *serial) { |
if (serial != NULL) |
udev = xxusb_serial_open(serial); |
if (!udev) |
MessagePopup ("Error", "Cannot connect to USB. ! Check the connection!"); |
} |
void WUSBXX_close (void) { |
if (udev) xxusb_device_close(udev); |
} |
int WUSBXX_CAMAC_write( usb_dev_handle *udev, int N, int A, int F, long Data, int *Q, int *X); |
int WUSBXX_CAMAC_read( usb_dev_handle *udev,int N, int A, int F, long *Data, int *Q, int *X); |
int WUSBXX_CAMAC_Z( usb_dev_handle *udev ); |
int WUSBXX_CAMAC_C( usb_dev_handle *udev ); |
int WUSBXX_CAMAC_I(usb_dev_handle *udev, int inhibit); |
int WUSBXX_CAMAC_write( usb_dev_handle *udev,int N, int A, int F, long Data, int *Q, int *X) { |
long intbuf[4]; |
int ret=0; |
// CAMAC direct write function |
intbuf[0]=1; |
intbuf[1]=(long)(F+A*32+N*512 + 0x4000); |
if ((F > 15) && (F < 24)) // orig controla |
//if ((F > 15) && (F < 28)) // orig controla |
{ |
intbuf[0]=3; |
intbuf[2]=(Data & 0xffff); |
intbuf[3]=((Data >>16) & 255); |
ret = xxusb_stack_execute(udev, intbuf); |
*Q = (intbuf[0] & 1); |
*X = ((intbuf[0] >> 1) & 1); |
} else { |
printf("Error N%d A%d F%d",N,A,F); |
} |
return ret; |
} |
int WUSBXX_CAMAC_read( usb_dev_handle *udev,int N, int A, int F, long *Data, int *Q, int *X) { |
long intbuf[4]; |
int ret; |
// CAMAC direct read function |
intbuf[0]=1; |
intbuf[1]=(long)(F+A*32+N*512 + 0x4000); |
// intbuf[1]=(long)(F+A*32+N*512); |
ret = xxusb_stack_execute(udev, intbuf); |
// printf ("ret = %d\n",ret); |
if (F < 16) { // orig controla |
// *Data = intbuf[0]; //16-bit word |
*Data = intbuf[0] + (intbuf[1] & 0xFF) * 0x10000; //24-bit word |
*Q = ((intbuf[1] >> 8) & 1); |
*X = ((intbuf[1] >> 9) & 1); |
} |
// else { |
// printf("Error N%d A%d F%d",N,A,F); |
// } |
return ret; |
} |
int WUSBXX_CAMAC_Z(usb_dev_handle *udev) { |
long intbuf[4]; |
int ret; |
// CAMAC Z = N(28) A(8) F(29) |
intbuf[0]=1; |
intbuf[1]=(long)(29+8*32+28*512 + 0x4000); |
ret = xxusb_stack_execute(udev, intbuf); |
return ret; |
} |
int WUSBXX_CAMAC_C(usb_dev_handle *udev) { |
long intbuf[4]; |
int ret; |
// CAMAC C = N(28) A(9) F(29) |
intbuf[0]=1; |
intbuf[1]=(long)(29+9*32+28*512 + 0x4000); |
ret = xxusb_stack_execute( udev, intbuf); |
return ret; |
} |
int WUSBXX_CAMAC_I(usb_dev_handle *udev, int inhibit) { |
long intbuf[4]; |
int ret; |
// Set Inhibit = N(29) A(9) F(24) |
// Clear Inhibit = N(29) A(9) F(26) |
intbuf[0]=1; |
if (inhibit) intbuf[1]=(long)(24+9*32+29*512 + 0x4000); |
else intbuf[1]=(long)(26+9*32+29*512 + 0x4000); |
ret = xxusb_stack_execute(udev, intbuf); |
return ret; |
} |
int init_CAMAC () { |
long dum; |
C_Z(udev); |
C_C(udev); |
C_I(udev,1); |
C_read ( udev,NTGG, 0 , 9, &dum, &Q,&X); /* init TGG */ |
C_write ( udev,NTGG, 0, 16, 1000, &Q,&X); /* Set preset counting value */ |
C_write ( udev,NTGG, 0 ,17, 0x2, &Q,&X); /* Set Load&Clock Modes */ |
C_write ( udev,NDIS, 0, 16, 0xffff, &Q,&X); /* enable all ch. */ |
C_read ( udev,NDIS, 0, 26, &dum, &Q, &X); |
C_I(udev, 0); |
return 0 ; |
} |
int scaler(int min, int max, int dx, int time_set, char *filename){ |
FILE *fp ; |
if (filename!=NULL) { |
fp = fopen ( filename, "w" ); |
} else { |
fp =stdout; |
} |
long val, dum; |
int thr_set; |
char str[0xFF]; |
int n=(max-min)/dx; |
double *x= (double *) malloc(n*sizeof(double)); |
double *y= (double *) malloc(n*sizeof(double)); |
dum=WUSBXX_load (NULL); |
if (dum) printf("Error", "Cannot load dll!"); |
WUSBXX_open ("CC0130"); |
init_CAMAC ( ); |
time_t mtime; |
time(&mtime); |
fprintf(fp, "#%s#gate(ms)=%d\n",ctime(&mtime),time_set); |
for (int i=0; i<n; i++) { |
int thr=min+i*dx; |
C_write ( udev, NDIS, 0, 17, thr, &Q, &X); /* set the threshold */ |
C_write ( udev, NDIS, 1, 17, 0, &Q,&X); /* */ |
C_read ( udev, NSCA,0,9,&dum, &Q,&X); |
C_write( udev, NTGG, 0, 16, time_set, &Q,&X); |
C_read ( udev, NTGG, 0, 15, &dum, &Q,&X); |
Delay(time_set*1e-3+0.01); |
int mych=2; |
val=0; |
for (int ch=1;ch<mych+1;ch++){ |
C_read ( udev, NSCA, ch, 0, &val, &Q,&X); |
//printf("%d\t", val); |
C_read ( udev, NSCA, ch, 0, &val, &Q,&X); |
} |
val--; |
x[i]=thr; |
y[i]=val; |
static int plothandle=0; |
if (plothandle) DeleteGraphPlot (p4, SCALER_GRAPH, plothandle, VAL_IMMEDIATE_DRAW); |
plothandle = PlotXY (p4,SCALER_GRAPH, x, y, i+1, VAL_DOUBLE, VAL_DOUBLE, VAL_THIN_LINE, VAL_NO_POINT, VAL_SOLID, 1, VAL_BLUE); |
sprintf ( str, "%d %d", thr, val) ; |
fprintf( fp, "%s\n", str); |
printf("scaler %s\n", str); |
C_I(udev, 0); |
if (!daq_on) break; |
} |
if (fp!=stdout) fclose ( fp ) ; |
printf("Threshold scan in the file %s\n", filename); |
WUSBXX_close (); |
return 0; |
} |
#ifdef MAIN |
int main( int argc, char **argv){ |
char filename[256]="tmp.txt" ; |
//ii=80000000/i-40; |
//if (ii<72) ii=72; |
//CAMAC_DGG(udev,0,7,0,ii,40,0,0); |
//CAMAC_DGG(udev,1,1,1,12,8,0,0); |
int min=0; |
int max=1000; |
int dx=10; |
int time_set=200; |
if (argc>1) min = atoi(argv[1]); |
if (argc>2) max = atoi(argv[2]); |
if (argc>3) dx = atoi(argv[3]); |
if (argc>4) time_set = (int)(1000*atof(argv[4])); |
if (argc>5) sprintf(filename, "%s", argv[5]); |
scaler(min, max, dx, time_set, filename); |
return 0; |
} |
#endif |
/cvi/instr/DRS/scaler.h |
---|
0,0 → 1,42 |
/**************************************************************************/ |
/* LabWindows/CVI User Interface Resource (UIR) Include File */ |
/* */ |
/* WARNING: Do not add to, delete from, or otherwise modify the contents */ |
/* of this include file. */ |
/**************************************************************************/ |
#include <userint.h> |
#ifdef __cplusplus |
extern "C" { |
#endif |
/* Panels and Controls: */ |
#define SCALER 1 |
#define SCALER_GRAPH 2 /* control type: graph, callback function: (none) */ |
#define SCALER_TIME 3 /* control type: numeric, callback function: (none) */ |
#define SCALER_STEP 4 /* control type: numeric, callback function: (none) */ |
#define SCALER_MAX 5 /* control type: numeric, callback function: (none) */ |
#define SCALER_START 6 /* control type: command, callback function: StartCB */ |
#define SCALER_MIN 7 /* control type: numeric, callback function: (none) */ |
/* Control Arrays: */ |
/* (no control arrays in the resource file) */ |
/* Menu Bars, Menus, and Menu Items: */ |
/* (no menu bars in the resource file) */ |
/* Callback Prototypes: */ |
int CVICALLBACK StartCB(int panel, int control, int event, void *callbackData, int eventData1, int eventData2); |
#ifdef __cplusplus |
} |
#endif |
/cvi/instr/DRS/scaler.uir |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/cvi/instr/DRS/usb.h |
---|
0,0 → 1,373 |
#ifndef __USB_H__ |
#define __USB_H__ |
#include <stdlib.h> |
/* |
* 'interface' is defined somewhere in the Windows header files. This macro |
* is deleted here to avoid conflicts and compile errors. |
*/ |
#ifdef interface |
#undef interface |
#endif |
/* |
* PATH_MAX from limits.h can't be used on Windows if the dll and |
* import libraries are build/used by different compilers |
*/ |
#define LIBUSB_PATH_MAX 512 |
/* |
* USB spec information |
* |
* This is all stuff grabbed from various USB specs and is pretty much |
* not subject to change |
*/ |
/* |
* Device and/or Interface Class codes |
*/ |
#define USB_CLASS_PER_INTERFACE 0 /* for DeviceClass */ |
#define USB_CLASS_AUDIO 1 |
#define USB_CLASS_COMM 2 |
#define USB_CLASS_HID 3 |
#define USB_CLASS_PRINTER 7 |
#define USB_CLASS_MASS_STORAGE 8 |
#define USB_CLASS_HUB 9 |
#define USB_CLASS_DATA 10 |
#define USB_CLASS_VENDOR_SPEC 0xff |
/* |
* Descriptor types |
*/ |
#define USB_DT_DEVICE 0x01 |
#define USB_DT_CONFIG 0x02 |
#define USB_DT_STRING 0x03 |
#define USB_DT_INTERFACE 0x04 |
#define USB_DT_ENDPOINT 0x05 |
#define USB_DT_HID 0x21 |
#define USB_DT_REPORT 0x22 |
#define USB_DT_PHYSICAL 0x23 |
#define USB_DT_HUB 0x29 |
/* |
* Descriptor sizes per descriptor type |
*/ |
#define USB_DT_DEVICE_SIZE 18 |
#define USB_DT_CONFIG_SIZE 9 |
#define USB_DT_INTERFACE_SIZE 9 |
#define USB_DT_ENDPOINT_SIZE 7 |
#define USB_DT_ENDPOINT_AUDIO_SIZE 9 /* Audio extension */ |
#define USB_DT_HUB_NONVAR_SIZE 7 |
/* ensure byte-packed structures */ |
#include <pshpack1.h> |
/* All standard descriptors have these 2 fields in common */ |
struct usb_descriptor_header { |
unsigned char bLength; |
unsigned char bDescriptorType; |
}; |
/* String descriptor */ |
struct usb_string_descriptor { |
unsigned char bLength; |
unsigned char bDescriptorType; |
unsigned short wData[1]; |
}; |
/* HID descriptor */ |
struct usb_hid_descriptor { |
unsigned char bLength; |
unsigned char bDescriptorType; |
unsigned short bcdHID; |
unsigned char bCountryCode; |
unsigned char bNumDescriptors; |
}; |
/* Endpoint descriptor */ |
#define USB_MAXENDPOINTS 32 |
struct usb_endpoint_descriptor { |
unsigned char bLength; |
unsigned char bDescriptorType; |
unsigned char bEndpointAddress; |
unsigned char bmAttributes; |
unsigned short wMaxPacketSize; |
unsigned char bInterval; |
unsigned char bRefresh; |
unsigned char bSynchAddress; |
unsigned char *extra; /* Extra descriptors */ |
int extralen; |
}; |
#define USB_ENDPOINT_ADDRESS_MASK 0x0f /* in bEndpointAddress */ |
#define USB_ENDPOINT_DIR_MASK 0x80 |
#define USB_ENDPOINT_TYPE_MASK 0x03 /* in bmAttributes */ |
#define USB_ENDPOINT_TYPE_CONTROL 0 |
#define USB_ENDPOINT_TYPE_ISOCHRONOUS 1 |
#define USB_ENDPOINT_TYPE_BULK 2 |
#define USB_ENDPOINT_TYPE_INTERRUPT 3 |
/* Interface descriptor */ |
#define USB_MAXINTERFACES 32 |
struct usb_interface_descriptor { |
unsigned char bLength; |
unsigned char bDescriptorType; |
unsigned char bInterfaceNumber; |
unsigned char bAlternateSetting; |
unsigned char bNumEndpoints; |
unsigned char bInterfaceClass; |
unsigned char bInterfaceSubClass; |
unsigned char bInterfaceProtocol; |
unsigned char iInterface; |
struct usb_endpoint_descriptor *endpoint; |
unsigned char *extra; /* Extra descriptors */ |
int extralen; |
}; |
#define USB_MAXALTSETTING 128 /* Hard limit */ |
struct usb_interface { |
struct usb_interface_descriptor *altsetting; |
int num_altsetting; |
}; |
/* Configuration descriptor information.. */ |
#define USB_MAXCONFIG 8 |
struct usb_config_descriptor { |
unsigned char bLength; |
unsigned char bDescriptorType; |
unsigned short wTotalLength; |
unsigned char bNumInterfaces; |
unsigned char bConfigurationValue; |
unsigned char iConfiguration; |
unsigned char bmAttributes; |
unsigned char MaxPower; |
struct usb_interface *interface; |
unsigned char *extra; /* Extra descriptors */ |
int extralen; |
}; |
/* Device descriptor */ |
struct usb_device_descriptor { |
unsigned char bLength; |
unsigned char bDescriptorType; |
unsigned short bcdUSB; |
unsigned char bDeviceClass; |
unsigned char bDeviceSubClass; |
unsigned char bDeviceProtocol; |
unsigned char bMaxPacketSize0; |
unsigned short idVendor; |
unsigned short idProduct; |
unsigned short bcdDevice; |
unsigned char iManufacturer; |
unsigned char iProduct; |
unsigned char iSerialNumber; |
unsigned char bNumConfigurations; |
}; |
struct usb_ctrl_setup { |
unsigned char bRequestType; |
unsigned char bRequest; |
unsigned short wValue; |
unsigned short wIndex; |
unsigned short wLength; |
}; |
/* |
* Standard requests |
*/ |
#define USB_REQ_GET_STATUS 0x00 |
#define USB_REQ_CLEAR_FEATURE 0x01 |
/* 0x02 is reserved */ |
#define USB_REQ_SET_FEATURE 0x03 |
/* 0x04 is reserved */ |
#define USB_REQ_SET_ADDRESS 0x05 |
#define USB_REQ_GET_DESCRIPTOR 0x06 |
#define USB_REQ_SET_DESCRIPTOR 0x07 |
#define USB_REQ_GET_CONFIGURATION 0x08 |
#define USB_REQ_SET_CONFIGURATION 0x09 |
#define USB_REQ_GET_INTERFACE 0x0A |
#define USB_REQ_SET_INTERFACE 0x0B |
#define USB_REQ_SYNCH_FRAME 0x0C |
#define USB_TYPE_STANDARD (0x00 << 5) |
#define USB_TYPE_CLASS (0x01 << 5) |
#define USB_TYPE_VENDOR (0x02 << 5) |
#define USB_TYPE_RESERVED (0x03 << 5) |
#define USB_RECIP_DEVICE 0x00 |
#define USB_RECIP_INTERFACE 0x01 |
#define USB_RECIP_ENDPOINT 0x02 |
#define USB_RECIP_OTHER 0x03 |
/* |
* Various libusb API related stuff |
*/ |
#define USB_ENDPOINT_IN 0x80 |
#define USB_ENDPOINT_OUT 0x00 |
/* Error codes */ |
#define USB_ERROR_BEGIN 500000 |
/* |
* This is supposed to look weird. This file is generated from autoconf |
* and I didn't want to make this too complicated. |
*/ |
#define USB_LE16_TO_CPU(x) |
/* Data types */ |
/* struct usb_device; */ |
/* struct usb_bus; */ |
struct usb_device { |
struct usb_device *next, *prev; |
char filename[LIBUSB_PATH_MAX]; |
struct usb_bus *bus; |
struct usb_device_descriptor descriptor; |
struct usb_config_descriptor *config; |
void *dev; /* Darwin support */ |
unsigned char devnum; |
unsigned char num_children; |
struct usb_device **children; |
}; |
struct usb_bus { |
struct usb_bus *next, *prev; |
char dirname[LIBUSB_PATH_MAX]; |
struct usb_device *devices; |
unsigned long location; |
struct usb_device *root_dev; |
}; |
/* Version information, Windows specific */ |
struct usb_version { |
struct { |
int major; |
int minor; |
int micro; |
int nano; |
} dll; |
struct { |
int major; |
int minor; |
int micro; |
int nano; |
} driver; |
}; |
struct usb_dev_handle; |
typedef struct usb_dev_handle usb_dev_handle; |
/* Variables */ |
struct usb_bus *usb_busses; |
#include <poppack.h> |
#ifdef __cplusplus |
extern "C" { |
#endif |
/* Function prototypes */ |
/* usb.c */ |
usb_dev_handle *usb_open(struct usb_device *dev); |
int usb_close(usb_dev_handle *dev); |
int usb_get_string(usb_dev_handle *dev, int index, int langid, char *buf, |
size_t buflen); |
int usb_get_string_simple(usb_dev_handle *dev, int index, char *buf, |
size_t buflen); |
/* descriptors.c */ |
int usb_get_descriptor_by_endpoint(usb_dev_handle *udev, int ep, |
unsigned char type, unsigned char index, |
void *buf, int size); |
int usb_get_descriptor(usb_dev_handle *udev, unsigned char type, |
unsigned char index, void *buf, int size); |
/* <arch>.c */ |
int usb_bulk_write(usb_dev_handle *dev, int ep, char *bytes, int size, |
int timeout); |
int usb_bulk_read(usb_dev_handle *dev, int ep, char *bytes, int size, |
int timeout); |
int usb_interrupt_write(usb_dev_handle *dev, int ep, char *bytes, int size, |
int timeout); |
int usb_interrupt_read(usb_dev_handle *dev, int ep, char *bytes, int size, |
int timeout); |
int usb_control_msg(usb_dev_handle *dev, int requesttype, int request, |
int value, int index, char *bytes, int size, |
int timeout); |
int usb_set_configuration(usb_dev_handle *dev, int configuration); |
int usb_claim_interface(usb_dev_handle *dev, int interface); |
int usb_release_interface(usb_dev_handle *dev, int interface); |
int usb_set_altinterface(usb_dev_handle *dev, int alternate); |
int usb_resetep(usb_dev_handle *dev, unsigned int ep); |
int usb_clear_halt(usb_dev_handle *dev, unsigned int ep); |
int usb_reset(usb_dev_handle *dev); |
char *usb_strerror(void); |
void usb_init(void); |
void usb_set_debug(int level); |
int usb_find_busses(void); |
int usb_find_devices(void); |
struct usb_device *usb_device(usb_dev_handle *dev); |
struct usb_bus *usb_get_busses(void); |
/* Windows specific functions */ |
#define LIBUSB_HAS_INSTALL_SERVICE_NP 1 |
int usb_install_service_np(void); |
#define LIBUSB_HAS_UNINSTALL_SERVICE_NP 1 |
int usb_uninstall_service_np(void); |
#define LIBUSB_HAS_INSTALL_DRIVER_NP 1 |
int usb_install_driver_np(const char *inf_file); |
const struct usb_version *usb_get_version(void); |
int usb_isochronous_setup_async(usb_dev_handle *dev, void **context, |
unsigned char ep, int pktsize); |
int usb_bulk_setup_async(usb_dev_handle *dev, void **context, |
unsigned char ep); |
int usb_interrupt_setup_async(usb_dev_handle *dev, void **context, |
unsigned char ep); |
int usb_submit_async(void *context, char *bytes, int size); |
int usb_reap_async(void *context, int timeout); |
int usb_free_async(void **context); |
#ifdef __cplusplus |
} |
#endif |
#endif /* __USB_H__ */ |
/cvi/instr/DRS/xxusbdll.h |
---|
0,0 → 1,112 |
#ifndef _XXUSB_DLL_H |
#define _XXUSB_DLL_H |
typedef unsigned short ADDRESS_MODIFIER; |
#define Std_Sup_Data (ADDRESS_MODIFIER)0x3d |
#define Std_Sup_Prog (ADDRESS_MODIFIER)0x3e |
#define Std_NoPriv_Data (ADDRESS_MODIFIER)0x39 |
#define Std_NoPriv_Prog (ADDRESS_MODIFIER)0x3a |
#define Short_Sup (ADDRESS_MODIFIER)0x2d |
#define Short_NoPriv (ADDRESS_MODIFIER)0x29 |
#define Ext_Sup_Data (ADDRESS_MODIFIER)0x0d |
#define Ext_Sup_Prog (ADDRESS_MODIFIER)0x0e |
#define Ext_NoPriv_Data (ADDRESS_MODIFIER)0x09 |
#define Ext_NoPriv_Prog (ADDRESS_MODIFIER)0x0a |
struct xxusb_device_typ |
{ |
struct usb_device *usbdev; |
char SerialString[7]; |
}; |
typedef struct xxusb_device_typ xxusb_device_type; |
#define xxusb_register_read (*xxusb_register_read_Ptr) |
#define xxusb_stack_read (*xxusb_stack_read_Ptr) |
#define xxusb_stack_write (*xxusb_stack_write_Ptr) |
#define xxusb_stack_execute (*xxusb_stack_execute_Ptr) |
#define xxusb_register_write (*xxusb_register_write_Ptr) |
#define xxusb_usbfifo_read (*xxusb_usbfifo_read_Ptr) |
#define xxusb_bulk_read (*xxusb_bulk_read_Ptr) |
#define xxusb_bulk_write (*xxusb_bulk_write_Ptr) |
#define xxusb_reset_toggle (*xxusb_reset_toggle_Ptr) |
#define xxusb_devices_find (*xxusb_devices_find_Ptr) |
#define xxusb_device_close (*xxusb_device_close_Ptr) |
#define xxusb_device_open (*xxusb_device_open_Ptr) |
#define xxusb_flash_program (*xxusb_flash_program_Ptr) |
#define xxusb_flashblock_program (*xxusb_flashblock_program_Ptr) |
#define xxusb_serial_open (*xxusb_serial_open_Ptr) |
#define VME_register_write (*VME_register_write_Ptr) |
#define VME_register_read (*VME_register_read_Ptr) |
#define VME_LED_settings (*VME_LED_settings_Ptr) |
#define VME_DGG (*VME_DGG_Ptr) |
#define VME_Output_settings (*VME_Output_settings_Ptr) |
#define VME_read_16 (*VME_read_16_Ptr) |
#define VME_read_32 (*VME_read_32_Ptr) |
#define VME_BLT_read_32 (*VME_BLT_read_32_Ptr) |
#define VME_write_16 (*VME_write_16_Ptr) |
#define VME_write_32 (*VME_write_32_Ptr) |
#define CAMAC_DGG (*CAMAC_DGG_Ptr) |
#define CAMAC_register_read (*CAMAC_register_read_Ptr) |
#define CAMAC_register_write (*CAMAC_register_write_Ptr) |
#define CAMAC_LED_settings (*CAMAC_LED_settings_Ptr) |
#define CAMAC_Output_settings (*CAMAC_Output_settings_Ptr) |
#define CAMAC_read_LAM_mask (*CAMAC_read_LAM_mask_Ptr) |
#define CAMAC_write_LAM_mask (*CAMAC_write_LAM_mask_Ptr) |
#define CAMAC_write (*CAMAC_write_Ptr) |
#define CAMAC_read (*CAMAC_read_Ptr) |
#define CAMAC_Z (*CAMAC_Z_Ptr) |
#define CAMAC_C (*CAMAC_C_Ptr) |
#define CAMAC_I (*CAMAC_I_Ptr) |
short __stdcall xxusb_register_read(usb_dev_handle *hDev, short RegAddr, long *RegData); |
short __stdcall xxusb_stack_read(usb_dev_handle *hDev, short StackAddr, long *StackData); |
short __stdcall xxusb_stack_write(usb_dev_handle *hDev, short StackAddr, long *StackData); |
short __stdcall xxusb_stack_execute(usb_dev_handle *hDev, long *StackData); |
short __stdcall xxusb_register_write(usb_dev_handle *hDev, short RegAddr, long RegData); |
short __stdcall xxusb_usbfifo_read(usb_dev_handle *hDev, long *DataBuffer, short lDataLen, int timeout); |
short __stdcall xxusb_bulk_read(usb_dev_handle *hDev, char *DataBuffer, short lDataLen, int timeout); |
short __stdcall xxusb_bulk_write(usb_dev_handle *hDev, char *DataBuffer, short lDataLen, int timeout); |
short __stdcall xxusb_reset_toggle(usb_dev_handle *hDev); |
short __stdcall xxusb_devices_find(xxusb_device_type *xxusbDev); |
short __stdcall xxusb_device_close(usb_dev_handle *hDev); |
usb_dev_handle* __stdcall xxusb_device_open(struct usb_device *dev); |
short __stdcall xxusb_flash_program(usb_dev_handle *hDev, char *config, short nsect); |
short __stdcall xxusb_flashblock_program(usb_dev_handle *hDev, UCHAR *config); |
usb_dev_handle* __stdcall xxusb_serial_open(char *SerialString); |
short __stdcall VME_register_write(usb_dev_handle *hdev, long VME_Address, long Data); |
short __stdcall VME_register_read(usb_dev_handle *hdev, long VME_Address, long *Data); |
short __stdcall VME_LED_settings(usb_dev_handle *hdev, int LED, int code, int invert, int latch); |
short __stdcall VME_DGG(usb_dev_handle *hdev, unsigned short channel, unsigned short trigger,unsigned short output, long delay, unsigned short gate, unsigned short invert, unsigned short latch); |
short __stdcall VME_Output_settings(usb_dev_handle *hdev, int Channel, int code, int invert, int latch); |
short __stdcall VME_read_16(usb_dev_handle *hdev,short Address_Modifier, long VME_Address, long *Data); |
short __stdcall VME_read_32(usb_dev_handle *hdev, short Address_Modifier, long VME_Address, long *Data); |
short __stdcall VME_BLT_read_32(usb_dev_handle *hdev, short Address_Modifier, int count, long VME_Address, long Data[]); |
short __stdcall VME_write_16(usb_dev_handle *hdev, short Address_Modifier, long VME_Address, long Data); |
short __stdcall VME_write_32(usb_dev_handle *hdev, short Address_Modifier, long VME_Address, long Data); |
short __stdcall CAMAC_DGG(usb_dev_handle *hdev, short channel, short trigger, short output, int delay, int gate, short invert, short latch); |
short __stdcall CAMAC_register_read(usb_dev_handle *hdev, int A, long *Data); |
short __stdcall CAMAC_register_write(usb_dev_handle *hdev, int A, long Data); |
short __stdcall CAMAC_LED_settings(usb_dev_handle *hdev, int LED, int code, int invert, int latch); |
short __stdcall CAMAC_Output_settings(usb_dev_handle *hdev, int Channel, int code, int invert, int latch); |
short __stdcall CAMAC_read_LAM_mask(usb_dev_handle *hdev, long *Data); |
short __stdcall CAMAC_write_LAM_mask(usb_dev_handle *hdev, long Data); |
short __stdcall CAMAC_write(usb_dev_handle *hdev, int N, int A, int F, long Data, int *Q, int *X); |
short __stdcall CAMAC_read(usb_dev_handle *hdev, int N, int A, int F, long *Data, int *Q, int *X); |
short __stdcall CAMAC_Z(usb_dev_handle *hdev); |
short __stdcall CAMAC_C(usb_dev_handle *hdev); |
short __stdcall CAMAC_I(usb_dev_handle *hdev, int inhibit); |
#endif |