areaDetector  3-12-1
EPICS areaDetector framework
PIXIEII_data_utilities_v2.h
Go to the documentation of this file.
1 /*
2  * PIXIEII_data_utilities_v2.h
3  *
4  * Created on: Jul 31, 2014
5  * Author: massimo
6  */
7 
8 #ifndef PIXIEII_DATA_UTILITIES_V2_H_
9 #define PIXIEII_DATA_UTILITIES_V2_H_
10 
11 
12 //#define WINDOWS
13 
14 
15 /*********************************************************************************************************/
16 //#define PIXIEIII 1
17 /*********************************************************************************************************/
18 
19 
20 
21 
22 
23 #include "pxrd2_interface_misc.h"
24 //#include "build_ver.h"
25 
26 //12 bit data fpga writing function Msb first
27 //PA0 SCLK
28 //PA1 SDATA to fpga
29 //PA2 SI_EN
30 
31 #define PIXIE_SI_STATUS_REG 0
32 #define SER_INT_RST 0x1
33 #define SER_INT_START 0x2
34 #define CAL_MODE 0x00
35 #define CONF_MODE 0x0C
36 #define RD_CONF_MODE 0x04
37 #define DEF_CONF_MODE 0x08
38 
39 
40 
41 #define PIXIEII_THSET_REG 7
42 #define PIXIEII_REG0_1 15
43 #define GLOBAL_CONF_REG_WR_OPCODE 0x0000
44 #define GLOBAL_DEFCONF_REG_WR_OPCODE 0x0020
45 #define GLOBAL_CONF_REG_RD_OPCODE 0x0010
46 #define COLUMN_BYPASS_WR_OPCODE 0x0030
47 #define COLUMN_BYPASS_RD_OPCODE 0x0040
48 #define COLUMN_BYPASS_WRDEF_OPCODE 0x0050
49 #define COLUMN_PAIR_SELECTION_OPCODE 0x0060
50 #define ALL_COLUMN_PAIR_SELECTION_OPCODE 0x0070
51 #define PIXEL_CONFIGURATION_OPCODE 0x0080
52 #define AUTOCALIBRATION_OPCODE 0x0090
53 #define COLUMN_BYPASS_WRDEFAULT_OPCODE 0x00a0
54 #define REG_0_BUFF_CODE 0
55 #define REG_1_BUFF_CODE 1
56 #define NETWORK_WAIT_ms 10
57 
58 
59 #define PIXIEII_GLOBAL_CONF_REG 18
60 //nota che PIXIEII_PIXEL_CONF_REG e' lo steso indirizzo di PIXIE_MEM_DATA_REG
61 #define PIXIEII_PIXEL_CONF_REG 12
62 #define PIXIEII_READ_OUT_MODE_REG 21
63 #define STANDARD_READOUT 0
64 #define READ_AUTOCAL_CODES 1
65 
66 #define PIXIE_MEM_DATA_REG 12
67 #define PIXIE_MEM_DATA_LOADER_REG 11
68 #define PIXIE_SHUTTER_OPENING_REG 10
69 #define PIXIE_STIMULI_REG_STATUS 1
70 #define PIXIEII_MEM_WR_CLK 0x4000
71 //#define MEM_WR_EN 0x8000
72 #define PIXIEII_FIFO_RESET 0x8000
73 #define MEM_ADD_MASK 0x03ff
74 #define EN_WR_INJ 0x1
75 #define COUNT_MODE 0x0
76 #define SERIALIZE 0x8
77 #define TESTENABLE 0x1
78 #define SHUTTEREND_FLAG 0x20
79 #define MASKREAD 0x4
80 #define PXDIN 0x2
81 
82 #define PSCNT_WIDTH 15
83 #define PSTABLE_DEPTH 32768
84 
85 //#ifndef PIXIEIII
86 /*****************************************************************************************/
87 #define PII_AUTOCAL_CODE_DEPTH 5
88 #define PII_STD_COUNTER_CODE_DEPTH 15
89 #define PII_PIXIE_COLS 512
90 #define PII_PIXIE_ROWS 476
91 #define PII_PIXIE_DOUTS 16
92 #define PII_COLS_PER_DOUT 32
93 #define PII_PIXELS_IN_SECTOR_MAP (PII_COLS_PER_DOUT*PII_PIXIE_ROWS)
94 #define PII_MATRIX_DIM_WORDS (PII_PIXIE_COLS*PII_PIXIE_ROWS)
95 #define PII_AUTOCAL_REGS 1
96 #define PII_COUNTER_REGS 2
97 #define PII_SEPARATION_COLUMNS_INPXX 3
98 
99 
100 /*****************************************************************************************/
101 
102 #define PIII_AUTOCAL_CODE_DEPTH 9
103 #define PIII_STD_COUNTER_CODE_DEPTH 15
104 #define PIII_SHORT_COUNTER_CODE_DEPTH 7
105 #define PIII_PIXIE_COLS 512
106 #define PIII_PIXIE_ROWS 402
107 #define PIII_PIXIE_DOUTS 16
108 #define PIII_COLS_PER_DOUT 32
109 #define PIII_PIXELS_IN_SECTOR_MAP (PIII_COLS_PER_DOUT*PIII_PIXIE_ROWS)
110 #define PIII_MATRIX_DIM_WORDS (PIII_PIXIE_COLS*PIII_PIXIE_ROWS)
111 #define PIII_AUTOCAL_REGS 3
112 #define PIII_COUNTER_REGS 2
113 #define PIII_SEPARATION_COLUMNS_INPXX 4
114 
115 /* Need to define these constants */
116 #define MAX_CODE_DEPTH 15
117 #define MAX_DOUTS 16
118 
119 /*****************************************************************************/
120 #define OLDRAW_HEADER_LENGHT 10
121 #define FILE_HEADER_LENGHT 12
122 #define FF_FILEHEADER_LENGHT 12
123 /*****************************************************************************/
124 #define BUFFER_HDR_TAG 0xffff
125 #define RESET_BUFFER_HDR_TAG 0xfff0
126 #define FLE_END_TAG 0xfffe
127 
128 /*****************************************************************************/
129 #define NEG_MODE_OFF 745
130 
131 
132 /*****************************************************************************/
133 #define OUTLIER_STDEV 8
134 #define MEDIAN_RADIUS 2
135 
136 #define INTERPOLA_PITCH_DEFAULT 60.0
137 
138 
139 
140 #define GRADIENT 0
141 #define LINE_45 1
142 #define SOMB 2
143 #define INJ 1
144 #define QUIET 0
145 #define PIXIE_CLOCKSEL_REG 2
146 #define PIXIE_AUTOCAL_CLOCKSEL_REG 7
147 #define PIXIE_WRITEPULSES_REG 8
148 #define PIXIE_OUTSEL_REG 3
149 #define PIXIE_CHIPSEL_REG 17
150 #define PIXIE_CLOCK_CNT_LSW_REG 4
151 #define PIXIE_CLOCK_CNT_MSW_REG 5
152 #define PIXIE_INJ_FREQ_REG 6
153 
154 
155 
156 
157 
158 
159 
160 
161 void genera_tabella_clock(unsigned short *clocks, unsigned short dim, unsigned short counterwidth);
162 unsigned short * conversion_table_allocation(SENSOR* Sens_ptr);
163 unsigned short * databuffer_allocation(unsigned long size);
164 void * buffer_allocation(unsigned long elems,int size_el);
165 int databuffer_sorting(unsigned short *buffer_a,SENSOR Sens);
166 int map_data_buffer_on_pixie(unsigned short *buffer_a,SENSOR Sens);
167 int map_data_buffer_on_pixieIII(unsigned short *buffer_a,SENSOR Sens);
168 int generate_test_buffer(unsigned short *buffer_a,unsigned short type,SENSOR Sens);
169 void decode_pixie_data_buffer(unsigned short* table, int table_depth,unsigned short* databuffer,int databuffer_len);
170 
171 void databuffer_filtering(unsigned short *buffer_a,unsigned short low_limit,unsigned short high_limit,SENSOR Sens);
172 void check_data_consistency(unsigned short*data_buffer,unsigned short test_pattern);
173 int dummy_buffer_init(unsigned short*data_buffer,char *namefile,SENSOR Sens);
174 void copy_databuff_to_netbuff(unsigned short* databuff, unsigned short* netbuff,unsigned char position,SENSOR Sens);
175 void my_bytes_swap(unsigned short* us_ptr);
176 int convert_bit_stream_to_counts(int code_depth,unsigned short* source_memory_offset,
177  unsigned short* destination_memory_offset,SENSOR Sens,int verbose);
178 //void get_pixie_raw_data(unsigned short*source_buff_ptr,unsigned short*dest_buff_ptr,unsigned short pixieii_modules,int decode,unsigned short* conv,int code_depth);
179 void get_pixie_raw_data(unsigned short*source_buff_ptr,unsigned short*dest_buff_ptr,ACQ_PROP Acq_sett,SENSOR Sens);
180 
181 /*********************************************************************************************************************************/
182 #define PIII_PRANDOM_15BITS_B0 13
183 #define PIII_PRANDOM_15BITS_B1 14
184 #define PIII_PRANDOM_07BITS_B0 5
185 #define PIII_PRANDOM_07BITS_B1 6
186 #define CONVERSIONTABLEDEPTH 32768
187 int GeneratePIIIConversionTable(unsigned short *table_ptr,int table_size, int code_dept);
188 int InvertPIIIConversionTable(unsigned short *table_ptr,int table_size, int code_dept);
189 unsigned short * PIIIConversion_table_allocation(int code_depth);
190 #endif /* PIXIEII_DATA_UTILITIES_V2_H_ */
Definition: pxrd2_interface_misc.h:90
unsigned short * databuffer_allocation(unsigned long size)
Definition: PIXIE_data_utilities.cpp:88
int map_data_buffer_on_pixie(unsigned short *buffer_a, SENSOR Sens)
Definition: PIXIE_data_utilities.cpp:140
unsigned short * PIIIConversion_table_allocation(int code_depth)
Definition: PIXIE_data_utilities.cpp:422
int InvertPIIIConversionTable(unsigned short *table_ptr, int table_size, int code_dept)
Definition: PIXIE_data_utilities.cpp:360
int map_data_buffer_on_pixieIII(unsigned short *buffer_a, SENSOR Sens)
Definition: PIXIE_data_utilities.cpp:173
void check_data_consistency(unsigned short *data_buffer, unsigned short test_pattern)
Definition: PIXIEII_data_utilities.cpp:212
void get_pixie_raw_data(unsigned short *source_buff_ptr, unsigned short *dest_buff_ptr, ACQ_PROP Acq_sett, SENSOR Sens)
Definition: PIXIE_data_utilities.cpp:271
Definition: pxrd2_interface_misc.h:113
int dummy_buffer_init(unsigned short *data_buffer, char *namefile, SENSOR Sens)
int generate_test_buffer(unsigned short *buffer_a, unsigned short type, SENSOR Sens)
void my_bytes_swap(unsigned short *us_ptr)
Definition: PIXIE_data_utilities.cpp:223
int databuffer_sorting(unsigned short *buffer_a, SENSOR Sens)
Definition: PIXIE_data_utilities.cpp:110
void databuffer_filtering(unsigned short *buffer_a, unsigned short low_limit, unsigned short high_limit, SENSOR Sens)
int convert_bit_stream_to_counts(int code_depth, unsigned short *source_memory_offset, unsigned short *destination_memory_offset, SENSOR Sens, int verbose)
Definition: PIXIE_data_utilities.cpp:233
void genera_tabella_clock(unsigned short *clocks, unsigned short dim, unsigned short counterwidth)
Definition: PIXIE_data_utilities.cpp:21
unsigned short * conversion_table_allocation(SENSOR *Sens_ptr)
Definition: PIXIE_data_utilities.cpp:49
void decode_pixie_data_buffer(unsigned short *table, int table_depth, unsigned short *databuffer, int databuffer_len)
Definition: PIXIE_data_utilities.cpp:210
int verbose
Definition: PIXIE_data_utilities.cpp:16
void * buffer_allocation(unsigned long elems, int size_el)
Definition: PIXIE_data_utilities.cpp:97
int GeneratePIIIConversionTable(unsigned short *table_ptr, int table_size, int code_dept)
Definition: PIXIE_data_utilities.cpp:379
void copy_databuff_to_netbuff(unsigned short *databuff, unsigned short *netbuff, unsigned char position, SENSOR Sens)