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
89impl NDArrayDriverParams {
90 pub fn create(base: &mut PortDriverBase) -> AsynResult<Self> {
91 Ok(Self {
92 port_name_self: base.create_param("PORT_NAME_SELF", ParamType::Octet)?,
94 ad_core_version: base.create_param("ADCORE_VERSION", ParamType::Octet)?,
95 driver_version: base.create_param("DRIVER_VERSION", ParamType::Octet)?,
96 manufacturer: base.create_param("MANUFACTURER", ParamType::Octet)?,
97 model: base.create_param("MODEL", ParamType::Octet)?,
98 serial_number: base.create_param("SERIAL_NUMBER", ParamType::Octet)?,
99 firmware_version: base.create_param("FIRMWARE_VERSION", ParamType::Octet)?,
100 sdk_version: base.create_param("SDK_VERSION", ParamType::Octet)?,
101
102 array_size_x: base.create_param("ARRAY_SIZE_X", ParamType::Int32)?,
104 array_size_y: base.create_param("ARRAY_SIZE_Y", ParamType::Int32)?,
105 array_size_z: base.create_param("ARRAY_SIZE_Z", ParamType::Int32)?,
106 array_size: base.create_param("ARRAY_SIZE", ParamType::Int32)?,
107 array_counter: base.create_param("ARRAY_COUNTER", ParamType::Int32)?,
108 array_callbacks: base.create_param("ARRAY_CALLBACKS", ParamType::Int32)?,
109 n_dimensions: base.create_param("ARRAY_NDIMENSIONS", ParamType::Int32)?,
110 array_dimensions: base.create_param("ARRAY_DIMENSIONS", ParamType::Int32Array)?,
111 data_type: base.create_param("DATA_TYPE", ParamType::Int32)?,
112 color_mode: base.create_param("COLOR_MODE", ParamType::Int32)?,
113 unique_id: base.create_param("UNIQUE_ID", ParamType::Int32)?,
114 bayer_pattern: base.create_param("BAYER_PATTERN", ParamType::Int32)?,
115 codec: base.create_param("CODEC", ParamType::Octet)?,
116 compressed_size: base.create_param("COMPRESSED_SIZE", ParamType::Int32)?,
117 timestamp_rbv: base.create_param("TIME_STAMP", ParamType::Float64)?,
118 epics_ts_sec: base.create_param("EPICS_TS_SEC", ParamType::Int32)?,
119 epics_ts_nsec: base.create_param("EPICS_TS_NSEC", ParamType::Int32)?,
120
121 ndarray_data: base.create_param("ARRAY_DATA", ParamType::GenericPointer)?,
123
124 pool_max_memory: base.create_param("POOL_MAX_MEMORY", ParamType::Float64)?,
126 pool_used_memory: base.create_param("POOL_USED_MEMORY", ParamType::Float64)?,
127 pool_alloc_buffers: base.create_param("POOL_ALLOC_BUFFERS", ParamType::Int32)?,
128 pool_free_buffers: base.create_param("POOL_FREE_BUFFERS", ParamType::Int32)?,
129 pool_max_buffers: base.create_param("POOL_MAX_BUFFERS", ParamType::Int32)?,
130 pool_pre_alloc: base.create_param("POOL_PRE_ALLOC_BUFFERS", ParamType::Int32)?,
131 pool_empty_free_list: base.create_param("POOL_EMPTY_FREELIST", ParamType::Int32)?,
132 pool_poll_stats: base.create_param("POOL_POLL_STATS", ParamType::Int32)?,
133 pool_num_pre_alloc_buffers: base
134 .create_param("POOL_NUM_PRE_ALLOC_BUFFERS", ParamType::Int32)?,
135
136 auto_save: base.create_param("AUTO_SAVE", ParamType::Int32)?,
138 file_format: base.create_param("FILE_FORMAT", ParamType::Int32)?,
139 free_capture: base.create_param("FREE_CAPTURE", ParamType::Int32)?,
140
141 file_path: base.create_param("FILE_PATH", ParamType::Octet)?,
143 file_name: base.create_param("FILE_NAME", ParamType::Octet)?,
144 file_number: base.create_param("FILE_NUMBER", ParamType::Int32)?,
145 file_template: base.create_param("FILE_TEMPLATE", ParamType::Octet)?,
146 auto_increment: base.create_param("AUTO_INCREMENT", ParamType::Int32)?,
147 full_file_name: base.create_param("FULL_FILE_NAME", ParamType::Octet)?,
148 file_path_exists: base.create_param("FILE_PATH_EXISTS", ParamType::Int32)?,
149 write_file: base.create_param("WRITE_FILE", ParamType::Int32)?,
150 read_file: base.create_param("READ_FILE", ParamType::Int32)?,
151 file_write_mode: base.create_param("WRITE_MODE", ParamType::Int32)?,
152 file_write_status: base.create_param("WRITE_STATUS", ParamType::Int32)?,
153 file_write_message: base.create_param("WRITE_MESSAGE", ParamType::Octet)?,
154 num_capture: base.create_param("NUM_CAPTURE", ParamType::Int32)?,
155 num_captured: base.create_param("NUM_CAPTURED", ParamType::Int32)?,
156 capture: base.create_param("CAPTURE", ParamType::Int32)?,
157 delete_driver_file: base.create_param("DELETE_DRIVER_FILE", ParamType::Int32)?,
158 lazy_open: base.create_param("FILE_LAZY_OPEN", ParamType::Int32)?,
159 create_dir: base.create_param("CREATE_DIR", ParamType::Int32)?,
160 temp_suffix: base.create_param("FILE_TEMP_SUFFIX", ParamType::Octet)?,
161
162 attributes_file: base.create_param("ND_ATTRIBUTES_FILE", ParamType::Octet)?,
164 attributes_status: base.create_param("ND_ATTRIBUTES_STATUS", ParamType::Int32)?,
165 attributes_macros: base.create_param("ND_ATTRIBUTES_MACROS", ParamType::Octet)?,
166
167 num_queued_arrays: base.create_param("NUM_QUEUED_ARRAYS", ParamType::Int32)?,
169
170 wait_for_plugins: base.create_param("WAIT_FOR_PLUGINS", ParamType::Int32)?,
172 })
173 }
174}
175
176#[cfg(test)]
177mod tests {
178 use super::*;
179 use asyn_rs::port::PortFlags;
180
181 #[test]
182 fn test_create_ndarray_driver_params() {
183 let mut base = PortDriverBase::new("test", 1, PortFlags::default());
184 let params = NDArrayDriverParams::create(&mut base).unwrap();
185 assert!(base.find_param("ARRAY_COUNTER").is_some());
186 assert!(base.find_param("FILE_PATH").is_some());
187 assert!(base.find_param("POOL_MAX_MEMORY").is_some());
188 assert!(base.find_param("ARRAY_DATA").is_some());
189 assert!(base.find_param("ND_ATTRIBUTES_FILE").is_some());
190 assert_eq!(
191 params.array_counter,
192 base.find_param("ARRAY_COUNTER").unwrap()
193 );
194 }
195
196 #[test]
197 fn test_ndarray_driver_param_count() {
198 let mut base = PortDriverBase::new("test", 1, PortFlags::default());
199 let _ = NDArrayDriverParams::create(&mut base).unwrap();
200 assert!(base.params.len() >= 45);
202 }
203}