/petdaqfmf/libxxusb.cpp |
File deleted |
|
Property changes: |
Deleted: svn:executable |
Index: petdaqfmf/CAENV965.c |
=================================================================== |
--- petdaqfmf/CAENV965.c (revision 111) |
+++ petdaqfmf/CAENV965.c (nonexistent) |
@@ -1,107 +0,0 @@ |
-#include <stdlib.h> |
-#include <stdio.h> |
-#include "CAENV965.h" |
-#include "CAENV965_DEF.h" |
-#include "vme.h" |
- |
-static unsigned long ModuleAddress[10]; |
- |
-int _VI_FUNC V965_map (int ModuleNumber, unsigned long ModuleOffset, int print) |
-{ |
- int i; |
- unsigned short geo, fw, ah, al; |
- if (print) { |
- printf("CAEN V965_map \n"); |
- } |
- ModuleAddress[ModuleNumber] = ModuleOffset; |
- VME_A24D16_R(ModuleAddress[ModuleNumber] + CAENV965_FW, &fw); |
- geo = 0; |
- VME_A24D16_W(ModuleAddress[ModuleNumber] + CAENV965_CRN, &geo); |
- for (i=0;i<32;i++) |
- VME_A24D16_W(ModuleAddress[ModuleNumber] + CAENV965_THM + 2*i, &geo); |
- geo = ModuleNumber+1; |
- VME_A24D16_W(ModuleAddress[ModuleNumber] + CAENV965_GEO, &geo); |
- geo = 0; |
- VME_A24D16_R(ModuleAddress[ModuleNumber] + CAENV965_GEO, &geo); |
- VME_A24D16_R(ModuleAddress[ModuleNumber] + CAENV965_ADH, &ah); |
- VME_A24D16_R(ModuleAddress[ModuleNumber] + CAENV965_ADL, &al); |
- if (print) { |
- printf("CAEN V965 offset = 0x%08x\n", ModuleOffset); |
- printf(" V965_map firmware = %d.%d\n", (fw>>8)&0xff, fw&0xff); |
- printf(" V965_map geo = %d\n", geo&0x1f ); |
- printf(" V965_map addr = 0x%04X0000\n", (ah<<8)|(al&0xff)); |
- } |
- |
- return 0; |
-} |
- |
- |
-int _VI_FUNC V965_init (int ModuleNumber, unsigned short ped) |
-{ |
- unsigned short dum16; |
- |
- dum16= 0x80; |
- VME_A24D16_W(ModuleAddress[ModuleNumber] + CAENV965_BS1, &dum16); |
- VME_A24D16_W(ModuleAddress[ModuleNumber] + CAENV965_BC1, &dum16); |
- dum16= ped; |
- VME_A24D16_W(ModuleAddress[ModuleNumber] + CAENV965_PED, &dum16); |
- dum16= 0x5000; |
- VME_A24D16_W(ModuleAddress[ModuleNumber] + CAENV965_BS2, &dum16); |
- dum16= 0x4; |
- VME_A24D16_W(ModuleAddress[ModuleNumber] + CAENV965_BS2, &dum16); |
- VME_A24D16_W(ModuleAddress[ModuleNumber] + CAENV965_BC2, &dum16); |
- VME_A24D16_W(ModuleAddress[ModuleNumber] + CAENV965_ECR, &dum16); |
- |
- printf ( " V965_init Module %d initialized!\n", ModuleNumber ) ; |
- return 0; |
-} |
- |
-int _VI_FUNC V965_clear (int ModuleNumber) |
-{ |
- |
- unsigned short dum16; |
- |
- dum16= 0x4; |
- VME_A24D16_W(ModuleAddress[ModuleNumber] + CAENV965_BS2, &dum16); |
- VME_A24D16_W(ModuleAddress[ModuleNumber] + CAENV965_BC2, &dum16); |
- printf("V965_clear\n"); |
- return 0; |
- |
-} |
- |
-int _VI_FUNC V965_status (int ModuleNumber) |
-{ |
- unsigned short dum16; |
- |
- VME_A24D16_R(ModuleAddress[ModuleNumber] + CAENV965_SR1, &dum16); |
- //printf("*%d\n",dum16); |
- return (int)dum16; |
-} |
- |
-int _VI_FUNC V965_status2 (int ModuleNumber) |
-{ |
- |
- unsigned short dum16; |
- |
- VME_A24D16_R(ModuleAddress[ModuleNumber] + CAENV965_SR2, &dum16); |
- |
- return (int)dum16; |
-} |
- |
-int _VI_FUNC V965_read (int ModuleNumber, unsigned long whereto[],int len) |
-{ |
- int status, ndata, i; |
- |
- ndata = 0; |
- |
- do { |
- if (ndata>=len) { |
- printf("ERROR V965_read: Increase storage size: ndata=%d\n",ndata); |
- break; |
- } |
- VME_A24D32_R(ModuleAddress[ModuleNumber] + CAENV965_OB, &whereto[ndata]); |
- i=(whereto[ndata]>>25)&0x3; |
- if (i<3) ndata++; |
- } while (i<2); |
- return ndata; |
-} |
Index: petdaqfmf/CAENV965.h |
=================================================================== |
--- petdaqfmf/CAENV965.h (revision 111) |
+++ petdaqfmf/CAENV965.h (nonexistent) |
@@ -1,13 +0,0 @@ |
-#ifndef _CAENV965_H |
-#define _CAENV965_H |
- |
-#define _VI_FUNC |
- |
-int _VI_FUNC V965_map (int ModuleNumber, unsigned long ModuleOffset, int print) ; |
-int _VI_FUNC V965_init (int ModuleNumber, unsigned short ped) ; |
-int _VI_FUNC V965_clear (int ModuleNumber) ; |
-int _VI_FUNC V965_status (int ModuleNumber) ; |
-int _VI_FUNC V965_status2 (int ModuleNumber) ; |
-int _VI_FUNC V965_read (int ModuleNumber, unsigned long whereto[],int len); |
- |
-#endif |
Index: petdaqfmf/libxxusb.h |
=================================================================== |
--- petdaqfmf/libxxusb.h (revision 111) |
+++ petdaqfmf/libxxusb.h (nonexistent) |
@@ -1,114 +0,0 @@ |
-#include <usb.h> |
- |
- |
-#define XXUSB_WIENER_VENDOR_ID 0x16DC /* Wiener, Plein & Baus */ |
-#define XXUSB_VMUSB_PRODUCT_ID 0x000B /* VM-USB */ |
-#define XXUSB_CCUSB_PRODUCT_ID 0x0001 /* CC-USB */ |
-#define XXUSB_ENDPOINT_OUT 2 /* Endpoint 2 Out*/ |
-#define XXUSB_ENDPOINT_IN 0x86 /* Endpoint 6 In */ |
-#define XXUSB_FIRMWARE_REGISTER 0 |
-#define XXUSB_GLOBAL_REGISTER 1 |
-#define XXUSB_ACTION_REGISTER 10 |
-#define XXUSB_DELAYS_REGISTER 2 |
-#define XXUSB_WATCHDOG_REGISTER 3 |
-#define XXUSB_SELLEDA_REGISTER 6 |
-#define XXUSB_SELNIM_REGISTER 7 |
-#define XXUSB_SELLEDB_REGISTER 4 |
-#define XXUSB_SERIAL_REGISTER 15 |
-#define XXUSB_LAMMASK_REGISTER 8 |
-#define XXUSB_LAM_REGISTER 12 |
-#define XXUSB_READOUT_STACK 2 |
-#define XXUSB_SCALER_STACK 3 |
-#define XXUSB_NAF_DIRECT 12 |
- |
-// dodal 19.4.2011 da dela na 64-bit masinah |
-typedef unsigned int Uint32_t; |
- |
-struct XXUSB_STACK |
-{ |
-Uint32_t Data; |
-short Hit; |
-short APatt; |
-short Num; |
-short HitMask; |
-}; |
- |
-struct XXUSB_CC_COMMAND_TYPE |
-{ |
-short Crate; |
-short F; |
-short A; |
-short N; |
-Uint32_t Data; |
-short NoS2; |
-short LongD; |
-short HitPatt; |
-short QStop; |
-short LAMMode; |
-short UseHit; |
-short Repeat; |
-short AddrScan; |
-short FastCam; |
-short NumMod; |
-short AddrPatt; |
-Uint32_t HitMask[4]; |
-Uint32_t Num; |
-}; |
- |
-struct xxusb_device_typ |
-{ |
- struct usb_device *usbdev; |
- char SerialString[7]; |
-}; |
- |
-typedef struct xxusb_device_typ xxusb_device_type; |
-typedef unsigned char UCHAR; |
-typedef struct usb_bus usb_busx; |
- |
- |
-int xxusb_longstack_execute(usb_dev_handle *hDev, void *DataBuffer, int lDataLen, int timeout); |
-int xxusb_bulk_read(usb_dev_handle *hDev, void *DataBuffer, int lDataLen, int timeout); |
-int xxusb_bulk_write(usb_dev_handle *hDev, void *DataBuffer, int lDataLen, int timeout); |
-int xxusb_usbfifo_read(usb_dev_handle *hDev, int *DataBuffer, int lDataLen, int timeout); |
- |
-short xxusb_register_read(usb_dev_handle *hDev, short RegAddr, Uint32_t *RegData); |
-short xxusb_stack_read(usb_dev_handle *hDev, short StackAddr, Uint32_t *StackData); |
-short xxusb_stack_write(usb_dev_handle *hDev, short StackAddr, Uint32_t *StackData); |
-short xxusb_stack_execute(usb_dev_handle *hDev, Uint32_t *StackData); |
-short xxusb_register_write(usb_dev_handle *hDev, short RegAddr, Uint32_t RegData); |
-short xxusb_reset_toggle(usb_dev_handle *hDev); |
- |
-short xxusb_devices_find(xxusb_device_type *xxusbDev); |
-short xxusb_device_close(usb_dev_handle *hDev); |
-usb_dev_handle* xxusb_device_open(struct usb_device *dev); |
-short xxusb_flash_program(usb_dev_handle *hDev, char *config, short nsect); |
-short xxusb_flashblock_program(usb_dev_handle *hDev, UCHAR *config); |
-usb_dev_handle* xxusb_serial_open(char *SerialString); |
- |
-short VME_register_write(usb_dev_handle *hdev, Uint32_t VME_Address, Uint32_t Data); |
-short VME_register_read(usb_dev_handle *hdev, Uint32_t VME_Address, Uint32_t *Data); |
-short VME_LED_settings(usb_dev_handle *hdev, int LED, int code, int invert, int latch); |
-short VME_DGG(usb_dev_handle *hdev, unsigned short channel, unsigned short trigger,unsigned short output, Uint32_t delay, unsigned short gate, unsigned short invert, unsigned short latch); |
- |
-short VME_Output_settings(usb_dev_handle *hdev, int Channel, int code, int invert, int latch); |
- |
-short VME_read_16(usb_dev_handle *hdev,short Address_Modifier, Uint32_t VME_Address, Uint32_t *Data); |
-short VME_read_32(usb_dev_handle *hdev, short Address_Modifier, Uint32_t VME_Address, Uint32_t *Data); |
-short VME_BLT_read_32(usb_dev_handle *hdev, short Address_Modifier, int count, Uint32_t VME_Address, Uint32_t Data[]); |
-short VME_write_16(usb_dev_handle *hdev, short Address_Modifier, Uint32_t VME_Address, Uint32_t Data); |
-short VME_write_32(usb_dev_handle *hdev, short Address_Modifier, Uint32_t VME_Address, Uint32_t Data); |
- |
-short CAMAC_DGG(usb_dev_handle *hdev, short channel, short trigger, short output, int delay, int gate, short invert, short latch); |
-short CAMAC_register_read(usb_dev_handle *hdev, int A, Uint32_t *Data); |
-short CAMAC_register_write(usb_dev_handle *hdev, int A, Uint32_t Data); |
-short CAMAC_LED_settings(usb_dev_handle *hdev, int LED, int code, int invert, int latch); |
-short CAMAC_Output_settings(usb_dev_handle *hdev, int Channel, int code, int invert, int latch); |
-short CAMAC_read_LAM_mask(usb_dev_handle *hdev, Uint32_t *Data); |
-short CAMAC_write_LAM_mask(usb_dev_handle *hdev, Uint32_t Data); |
- |
-short CAMAC_write(usb_dev_handle *hdev, int N, int A, int F, Uint32_t Data, int *Q, int *X); |
-short CAMAC_read(usb_dev_handle *hdev, int N, int A, int F, Uint32_t *Data, int *Q, int *X); |
-short CAMAC_Z(usb_dev_handle *hdev); |
-short CAMAC_C(usb_dev_handle *hdev); |
-short CAMAC_I(usb_dev_handle *hdev, int inhibit); |
- |
/petdaqfmf/libxxusb.h |
Property changes: |
Deleted: svn:executable |
Index: petdaqfmf/daq.C |
=================================================================== |
--- petdaqfmf/daq.C (revision 111) |
+++ petdaqfmf/daq.C (nonexistent) |
@@ -1,583 +0,0 @@ |
-#include <stdio.h> |
-#include <stdlib.h> |
-#include <string.h> |
-#include <unistd.h> |
-#include <sys/mman.h> |
-#include <errno.h> |
-#include <ctype.h> |
-#include <time.h> |
-#include <sys/time.h> |
-#include <sys/stat.h> |
-#include <signal.h> |
-#include <zlib.h> |
- |
-#include "CAENV965_DEF.h" |
-#include "VmUsbStack.h" |
- |
-#include "vme.h" |
- |
-#include "daq.h" |
- |
-#define VERSION 1.0 |
-#define TIMEOUT 3 |
- |
- |
-/* VME modules */ |
- |
-#define CAEN_V792 0x340000 // IJS V792 |
-#define CAEN_V792_1 0x530000 // FMF1 V792 |
-#define CAEN_V792_2 0x630000 // FMF2 V792 |
-#define CAEN_V965 0x350000 // IJS V965 |
-int addr[3]={CAEN_V792,CAEN_V792_1,CAEN_V965 }; |
-int nadc=3; |
- |
-int gPedestal = 255; |
- |
-#define BUFF_L 2048 |
-static int stackwrite[10000]; |
-static int stackdata[10000],stackdump[27000]; |
- |
- |
-/************************************************/ |
-int weight_while(int num) |
-{ |
- int i, tmp; |
- |
- for ( i =0; i <num; i++ ) tmp = 0; |
- return 0; |
-} |
-#define WWHILE weight_while(0) |
- |
-#define TRUE 1 |
-#define FALSE 0 |
- |
-int timer_out; |
-struct sigaction oact; |
-void timerast (int signumber) |
-{ |
- timer_out = TRUE; |
- fprintf(stderr,"TIMEOUT !!!\n"); |
-} |
- |
-void tmlnk (int tout) |
-{ |
- timer_out = FALSE; |
- struct sigaction act; |
- struct itimerval tdelay; |
- |
- act.sa_handler = timerast; |
- sigemptyset (&act.sa_mask); |
- act.sa_flags = 0; |
- |
- tdelay.it_value.tv_sec = tout / 100; |
- tdelay.it_value.tv_usec = 10000 * (tout % 100); |
- tdelay.it_interval.tv_sec = 0; |
- tdelay.it_interval.tv_usec = 0; |
- |
- if (sigaction (SIGALRM, &act, &oact) < 0) |
- { |
- perror ("sigaction(tmlnk)"); |
- exit (EXIT_FAILURE); |
- } |
- if (setitimer (ITIMER_REAL, &tdelay, NULL) < 0) |
- { |
- perror ("setitimer(tmlnk)"); |
- exit (EXIT_FAILURE); |
- } |
-} |
- |
-void tmulk () |
-{ |
- struct itimerval tdelay; |
- |
- tdelay.it_value.tv_sec = 0; |
- tdelay.it_value.tv_usec = 0; |
- tdelay.it_interval.tv_sec = 0; |
- tdelay.it_interval.tv_usec = 0; |
- |
- if (setitimer (ITIMER_REAL, &tdelay, NULL) < 0) |
- { |
- perror ("setitimer(tmulk)"); |
- exit (EXIT_FAILURE); |
- } |
- if (sigaction (SIGALRM, &oact, NULL) < 0) |
- { |
- perror ("sigaction(tmulk)"); |
- exit (EXIT_FAILURE); |
- } |
-} |
- |
-int fexist( char * path){ |
- struct stat sbuf; |
- int res; |
- if(!path || !*path) return 0; |
- res=stat(path,&sbuf); |
- if (res){ |
- if (errno==ENOENT) { |
- return 0; |
- } else { |
- return -1; |
- } |
- } |
- return 1; |
-} |
- |
- |
- |
- |
-int daq::init(){ |
- |
- xxusb_register_write(udev,1,0x0); // Stop DAQ mode |
- while (xxusb_usbfifo_read(udev,(int *) stackdump,BUFF_L,100)>0); |
- |
- |
- int rate=1000; |
- int i=80000000/rate-40; // 80 MHz |
- if (i<72) i=72; |
- // Set DGG channel A as a pulser, output on O1, |
- // with delay =500 x 12.5ns, |
- // and width = 500 x 12.5ns, |
- // not latching or inverting |
- // VME_DGG(udev,0,6,0,24000,6000,0,0); |
- VME_DGG(udev,0,6,0,i,40,0,0); |
- // Set DGG channel B to trigger on NIM1, output on O2, |
- // with delay =200 x 12.5ns, |
- // and width = 200 x 12.5ns, |
- // not latching or inverting |
- VME_DGG(udev,1,1,1,0,10,0,1); |
- |
- |
-// INIT stackdata |
- int fPedestal=gPedestal; |
- printf("CAEN V965 Pedestal set to %d\n", fPedestal); |
- if (fInit != NULL ) delete fInit; |
- fInit=new VmUsbStack(); |
- |
- for (int i=0;i<nadc;i++){ |
- fInit->WriteA24D16( addr[i] + CAENV965_CRN , 0x0); |
- fInit->WriteA24D16( addr[i] + CAENV965_GEO , i); |
- fInit->ReadA24D16(addr[i] + CAENV965_GEO); |
- for (int j=0;j<32;j++){ |
- fInit->WriteA24D16(addr[i] + CAENV965_THM + 0x02*j, fThreshold[j+i*32]); // threshold/kill for 32 channels |
- } |
- fInit->WriteA24D16( addr[i] + CAENV965_BS1, 0x80 ); // soft reset |
- fInit->WriteA24D16( addr[i] + CAENV965_BC1, 0x80 ); // soft reset |
- fInit->WriteA24D16( addr[i] + CAENV965_PED, fPedestal ); // pedestal |
- fInit->WriteA24D16( addr[i] + CAENV965_BS2,0x5000); |
- fInit->WriteA24D16( addr[i] + CAENV965_BS2,0x4); // clear module |
- fInit->WriteA24D16( addr[i] + CAENV965_BC2,0x4); |
- } |
- fInit->Marker(0xFAFC); |
- |
-// fInit->Print(); |
- |
- |
- // READOUT stackdata |
- if (fStack != NULL ) delete fStack; |
- fStack=new VmUsbStack(); |
- fStack->Marker(0xFFAB); |
- //fStack->ConditionalRead(addr[i] + CAENV965_SR1,0x1); // TRG wait : loop until bit 0 is on |
- // fStack->RepeatRead( CMD_A24, CMD_D32, addr[i] + CAENV965_OB,34,0); // repead read |
- //fStack->ConditionalRead(addr[i] + CAENV965_OB ,0x4000000) ; // loop until bit 26 is on, read data |
- for (int j=0;j<36;j++) fStack->ReadA24D32(addr[0] + CAENV965_OB); |
- for (int j=0;j<36;j++) fStack->ReadA24D32(addr[1] + CAENV965_OB); |
- for (int j=0;j<8;j++) fStack->ReadA24D32(addr[2] + CAENV965_OB);// 4 channels connected |
- fStack->Marker(0xFAFB); |
- |
- for (int i=0;i<nadc;i++){ |
- fStack->WriteA24D16(addr[i] + CAENV965_BS2,0x4); // clear module |
- fStack->WriteA24D16(addr[i] + CAENV965_BC2,0x4); |
- } |
- |
- //fStack->Print(); |
- |
- VME_LED_settings(udev, 0,0,0,0); // Set Yellow LED to light with with USB out buffer not empty |
- VME_LED_settings(udev, 1,1,0,0); // Set Red LED to light with NIM1 |
- VME_LED_settings(udev,2,0,0,0); // Set Green LED to light when stack is not empty |
- |
- Uint32_t vmereg; |
- VME_register_read(udev,0x00,&vmereg); |
- printf("VMUSB Firmware ID -> 0x%08X\n",vmereg); |
- |
- VME_register_read(udev,0x04,&vmereg); |
- printf("VMUSB Global Mode -> 0x%08X\n",vmereg); |
- |
- vmereg=(vmereg&0xF000)|0x0004; |
- VME_register_write(udev,0x04,vmereg); |
- VME_register_write(udev,0x08,0x00000080); |
- VME_register_write(udev,0x28,0x0); |
- VME_register_write(udev,0x2C,0x0); |
- VME_register_write(udev,0x30,0x0); |
- VME_register_write(udev,0x34,0x0); |
- VME_register_write(udev,0x3C,0x000); |
- |
- int nb = fInit->Get(10000,stackdata); |
- int ret= xxusb_stack_execute(udev,(Uint32_t *)stackdata); |
- printf("Init::%d ret=%d\n",nb,ret); |
- if (ret>0) for (int i=0;i<ret/2;i++) printf ("stackdata=0x%08X\n",stackdata[i]); |
- |
- int nb0= fStack->Get(10000,&stackwrite[0]); |
- if (nb0>768) { |
- fprintf(stderr,"nb0=%d > 768 error xxusb_stack_write\n", nb0); |
- exit(-1); |
- } |
- nb =xxusb_stack_write(udev,0x2,(Uint32_t *) stackwrite); |
- nb0=xxusb_stack_read(udev,0x2,(Uint32_t *) stackdata); |
- for (int i=0;i<stackwrite[0]+1;i++){ |
- if (stackdata[i]!=stackwrite[i]) printf("%d %d init err %x %x\n",nb,nb0,stackwrite[i], stackdata[i]); |
- } |
- |
- if (fMode==2) xxusb_register_write(udev,1,0x1); // Start DAQ mode |
- |
- printf("daq::init() \n"); |
- return 0; |
-} |
- |
-int daq::connect(){ |
- VME_START(NULL); |
- printf("daq::connect()\n"); |
- return 0; |
-} |
- |
-int daq::disconnect(){ |
- /* zakljuci */ |
- VME_STOP(); |
- printf("daq::disconnect()\n"); |
- return 0; |
-} |
- |
-int daq:: clear(){ |
- return 0; |
-} |
- |
-inline int module_header(int recid,Uint32_t *data,int len){ |
- data[0] = recid; |
- data[1] = (len >0)? len : 0 ; |
- return data[1]+2; |
-} |
- |
- |
-int daq::event(unsigned int *data, int maxn, int *ctr, int print){ |
- int tout=200; /* 1/100 of a second */ |
- const int lsize=sizeof(unsigned Uint32_t); |
- |
- |
- ctr[0]++; |
- ctr[1]++; |
- |
- int count=0; |
- |
- switch (fMode){ |
- case 0:// normal calls |
- { |
- unsigned short clr= 0x4; |
- unsigned int status=0; |
- Uint32_t mdata; |
- |
- for (int i=0;i<2;i++){ |
- // wait for trg |
- tmlnk (tout); |
- do VME_A24D16_R( addr[i] + CAENV965_SR1, &status); while ( (status&0x1)==0 && timer_out==0 ); |
- tmulk(); |
- // readout data |
- if (timer_out) return 0; |
- int len=0; |
- |
- do { |
- VME_A24D32_R(addr[i] + CAENV965_OB, &mdata); |
- mdata=data[count++]; |
- len++; |
- } while ( (mdata & 0x4000000)==0 && timer_out==0) ; // bit 26 EOB or not valid datum |
- // clear |
- VME_A24D16_W( addr[i] + CAENV965_BS2, &clr); |
- VME_A24D16_W( addr[i] + CAENV965_BC2, &clr); |
- |
- if (count+2<maxn) { |
- if (print) printf("V965 %3d\n",len); |
- count+=module_header(0x130+i,&data[count],len); |
- ctr[2]++; |
- ctr[3]+=len; |
- } |
- |
- timer_out=0; |
- } |
- } |
- break; |
- case 1:// stack execute |
- { |
- fStack->Get(10000,(int *)data); |
- int ret=xxusb_stack_execute(udev,(Uint32_t *) data); //The first element of the array is the number of bytes. |
- if (ret< 0 ) { |
- printf ("xxusb_stack_execute error err=%d\n",ret); \ |
- count = 0; |
- } else count= ret/lsize; |
- |
- } |
- break; |
- case 2:// stack load |
- { |
- int ret=xxusb_usbfifo_read(udev,(int *) data,BUFF_L,100); |
- if (ret< 0 ) { |
- if (ret!=-110) { |
- printf ("xxusb_usbfifo_read error err=%d\n",ret); |
- end(); |
- init(); |
- } |
- count = 0; |
- } else { |
- if (0 && print && ret>0) { |
- for (int i=0;i<100;i++) { |
- printf ("%4d fifodata=0x%08X\n",i, data[i]); |
- if (data[i]==0xFAFB) break; |
- } |
- /* |
- |
- 0 fifodata=0x0000000D |
- 1 fifodata=0x00000049 |
- 2 fifodata=0x0000FFAB |
- 3 fifodata=0x00002000 |
- 4 fifodata=0x00000200 |
- 5 fifodata=0x00004141 |
- 6 fifodata=0x00000000 |
- 7 fifodata=0x00004057 |
- 8 fifodata=0x00000010 |
- 9 fifodata=0x00004052 |
- 10 fifodata=0x00000001 |
- 11 fifodata=0x0000405C |
- 12 fifodata=0x00000011 |
- 13 fifodata=0x0000405D |
- 14 fifodata=0x00000002 |
- 15 fifodata=0x0000405E |
- 16 fifodata=0x00000012 |
- 17 fifodata=0x0000401C |
- 18 fifodata=0x00000003 |
- 19 fifodata=0x0000402F |
- 20 fifodata=0x00000013 |
- 21 fifodata=0x00004024 |
- 22 fifodata=0x00000004 |
- 23 fifodata=0x00004076 |
- 24 fifodata=0x00000014 |
- 25 fifodata=0x0000412F |
- 26 fifodata=0x00000005 |
- 27 fifodata=0x0000404C |
- 28 fifodata=0x00000015 |
- 29 fifodata=0x00004132 |
- 30 fifodata=0x00000006 |
- 31 fifodata=0x00004044 |
- 32 fifodata=0x00000016 |
- 33 fifodata=0x0000404A |
- 34 fifodata=0x00000007 |
- 35 fifodata=0x0000409B |
- 36 fifodata=0x00000017 |
- 37 fifodata=0x000040F1 |
- 38 fifodata=0x00000008 |
- 39 fifodata=0x00004087 |
- 40 fifodata=0x00000018 |
- 41 fifodata=0x00004173 |
- 42 fifodata=0x00000009 |
- 43 fifodata=0x0000404C |
- 44 fifodata=0x00000019 |
- 45 fifodata=0x0000406C |
- 46 fifodata=0x0000000A |
- 47 fifodata=0x00004070 |
- 48 fifodata=0x0000001A |
- 49 fifodata=0x0000406E |
- 50 fifodata=0x0000000B |
- 51 fifodata=0x00004014 |
- 52 fifodata=0x0000001B |
- 53 fifodata=0x000040B7 |
- 54 fifodata=0x0000000C |
- 55 fifodata=0x000040A9 |
- 56 fifodata=0x0000001C |
- 57 fifodata=0x00004048 |
- 58 fifodata=0x0000000D |
- 59 fifodata=0x00004118 |
- 60 fifodata=0x0000001D |
- 61 fifodata=0x0000409D |
- 62 fifodata=0x0000000E |
- 63 fifodata=0x0000405B |
- 64 fifodata=0x0000001E |
- 65 fifodata=0x00004285 |
- 66 fifodata=0x0000000F |
- 67 fifodata=0x00004159 |
- 68 fifodata=0x0000001F |
- 69 fifodata=0x00000035 |
- 70 fifodata=0x00000400 |
- 71 fifodata=0x00000035 |
- 72 fifodata=0x00000600 |
- 73 fifodata=0x00000035 |
- 74 fifodata=0x0000FAFB |
- |
- |
- */ |
- } |
- if (print) printf("------------------ret=%d data[0]=%d\n",ret,(int)data[0]); |
- count= ret/lsize; |
- ctr[2]+=data[0]; |
- ctr[3]+=count; |
- } |
- } |
- break; |
- } |
- return count*lsize; |
-} |
- |
-int daq::end(){ |
- |
- xxusb_register_write(udev,1,0x0); // Stop DAQ mode |
- while (xxusb_usbfifo_read(udev,(int *) stackdata,BUFF_L,30)>0); |
- printf("daq::end()\n"); |
- return 0; |
-} |
- |
-daq::daq(){ |
- fMode = 2; |
- fPedestal=255; |
- for (int i=0;i<128;i++){ |
- if (i<72) fThreshold.push_back(0); |
- else fThreshold.push_back(0x1<<8); // samo 4 kanali na zadnjem modulu so enablani |
- } |
- fThresholdEnable=0; |
- fStop=0; |
- fInit=NULL; |
- fStack=NULL; |
- connect(); |
-} |
- |
-daq::~daq(){ |
-disconnect(); |
-} |
- |
-#ifdef MAIN |
-/* ------------------- CatchSig ----------------- */ |
-int ctrlcflag=0; |
- |
-void SigInt (int sig) |
-{ |
- ctrlcflag = 1; |
- timer_out=1; |
-} |
- |
-int main (int argc, char **argv){ |
- // intercept routine |
- if (signal (SIGINT, SigInt) == SIG_ERR) { |
- perror ("sigignore"); |
- } |
- |
- // print welcome message |
- time_t t,told, tstart, tstop; |
- time(&t); |
- fprintf(stdout,"#############################################\n"); |
- fprintf(stdout,"Program %s version %2.1f\n",argv[0], VERSION); |
- fprintf(stdout,"Compiled on %s %s\n",__DATE__, __TIME__); |
- fprintf(stdout,"Runtime %s \n",ctime(&t)); |
- fprintf(stdout,"#############################################\n"); |
- |
- |
- int neve=-1; |
- char cfname[100]="test.dat"; |
- char *fname=cfname; |
- char *fpedname=NULL; |
- |
-#define BSIZE 10000 |
- Uint32_t data[10000]; |
- |
- |
- daq *d= new daq(); |
- int c; |
- |
- while ((c = getopt (argc, argv, "p:n:t:o:")) != -1) |
- switch (c) |
- { |
- case 'o': |
- sprintf(fname ,"%s", optarg); |
- if (fexist(fname)==1){ |
- fprintf(stdout,"Error !\n"); |
- fprintf(stdout,"File %s already exist. Appending ....\n",fname); |
- //fprintf(stdout,"Remove the file and restart !!!\n"); |
- //exit(0); |
- } |
- break; // input file |
- case 'n': |
- neve = atoi(optarg); // negative argument time ( in s )limited event loop |
- break; |
- case 't': |
- { |
- |
- sprintf(fpedname ,"%s", optarg); |
- FILE *fped=fopen(fpedname,"r"); |
- int j=0; |
- int ndim=400; |
- char line[ndim]; |
- int val=0; |
- while (fgets(line,ndim,fped)!=NULL){ |
- sscanf(line,"%d",&val); |
- d->fThreshold[j++]=val; |
- } |
- d->fThresholdEnable=1; |
- //fclose(fped); |
- fclose(fped); |
- break; |
- } |
- case 'p': |
- gPedestal = atoi(optarg); // injected charge to the qdc |
- break; |
- } |
- |
- if (argc==1) { |
- fprintf(stdout,"Usage: %s -o [filename] -n [number of events] -t [thresholdfile] -p <qdc inject charge>\n negative number of events = acq time in seconds\n",argv[0]); |
- exit(-1); |
- } |
- //FILE *fp=fopen(fname,"a"); |
- gzFile fp=gzopen(fname,"a"); |
- |
- d->init(); |
- d->clear(); |
- |
- int hdr[4]={2}; // recid od run 11 naprej |
- int i=0; |
- int ntotal=0; |
- int counters[30]={0,0,0,0,0, 0,0,0,0,0,0,0}; |
- char names[10][20]={"TRG","CAEN V965"}; |
- time(&t); |
- tstart=t; |
- tstop=tstart+360000; |
- if (neve<-1) { |
- tstop=tstart-neve; |
- neve=-1; |
- } |
- for (i=0;i!=neve && !ctrlcflag && t<tstop;i++){ |
- time(&t); |
- if (t!=told ) printf("%d in %2.2f min daq::event() %s\n",i, (double)(t-tstart)/60., ctime(&t)); |
- int nb=d->event(data,BSIZE, counters,t!=told); |
- if (nb>0){ |
- // zapis v datoteko |
- hdr[1]=nb+4*sizeof(int); |
- hdr[2]=time(NULL); |
- hdr[3]=i; |
- |
- //fwrite(hdr, sizeof(int),4 , fp); |
- gzwrite(fp, hdr, sizeof(int)*4); //gzip |
- // recid=1 do runa 10. ntotal += fwrite(data, sizeof(int),nb, fp); |
- //ntotal += fwrite(data, 1,nb, fp); |
- ntotal += gzwrite(fp, data, nb); |
- told=t; |
- } else i--; |
- } |
- |
- d->end(); |
- delete d; |
- printf("Number of Events: %d\n",i); |
- if (ctrlcflag) printf("User Program termination CTRL-C\n"); |
- if (t>tstop ) printf("Timeout termination tstart# t>tstop: %d# %d >%d\n",(int)t, (int)tstart, (int) tstop); |
- |
- |
- //fclose(fp); |
- gzclose(fp); |
- fprintf(stdout,"%d bytes written to %s\nCounts:\n", (int) (ntotal*sizeof(int)),fname); |
- for (i=0;i<2;i++) fprintf(stdout,"%s\t%d\t%d\n",names[i],counters[2*i],counters[2*i+1]) ; |
- |
- |
- return 0; |
-} |
-#endif |
Index: petdaqfmf/.root_hist |
=================================================================== |
--- petdaqfmf/.root_hist (revision 111) |
+++ petdaqfmf/.root_hist (nonexistent) |
@@ -1,99 +0,0 @@ |
-TBrowser tt |
-.q |
-TBrowser d |
-TFile *_file0 = TFile::Open("test100.root") |
-ach0->Draw() |
-.q |
-TFile *_file0 = TFile::Open("test50.root") |
-ach0->Draw() |
-.q |
-TFile *_file0 = TFile::Open("test150.root") |
-ach0->Draw() |
-TFile *_file0 = TFile::Open("test250.root") |
-ach0->Draw() |
-TFile *_file0 = TFile::Open("test200.root") |
-ach0->Draw() |
-TFile *_file0 = TFile::Open("test150.root") |
-ach0->Draw() |
-TFile *_file0 = TFile::Open("test100.root") |
-ach0->Draw() |
-TFile *_file0 = TFile::Open("test50.root") |
-ach0->Draw() |
-.q |
-TFile *_file0 = TFile::Open("test80.root") |
-ach0->Draw() |
-ach0->Draw() |
-ach1->Draw() |
-ach2->Draw() |
-ach3->Draw() |
-ach4->Draw() |
-ach5->Draw() |
-ach6->Draw() |
-ach7->Draw() |
-ach8->Draw() |
-ach9->Draw() |
-ach10->Draw() |
-ach11->Draw() |
-ach12->Draw() |
-ach13->Draw() |
-ach14->Draw() |
-ach15->Draw() |
-ach16->Draw() |
-ach15->Draw() |
-.q |
-TFile *_file0 = TFile::Open("test80_reversed.root") |
-ach15->Draw() |
-ach1->Draw() |
-ach2->Draw() |
-ach3->Draw() |
-ach4->Draw() |
-ach4->Draw() |
-.q |
-TFile *_file0 = TFile::Open("test.root") |
-ach4->Draw() |
-1->Draw() |
-a1->Draw() |
-ach5->Draw() |
-ach5->Draw() |
-ach7->Draw() |
-ach16->Draw() |
-ach18->Draw() |
-ach36->Draw() |
-.q |
-TFile *_file0 = TFile::Open("test1.root") |
-ach7->Draw() |
-ach17->Draw() |
-ach7->Draw() |
-.q |
-TFile *_file0 = TFile::Open("test.root") |
-ach7->Draw() |
-ach27->Draw() |
-ach17->Draw() |
-ach18->Draw() |
-ach16->Draw() |
-ach15->Draw() |
-ach14->Draw() |
-ach13->Draw() |
-.ls |
-sumadc1->Draw() |
-sumadc0->Draw() |
-cadc0->Draw() |
-pmt0->Draw() |
-pmt1->Draw() |
-pmt0->Draw() |
-sumadc0->Draw() |
-.q |
-TFile *_file0 = TFile::Open("test_reversed.root") |
-sumadc0->Draw() |
-tbrowser |
-TBrowser |
-TBrowser jj |
-.q |
-TFile *_file0 = TFile::Open("test850.root") |
-ach14->Draw() |
-ach11->Draw() |
-ach0->Draw() |
-ach15->Draw() |
-ach16->Draw() |
-ach15->Draw() |
-.q |
Index: petdaqfmf/wienvme_dll.h |
=================================================================== |
--- petdaqfmf/wienvme_dll.h (revision 111) |
+++ petdaqfmf/wienvme_dll.h (nonexistent) |
@@ -1,53 +0,0 @@ |
-#ifndef _WIENVME_DLL_H |
-#define _WIENVME_DLL_H |
- |
-#include "libxxusb.h" |
- |
-extern usb_dev_handle *udev; |
- |
- |
- |
-int VME_start (char*); |
-int VME_close (int); |
-int VME_stop (void); |
-int VME_reset (void); |
- |
- |
-int VME_read16 (Uint32_t, void*); |
-int VME_read32 (Uint32_t, void*); |
- |
-int VME_write16 ( Uint32_t, void*); |
-int VME_write32 ( Uint32_t, void*); |
- |
-#define VME_START(NODE) VME_start((NODE)) |
-#define VME_STOP() VME_stop() |
-#define VME_RESET() VME_reset() |
- |
-#define VME_A24D16_R(VME,DATA) VME_read16( (VME), (DATA)) |
-#define VME_A24D32_R(VME,DATA) VME_read32( (VME), (DATA)) |
- |
-#define VME_A24D16_W(VME,DATA) VME_write16( (VME), (DATA)) |
-#define VME_A24D32_W(VME,DATA) VME_write32( (VME), (DATA)) |
- |
-#define VME_A32D16_R(VME,DATA) VME_read16( (VME), (DATA)) |
-#define VME_A32D32_R(VME,DATA) VME_read32( (VME), (DATA)) |
- |
-#define VME_A32D16_W(VME,DATA) VME_write16( (VME), (DATA)) |
-#define VME_A32D32_W(VME,DATA) VME_write32( (VME), (DATA)) |
- |
-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 |
- |
-#endif |
/petdaqfmf/wienvme_dll.h |
Property changes: |
Deleted: svn:executable |
Index: petdaqfmf/daq.h |
=================================================================== |
--- petdaqfmf/daq.h (revision 111) |
+++ petdaqfmf/daq.h (nonexistent) |
@@ -1,24 +0,0 @@ |
-#ifndef _daq_h_ |
-#define _daq_h_ |
-#include <vector> |
-class VmUsbStack; |
-class daq { |
-public: |
- VmUsbStack * fStack; |
- VmUsbStack * fInit; |
- int fPedestal; |
- int fThresholdEnable; |
- std::vector<int> fThreshold; |
- int fStop; |
- int fMode; |
- int clear(); |
- int end(); |
- int event(unsigned int *, int,int*, int ); |
- int init(); |
- int connect(); |
- int disconnect(); |
- daq(); |
- ~daq(); |
-}; |
- |
-#endif |
Index: petdaqfmf/VMEModule.hh |
=================================================================== |
--- petdaqfmf/VMEModule.hh (revision 111) |
+++ petdaqfmf/VMEModule.hh (nonexistent) |
@@ -1,39 +0,0 @@ |
-/********************\ |
- VMEModule.hh |
- |
- update: 04/01/28 |
- |
-\********************/ |
- |
-#ifndef VMEMODULE_HH |
-#define VMEMODULE_HH |
- |
- |
- |
-#include <stdio.h> |
-#include <sys/types.h> |
-#include "pcivme_ni.h" |
- |
-#define VMEA24 (unsigned short)0x39 |
-#define VMEA32 (unsigned short)0x09 |
-#define VMEA16 (unsigned short)0x29 |
-class VMEModule { |
-protected: |
- int m_fd; |
- int m_vmeptr; |
- caddr_t m_vmeaddr; |
- size_t m_size; |
- unsigned long m_baseaddress; |
-public: |
- VMEModule(int device, caddr_t vmeaddr, size_t size); |
- ~VMEModule(); |
- unsigned long getBaseAddress() { return (unsigned long) m_baseaddress; } |
- caddr_t getVmeAddress() { return m_vmeaddr; } |
- void write32(unsigned long address, unsigned long value); |
- unsigned long read32(unsigned long address); |
- |
- void write16(unsigned long address, unsigned short value); |
- unsigned short read16(unsigned long address); |
-}; |
- |
-#endif |
Index: petdaqfmf/README |
=================================================================== |
--- petdaqfmf/README (revision 111) |
+++ petdaqfmf/README (nonexistent) |
@@ -1,2 +0,0 @@ |
-./daq -o [filename] -n [number of events] -t [thresholdfile] -p <qdc inject charge> |
- negative number of events = acq time in seconds |
Index: petdaqfmf/pcivme_ni.h |
=================================================================== |
--- petdaqfmf/pcivme_ni.h (revision 111) |
+++ petdaqfmf/pcivme_ni.h (nonexistent) |
@@ -1,84 +0,0 @@ |
-#ifndef __PCIVME_NI_H__ |
-#define __PCIVME_NI_H__ |
- |
-//------------------------------------------------------------------------------------------- |
-// pcivme_ni.h - header for ni-labview shared library or dll for ARW pcivme interface |
-// this library can also be used for other purposes aside from labview |
-// |
-// Copyright (C) 2002-2004 ARW Elektronik Germany |
-// |
-// this source code is published under LGPL (Open Source). You can use, redistrubute and |
-// modify it unless this header is not modified or deleted. No warranty is given that |
-// this software will work like expected. |
-// This product is not authorized for use as critical component in life support systems |
-// wihout the express written approval of ARW Elektronik Germany. |
-// |
-// Please announce changes and hints to ARW Elektronik |
-// |
-// $Log: pcivme_ni.h,v $ |
-// Revision 1.8 2004/08/13 19:23:45 klaus |
-// conversion to kernel-version 2.6, released version 3.0 |
-// |
-// Revision 1.7 2002/10/20 18:07:18 klaus |
-// changed error handling |
-// |
-// Revision 1.6 2002/10/18 21:56:28 klaus |
-// completed functional features, untested |
-// |
-// Revision 1.5 2002/10/18 21:56:28 klaus |
-// completed functional features, untested |
-// |
-// Revision 1.4 2002/10/17 21:16:03 klaus |
-// filled function bodies |
-// |
-// Revision 1.3 2002/10/17 21:16:03 klaus |
-// filled function bodies |
-// |
-// Revision 1.2 2002/10/17 19:05:03 klaus |
-// VME access is working through test to lib to driver |
-// |
-// Revision 1.1 2002/10/12 22:04:44 klaus |
-// first work done |
-// |
-// what who when |
-// first steps AR 17.11.1999 |
-// VMEerror new AR 07.01.2000 |
-// made LINUX shared library from windows template AR 12.10.2002 |
-// |
- |
-//------------------------------------------------------------------------------------------- |
-// INCLUDES |
-// |
-#define BOOLEAN int |
-#if !defined(TRUE) && !defined(FALSE) |
- #define FALSE 0 |
- #define TRUE 1 |
-#endif |
- |
-//------------------------------------------------------------------------------------------- |
-// PROTOTYPES |
-// |
-#ifdef __cplusplus |
-extern "C" |
-{ |
-#endif |
-int VMEopen(const char *cszDeviceName, unsigned char ubAddressModifier, int *pnHandle); |
-int VMEinit(const char *cszDeviceName, unsigned short nVMEMM, unsigned char ubAddressModifier, int *pnHandle); |
-int setAccessProperties(int nHandle, unsigned char bModifier, unsigned char bAccessType); |
-int VMEread(int nHandle, unsigned long ulAddress, unsigned char ubAccessWidth, unsigned long ulElementCount, void *pvBuffer); |
-int VMEwrite(int nHandle, unsigned long ulAddress, unsigned char ubAccessWidth, unsigned long ulElementCount, void *pvBuffer); |
-int VMEaccessVIC(int nHandle, unsigned char ubAccessMode, unsigned short uwAddress, unsigned char *ubContent); |
-int VMEreset(int nHandle); |
-int VMETAS(int nHandle, unsigned long ulAddress, unsigned char *ubResult); |
-int VMEcontrolInterrupt(int nHandle, BOOLEAN *bEnable); |
-int VMEinterrupt(int nHandle, unsigned char *ubVector); |
-int VMEsysfailGet(int nHandle, BOOLEAN *bResult); |
-int VMEsysfailSet(int nHandle, BOOLEAN bForce); |
-int VMEerror(int nHandle); |
-int VMEclose(int nHandle); |
-int GetLastError(int nHandle); |
-#ifdef __cplusplus |
-} |
-#endif |
- |
-#endif /* __PCIVME_NI_H__ */ |
Index: petdaqfmf/wienvmeusb_dll.c |
=================================================================== |
--- petdaqfmf/wienvmeusb_dll.c (revision 111) |
+++ petdaqfmf/wienvmeusb_dll.c (nonexistent) |
@@ -1,98 +0,0 @@ |
-#include <stdlib.h> |
-#include <stdio.h> |
-#include "pcivme_ni.h" |
-#include "wienvme_dll.h" |
-//----------- DEFINES ----------------------------------------------------- |
-#define DEVICENAME_LINUX "/dev/vmemm_1" // a device name 'template' for WINNT |
- |
-usb_dev_handle *udev; |
- |
- |
- |
- |
-int VME_start (char* serial) |
-{ |
- |
- char serial_default[100]; |
- sprintf(serial_default, "VM0120"); |
- if (serial != NULL) |
- udev = xxusb_serial_open(serial); |
- else |
- udev = xxusb_serial_open(serial_default); |
- printf(" VME_start %s--->udev!=NULL ==>%d\n", serial, udev!=NULL); |
- if (!udev) { |
- printf(" Check usb udev permissions and restart! Exiting .....\n", serial, udev!=NULL); |
- exit(-1); |
- } |
- return 0; |
-} |
- |
- |
- |
-int VME_stop () |
-{ |
- if (udev) xxusb_device_close(udev); |
- |
- |
- return 0; |
-} |
- |
-short Address_Modifier= Std_NoPriv_Data; |
- |
-int VME_read16 (Uint32_t at, void* buff) |
-{ |
- int result; |
- |
-/* D16 read */ |
- |
- result = VME_read_16(udev, Address_Modifier, at , (Uint32_t *) buff); |
- if (result <0) { |
- printf("D16 read at 0x%X failed! err=%d\n", at,result); |
- } |
-// printf("0x%X, 0x%X, 0x%X, 0x%X\n", hHandle, at, n, * (unsigned short *) buff); |
- return (result); |
-} |
- |
-int VME_read32 (Uint32_t at, void* buff) |
-{ |
- int result; |
- |
-/* D32 read */ |
- |
- result = VME_read_32(udev, Address_Modifier, at , (Uint32_t *) buff); |
- if (result < 0) { |
- printf("D32 read at 0x%X failed err=%d!\n", at,result); |
- } |
- //printf("0x%X, 0x%X, 0x%X, 0x%X\n", hHandle, at, n, * (unsigned short *) buff); |
- return (result); |
-} |
- |
-int VME_write16 (Uint32_t at, void* buff) |
-{ |
- int result; |
- Uint32_t data= *((short *)buff); |
- |
-/* D16 write */ |
- |
- result = VME_write_16(udev, Address_Modifier, at, data ); |
- if (result<0) { |
- printf("D16 write at 0x%X failed! err=%d\n", at,result); |
- } |
- return (result); |
-} |
- |
-int VME_write32 ( Uint32_t at, void* buff) |
-{ |
- int result; |
- Uint32_t data= *((Uint32_t *)buff); |
- |
-/* D32 write */ |
- |
- result = VME_write_32(udev, Address_Modifier, at, data ); |
- |
- if (result<0) { |
- printf("D32 write at 0x%X failed! err=%d\n", at,result); |
- } |
- //printf("D32 write at 0x%lX buff=0x%X\n", at,((int*) buff)[0]); |
- return (result); |
-} |
/petdaqfmf/wienvmeusb_dll.c |
Property changes: |
Deleted: svn:executable |
Index: petdaqfmf/LinkDef.h |
=================================================================== |
--- petdaqfmf/LinkDef.h (revision 111) |
+++ petdaqfmf/LinkDef.h (nonexistent) |
@@ -1,10 +0,0 @@ |
-#ifdef __CINT__ |
- |
-#pragma link off all globals; |
-#pragma link off all classes; |
-#pragma link off all functions; |
- |
-#pragma link C++ class daq; |
- |
-#endif |
- |
Index: petdaqfmf/VmUsbStack.C |
=================================================================== |
--- petdaqfmf/VmUsbStack.C (revision 111) |
+++ petdaqfmf/VmUsbStack.C (nonexistent) |
@@ -1,124 +0,0 @@ |
-#include <stdio.h> |
-#include <vector> |
-#include "VmUsbStack.h" |
- |
-VmUsbStack::VmUsbStack(){ |
- fStack.push_back(0x1); |
- fStack.push_back(0x0); |
-} |
- |
-VmUsbStack::~VmUsbStack(){ |
- fStack.clear(); |
-} |
- |
-int VmUsbStack::Get(int maxn, int *stack){ |
- for (int i=0;i<fStack.size();i++){ |
- if (i<maxn) stack[i]=fStack[i]; else return -1; |
- } |
- return fStack[0]; |
-} |
- |
- |
-void VmUsbStack::Append(int cmd, int addr ){ |
- fStack.push_back(cmd & 0xFFFF); |
- fStack.push_back(cmd >> 16); |
- fStack.push_back(addr&0xFFFF); |
- fStack.push_back((addr >> 16)& 0xFFFF); |
- fStack[0]=fStack.size()-1; |
-} |
- |
-void VmUsbStack::Append(int cmd, int addr , int data){ |
- Append( cmd, addr ); |
- fStack.push_back(data&0xFFFF); |
- fStack.push_back((data >> 16)&0xFFFF); |
- fStack[0] = fStack.size()-1; |
-} |
- |
-void VmUsbStack::ReadA24D16(int addr ){ |
- Append(CMD_READ | CMD_A24 , CMD_D16 | addr); |
-} |
- |
-void VmUsbStack::WriteA24D16(int addr, int data){ |
- return Append(CMD_WRITE | CMD_A24,CMD_D16 | addr, data); |
-} |
- |
-void VmUsbStack::ReadA24D32(int addr ){ |
- Append(CMD_READ | CMD_A24 , CMD_D32 | addr); |
-} |
- |
-void VmUsbStack::WriteA24D32(int addr, int data){ |
- return Append(CMD_WRITE | CMD_A24 , CMD_D32 | addr, data); |
-} |
- |
-void VmUsbStack::ReadA32D16(int addr ){ |
- Append(CMD_READ | CMD_A32 , CMD_D16| addr); |
-} |
- |
-void VmUsbStack::WriteA32D16(int addr, int data){ |
- return Append(CMD_WRITE | CMD_A32 , CMD_D16 | addr, data); |
-} |
- |
-void VmUsbStack::ReadA32D32(int addr ){ |
- Append(CMD_READ | CMD_A32 , CMD_D32 | addr); |
-} |
- |
-void VmUsbStack::WriteA32D32(int addr, int data){ |
- return Append(CMD_WRITE | CMD_A32 , CMD_D32| addr, data); |
-} |
- |
- |
-void VmUsbStack::Marker(int marker){ |
- return Append(CMD_MRK, marker); |
-} |
- |
-void VmUsbStack::ConditionalRead(int adr_mod,int d16d32, int addr, int bmask){ |
- Append(CMD_READ| CMD_HD | adr_mod ,addr); |
- Append(CMD_READ| CMD_HD | CMD_HM |adr_mod, d16d32 |addr,bmask); |
-} |
- |
-void VmUsbStack::RepeatRead(int adr_mod,int d16d32, int baseaddr, int n, int increment){ |
- for (int i=0;i<n;i++) Append( adr_mod | CMD_READ, d16d32 +baseaddr + i*increment); |
-} |
-void VmUsbStack::RepeatWrite(int adr_mod,int d16d32,int baseaddr, int n, int increment, int data){ |
- for (int i=0;i<n;i++) Append( adr_mod | CMD_WRITE,d16d32 + baseaddr+i*increment, data); |
-} |
- |
-void VmUsbStack::Print(){ |
- for (int i=0; i < fStack.size();i++) printf("0x%04x\n",fStack[i]); |
- printf("%d %d __________________________________\n",fStack.size(),fStack[0]); |
-} |
- |
-#ifdef MAIN |
-#include "CAENV965_DEF.h" |
-#define CAEN_V965 0x340000 |
- |
-int main(){ |
-// INIT stackdata |
-int geo=1,fPedestal=255; |
-VmUsbStack *init=new VmUsbStack(); |
-init->Write(CAEN_V965 + CAENV965_CRN, 0x0); |
-init->Write(CAEN_V965 + CAENV965_GEO, geo); |
-init->RepeatWrite( CAEN_V965 + CAENV965_THM, 32, 0x02,0x0); // threshold/kill for 32 channels, 2*i addr increment |
-init->Write( CAEN_V965 + CAENV965_BS1, 0x80 ); // soft reset |
-init->Write( CAEN_V965 + CAENV965_BC1, 0x80 ); // soft reset |
-init->Write( CAEN_V965 + CAENV965_PED, fPedestal ); // pedestal |
-init->Write(CAEN_V965 + CAENV965_BS2,0x5000); |
-init->Write(CAEN_V965 + CAENV965_BS2,0x4); // clear module |
-init->Write(CAEN_V965 + CAENV965_BC2,0x4); |
-init->Print(); |
- |
-// READOUT stackdata |
-VmUsbStack *stack=new VmUsbStack(); |
-stack->Write(CAEN_V965 + CAENV965_BS2,0x4); // clear module |
-stack->Write(CAEN_V965 + CAENV965_BC2,0x4); |
-stack->ConditionalRead(CAEN_V965 + CAENV965_SR1,0x1); // TRG wait : loop until bit 0 is on |
-stack->ConditionalRead(CAEN_V965 + CAENV965_OB ,0x4000000) ; // loop until bit 26 is on, read data |
-stack->Marker(0xFAFB); |
-stack->Print(); |
- |
- int st[1000]; |
- int nb= stack->Get(1000,st); |
- for (int i=0;i<nb;i++) if (st[i]!=stack->fStack[i]) printf("error i=%d 0x%04x 0x%04x \n",i,st[i],stack->fStack[i] ); |
- return 0; |
-} |
-#endif |
Index: petdaqfmf/CAENV965_DEF.h |
=================================================================== |
--- petdaqfmf/CAENV965_DEF.h (revision 111) |
+++ petdaqfmf/CAENV965_DEF.h (nonexistent) |
@@ -1,22 +0,0 @@ |
-#ifndef _CAENV965_DEF_H |
-#define _CAENV965_DEF_H |
- |
-#define CAENV965_OB 0x0 |
-#define CAENV965_FW 0x1000 |
-#define CAENV965_GEO 0x1002 |
-#define CAENV965_MCA 0x1004 |
-#define CAENV965_BS1 0x1006 |
-#define CAENV965_BC1 0x1008 |
-#define CAENV965_SR1 0x100E |
-#define CAENV965_CR1 0x1010 |
-#define CAENV965_ADH 0x1012 |
-#define CAENV965_ADL 0x1014 |
-#define CAENV965_SR2 0x1022 |
-#define CAENV965_BS2 0x1032 |
-#define CAENV965_BC2 0x1034 |
-#define CAENV965_CRN 0x103C |
-#define CAENV965_ECR 0x1040 |
-#define CAENV965_PED 0x1060 |
-#define CAENV965_THM 0x1080 |
- |
-#endif |
Index: petdaqfmf/gui.C |
=================================================================== |
--- petdaqfmf/gui.C (revision 111) |
+++ petdaqfmf/gui.C (nonexistent) |
@@ -1,455 +0,0 @@ |
-// By ROOT version 5.17/02 on 2008-03-13 06:46:41 |
- |
-#ifndef ROOT_TGDockableFrame |
-#include "TGDockableFrame.h" |
-#endif |
-#ifndef ROOT_TGMenu |
-#include "TGMenu.h" |
-#endif |
-#ifndef ROOT_TGMdiDecorFrame |
-#include "TGMdiDecorFrame.h" |
-#endif |
-#ifndef ROOT_TG3DLine |
-#include "TG3DLine.h" |
-#endif |
-#ifndef ROOT_TGMdiFrame |
-#include "TGMdiFrame.h" |
-#endif |
-#ifndef ROOT_TGMdiMainFrame |
-#include "TGMdiMainFrame.h" |
-#endif |
-#ifndef ROOT_TGuiBldHintsButton |
-#include "TGuiBldHintsButton.h" |
-#endif |
-#ifndef ROOT_TGMdiMenu |
-#include "TGMdiMenu.h" |
-#endif |
-#ifndef ROOT_TGListBox |
-#include "TGListBox.h" |
-#endif |
-#ifndef ROOT_TGNumberEntry |
-#include "TGNumberEntry.h" |
-#endif |
-#ifndef ROOT_TGScrollBar |
-#include "TGScrollBar.h" |
-#endif |
-#ifndef ROOT_TGuiBldHintsEditor |
-#include "TGuiBldHintsEditor.h" |
-#endif |
-#ifndef ROOT_TRootBrowser |
-#include "TRootBrowser.h" |
-#endif |
-#ifndef ROOT_TGFrame |
-#include "TGFrame.h" |
-#endif |
-#ifndef ROOT_TGFileDialog |
-#include "TGFileDialog.h" |
-#endif |
-#ifndef ROOT_TGShutter |
-#include "TGShutter.h" |
-#endif |
-#ifndef ROOT_TGButtonGroup |
-#include "TGButtonGroup.h" |
-#endif |
-#ifndef ROOT_TGCanvas |
-#include "TGCanvas.h" |
-#endif |
-#ifndef ROOT_TGFSContainer |
-#include "TGFSContainer.h" |
-#endif |
-#ifndef ROOT_TGButton |
-#include "TGButton.h" |
-#endif |
-#ifndef ROOT_TGuiBldEditor |
-#include "TGuiBldEditor.h" |
-#endif |
-#ifndef ROOT_TGTextEdit |
-#include "TGTextEdit.h" |
-#endif |
-#ifndef ROOT_TGFSComboBox |
-#include "TGFSComboBox.h" |
-#endif |
-#ifndef ROOT_TGLabel |
-#include "TGLabel.h" |
-#endif |
-#ifndef ROOT_TGView |
-#include "TGView.h" |
-#endif |
-#ifndef ROOT_TRootGuiBuilder |
-#include "TRootGuiBuilder.h" |
-#endif |
-#ifndef ROOT_TGTab |
-#include "TGTab.h" |
-#endif |
-#ifndef ROOT_TGListView |
-#include "TGListView.h" |
-#endif |
-#ifndef ROOT_TGSplitter |
-#include "TGSplitter.h" |
-#endif |
-#ifndef ROOT_TGStatusBar |
-#include "TGStatusBar.h" |
-#endif |
-#ifndef ROOT_TGListTree |
-#include "TGListTree.h" |
-#endif |
-#ifndef ROOT_TGToolTip |
-#include "TGToolTip.h" |
-#endif |
-#ifndef ROOT_TGToolBar |
-#include "TGToolBar.h" |
-#endif |
-#ifndef ROOT_TRootEmbeddedCanvas |
-#include "TRootEmbeddedCanvas.h" |
-#endif |
-#ifndef ROOT_TCanvas |
-#include "TCanvas.h" |
-#endif |
-#ifndef ROOT_TGuiBldDragManager |
-#include "TGuiBldDragManager.h" |
-#endif |
- |
-#include "Riostream.h" |
-#include "TApplication.h" |
-#include "TROOT.h" |
-#include "TSystem.h" |
-#include "TGraph.h" |
-#include "TH1F.h" |
-#include "daq.h" |
- |
-TGTextButton *gTextButton[10]; |
-TCanvas *fCanvas; |
-TGMainFrame *fMain; |
-TGTextEntry *gFilename; |
-TGNumberEntry *gPedestal; |
-TGNumberEntry *gCh; |
-TGNumberEntry *gMaxEve; |
-TGNumberEntry *gNeve; |
-TGTextEntry *gTimeDisplay; |
-TGCheckButton *gCheckButton; |
- |
- |
-TRootEmbeddedCanvas *gCanvas; |
-#define MAXCH 32 |
-TH1F* gHisto[MAXCH]; |
-daq * gDaq; |
-#define WINDOW_NAME "ADC CAEN V965" |
-//---------------------------------------------------- |
-int UIRDimming(int state){ |
- switch (state) { |
- case 0: |
- gTextButton[0]->SetEnabled(0); |
- gTextButton[1]->SetEnabled(1); |
- gTextButton[2]->SetEnabled(0); |
- |
- break; |
- |
- case 1: |
- gTextButton[0]->SetEnabled(0); |
- gTextButton[1]->SetEnabled(0); |
- gTextButton[2]->SetEnabled(1); |
- |
- break; |
- |
- case 2: |
- gTextButton[0]->SetEnabled(1); |
- gTextButton[1]->SetEnabled(1); |
- gTextButton[2]->SetEnabled(0); |
- break; |
- |
- default: |
- break; |
- } |
- return 0; |
-} |
- |
-int fDebug; |
-void GetDebug(){ |
- if ( gCheckButton->IsOn() ) fDebug=1; |
- else fDebug=0; |
-} |
- |
-int GetTime(char *x){ |
- int ret; |
- time_t rawtime; |
- static time_t oldtime=-1; |
- struct tm * timeinfo; |
- time ( &rawtime ); |
- ret = (oldtime==rawtime); |
- timeinfo = localtime ( &rawtime ); |
- sprintf(x,"%s",asctime (timeinfo)); |
- int len=strlen(x); |
- if (len) x[len-1]=0; |
- return ret; |
-} |
-void MyTimer(){ |
- char cmd[100]; |
- if (!GetTime(cmd)){ |
- if (gTimeDisplay) gTimeDisplay->SetText(cmd); |
- if (gCanvas){ |
- gCanvas->GetCanvas()->Modified(); |
- gCanvas->GetCanvas()->Update(); |
- } |
- } |
-} |
- |
-//---------------------------------------------------- |
-// thread function |
-int gStop=0; |
-#define BSIZE 10000 |
-unsigned long gBuf[BSIZE]; |
-void Run(){ |
- printf("Start of Run\n" ); |
- |
- // odpremo datoteko za pisanje |
- int counters[10]={0,0,0,0,0, 0,0,0,0,0}; |
- char names[20][20]={"CAENV 1290","CAEN V965","LC2277","LC2277","LC2277"}; |
- |
- char fname[128]; |
- sprintf(fname,"%s.dat",gFilename->GetText()); |
- FILE *fp=fopen(fname,"w"); |
- int neve = (int) gMaxEve->GetNumber(); |
- int hdr[4]={1}; |
- |
- if (gDaq) gDaq->fStop=0; |
- // zajem zeljenega kolicine podatkov |
- for (int n=0;n<neve;n++){ |
- if (!gDaq) break; |
- int nb = gDaq->event(gBuf,BSIZE,counters,1); |
- if (gDaq->fStop) break; |
- // zapis v datoteko |
- hdr[1]=nb+4*sizeof(int); |
- hdr[2]=time(NULL); |
- hdr[3]=n; |
- |
- fwrite(hdr, sizeof(int),4 , fp); |
- if (nb) fwrite(gBuf, 1,nb, fp); |
- // napolni histograme |
- int nint= nb/4; |
- |
- int ii=0; |
- |
- while (ii<nint){ |
- |
- int recid=gBuf[ii++]; |
- int len =gBuf[ii++]; |
- unsigned int *dbuf= (unsigned int *)&gBuf[ii]; |
- if (n%1000==0) printf("%d 0x%03x Len=%d\n",n,recid,len); |
- unsigned short edge; |
- |
- if (recid==0x130){ |
- for (int i=0; i<len; i++) { |
- int dtype=(dbuf[i]>>25)&0x3; |
- if (dtype==0) { |
- int ch=(dbuf[i]>>17)&0xf; |
- if (2*ch<MAXCH) { |
- int rg=(dbuf[i]>>16)&0x1; |
- int adc=dbuf[i]&0xfff; |
- gHisto[2*ch+rg]->Fill(adc); |
- // printf("V965 0x%08x nev=%4d %d. [ch=%2d] range=%d data=%d \n",dbuf[i],n,i,ch,rg,adc); |
- } |
- } |
- } |
- } // if (recid==0x130) |
- ii+=len; |
- } |
- /* |
- // decode |
- |
- int nint=nb/sizeof(int); |
- |
- for (int i=0;i<nint;i++){ |
- unsigned short tdc = gBuf[i]&0xFFFF; |
- unsigned short ch = (gBuf[i] >> 17 ) &0x1F; |
- unsigned short edge = (gBuf[i] >> 16 ) &0x1; |
- if (edge && ch < MAXCH) gHisto[ch]->Fill(tdc); |
- if (fDebug) printf("nev=%4d %d. [ch=%2d] egde=%d data=%d",n,i,ch,edge,tdc); |
- } |
- */ |
- gSystem->ProcessEvents(); |
- MyTimer(); |
- gNeve->SetNumber(n); |
- } |
- fclose(fp); |
- UIRDimming(2); |
- printf("End of MyThread neve=%d\n",neve); |
- |
-} |
- |
- |
-int save2ascii(){ |
- if (!gHisto[0]) return 0; |
- char fname[128]; |
- sprintf(fname,"%s.txt",gFilename->GetText()); |
- FILE *fp= fopen(fname, "w"); |
- fprintf(fp, "%s\n",WINDOW_NAME); |
- char cmd[128]; |
- GetTime(cmd); |
- fprintf(fp, "Shranjeno: %s\n\n", cmd ); |
- fprintf(fp, "Kanal hid=") ; |
- for (int j=0;j<MAXCH;j++) fprintf(fp, "%d\t",j); |
- fprintf(fp, "\n-------------------------------------------------\n"); |
- for (int i=0;i<gHisto[0]->GetNbinsX();i++){ |
- fprintf(fp, "%d\t",i); |
- for (int j=0;j<MAXCH;j++) fprintf(fp, "%d\t",(int) gHisto[j]->GetBinContent(i+1)); |
- fprintf(fp, "\n"); |
- } |
- fclose(fp); |
- printf("Histogram content is dumped to the file %s\n",fname); |
- return 0; |
- } |
- |
-void MyEventHandler(int i){ |
- |
- UIRDimming(i); |
- |
- switch (i) { |
- case 0: // Init |
- gDaq->fPedestal = (int)(gPedestal->GetNumber()); |
- gDaq->init(); |
- break; |
- case 1: // Start |
- Run(); |
- case 2: // Stop |
- gDaq->fStop=1; |
- case 3: // ReDraw |
- gCanvas->GetCanvas()->Modified(); |
- gCanvas->GetCanvas()->Update(); |
- break; |
- case 4: // Clear |
- for (int j=0;j<MAXCH;j++) if (gHisto[j]) gHisto[j]->Reset(); |
- break; |
- case 5: // Save |
- save2ascii(); |
- break; |
- case 6: // Print |
- gCanvas->GetCanvas()->SaveAs("zivljenjski_cas_mionov.pdf"); |
- break; |
- case 7: // exit |
- gApplication->Terminate(0); |
- break; |
- } |
- |
-} |
- |
-int Redraw(long val=0){ |
- unsigned int ch= (unsigned int)(gCh->GetNumber()); |
- if (ch<MAXCH && gHisto[ch]) { |
- gCanvas->GetCanvas()->cd(); |
- gHisto[ch]->Draw(); |
- gCanvas->GetCanvas()->Modified(); |
- gCanvas->GetCanvas()->Update(); |
- } else { |
- if (gCh->GetNumber()>=MAXCH) gCh->SetNumber(MAXCH-1); |
- if (gCh->GetNumber()< 0) gCh->SetNumber(0); |
- } |
- return 0; |
-} |
-//---------------------------------------------------- |
- |
-int gui(){ |
- |
- for (int i=0;i<MAXCH;i++){ |
- char hname[50]; |
- sprintf(hname,"Ch. %d Rg.%d;ADC;N",i/2,i%2); |
- char hn[50]; |
- sprintf(hn,"ch%d",i); |
- gHisto[i] = new TH1F(hn,hname,4096,-0.5,4095.5); |
- } |
- gDaq= new daq(); |
- fMain = new TGMainFrame(0,800,800); |
- TGHorizontalFrame *fH=new TGHorizontalFrame(fMain,800,400); |
- //------------------------------------------------------------ |
- TGLayoutHints *f0= new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2); |
- TGLayoutHints *layout2= new TGLayoutHints(kLHintsLeft | kLHintsTop,20,20,20,20); |
- // gumbi |
- |
- int nbut=8; |
- const char *names[10]={"Init","Start","Stop","Refresh","Clear","Save", "Print" , "Exit"}; |
- for (int i=0;i<nbut;i++){ |
- |
- gTextButton[i]= new TGTextButton(fH, names[i]); |
- gTextButton[i]->SetTextJustify(36); |
- gTextButton[i]->SetMargins(0,0,0,0); |
- gTextButton[i]->SetWrapLength(-1); |
- gTextButton[i]->Resize(50,22); |
- fH->AddFrame(gTextButton[i], layout2); |
- char cmd[50]; |
- sprintf(cmd,"MyEventHandler(=%d)",i); |
- TQObject::Connect(gTextButton[i],"Clicked()",0,0,cmd); |
- } |
- |
- gCheckButton = new TGCheckButton( fH,"Debug"); |
- gCheckButton->Resize(50,22); |
- TQObject::Connect(gCheckButton,"Clicked()", 0, 0 , "GetDebug()"); |
- gCheckButton->SetState(kButtonDown); |
- fH->AddFrame(gCheckButton, f0); |
- |
- fMain->AddFrame(fH , f0); |
- //--------------------------------------------------------- |
- // ura |
- TGLabel *lab1; |
- fH=new TGHorizontalFrame(fMain,800,200); |
- lab1 = new TGLabel( fH ,"Time:"); |
- fH->AddFrame(lab1, f0); |
- gTimeDisplay = new TGTextEntry( fH,""); |
- gTimeDisplay->Resize(200,22); |
- fH->AddFrame(gTimeDisplay, f0); |
- fMain->AddFrame(fH , f0); |
- //--------------------------------------------------------- |
- // inputi |
- fH=new TGHorizontalFrame(fMain,800,200); |
- lab1 = new TGLabel( fH ,"Filename:"); |
- fH->AddFrame(lab1, f0); |
- gFilename = new TGTextEntry( fH,"filename"); |
- gFilename->Resize(200,22); |
- fH->AddFrame(gFilename, f0); |
- fMain->AddFrame(fH , f0); |
- //--------------------------------------------------------- |
- fH=new TGHorizontalFrame(fMain,800,200); |
- lab1 = new TGLabel( fH ,"ADC Pedestal:"); |
- fH->AddFrame(lab1, f0); |
- gPedestal = new TGNumberEntry( fH,100); |
- gPedestal->Resize(100,22); |
- fH->AddFrame(gPedestal, f0); |
- fMain->AddFrame(fH , f0); |
- //--------------------------------------------------------- |
- fH=new TGHorizontalFrame(fMain,800,200); |
- lab1 = new TGLabel( fH ,"N of events to acquire:"); |
- fH->AddFrame(lab1, f0); |
- gMaxEve = new TGNumberEntry( fH,10000); |
- gMaxEve->Resize(100,22); |
- fH->AddFrame(gMaxEve, f0); |
- fMain->AddFrame(fH , f0); |
- //--------------------------------------------------------- |
- fH=new TGHorizontalFrame(fMain,800,200); |
- lab1 = new TGLabel( fH ,"Number of events:"); |
- fH->AddFrame(lab1, f0); |
- gNeve = new TGNumberEntry( fH,0); |
- gNeve->Resize(100,22); |
- fH->AddFrame(gNeve, f0); |
- fMain->AddFrame(fH , f0); |
- //--------------------------------------------------------- |
- // canvas |
- fH=new TGHorizontalFrame(fMain,800,200); |
- gCanvas = new TRootEmbeddedCanvas ("gCanvas",fH,800,400); |
- fH->AddFrame(gCanvas, f0); |
- fMain->AddFrame(fH , f0); |
- //------------------------------------------------------------ |
- fH=new TGHorizontalFrame(fMain,800,200); |
- lab1 = new TGLabel( fH ,"Channel number (0..31):"); |
- fH->AddFrame(lab1, f0); |
- gCh = new TGNumberEntry( fH,0); |
- fH->AddFrame(gCh, f0); |
- TQObject::Connect(gCh,"ValueSet(Long_t)",0,0,"Redraw(Long_t )"); |
- |
- fMain->AddFrame(fH , f0); |
- //------------------------------------------------------------ |
- fMain->SetWindowName(WINDOW_NAME); |
- fMain->MapSubwindows(); |
- fMain->Resize(fMain->GetDefaultSize()); |
- fMain->MapWindow(); |
- Redraw(); |
- GetDebug(); |
- return 0; |
-} |
Index: petdaqfmf/VmUsbStack.h |
=================================================================== |
--- petdaqfmf/VmUsbStack.h (revision 111) |
+++ petdaqfmf/VmUsbStack.h (nonexistent) |
@@ -1,45 +0,0 @@ |
-#ifndef VMUSBSTACK_H |
-#define VMUSBSTACK_H |
-#define CMD_WRITE 0x000 |
-#define CMD_READ 0x100 |
-#define CMD_A24 0x039 |
-#define CMD_A32 0x009 |
-#define CMD_HM 0x80000 |
-#define CMD_HD 0x20000 |
-#define CMD_MRK 0x2000 |
-#define CMD_DLY 0x8000 |
-#define CMD_BLT 0xFF000000 |
- |
-#define CMD_D16 1 |
-#define CMD_D32 0 |
- |
-#include <vector> |
-class VmUsbStack { |
- public: |
- VmUsbStack(); |
- ~VmUsbStack(); |
- std::vector<int> fStack; |
- void Append(int cmd, int marker); |
- void Append(int cmd, int addr, int data); |
- |
- void Marker(int marker); |
- void WriteA32D16(int addr, int data); |
- void ReadA32D16(int addr ); |
- void WriteA32D32(int addr, int data); |
- void ReadA32D32(int addr ); |
- |
- void WriteA24D16(int addr, int data); |
- void ReadA24D16(int addr ); |
- void WriteA24D32(int addr, int data); |
- void ReadA24D32(int addr ); |
- |
- void ConditionalRead(int am ,int d16d32,int addr, int data); |
- void RepeatRead(int addr_modifier,int d16d32, int baseaddr, int n, int increment); |
- void RepeatWrite(int addr_modifier,int d16d32, int baseaddr, int n, int increment, int data); |
- |
- int Get(int maxn, int *stack); |
- void Print(); |
-}; |
- |
- |
-#endif |
Index: petdaqfmf/Dict.h |
=================================================================== |
--- petdaqfmf/Dict.h (revision 111) |
+++ petdaqfmf/Dict.h (nonexistent) |
@@ -1,44 +0,0 @@ |
-/******************************************************************** |
-* Dict.h |
-* CAUTION: DON'T CHANGE THIS FILE. THIS FILE IS AUTOMATICALLY GENERATED |
-* FROM HEADER FILES LISTED IN G__setup_cpp_environmentXXX(). |
-* CHANGE THOSE HEADER FILES AND REGENERATE THIS FILE. |
-********************************************************************/ |
-#ifdef __CINT__ |
-#error Dict.h/C is only for compilation. Abort cint. |
-#endif |
-#include <stddef.h> |
-#include <stdio.h> |
-#include <stdlib.h> |
-#include <math.h> |
-#include <string.h> |
-#define G__ANSIHEADER |
-#define G__DICTIONARY |
-#include "G__ci.h" |
-extern "C" { |
-extern void G__cpp_setup_tagtableDict(); |
-extern void G__cpp_setup_inheritanceDict(); |
-extern void G__cpp_setup_typetableDict(); |
-extern void G__cpp_setup_memvarDict(); |
-extern void G__cpp_setup_globalDict(); |
-extern void G__cpp_setup_memfuncDict(); |
-extern void G__cpp_setup_funcDict(); |
-extern void G__set_cpp_environmentDict(); |
-} |
- |
- |
-#include "TObject.h" |
-#include "TMemberInspector.h" |
-#include "daq.h" |
-#include <algorithm> |
-namespace std { } |
-using namespace std; |
- |
-#ifndef G__MEMFUNCBODY |
-#endif |
- |
-extern G__linked_taginfo G__DictLN_vectorlEintcOallocatorlEintgRsPgR; |
-extern G__linked_taginfo G__DictLN_VmUsbStack; |
-extern G__linked_taginfo G__DictLN_daq; |
- |
-/* STUB derived class for protected member access */ |
Index: petdaqfmf/vme.h |
=================================================================== |
--- petdaqfmf/vme.h (revision 111) |
+++ petdaqfmf/vme.h (nonexistent) |
@@ -1,6 +0,0 @@ |
-#ifndef _VME_H_ |
-#define _VME_H_ |
- |
-#define _VI_FUNC |
-#include "wienvme_dll.h" |
-#endif |
Index: petdaqfmf/Makefile |
=================================================================== |
--- petdaqfmf/Makefile (revision 111) |
+++ petdaqfmf/Makefile (nonexistent) |
@@ -1,78 +0,0 @@ |
- |
-ROOTINC=$(shell root-config --incdir ) |
-ROOTLIB=$(shell root-config --libs ) |
- |
- |
-INC=-I. -I$(ROOTINC) |
- |
- |
-LIBS=$(ROOTLIB) -L./ -lm |
-LIBS1=$(shell root-config --libs --glibs ) |
- |
- |
- |
-SRC = . |
-INC1 = -I. -I../lib -I/usr/include |
-DBG = |
-CFLAGS = $(DBG) $(INC1) -Wall |
- |
- |
-TARGET1 = daq |
- |
-FILES1 = $(SRC)/daq.C |
- |
-VMELIB = libf9vme.a |
- |
-SHLIB = $(VMELIB) -lusb -lz |
- |
-OBJ_FILES = VMEModule.o CAENV965.o libxxusb.o wienvmeusb_dll.o VmUsbStack.o |
- |
-all: vme $(TARGET1) |
- |
-libxxusb.o: libxxusb.cpp libxxusb.h |
- |
- |
- |
-.cpp.o: |
- $(CXX) -c -g $< |
- ar r $(VMELIB) $@ |
- |
-.C.o: |
- $(CXX) -c -g $< |
- ar r $(VMELIB) $@ |
- |
- |
-.cc.o: |
- $(CXX) -c -g $< |
- ar r $(VMELIB) $@ |
- |
-.c.o: |
- $(CXX) -c -g $< |
- ar r $(VMELIB) $@ |
- |
-vme: $(OBJ_FILES) |
- |
-wienvme_dll.o: wienvme_dll.c |
- |
- |
- |
-VMEModule.o: VMEModule.hh VMEModule.cc |
- |
-CAENV965.o: CAENV965.h CAENV965_DEF.h CAENV965.c |
- |
- |
-$(TARGET1): $(FILES1) vme |
- $(CXX) -DMAIN $(FILES1) $(CFLAGS) -o $(TARGET1) $(SHLIB) -lstdc++ |
- |
- |
-libdaq.so: $(FILES1) |
- @echo "Generating dictionary Dict.C..." |
- rootcint -f Dict.C -c $(INC) $(CPPFLAGS) daq.h LinkDef.h |
- $(CXX) -DG__DICTIONARY $(CPPFLAGS) $(INC) -fPIC -g -Wall $(FILES1) Dict.C -L. $(SHLIB) -shared -o libdaq.so |
- |
-clean: |
- rm Dict.C libdaq.so $(TARGET1) |
- |
- |
-tgz: |
- tar czvf vme.tgz Makefile *.c *.h *.C *.cc *.hh |
Index: praktikum/petdaqfmf/CAENV965.c |
=================================================================== |
--- praktikum/petdaqfmf/CAENV965.c (nonexistent) |
+++ praktikum/petdaqfmf/CAENV965.c (revision 112) |
@@ -0,0 +1,107 @@ |
+#include <stdlib.h> |
+#include <stdio.h> |
+#include "CAENV965.h" |
+#include "CAENV965_DEF.h" |
+#include "vme.h" |
+ |
+static unsigned long ModuleAddress[10]; |
+ |
+int _VI_FUNC V965_map (int ModuleNumber, unsigned long ModuleOffset, int print) |
+{ |
+ int i; |
+ unsigned short geo, fw, ah, al; |
+ if (print) { |
+ printf("CAEN V965_map \n"); |
+ } |
+ ModuleAddress[ModuleNumber] = ModuleOffset; |
+ VME_A24D16_R(ModuleAddress[ModuleNumber] + CAENV965_FW, &fw); |
+ geo = 0; |
+ VME_A24D16_W(ModuleAddress[ModuleNumber] + CAENV965_CRN, &geo); |
+ for (i=0;i<32;i++) |
+ VME_A24D16_W(ModuleAddress[ModuleNumber] + CAENV965_THM + 2*i, &geo); |
+ geo = ModuleNumber+1; |
+ VME_A24D16_W(ModuleAddress[ModuleNumber] + CAENV965_GEO, &geo); |
+ geo = 0; |
+ VME_A24D16_R(ModuleAddress[ModuleNumber] + CAENV965_GEO, &geo); |
+ VME_A24D16_R(ModuleAddress[ModuleNumber] + CAENV965_ADH, &ah); |
+ VME_A24D16_R(ModuleAddress[ModuleNumber] + CAENV965_ADL, &al); |
+ if (print) { |
+ printf("CAEN V965 offset = 0x%08x\n", ModuleOffset); |
+ printf(" V965_map firmware = %d.%d\n", (fw>>8)&0xff, fw&0xff); |
+ printf(" V965_map geo = %d\n", geo&0x1f ); |
+ printf(" V965_map addr = 0x%04X0000\n", (ah<<8)|(al&0xff)); |
+ } |
+ |
+ return 0; |
+} |
+ |
+ |
+int _VI_FUNC V965_init (int ModuleNumber, unsigned short ped) |
+{ |
+ unsigned short dum16; |
+ |
+ dum16= 0x80; |
+ VME_A24D16_W(ModuleAddress[ModuleNumber] + CAENV965_BS1, &dum16); |
+ VME_A24D16_W(ModuleAddress[ModuleNumber] + CAENV965_BC1, &dum16); |
+ dum16= ped; |
+ VME_A24D16_W(ModuleAddress[ModuleNumber] + CAENV965_PED, &dum16); |
+ dum16= 0x5000; |
+ VME_A24D16_W(ModuleAddress[ModuleNumber] + CAENV965_BS2, &dum16); |
+ dum16= 0x4; |
+ VME_A24D16_W(ModuleAddress[ModuleNumber] + CAENV965_BS2, &dum16); |
+ VME_A24D16_W(ModuleAddress[ModuleNumber] + CAENV965_BC2, &dum16); |
+ VME_A24D16_W(ModuleAddress[ModuleNumber] + CAENV965_ECR, &dum16); |
+ |
+ printf ( " V965_init Module %d initialized!\n", ModuleNumber ) ; |
+ return 0; |
+} |
+ |
+int _VI_FUNC V965_clear (int ModuleNumber) |
+{ |
+ |
+ unsigned short dum16; |
+ |
+ dum16= 0x4; |
+ VME_A24D16_W(ModuleAddress[ModuleNumber] + CAENV965_BS2, &dum16); |
+ VME_A24D16_W(ModuleAddress[ModuleNumber] + CAENV965_BC2, &dum16); |
+ printf("V965_clear\n"); |
+ return 0; |
+ |
+} |
+ |
+int _VI_FUNC V965_status (int ModuleNumber) |
+{ |
+ unsigned short dum16; |
+ |
+ VME_A24D16_R(ModuleAddress[ModuleNumber] + CAENV965_SR1, &dum16); |
+ //printf("*%d\n",dum16); |
+ return (int)dum16; |
+} |
+ |
+int _VI_FUNC V965_status2 (int ModuleNumber) |
+{ |
+ |
+ unsigned short dum16; |
+ |
+ VME_A24D16_R(ModuleAddress[ModuleNumber] + CAENV965_SR2, &dum16); |
+ |
+ return (int)dum16; |
+} |
+ |
+int _VI_FUNC V965_read (int ModuleNumber, unsigned long whereto[],int len) |
+{ |
+ int status, ndata, i; |
+ |
+ ndata = 0; |
+ |
+ do { |
+ if (ndata>=len) { |
+ printf("ERROR V965_read: Increase storage size: ndata=%d\n",ndata); |
+ break; |
+ } |
+ VME_A24D32_R(ModuleAddress[ModuleNumber] + CAENV965_OB, &whereto[ndata]); |
+ i=(whereto[ndata]>>25)&0x3; |
+ if (i<3) ndata++; |
+ } while (i<2); |
+ return ndata; |
+} |
Index: praktikum/petdaqfmf/libxxusb.cpp |
=================================================================== |
--- praktikum/petdaqfmf/libxxusb.cpp (nonexistent) |
+++ praktikum/petdaqfmf/libxxusb.cpp (revision 112) |
@@ -0,0 +1,1659 @@ |
+ |
+// libxxusb.cpp : Defines the entry point for the DLL application. |
+// |
+ |
+ |
+ |
+#include <string.h> |
+#include <malloc.h> |
+#include "usb.h" |
+#include "libxxusb.h" |
+#include <time.h> |
+#include "stdio.h" |
+ |
+ |
+ |
+// 03/09/06 Release 3.00 changes |
+// 07/28/06 correction CAMAC write for F to be in range 16...23 |
+// 10/09/06 correction CAMAC read for F to be in range <16 OR >23 |
+// 10/16/06 CAMAC DGG corrected |
+// 12/28/07 Open corrected for bug when calling register after opening |
+/* |
+******** xxusb_longstack_execute ************************ |
+ |
+ Executes stack array passed to the function and returns the data read from the VME bus |
+ |
+ Paramters: |
+ hdev: USB device handle returned from an open function |
+ DataBuffer: pointer to the dual use buffer |
+ when calling , DataBuffer contains (unsigned short) stack data, with first word serving |
+ as a placeholder |
+ upon successful return, DataBuffer contains (unsigned short) VME data |
+ lDataLen: The number of bytes to be fetched from VME bus - not less than the actual number |
+ expected, or the function will return -5 code. For stack consisting only of write operations, |
+ lDataLen may be set to 1. |
+ timeout: The time in ms that should be spent tryimg to write data. |
+ |
+ Returns: |
+ When Successful, the number of bytes read from xxusb. |
+ Upon failure, a negative number |
+ |
+ Note: |
+ The function must pass a pointer to an array of unsigned integer stack data, in which the first word |
+ is left empty to serve as a placeholder. |
+ The function is intended for executing Uint32_t stacks, up to 4 MBytes Uint32_t, both "write" and "read" |
+ oriented, such as using multi-block transfer operations. |
+ Structure upon call: |
+ DataBuffer(0) = 0(don't care place holder) |
+ DataBuffer(1) = (unsigned short)StackLength bits 0-15 |
+ DataBuffer(2) = (unsigned short)StackLength bits 16-20 |
+ DataBuffer(3 - StackLength +2) (unsigned short) stack data |
+ StackLength represents the number of words following DataBuffer(1) word, thus the total number |
+ of words is StackLength+2 |
+ Structure upon return: |
+ DataBuffer(0 - (ReturnValue/2-1)) - (unsigned short)array of returned data when ReturnValue>0 |
+*/ |
+ |
+int xxusb_longstack_execute(usb_dev_handle *hDev, void *DataBuffer, int lDataLen, int timeout) |
+{ |
+ int ret; |
+ char *cbuf; |
+ unsigned short *usbuf; |
+ int bufsize; |
+ |
+ cbuf = (char *)DataBuffer; |
+ usbuf = (unsigned short *)DataBuffer; |
+ cbuf[0]=12; |
+ cbuf[1]=0; |
+ bufsize = 2*(usbuf[1]+0x10000*usbuf[2])+4; |
+ ret=usb_bulk_write(hDev, XXUSB_ENDPOINT_OUT, cbuf, bufsize, timeout); |
+ if (ret>0) |
+ ret=usb_bulk_read(hDev, XXUSB_ENDPOINT_IN, cbuf, lDataLen, timeout); |
+ |
+ return ret; |
+} |
+ |
+/* |
+******** xxusb_bulk_read ************************ |
+ |
+ Reads the content of the usbfifo whenever "FIFO full" flag is set, |
+ otherwise times out. |
+ |
+ Paramters: |
+ hdev: USB device handle returned from an open function |
+ DataBuffer: pointer to an array to store data that is read from the VME bus; |
+ the array may be declared as byte, unsigned short, or unsigned Uint32_t |
+ lDatalen: The number of bytes to read from xxusb |
+ timeout: The time in ms that should be spent waiting for data. |
+ |
+ Returns: |
+ When Successful, the number of bytes read from xxusb. |
+ Upon failure, a negative number |
+ |
+ Note: |
+ Depending upon the actual need, the function may be used to return the data in a form |
+ of an array of bytes, unsigned short integers (16 bits), or unsigned Uint32_t integers (32 bits). |
+ The latter option of passing a pointer to an array of unsigned Uint32_t integers is meaningful when |
+ xxusb data buffering option is used (bit 7=128 of the global register) that requires data |
+ 32-bit data alignment. |
+ |
+*/ |
+int xxusb_bulk_read(usb_dev_handle *hDev, void *DataBuffer, int lDataLen, int timeout) |
+{ |
+int ret; |
+char *cbuf; |
+cbuf = (char *)DataBuffer; |
+ ret = usb_bulk_read(hDev, XXUSB_ENDPOINT_IN, cbuf, lDataLen, timeout); |
+ return ret; |
+} |
+ |
+/* |
+******** xxusb_bulk_write ************************ |
+ |
+ Writes the content of an array of bytes, unsigned short integers, or unsigned Uint32_t integers |
+ to the USB port fifo; times out when the USB fifo is full (e.g., when xxusb is busy). |
+ |
+ Paramters: |
+ hdev: USB device handle returned from an open function |
+ DataBuffer: pointer to an array storing the data to be sent; |
+ the array may be declared as byte, unsigned short, or unsigned Uint32_t |
+ lDatalen: The number of bytes to to send to xxusb |
+ timeout: The time in ms that should be spent waiting for data. |
+ |
+ Returns: |
+ When Successful, the number of bytes passed to xxusb. |
+ Upon failure, a negative number |
+ |
+ Note: |
+ Depending upon the actual need, the function may be used to pass to xxusb the data in a form |
+ of an array of bytes, unsigned short integers (16 bits), or unsigned Uint32_t integers (32 bits). |
+*/ |
+int xxusb_bulk_write(usb_dev_handle *hDev, void *DataBuffer, int lDataLen, int timeout) |
+{ |
+int ret; |
+char *cbuf; |
+cbuf = (char *)DataBuffer; |
+ ret = usb_bulk_write(hDev, XXUSB_ENDPOINT_OUT, cbuf, lDataLen, timeout); |
+ return ret; |
+} |
+ |
+/* |
+******** xxusb_usbfifo_read ************************ |
+ |
+ Reads data stored in the xxusb fifo and packs them in an array of Uint32_t integers. |
+ |
+ Paramters: |
+ hdev: USB device handle returned from an open function |
+ DataBuffer: pointer to an array of Uint32_t to store data that is read |
+ the data occupy only the least significant 16 bits of the 32-bit data words |
+ lDatalen: The number of bytes to read from the xxusb |
+ timeout: The time in ms that should be spent waiting for data. |
+ |
+ Returns: |
+ When Successful, the number of bytes read from xxusb. |
+ Upon failure, a negative number |
+ |
+ Note: |
+ The function is not economical as it wastes half of the space required for storing |
+ the data received. Also, it is relatively slow, as it performs extensive data repacking. |
+ It is recommended to use xxusb_bulk_read with a pointer to an array of unsigned short |
+ integers. |
+*/ |
+int xxusb_usbfifo_read(usb_dev_handle *hDev, int *DataBuffer, int lDataLen, int timeout) |
+{ |
+int ret; |
+char *cbuf; |
+unsigned short *usbuf; |
+int i; |
+ |
+cbuf = (char *)DataBuffer; |
+usbuf = (unsigned short *)DataBuffer; |
+ |
+ ret = usb_bulk_read(hDev, XXUSB_ENDPOINT_IN, cbuf, lDataLen, timeout); |
+ if (ret > 0) |
+ for (i=ret/2-1; i >= 0; i=i-1) |
+ { |
+ usbuf[i*2]=usbuf[i]; |
+ usbuf[i*2+1]=0; |
+ } |
+ return ret; |
+} |
+ |
+ |
+//******************************************************// |
+//******************* GENERAL XX_USB *******************// |
+//******************************************************// |
+// The following are functions used for both VM_USB & CC_USB |
+ |
+ |
+/* |
+******** xxusb_register_write ************************ |
+ |
+ Writes Data to the xxusb register selected by RedAddr. For |
+ acceptable values for RegData and RegAddr see the manual |
+ the module you are using. |
+ |
+ Parameters: |
+ hdev: usb device handle returned from open device |
+ RegAddr: The internal address if the xxusb |
+ RegData: The Data to be written to the register |
+ |
+ Returns: |
+ Number of bytes sent to xxusb if successful |
+ 0 if the register is write only |
+ Negative numbers if the call fails |
+*/ |
+short xxusb_register_write(usb_dev_handle *hDev, short RegAddr, Uint32_t RegData) |
+{ |
+ Uint32_t RegD; |
+ char buf[8]={5,0,0,0,0,0,0,0}; |
+ int ret; |
+ int lDataLen; |
+ int timeout; |
+ if ((RegAddr==0) || (RegAddr==12) || (RegAddr==15)) |
+ return 0; |
+ buf[2]=(char)(RegAddr & 15); |
+ buf[4]=(char)(RegData & 255); |
+ |
+ RegD = RegData >> 8; |
+ buf[5]=(char)(RegD & 255); |
+ RegD = RegD >>8; |
+ if (RegAddr==8) |
+ { |
+ buf[6]=(char)(RegD & 255); |
+ lDataLen=8; |
+ } |
+ else |
+ lDataLen=6; |
+ timeout=10; |
+ ret=xxusb_bulk_write(hDev, buf, lDataLen, timeout); |
+ return ret; |
+} |
+ |
+/* |
+******** xxusb_stack_write ************************ |
+ |
+ Writes a stack of VME/CAMAC calls to the VM_USB/CC_USB |
+ to be executed upon trigger. |
+ |
+ Parameters: |
+ hdev: usb device handle returned from an open function |
+ StackAddr: internal register to which the stack should be written |
+ lpStackData: Pointer to an array holding the stack |
+ |
+ Returns: |
+ The number of Bytes written to the xxusb when successful |
+ A negative number upon failure |
+*/ |
+short xxusb_stack_write(usb_dev_handle *hDev, short StackAddr, Uint32_t *intbuf) |
+{ |
+ int timeout; |
+ short ret; |
+ short lDataLen; |
+ char buf[2000]; |
+ short i; |
+ int bufsize; |
+ |
+ buf[0]=(char)((StackAddr & 51) + 4); |
+ buf[1]=0; |
+ lDataLen=(short)(intbuf[0] & 0xFFF); |
+ buf[2]=(char)(lDataLen & 255); |
+ lDataLen = lDataLen >> 8; |
+ buf[3] = (char)(lDataLen & 255); |
+ bufsize=intbuf[0]*2+4; |
+ if (intbuf[0]==0) |
+ return 0; |
+ for (i=1; i <= intbuf[0]; i++) |
+ { |
+ buf[2+2*i] = (char)(intbuf[i] & 255); |
+ buf[3+2*i] = (char)((intbuf[i] >>8) & 255); |
+ } |
+ timeout=50; |
+ ret=usb_bulk_write(hDev, XXUSB_ENDPOINT_OUT, buf, bufsize, timeout); |
+ return ret; |
+} |
+ |
+/* |
+******** xxusb_stack_execute ********************** |
+ |
+ Writes, executes and returns the value of a DAQ stack. |
+ |
+ Parameters: |
+ hdev: USB device handle returned from an open function |
+ intbuf: Pointer to an array holding the values stack. Upon return |
+ Pointer value is the Data returned from the stack. |
+ |
+ Returns: |
+ When successful, the number of Bytes read from xxusb |
+ Upon Failure, a negative number. |
+*/ |
+short xxusb_stack_execute(usb_dev_handle *hDev, Uint32_t *intbuf) |
+{ |
+ int timeout; |
+ short ret; |
+ short lDataLen; |
+ char buf[26700]; |
+ short i; |
+ int bufsize; |
+ int ii = 0; |
+ |
+ buf[0]=12; |
+ buf[1]=0; |
+ lDataLen=(short)(intbuf[0] & 0xFFF); |
+ buf[2]=(char)(lDataLen & 255); |
+ lDataLen = lDataLen >> 8; |
+ buf[3] = (char)(lDataLen & 15); |
+ bufsize=intbuf[0]*2+4; |
+ if (intbuf[0]==0) |
+ return 0; |
+ for (i=1; i <= intbuf[0]; i++) |
+ { |
+ buf[2+2*i] = (char)(intbuf[i] & 255); |
+ buf[3+2*i] = (char)((intbuf[i] >>8) & 255); |
+ } |
+ timeout=2000; |
+ ret=usb_bulk_write(hDev, XXUSB_ENDPOINT_OUT, buf, bufsize, timeout); |
+ if (ret>0) |
+ { |
+ lDataLen=26700; |
+ timeout=6000; |
+ ret=usb_bulk_read(hDev, XXUSB_ENDPOINT_IN, buf, lDataLen, timeout); |
+ if (ret>0) |
+ for (i=0; i < ret; i=i+2) |
+ intbuf[ii++]=(UCHAR)(buf[i]) +(UCHAR)( buf[i+1])*256; |
+ } |
+ return ret; |
+} |
+ |
+/* |
+******** xxusb_stack_read ************************ |
+ |
+ Reads the current DAQ stack stored by xxusb |
+ |
+ Parameters: |
+ hdev: USB device handle returned by an open function |
+ StackAddr: Indicates which stack to read, primary or secondary |
+ intbuf: Pointer to a array where the stack can be stored |
+ |
+ Returns: |
+ Number of bytes read from xxusb when successful |
+ Upon failure, a negative number |
+*/ |
+short xxusb_stack_read(usb_dev_handle *hDev, short StackAddr, Uint32_t *intbuf) |
+{ |
+ int timeout; |
+ short ret; |
+ short lDataLen; |
+ short bufsize; |
+ char buf[1600]; |
+ int i; |
+ |
+ buf[0]=(char)(StackAddr & 51); |
+ buf[1]=0; |
+ lDataLen = 2; |
+ timeout=100; |
+ ret=usb_bulk_write(hDev, XXUSB_ENDPOINT_OUT, buf, lDataLen, timeout); |
+ if (ret < 0) |
+ return ret; |
+ else |
+ bufsize=1600; |
+ int ii=0; |
+ { |
+ ret=usb_bulk_read(hDev, XXUSB_ENDPOINT_IN, buf, bufsize, timeout); |
+ if (ret>0) |
+ for (i=0; i < ret; i=i+2) |
+ intbuf[ii++]=(UCHAR)(buf[i]) + (UCHAR)(buf[i+1])*256; |
+ return ret; |
+ |
+ } |
+} |
+ |
+/* |
+******** xxusb_register_read ************************ |
+ |
+ Reads the current contents of an internal xxusb register |
+ |
+ Parameters: |
+ hdev: USB device handle returned from an open function |
+ RegAddr: The internal address of the register from which to read |
+ RegData: Pointer to a Uint32_t to hold the data. |
+ |
+ Returns: |
+ When Successful, the number of bytes read from xxusb. |
+ Upon failure, a negative number |
+*/ |
+short xxusb_register_read(usb_dev_handle *hDev, short RegAddr, Uint32_t *RegData) |
+{ |
+//Uint32_t RegD; |
+int timeout; |
+ char buf[4]={1,0,0,0}; |
+ int ret; |
+ int lDataLen; |
+ |
+ buf[2]=(char)(RegAddr & 15); |
+ timeout=10; |
+ lDataLen=4; |
+ ret=xxusb_bulk_write(hDev, buf, lDataLen, timeout); |
+ if (ret < 0) |
+ return (short)ret; |
+ else |
+ { |
+ lDataLen=8; |
+ timeout=100; |
+ ret=xxusb_bulk_read(hDev, buf, lDataLen, timeout); |
+ if (ret<0) |
+ return (short)ret; |
+ else |
+ { |
+ *RegData=(UCHAR)(buf[0])+256*(UCHAR)(buf[1]); |
+ if (ret==4) |
+ *RegData=*RegData+0x10000*(UCHAR)(buf[2]); |
+ return (short)ret; |
+ } |
+ } |
+} |
+ |
+/* |
+******** xxusb_reset_toggle ************************ |
+ |
+ Toggles the reset state of the FPGA while the xxusb in programming mode |
+ |
+ Parameters |
+ hdev: US B device handle returned from an open function |
+ |
+ Returns: |
+ Upon failure, a negative number |
+*/ |
+short xxusb_reset_toggle(usb_dev_handle *hDev) |
+{ |
+ short ret; |
+ char buf[2] = {(char)255,(char)255}; |
+ int lDataLen=2; |
+ int timeout=1000; |
+ ret = usb_bulk_write(hDev, XXUSB_ENDPOINT_OUT, buf,lDataLen, timeout); |
+ return (short)ret; |
+} |
+ |
+/* |
+******** xxusb_devices_find ************************ |
+ |
+ Determines the number and parameters of all xxusb devices attched to |
+ the computer. |
+ |
+ Parameters: |
+ xxdev: pointer to an array on which the device parameters are stored |
+ |
+ Returns: |
+ Upon success, returns the number of devices found |
+ Upon Failure returns a negative number |
+*/ |
+short xxusb_devices_find(xxusb_device_type *xxdev) |
+{ |
+ short DevFound = 0; |
+ usb_dev_handle *udev; |
+ struct usb_bus *bus; |
+ struct usb_device *dev; |
+struct usb_bus *usb_busses; |
+ char string[256]; |
+ short ret; |
+ usb_init(); |
+ usb_find_busses(); |
+ usb_busses=usb_get_busses(); |
+ usb_find_devices(); |
+ for (bus=usb_busses; bus; bus = bus->next) |
+ { |
+ for (dev = bus->devices; dev; dev= dev->next) |
+ { |
+ if (dev->descriptor.idVendor==XXUSB_WIENER_VENDOR_ID) |
+ { |
+ udev = usb_open(dev); |
+ if (udev) |
+ { |
+ ret = usb_get_string_simple(udev, dev->descriptor.iSerialNumber, string, sizeof(string)); |
+ if (ret >0 ) |
+ { |
+ xxdev[DevFound].usbdev=dev; |
+ strcpy(xxdev[DevFound].SerialString, string); |
+ DevFound++; |
+ } |
+ usb_close(udev); |
+ } |
+ else return -1; |
+ } |
+ } |
+ } |
+ return DevFound; |
+} |
+ |
+/* |
+******** xxusb_device_close ************************ |
+ |
+ Closes an xxusb device |
+ |
+ Parameters: |
+ hdev: USB device handle returned from an open function |
+ |
+ Returns: 1 |
+*/ |
+short xxusb_device_close(usb_dev_handle *hDev) |
+{ |
+ short ret; |
+ ret=usb_release_interface(hDev,0); |
+ usb_close(hDev); |
+ return 1; |
+} |
+ |
+/* |
+******** xxusb_device_open ************************ |
+ |
+ Opens an xxusb device found by xxusb_device_find |
+ |
+ Parameters: |
+ dev: a usb device |
+ |
+ Returns: |
+ A USB device handle |
+*/ |
+usb_dev_handle* xxusb_device_open(struct usb_device *dev) |
+{ |
+ short ret; |
+ Uint32_t val; |
+ int count =0; |
+ usb_dev_handle *udev; |
+ udev = usb_open(dev); |
+ ret = usb_set_configuration(udev,1); |
+ ret = usb_claim_interface(udev,0); |
+// RESET USB (added 10/16/06 Andreas Ruben) |
+ ret=xxusb_register_write(udev, 10, 0x04); |
+// Loop to find known state (added 12/28/07 TH / AR) |
+ ret =-1; |
+ while ((ret <0) && (count <10)) |
+ { |
+ xxusb_register_read(udev, 0, &val); |
+ count++; |
+ } |
+ |
+ return udev; |
+} |
+ |
+/* |
+******** xxusb_flash_program ************************ |
+ |
+ --Untested and therefore uncommented-- |
+*/ |
+short xxusb_flash_program(usb_dev_handle *hDev, char *config, short nsect) |
+{ |
+ int i=0; |
+ int k=0; |
+ short ret=0; |
+ time_t t1,t2; |
+ |
+ char *pconfig; |
+ char *pbuf; |
+ pconfig=config; |
+ char buf[518] ={(char)0xAA,(char)0xAA,(char)0x55,(char)0x55,(char)0xA0,(char)0xA0}; |
+ while (*pconfig++ != -1); |
+ for (i=0; i<nsect; i++) |
+ { |
+ pbuf=buf+6; |
+ for (k=0; k<256; k++) |
+ { |
+ *(pbuf++)=*(pconfig); |
+ *(pbuf++)=*(pconfig++); |
+ } |
+ ret = usb_bulk_write(hDev, XXUSB_ENDPOINT_OUT, buf, 518, 2000); |
+ if (ret<0) |
+ return ret; |
+ t1=clock()+(time_t)(0.03*CLOCKS_PER_SEC); |
+ while (t1>clock()); |
+ t2=clock(); |
+ } |
+ return ret; |
+} |
+ |
+/* |
+******** xxusb_flashblock_program ************************ |
+ |
+ --Untested and therefore uncommented-- |
+*/ |
+short xxusb_flashblock_program(usb_dev_handle *hDev, UCHAR *config) |
+{ |
+ int k=0; |
+ short ret=0; |
+ |
+ UCHAR *pconfig; |
+ char *pbuf; |
+ pconfig=config; |
+ char buf[518] ={(char)0xAA,(char)0xAA,(char)0x55,(char)0x55,(char)0xA0,(char)0xA0}; |
+ pbuf=buf+6; |
+ for (k=0; k<256; k++) |
+ { |
+ *(pbuf++)=(UCHAR)(*(pconfig)); |
+ *(pbuf++)=(UCHAR)(*(pconfig++)); |
+ } |
+ ret = usb_bulk_write(hDev, XXUSB_ENDPOINT_OUT, buf, 518, 2000); |
+ return ret; |
+} |
+ |
+/* |
+******** xxusb_serial_open ************************ |
+ |
+ Opens a xxusb device whose serial number is given |
+ |
+ Parameters: |
+ SerialString: a char string that gives the serial number of |
+ the device you wish to open. It takes the form: |
+ VM0009 - for a vm_usb with serial number 9 or |
+ CC0009 - for a cc_usb with serial number 9 |
+ |
+ Returns: |
+ A USB device handle |
+*/ |
+usb_dev_handle* xxusb_serial_open(char *SerialString) |
+{ |
+ short DevFound = 0; |
+ usb_dev_handle *udev = NULL; |
+ struct usb_bus *bus; |
+ struct usb_device *dev; |
+struct usb_bus *usb_busses; |
+char string[20]; |
+ short ret; |
+ //usb_set_debug(4); |
+ usb_init(); |
+ usb_find_busses(); |
+ usb_busses=usb_get_busses(); |
+ usb_find_devices(); |
+ for (bus=usb_busses; bus; bus = bus->next) |
+ { |
+ for (dev = bus->devices; dev; dev= dev->next) |
+ { |
+ if (dev->descriptor.idVendor==XXUSB_WIENER_VENDOR_ID) |
+ { |
+ printf("id %04x\n",dev->descriptor.idVendor); |
+ udev = xxusb_device_open(dev); |
+ if (udev) |
+ { |
+ ret = usb_get_string_simple(udev, dev->descriptor.iSerialNumber, string, sizeof(string)); |
+ printf("iSerial %04x string %s\n",dev->descriptor.iSerialNumber,string); |
+ if (ret >0 ) |
+ { |
+ printf(" Device with %s\n",SerialString); |
+ |
+ if (strcmp(string,SerialString)==0){ |
+ printf(" Device with %s found\n",SerialString); |
+ return udev; |
+ } |
+ } else { |
+ printf(" Device returned %d\n",ret); |
+ } |
+ usb_close(udev); |
+ } |
+ } |
+ } |
+ } |
+ udev = NULL; |
+ return udev; |
+} |
+ |
+ |
+//******************************************************// |
+//****************** EZ_VME Functions ******************// |
+//******************************************************// |
+// The following are functions used to perform simple |
+// VME Functions with the VM_USB |
+ |
+/* |
+******** VME_write_32 ************************ |
+ |
+ Writes a 32 bit data word to the VME bus |
+ |
+ Parameters: |
+ hdev: USB devcie handle returned from an open function |
+ Address_Modifier: VME address modifier for the VME call |
+ VME_Address: Address to write the data to |
+ Data: 32 bit data word to be written to VME_Address |
+ |
+ Returns: |
+ Number of bytes read from xxusb when successful |
+ Upon failure, a negative number |
+*/ |
+short VME_write_32(usb_dev_handle *hdev, short Address_Modifier, Uint32_t VME_Address, Uint32_t Data) |
+{ |
+ Uint32_t intbuf[1000]; |
+ short ret; |
+ intbuf[0]=7; |
+ intbuf[1]=0; |
+ intbuf[2]=Address_Modifier; |
+ intbuf[3]=0; |
+ intbuf[4]=(VME_Address & 0xffff); |
+ intbuf[5]=((VME_Address >>16) & 0xffff); |
+ intbuf[6]=(Data & 0xffff); |
+ intbuf[7]=((Data >> 16) & 0xffff); |
+ ret = xxusb_stack_execute(hdev, intbuf); |
+ return ret; |
+} |
+ |
+/* |
+******** VME_read_32 ************************ |
+ |
+ |
+ Reads a 32 bit data word from a VME address |
+ |
+ Parameters: |
+ hdev: USB devcie handle returned from an open function |
+ Address_Modifier: VME address modifier for the VME call |
+ VME_Address: Address to read the data from |
+ Data: 32 bit data word read from VME_Address |
+ |
+ Returns: |
+ Number of bytes read from xxusb when successful |
+ Upon failure, a negative number |
+*/ |
+short VME_read_32(usb_dev_handle *hdev, short Address_Modifier, Uint32_t VME_Address, Uint32_t *Data) |
+{ |
+ Uint32_t intbuf[1000]; |
+ short ret; |
+ intbuf[0]=5; |
+ intbuf[1]=0; |
+ intbuf[2]=Address_Modifier +0x100; |
+ intbuf[3]=0; |
+ intbuf[4]=(VME_Address & 0xffff); |
+ intbuf[5]=((VME_Address >>16) & 0xffff); |
+ ret = xxusb_stack_execute(hdev, intbuf); |
+ *Data=intbuf[0] + (intbuf[1] * 0x10000); |
+ return ret; |
+} |
+ |
+/* |
+******** VME_write_16 ************************ |
+ |
+ Writes a 16 bit data word to the VME bus |
+ |
+ Parameters: |
+ hdev: USB devcie handle returned from an open function |
+ Address_Modifier: VME address modifier for the VME call |
+ VME_Address: Address to write the data to |
+ Data: word to be written to VME_Address |
+ |
+ Returns: |
+ Number of bytes read from xxusb when successful |
+ Upon failure, a negative number |
+*/ |
+short VME_write_16(usb_dev_handle *hdev, short Address_Modifier, Uint32_t VME_Address, Uint32_t Data) |
+{ |
+ Uint32_t intbuf[1000]; |
+ short ret; |
+ intbuf[0]=7; |
+ intbuf[1]=0; |
+ intbuf[2]=Address_Modifier; |
+ intbuf[3]=0; |
+ intbuf[4]=(VME_Address & 0xffff)+ 0x01; |
+ intbuf[5]=((VME_Address >>16) & 0xffff); |
+ intbuf[6]=(Data & 0xffff); |
+ intbuf[7]=0; |
+ ret = xxusb_stack_execute(hdev, intbuf); |
+ return ret; |
+} |
+ |
+/* |
+******** VME_read_16 ************************ |
+ |
+ Reads a 16 bit data word from a VME address |
+ |
+ Parameters: |
+ hdev: USB devcie handle returned from an open function |
+ Address_Modifier: VME address modifier for the VME call |
+ VME_Address: Address to read the data from |
+ Data: word read from VME_Address |
+ |
+ Returns: |
+ Number of bytes read from xxusb when successful |
+ Upon failure, a negative number |
+*/ |
+short VME_read_16(usb_dev_handle *hdev,short Address_Modifier, Uint32_t VME_Address, Uint32_t *Data) |
+{ |
+ Uint32_t intbuf[1000]; |
+ short ret; |
+ intbuf[0]=5; |
+ intbuf[1]=0; |
+ intbuf[2]=Address_Modifier +0x100; |
+ intbuf[3]=0; |
+ intbuf[4]=(VME_Address & 0xffff)+ 0x01; |
+ intbuf[5]=((VME_Address >>16) & 0xffff); |
+ ret = xxusb_stack_execute(hdev, intbuf); |
+ *Data=intbuf[0]; |
+ return ret; |
+} |
+ |
+/* |
+******** VME_BLT_read_32 ************************ |
+ |
+ Performs block transfer of 32 bit words from a VME address |
+ |
+ Parameters: |
+ hdev: USB devcie handle returned from an open function |
+ Address_Modifier: VME address modifier for the VME call |
+ count: number of data words to read |
+ VME_Address: Address to read the data from |
+ Data: pointer to an array to hold the data words |
+ |
+ Returns: |
+ Number of bytes read from xxusb when successful |
+ Upon failure, a negative number |
+*/ |
+short VME_BLT_read_32(usb_dev_handle *hdev, short Adress_Modifier, int count, Uint32_t VME_Address, Uint32_t Data[]) |
+{ |
+ Uint32_t intbuf[1000]; |
+ short ret; |
+ int i=0; |
+ if (count > 255) return -1; |
+ intbuf[0]=5; |
+ intbuf[1]=0; |
+ intbuf[2]=Adress_Modifier +0x100; |
+ intbuf[3]=(count << 8); |
+ intbuf[4]=(VME_Address & 0xffff); |
+ intbuf[5]=((VME_Address >>16) & 0xffff); |
+ ret = xxusb_stack_execute(hdev, intbuf); |
+ int j=0; |
+ for (i=0;i<(2*count);i=i+2) |
+ { |
+ Data[j]=intbuf[i] + (intbuf[i+1] * 0x10000); |
+ j++; |
+ } |
+ return ret; |
+} |
+ |
+//******************************************************// |
+//****************** VM_USB Registers ******************// |
+//******************************************************// |
+// The following are functions used to set the registers |
+// in the VM_USB |
+ |
+/* |
+******** VME_register_write ************************ |
+ |
+ Writes to the vmusb registers that are accessible through |
+ VME style calls |
+ |
+ Parameters: |
+ hdev: USB devcie handle returned from an open function |
+ VME_Address: The VME Address of the internal register |
+ Data: Data to be written to VME_Address |
+ |
+ Returns: |
+ Number of bytes read from xxusb when successful |
+ Upon failure, a negative number |
+*/ |
+short VME_register_write(usb_dev_handle *hdev, Uint32_t VME_Address, Uint32_t Data) |
+{ |
+ Uint32_t intbuf[1000]; |
+ short ret; |
+ |
+ intbuf[0]=7; |
+ intbuf[1]=0; |
+ intbuf[2]=0x1000; |
+ intbuf[3]=0; |
+ intbuf[4]=(VME_Address & 0xffff); |
+ intbuf[5]=((VME_Address >>16) & 0xffff); |
+ intbuf[6]=(Data & 0xffff); |
+ intbuf[7]=((Data >> 16) & 0xffff); |
+ ret = xxusb_stack_execute(hdev, intbuf); |
+ return ret; |
+} |
+ |
+/* |
+******** VME_register_read ************************ |
+ |
+ Reads from the vmusb registers that are accessible trough VME style calls |
+ |
+ Parameters: |
+ hdev: USB devcie handle returned from an open function |
+ VME_Address: The VME Address of the internal register |
+ Data: Data read from VME_Address |
+ |
+ Returns: |
+ Number of bytes read from xxusb when successful |
+ Upon failure, a negative number |
+*/ |
+short VME_register_read(usb_dev_handle *hdev, Uint32_t VME_Address, Uint32_t *Data) |
+{ |
+ Uint32_t intbuf[1000]; |
+ short ret; |
+ |
+ intbuf[0]=5; |
+ intbuf[1]=0; |
+ intbuf[2]=0x1100; |
+ intbuf[3]=0; |
+ intbuf[4]=(VME_Address & 0xffff); |
+ intbuf[5]=((VME_Address >>16) & 0xffff); |
+ ret = xxusb_stack_execute(hdev, intbuf); |
+ *Data=intbuf[0] + (intbuf[1] * 0x10000); |
+ return ret; |
+} |
+ |
+/* |
+******** VME_LED_settings ************************ |
+ |
+ Sets the vmusb LED's |
+ |
+ Parameters: |
+ hdev: USB devcie handle returned from an open function |
+ LED: The number which corresponds to an LED values are: |
+ 0 - for Top YELLOW LED |
+ 1 - for RED LED |
+ 2 - for GREEN LED |
+ 3 - for Bottom YELLOW LED |
+ code: The LED aource selector code, valid values for each LED |
+ are listed in the manual |
+ invert: to invert the LED lighting |
+ latch: sets LED latch bit |
+ |
+ Returns: |
+ Number of bytes read from xxusb when successful |
+ Upon failure, a negative number |
+*/ |
+short VME_LED_settings(usb_dev_handle *hdev, int LED, int code, int invert, int latch) |
+{ |
+ short ret; |
+// Uint32_t internal; |
+ Uint32_t Data; |
+ |
+ if( (LED <0) ||(LED > 3) || (code < 0) || (code > 7)) return -1; |
+ |
+ VME_register_read(hdev,0xc,&Data); |
+ if(LED == 0) |
+ { |
+ Data = Data & 0xFFFFFF00; |
+ Data = Data | code; |
+ if (invert == 1 && latch == 1) Data = Data | 0x18; |
+ if (invert == 1 && latch == 0) Data = Data | 0x08; |
+ if (invert == 0 && latch == 1) Data = Data | 0x10; |
+ } |
+ if(LED == 1) |
+ { |
+ Data = Data & 0xFFFF00FF; |
+ Data = Data | (code * 0x0100); |
+ if (invert == 1 && latch == 1) Data = Data | 0x1800; |
+ if (invert == 1 && latch == 0) Data = Data | 0x0800; |
+ if (invert == 0 && latch == 1) Data = Data | 0x1000; |
+ } |
+ if(LED == 2) |
+ { |
+ Data = Data & 0xFF00FFFF; |
+ Data = Data | (code * 0x10000); |
+ if (invert == 1 && latch == 1) Data = Data | 0x180000; |
+ if (invert == 1 && latch == 0) Data = Data | 0x080000; |
+ if (invert == 0 && latch == 1) Data = Data | 0x100000; |
+ } |
+ if(LED == 3) |
+ { |
+ Data = Data & 0x00FFFFFF; |
+ Data = Data | (code * 0x10000); |
+ if (invert == 1 && latch == 1) Data = Data | 0x18000000; |
+ if (invert == 1 && latch == 0) Data = Data | 0x08000000; |
+ if (invert == 0 && latch == 1) Data = Data | 0x10000000; |
+ } |
+ ret = VME_register_write(hdev, 0xc, Data); |
+ return ret; |
+} |
+ |
+/* |
+******** VME_DGG ************************ |
+ |
+ Sets the parameters for Gate & Delay channel A of vmusb |
+ |
+ Parameters: |
+ hdev: USB devcie handle returned from an open function |
+ channel: Which DGG channel to use Valid Values are: |
+ 0 - For DGG A |
+ 1 - For DGG B |
+ trigger: Determines what triggers the start of the DGG Valid values are: |
+ 0 - Channel disabled |
+ 1 - NIM input 1 |
+ 2 - NIM input 2 |
+ 3 - Event Trigger |
+ 4 - End of Event |
+ 5 - USB Trigger |
+ 6 - Pulser |
+ output: Determines which NIM output to use for the channel, Vaild values are: |
+ 0 - for NIM O1 |
+ 1 - for NIM O2 |
+ delay: 32 bit word consisting of |
+ lower 16 bits: Delay_fine in steps of 12.5ns between trigger and start of gate |
+ upper 16 bits: Delay_coarse in steps of 81.7us between trigger and start of gate |
+ gate: the time the gate should stay open in steps of 12.5ns |
+ invert: is 1 if you wish to invert the DGG channel output |
+ latch: is 1 if you wish to run the DGG channel latched |
+ |
+ Returns: |
+ Returns 1 when successful |
+ Upon failure, a negative number |
+*/ |
+short VME_DGG(usb_dev_handle *hdev, unsigned short channel, unsigned short trigger, unsigned short output, |
+ Uint32_t delay, unsigned short gate, unsigned short invert, unsigned short latch) |
+{ |
+ Uint32_t Data, DGData, Delay_ext; |
+ Uint32_t internal; |
+ short ret; |
+ |
+ |
+ ret = VME_register_read(hdev, 0x10, &Data); |
+ // check and correct values |
+ if(ret<=0) return -1; |
+ |
+ if(channel >1) channel =1; |
+ if(invert >1) invert =1; |
+ if(latch >1) latch =1; |
+ if(output >1) output =1; |
+ if(trigger >6) trigger =0; |
+ |
+ // define Delay and Gate data |
+ DGData = gate * 0x10000; |
+ DGData += (unsigned short) delay; |
+ |
+ // Set channel, output, invert, latch |
+ if (output == 0) |
+ { |
+ Data = Data & 0xFFFFFF00; |
+ Data += 0x04 + channel +0x08*invert + 0x10*latch; |
+ } |
+ if (output == 1) |
+ { |
+ Data = Data & 0xFFFF00FF; |
+ Data += (0x04 + channel +0x08*invert + 0x10*latch)*0x100; |
+ } |
+ |
+ // Set trigger, delay, gate |
+ |
+ if(channel ==0) // CHANNEL DGG_A |
+ { |
+ internal = (trigger * 0x1000000) ; |
+ Data= Data & 0xF0FFFFFF; |
+ Data += internal; |
+ ret = VME_register_write(hdev,0x10,Data); |
+ if(ret<=0) return -1; |
+ ret=VME_register_write(hdev,0x14,DGData); |
+ if(ret<=0) return -1; |
+ // Set coarse delay in DGG_Extended register |
+ ret = VME_register_read(hdev,0x38,&Data); |
+ Delay_ext= (Data & 0xffff0000); |
+ Delay_ext+= ((delay/0x10000) & 0xffff); |
+ ret = VME_register_write(hdev,0x38,Delay_ext); |
+ } |
+ if( channel ==1) // CHANNEL DGG_B |
+ { |
+ internal = (trigger * 0x10000000) ; |
+ Data= Data & 0x0FFFFFFF; |
+ Data += internal; |
+ ret = VME_register_write(hdev,0x10,Data); |
+ if(ret<=0) return -1; |
+ ret=VME_register_write(hdev,0x18,DGData); |
+ if(ret<=0) return -1; |
+ // Set coarse delay in DGG_Extended register |
+ ret = VME_register_read(hdev,0x38,&Data); |
+ Delay_ext= (Data & 0x0000ffff); |
+ Delay_ext+= (delay & 0xffff0000); |
+ ret = VME_register_write(hdev,0x38,Delay_ext); |
+ } |
+ return 1; |
+ |
+} |
+ |
+/* |
+******** VME_Output_settings ************************ |
+ |
+ Sets the vmusb NIM output register |
+ |
+ Parameters: |
+ hdev: USB devcie handle returned from an open function |
+ Channel: The number which corresponds to an output: |
+ 1 - for Output 1 |
+ 2 - for Output 2 |
+ code: The Output selector code, valid values |
+ are listed in the manual |
+ invert: to invert the output |
+ latch: sets latch bit |
+ |
+ Returns: |
+ Number of bytes read from xxusb when successful |
+ Upon failure, a negative number |
+*/ |
+short VME_Output_settings(usb_dev_handle *hdev, int Channel, int code, int invert, int latch) |
+{ |
+ |
+ short ret; |
+// Uint32_t internal; |
+ Uint32_t Data; |
+ |
+ if( (Channel <1) ||(Channel > 2) || (code < 0) || (code > 7)) return -1; |
+ VME_register_read(hdev,0x10,&Data); |
+ if(Channel == 1) |
+ { |
+ Data = Data & 0xFFFF00; |
+ Data = Data | code; |
+ if (invert == 1 && latch == 1) Data = Data | 0x18; |
+ if (invert == 1 && latch == 0) Data = Data | 0x08; |
+ if (invert == 0 && latch == 1) Data = Data | 0x10; |
+ } |
+ if(Channel == 2) |
+ { |
+ Data = Data & 0xFF00FF; |
+ Data = Data | (code * 0x0100); |
+ if (invert == 1 && latch == 1) Data = Data | 0x1800; |
+ if (invert == 1 && latch == 0) Data = Data | 0x0800; |
+ if (invert == 0 && latch == 1) Data = Data | 0x1000; |
+ } |
+ ret = VME_register_write(hdev, 0x10, Data); |
+ return ret; |
+} |
+ |
+ |
+//******************************************************// |
+//****************** CC_USB Registers ******************// |
+//******************************************************// |
+// The following are functions used to set the registers |
+// in the CAMAC_USB |
+ |
+/* |
+******** CAMAC_register_write ***************** |
+ |
+ Performs a CAMAC write to CC_USB register |
+ |
+ Parameters: |
+ hdev: USB device handle returned from an open function |
+ A: CAMAC Subaddress |
+ F: CAMAC Function |
+ Data: data to be written |
+ |
+ Returns: |
+ Number of bytes written to xxusb when successful |
+ Upon failure, a negative number |
+*/ |
+short CAMAC_register_write(usb_dev_handle *hdev, int A, Uint32_t Data) |
+{ |
+ int F = 16; |
+ int N = 25; |
+ Uint32_t intbuf[4]; |
+ int ret; |
+ |
+ intbuf[0]=1; |
+ intbuf[1]=(Uint32_t)(F+A*32+N*512 + 0x4000); |
+ intbuf[0]=3; |
+ intbuf[2]=(Data & 0xffff); |
+ intbuf[3]=((Data >>16) & 0xffff); |
+ ret = xxusb_stack_execute(hdev, intbuf); |
+ |
+ return ret; |
+} |
+ |
+/* |
+******** CAMAC_register_read ************************ |
+ |
+ Performs a CAMAC read from CC_USB register |
+ |
+ Parameters: |
+ hdev: USB device handle returned from an open function |
+ N: CAMAC Station Number |
+ A: CAMAC Subaddress |
+ F: CAMAC Function |
+ Q: The Q response from the CAMAC dataway |
+ X: The comment accepted response from CAMAC dataway |
+ |
+ Returns: |
+ Number of bytes read from xxusb when successful |
+ Upon failure, a negative number |
+*/ |
+short CAMAC_register_read(usb_dev_handle *hdev, int A, Uint32_t *Data) |
+{ |
+ int F = 0; |
+ int N = 25; |
+ Uint32_t intbuf[4]; |
+ int ret; |
+ |
+ intbuf[0]=1; |
+ intbuf[1]=(Uint32_t)(F+A*32+N*512 + 0x4000); |
+ ret = xxusb_stack_execute(hdev, intbuf); |
+ *Data=intbuf[0] + (intbuf[1] * 0x10000); |
+ |
+ return ret; |
+} |
+ |
+/* |
+******** CAMAC_DGG ************************ |
+ |
+ Sets the parameters for Gate & Delay channel A of CC_USB |
+ |
+ Parameters: |
+ hdev: USB devcie handle returned from an open function |
+ channel: Which DGG channel to use Valid Values are: |
+ 0 - For DGG A |
+ 1 - For DGG B |
+ trigger: Determines what triggers the start of the DGG Valid values are: |
+ 0 - Channel disabled |
+ 1 - NIM input 1 |
+ 2 - NIM input 2 |
+ 3 - NIM input 2 |
+ 4 - Event Trigger |
+ 5 - End of Event |
+ 6 - USB Trigger |
+ 7 - Pulser |
+ output: Determines which NIM output to use for the channel, Vaild values are: |
+ 1 - for NIM O1 |
+ 2 - for NIM O2 |
+ 3 - for NIM O3 |
+ delay: Delay in steps of 12.5ns between trigger and start of gate |
+ gate: the time the gate should stay open in steps of 12.5ns |
+ invert: is 1 if you wish to invert the DGG channel output |
+ latch: is 1 if you wish to run the DGG channel latched |
+ |
+ Returns: |
+ Returns 1 when successful |
+ Upon failure, a negative number |
+*/ |
+short CAMAC_DGG(usb_dev_handle *hdev, short channel, short trigger, short output, |
+ int delay, int gate, short invert, short latch) |
+ |
+ |
+ |
+{ |
+// short channel_ID; |
+ Uint32_t Data; |
+ Uint32_t internal; |
+ short ret; |
+ Uint32_t Delay_ext; |
+ |
+ ret = CAMAC_register_read(hdev,5,&Data); |
+ //Set trigger |
+ if((output < 1 ) || (output >3) || (channel < 0 ) || (channel > 1)) |
+ return -1; |
+ if(output ==1) |
+ { |
+ if(channel ==0) |
+ { |
+ internal = 0x03; |
+ } else { |
+ internal = 0x04; |
+ } |
+ } |
+ if(output ==2) |
+ { |
+ if(channel ==0) |
+ { |
+ internal = 0x04; |
+ } else { |
+ internal = 0x05; |
+ } |
+ } |
+ if(output ==3) |
+ { |
+ if(channel ==0) |
+ { |
+ internal = 0x05; |
+ } else { |
+ internal = 0x06; |
+ } |
+ } |
+ |
+ |
+// Set invert bit |
+ if(invert ==1) |
+ internal = internal | 0x10; |
+ else |
+ internal = internal & 0x0F; |
+ // Set Latch Bit |
+ if(latch==1) |
+ internal = internal | 0x20; |
+ else |
+ internal = internal & 0x1F; |
+// Add new data to old |
+ if(output == 1) |
+ { |
+ Data = Data & 0xFFFF00; |
+ Data = Data | internal; |
+ } |
+ if(output == 2) |
+ { |
+ Data = Data & 0xFF00FF; |
+ Data = Data |(internal * 0x100); |
+ } |
+ if(output == 3) |
+ { |
+ Data = Data & 0x00FFFF; |
+ Data = Data | (internal * 0x10000) ; |
+ } |
+ CAMAC_register_write(hdev, 5, Data); |
+ ret = CAMAC_register_read(hdev,6,&Data); |
+//Set Trigger |
+ if(trigger <0 || trigger > 7) |
+ return -1; |
+ if(channel ==0) |
+ { |
+ Data = Data & 0xFF00FFFF; |
+ internal = trigger * 0x10000; |
+ Data = Data | internal; |
+ } else { |
+ Data = Data & 0x00FFFFFF; |
+ internal = trigger * 0x1000000; |
+ Data = Data | internal; |
+ } |
+ ret = CAMAC_register_write(hdev, 6, Data); |
+ if(channel == 0) |
+ { |
+// Write Delay and Gate info |
+ ret = CAMAC_register_read(hdev,13,&Data); |
+ Delay_ext= (Data & 0xffff0000); |
+ Delay_ext+= ((delay/0x10000) & 0xffff); |
+ internal = gate * 0x10000; |
+ Data = internal + (delay & 0xffff); |
+ ret=CAMAC_register_write(hdev,7,Data); |
+// Set coarse delay in DGG_Extended register |
+ ret=CAMAC_register_write(hdev,13,Delay_ext); |
+ } |
+ else |
+ { |
+ ret=CAMAC_register_write(hdev,8,Data); |
+ ret = CAMAC_register_read(hdev,13,&Data); |
+ Delay_ext= (Data & 0x0000ffff); |
+ Delay_ext+= (delay & 0xffff0000); |
+ internal = gate * 0x10000; |
+ Data = internal + (delay & 0xffff); |
+// Set coarse delay in DGG_Extended register |
+ ret=CAMAC_register_write(hdev,13,Delay_ext); |
+ } |
+ return 1; |
+} |
+ |
+/* |
+******** CAMAC_LED_settings ************************ |
+ |
+ Writes a data word to the vmusb LED register |
+ |
+ Parameters: |
+ hdev: USB devcie handle returned from an open function |
+ LED: The number which corresponds to an LED values are: |
+ 1 - for RED LED |
+ 2 - for GREEN LED |
+ 3 - for Yellow LED |
+ code: The LED aource selector code, valid values for each LED |
+ are listed in the manual |
+ invert: to invert the LED lighting |
+ latch: sets LED latch bit |
+ |
+ Returns: |
+ Number of bytes read from xxusb when successful |
+ Upon failure, a negative number |
+*/ |
+short CAMAC_LED_settings(usb_dev_handle *hdev, int LED, int code, int invert, int latch) |
+{ |
+ |
+ short ret; |
+// Uint32_t internal; |
+ Uint32_t Data; |
+ |
+ if( (LED <1) ||(LED > 3) || (code < 0) || (code > 7)) |
+ return -1; |
+ |
+ CAMAC_register_read(hdev,4,&Data); |
+ |
+ if(LED == 1) |
+ { |
+ Data = Data & 0xFFFF00; |
+ Data = Data | code; |
+ if (invert == 1 && latch == 1) |
+ Data = Data | 0x30; |
+ if (invert == 1 && latch == 0) |
+ Data = Data | 0x10; |
+ if (invert == 0 && latch == 1) |
+ Data = Data | 0x20; |
+ } |
+ if(LED == 2) |
+ { |
+ Data = Data & 0xFF00FF; |
+ Data = Data | (code * 0x0100); |
+ if (invert == 1 && latch == 1) |
+ Data = Data | 0x3000; |
+ if (invert == 1 && latch == 0) |
+ Data = Data | 0x1000; |
+ if (invert == 0 && latch == 1) |
+ Data = Data | 0x2000; |
+ } |
+ if(LED == 3) |
+ { |
+ Data = Data & 0x00FFFF; |
+ Data = Data | (code * 0x10000); |
+ if (invert == 1 && latch == 1) |
+ Data = Data | 0x300000; |
+ if (invert == 1 && latch == 0) |
+ Data = Data | 0x100000; |
+ if (invert == 0 && latch == 1) |
+ Data = Data | 0x200000; |
+ } |
+ ret = CAMAC_register_write(hdev, 4, Data); |
+ return ret; |
+} |
+ |
+/* |
+******** CAMAC_Output_settings ************************ |
+ |
+ Writes a data word to the vmusb LED register |
+ |
+ Parameters: |
+ hdev: USB devcie handle returned from an open function |
+ Channel: The number which corresponds to an output: |
+ 1 - for Output 1 |
+ 2 - for Output 2 |
+ 3 - for Output 3 |
+ code: The Output selector code, valid values |
+ are listed in the manual |
+ invert: to invert the output |
+ latch: sets latch bit |
+ |
+ Returns: |
+ Number of bytes read from xxusb when successful |
+ Upon failure, a negative number |
+*/ |
+short CAMAC_Output_settings(usb_dev_handle *hdev, int Channel, int code, int invert, int latch) |
+{ |
+ short ret; |
+// Uint32_t internal; |
+ Uint32_t Data; |
+ |
+ if( (Channel <1) ||(Channel > 3) || (code < 0) || (code > 7)) |
+ return -1; |
+ |
+ CAMAC_register_read(hdev,5,&Data); |
+ |
+ if(Channel == 1) |
+ { |
+ Data = Data & 0xFFFF00; |
+ Data = Data | code; |
+ if (invert == 1 && latch == 1) |
+ Data = Data | 0x30; |
+ if (invert == 1 && latch == 0) |
+ Data = Data | 0x10; |
+ if (invert == 0 && latch == 1) |
+ Data = Data | 0x20; |
+ } |
+ if(Channel == 2) |
+ { |
+ Data = Data & 0xFF00FF; |
+ Data = Data | (code * 0x0100); |
+ if (invert == 1 && latch == 1) |
+ Data = Data | 0x3000; |
+ if (invert == 1 && latch == 0) |
+ Data = Data | 0x1000; |
+ if (invert == 0 && latch == 1) |
+ Data = Data | 0x2000; |
+ } |
+ if(Channel == 3) |
+ { |
+ Data = Data & 0x00FFFF; |
+ Data = Data | (code * 0x10000); |
+ if (invert == 1 && latch == 1) |
+ Data = Data | 0x300000; |
+ if (invert == 1 && latch == 0) |
+ Data = Data | 0x100000; |
+ if (invert == 0 && latch == 1) |
+ Data = Data | 0x200000; |
+ } |
+ ret = CAMAC_register_write(hdev, 5, Data); |
+ return ret; |
+} |
+ |
+/* |
+******** CAMAC_write_LAM_mask ************************ |
+ |
+ Writes the data word to the LAM mask register |
+ |
+ Parameters: |
+ hdev: USB devcie handle returned from an open function |
+ Data: LAM mask to write |
+ |
+ Returns: |
+ Number of bytes read from xxusb when successful |
+ Upon failure, a negative number |
+*/ |
+short CAMAC_write_LAM_mask(usb_dev_handle *hdev, Uint32_t Data) |
+{ |
+ short ret; |
+ ret = CAMAC_register_write(hdev, 9, Data); |
+ |
+ return ret; |
+} |
+ |
+/* |
+******** CAMAC_read_LAM_mask ************************ |
+ |
+ Writes the data word to the LAM mask register |
+ |
+ Parameters: |
+ hdev: USB devcie handle returned from an open function |
+ Data: LAM mask to write |
+ |
+ Returns: |
+ Number of bytes read from xxusb when successful |
+ Upon failure, a negative number |
+*/ |
+short CAMAC_read_LAM_mask(usb_dev_handle *hdev, Uint32_t *Data) |
+{ |
+ Uint32_t intbuf[4]; |
+ int ret; |
+ int N = 25; |
+ int F = 0; |
+ int A = 9; |
+ |
+ // CAMAC direct read function |
+ intbuf[0]=1; |
+ intbuf[1]=(Uint32_t)(F+A*32+N*512 + 0x4000); |
+ ret = xxusb_stack_execute(hdev, intbuf); |
+ *Data=intbuf[0] + (intbuf[1] & 255) * 0x10000; |
+ return ret; |
+} |
+ |
+ |
+//******************************************************// |
+//**************** EZ_CAMAC Functions ******************// |
+//******************************************************// |
+// The following are functions used to perform simple |
+// CAMAC Functions with the CC_USB |
+ |
+ |
+/* |
+******** CAMAC_write ************************ |
+ |
+ Performs a CAMAC write using NAF comments |
+ |
+ Parameters: |
+ hdev: USB device handle returned from an open function |
+ N: CAMAC Station Number |
+ A: CAMAC Subaddress |
+ F: CAMAC Function (16...23) |
+ Q: The Q response from the CAMAC dataway |
+ X: The comment accepted response from CAMAC dataway |
+ |
+ Returns: |
+ Number of bytes written to xxusb when successful |
+ Upon failure, a negative number |
+*/ |
+short CAMAC_write(usb_dev_handle *hdev, int N, int A, int F, Uint32_t Data, int *Q, int *X) |
+{ |
+ Uint32_t intbuf[4]; |
+ int ret; |
+// CAMAC direct write function |
+ intbuf[0]=1; |
+ intbuf[1]=(Uint32_t)(F+A*32+N*512 + 0x4000); |
+ if ((F > 15) && (F < 24)) |
+ { |
+ intbuf[0]=3; |
+ intbuf[2]=(Data & 0xffff); |
+ intbuf[3]=((Data >>16) & 255); |
+ ret = xxusb_stack_execute(hdev, intbuf); |
+ *Q = (intbuf[0] & 1); |
+ *X = ((intbuf[0] >> 1) & 1); |
+ } |
+ return ret; |
+} |
+ |
+/* |
+******** CAMAC_read ************************ |
+ |
+ Performs a CAMAC read using NAF comments |
+ |
+ Parameters: |
+ hdev: USB device handle returned from an open function |
+ N: CAMAC Station Number |
+ A: CAMAC Subaddress |
+ F: CAMAC Function (F<16 or F>23) |
+ Q: The Q response from the CAMAC dataway |
+ X: The comment accepted response from CAMAC dataway |
+ |
+ Returns: |
+ Number of bytes read from xxusb when successful |
+ Upon failure, a negative number |
+*/ |
+short CAMAC_read(usb_dev_handle *hdev, int N, int A, int F, Uint32_t *Data, int *Q, int *X) |
+{ |
+ Uint32_t intbuf[4]; |
+ int ret; |
+ // CAMAC direct read function |
+ intbuf[0]=1; |
+ intbuf[1]=(Uint32_t)(F+A*32+N*512 + 0x4000); |
+ ret = xxusb_stack_execute(hdev, intbuf); |
+ if ((F < 16) || (F >23)) |
+ { |
+ *Data=intbuf[0] + (intbuf[1] & 255) * 0x10000; //24-bit word |
+ *Q = ((intbuf[1] >> 8) & 1); |
+ *X = ((intbuf[1] >> 9) & 1); |
+ } |
+ return ret; |
+} |
+ |
+/* |
+******** CAMAC_Z ************************ |
+ |
+ Performs a CAMAC init |
+ |
+ Parameters: |
+ hdev: USB device handle returned from an open function |
+ |
+ Returns: |
+ Number of bytes written to xxusb when successful |
+ Upon failure, a negative number |
+*/ |
+short CAMAC_Z(usb_dev_handle *hdev) |
+{ |
+ Uint32_t intbuf[4]; |
+ int ret; |
+// CAMAC Z = N(28) A(8) F(29) |
+ intbuf[0]=1; |
+ intbuf[1]=(Uint32_t)(29+8*32+28*512 + 0x4000); |
+ ret = xxusb_stack_execute(hdev, intbuf); |
+ return ret; |
+} |
+ |
+/* |
+******** CAMAC_C ************************ |
+ |
+ Performs a CAMAC clear |
+ |
+ Parameters: |
+ hdev: USB device handle returned from an open function |
+ |
+ Returns: |
+ Number of bytes written to xxusb when successful |
+ Upon failure, a negative number |
+*/ |
+short CAMAC_C(usb_dev_handle *hdev) |
+{ |
+ Uint32_t intbuf[4]; |
+ int ret; |
+ intbuf[0]=1; |
+ intbuf[1]=(Uint32_t)(29+9*32+28*512 + 0x4000); |
+ ret = xxusb_stack_execute(hdev, intbuf); |
+ return ret; |
+} |
+ |
+/* |
+******** CAMAC_I ************************ |
+ |
+ Set CAMAC inhibit |
+ |
+ Parameters: |
+ hdev: USB device handle returned from an open function |
+ |
+ Returns: |
+ Number of bytes written to xxusb when successful |
+ Upon failure, a negative number |
+*/ |
+short CAMAC_I(usb_dev_handle *hdev, int inhibit) |
+{ |
+ Uint32_t intbuf[4]; |
+ int ret; |
+ intbuf[0]=1; |
+ if (inhibit) intbuf[1]=(Uint32_t)(24+9*32+29*512 + 0x4000); |
+ else intbuf[1]=(Uint32_t)(26+9*32+29*512 + 0x4000); |
+ ret = xxusb_stack_execute(hdev, intbuf); |
+ return ret; |
+} |
+ |
+ |
/praktikum/petdaqfmf/libxxusb.cpp |
Property changes: |
Added: svn:executable |
Index: praktikum/petdaqfmf/VMEModule.cc |
=================================================================== |
--- praktikum/petdaqfmf/VMEModule.cc (nonexistent) |
+++ praktikum/petdaqfmf/VMEModule.cc (revision 112) |
@@ -0,0 +1,42 @@ |
+/********************\ |
+ VMEModule.hh |
+\********************/ |
+ |
+#include <stdlib.h> |
+#include <unistd.h> |
+#include <fcntl.h> |
+#include <sys/mman.h> |
+#include "VMEModule.hh" |
+#include "wienvme_dll.h" |
+ |
+ |
+VMEModule::VMEModule(int device ,caddr_t vmeaddr, size_t size) { |
+ m_vmeaddr = vmeaddr; |
+ m_baseaddress = (unsigned long)(vmeaddr) ; |
+} |
+ |
+VMEModule::~VMEModule() { |
+ |
+} |
+ |
+void VMEModule::write32( unsigned long address, unsigned long value ) { |
+ VME_write32(address, (void *) &value); |
+} |
+ |
+unsigned long VMEModule::read32( unsigned long address ){ |
+ unsigned long data; |
+ VME_read32( address, (void *) &data); |
+ return data; |
+} |
+ |
+void VMEModule::write16( unsigned long address, unsigned short value ) { |
+ VME_write16( address, (void *) &value); |
+} |
+ |
+unsigned short VMEModule::read16( unsigned long address ){ |
+ unsigned long data; |
+ VME_read16( address, (void *) &data); |
+ return (short) (data& 0xFFFF); |
+} |
+ |
+ |
Index: praktikum/petdaqfmf/CAENV965.h |
=================================================================== |
--- praktikum/petdaqfmf/CAENV965.h (nonexistent) |
+++ praktikum/petdaqfmf/CAENV965.h (revision 112) |
@@ -0,0 +1,13 @@ |
+#ifndef _CAENV965_H |
+#define _CAENV965_H |
+ |
+#define _VI_FUNC |
+ |
+int _VI_FUNC V965_map (int ModuleNumber, unsigned long ModuleOffset, int print) ; |
+int _VI_FUNC V965_init (int ModuleNumber, unsigned short ped) ; |
+int _VI_FUNC V965_clear (int ModuleNumber) ; |
+int _VI_FUNC V965_status (int ModuleNumber) ; |
+int _VI_FUNC V965_status2 (int ModuleNumber) ; |
+int _VI_FUNC V965_read (int ModuleNumber, unsigned long whereto[],int len); |
+ |
+#endif |
Index: praktikum/petdaqfmf/libxxusb.h |
=================================================================== |
--- praktikum/petdaqfmf/libxxusb.h (nonexistent) |
+++ praktikum/petdaqfmf/libxxusb.h (revision 112) |
@@ -0,0 +1,114 @@ |
+#include <usb.h> |
+ |
+ |
+#define XXUSB_WIENER_VENDOR_ID 0x16DC /* Wiener, Plein & Baus */ |
+#define XXUSB_VMUSB_PRODUCT_ID 0x000B /* VM-USB */ |
+#define XXUSB_CCUSB_PRODUCT_ID 0x0001 /* CC-USB */ |
+#define XXUSB_ENDPOINT_OUT 2 /* Endpoint 2 Out*/ |
+#define XXUSB_ENDPOINT_IN 0x86 /* Endpoint 6 In */ |
+#define XXUSB_FIRMWARE_REGISTER 0 |
+#define XXUSB_GLOBAL_REGISTER 1 |
+#define XXUSB_ACTION_REGISTER 10 |
+#define XXUSB_DELAYS_REGISTER 2 |
+#define XXUSB_WATCHDOG_REGISTER 3 |
+#define XXUSB_SELLEDA_REGISTER 6 |
+#define XXUSB_SELNIM_REGISTER 7 |
+#define XXUSB_SELLEDB_REGISTER 4 |
+#define XXUSB_SERIAL_REGISTER 15 |
+#define XXUSB_LAMMASK_REGISTER 8 |
+#define XXUSB_LAM_REGISTER 12 |
+#define XXUSB_READOUT_STACK 2 |
+#define XXUSB_SCALER_STACK 3 |
+#define XXUSB_NAF_DIRECT 12 |
+ |
+// dodal 19.4.2011 da dela na 64-bit masinah |
+typedef unsigned int Uint32_t; |
+ |
+struct XXUSB_STACK |
+{ |
+Uint32_t Data; |
+short Hit; |
+short APatt; |
+short Num; |
+short HitMask; |
+}; |
+ |
+struct XXUSB_CC_COMMAND_TYPE |
+{ |
+short Crate; |
+short F; |
+short A; |
+short N; |
+Uint32_t Data; |
+short NoS2; |
+short LongD; |
+short HitPatt; |
+short QStop; |
+short LAMMode; |
+short UseHit; |
+short Repeat; |
+short AddrScan; |
+short FastCam; |
+short NumMod; |
+short AddrPatt; |
+Uint32_t HitMask[4]; |
+Uint32_t Num; |
+}; |
+ |
+struct xxusb_device_typ |
+{ |
+ struct usb_device *usbdev; |
+ char SerialString[7]; |
+}; |
+ |
+typedef struct xxusb_device_typ xxusb_device_type; |
+typedef unsigned char UCHAR; |
+typedef struct usb_bus usb_busx; |
+ |
+ |
+int xxusb_longstack_execute(usb_dev_handle *hDev, void *DataBuffer, int lDataLen, int timeout); |
+int xxusb_bulk_read(usb_dev_handle *hDev, void *DataBuffer, int lDataLen, int timeout); |
+int xxusb_bulk_write(usb_dev_handle *hDev, void *DataBuffer, int lDataLen, int timeout); |
+int xxusb_usbfifo_read(usb_dev_handle *hDev, int *DataBuffer, int lDataLen, int timeout); |
+ |
+short xxusb_register_read(usb_dev_handle *hDev, short RegAddr, Uint32_t *RegData); |
+short xxusb_stack_read(usb_dev_handle *hDev, short StackAddr, Uint32_t *StackData); |
+short xxusb_stack_write(usb_dev_handle *hDev, short StackAddr, Uint32_t *StackData); |
+short xxusb_stack_execute(usb_dev_handle *hDev, Uint32_t *StackData); |
+short xxusb_register_write(usb_dev_handle *hDev, short RegAddr, Uint32_t RegData); |
+short xxusb_reset_toggle(usb_dev_handle *hDev); |
+ |
+short xxusb_devices_find(xxusb_device_type *xxusbDev); |
+short xxusb_device_close(usb_dev_handle *hDev); |
+usb_dev_handle* xxusb_device_open(struct usb_device *dev); |
+short xxusb_flash_program(usb_dev_handle *hDev, char *config, short nsect); |
+short xxusb_flashblock_program(usb_dev_handle *hDev, UCHAR *config); |
+usb_dev_handle* xxusb_serial_open(char *SerialString); |
+ |
+short VME_register_write(usb_dev_handle *hdev, Uint32_t VME_Address, Uint32_t Data); |
+short VME_register_read(usb_dev_handle *hdev, Uint32_t VME_Address, Uint32_t *Data); |
+short VME_LED_settings(usb_dev_handle *hdev, int LED, int code, int invert, int latch); |
+short VME_DGG(usb_dev_handle *hdev, unsigned short channel, unsigned short trigger,unsigned short output, Uint32_t delay, unsigned short gate, unsigned short invert, unsigned short latch); |
+ |
+short VME_Output_settings(usb_dev_handle *hdev, int Channel, int code, int invert, int latch); |
+ |
+short VME_read_16(usb_dev_handle *hdev,short Address_Modifier, Uint32_t VME_Address, Uint32_t *Data); |
+short VME_read_32(usb_dev_handle *hdev, short Address_Modifier, Uint32_t VME_Address, Uint32_t *Data); |
+short VME_BLT_read_32(usb_dev_handle *hdev, short Address_Modifier, int count, Uint32_t VME_Address, Uint32_t Data[]); |
+short VME_write_16(usb_dev_handle *hdev, short Address_Modifier, Uint32_t VME_Address, Uint32_t Data); |
+short VME_write_32(usb_dev_handle *hdev, short Address_Modifier, Uint32_t VME_Address, Uint32_t Data); |
+ |
+short CAMAC_DGG(usb_dev_handle *hdev, short channel, short trigger, short output, int delay, int gate, short invert, short latch); |
+short CAMAC_register_read(usb_dev_handle *hdev, int A, Uint32_t *Data); |
+short CAMAC_register_write(usb_dev_handle *hdev, int A, Uint32_t Data); |
+short CAMAC_LED_settings(usb_dev_handle *hdev, int LED, int code, int invert, int latch); |
+short CAMAC_Output_settings(usb_dev_handle *hdev, int Channel, int code, int invert, int latch); |
+short CAMAC_read_LAM_mask(usb_dev_handle *hdev, Uint32_t *Data); |
+short CAMAC_write_LAM_mask(usb_dev_handle *hdev, Uint32_t Data); |
+ |
+short CAMAC_write(usb_dev_handle *hdev, int N, int A, int F, Uint32_t Data, int *Q, int *X); |
+short CAMAC_read(usb_dev_handle *hdev, int N, int A, int F, Uint32_t *Data, int *Q, int *X); |
+short CAMAC_Z(usb_dev_handle *hdev); |
+short CAMAC_C(usb_dev_handle *hdev); |
+short CAMAC_I(usb_dev_handle *hdev, int inhibit); |
+ |
/praktikum/petdaqfmf/libxxusb.h |
Property changes: |
Added: svn:executable |
Index: praktikum/petdaqfmf/daq.C |
=================================================================== |
--- praktikum/petdaqfmf/daq.C (nonexistent) |
+++ praktikum/petdaqfmf/daq.C (revision 112) |
@@ -0,0 +1,583 @@ |
+#include <stdio.h> |
+#include <stdlib.h> |
+#include <string.h> |
+#include <unistd.h> |
+#include <sys/mman.h> |
+#include <errno.h> |
+#include <ctype.h> |
+#include <time.h> |
+#include <sys/time.h> |
+#include <sys/stat.h> |
+#include <signal.h> |
+#include <zlib.h> |
+ |
+#include "CAENV965_DEF.h" |
+#include "VmUsbStack.h" |
+ |
+#include "vme.h" |
+ |
+#include "daq.h" |
+ |
+#define VERSION 1.0 |
+#define TIMEOUT 3 |
+ |
+ |
+/* VME modules */ |
+ |
+#define CAEN_V792 0x340000 // IJS V792 |
+#define CAEN_V792_1 0x530000 // FMF1 V792 |
+#define CAEN_V792_2 0x630000 // FMF2 V792 |
+#define CAEN_V965 0x350000 // IJS V965 |
+int addr[3]={CAEN_V792,CAEN_V792_1,CAEN_V965 }; |
+int nadc=3; |
+ |
+int gPedestal = 255; |
+ |
+#define BUFF_L 2048 |
+static int stackwrite[10000]; |
+static int stackdata[10000],stackdump[27000]; |
+ |
+ |
+/************************************************/ |
+int weight_while(int num) |
+{ |
+ int i, tmp; |
+ |
+ for ( i =0; i <num; i++ ) tmp = 0; |
+ return 0; |
+} |
+#define WWHILE weight_while(0) |
+ |
+#define TRUE 1 |
+#define FALSE 0 |
+ |
+int timer_out; |
+struct sigaction oact; |
+void timerast (int signumber) |
+{ |
+ timer_out = TRUE; |
+ fprintf(stderr,"TIMEOUT !!!\n"); |
+} |
+ |
+void tmlnk (int tout) |
+{ |
+ timer_out = FALSE; |
+ struct sigaction act; |
+ struct itimerval tdelay; |
+ |
+ act.sa_handler = timerast; |
+ sigemptyset (&act.sa_mask); |
+ act.sa_flags = 0; |
+ |
+ tdelay.it_value.tv_sec = tout / 100; |
+ tdelay.it_value.tv_usec = 10000 * (tout % 100); |
+ tdelay.it_interval.tv_sec = 0; |
+ tdelay.it_interval.tv_usec = 0; |
+ |
+ if (sigaction (SIGALRM, &act, &oact) < 0) |
+ { |
+ perror ("sigaction(tmlnk)"); |
+ exit (EXIT_FAILURE); |
+ } |
+ if (setitimer (ITIMER_REAL, &tdelay, NULL) < 0) |
+ { |
+ perror ("setitimer(tmlnk)"); |
+ exit (EXIT_FAILURE); |
+ } |
+} |
+ |
+void tmulk () |
+{ |
+ struct itimerval tdelay; |
+ |
+ tdelay.it_value.tv_sec = 0; |
+ tdelay.it_value.tv_usec = 0; |
+ tdelay.it_interval.tv_sec = 0; |
+ tdelay.it_interval.tv_usec = 0; |
+ |
+ if (setitimer (ITIMER_REAL, &tdelay, NULL) < 0) |
+ { |
+ perror ("setitimer(tmulk)"); |
+ exit (EXIT_FAILURE); |
+ } |
+ if (sigaction (SIGALRM, &oact, NULL) < 0) |
+ { |
+ perror ("sigaction(tmulk)"); |
+ exit (EXIT_FAILURE); |
+ } |
+} |
+ |
+int fexist( char * path){ |
+ struct stat sbuf; |
+ int res; |
+ if(!path || !*path) return 0; |
+ res=stat(path,&sbuf); |
+ if (res){ |
+ if (errno==ENOENT) { |
+ return 0; |
+ } else { |
+ return -1; |
+ } |
+ } |
+ return 1; |
+} |
+ |
+ |
+ |
+ |
+int daq::init(){ |
+ |
+ xxusb_register_write(udev,1,0x0); // Stop DAQ mode |
+ while (xxusb_usbfifo_read(udev,(int *) stackdump,BUFF_L,100)>0); |
+ |
+ |
+ int rate=1000; |
+ int i=80000000/rate-40; // 80 MHz |
+ if (i<72) i=72; |
+ // Set DGG channel A as a pulser, output on O1, |
+ // with delay =500 x 12.5ns, |
+ // and width = 500 x 12.5ns, |
+ // not latching or inverting |
+ // VME_DGG(udev,0,6,0,24000,6000,0,0); |
+ VME_DGG(udev,0,6,0,i,40,0,0); |
+ // Set DGG channel B to trigger on NIM1, output on O2, |
+ // with delay =200 x 12.5ns, |
+ // and width = 200 x 12.5ns, |
+ // not latching or inverting |
+ VME_DGG(udev,1,1,1,0,10,0,1); |
+ |
+ |
+// INIT stackdata |
+ int fPedestal=gPedestal; |
+ printf("CAEN V965 Pedestal set to %d\n", fPedestal); |
+ if (fInit != NULL ) delete fInit; |
+ fInit=new VmUsbStack(); |
+ |
+ for (int i=0;i<nadc;i++){ |
+ fInit->WriteA24D16( addr[i] + CAENV965_CRN , 0x0); |
+ fInit->WriteA24D16( addr[i] + CAENV965_GEO , i); |
+ fInit->ReadA24D16(addr[i] + CAENV965_GEO); |
+ for (int j=0;j<32;j++){ |
+ fInit->WriteA24D16(addr[i] + CAENV965_THM + 0x02*j, fThreshold[j+i*32]); // threshold/kill for 32 channels |
+ } |
+ fInit->WriteA24D16( addr[i] + CAENV965_BS1, 0x80 ); // soft reset |
+ fInit->WriteA24D16( addr[i] + CAENV965_BC1, 0x80 ); // soft reset |
+ fInit->WriteA24D16( addr[i] + CAENV965_PED, fPedestal ); // pedestal |
+ fInit->WriteA24D16( addr[i] + CAENV965_BS2,0x5000); |
+ fInit->WriteA24D16( addr[i] + CAENV965_BS2,0x4); // clear module |
+ fInit->WriteA24D16( addr[i] + CAENV965_BC2,0x4); |
+ } |
+ fInit->Marker(0xFAFC); |
+ |
+// fInit->Print(); |
+ |
+ |
+ // READOUT stackdata |
+ if (fStack != NULL ) delete fStack; |
+ fStack=new VmUsbStack(); |
+ fStack->Marker(0xFFAB); |
+ //fStack->ConditionalRead(addr[i] + CAENV965_SR1,0x1); // TRG wait : loop until bit 0 is on |
+ // fStack->RepeatRead( CMD_A24, CMD_D32, addr[i] + CAENV965_OB,34,0); // repead read |
+ //fStack->ConditionalRead(addr[i] + CAENV965_OB ,0x4000000) ; // loop until bit 26 is on, read data |
+ for (int j=0;j<36;j++) fStack->ReadA24D32(addr[0] + CAENV965_OB); |
+ for (int j=0;j<36;j++) fStack->ReadA24D32(addr[1] + CAENV965_OB); |
+ for (int j=0;j<8;j++) fStack->ReadA24D32(addr[2] + CAENV965_OB);// 4 channels connected |
+ fStack->Marker(0xFAFB); |
+ |
+ for (int i=0;i<nadc;i++){ |
+ fStack->WriteA24D16(addr[i] + CAENV965_BS2,0x4); // clear module |
+ fStack->WriteA24D16(addr[i] + CAENV965_BC2,0x4); |
+ } |
+ |
+ //fStack->Print(); |
+ |
+ VME_LED_settings(udev, 0,0,0,0); // Set Yellow LED to light with with USB out buffer not empty |
+ VME_LED_settings(udev, 1,1,0,0); // Set Red LED to light with NIM1 |
+ VME_LED_settings(udev,2,0,0,0); // Set Green LED to light when stack is not empty |
+ |
+ Uint32_t vmereg; |
+ VME_register_read(udev,0x00,&vmereg); |
+ printf("VMUSB Firmware ID -> 0x%08X\n",vmereg); |
+ |
+ VME_register_read(udev,0x04,&vmereg); |
+ printf("VMUSB Global Mode -> 0x%08X\n",vmereg); |
+ |
+ vmereg=(vmereg&0xF000)|0x0004; |
+ VME_register_write(udev,0x04,vmereg); |
+ VME_register_write(udev,0x08,0x00000080); |
+ VME_register_write(udev,0x28,0x0); |
+ VME_register_write(udev,0x2C,0x0); |
+ VME_register_write(udev,0x30,0x0); |
+ VME_register_write(udev,0x34,0x0); |
+ VME_register_write(udev,0x3C,0x000); |
+ |
+ int nb = fInit->Get(10000,stackdata); |
+ int ret= xxusb_stack_execute(udev,(Uint32_t *)stackdata); |
+ printf("Init::%d ret=%d\n",nb,ret); |
+ if (ret>0) for (int i=0;i<ret/2;i++) printf ("stackdata=0x%08X\n",stackdata[i]); |
+ |
+ int nb0= fStack->Get(10000,&stackwrite[0]); |
+ if (nb0>768) { |
+ fprintf(stderr,"nb0=%d > 768 error xxusb_stack_write\n", nb0); |
+ exit(-1); |
+ } |
+ nb =xxusb_stack_write(udev,0x2,(Uint32_t *) stackwrite); |
+ nb0=xxusb_stack_read(udev,0x2,(Uint32_t *) stackdata); |
+ for (int i=0;i<stackwrite[0]+1;i++){ |
+ if (stackdata[i]!=stackwrite[i]) printf("%d %d init err %x %x\n",nb,nb0,stackwrite[i], stackdata[i]); |
+ } |
+ |
+ if (fMode==2) xxusb_register_write(udev,1,0x1); // Start DAQ mode |
+ |
+ printf("daq::init() \n"); |
+ return 0; |
+} |
+ |
+int daq::connect(){ |
+ VME_START(NULL); |
+ printf("daq::connect()\n"); |
+ return 0; |
+} |
+ |
+int daq::disconnect(){ |
+ /* zakljuci */ |
+ VME_STOP(); |
+ printf("daq::disconnect()\n"); |
+ return 0; |
+} |
+ |
+int daq:: clear(){ |
+ return 0; |
+} |
+ |
+inline int module_header(int recid,Uint32_t *data,int len){ |
+ data[0] = recid; |
+ data[1] = (len >0)? len : 0 ; |
+ return data[1]+2; |
+} |
+ |
+ |
+int daq::event(unsigned int *data, int maxn, int *ctr, int print){ |
+ int tout=200; /* 1/100 of a second */ |
+ const int lsize=sizeof(unsigned Uint32_t); |
+ |
+ |
+ ctr[0]++; |
+ ctr[1]++; |
+ |
+ int count=0; |
+ |
+ switch (fMode){ |
+ case 0:// normal calls |
+ { |
+ unsigned short clr= 0x4; |
+ unsigned int status=0; |
+ Uint32_t mdata; |
+ |
+ for (int i=0;i<2;i++){ |
+ // wait for trg |
+ tmlnk (tout); |
+ do VME_A24D16_R( addr[i] + CAENV965_SR1, &status); while ( (status&0x1)==0 && timer_out==0 ); |
+ tmulk(); |
+ // readout data |
+ if (timer_out) return 0; |
+ int len=0; |
+ |
+ do { |
+ VME_A24D32_R(addr[i] + CAENV965_OB, &mdata); |
+ mdata=data[count++]; |
+ len++; |
+ } while ( (mdata & 0x4000000)==0 && timer_out==0) ; // bit 26 EOB or not valid datum |
+ // clear |
+ VME_A24D16_W( addr[i] + CAENV965_BS2, &clr); |
+ VME_A24D16_W( addr[i] + CAENV965_BC2, &clr); |
+ |
+ if (count+2<maxn) { |
+ if (print) printf("V965 %3d\n",len); |
+ count+=module_header(0x130+i,&data[count],len); |
+ ctr[2]++; |
+ ctr[3]+=len; |
+ } |
+ |
+ timer_out=0; |
+ } |
+ } |
+ break; |
+ case 1:// stack execute |
+ { |
+ fStack->Get(10000,(int *)data); |
+ int ret=xxusb_stack_execute(udev,(Uint32_t *) data); //The first element of the array is the number of bytes. |
+ if (ret< 0 ) { |
+ printf ("xxusb_stack_execute error err=%d\n",ret); \ |
+ count = 0; |
+ } else count= ret/lsize; |
+ |
+ } |
+ break; |
+ case 2:// stack load |
+ { |
+ int ret=xxusb_usbfifo_read(udev,(int *) data,BUFF_L,100); |
+ if (ret< 0 ) { |
+ if (ret!=-110) { |
+ printf ("xxusb_usbfifo_read error err=%d\n",ret); |
+ end(); |
+ init(); |
+ } |
+ count = 0; |
+ } else { |
+ if (0 && print && ret>0) { |
+ for (int i=0;i<100;i++) { |
+ printf ("%4d fifodata=0x%08X\n",i, data[i]); |
+ if (data[i]==0xFAFB) break; |
+ } |
+ /* |
+ |
+ 0 fifodata=0x0000000D |
+ 1 fifodata=0x00000049 |
+ 2 fifodata=0x0000FFAB |
+ 3 fifodata=0x00002000 |
+ 4 fifodata=0x00000200 |
+ 5 fifodata=0x00004141 |
+ 6 fifodata=0x00000000 |
+ 7 fifodata=0x00004057 |
+ 8 fifodata=0x00000010 |
+ 9 fifodata=0x00004052 |
+ 10 fifodata=0x00000001 |
+ 11 fifodata=0x0000405C |
+ 12 fifodata=0x00000011 |
+ 13 fifodata=0x0000405D |
+ 14 fifodata=0x00000002 |
+ 15 fifodata=0x0000405E |
+ 16 fifodata=0x00000012 |
+ 17 fifodata=0x0000401C |
+ 18 fifodata=0x00000003 |
+ 19 fifodata=0x0000402F |
+ 20 fifodata=0x00000013 |
+ 21 fifodata=0x00004024 |
+ 22 fifodata=0x00000004 |
+ 23 fifodata=0x00004076 |
+ 24 fifodata=0x00000014 |
+ 25 fifodata=0x0000412F |
+ 26 fifodata=0x00000005 |
+ 27 fifodata=0x0000404C |
+ 28 fifodata=0x00000015 |
+ 29 fifodata=0x00004132 |
+ 30 fifodata=0x00000006 |
+ 31 fifodata=0x00004044 |
+ 32 fifodata=0x00000016 |
+ 33 fifodata=0x0000404A |
+ 34 fifodata=0x00000007 |
+ 35 fifodata=0x0000409B |
+ 36 fifodata=0x00000017 |
+ 37 fifodata=0x000040F1 |
+ 38 fifodata=0x00000008 |
+ 39 fifodata=0x00004087 |
+ 40 fifodata=0x00000018 |
+ 41 fifodata=0x00004173 |
+ 42 fifodata=0x00000009 |
+ 43 fifodata=0x0000404C |
+ 44 fifodata=0x00000019 |
+ 45 fifodata=0x0000406C |
+ 46 fifodata=0x0000000A |
+ 47 fifodata=0x00004070 |
+ 48 fifodata=0x0000001A |
+ 49 fifodata=0x0000406E |
+ 50 fifodata=0x0000000B |
+ 51 fifodata=0x00004014 |
+ 52 fifodata=0x0000001B |
+ 53 fifodata=0x000040B7 |
+ 54 fifodata=0x0000000C |
+ 55 fifodata=0x000040A9 |
+ 56 fifodata=0x0000001C |
+ 57 fifodata=0x00004048 |
+ 58 fifodata=0x0000000D |
+ 59 fifodata=0x00004118 |
+ 60 fifodata=0x0000001D |
+ 61 fifodata=0x0000409D |
+ 62 fifodata=0x0000000E |
+ 63 fifodata=0x0000405B |
+ 64 fifodata=0x0000001E |
+ 65 fifodata=0x00004285 |
+ 66 fifodata=0x0000000F |
+ 67 fifodata=0x00004159 |
+ 68 fifodata=0x0000001F |
+ 69 fifodata=0x00000035 |
+ 70 fifodata=0x00000400 |
+ 71 fifodata=0x00000035 |
+ 72 fifodata=0x00000600 |
+ 73 fifodata=0x00000035 |
+ 74 fifodata=0x0000FAFB |
+ |
+ |
+ */ |
+ } |
+ if (print) printf("------------------ret=%d data[0]=%d\n",ret,(int)data[0]); |
+ count= ret/lsize; |
+ ctr[2]+=data[0]; |
+ ctr[3]+=count; |
+ } |
+ } |
+ break; |
+ } |
+ return count*lsize; |
+} |
+ |
+int daq::end(){ |
+ |
+ xxusb_register_write(udev,1,0x0); // Stop DAQ mode |
+ while (xxusb_usbfifo_read(udev,(int *) stackdata,BUFF_L,30)>0); |
+ printf("daq::end()\n"); |
+ return 0; |
+} |
+ |
+daq::daq(){ |
+ fMode = 2; |
+ fPedestal=255; |
+ for (int i=0;i<128;i++){ |
+ if (i<72) fThreshold.push_back(0); |
+ else fThreshold.push_back(0x1<<8); // samo 4 kanali na zadnjem modulu so enablani |
+ } |
+ fThresholdEnable=0; |
+ fStop=0; |
+ fInit=NULL; |
+ fStack=NULL; |
+ connect(); |
+} |
+ |
+daq::~daq(){ |
+disconnect(); |
+} |
+ |
+#ifdef MAIN |
+/* ------------------- CatchSig ----------------- */ |
+int ctrlcflag=0; |
+ |
+void SigInt (int sig) |
+{ |
+ ctrlcflag = 1; |
+ timer_out=1; |
+} |
+ |
+int main (int argc, char **argv){ |
+ // intercept routine |
+ if (signal (SIGINT, SigInt) == SIG_ERR) { |
+ perror ("sigignore"); |
+ } |
+ |
+ // print welcome message |
+ time_t t,told, tstart, tstop; |
+ time(&t); |
+ fprintf(stdout,"#############################################\n"); |
+ fprintf(stdout,"Program %s version %2.1f\n",argv[0], VERSION); |
+ fprintf(stdout,"Compiled on %s %s\n",__DATE__, __TIME__); |
+ fprintf(stdout,"Runtime %s \n",ctime(&t)); |
+ fprintf(stdout,"#############################################\n"); |
+ |
+ |
+ int neve=-1; |
+ char cfname[100]="test.dat"; |
+ char *fname=cfname; |
+ char *fpedname=NULL; |
+ |
+#define BSIZE 10000 |
+ Uint32_t data[10000]; |
+ |
+ |
+ daq *d= new daq(); |
+ int c; |
+ |
+ while ((c = getopt (argc, argv, "p:n:t:o:")) != -1) |
+ switch (c) |
+ { |
+ case 'o': |
+ sprintf(fname ,"%s", optarg); |
+ if (fexist(fname)==1){ |
+ fprintf(stdout,"Error !\n"); |
+ fprintf(stdout,"File %s already exist. Appending ....\n",fname); |
+ //fprintf(stdout,"Remove the file and restart !!!\n"); |
+ //exit(0); |
+ } |
+ break; // input file |
+ case 'n': |
+ neve = atoi(optarg); // negative argument time ( in s )limited event loop |
+ break; |
+ case 't': |
+ { |
+ |
+ sprintf(fpedname ,"%s", optarg); |
+ FILE *fped=fopen(fpedname,"r"); |
+ int j=0; |
+ int ndim=400; |
+ char line[ndim]; |
+ int val=0; |
+ while (fgets(line,ndim,fped)!=NULL){ |
+ sscanf(line,"%d",&val); |
+ d->fThreshold[j++]=val; |
+ } |
+ d->fThresholdEnable=1; |
+ //fclose(fped); |
+ fclose(fped); |
+ break; |
+ } |
+ case 'p': |
+ gPedestal = atoi(optarg); // injected charge to the qdc |
+ break; |
+ } |
+ |
+ if (argc==1) { |
+ fprintf(stdout,"Usage: %s -o [filename] -n [number of events] -t [thresholdfile] -p <qdc inject charge>\n negative number of events = acq time in seconds\n",argv[0]); |
+ exit(-1); |
+ } |
+ //FILE *fp=fopen(fname,"a"); |
+ gzFile fp=gzopen(fname,"a"); |
+ |
+ d->init(); |
+ d->clear(); |
+ |
+ int hdr[4]={2}; // recid od run 11 naprej |
+ int i=0; |
+ int ntotal=0; |
+ int counters[30]={0,0,0,0,0, 0,0,0,0,0,0,0}; |
+ char names[10][20]={"TRG","CAEN V965"}; |
+ time(&t); |
+ tstart=t; |
+ tstop=tstart+360000; |
+ if (neve<-1) { |
+ tstop=tstart-neve; |
+ neve=-1; |
+ } |
+ for (i=0;i!=neve && !ctrlcflag && t<tstop;i++){ |
+ time(&t); |
+ if (t!=told ) printf("%d in %2.2f min daq::event() %s\n",i, (double)(t-tstart)/60., ctime(&t)); |
+ int nb=d->event(data,BSIZE, counters,t!=told); |
+ if (nb>0){ |
+ // zapis v datoteko |
+ hdr[1]=nb+4*sizeof(int); |
+ hdr[2]=time(NULL); |
+ hdr[3]=i; |
+ |
+ //fwrite(hdr, sizeof(int),4 , fp); |
+ gzwrite(fp, hdr, sizeof(int)*4); //gzip |
+ // recid=1 do runa 10. ntotal += fwrite(data, sizeof(int),nb, fp); |
+ //ntotal += fwrite(data, 1,nb, fp); |
+ ntotal += gzwrite(fp, data, nb); |
+ told=t; |
+ } else i--; |
+ } |
+ |
+ d->end(); |
+ delete d; |
+ printf("Number of Events: %d\n",i); |
+ if (ctrlcflag) printf("User Program termination CTRL-C\n"); |
+ if (t>tstop ) printf("Timeout termination tstart# t>tstop: %d# %d >%d\n",(int)t, (int)tstart, (int) tstop); |
+ |
+ |
+ //fclose(fp); |
+ gzclose(fp); |
+ fprintf(stdout,"%d bytes written to %s\nCounts:\n", (int) (ntotal*sizeof(int)),fname); |
+ for (i=0;i<2;i++) fprintf(stdout,"%s\t%d\t%d\n",names[i],counters[2*i],counters[2*i+1]) ; |
+ |
+ |
+ return 0; |
+} |
+#endif |
Index: praktikum/petdaqfmf/.root_hist |
=================================================================== |
--- praktikum/petdaqfmf/.root_hist (nonexistent) |
+++ praktikum/petdaqfmf/.root_hist (revision 112) |
@@ -0,0 +1,99 @@ |
+TBrowser tt |
+.q |
+TBrowser d |
+TFile *_file0 = TFile::Open("test100.root") |
+ach0->Draw() |
+.q |
+TFile *_file0 = TFile::Open("test50.root") |
+ach0->Draw() |
+.q |
+TFile *_file0 = TFile::Open("test150.root") |
+ach0->Draw() |
+TFile *_file0 = TFile::Open("test250.root") |
+ach0->Draw() |
+TFile *_file0 = TFile::Open("test200.root") |
+ach0->Draw() |
+TFile *_file0 = TFile::Open("test150.root") |
+ach0->Draw() |
+TFile *_file0 = TFile::Open("test100.root") |
+ach0->Draw() |
+TFile *_file0 = TFile::Open("test50.root") |
+ach0->Draw() |
+.q |
+TFile *_file0 = TFile::Open("test80.root") |
+ach0->Draw() |
+ach0->Draw() |
+ach1->Draw() |
+ach2->Draw() |
+ach3->Draw() |
+ach4->Draw() |
+ach5->Draw() |
+ach6->Draw() |
+ach7->Draw() |
+ach8->Draw() |
+ach9->Draw() |
+ach10->Draw() |
+ach11->Draw() |
+ach12->Draw() |
+ach13->Draw() |
+ach14->Draw() |
+ach15->Draw() |
+ach16->Draw() |
+ach15->Draw() |
+.q |
+TFile *_file0 = TFile::Open("test80_reversed.root") |
+ach15->Draw() |
+ach1->Draw() |
+ach2->Draw() |
+ach3->Draw() |
+ach4->Draw() |
+ach4->Draw() |
+.q |
+TFile *_file0 = TFile::Open("test.root") |
+ach4->Draw() |
+1->Draw() |
+a1->Draw() |
+ach5->Draw() |
+ach5->Draw() |
+ach7->Draw() |
+ach16->Draw() |
+ach18->Draw() |
+ach36->Draw() |
+.q |
+TFile *_file0 = TFile::Open("test1.root") |
+ach7->Draw() |
+ach17->Draw() |
+ach7->Draw() |
+.q |
+TFile *_file0 = TFile::Open("test.root") |
+ach7->Draw() |
+ach27->Draw() |
+ach17->Draw() |
+ach18->Draw() |
+ach16->Draw() |
+ach15->Draw() |
+ach14->Draw() |
+ach13->Draw() |
+.ls |
+sumadc1->Draw() |
+sumadc0->Draw() |
+cadc0->Draw() |
+pmt0->Draw() |
+pmt1->Draw() |
+pmt0->Draw() |
+sumadc0->Draw() |
+.q |
+TFile *_file0 = TFile::Open("test_reversed.root") |
+sumadc0->Draw() |
+tbrowser |
+TBrowser |
+TBrowser jj |
+.q |
+TFile *_file0 = TFile::Open("test850.root") |
+ach14->Draw() |
+ach11->Draw() |
+ach0->Draw() |
+ach15->Draw() |
+ach16->Draw() |
+ach15->Draw() |
+.q |
Index: praktikum/petdaqfmf/wienvme_dll.h |
=================================================================== |
--- praktikum/petdaqfmf/wienvme_dll.h (nonexistent) |
+++ praktikum/petdaqfmf/wienvme_dll.h (revision 112) |
@@ -0,0 +1,53 @@ |
+#ifndef _WIENVME_DLL_H |
+#define _WIENVME_DLL_H |
+ |
+#include "libxxusb.h" |
+ |
+extern usb_dev_handle *udev; |
+ |
+ |
+ |
+int VME_start (char*); |
+int VME_close (int); |
+int VME_stop (void); |
+int VME_reset (void); |
+ |
+ |
+int VME_read16 (Uint32_t, void*); |
+int VME_read32 (Uint32_t, void*); |
+ |
+int VME_write16 ( Uint32_t, void*); |
+int VME_write32 ( Uint32_t, void*); |
+ |
+#define VME_START(NODE) VME_start((NODE)) |
+#define VME_STOP() VME_stop() |
+#define VME_RESET() VME_reset() |
+ |
+#define VME_A24D16_R(VME,DATA) VME_read16( (VME), (DATA)) |
+#define VME_A24D32_R(VME,DATA) VME_read32( (VME), (DATA)) |
+ |
+#define VME_A24D16_W(VME,DATA) VME_write16( (VME), (DATA)) |
+#define VME_A24D32_W(VME,DATA) VME_write32( (VME), (DATA)) |
+ |
+#define VME_A32D16_R(VME,DATA) VME_read16( (VME), (DATA)) |
+#define VME_A32D32_R(VME,DATA) VME_read32( (VME), (DATA)) |
+ |
+#define VME_A32D16_W(VME,DATA) VME_write16( (VME), (DATA)) |
+#define VME_A32D32_W(VME,DATA) VME_write32( (VME), (DATA)) |
+ |
+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 |
+ |
+#endif |
/praktikum/petdaqfmf/wienvme_dll.h |
Property changes: |
Added: svn:executable |
Index: praktikum/petdaqfmf/VMEModule.hh |
=================================================================== |
--- praktikum/petdaqfmf/VMEModule.hh (nonexistent) |
+++ praktikum/petdaqfmf/VMEModule.hh (revision 112) |
@@ -0,0 +1,39 @@ |
+/********************\ |
+ VMEModule.hh |
+ |
+ update: 04/01/28 |
+ |
+\********************/ |
+ |
+#ifndef VMEMODULE_HH |
+#define VMEMODULE_HH |
+ |
+ |
+ |
+#include <stdio.h> |
+#include <sys/types.h> |
+#include "pcivme_ni.h" |
+ |
+#define VMEA24 (unsigned short)0x39 |
+#define VMEA32 (unsigned short)0x09 |
+#define VMEA16 (unsigned short)0x29 |
+class VMEModule { |
+protected: |
+ int m_fd; |
+ int m_vmeptr; |
+ caddr_t m_vmeaddr; |
+ size_t m_size; |
+ unsigned long m_baseaddress; |
+public: |
+ VMEModule(int device, caddr_t vmeaddr, size_t size); |
+ ~VMEModule(); |
+ unsigned long getBaseAddress() { return (unsigned long) m_baseaddress; } |
+ caddr_t getVmeAddress() { return m_vmeaddr; } |
+ void write32(unsigned long address, unsigned long value); |
+ unsigned long read32(unsigned long address); |
+ |
+ void write16(unsigned long address, unsigned short value); |
+ unsigned short read16(unsigned long address); |
+}; |
+ |
+#endif |
Index: praktikum/petdaqfmf/daq.h |
=================================================================== |
--- praktikum/petdaqfmf/daq.h (nonexistent) |
+++ praktikum/petdaqfmf/daq.h (revision 112) |
@@ -0,0 +1,24 @@ |
+#ifndef _daq_h_ |
+#define _daq_h_ |
+#include <vector> |
+class VmUsbStack; |
+class daq { |
+public: |
+ VmUsbStack * fStack; |
+ VmUsbStack * fInit; |
+ int fPedestal; |
+ int fThresholdEnable; |
+ std::vector<int> fThreshold; |
+ int fStop; |
+ int fMode; |
+ int clear(); |
+ int end(); |
+ int event(unsigned int *, int,int*, int ); |
+ int init(); |
+ int connect(); |
+ int disconnect(); |
+ daq(); |
+ ~daq(); |
+}; |
+ |
+#endif |
Index: praktikum/petdaqfmf/README |
=================================================================== |
--- praktikum/petdaqfmf/README (nonexistent) |
+++ praktikum/petdaqfmf/README (revision 112) |
@@ -0,0 +1,2 @@ |
+./daq -o [filename] -n [number of events] -t [thresholdfile] -p <qdc inject charge> |
+ negative number of events = acq time in seconds |
Index: praktikum/petdaqfmf/pcivme_ni.h |
=================================================================== |
--- praktikum/petdaqfmf/pcivme_ni.h (nonexistent) |
+++ praktikum/petdaqfmf/pcivme_ni.h (revision 112) |
@@ -0,0 +1,84 @@ |
+#ifndef __PCIVME_NI_H__ |
+#define __PCIVME_NI_H__ |
+ |
+//------------------------------------------------------------------------------------------- |
+// pcivme_ni.h - header for ni-labview shared library or dll for ARW pcivme interface |
+// this library can also be used for other purposes aside from labview |
+// |
+// Copyright (C) 2002-2004 ARW Elektronik Germany |
+// |
+// this source code is published under LGPL (Open Source). You can use, redistrubute and |
+// modify it unless this header is not modified or deleted. No warranty is given that |
+// this software will work like expected. |
+// This product is not authorized for use as critical component in life support systems |
+// wihout the express written approval of ARW Elektronik Germany. |
+// |
+// Please announce changes and hints to ARW Elektronik |
+// |
+// $Log: pcivme_ni.h,v $ |
+// Revision 1.8 2004/08/13 19:23:45 klaus |
+// conversion to kernel-version 2.6, released version 3.0 |
+// |
+// Revision 1.7 2002/10/20 18:07:18 klaus |
+// changed error handling |
+// |
+// Revision 1.6 2002/10/18 21:56:28 klaus |
+// completed functional features, untested |
+// |
+// Revision 1.5 2002/10/18 21:56:28 klaus |
+// completed functional features, untested |
+// |
+// Revision 1.4 2002/10/17 21:16:03 klaus |
+// filled function bodies |
+// |
+// Revision 1.3 2002/10/17 21:16:03 klaus |
+// filled function bodies |
+// |
+// Revision 1.2 2002/10/17 19:05:03 klaus |
+// VME access is working through test to lib to driver |
+// |
+// Revision 1.1 2002/10/12 22:04:44 klaus |
+// first work done |
+// |
+// what who when |
+// first steps AR 17.11.1999 |
+// VMEerror new AR 07.01.2000 |
+// made LINUX shared library from windows template AR 12.10.2002 |
+// |
+ |
+//------------------------------------------------------------------------------------------- |
+// INCLUDES |
+// |
+#define BOOLEAN int |
+#if !defined(TRUE) && !defined(FALSE) |
+ #define FALSE 0 |
+ #define TRUE 1 |
+#endif |
+ |
+//------------------------------------------------------------------------------------------- |
+// PROTOTYPES |
+// |
+#ifdef __cplusplus |
+extern "C" |
+{ |
+#endif |
+int VMEopen(const char *cszDeviceName, unsigned char ubAddressModifier, int *pnHandle); |
+int VMEinit(const char *cszDeviceName, unsigned short nVMEMM, unsigned char ubAddressModifier, int *pnHandle); |
+int setAccessProperties(int nHandle, unsigned char bModifier, unsigned char bAccessType); |
+int VMEread(int nHandle, unsigned long ulAddress, unsigned char ubAccessWidth, unsigned long ulElementCount, void *pvBuffer); |
+int VMEwrite(int nHandle, unsigned long ulAddress, unsigned char ubAccessWidth, unsigned long ulElementCount, void *pvBuffer); |
+int VMEaccessVIC(int nHandle, unsigned char ubAccessMode, unsigned short uwAddress, unsigned char *ubContent); |
+int VMEreset(int nHandle); |
+int VMETAS(int nHandle, unsigned long ulAddress, unsigned char *ubResult); |
+int VMEcontrolInterrupt(int nHandle, BOOLEAN *bEnable); |
+int VMEinterrupt(int nHandle, unsigned char *ubVector); |
+int VMEsysfailGet(int nHandle, BOOLEAN *bResult); |
+int VMEsysfailSet(int nHandle, BOOLEAN bForce); |
+int VMEerror(int nHandle); |
+int VMEclose(int nHandle); |
+int GetLastError(int nHandle); |
+#ifdef __cplusplus |
+} |
+#endif |
+ |
+#endif /* __PCIVME_NI_H__ */ |
Index: praktikum/petdaqfmf/wienvmeusb_dll.c |
=================================================================== |
--- praktikum/petdaqfmf/wienvmeusb_dll.c (nonexistent) |
+++ praktikum/petdaqfmf/wienvmeusb_dll.c (revision 112) |
@@ -0,0 +1,98 @@ |
+#include <stdlib.h> |
+#include <stdio.h> |
+#include "pcivme_ni.h" |
+#include "wienvme_dll.h" |
+//----------- DEFINES ----------------------------------------------------- |
+#define DEVICENAME_LINUX "/dev/vmemm_1" // a device name 'template' for WINNT |
+ |
+usb_dev_handle *udev; |
+ |
+ |
+ |
+ |
+int VME_start (char* serial) |
+{ |
+ |
+ char serial_default[100]; |
+ sprintf(serial_default, "VM0120"); |
+ if (serial != NULL) |
+ udev = xxusb_serial_open(serial); |
+ else |
+ udev = xxusb_serial_open(serial_default); |
+ printf(" VME_start %s--->udev!=NULL ==>%d\n", serial, udev!=NULL); |
+ if (!udev) { |
+ printf(" Check usb udev permissions and restart! Exiting .....\n", serial, udev!=NULL); |
+ exit(-1); |
+ } |
+ return 0; |
+} |
+ |
+ |
+ |
+int VME_stop () |
+{ |
+ if (udev) xxusb_device_close(udev); |
+ |
+ |
+ return 0; |
+} |
+ |
+short Address_Modifier= Std_NoPriv_Data; |
+ |
+int VME_read16 (Uint32_t at, void* buff) |
+{ |
+ int result; |
+ |
+/* D16 read */ |
+ |
+ result = VME_read_16(udev, Address_Modifier, at , (Uint32_t *) buff); |
+ if (result <0) { |
+ printf("D16 read at 0x%X failed! err=%d\n", at,result); |
+ } |
+// printf("0x%X, 0x%X, 0x%X, 0x%X\n", hHandle, at, n, * (unsigned short *) buff); |
+ return (result); |
+} |
+ |
+int VME_read32 (Uint32_t at, void* buff) |
+{ |
+ int result; |
+ |
+/* D32 read */ |
+ |
+ result = VME_read_32(udev, Address_Modifier, at , (Uint32_t *) buff); |
+ if (result < 0) { |
+ printf("D32 read at 0x%X failed err=%d!\n", at,result); |
+ } |
+ //printf("0x%X, 0x%X, 0x%X, 0x%X\n", hHandle, at, n, * (unsigned short *) buff); |
+ return (result); |
+} |
+ |
+int VME_write16 (Uint32_t at, void* buff) |
+{ |
+ int result; |
+ Uint32_t data= *((short *)buff); |
+ |
+/* D16 write */ |
+ |
+ result = VME_write_16(udev, Address_Modifier, at, data ); |
+ if (result<0) { |
+ printf("D16 write at 0x%X failed! err=%d\n", at,result); |
+ } |
+ return (result); |
+} |
+ |
+int VME_write32 ( Uint32_t at, void* buff) |
+{ |
+ int result; |
+ Uint32_t data= *((Uint32_t *)buff); |
+ |
+/* D32 write */ |
+ |
+ result = VME_write_32(udev, Address_Modifier, at, data ); |
+ |
+ if (result<0) { |
+ printf("D32 write at 0x%X failed! err=%d\n", at,result); |
+ } |
+ //printf("D32 write at 0x%lX buff=0x%X\n", at,((int*) buff)[0]); |
+ return (result); |
+} |
/praktikum/petdaqfmf/wienvmeusb_dll.c |
Property changes: |
Added: svn:executable |
Index: praktikum/petdaqfmf/LinkDef.h |
=================================================================== |
--- praktikum/petdaqfmf/LinkDef.h (nonexistent) |
+++ praktikum/petdaqfmf/LinkDef.h (revision 112) |
@@ -0,0 +1,10 @@ |
+#ifdef __CINT__ |
+ |
+#pragma link off all globals; |
+#pragma link off all classes; |
+#pragma link off all functions; |
+ |
+#pragma link C++ class daq; |
+ |
+#endif |
+ |
Index: praktikum/petdaqfmf/VmUsbStack.C |
=================================================================== |
--- praktikum/petdaqfmf/VmUsbStack.C (nonexistent) |
+++ praktikum/petdaqfmf/VmUsbStack.C (revision 112) |
@@ -0,0 +1,124 @@ |
+#include <stdio.h> |
+#include <vector> |
+#include "VmUsbStack.h" |
+ |
+VmUsbStack::VmUsbStack(){ |
+ fStack.push_back(0x1); |
+ fStack.push_back(0x0); |
+} |
+ |
+VmUsbStack::~VmUsbStack(){ |
+ fStack.clear(); |
+} |
+ |
+int VmUsbStack::Get(int maxn, int *stack){ |
+ for (int i=0;i<fStack.size();i++){ |
+ if (i<maxn) stack[i]=fStack[i]; else return -1; |
+ } |
+ return fStack[0]; |
+} |
+ |
+ |
+void VmUsbStack::Append(int cmd, int addr ){ |
+ fStack.push_back(cmd & 0xFFFF); |
+ fStack.push_back(cmd >> 16); |
+ fStack.push_back(addr&0xFFFF); |
+ fStack.push_back((addr >> 16)& 0xFFFF); |
+ fStack[0]=fStack.size()-1; |
+} |
+ |
+void VmUsbStack::Append(int cmd, int addr , int data){ |
+ Append( cmd, addr ); |
+ fStack.push_back(data&0xFFFF); |
+ fStack.push_back((data >> 16)&0xFFFF); |
+ fStack[0] = fStack.size()-1; |
+} |
+ |
+void VmUsbStack::ReadA24D16(int addr ){ |
+ Append(CMD_READ | CMD_A24 , CMD_D16 | addr); |
+} |
+ |
+void VmUsbStack::WriteA24D16(int addr, int data){ |
+ return Append(CMD_WRITE | CMD_A24,CMD_D16 | addr, data); |
+} |
+ |
+void VmUsbStack::ReadA24D32(int addr ){ |
+ Append(CMD_READ | CMD_A24 , CMD_D32 | addr); |
+} |
+ |
+void VmUsbStack::WriteA24D32(int addr, int data){ |
+ return Append(CMD_WRITE | CMD_A24 , CMD_D32 | addr, data); |
+} |
+ |
+void VmUsbStack::ReadA32D16(int addr ){ |
+ Append(CMD_READ | CMD_A32 , CMD_D16| addr); |
+} |
+ |
+void VmUsbStack::WriteA32D16(int addr, int data){ |
+ return Append(CMD_WRITE | CMD_A32 , CMD_D16 | addr, data); |
+} |
+ |
+void VmUsbStack::ReadA32D32(int addr ){ |
+ Append(CMD_READ | CMD_A32 , CMD_D32 | addr); |
+} |
+ |
+void VmUsbStack::WriteA32D32(int addr, int data){ |
+ return Append(CMD_WRITE | CMD_A32 , CMD_D32| addr, data); |
+} |
+ |
+ |
+void VmUsbStack::Marker(int marker){ |
+ return Append(CMD_MRK, marker); |
+} |
+ |
+void VmUsbStack::ConditionalRead(int adr_mod,int d16d32, int addr, int bmask){ |
+ Append(CMD_READ| CMD_HD | adr_mod ,addr); |
+ Append(CMD_READ| CMD_HD | CMD_HM |adr_mod, d16d32 |addr,bmask); |
+} |
+ |
+void VmUsbStack::RepeatRead(int adr_mod,int d16d32, int baseaddr, int n, int increment){ |
+ for (int i=0;i<n;i++) Append( adr_mod | CMD_READ, d16d32 +baseaddr + i*increment); |
+} |
+void VmUsbStack::RepeatWrite(int adr_mod,int d16d32,int baseaddr, int n, int increment, int data){ |
+ for (int i=0;i<n;i++) Append( adr_mod | CMD_WRITE,d16d32 + baseaddr+i*increment, data); |
+} |
+ |
+void VmUsbStack::Print(){ |
+ for (int i=0; i < fStack.size();i++) printf("0x%04x\n",fStack[i]); |
+ printf("%d %d __________________________________\n",fStack.size(),fStack[0]); |
+} |
+ |
+#ifdef MAIN |
+#include "CAENV965_DEF.h" |
+#define CAEN_V965 0x340000 |
+ |
+int main(){ |
+// INIT stackdata |
+int geo=1,fPedestal=255; |
+VmUsbStack *init=new VmUsbStack(); |
+init->Write(CAEN_V965 + CAENV965_CRN, 0x0); |
+init->Write(CAEN_V965 + CAENV965_GEO, geo); |
+init->RepeatWrite( CAEN_V965 + CAENV965_THM, 32, 0x02,0x0); // threshold/kill for 32 channels, 2*i addr increment |
+init->Write( CAEN_V965 + CAENV965_BS1, 0x80 ); // soft reset |
+init->Write( CAEN_V965 + CAENV965_BC1, 0x80 ); // soft reset |
+init->Write( CAEN_V965 + CAENV965_PED, fPedestal ); // pedestal |
+init->Write(CAEN_V965 + CAENV965_BS2,0x5000); |
+init->Write(CAEN_V965 + CAENV965_BS2,0x4); // clear module |
+init->Write(CAEN_V965 + CAENV965_BC2,0x4); |
+init->Print(); |
+ |
+// READOUT stackdata |
+VmUsbStack *stack=new VmUsbStack(); |
+stack->Write(CAEN_V965 + CAENV965_BS2,0x4); // clear module |
+stack->Write(CAEN_V965 + CAENV965_BC2,0x4); |
+stack->ConditionalRead(CAEN_V965 + CAENV965_SR1,0x1); // TRG wait : loop until bit 0 is on |
+stack->ConditionalRead(CAEN_V965 + CAENV965_OB ,0x4000000) ; // loop until bit 26 is on, read data |
+stack->Marker(0xFAFB); |
+stack->Print(); |
+ |
+ int st[1000]; |
+ int nb= stack->Get(1000,st); |
+ for (int i=0;i<nb;i++) if (st[i]!=stack->fStack[i]) printf("error i=%d 0x%04x 0x%04x \n",i,st[i],stack->fStack[i] ); |
+ return 0; |
+} |
+#endif |
Index: praktikum/petdaqfmf/CAENV965_DEF.h |
=================================================================== |
--- praktikum/petdaqfmf/CAENV965_DEF.h (nonexistent) |
+++ praktikum/petdaqfmf/CAENV965_DEF.h (revision 112) |
@@ -0,0 +1,22 @@ |
+#ifndef _CAENV965_DEF_H |
+#define _CAENV965_DEF_H |
+ |
+#define CAENV965_OB 0x0 |
+#define CAENV965_FW 0x1000 |
+#define CAENV965_GEO 0x1002 |
+#define CAENV965_MCA 0x1004 |
+#define CAENV965_BS1 0x1006 |
+#define CAENV965_BC1 0x1008 |
+#define CAENV965_SR1 0x100E |
+#define CAENV965_CR1 0x1010 |
+#define CAENV965_ADH 0x1012 |
+#define CAENV965_ADL 0x1014 |
+#define CAENV965_SR2 0x1022 |
+#define CAENV965_BS2 0x1032 |
+#define CAENV965_BC2 0x1034 |
+#define CAENV965_CRN 0x103C |
+#define CAENV965_ECR 0x1040 |
+#define CAENV965_PED 0x1060 |
+#define CAENV965_THM 0x1080 |
+ |
+#endif |
Index: praktikum/petdaqfmf/gui.C |
=================================================================== |
--- praktikum/petdaqfmf/gui.C (nonexistent) |
+++ praktikum/petdaqfmf/gui.C (revision 112) |
@@ -0,0 +1,455 @@ |
+// By ROOT version 5.17/02 on 2008-03-13 06:46:41 |
+ |
+#ifndef ROOT_TGDockableFrame |
+#include "TGDockableFrame.h" |
+#endif |
+#ifndef ROOT_TGMenu |
+#include "TGMenu.h" |
+#endif |
+#ifndef ROOT_TGMdiDecorFrame |
+#include "TGMdiDecorFrame.h" |
+#endif |
+#ifndef ROOT_TG3DLine |
+#include "TG3DLine.h" |
+#endif |
+#ifndef ROOT_TGMdiFrame |
+#include "TGMdiFrame.h" |
+#endif |
+#ifndef ROOT_TGMdiMainFrame |
+#include "TGMdiMainFrame.h" |
+#endif |
+#ifndef ROOT_TGuiBldHintsButton |
+#include "TGuiBldHintsButton.h" |
+#endif |
+#ifndef ROOT_TGMdiMenu |
+#include "TGMdiMenu.h" |
+#endif |
+#ifndef ROOT_TGListBox |
+#include "TGListBox.h" |
+#endif |
+#ifndef ROOT_TGNumberEntry |
+#include "TGNumberEntry.h" |
+#endif |
+#ifndef ROOT_TGScrollBar |
+#include "TGScrollBar.h" |
+#endif |
+#ifndef ROOT_TGuiBldHintsEditor |
+#include "TGuiBldHintsEditor.h" |
+#endif |
+#ifndef ROOT_TRootBrowser |
+#include "TRootBrowser.h" |
+#endif |
+#ifndef ROOT_TGFrame |
+#include "TGFrame.h" |
+#endif |
+#ifndef ROOT_TGFileDialog |
+#include "TGFileDialog.h" |
+#endif |
+#ifndef ROOT_TGShutter |
+#include "TGShutter.h" |
+#endif |
+#ifndef ROOT_TGButtonGroup |
+#include "TGButtonGroup.h" |
+#endif |
+#ifndef ROOT_TGCanvas |
+#include "TGCanvas.h" |
+#endif |
+#ifndef ROOT_TGFSContainer |
+#include "TGFSContainer.h" |
+#endif |
+#ifndef ROOT_TGButton |
+#include "TGButton.h" |
+#endif |
+#ifndef ROOT_TGuiBldEditor |
+#include "TGuiBldEditor.h" |
+#endif |
+#ifndef ROOT_TGTextEdit |
+#include "TGTextEdit.h" |
+#endif |
+#ifndef ROOT_TGFSComboBox |
+#include "TGFSComboBox.h" |
+#endif |
+#ifndef ROOT_TGLabel |
+#include "TGLabel.h" |
+#endif |
+#ifndef ROOT_TGView |
+#include "TGView.h" |
+#endif |
+#ifndef ROOT_TRootGuiBuilder |
+#include "TRootGuiBuilder.h" |
+#endif |
+#ifndef ROOT_TGTab |
+#include "TGTab.h" |
+#endif |
+#ifndef ROOT_TGListView |
+#include "TGListView.h" |
+#endif |
+#ifndef ROOT_TGSplitter |
+#include "TGSplitter.h" |
+#endif |
+#ifndef ROOT_TGStatusBar |
+#include "TGStatusBar.h" |
+#endif |
+#ifndef ROOT_TGListTree |
+#include "TGListTree.h" |
+#endif |
+#ifndef ROOT_TGToolTip |
+#include "TGToolTip.h" |
+#endif |
+#ifndef ROOT_TGToolBar |
+#include "TGToolBar.h" |
+#endif |
+#ifndef ROOT_TRootEmbeddedCanvas |
+#include "TRootEmbeddedCanvas.h" |
+#endif |
+#ifndef ROOT_TCanvas |
+#include "TCanvas.h" |
+#endif |
+#ifndef ROOT_TGuiBldDragManager |
+#include "TGuiBldDragManager.h" |
+#endif |
+ |
+#include "Riostream.h" |
+#include "TApplication.h" |
+#include "TROOT.h" |
+#include "TSystem.h" |
+#include "TGraph.h" |
+#include "TH1F.h" |
+#include "daq.h" |
+ |
+TGTextButton *gTextButton[10]; |
+TCanvas *fCanvas; |
+TGMainFrame *fMain; |
+TGTextEntry *gFilename; |
+TGNumberEntry *gPedestal; |
+TGNumberEntry *gCh; |
+TGNumberEntry *gMaxEve; |
+TGNumberEntry *gNeve; |
+TGTextEntry *gTimeDisplay; |
+TGCheckButton *gCheckButton; |
+ |
+ |
+TRootEmbeddedCanvas *gCanvas; |
+#define MAXCH 32 |
+TH1F* gHisto[MAXCH]; |
+daq * gDaq; |
+#define WINDOW_NAME "ADC CAEN V965" |
+//---------------------------------------------------- |
+int UIRDimming(int state){ |
+ switch (state) { |
+ case 0: |
+ gTextButton[0]->SetEnabled(0); |
+ gTextButton[1]->SetEnabled(1); |
+ gTextButton[2]->SetEnabled(0); |
+ |
+ break; |
+ |
+ case 1: |
+ gTextButton[0]->SetEnabled(0); |
+ gTextButton[1]->SetEnabled(0); |
+ gTextButton[2]->SetEnabled(1); |
+ |
+ break; |
+ |
+ case 2: |
+ gTextButton[0]->SetEnabled(1); |
+ gTextButton[1]->SetEnabled(1); |
+ gTextButton[2]->SetEnabled(0); |
+ break; |
+ |
+ default: |
+ break; |
+ } |
+ return 0; |
+} |
+ |
+int fDebug; |
+void GetDebug(){ |
+ if ( gCheckButton->IsOn() ) fDebug=1; |
+ else fDebug=0; |
+} |
+ |
+int GetTime(char *x){ |
+ int ret; |
+ time_t rawtime; |
+ static time_t oldtime=-1; |
+ struct tm * timeinfo; |
+ time ( &rawtime ); |
+ ret = (oldtime==rawtime); |
+ timeinfo = localtime ( &rawtime ); |
+ sprintf(x,"%s",asctime (timeinfo)); |
+ int len=strlen(x); |
+ if (len) x[len-1]=0; |
+ return ret; |
+} |
+void MyTimer(){ |
+ char cmd[100]; |
+ if (!GetTime(cmd)){ |
+ if (gTimeDisplay) gTimeDisplay->SetText(cmd); |
+ if (gCanvas){ |
+ gCanvas->GetCanvas()->Modified(); |
+ gCanvas->GetCanvas()->Update(); |
+ } |
+ } |
+} |
+ |
+//---------------------------------------------------- |
+// thread function |
+int gStop=0; |
+#define BSIZE 10000 |
+unsigned long gBuf[BSIZE]; |
+void Run(){ |
+ printf("Start of Run\n" ); |
+ |
+ // odpremo datoteko za pisanje |
+ int counters[10]={0,0,0,0,0, 0,0,0,0,0}; |
+ char names[20][20]={"CAENV 1290","CAEN V965","LC2277","LC2277","LC2277"}; |
+ |
+ char fname[128]; |
+ sprintf(fname,"%s.dat",gFilename->GetText()); |
+ FILE *fp=fopen(fname,"w"); |
+ int neve = (int) gMaxEve->GetNumber(); |
+ int hdr[4]={1}; |
+ |
+ if (gDaq) gDaq->fStop=0; |
+ // zajem zeljenega kolicine podatkov |
+ for (int n=0;n<neve;n++){ |
+ if (!gDaq) break; |
+ int nb = gDaq->event(gBuf,BSIZE,counters,1); |
+ if (gDaq->fStop) break; |
+ // zapis v datoteko |
+ hdr[1]=nb+4*sizeof(int); |
+ hdr[2]=time(NULL); |
+ hdr[3]=n; |
+ |
+ fwrite(hdr, sizeof(int),4 , fp); |
+ if (nb) fwrite(gBuf, 1,nb, fp); |
+ // napolni histograme |
+ int nint= nb/4; |
+ |
+ int ii=0; |
+ |
+ while (ii<nint){ |
+ |
+ int recid=gBuf[ii++]; |
+ int len =gBuf[ii++]; |
+ unsigned int *dbuf= (unsigned int *)&gBuf[ii]; |
+ if (n%1000==0) printf("%d 0x%03x Len=%d\n",n,recid,len); |
+ unsigned short edge; |
+ |
+ if (recid==0x130){ |
+ for (int i=0; i<len; i++) { |
+ int dtype=(dbuf[i]>>25)&0x3; |
+ if (dtype==0) { |
+ int ch=(dbuf[i]>>17)&0xf; |
+ if (2*ch<MAXCH) { |
+ int rg=(dbuf[i]>>16)&0x1; |
+ int adc=dbuf[i]&0xfff; |
+ gHisto[2*ch+rg]->Fill(adc); |
+ // printf("V965 0x%08x nev=%4d %d. [ch=%2d] range=%d data=%d \n",dbuf[i],n,i,ch,rg,adc); |
+ } |
+ } |
+ } |
+ } // if (recid==0x130) |
+ ii+=len; |
+ } |
+ /* |
+ // decode |
+ |
+ int nint=nb/sizeof(int); |
+ |
+ for (int i=0;i<nint;i++){ |
+ unsigned short tdc = gBuf[i]&0xFFFF; |
+ unsigned short ch = (gBuf[i] >> 17 ) &0x1F; |
+ unsigned short edge = (gBuf[i] >> 16 ) &0x1; |
+ if (edge && ch < MAXCH) gHisto[ch]->Fill(tdc); |
+ if (fDebug) printf("nev=%4d %d. [ch=%2d] egde=%d data=%d",n,i,ch,edge,tdc); |
+ } |
+ */ |
+ gSystem->ProcessEvents(); |
+ MyTimer(); |
+ gNeve->SetNumber(n); |
+ } |
+ fclose(fp); |
+ UIRDimming(2); |
+ printf("End of MyThread neve=%d\n",neve); |
+ |
+} |
+ |
+ |
+int save2ascii(){ |
+ if (!gHisto[0]) return 0; |
+ char fname[128]; |
+ sprintf(fname,"%s.txt",gFilename->GetText()); |
+ FILE *fp= fopen(fname, "w"); |
+ fprintf(fp, "%s\n",WINDOW_NAME); |
+ char cmd[128]; |
+ GetTime(cmd); |
+ fprintf(fp, "Shranjeno: %s\n\n", cmd ); |
+ fprintf(fp, "Kanal hid=") ; |
+ for (int j=0;j<MAXCH;j++) fprintf(fp, "%d\t",j); |
+ fprintf(fp, "\n-------------------------------------------------\n"); |
+ for (int i=0;i<gHisto[0]->GetNbinsX();i++){ |
+ fprintf(fp, "%d\t",i); |
+ for (int j=0;j<MAXCH;j++) fprintf(fp, "%d\t",(int) gHisto[j]->GetBinContent(i+1)); |
+ fprintf(fp, "\n"); |
+ } |
+ fclose(fp); |
+ printf("Histogram content is dumped to the file %s\n",fname); |
+ return 0; |
+ } |
+ |
+void MyEventHandler(int i){ |
+ |
+ UIRDimming(i); |
+ |
+ switch (i) { |
+ case 0: // Init |
+ gDaq->fPedestal = (int)(gPedestal->GetNumber()); |
+ gDaq->init(); |
+ break; |
+ case 1: // Start |
+ Run(); |
+ case 2: // Stop |
+ gDaq->fStop=1; |
+ case 3: // ReDraw |
+ gCanvas->GetCanvas()->Modified(); |
+ gCanvas->GetCanvas()->Update(); |
+ break; |
+ case 4: // Clear |
+ for (int j=0;j<MAXCH;j++) if (gHisto[j]) gHisto[j]->Reset(); |
+ break; |
+ case 5: // Save |
+ save2ascii(); |
+ break; |
+ case 6: // Print |
+ gCanvas->GetCanvas()->SaveAs("zivljenjski_cas_mionov.pdf"); |
+ break; |
+ case 7: // exit |
+ gApplication->Terminate(0); |
+ break; |
+ } |
+ |
+} |
+ |
+int Redraw(long val=0){ |
+ unsigned int ch= (unsigned int)(gCh->GetNumber()); |
+ if (ch<MAXCH && gHisto[ch]) { |
+ gCanvas->GetCanvas()->cd(); |
+ gHisto[ch]->Draw(); |
+ gCanvas->GetCanvas()->Modified(); |
+ gCanvas->GetCanvas()->Update(); |
+ } else { |
+ if (gCh->GetNumber()>=MAXCH) gCh->SetNumber(MAXCH-1); |
+ if (gCh->GetNumber()< 0) gCh->SetNumber(0); |
+ } |
+ return 0; |
+} |
+//---------------------------------------------------- |
+ |
+int gui(){ |
+ |
+ for (int i=0;i<MAXCH;i++){ |
+ char hname[50]; |
+ sprintf(hname,"Ch. %d Rg.%d;ADC;N",i/2,i%2); |
+ char hn[50]; |
+ sprintf(hn,"ch%d",i); |
+ gHisto[i] = new TH1F(hn,hname,4096,-0.5,4095.5); |
+ } |
+ gDaq= new daq(); |
+ fMain = new TGMainFrame(0,800,800); |
+ TGHorizontalFrame *fH=new TGHorizontalFrame(fMain,800,400); |
+ //------------------------------------------------------------ |
+ TGLayoutHints *f0= new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2); |
+ TGLayoutHints *layout2= new TGLayoutHints(kLHintsLeft | kLHintsTop,20,20,20,20); |
+ // gumbi |
+ |
+ int nbut=8; |
+ const char *names[10]={"Init","Start","Stop","Refresh","Clear","Save", "Print" , "Exit"}; |
+ for (int i=0;i<nbut;i++){ |
+ |
+ gTextButton[i]= new TGTextButton(fH, names[i]); |
+ gTextButton[i]->SetTextJustify(36); |
+ gTextButton[i]->SetMargins(0,0,0,0); |
+ gTextButton[i]->SetWrapLength(-1); |
+ gTextButton[i]->Resize(50,22); |
+ fH->AddFrame(gTextButton[i], layout2); |
+ char cmd[50]; |
+ sprintf(cmd,"MyEventHandler(=%d)",i); |
+ TQObject::Connect(gTextButton[i],"Clicked()",0,0,cmd); |
+ } |
+ |
+ gCheckButton = new TGCheckButton( fH,"Debug"); |
+ gCheckButton->Resize(50,22); |
+ TQObject::Connect(gCheckButton,"Clicked()", 0, 0 , "GetDebug()"); |
+ gCheckButton->SetState(kButtonDown); |
+ fH->AddFrame(gCheckButton, f0); |
+ |
+ fMain->AddFrame(fH , f0); |
+ //--------------------------------------------------------- |
+ // ura |
+ TGLabel *lab1; |
+ fH=new TGHorizontalFrame(fMain,800,200); |
+ lab1 = new TGLabel( fH ,"Time:"); |
+ fH->AddFrame(lab1, f0); |
+ gTimeDisplay = new TGTextEntry( fH,""); |
+ gTimeDisplay->Resize(200,22); |
+ fH->AddFrame(gTimeDisplay, f0); |
+ fMain->AddFrame(fH , f0); |
+ //--------------------------------------------------------- |
+ // inputi |
+ fH=new TGHorizontalFrame(fMain,800,200); |
+ lab1 = new TGLabel( fH ,"Filename:"); |
+ fH->AddFrame(lab1, f0); |
+ gFilename = new TGTextEntry( fH,"filename"); |
+ gFilename->Resize(200,22); |
+ fH->AddFrame(gFilename, f0); |
+ fMain->AddFrame(fH , f0); |
+ //--------------------------------------------------------- |
+ fH=new TGHorizontalFrame(fMain,800,200); |
+ lab1 = new TGLabel( fH ,"ADC Pedestal:"); |
+ fH->AddFrame(lab1, f0); |
+ gPedestal = new TGNumberEntry( fH,100); |
+ gPedestal->Resize(100,22); |
+ fH->AddFrame(gPedestal, f0); |
+ fMain->AddFrame(fH , f0); |
+ //--------------------------------------------------------- |
+ fH=new TGHorizontalFrame(fMain,800,200); |
+ lab1 = new TGLabel( fH ,"N of events to acquire:"); |
+ fH->AddFrame(lab1, f0); |
+ gMaxEve = new TGNumberEntry( fH,10000); |
+ gMaxEve->Resize(100,22); |
+ fH->AddFrame(gMaxEve, f0); |
+ fMain->AddFrame(fH , f0); |
+ //--------------------------------------------------------- |
+ fH=new TGHorizontalFrame(fMain,800,200); |
+ lab1 = new TGLabel( fH ,"Number of events:"); |
+ fH->AddFrame(lab1, f0); |
+ gNeve = new TGNumberEntry( fH,0); |
+ gNeve->Resize(100,22); |
+ fH->AddFrame(gNeve, f0); |
+ fMain->AddFrame(fH , f0); |
+ //--------------------------------------------------------- |
+ // canvas |
+ fH=new TGHorizontalFrame(fMain,800,200); |
+ gCanvas = new TRootEmbeddedCanvas ("gCanvas",fH,800,400); |
+ fH->AddFrame(gCanvas, f0); |
+ fMain->AddFrame(fH , f0); |
+ //------------------------------------------------------------ |
+ fH=new TGHorizontalFrame(fMain,800,200); |
+ lab1 = new TGLabel( fH ,"Channel number (0..31):"); |
+ fH->AddFrame(lab1, f0); |
+ gCh = new TGNumberEntry( fH,0); |
+ fH->AddFrame(gCh, f0); |
+ TQObject::Connect(gCh,"ValueSet(Long_t)",0,0,"Redraw(Long_t )"); |
+ |
+ fMain->AddFrame(fH , f0); |
+ //------------------------------------------------------------ |
+ fMain->SetWindowName(WINDOW_NAME); |
+ fMain->MapSubwindows(); |
+ fMain->Resize(fMain->GetDefaultSize()); |
+ fMain->MapWindow(); |
+ Redraw(); |
+ GetDebug(); |
+ return 0; |
+} |
Index: praktikum/petdaqfmf/VmUsbStack.h |
=================================================================== |
--- praktikum/petdaqfmf/VmUsbStack.h (nonexistent) |
+++ praktikum/petdaqfmf/VmUsbStack.h (revision 112) |
@@ -0,0 +1,45 @@ |
+#ifndef VMUSBSTACK_H |
+#define VMUSBSTACK_H |
+#define CMD_WRITE 0x000 |
+#define CMD_READ 0x100 |
+#define CMD_A24 0x039 |
+#define CMD_A32 0x009 |
+#define CMD_HM 0x80000 |
+#define CMD_HD 0x20000 |
+#define CMD_MRK 0x2000 |
+#define CMD_DLY 0x8000 |
+#define CMD_BLT 0xFF000000 |
+ |
+#define CMD_D16 1 |
+#define CMD_D32 0 |
+ |
+#include <vector> |
+class VmUsbStack { |
+ public: |
+ VmUsbStack(); |
+ ~VmUsbStack(); |
+ std::vector<int> fStack; |
+ void Append(int cmd, int marker); |
+ void Append(int cmd, int addr, int data); |
+ |
+ void Marker(int marker); |
+ void WriteA32D16(int addr, int data); |
+ void ReadA32D16(int addr ); |
+ void WriteA32D32(int addr, int data); |
+ void ReadA32D32(int addr ); |
+ |
+ void WriteA24D16(int addr, int data); |
+ void ReadA24D16(int addr ); |
+ void WriteA24D32(int addr, int data); |
+ void ReadA24D32(int addr ); |
+ |
+ void ConditionalRead(int am ,int d16d32,int addr, int data); |
+ void RepeatRead(int addr_modifier,int d16d32, int baseaddr, int n, int increment); |
+ void RepeatWrite(int addr_modifier,int d16d32, int baseaddr, int n, int increment, int data); |
+ |
+ int Get(int maxn, int *stack); |
+ void Print(); |
+}; |
+ |
+ |
+#endif |
Index: praktikum/petdaqfmf/Dict.h |
=================================================================== |
--- praktikum/petdaqfmf/Dict.h (nonexistent) |
+++ praktikum/petdaqfmf/Dict.h (revision 112) |
@@ -0,0 +1,44 @@ |
+/******************************************************************** |
+* Dict.h |
+* CAUTION: DON'T CHANGE THIS FILE. THIS FILE IS AUTOMATICALLY GENERATED |
+* FROM HEADER FILES LISTED IN G__setup_cpp_environmentXXX(). |
+* CHANGE THOSE HEADER FILES AND REGENERATE THIS FILE. |
+********************************************************************/ |
+#ifdef __CINT__ |
+#error Dict.h/C is only for compilation. Abort cint. |
+#endif |
+#include <stddef.h> |
+#include <stdio.h> |
+#include <stdlib.h> |
+#include <math.h> |
+#include <string.h> |
+#define G__ANSIHEADER |
+#define G__DICTIONARY |
+#include "G__ci.h" |
+extern "C" { |
+extern void G__cpp_setup_tagtableDict(); |
+extern void G__cpp_setup_inheritanceDict(); |
+extern void G__cpp_setup_typetableDict(); |
+extern void G__cpp_setup_memvarDict(); |
+extern void G__cpp_setup_globalDict(); |
+extern void G__cpp_setup_memfuncDict(); |
+extern void G__cpp_setup_funcDict(); |
+extern void G__set_cpp_environmentDict(); |
+} |
+ |
+ |
+#include "TObject.h" |
+#include "TMemberInspector.h" |
+#include "daq.h" |
+#include <algorithm> |
+namespace std { } |
+using namespace std; |
+ |
+#ifndef G__MEMFUNCBODY |
+#endif |
+ |
+extern G__linked_taginfo G__DictLN_vectorlEintcOallocatorlEintgRsPgR; |
+extern G__linked_taginfo G__DictLN_VmUsbStack; |
+extern G__linked_taginfo G__DictLN_daq; |
+ |
+/* STUB derived class for protected member access */ |
Index: praktikum/petdaqfmf/vme.h |
=================================================================== |
--- praktikum/petdaqfmf/vme.h (nonexistent) |
+++ praktikum/petdaqfmf/vme.h (revision 112) |
@@ -0,0 +1,6 @@ |
+#ifndef _VME_H_ |
+#define _VME_H_ |
+ |
+#define _VI_FUNC |
+#include "wienvme_dll.h" |
+#endif |
Index: praktikum/petdaqfmf/Makefile |
=================================================================== |
--- praktikum/petdaqfmf/Makefile (nonexistent) |
+++ praktikum/petdaqfmf/Makefile (revision 112) |
@@ -0,0 +1,78 @@ |
+ |
+ROOTINC=$(shell root-config --incdir ) |
+ROOTLIB=$(shell root-config --libs ) |
+ |
+ |
+INC=-I. -I$(ROOTINC) |
+ |
+ |
+LIBS=$(ROOTLIB) -L./ -lm |
+LIBS1=$(shell root-config --libs --glibs ) |
+ |
+ |
+ |
+SRC = . |
+INC1 = -I. -I../lib -I/usr/include |
+DBG = |
+CFLAGS = $(DBG) $(INC1) -Wall |
+ |
+ |
+TARGET1 = daq |
+ |
+FILES1 = $(SRC)/daq.C |
+ |
+VMELIB = libf9vme.a |
+ |
+SHLIB = $(VMELIB) -lusb -lz |
+ |
+OBJ_FILES = VMEModule.o CAENV965.o libxxusb.o wienvmeusb_dll.o VmUsbStack.o |
+ |
+all: vme $(TARGET1) |
+ |
+libxxusb.o: libxxusb.cpp libxxusb.h |
+ |
+ |
+ |
+.cpp.o: |
+ $(CXX) -c -g $< |
+ ar r $(VMELIB) $@ |
+ |
+.C.o: |
+ $(CXX) -c -g $< |
+ ar r $(VMELIB) $@ |
+ |
+ |
+.cc.o: |
+ $(CXX) -c -g $< |
+ ar r $(VMELIB) $@ |
+ |
+.c.o: |
+ $(CXX) -c -g $< |
+ ar r $(VMELIB) $@ |
+ |
+vme: $(OBJ_FILES) |
+ |
+wienvme_dll.o: wienvme_dll.c |
+ |
+ |
+ |
+VMEModule.o: VMEModule.hh VMEModule.cc |
+ |
+CAENV965.o: CAENV965.h CAENV965_DEF.h CAENV965.c |
+ |
+ |
+$(TARGET1): $(FILES1) vme |
+ $(CXX) -DMAIN $(FILES1) $(CFLAGS) -o $(TARGET1) $(SHLIB) -lstdc++ |
+ |
+ |
+libdaq.so: $(FILES1) |
+ @echo "Generating dictionary Dict.C..." |
+ rootcint -f Dict.C -c $(INC) $(CPPFLAGS) daq.h LinkDef.h |
+ $(CXX) -DG__DICTIONARY $(CPPFLAGS) $(INC) -fPIC -g -Wall $(FILES1) Dict.C -L. $(SHLIB) -shared -o libdaq.so |
+ |
+clean: |
+ rm Dict.C libdaq.so $(TARGET1) |
+ |
+ |
+tgz: |
+ tar czvf vme.tgz Makefile *.c *.h *.C *.cc *.hh |