Subversion Repositories f9daq

Compare Revisions

Ignore whitespace Rev 264 → Rev 263

/cvi/apps/petdemo/vmusb.c
File deleted
/cvi/apps/petdemo/analyse.c
File deleted
/cvi/apps/petdemo/petdemo.c
File deleted
/cvi/apps/petdemo/ini/m16_reverse.map
File deleted
/cvi/apps/petdemo/ini/pedestals.dat
File deleted
/cvi/apps/petdemo/ini/fotovrh.dat
File deleted
/cvi/apps/petdemo/ini/m16.map
File deleted
/cvi/apps/petdemo/ini/sumpedestals.dat
File deleted
/cvi/apps/petdemo/ini/calibration_all.root
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
## -1 +0,0 ##
-application/octet-stream
\ No newline at end of property
Index: petdemo/ini/modules.map
===================================================================
--- petdemo/ini/modules.map (revision 264)
+++ petdemo/ini/modules.map (nonexistent)
@@ -1,5 +0,0 @@
-#module ID (connector) r(mm) angle(deg)
-0 61 0
-1 61 22.5
-2 61 180
-3 61 202.5
Index: petdemo/ini/config.xml
===================================================================
--- petdemo/ini/config.xml (revision 264)
+++ petdemo/ini/config.xml (nonexistent)
@@ -1,24 +0,0 @@
-<?xml version="1.0"?>
-<pet>
-
-<scintillator>
-<nofcrystalsx>9</nofcrystalsx>
-<nofcrystalsy>9</nofcrystalsy>
-<crystalpitchx>2.25</crystalpitchx>
-<crystalpitchy>2.25</crystalpitchy>
-</scintillator>
-
-<sensor>
-<modules>ini/modules.map</modules>
-<channels>ini/m16.map</channels>
-</sensor>
-
-<calibration>
-<sumpedestals>ini/sumpedestals.dat</sumpedestals>
-<pedestals>ini/pedestals_new.dat</pedestals>
-<photopeak>ini/fotovrh.dat</photopeak>
-<channelcalibration>ini/calibration_all.root</channelcalibration>
-<adcthreshold>300</adcthreshold>
-</calibration>
-
-</pet>
Index: petdemo/ini/pedestals_new.dat
===================================================================
--- petdemo/ini/pedestals_new.dat (revision 264)
+++ petdemo/ini/pedestals_new.dat (nonexistent)
@@ -1,64 +0,0 @@
-0 339.13
-1 354.26
-2 327.546
-3 282.69
-4 312.863
-5 365.795
-6 317.055
-7 316.198
-8 348.804
-9 337.947
-10 385.535
-11 341.414
-12 351.877
-13 346.92
-14 339.204
-15 334.106
-16 331.704
-17 333.163
-18 302.789
-19 319.067
-20 325.209
-21 348.417
-22 337.329
-23 326.671
-24 351.699
-25 348.799
-26 308.549
-27 286.519
-28 332.446
-29 324.031
-30 351.92
-31 342.048
-32 359.25
-33 325.419
-34 334.892
-35 322.25
-36 293.95
-37 354.971
-38 304.267
-39 370.495
-40 374.192
-41 347.656
-42 340.723
-43 311.266
-44 301.842
-45 320.301
-46 387.6
-47 318.137
-48 321.878
-49 348.859
-50 342.913
-51 332.14
-52 346.995
-53 350.787
-54 337.321
-55 329.6
-56 346.56
-57 303.365
-58 298.587
-59 302.891
-60 306.159
-61 293.716
-62 324.878
-63 341.973
Index: petdemo/ini/ph511.dat
===================================================================
--- petdemo/ini/ph511.dat (revision 264)
+++ petdemo/ini/ph511.dat (nonexistent)
@@ -1,84 +0,0 @@
-0 1700
-1 1900
-2 1680
-3 1700
-4 1870
-5 1680
-6 1430
-7 1460
-8 1680
-9 1700
-10 1713
-11 1650
-12 1630
-13 1830
-14 1750
-15 1740
-16 2440
-17 2320
-18 2640
-19 2500
-20 2790
-21 2600
-22 2900
-23 2820
-24 2660
-25 2470
-26 2310
-27 2330
-28 2817
-29 2860
-30 2140
-31 2140
-32 2120
-33 2410
-34 1990
-35 2480
-36 2200
-37 2100
-38 2040
-39 2060
-40 2090
-41 1970
-42 2032
-43 1970
-44 2054
-45 2120
-46 2076
-47 1920
-48 2206
-49 2420
-50 1930
-51 2290
-52 2400
-53 2425
-54 1950
-55 2400
-56 2076
-57 2010
-58 1792
-59 1830
-60 2000
-61 2032
-62 1640
-63 1614
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Index: petdemo/libxxusb.cpp
===================================================================
--- petdemo/libxxusb.cpp (revision 264)
+++ petdemo/libxxusb.cpp (nonexistent)
@@ -1,1651 +0,0 @@
-
-// 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>
-
-
-
-
-// 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 long stacks, up to 4 MBytes long, 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 long
- 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 long integers (32 bits).
- The latter option of passing a pointer to an array of unsigned long 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 long 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 long
- 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 long 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 long integers.
-
- Paramters:
- hdev: USB device handle returned from an open function
- DataBuffer: pointer to an array of long 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, long RegData)
-{
- long 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, long *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, long *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, long *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 long 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, long *RegData)
-{
-//long 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;
- long 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[7];
- 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)
- {
- udev = xxusb_device_open(dev);
- if (udev)
- {
- ret = usb_get_string_simple(udev, dev->descriptor.iSerialNumber, string, sizeof(string));
- if (ret >0 )
- {
- if (strcmp(string,SerialString)==0)
- return udev;
- }
- 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, long VME_Address, long Data)
-{
- long 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, long VME_Address, long *Data)
-{
- long 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, long VME_Address, long Data)
-{
- long 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, long VME_Address, long *Data)
-{
- long 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, long VME_Address, long Data[])
-{
- long 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, long VME_Address, long Data)
-{
- long 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, long VME_Address, long *Data)
-{
- long 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;
-// long internal;
- long 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,
- long delay, unsigned short gate, unsigned short invert, unsigned short latch)
-{
- long Data, DGData, Delay_ext;
- long 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;
-// long internal;
- long 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, long Data)
-{
- int F = 16;
- int N = 25;
- long intbuf[4];
- int ret;
-
- intbuf[0]=1;
- intbuf[1]=(long)(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, long *Data)
-{
- int F = 0;
- int N = 25;
- long intbuf[4];
- int ret;
-
- intbuf[0]=1;
- intbuf[1]=(long)(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;
- long Data;
- long internal;
- short ret;
- long 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;
-// long internal;
- long 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;
-// long internal;
- long 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, long 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, long *Data)
-{
- long intbuf[4];
- int ret;
- int N = 25;
- int F = 0;
- int A = 9;
-
- // CAMAC direct read function
- intbuf[0]=1;
- intbuf[1]=(long)(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, long Data, int *Q, int *X)
-{
- long intbuf[4];
- int ret;
-// CAMAC direct write function
- intbuf[0]=1;
- intbuf[1]=(long)(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, long *Data, int *Q, int *X)
-{
- long intbuf[4];
- int ret;
- // CAMAC direct read function
- intbuf[0]=1;
- intbuf[1]=(long)(F+A*32+N*512 + 0x4000);
- 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)
-{
- long intbuf[4];
- int ret;
-// CAMAC Z = N(28) A(8) F(29)
- intbuf[0]=1;
- intbuf[1]=(long)(29+8*32+28*512 + 0x4000);
- ret = xxusb_stack_execute(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)
-{
- long intbuf[4];
- int ret;
- intbuf[0]=1;
- intbuf[1]=(long)(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)
-{
- long intbuf[4];
- int ret;
- intbuf[0]=1;
- if (inhibit) intbuf[1]=(long)(24+9*32+29*512 + 0x4000);
- else intbuf[1]=(long)(26+9*32+29*512 + 0x4000);
- ret = xxusb_stack_execute(hdev, intbuf);
- return ret;
-}
-
-
Index: petdemo/petdemo_uir.h
===================================================================
--- petdemo/petdemo_uir.h (revision 264)
+++ petdemo/petdemo_uir.h (nonexistent)
@@ -1,61 +0,0 @@
-/**************************************************************************/
-/* LabWindows/CVI User Interface Resource (UIR) Include File */
-/* */
-/* WARNING: Do not add to, delete from, or otherwise modify the contents */
-/* of this include file. */
-/**************************************************************************/
-
-#include <userint.h>
-
-#ifdef __cplusplus
- extern "C" {
-#endif
-
- /* Panels and Controls: */
-
-#define P1 1
-#define P1_EXIT 2 /* control type: command, callback function: ExitCB */
-#define P1_STOP 3 /* control type: command, callback function: StopCB */
-#define P1_START 4 /* control type: command, callback function: StartCB */
-#define P1_CPOSITION 5 /* control type: numeric, callback function: (none) */
-#define P1_NFI 6 /* control type: numeric, callback function: (none) */
-#define P1_DFI 7 /* control type: numeric, callback function: (none) */
-#define P1_FI0 8 /* control type: numeric, callback function: (none) */
-#define P1_CEVE 9 /* control type: numeric, callback function: (none) */
-#define P1_DAQTIME 10 /* control type: numeric, callback function: (none) */
-#define P1_GXY 11 /* control type: graph, callback function: (none) */
-#define P1_GSUMADC 12 /* control type: graph, callback function: (none) */
-#define P1_GADC 13 /* control type: graph, callback function: (none) */
-#define P1_GSINOGRAM 14 /* control type: graph, callback function: (none) */
-#define P1_PROGRESS 15 /* control type: slide, callback function: (none) */
-#define P1_STAGELED 16 /* control type: LED, callback function: (none) */
-#define P1_STDIO 17 /* control type: textBox, callback function: (none) */
-#define P1_FILENAME 18 /* control type: string, callback function: (none) */
-#define P1_DEBUG 19 /* control type: radioButton, callback function: DebugCB */
-#define P1_CH 20 /* control type: numeric, callback function: RedrawCB */
-#define P1_TIMER 21 /* control type: timer, callback function: RedrawCB */
-#define P1_DAQRATE 22 /* control type: strip, callback function: (none) */
-
-
- /* Control Arrays: */
-
- /* (no control arrays in the resource file) */
-
-
- /* Menu Bars, Menus, and Menu Items: */
-
- /* (no menu bars in the resource file) */
-
-
- /* Callback Prototypes: */
-
-int CVICALLBACK DebugCB(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
-int CVICALLBACK ExitCB(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
-int CVICALLBACK RedrawCB(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
-int CVICALLBACK StartCB(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
-int CVICALLBACK StopCB(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
-
-
-#ifdef __cplusplus
- }
-#endif
Index: petdemo/config.ini
===================================================================
--- petdemo/config.ini (revision 264)
+++ petdemo/config.ini (nonexistent)
@@ -1,20 +0,0 @@
-[scintillator]
-
-nofcrystalsx=9
-nofcrystalsy=9
-crystalpitchx=2.25
-crystalpitchy=2.25
-
-
-[sensor]
-modules=ini/modules.map
-channels=ini/m16.map
-
-
-[calibration]
-
-sumpedestals=ini/sumpedestals.dat
-pedestals=ini/pedestals_new.dat
-photopeak=ini/fotovrh.dat
-channelcalibration=ini/calibration_all.root
-adcthreshold=300
Index: petdemo/PETProjDataMgr.c
===================================================================
--- petdemo/PETProjDataMgr.c (revision 264)
+++ petdemo/PETProjDataMgr.c (nonexistent)
@@ -1,645 +0,0 @@
-//
-// ../bin/FBP2D FBP2D.par
-//
-// ********************************************************************
-// * License and Disclaimer *
-// * *
-// * The GAMOS software is copyright of the Copyright Holders of *
-// * the GAMOS Collaboration. It is provided under the terms and *
-// * conditions of the GAMOS Software License, included in the file *
-// * LICENSE and available at http://fismed.ciemat.es/GAMOS/license .*
-// * These include a list of copyright holders. *
-// * *
-// * Neither the authors of this software system, nor their employing *
-// * institutes,nor the agencies providing financial support for this *
-// * work make any representation or warranty, express or implied, *
-// * regarding this software system or assume any liability for its *
-// * use. Please see the license in the file LICENSE and URL above *
-// * for the full disclaimer and the limitation of liability. *
-// * *
-// * This code implementation is the result of the scientific and *
-// * technical work of the GAMOS collaboration. *
-// * By using, copying, modifying or distributing the software (or *
-// * any work based on the software) you agree to acknowledge its *
-// * use in resulting scientific publications, and indicate your *
-// * acceptance of all terms of the GAMOS Software license. *
-// ********************************************************************
-//
-#include "PETProjDataMgr.h"
-
-
-static struct PETProjDataMgr mgr;
-
-void SetNPlanes(int n) {
- mgr.m_NOfPlanes=n;
-};
-void SetNBin(int n) {
- mgr.m_NOfBins=n;
-};
-void SetNAng(int n) {
- mgr.m_NOfAngles=n;
-};
-void SetDebug(int n) {
- mgr.m_Debug=n;
-};
-void SetNumberOfChannels(int n) {
- mgr.m_nch=n;
-};
-
-void SetRingDiameter( double x) {
- mgr.m_RingDiameter = x;
-};
-void SetAxialDistance( double x) {
- mgr.m_AxialDistance = x;
-};
-
-//----------------------------------------------------------------------
-
-//----------------------------------------------------------------------
-struct PETProjDataMgr *GetInstance() {
-
-
- return &mgr;
-
-}
-
-//-----------------------------------------------------------------------
-int PETProjDataMgrInit() {
-
- /*
- // ARGUMENTS:
- " cout << " -------------------------- \n"
- " Arguments convention: \n"
- " -a Axial FOV (mm), <theDist_axial=100.0> \n"
- " -d Diameter Transaxial FOV (mm), <m_RingDiameter=300.0> \n"
- " -i Type of the input file (by default: 0 = Arce_binary), <typeINfile=0> \n"
- " \n"
- " -m Maximum ring difference (by default: -1 = m_NOfPlanes), <m_MaxRingDifferenceiff> \n"
- " -n Name of output file, <m_Filename> \n"
- " -p Axial number of planes, <m_NOfPlanes> \n"
- " -r Number of bins, \"distancias\", <m_NOfBins> \n"
- // -s Span TO DO:span !!!!!
- " -t Number of angular views, \"direcciones\", <m_NOfAngles> \n"
- " -v Verbosity (by default: 0=silent, 3=debug), <verbos> \n"
- " -x Maximum number of coincidences to be stored (by default: -1 = no limit), <Max_Coinci> \n"
- " -o Output type (by default: 0 = mcc Interfile, 1 = STIR Interfile), <OutType> \n"
-
- " \n"
- " PET Reconstruction. CIEMAT 2009-11 \n"
- " mario.canadas@ciemat.es \n"
- " -------------------------- \n";
- */
-
- mgr.m_AxialDistance = (9-1)*2.25; // Axial pixel dimension*NOfPlanes
- mgr.m_RingDiameter = 100.0; // notranji premer peta
- mgr.m_NOfPlanes = 9; // stevilo ravnin
- mgr.m_NOfBins = 128; // stevilo binov v razdalji
- mgr.m_nch = 128; // stevilo padov okoli in okoli
- mgr.m_NOfAngles = fabs(mgr.m_nch)/2; // stevilo kotov = stevilo padov okoli in okoli /2
-
- mgr.m_MaxRingDifference = -1;
- //mgr.m_MaxRingDifference = 3; // najvecja razdalja med padi
- // toDo: theSpan = int(GmParameterMgr::GetInstance()->GetNumericValue("PET:ProjData:Span",1));
-
-
- mgr.m_OutFormat = 1; // 1.. projections 0 .. image
-
- mgr.m_Debug=1;
-
- if (mgr.m_MaxRingDifference==-1) mgr.m_MaxRingDifference=mgr.m_NOfPlanes-1;
-
-
- mgr.m_TotalAxialPlanes=mgr.m_NOfPlanes*mgr.m_NOfPlanes;
- if (mgr.m_OutFormat==1) mgr.m_TotalAxialPlanes= (2*mgr.m_NOfPlanes-1 - mgr.m_MaxRingDifference)*mgr.m_MaxRingDifference + mgr.m_NOfPlanes; // total number of Axial planes (segments*planes) in STIR format
-
- /*--- Initialize sino3D ---*/
- mgr.m_projections = (SINO_TYPE ** *) malloc(mgr.m_NOfBins*sizeof(SINO_TYPE **));
- for(int i=0; i<mgr.m_NOfBins; i++) {
- mgr.m_projections[i] = (SINO_TYPE **) malloc(mgr.m_NOfAngles*sizeof(SINO_TYPE *));
- for(int j=0; j<mgr.m_NOfAngles; j++) {
- mgr.m_projections[i][j] = (SINO_TYPE *) malloc(mgr.m_TotalAxialPlanes *sizeof(SINO_TYPE)); /// ! If mgr.m_OutFormat==1 (STIR output):Matrix size depends on the MAX_Ring_Difference
- for(int k=0; k<mgr.m_TotalAxialPlanes; k++) {
- mgr.m_projections[i][j][k]=0;
- }
- }
- }
-
- mgr.m_TotalProjectionCoincidences=0;
- mgr.m_TotalCoincidences=0;
- //OutputType = "pet";
- return 0;
-}
-
-//-----------------------------------------------------------------------
-void SetProjection( int axialplane, int id) {
- for(int i=0; i<mgr.m_NOfBins; i++) {
- for(int j=0; j<mgr.m_NOfAngles; j++) {
- mgr.m_projections[i][j][axialplane]=H2D_GetBinContent(id,i+1,j+1);
- }
- }
-
-}
-//-----------------------------------------------------------------------
-
-//-----------------------------------------------------------
-// from Gate
-//------------------------------------------------------------
-double ComputeSinogramS(double X1, double Y1, double X2, double Y2) {
- double s;
-
- double denom = (Y1-Y2) * (Y1-Y2) + (X2-X1) * (X2-X1);
-
- if (denom!=0.) {
- denom = sqrt(denom);
- s = ( X1 * (Y2-Y1) + Y1 * (X1-X2) ) / denom;
- } else {
- s = 0.;
- }
-
- double theta;
- if ((X1-X2)!=0.) {
- theta=atan((X1-X2) /(Y1-Y2));
- } else {
- theta=3.1416/2.;
- }
- if ((theta > 0.) && ((X1-X2) > 0.)) s = -s;
- if ((theta < 0.) && ((X1-X2) < 0.)) s = -s;
- if ( theta < 0.) {
- theta = theta+3.1416;
- s = -s;
- }
- return s;
-}
-
-
-void AddEvent( const HVector3 pos1 , const HVector3 pos2) {
- int z1_i, z2_i;
- //for discretization on the crystal: int x1_i, x2_i, y1_i, y2_i;
-
- double z1_abs=pos1.x[2]+mgr.m_AxialDistance/2;
- double z2_abs=pos2.x[2]+mgr.m_AxialDistance/2;
- double a, b, phi, dis;
- int phi_i, dis_i;
- int ring_diff;
-
- double _PI=2*asin(1);
-
- mgr.m_TotalCoincidences++;
-
- z1_i=(int)(mgr.m_NOfPlanes* z1_abs/mgr.m_AxialDistance); //round --> mgr.m_NOfPlanes+1 ...
- z2_i=(int)(mgr.m_NOfPlanes* z2_abs/mgr.m_AxialDistance);
-
- // control; if z_i out of range: return
-
- if ( (pos1.x[0]==pos2.x[0]) && (pos1.x[1]==pos2.x[1]) ) {
-#ifndef GAMOS_NO_VERBOSE
- if( mgr.m_Debug ) {
- printf( "AddEvent:WARNING! Event_1 == Event_2 ; x= %f y= %f z= %f\n", pos2.x[0], pos2.x[1], pos2.x[2] );
- }
-#endif
- return;
- }
-
- if ( (z1_i<0) || (z2_i<0) || (z1_i>= mgr.m_NOfPlanes) || (z2_i>= mgr.m_NOfPlanes) ) {
-#ifndef GAMOS_NO_VERBOSE
- if( mgr.m_Debug ) {
- printf("PETProjDataMgr::AddEvent:WARNING! Event out of bounds (Axial):");
- printf( "x1= %f y1= %f z1= %f ", pos1.x[0], pos1.x[1], pos1.x[2] );
- printf( "x2= %f y2= %f z2= %f \n", pos2.x[0], pos2.x[1], pos2.x[2] );
- }
-#endif
- return;
- }
-
- ring_diff = (int)fabs(z1_i-z2_i);
-
- // max ring difference; control:
- if (ring_diff > mgr.m_MaxRingDifference) {
-#ifndef GAMOS_NO_VERBOSE
- if( mgr.m_Debug ) {
- printf("PETProjDataMgr::AddEvent:WARNING! Event out of bounds (Max. Ring Diff.): %f>%f",ring_diff , mgr.m_MaxRingDifference );
- printf( "x1= %f y1= %f z1= %f ", pos1.x[0], pos1.x[1], pos1.x[2] );
- printf( "x2= %f y2= %f z2= %f \n", pos2.x[0], pos2.x[1], pos2.x[2] );
- }
-#endif
- return;
- }
-
- a=(double)(pos2.x[1]- pos1.x[1]);
- b=(double)(pos2.x[0]- pos1.x[0]);
-
- if (a==0.0) {
- phi=_PI*0.5;
- } else {
- phi=atan(b/a);
- }
-
- if (phi<0) phi = phi +_PI;
-
- dis=pos1.x[0]*cos(phi) - pos1.x[1]*sin(phi);
- //dis=ComputeSinogramS(pos1.x(), pos1.y(), pos2.x(), pos2.x());
- // control; transaxial FOV
- if ( fabs(dis) > mgr.m_RingDiameter*0.5 ) {
-#ifndef GAMOS_NO_VERBOSE
- if( mgr.m_Debug ) {
- printf("PETProjDataMgr::AddEvent:WARNING! Event out of bounds (Transaxial):" );
- printf( "x1= %f y1= %f z1= %f ", pos1.x[0], pos1.x[1], pos1.x[2] );
- printf( "x2= %f y2= %f z2= %f \n", pos2.x[0], pos2.x[1], pos2.x[2] );
- }
-#endif
- return;
- }
-
- dis = dis + mgr.m_RingDiameter*0.5;
-
- // discret values:
- phi_i=RoundRealToNearestInteger( (double)(mgr.m_NOfAngles-1)*phi/_PI );
- dis_i=RoundRealToNearestInteger( (double)(mgr.m_NOfBins-1)*dis/(double)mgr.m_RingDiameter );
-
- if ((phi_i>=mgr.m_NOfAngles) || (dis_i>=mgr.m_NOfBins)) return; // only possible "=" because 'round' check it..
-
- // OLD: (SRRB included) sino3D[dis_i][phi_i][ (z1_i+z2_i)+ring_diff*(mgr.m_NOfPlanes-1) ]++;
-
- int Zpos;
-
- if (mgr.m_OutFormat==0) {
- Zpos = (z1_i*mgr.m_NOfPlanes + z2_i);
- } else {
-
- if (z1_i>=z2_i) { // SIN Max Ring_Diff: Zpos= ( ((mgr.m_NOfPlanes-ring_diff)*(mgr.m_NOfPlanes-1-ring_diff))/2 + z2_i );
-
- Zpos= ( ((2*mgr.m_NOfPlanes-1 - mgr.m_MaxRingDifference - ring_diff)*(mgr.m_MaxRingDifference - ring_diff))/2 + z2_i);
-
- } else {
- Zpos= ( (mgr.m_TotalAxialPlanes) - ((2*mgr.m_NOfPlanes-1 - mgr.m_MaxRingDifference - ring_diff +1)*(mgr.m_MaxRingDifference - ring_diff +1))/2 + z1_i );
-
- }
- }
-
- mgr.m_projections[dis_i][phi_i][ Zpos ]++;
- mgr.m_TotalProjectionCoincidences++;
-
-#ifndef GAMOS_NO_VERBOSE
- if( mgr.m_Debug >1) {
- printf("PETProjDataMgr::AddEvent:");
- printf( "x1= %f y1= %f z1= %f ", pos1.x[0], pos1.x[1], pos1.x[2] );
- printf( "x2= %f y2= %f z2= %f \n", pos2.x[0], pos2.x[1], pos2.x[2] );
- printf("PETProjDataMgr::AddEvent: Sinogram pos.: distance(s)= %f angular view(phi)= %f Zpos= %f Segment (Ring diff.) =%f\n" , dis_i , phi_i, Zpos , ring_diff );
- }
-#endif
-
-
-}
-
-//-----------------------------------------------------------------------
-void PETProjDataMgrFree() {
- int i,j;
- if (mgr.m_projections){
- for(i=0; i<mgr.m_NOfBins; i++) {
- for(j=0; j<mgr.m_NOfAngles; j++) {
- if (mgr.m_projections[i][j]) free(mgr.m_projections[i][j]);
- mgr.m_projections[i][j]= NULL;
- }
- if (mgr.m_projections[i]) free(mgr.m_projections[i]);
- mgr.m_projections[i]= NULL;
-
- }
- free(mgr.m_projections);
- mgr.m_projections= NULL;
- }
-
-}
-
-
-//-----------------------------------------------------------------------
-void WriteInterfile(const char * Filename ) {
-
- char name_hv[512];
- char name_v[512];
- FILE *fp;
- if (mgr.m_OutFormat==0) {
-
- strcpy(name_hv, Filename);
- strcpy(name_v, Filename);
- strcat(name_hv, ".hv");
- strcat(name_v, ".v");
- fp = fopen(name_hv, "w");
-
- fprintf (fp, "!INTERFILE := \n");
- fprintf (fp, "name of data file := %s\n", name_v);
- fprintf (fp, "!GENERAL DATA := \n");
- fprintf (fp, "!GENERAL IMAGE DATA :=\n");
- fprintf (fp, "!type of data := tomographic\n");
- fprintf (fp, "!version of keys := 3.3\n");
- fprintf (fp, "!data offset in bytes := 0\n");
- fprintf (fp, "imagedata byte order := littleendian\n");
- fprintf (fp, "!PET STUDY (General) :=\n");
- fprintf (fp, "!PET data type := 3D-Sinogram\n");
- fprintf (fp, "process status := Reconstructed\n");
- fprintf (fp, "!number format := unsigned short\n");
- fprintf (fp, "!number of bytes per pixel := 2\n");
- fprintf (fp, "number of dimensions := 3\n");
- fprintf (fp, "matrix axis label [1] := x\n");
- fprintf (fp, "!matrix size [1] := %i\n",mgr.m_NOfBins);
- fprintf (fp, "scaling factor (mm/pixel) [1] := %f\n",(float)(mgr.m_RingDiameter/(mgr.m_NOfBins-1.0)));
-
- fprintf (fp, "matrix axis label [2] := y\n");
- fprintf (fp, "!matrix size [2] := %i\n",mgr.m_NOfAngles);
-
- fprintf (fp, "scaling factor (degree/pixel) [2] := %f\n",(float)(360./mgr.m_NOfAngles));
-
- fprintf (fp, "matrix axis label [3] := z\n");
- fprintf (fp, "!matrix size [3] := %i\n",mgr.m_NOfPlanes*mgr.m_NOfPlanes);
- fprintf (fp, "scaling factor (mm/pixel) [3] := %f\n",(float)(mgr.m_AxialDistance/(mgr.m_NOfPlanes-1.0)));
-
- fprintf (fp, "number of slices := %i\n",mgr.m_NOfPlanes*mgr.m_NOfPlanes);
- fprintf (fp, "number of time frames := 1\n");
- fprintf (fp, "image scaling factor[1] := 1\n");
- fprintf (fp, "data offset in bytes[1] := 0\n");
- fprintf (fp, "quantification units := 1\n");
- fprintf (fp, "!END OF INTERFILE := \n");
-
- fclose(fp);
- //(size_t)(mgr.m_NOfBins*mgr.m_NOfAngles*mgr.m_NOfPlanes*mgr.m_NOfPlanes);
-
- } else {
-
- strcpy(name_hv, Filename);
- strcpy(name_v, Filename);
-
- strcat(name_hv, ".hs"); // STIR extension: .hs .s
- strcat(name_v, ".s");
- fp =fopen(name_hv, "w");
-
- fprintf (fp, "!INTERFILE := \n");
- fprintf (fp, "name of data file := %s\n",name_v);
- fprintf (fp, "!GENERAL DATA := \n");
- fprintf (fp, "!GENERAL IMAGE DATA :=\n");
- fprintf (fp, "!type of data := PET\n");
- // fprintf (fp, "!version of keys := 3.3\n"); STIR format is not 3.3 (almost but not completely), ERROR in STIR if it is not removed
- // fprintf (fp, "!data offset in bytes := 0\n");
- fprintf (fp, "imagedata byte order := littleendian\n");
- fprintf (fp, "!PET STUDY (General) :=\n");
- fprintf (fp, "!PET data type := Emission\n");
- fprintf (fp, "applied corrections := {arc correction}\n"); // {none}\n");
- // fprintf (fp, "process status := Reconstructed\n");
- fprintf (fp, "!number format := unsigned integer\n");
- fprintf (fp, "!number of bytes per pixel := 2\n");
-
- fprintf (fp, "number of dimensions := 4\n");
- fprintf (fp, "matrix axis label [4] := segment\n");
- fprintf (fp, "!matrix size [4] := %i\n",mgr.m_MaxRingDifference*2 + 1);
- // fprintf (fp, "scaling factor (mm/pixel) [1] := %f\n",(float)(d_FOV/(mgr.m_NOfBins-1)));
- fprintf (fp, "matrix axis label [3] := axial coordinate\n");
- fprintf (fp, "!matrix size [3] := { ");
- if (mgr.m_MaxRingDifference==0) {
- fprintf (fp, "%i}\n", mgr.m_NOfPlanes);
- } else {
- int m;
- for(m=mgr.m_NOfPlanes-mgr.m_MaxRingDifference; m<=mgr.m_NOfPlanes; m++) fprintf (fp, "%i,", m);
- for(m=mgr.m_NOfPlanes-1; m>mgr.m_NOfPlanes-mgr.m_MaxRingDifference; m--) fprintf (fp, "%i,", m);
- fprintf (fp, "%i}\n", mgr.m_NOfPlanes-mgr.m_MaxRingDifference);
- }
- fprintf (fp, "matrix axis label [2] := view\n");
- fprintf (fp, "!matrix size [2] := %i\n",mgr.m_NOfAngles);
- fprintf (fp, "matrix axis label [1] := tangential coordinate\n");
- fprintf (fp, "!matrix size [1] := %i\n",mgr.m_NOfBins);
-
- fprintf (fp, "minimum ring difference per segment := {"); // TO DO : add SPAN (mgr.m_MaxRingDifferenceiff per seg. variable)
- fprintf (fp, "%i", -mgr.m_MaxRingDifference);
- int m;
- for(m=-mgr.m_MaxRingDifference+1; m<=mgr.m_MaxRingDifference; m++) fprintf (fp, ",%i", m);
- fprintf (fp, "}\n");
- fprintf (fp, "maximum ring difference per segment := {"); // TO DO : add SPAN (mgr.m_MaxRingDifferenceiff per seg. variable)
- fprintf (fp, "%i", -mgr.m_MaxRingDifference);
- for(m=-mgr.m_MaxRingDifference+1; m<=mgr.m_MaxRingDifference; m++) fprintf (fp, ",%i", m);
- fprintf (fp, "}\n");
-
- fprintf (fp, "inner ring diameter (cm) := %f\n", mgr.m_RingDiameter/10); // STIR Required parameter, now assigned to FOV (not detectors)
- fprintf (fp, "average depth of interaction (cm) := 0.0001\n");
- fprintf (fp, "default bin size (cm) := %f\n",0.1*((float)mgr.m_RingDiameter/((float)mgr.m_NOfBins-1.0)) );
- fprintf (fp, "number of rings := %i\n",mgr.m_NOfPlanes );
- fprintf (fp, "distance between rings (cm) := %f\n", 0.1*((float)mgr.m_AxialDistance/(float)(mgr.m_NOfPlanes-1)) ); // Axial pixel dimension
-
- fprintf (fp, "number of detectors per ring := %i\n",mgr.m_NOfAngles*2 );
- // fprintf (fp, "number of slices := %i\n",mgr.m_NOfPlanes*mgr.m_NOfPlanes);
- fprintf (fp, "number of time frames := 1\n");
- fprintf (fp, "image scaling factor[1] := 1\n");
- fprintf (fp, "data offset in bytes[1] := 0\n");
- fprintf (fp, "quantification units := 1\n");
- fprintf (fp, "!END OF INTERFILE := \n");
-
- fclose(fp);
-
- }
- int mbsize = mgr.m_NOfBins*mgr.m_NOfAngles*mgr.m_TotalAxialPlanes*sizeof(SINO_TYPE);
- mgr.m_Buffer = (SINO_TYPE *) malloc( mbsize );
-
- long unsigned int cont=0;
- int i,j,k;
-
- for(k=0; k<mgr.m_TotalAxialPlanes; k++) {
- for(j=0; j<mgr.m_NOfAngles; j++) {
- for(i=0; i<mgr.m_NOfBins; i++) {
- mgr.m_Buffer[cont]=mgr.m_projections[i][j][k];
- cont++;
- }
- }
- }
-
- fp=fopen(name_v, "wb");
-
- //printf(4096*sizeof(SINO_TYPE) );
- int nb=fwrite(mgr.m_Buffer,1,mbsize, fp);
- fclose(fp);
-
-#ifndef GAMOS_NO_VERBOSE
- printf("PETProjDataMgr::WriteInterfile: File name: %s\n", Filename );
- printf("PETProjDataMgr::WriteInterfile: Numer of bytes written: %d\n" , nb );
- printf("PETProjDataMgr::WriteInterfile: Planes = %d bins = %d ang_views = %d\n", mgr.m_NOfPlanes, mgr.m_NOfBins, mgr.m_NOfAngles );
- printf("PETProjDataMgr::WriteInterfile: Dimensions (mm): Transaxial FOV = %f ; Axial FOV = %f ; Transaxial_pix =%f ; Plane width = %f\n", mgr.m_RingDiameter , mgr.m_AxialDistance , mgr.m_RingDiameter/(mgr.m_NOfBins-1) , mgr.m_AxialDistance/(mgr.m_NOfPlanes-1) ); // Image Axial Pixel(ssrb) == 0.5*(Plane_Width);
- printf("... " );
-
- printf("PETProjDataMgr::WriteInterfile: Total Coinci: %d\n" , mgr.m_TotalCoincidences );
- printf("PETProjDataMgr::WriteInterfile: Sino3D Coinci: %d\n" ,mgr.m_TotalProjectionCoincidences );
-#endif
-
-}
-
-double Mag2(HVector3 x) {
- return x.x[0]*x.x[0]+x.x[1]*x.x[1]+x.x[2]*x.x[2];
-}
-
-
-double Mag(HVector3 x) {
- return sqrt(Mag2(x));
-}
-
-void SetPhi(HVector3 *r,double phi) {
-
-}
-void SetTheta(HVector3 *r,double phi) {
-
-}
-
-double Product(HVector3 a, HVector3 b) {
- double c=0;
- for (int i=0; i<3; i++) c += a.x[i] * b.x[i];
- return c;
-}
-
-HVector3 Multiply(double a, HVector3 b) {
- HVector3 c;
- for (int i=0; i<3; i++) c.x[i]= a* b.x[i];
- return c;
-}
-
-HVector3 Add(HVector3 a, HVector3 b) {
- HVector3 c;
- for (int i=0; i<3; i++) c.x[i]= a.x[i] + b.x[i];
- return c;
-}
-
-HVector3 Subtract(HVector3 a, HVector3 b) {
- HVector3 c;
- for (int i=0; i<3; i++) c.x[i]= a.x[i] - b.x[i];
- return c;
-}
-
-
-HVector3 Hits2Digits(const HVector3 r) {
- if (!mgr.m_nch) return r;
- float smear=0.5;
-
- if (mgr.m_nch<0) smear=Random(0,1);
-
- double angle = atan2(r.x[0],r.x[1]); // vrne kot med -pi in pi
- double twopi=2*Pi();
- if (angle<0) angle+=twopi;
-
- angle= ((int)(angle/twopi*fabs(mgr.m_nch))+smear)*twopi/fabs(mgr.m_nch);
- //(mgr.m_rnd->Rndm()-0.5)*mgr.m_AxialDistance;
- HVector3 x;
- x.x[0]=sin(angle);
- x.x[1]=cos(angle);
- x.x[2]=0;
- return x; // z coordinata ni cisto v redu
-
-}
-
-int FwdProject(double x,double y, double z, int nmax, int h) {
- HVector3 r;
- r.x[0]=x;
- r.x[1]=y;
- r.x[2]=z;
- int h2d=1;
- double tfac=mgr.m_RingDiameter*mgr.m_RingDiameter/4-Mag2(r);
- double rfac= mgr.m_AxialDistance/mgr.m_RingDiameter;
- for (int i=0; i<nmax; i++) {
-
- double phi= Random(0,Pi());
- HVector3 s;
- s.x[0]=1;
- s.x[1]=0;
- s.x[2]=0;
- SetPhi(&s,phi);
- double sign = (Random(0,1)>0.5)? 1 : 0;
- double theta = acos(Random(0,rfac));
- theta+=sign*Pi();
-
- SetTheta(&s,theta);
- double t=Product(r,s);
- HVector3 rx=Add(r,Multiply(-t,s));
-
- double d=sqrt(t*t+tfac);
-
- HVector3 r1= Add(rx,Multiply(d,s));
- HVector3 r2= Add(rx,Multiply(-d,s));
-
- //r1=Hits2Digits(r1);
- //r2=Hits2Digits(r2);
-
- HVector3 s1=Subtract(r2,r1);
- double s1len= Mag(s1);
- int niter=(int) (100*s1len/mgr.m_RingDiameter);
- for (int j=0; j<niter; j++) {
- r2=Add(r1,Multiply(Random(0,1),s1));
- if (h2d) H2D_Fill(h,r2.x[0],r2.x[1],1);
- else H3D_Fill(h,r2.x[0],r2.x[1],r2.x[2],1);
- }
- }
- return 0;
-}
-
-int FwdProject2d(int img, int h) {
-
- for (int i=0; i<H2D_GetNbinsX(img); i++) {
- double x_=H2D_GetXBinCenter( img, i+1 );
- for (int j=0; j<H2D_GetNbinsY(img); j++) {
- double y_=H2D_GetYBinCenter(img, j+1 );
- double density= H2D_GetBinContent(img,i+1,j+1);
- if (density>0) FwdProject(x_,y_,mgr.m_AxialDistance*(Random(-0.5,0.5)), density,h);
- }
- }
- return 0;
-}
-
-
-int FwdProject3d(int img, int h) {
-
- for (int i=0; i<H3D_GetNbinsX(img); i++) {
- double x_=H3D_GetXBinCenter( img, i+1 );
- for (int j=0; j<H3D_GetNbinsY(img); j++) {
- double y_=H3D_GetYBinCenter(img, j+1 );
- for (int k=0; k<H3D_GetNbinsZ(img); k++) {
- double z_=H3D_GetZBinCenter( img, k+1 );
- double density= H3D_GetBinContent(img, i+1,j+1,k+1);
- if (density>0) FwdProject(x_,y_,z_, density,h);
- }
- }
- }
- return 0;
-}
-
-
-int Phantom(int kaj) {
- int img = H2D_Init(1, "img","Original Image",100,-50,50,100,-50,50);
- int i=0;
-// izberi sliko 0: kroglice, 1: point source 2: central ball
- switch (kaj) {
-
- case 0:
- for (i=0; i<H2D_GetNbinsX(img); i++) {
- for (int j=0; j<H2D_GetNbinsY(img); j++) {
- double x_=H2D_GetXBinCenter( img, i+1 );
- double y_=H2D_GetYBinCenter( img, j+1 );
- double density=1000;
- if ((x_*x_+y_*y_)<6) H2D_SetBinContent(img, i+1,j+1,density);
-
- density=500;
- if ((x_-25)*(x_-25)+y_*y_<12) H2D_SetBinContent(img,i+1,j+1,density);
- density=2000;
- if ((y_-25)*(y_-25)+x_*x_<2) H2D_SetBinContent(img,i+1,j+1,density);
- }
- }
- break;
-
- case 2:
- for (i=0; i<H2D_GetNbinsX(img); i++) {
- for (int j=0; j<H2D_GetNbinsY(img); j++) {
- double x_=H2D_GetXBinCenter( img, i+1 );
- double y_=H2D_GetYBinCenter( img, j+1 );
- double density=1000;
- if ((x_*x_+y_*y_)<12.5) H2D_SetBinContent(img, i+1,j+1,density);
- }
- }
- break;
-
- case 1:
- H2D_Fill(img, 25,25,10000);
- break;
-
- }
-
- return img;
-}
Index: petdemo/libxxusb.lib
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/petdemo/libxxusb.lib
Property changes:
Deleted: svn:mime-type
## -1 +0,0 ##
-application/octet-stream
\ No newline at end of property
Index: petdemo/libxxusb.h
===================================================================
--- petdemo/libxxusb.h (revision 264)
+++ petdemo/libxxusb.h (nonexistent)
@@ -1,111 +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
-
-struct XXUSB_STACK
-{
-long Data;
-short Hit;
-short APatt;
-short Num;
-short HitMask;
-};
-
-struct XXUSB_CC_COMMAND_TYPE
-{
-short Crate;
-short F;
-short A;
-short N;
-long Data;
-short NoS2;
-short LongD;
-short HitPatt;
-short QStop;
-short LAMMode;
-short UseHit;
-short Repeat;
-short AddrScan;
-short FastCam;
-short NumMod;
-short AddrPatt;
-long HitMask[4];
-long 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, long *RegData);
-short xxusb_stack_read(usb_dev_handle *hDev, short StackAddr, long *StackData);
-short xxusb_stack_write(usb_dev_handle *hDev, short StackAddr, long *StackData);
-short xxusb_stack_execute(usb_dev_handle *hDev, long *StackData);
-short xxusb_register_write(usb_dev_handle *hDev, short RegAddr, long 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, long VME_Address, long Data);
-short VME_register_read(usb_dev_handle *hdev, long VME_Address, long *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, long 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, long VME_Address, long *Data);
-short VME_read_32(usb_dev_handle *hdev, short Address_Modifier, long VME_Address, long *Data);
-short VME_BLT_read_32(usb_dev_handle *hdev, short Address_Modifier, int count, long VME_Address, long Data[]);
-short VME_write_16(usb_dev_handle *hdev, short Address_Modifier, long VME_Address, long Data);
-short VME_write_32(usb_dev_handle *hdev, short Address_Modifier, long VME_Address, long 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, long *Data);
-short CAMAC_register_write(usb_dev_handle *hdev, int A, long 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, long *Data);
-short CAMAC_write_LAM_mask(usb_dev_handle *hdev, long Data);
-
-short CAMAC_write(usb_dev_handle *hdev, int N, int A, int F, long Data, int *Q, int *X);
-short CAMAC_read(usb_dev_handle *hdev, int N, int A, int F, long *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);
-
Index: petdemo/petdemo.prj
===================================================================
--- petdemo/petdemo.prj (revision 264)
+++ petdemo/petdemo.prj (nonexistent)
@@ -1,617 +0,0 @@
-[Project Header]
-Version = 1302
-Pathname = "/c/home/cvi/apps/petdemo/petdemo.prj"
-CVI Dir = "/c/program files/national instruments/cvi2013"
-CVI Shared Dir = "/C/Program Files/National Instruments/Shared/CVI"
-CVI Pub Local Dir = "/C/ProgramData/National Instruments/CVI2013"
-CVI Pub Global Dir = "/C/ProgramData/National Instruments/CVI"
-IVI Standard Root Dir = "/C/Program Files/IVI Foundation/IVI"
-VXIplug&play Framework Dir = "/C/Program Files/IVI Foundation/VISA/winnt"
-IVI Standard Root 64-bit Dir = "/C/Program Files/IVI Foundation/IVI"
-VXIplug&play Framework 64-bit Dir = "/C/Program Files/IVI Foundation/VISA/win64"
-Number of Files = 17
-Target Type = "Executable"
-Flags = 2064
-Copied From Locked InstrDrv Directory = False
-Copied from VXIPNP Directory = False
-Locked InstrDrv Name = ""
-Don't Display Deploy InstrDrv Dialog = False
-
-[Folders]
-Folder 0 = "User Interface Files"
-FolderEx 0 = "User Interface Files"
-Folder 1 = "Source Files"
-FolderEx 1 = "Source Files"
-Folder 2 = "Instrument Files"
-FolderEx 2 = "Instrument Files"
-Folder 3 = "Library Files"
-FolderEx 3 = "Library Files"
-Folder 4 = "Include Files"
-FolderEx 4 = "Include Files"
-
-[File 0001]
-File Type = "User Interface Resource"
-Res Id = 1
-Path Is Rel = True
-Path Rel To = "Project"
-Path Rel Path = "petdemo_uir.uir"
-Path = "/c/home/cvi/apps/petdemo/petdemo_uir.uir"
-Exclude = False
-Project Flags = 0
-Folder = "User Interface Files"
-Folder Id = 0
-
-[File 0002]
-File Type = "CSource"
-Res Id = 2
-Path Is Rel = True
-Path Rel To = "Project"
-Path Rel Path = "analyse.c"
-Path = "/c/home/cvi/apps/petdemo/analyse.c"
-Exclude = False
-Compile Into Object File = False
-Project Flags = 0
-Folder = "Source Files"
-Folder Id = 1
-
-[File 0003]
-File Type = "CSource"
-Res Id = 3
-Path Is Rel = True
-Path Rel To = "Project"
-Path Rel Path = "petdemo.c"
-Path = "/c/home/cvi/apps/petdemo/petdemo.c"
-Exclude = False
-Compile Into Object File = False
-Project Flags = 0
-Folder = "Source Files"
-Folder Id = 1
-
-[File 0004]
-File Type = "CSource"
-Res Id = 4
-Path Is Rel = True
-Path Rel To = "Project"
-Path Rel Path = "PETProjDataMgr.c"
-Path = "/c/home/cvi/apps/petdemo/PETProjDataMgr.c"
-Exclude = False
-Compile Into Object File = False
-Project Flags = 0
-Folder = "Source Files"
-Folder Id = 1
-
-[File 0005]
-File Type = "CSource"
-Res Id = 5
-Path Is Rel = True
-Path Rel To = "Project"
-Path Rel Path = "vmusb.c"
-Path = "/c/home/cvi/apps/petdemo/vmusb.c"
-Exclude = False
-Compile Into Object File = False
-Project Flags = 0
-Folder = "Source Files"
-Folder Id = 1
-
-[File 0006]
-File Type = "CSource"
-Res Id = 6
-Path Is Rel = True
-Path Rel To = "Project"
-Path Rel Path = "../../instr/WUSBVME_DLL/wusbvme_dll.c"
-Path = "/c/home/cvi/instr/WUSBVME_DLL/wusbvme_dll.c"
-Exclude = False
-Compile Into Object File = False
-Project Flags = 0
-Folder = "Source Files"
-Folder Id = 1
-
-[File 0007]
-File Type = "Function Panel"
-Res Id = 7
-Path Is Rel = True
-Path Rel To = "Project"
-Path Rel Path = "../../instr/HISTO/H1D.fp"
-Path = "/c/home/cvi/instr/HISTO/H1D.fp"
-Exclude = False
-Project Flags = 0
-Folder = "Instrument Files"
-Folder Id = 2
-
-[File 0008]
-File Type = "Function Panel"
-Res Id = 8
-Path Is Rel = True
-Path Rel To = "Project"
-Path Rel Path = "../../instr/HISTO/H2D.fp"
-Path = "/c/home/cvi/instr/HISTO/H2D.fp"
-Exclude = False
-Project Flags = 0
-Folder = "Instrument Files"
-Folder Id = 2
-
-[File 0009]
-File Type = "Function Panel"
-Res Id = 9
-Path Is Rel = True
-Path Rel To = "Project"
-Path Rel Path = "../../instr/HISTO/H3D.fp"
-Path = "/c/home/cvi/instr/HISTO/H3D.fp"
-Exclude = False
-Project Flags = 0
-Folder = "Instrument Files"
-Folder Id = 2
-
-[File 0010]
-File Type = "Function Panel"
-Res Id = 10
-Path Is Rel = True
-Path Rel To = "CVI"
-Path Rel To Override = "CVI"
-Path Rel Path = "toolslib/toolbox/inifile.fp"
-Path = "/c/Program Files/National Instruments/CVI2013/toolslib/toolbox/inifile.fp"
-Exclude = False
-Project Flags = 0
-Folder = "Instrument Files"
-Folder Id = 2
-
-[File 0011]
-File Type = "Function Panel"
-Res Id = 11
-Path Is Rel = True
-Path Rel To = "Project"
-Path Rel Path = "../../instr/uSMC/uSMC.fp"
-Path = "/c/home/cvi/instr/uSMC/uSMC.fp"
-Exclude = False
-Project Flags = 0
-Folder = "Instrument Files"
-Folder Id = 2
-
-[File 0012]
-File Type = "Library"
-Res Id = 12
-Path Is Rel = True
-Path Rel To = "Project"
-Path Rel Path = "../../instr/vme/msvc/libusb.lib"
-Path = "/c/home/cvi/instr/vme/msvc/libusb.lib"
-Exclude = False
-Project Flags = 0
-Folder = "Library Files"
-Folder Id = 3
-
-[File 0013]
-File Type = "Library"
-Res Id = 13
-Path Is Rel = True
-Path Rel To = "Project"
-Path Rel Path = "libxxusb.lib"
-Path = "/c/home/cvi/apps/petdemo/libxxusb.lib"
-Exclude = False
-Project Flags = 0
-Folder = "Library Files"
-Folder Id = 3
-
-[File 0014]
-File Type = "Library"
-Res Id = 14
-Path Is Rel = True
-Path Rel To = "Project"
-Path Rel Path = "../../instr/uSMC/msvc/USMCDLL.lib"
-Path = "/c/home/cvi/instr/uSMC/msvc/USMCDLL.lib"
-Exclude = False
-Project Flags = 0
-Folder = "Library Files"
-Folder Id = 3
-
-[File 0015]
-File Type = "Include"
-Res Id = 15
-Path Is Rel = True
-Path Rel To = "Project"
-Path Rel Path = "daq.h"
-Path = "/c/home/cvi/apps/petdemo/daq.h"
-Exclude = False
-Project Flags = 0
-Folder = "Include Files"
-Folder Id = 4
-
-[File 0016]
-File Type = "Include"
-Res Id = 16
-Path Is Rel = True
-Path Rel To = "Project"
-Path Rel Path = "PETProjDataMgr.h"
-Path = "/c/home/cvi/apps/petdemo/PETProjDataMgr.h"
-Exclude = False
-Project Flags = 0
-Folder = "Include Files"
-Folder Id = 4
-
-[File 0017]
-File Type = "Include"
-Res Id = 17
-Path Is Rel = True
-Path Rel To = "Project"
-Path Rel Path = "../../instr/vme/vme.h"
-Path = "/c/home/cvi/instr/vme/vme.h"
-Exclude = False
-Project Flags = 0
-Folder = "Include Files"
-Folder Id = 4
-
-[Custom Build Configs]
-Num Custom Build Configs = 0
-
-[Default Build Config Debug]
-Config Name = "Debug"
-Is 64-Bit = False
-Is Release = False
-Default Calling Convention = "cdecl"
-Optimization Level = "Optimize for speed (level 2)"
-Require Prototypes = True
-Show Warning IDs in Build Output = False
-Selected Warning Level = "None"
-Warning List None = "4,9,84,105,106,107,108,109,110,111"
-Warning List Common = ""
-Warning List Extended = ""
-Warning List All = ""
-Warning Mode = 0
-Enable Unreferenced Identifiers Warning = False
-Enable Pointer Mismatch Warning = False
-Enable Unreachable Code Warning = False
-Enable Assignment In Conditional Warning = False
-Uninitialized Locals Compile Warning = "Aggressive"
-Require Return Values = True
-Enable C99 Extensions = False
-Enable OpenMP Extensions = False
-Stack Size = 250000
-Stack Reserve = 1048576
-Stack Commit = 4096
-Image Base Address = 4194304
-Image Base Address x64 = 4194304
-Compiler Defines = "/DWIN32_LEAN_AND_MEAN /DXXDLL"
-Sign = False
-Sign Store = ""
-Sign Certificate = ""
-Sign Timestamp URL = ""
-Sign URL = ""
-Manifest Embed = False
-Icon File Is Rel = False
-Icon File = ""
-Application Title = ""
-Use IVI Subdirectories for Import Libraries = False
-Use VXIPNP Subdirectories for Import Libraries = False
-Use Dflt Import Lib Base Name = True
-Where to Copy DLL = "Do not copy"
-Custom Directory to Copy DLL Is Rel = False
-Custom Directory to Copy DLL = ""
-Generate Source Documentation = "None"
-Runtime Support = "Full Runtime Support"
-Runtime Binding = "Shared"
-Embed Project .UIRs = False
-Generate Map File = False
-Embed Timestamp = True
-Create Console Application = False
-Using LoadExternalModule = False
-DLL Exports = "Include File Symbols"
-Register ActiveX Server = False
-Numeric File Version = "1,0,0,0"
-Numeric Prod Version = "1,0,0,0"
-Comments = ""
-Comments Ex = ""
-Company Name = ""
-Company Name Ex = "%company"
-File Description = "petdemo (Debug x86)"
-File Description Ex = "%application (%rel_dbg %arch)"
-File Version = "1.0"
-File Version Ex = "%f1.%f2"
-Internal Name = "petdemo"
-Internal Name Ex = "%basename"
-Legal Copyright = "Copyright © 2017"
-Legal Copyright Ex = "Copyright © %company %Y"
-Legal Trademarks = ""
-Legal Trademarks Ex = ""
-Original Filename = "petdemo.exe"
-Original Filename Ex = "%filename"
-Private Build = ""
-Private Build Ex = ""
-Product Name = " petdemo"
-Product Name Ex = "%company %application"
-Product Version = "1.0"
-Product Version Ex = "%p1.%p2"
-Special Build = ""
-Special Build Ex = ""
-Add Type Lib To DLL = False
-Include Type Lib Help Links = False
-TLB Help Style = "HLP"
-Type Lib FP File Is Rel = False
-Type Lib FP File = ""
-
-[Default Build Config Release]
-Config Name = "Release"
-Is 64-Bit = False
-Is Release = True
-Default Calling Convention = "cdecl"
-Optimization Level = "Optimize for speed (level 2)"
-Require Prototypes = True
-Show Warning IDs in Build Output = False
-Selected Warning Level = "None"
-Warning List None = "4,9,84,105,106,107,108,109,110,111"
-Warning List Common = ""
-Warning List Extended = ""
-Warning List All = ""
-Warning Mode = 0
-Enable Unreferenced Identifiers Warning = False
-Enable Pointer Mismatch Warning = False
-Enable Unreachable Code Warning = False
-Enable Assignment In Conditional Warning = False
-Uninitialized Locals Compile Warning = "Aggressive"
-Require Return Values = True
-Enable C99 Extensions = False
-Enable OpenMP Extensions = False
-Stack Size = 250000
-Stack Reserve = 1048576
-Stack Commit = 4096
-Image Base Address = 4194304
-Image Base Address x64 = 4194304
-Compiler Defines = "/DWIN32_LEAN_AND_MEAN"
-Sign = False
-Sign Store = ""
-Sign Certificate = ""
-Sign Timestamp URL = ""
-Sign URL = ""
-Manifest Embed = False
-Icon File Is Rel = False
-Icon File = ""
-Application Title = ""
-Use IVI Subdirectories for Import Libraries = False
-Use VXIPNP Subdirectories for Import Libraries = False
-Use Dflt Import Lib Base Name = True
-Where to Copy DLL = "Do not copy"
-Custom Directory to Copy DLL Is Rel = False
-Custom Directory to Copy DLL = ""
-Generate Source Documentation = "None"
-Runtime Support = "Full Runtime Support"
-Runtime Binding = "Shared"
-Embed Project .UIRs = False
-Generate Map File = False
-Embed Timestamp = True
-Create Console Application = False
-Using LoadExternalModule = False
-DLL Exports = "Include File Symbols"
-Register ActiveX Server = False
-Add Type Lib To DLL = False
-Include Type Lib Help Links = False
-TLB Help Style = "HLP"
-Type Lib FP File Is Rel = False
-Type Lib FP File = ""
-
-[Default Build Config Debug64]
-Config Name = "Debug64"
-Is 64-Bit = True
-Is Release = False
-Default Calling Convention = "cdecl"
-Optimization Level = "Optimize for speed (level 2)"
-Require Prototypes = True
-Show Warning IDs in Build Output = False
-Selected Warning Level = "None"
-Warning List None = "4,9,84,105,106,107,108,109,110,111"
-Warning List Common = ""
-Warning List Extended = ""
-Warning List All = ""
-Warning Mode = 0
-Enable Unreferenced Identifiers Warning = False
-Enable Pointer Mismatch Warning = False
-Enable Unreachable Code Warning = False
-Enable Assignment In Conditional Warning = False
-Uninitialized Locals Compile Warning = "Aggressive"
-Require Return Values = True
-Enable C99 Extensions = False
-Enable OpenMP Extensions = False
-Stack Size = 250000
-Stack Reserve = 1048576
-Stack Commit = 4096
-Image Base Address = 4194304
-Image Base Address x64 = 4194304
-Compiler Defines = "/DWIN32_LEAN_AND_MEAN"
-Sign = False
-Sign Store = ""
-Sign Certificate = ""
-Sign Timestamp URL = ""
-Sign URL = ""
-Manifest Embed = False
-Icon File Is Rel = False
-Icon File = ""
-Application Title = ""
-Use IVI Subdirectories for Import Libraries = False
-Use VXIPNP Subdirectories for Import Libraries = False
-Use Dflt Import Lib Base Name = True
-Where to Copy DLL = "Do not copy"
-Custom Directory to Copy DLL Is Rel = False
-Custom Directory to Copy DLL = ""
-Generate Source Documentation = "None"
-Runtime Support = "Full Runtime Support"
-Runtime Binding = "Shared"
-Embed Project .UIRs = False
-Generate Map File = False
-Embed Timestamp = True
-Create Console Application = False
-Using LoadExternalModule = False
-DLL Exports = "Include File Symbols"
-Register ActiveX Server = False
-Add Type Lib To DLL = False
-Include Type Lib Help Links = False
-TLB Help Style = "HLP"
-Type Lib FP File Is Rel = False
-Type Lib FP File = ""
-
-[Default Build Config Release64]
-Config Name = "Release64"
-Is 64-Bit = True
-Is Release = True
-Default Calling Convention = "cdecl"
-Optimization Level = "Optimize for speed (level 2)"
-Require Prototypes = True
-Show Warning IDs in Build Output = False
-Selected Warning Level = "None"
-Warning List None = "4,9,84,105,106,107,108,109,110,111"
-Warning List Common = ""
-Warning List Extended = ""
-Warning List All = ""
-Warning Mode = 0
-Enable Unreferenced Identifiers Warning = False
-Enable Pointer Mismatch Warning = False
-Enable Unreachable Code Warning = False
-Enable Assignment In Conditional Warning = False
-Uninitialized Locals Compile Warning = "Aggressive"
-Require Return Values = True
-Enable C99 Extensions = False
-Enable OpenMP Extensions = False
-Stack Size = 250000
-Stack Reserve = 1048576
-Stack Commit = 4096
-Image Base Address = 4194304
-Image Base Address x64 = 4194304
-Compiler Defines = "/DWIN32_LEAN_AND_MEAN"
-Sign = False
-Sign Store = ""
-Sign Certificate = ""
-Sign Timestamp URL = ""
-Sign URL = ""
-Manifest Embed = False
-Icon File Is Rel = False
-Icon File = ""
-Application Title = ""
-Use IVI Subdirectories for Import Libraries = False
-Use VXIPNP Subdirectories for Import Libraries = False
-Use Dflt Import Lib Base Name = True
-Where to Copy DLL = "Do not copy"
-Custom Directory to Copy DLL Is Rel = False
-Custom Directory to Copy DLL = ""
-Generate Source Documentation = "None"
-Runtime Support = "Full Runtime Support"
-Runtime Binding = "Shared"
-Embed Project .UIRs = False
-Generate Map File = False
-Embed Timestamp = True
-Create Console Application = False
-Using LoadExternalModule = False
-DLL Exports = "Include File Symbols"
-Register ActiveX Server = False
-Add Type Lib To DLL = False
-Include Type Lib Help Links = False
-TLB Help Style = "HLP"
-Type Lib FP File Is Rel = False
-Type Lib FP File = ""
-
-[Compiler Options]
-Default Calling Convention = "cdecl"
-Require Prototypes = True
-Require Return Values = True
-Enable Pointer Mismatch Warning = False
-Enable Unreachable Code Warning = False
-Enable Unreferenced Identifiers Warning = False
-Enable Assignment In Conditional Warning = False
-O Option Compatible With 5.0 = False
-Enable C99 Extensions = False
-Uninitialized Locals Compile Warning = "Aggressive"
-Precompile Prefix Header = False
-Prefix Header File = ""
-
-[Run Options]
-Stack Size = 250000
-Stack Commit = 4096
-Image Base Address = 4194304
-Image Base Address x64 = 4194304
-
-[Compiler Defines]
-Compiler Defines = "/DWIN32_LEAN_AND_MEAN"
-
-[Include Paths]
-Include Path 1 Is Rel = True
-Include Path 1 Rel To = "Project"
-Include Path 1 Rel Path = "../../instr/CAENV965"
-Include Path 1 = "/c/home/cvi/instr/CAENV965"
-Include Path 2 Is Rel = True
-Include Path 2 Rel To = "Project"
-Include Path 2 Rel Path = "../../instr/WUSBVME_DLL"
-Include Path 2 = "/c/home/cvi/instr/WUSBVME_DLL"
-
-[Create Executable]
-Executable File_Debug Is Rel = True
-Executable File_Debug Rel To = "Project"
-Executable File_Debug Rel Path = "petdemo.exe"
-Executable File_Debug = "/c/home/cvi/apps/petdemo/petdemo.exe"
-Executable File_Release Is Rel = True
-Executable File_Release Rel To = "Project"
-Executable File_Release Rel Path = "petdemo.exe"
-Executable File_Release = "/c/home/cvi/apps/petdemo/petdemo.exe"
-Executable File_Debug64 Is Rel = True
-Executable File_Debug64 Rel To = "Project"
-Executable File_Debug64 Rel Path = "petdemo.exe"
-Executable File_Debug64 = "/c/home/cvi/apps/petdemo/petdemo.exe"
-Executable File_Release64 Is Rel = True
-Executable File_Release64 Rel To = "Project"
-Executable File_Release64 Rel Path = "petdemo.exe"
-Executable File_Release64 = "/c/home/cvi/apps/petdemo/petdemo.exe"
-Icon File Is Rel = False
-Icon File = ""
-Application Title = ""
-DLL Exports = "Include File Symbols"
-Use IVI Subdirectories for Import Libraries = False
-Use VXIPNP Subdirectories for Import Libraries = False
-Use Dflt Import Lib Base Name = True
-Where to Copy DLL = "Do not copy"
-Custom Directory to Copy DLL Is Rel = False
-Custom Directory to Copy DLL = ""
-Generate Source Documentation = "None"
-Add Type Lib To DLL = False
-Include Type Lib Help Links = False
-TLB Help Style = "HLP"
-Type Lib FP File Is Rel = False
-Type Lib FP File = ""
-Type Lib Guid = ""
-Runtime Support = "Full Runtime Support"
-Instrument Driver Support Only = False
-Embed Project .UIRs = False
-Generate Map File = False
-
-[External Compiler Support]
-UIR Callbacks File Option = 0
-Using LoadExternalModule = False
-Create Project Symbols File = True
-UIR Callbacks Obj File Is Rel = False
-UIR Callbacks Obj File = ""
-Project Symbols H File Is Rel = False
-Project Symbols H File = ""
-Project Symbols Obj File Is Rel = False
-Project Symbols Obj File = ""
-
-[ActiveX Server Options]
-Specification File Is Rel = False
-Specification File = ""
-Source File Is Rel = False
-Source File = ""
-Include File Is Rel = False
-Include File = ""
-IDL File Is Rel = False
-IDL File = ""
-Register ActiveX Server = False
-
-[Signing Info]
-Sign = False
-Sign Debug Build = False
-Store = ""
-Certificate = ""
-Timestamp URL = ""
-URL = ""
-
-[Manifest Info]
-Embed = False
-
-[tpcSection]
-tpcEnabled = 0
-tpcOverrideEnvironment = 0
-tpcEnabled x64 = 0
-tpcOverrideEnvironment x64 = 0
-
Index: petdemo/PETProjDataMgr.h
===================================================================
--- petdemo/PETProjDataMgr.h (revision 264)
+++ petdemo/PETProjDataMgr.h (nonexistent)
@@ -1,110 +0,0 @@
-//
-// ********************************************************************
-// * License and Disclaimer *
-// * *
-// * The GAMOS software is copyright of the Copyright Holders of *
-// * the GAMOS Collaboration. It is provided under the terms and *
-// * conditions of the GAMOS Software License, included in the file *
-// * LICENSE and available at http://fismed.ciemat.es/GAMOS/license .*
-// * These include a list of copyright holders. *
-// * *
-// * Neither the authors of this software system, nor their employing *
-// * institutes,nor the agencies providing financial support for this *
-// * work make any representation or warranty, express or implied, *
-// * regarding this software system or assume any liability for its *
-// * use. Please see the license in the file LICENSE and URL above *
-// * for the full disclaimer and the limitation of liability. *
-// * *
-// * This code implementation is the result of the scientific and *
-// * technical work of the GAMOS collaboration. *
-// * By using, copying, modifying or distributing the software (or *
-// * any work based on the software) you agree to acknowledge its *
-// * use in resulting scientific publications, and indicate your *
-// * acceptance of all terms of the GAMOS Software license. *
-// ********************************************************************
-//
-
-#ifndef PETProjDataMgr_h
-#define PETProjDataMgr_h
-
-/*---------------------------------------------------------------------------
-ClassName: PETProjDataMgr
-Author: M. Canadas, P. Arce
-Changes: 01/11: creation
-
--------------------------------------------------------------------------
-// Description
-
- PET output (List-mode X Y Z) into projection data (sinograms).
-
- Output data: Sinograms for PET image reconstruction. Interfile format, STIR compatible (.hs/.s),
- STIR Software for Tomographic Image Reconstruction: http://stir.sourceforge.net/main.htm
-
------------------------------------------------------------------------*/
-#include <stdlib.h>
-#include <stdio.h>
-#include <stdint.h>
-#include "H1D.h"
-#include "H2D.h"
-#include "H3D.h"
-
-#include "daq.h"
-
-
- typedef unsigned short SINO_TYPE; //!!NOTE: Check "Write_sino3D" (.hv file) if SINO_TYPE changes !!
-
- struct PETProjDataMgr {
-
- int m_Debug;
- double m_AxialDistance;
- double m_RingDiameter;
- int m_NOfPlanes;
- int m_NOfBins;
- int m_NOfAngles;
- int m_MaxRingDifference;
- int m_OutFormat;
- int m_nch;
- int m_TotalAxialPlanes;
- char m_Filename;
-
- //G4bool bDumpCout;
-
- SINO_TYPE ***m_projections;
- SINO_TYPE *m_Buffer;
-
- unsigned long int m_TotalCoincidences;
- unsigned long int m_TotalProjectionCoincidences;
-
-
-
-
- };
-//-----------------------------------------------------------------------
- int PETProjDataMgrInit();
- void PETProjDataMgrFree();
-
- void AddEvent(const HVector3 pos1, const HVector3 pos2);
- //void ReadFile();
- //PETOutput ReadEvent( G4bool& bEof );
- void SetProjection(int axialplane, int h2d);
- void WriteInterfile(const char *fname);
- void SetNPlanes(int n);
- void SetNBin(int n);
- void SetNAng(int n);
- void SetDebug(int n);
- void SetNumberOfChannels(int n);
-
- void SetRingDiameter( double x);
- void SetAxialDistance( double x);
- int Phantom(int kaj);
- int FwdProject2d(int img2d, int h2d);
- int FwdProject3d(int img3d, int h3d);
-
- int FwdProject(double x,double y, double z, int nmax, int h1d);
- HVector3 Hits2Digits(const HVector3 r);
-
-
-
- struct PETProjDataMgr* GetInstance();
-#endif
-
Index: petdemo/libxxusb.dll
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/petdemo/libxxusb.dll
Property changes:
Deleted: svn:mime-type
## -1 +0,0 ##
-application/octet-stream
\ No newline at end of property
Index: petdemo/petdemo_uir.uir
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/petdemo/petdemo_uir.uir
Property changes:
Deleted: svn:mime-type
## -1 +0,0 ##
-application/octet-stream
\ No newline at end of property
Index: petdemo/daq.h
===================================================================
--- petdemo/daq.h (revision 264)
+++ petdemo/daq.h (nonexistent)
@@ -1,117 +0,0 @@
-#ifndef _daq_h_
-#define _daq_h_
-
-#define MAXCH 64
-#define MAXPMT 16
-
-#define NSTEPS 4790 // en krog je 4790 korakov
-
-typedef struct {
- float x[3];
-} HVector3;
-
-struct Module {
- double r;
- double phi;
-};
-
-
-
-struct Channel {
- int ix;
- int iy;
-};
-
-
-struct Config {
- int nofcrystalsx;
- int nofcrystalsy;
- double crystalpitchx;
- double crystalpitchy;
- char *modules;
- char *channels;
- char *sumpedestals;
- char *pedestals;
- char *photopeak;
- char *channelcalibration;
- int adcthreshold;
- double peakscaling;
- struct Module module[16];
- struct Channel channel[16];
- float apedestals[MAXCH];
- float apeak[MAXCH];
- float rotation;
- int write;
- int coincidences; // stevilo koincidenc
-} conf;
-
-
-
-#define NUM_CHANNELS 1
-#define PEDESTAL 255
-#define SCAN_TYPE 1
-
-#define RUNREC_ID 1
-#define ENDREC_ID 2
-#define POSREC_ID 3
-#define EVTREC_ID 4
-
-typedef struct {
- unsigned int id,length;
- unsigned int fver,time;
- unsigned int num_events,num_channels,pedestal,xy;
- int nx,x0,dx,ny,y0,dy;
-} RUNREC;
-typedef struct {
- unsigned int id,length;
- unsigned int time,dum;
-} ENDREC;
-
-typedef struct {
- unsigned int id,length;
- unsigned int time;
- int num_iter_x,mikro_pos_x,set_pos_x;
- int num_iter_y,mikro_pos_y,set_pos_y;
-} POSREC;
-
-int debug;
-int fPedestal;
-int fThresholdEnable;
-int fStop;
-int fMode;
-int clear();
-int end();
-int event(unsigned int *, int,int *, int );
-int init();
-int vmconnect();
-int vmdisconnect();
-int vmacquire (int neve,FILE *fp, char *fpedname);
-
-
-int HistogramsInit();
-int HistogramsFill();
-int HistogramsWrite(const char *fname);
-int GetGlobalPosition(int ipmt, double angle, float cx, float cy, float *gposition);
-int analyse(int nb, uint32_t *data);
-
-
-//-----------------
-
-int m_Adc[MAXCH];
-int m_AdcCut[MAXCH];
-int m_Adc_vs_Nhits[MAXCH];
-int m_Adc_vs_Sum[MAXCH];
-int m_Adc_vs_Sum_Uncorected[MAXCH];
-int m_Nhits;
-int m_AdcSum[MAXPMT];
-int m_CenterOfGravity[MAXPMT];
-int m_ReconstructedPosition[MAXPMT];
-int m_CenterOfGravityforChAboveThreshold[MAXPMT];
-int m_GlobalPosition;
-int m_AdcSumCluster[MAXPMT];
-int m_MaxAdc[MAXPMT];
-int m_SumAdc[MAXPMT];
-
-//-----------------
-
-#endif