1use asyn_rs::error::AsynResult;
2use asyn_rs::param::ParamType;
3use asyn_rs::port::PortDriverBase;
4
5#[derive(Clone, Copy)]
7pub struct NDArrayDriverParams {
8 pub port_name_self: usize,
10 pub ad_core_version: usize,
11 pub driver_version: usize,
12 pub manufacturer: usize,
13 pub model: usize,
14 pub serial_number: usize,
15 pub firmware_version: usize,
16 pub sdk_version: usize,
17
18 pub array_size_x: usize,
20 pub array_size_y: usize,
21 pub array_size_z: usize,
22 pub array_size: usize,
23 pub array_counter: usize,
24 pub array_callbacks: usize,
25 pub n_dimensions: usize,
26 pub array_dimensions: usize,
27 pub data_type: usize,
28 pub color_mode: usize,
29 pub unique_id: usize,
30 pub bayer_pattern: usize,
31 pub codec: usize,
32 pub compressed_size: usize,
33 pub timestamp_rbv: usize,
34 pub epics_ts_sec: usize,
35 pub epics_ts_nsec: usize,
36
37 pub ndarray_data: usize,
39
40 pub pool_max_memory: usize, pub pool_used_memory: usize, pub pool_alloc_buffers: usize,
44 pub pool_free_buffers: usize,
45 pub pool_max_buffers: usize,
46 pub pool_pre_alloc: usize,
47 pub pool_empty_free_list: usize,
48 pub pool_poll_stats: usize,
49 pub pool_num_pre_alloc_buffers: usize,
50
51 pub auto_save: usize,
53 pub file_format: usize,
54 pub free_capture: usize,
55
56 pub file_path: usize,
58 pub file_name: usize,
59 pub file_number: usize,
60 pub file_template: usize,
61 pub auto_increment: usize,
62 pub full_file_name: usize,
63 pub file_path_exists: usize,
64 pub write_file: usize,
65 pub read_file: usize,
66 pub file_write_mode: usize,
67 pub file_write_status: usize,
68 pub file_write_message: usize,
69 pub num_capture: usize,
70 pub num_captured: usize,
71 pub capture: usize,
72 pub delete_driver_file: usize,
73 pub lazy_open: usize,
74 pub create_dir: usize,
75 pub temp_suffix: usize,
76
77 pub attributes_file: usize,
79 pub attributes_status: usize,
80 pub attributes_macros: usize,
81
82 pub num_queued_arrays: usize,
84
85 pub wait_for_plugins: usize,
87
88 pub acquire: usize,
90 pub acquire_busy: usize,
91}
92
93impl NDArrayDriverParams {
94 pub fn create(base: &mut PortDriverBase) -> AsynResult<Self> {
95 Ok(Self {
96 port_name_self: base.create_param("PORT_NAME_SELF", ParamType::Octet)?,
98 ad_core_version: base.create_param("ADCORE_VERSION", ParamType::Octet)?,
99 driver_version: base.create_param("DRIVER_VERSION", ParamType::Octet)?,
100 manufacturer: base.create_param("MANUFACTURER", ParamType::Octet)?,
101 model: base.create_param("MODEL", ParamType::Octet)?,
102 serial_number: base.create_param("SERIAL_NUMBER", ParamType::Octet)?,
103 firmware_version: base.create_param("FIRMWARE_VERSION", ParamType::Octet)?,
104 sdk_version: base.create_param("SDK_VERSION", ParamType::Octet)?,
105
106 array_size_x: base.create_param("ARRAY_SIZE_X", ParamType::Int32)?,
108 array_size_y: base.create_param("ARRAY_SIZE_Y", ParamType::Int32)?,
109 array_size_z: base.create_param("ARRAY_SIZE_Z", ParamType::Int32)?,
110 array_size: base.create_param("ARRAY_SIZE", ParamType::Int32)?,
111 array_counter: base.create_param("ARRAY_COUNTER", ParamType::Int32)?,
112 array_callbacks: base.create_param("ARRAY_CALLBACKS", ParamType::Int32)?,
113 n_dimensions: base.create_param("ARRAY_NDIMENSIONS", ParamType::Int32)?,
114 array_dimensions: base.create_param("ARRAY_DIMENSIONS", ParamType::Int32Array)?,
115 data_type: base.create_param("DATA_TYPE", ParamType::Int32)?,
116 color_mode: base.create_param("COLOR_MODE", ParamType::Int32)?,
117 unique_id: base.create_param("UNIQUE_ID", ParamType::Int32)?,
118 bayer_pattern: base.create_param("BAYER_PATTERN", ParamType::Int32)?,
119 codec: base.create_param("CODEC", ParamType::Octet)?,
120 compressed_size: base.create_param("COMPRESSED_SIZE", ParamType::Int32)?,
121 timestamp_rbv: base.create_param("TIME_STAMP", ParamType::Float64)?,
122 epics_ts_sec: base.create_param("EPICS_TS_SEC", ParamType::Int32)?,
123 epics_ts_nsec: base.create_param("EPICS_TS_NSEC", ParamType::Int32)?,
124
125 ndarray_data: base.create_param("ARRAY_DATA", ParamType::GenericPointer)?,
127
128 pool_max_memory: base.create_param("POOL_MAX_MEMORY", ParamType::Float64)?,
130 pool_used_memory: base.create_param("POOL_USED_MEMORY", ParamType::Float64)?,
131 pool_alloc_buffers: base.create_param("POOL_ALLOC_BUFFERS", ParamType::Int32)?,
132 pool_free_buffers: base.create_param("POOL_FREE_BUFFERS", ParamType::Int32)?,
133 pool_max_buffers: base.create_param("POOL_MAX_BUFFERS", ParamType::Int32)?,
134 pool_pre_alloc: base.create_param("POOL_PRE_ALLOC_BUFFERS", ParamType::Int32)?,
135 pool_empty_free_list: base.create_param("POOL_EMPTY_FREELIST", ParamType::Int32)?,
136 pool_poll_stats: base.create_param("POOL_POLL_STATS", ParamType::Int32)?,
137 pool_num_pre_alloc_buffers: base
138 .create_param("POOL_NUM_PRE_ALLOC_BUFFERS", ParamType::Int32)?,
139
140 auto_save: base.create_param("AUTO_SAVE", ParamType::Int32)?,
142 file_format: base.create_param("FILE_FORMAT", ParamType::Int32)?,
143 free_capture: base.create_param("FREE_CAPTURE", ParamType::Int32)?,
144
145 file_path: base.create_param("FILE_PATH", ParamType::Octet)?,
147 file_name: base.create_param("FILE_NAME", ParamType::Octet)?,
148 file_number: base.create_param("FILE_NUMBER", ParamType::Int32)?,
149 file_template: base.create_param("FILE_TEMPLATE", ParamType::Octet)?,
150 auto_increment: base.create_param("AUTO_INCREMENT", ParamType::Int32)?,
151 full_file_name: base.create_param("FULL_FILE_NAME", ParamType::Octet)?,
152 file_path_exists: base.create_param("FILE_PATH_EXISTS", ParamType::Int32)?,
153 write_file: base.create_param("WRITE_FILE", ParamType::Int32)?,
154 read_file: base.create_param("READ_FILE", ParamType::Int32)?,
155 file_write_mode: base.create_param("WRITE_MODE", ParamType::Int32)?,
156 file_write_status: base.create_param("WRITE_STATUS", ParamType::Int32)?,
157 file_write_message: base.create_param("WRITE_MESSAGE", ParamType::Octet)?,
158 num_capture: base.create_param("NUM_CAPTURE", ParamType::Int32)?,
159 num_captured: base.create_param("NUM_CAPTURED", ParamType::Int32)?,
160 capture: base.create_param("CAPTURE", ParamType::Int32)?,
161 delete_driver_file: base.create_param("DELETE_DRIVER_FILE", ParamType::Int32)?,
162 lazy_open: base.create_param("FILE_LAZY_OPEN", ParamType::Int32)?,
163 create_dir: base.create_param("CREATE_DIR", ParamType::Int32)?,
164 temp_suffix: base.create_param("FILE_TEMP_SUFFIX", ParamType::Octet)?,
165
166 attributes_file: base.create_param("ND_ATTRIBUTES_FILE", ParamType::Octet)?,
168 attributes_status: base.create_param("ND_ATTRIBUTES_STATUS", ParamType::Int32)?,
169 attributes_macros: base.create_param("ND_ATTRIBUTES_MACROS", ParamType::Octet)?,
170
171 num_queued_arrays: base.create_param("NUM_QUEUED_ARRAYS", ParamType::Int32)?,
173
174 wait_for_plugins: base.create_param("WAIT_FOR_PLUGINS", ParamType::Int32)?,
176
177 acquire: base.create_param("ACQUIRE", ParamType::Int32)?,
179 acquire_busy: base.create_param("ACQUIRE_BUSY", ParamType::Int32)?,
180 })
181 }
182}
183
184#[cfg(test)]
185mod tests {
186 use super::*;
187 use asyn_rs::port::PortFlags;
188
189 #[test]
190 fn test_create_ndarray_driver_params() {
191 let mut base = PortDriverBase::new("test", 1, PortFlags::default());
192 let params = NDArrayDriverParams::create(&mut base).unwrap();
193 assert!(base.find_param("ARRAY_COUNTER").is_some());
194 assert!(base.find_param("FILE_PATH").is_some());
195 assert!(base.find_param("POOL_MAX_MEMORY").is_some());
196 assert!(base.find_param("ARRAY_DATA").is_some());
197 assert!(base.find_param("ND_ATTRIBUTES_FILE").is_some());
198 assert_eq!(
199 params.array_counter,
200 base.find_param("ARRAY_COUNTER").unwrap()
201 );
202 }
203
204 #[test]
205 fn test_ndarray_driver_param_count() {
206 let mut base = PortDriverBase::new("test", 1, PortFlags::default());
207 let _ = NDArrayDriverParams::create(&mut base).unwrap();
208 assert!(base.params.len() >= 45);
210 }
211}