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 data_type: usize,
27 pub color_mode: usize,
28 pub unique_id: usize,
29 pub bayer_pattern: usize,
30 pub codec: usize,
31 pub compressed_size: usize,
32 pub timestamp_rbv: usize,
33 pub epics_ts_sec: usize,
34 pub epics_ts_nsec: usize,
35
36 pub ndarray_data: usize,
38
39 pub pool_max_memory: usize, pub pool_used_memory: usize, pub pool_alloc_buffers: usize,
43 pub pool_free_buffers: usize,
44 pub pool_max_buffers: usize,
45 pub pool_pre_alloc: usize,
46 pub pool_empty_free_list: usize,
47 pub pool_poll_stats: usize,
48 pub pool_num_pre_alloc_buffers: usize,
49
50 pub auto_save: usize,
52 pub file_format: usize,
53 pub free_capture: usize,
54
55 pub file_path: usize,
57 pub file_name: usize,
58 pub file_number: usize,
59 pub file_template: usize,
60 pub auto_increment: usize,
61 pub full_file_name: usize,
62 pub file_path_exists: usize,
63 pub write_file: usize,
64 pub read_file: usize,
65 pub file_write_mode: usize,
66 pub file_write_status: usize,
67 pub file_write_message: usize,
68 pub num_capture: usize,
69 pub num_captured: usize,
70 pub capture: usize,
71 pub delete_driver_file: usize,
72 pub lazy_open: usize,
73 pub create_dir: usize,
74 pub temp_suffix: usize,
75
76 pub attributes_file: usize,
78 pub attributes_status: usize,
79 pub attributes_macros: usize,
80
81 pub num_queued_arrays: usize,
83
84 pub wait_for_plugins: usize,
86}
87
88impl NDArrayDriverParams {
89 pub fn create(base: &mut PortDriverBase) -> AsynResult<Self> {
90 Ok(Self {
91 port_name_self: base.create_param("PORT_NAME_SELF", ParamType::Octet)?,
93 ad_core_version: base.create_param("ADCORE_VERSION", ParamType::Octet)?,
94 driver_version: base.create_param("DRIVER_VERSION", ParamType::Octet)?,
95 manufacturer: base.create_param("MANUFACTURER", ParamType::Octet)?,
96 model: base.create_param("MODEL", ParamType::Octet)?,
97 serial_number: base.create_param("SERIAL_NUMBER", ParamType::Octet)?,
98 firmware_version: base.create_param("FIRMWARE_VERSION", ParamType::Octet)?,
99 sdk_version: base.create_param("SDK_VERSION", ParamType::Octet)?,
100
101 array_size_x: base.create_param("ARRAY_SIZE_X", ParamType::Int32)?,
103 array_size_y: base.create_param("ARRAY_SIZE_Y", ParamType::Int32)?,
104 array_size_z: base.create_param("ARRAY_SIZE_Z", ParamType::Int32)?,
105 array_size: base.create_param("ARRAY_SIZE", ParamType::Int32)?,
106 array_counter: base.create_param("ARRAY_COUNTER", ParamType::Int32)?,
107 array_callbacks: base.create_param("ARRAY_CALLBACKS", ParamType::Int32)?,
108 n_dimensions: base.create_param("NDIMENSIONS", ParamType::Int32)?,
109 data_type: base.create_param("DATA_TYPE", ParamType::Int32)?,
110 color_mode: base.create_param("COLOR_MODE", ParamType::Int32)?,
111 unique_id: base.create_param("UNIQUE_ID", ParamType::Int32)?,
112 bayer_pattern: base.create_param("BAYER_PATTERN", ParamType::Int32)?,
113 codec: base.create_param("CODEC", ParamType::Octet)?,
114 compressed_size: base.create_param("COMPRESSED_SIZE", ParamType::Int32)?,
115 timestamp_rbv: base.create_param("TIMESTAMP", ParamType::Float64)?,
116 epics_ts_sec: base.create_param("EPICS_TS_SEC", ParamType::Int32)?,
117 epics_ts_nsec: base.create_param("EPICS_TS_NSEC", ParamType::Int32)?,
118
119 ndarray_data: base.create_param("NDARRAY_DATA", ParamType::GenericPointer)?,
121
122 pool_max_memory: base.create_param("POOL_MAX_MEMORY", ParamType::Float64)?,
124 pool_used_memory: base.create_param("POOL_USED_MEMORY", ParamType::Float64)?,
125 pool_alloc_buffers: base.create_param("POOL_ALLOC_BUFFERS", ParamType::Int32)?,
126 pool_free_buffers: base.create_param("POOL_FREE_BUFFERS", ParamType::Int32)?,
127 pool_max_buffers: base.create_param("POOL_MAX_BUFFERS", ParamType::Int32)?,
128 pool_pre_alloc: base.create_param("POOL_PRE_ALLOC", ParamType::Int32)?,
129 pool_empty_free_list: base.create_param("POOL_EMPTY_FREE_LIST", ParamType::Int32)?,
130 pool_poll_stats: base.create_param("POOL_POLL_STATS", ParamType::Int32)?,
131 pool_num_pre_alloc_buffers: base.create_param("POOL_NUM_PRE_ALLOC_BUFFERS", ParamType::Int32)?,
132
133 auto_save: base.create_param("AUTO_SAVE", ParamType::Int32)?,
135 file_format: base.create_param("FILE_FORMAT", ParamType::Int32)?,
136 free_capture: base.create_param("FREE_CAPTURE", ParamType::Int32)?,
137
138 file_path: base.create_param("FILE_PATH", ParamType::Octet)?,
140 file_name: base.create_param("FILE_NAME", ParamType::Octet)?,
141 file_number: base.create_param("FILE_NUMBER", ParamType::Int32)?,
142 file_template: base.create_param("FILE_TEMPLATE", ParamType::Octet)?,
143 auto_increment: base.create_param("AUTO_INCREMENT", ParamType::Int32)?,
144 full_file_name: base.create_param("FULL_FILE_NAME", ParamType::Octet)?,
145 file_path_exists: base.create_param("FILE_PATH_EXISTS", ParamType::Int32)?,
146 write_file: base.create_param("WRITE_FILE", ParamType::Int32)?,
147 read_file: base.create_param("READ_FILE", ParamType::Int32)?,
148 file_write_mode: base.create_param("FILE_WRITE_MODE", ParamType::Int32)?,
149 file_write_status: base.create_param("FILE_WRITE_STATUS", ParamType::Int32)?,
150 file_write_message: base.create_param("FILE_WRITE_MESSAGE", ParamType::Octet)?,
151 num_capture: base.create_param("NUM_CAPTURE", ParamType::Int32)?,
152 num_captured: base.create_param("NUM_CAPTURED", ParamType::Int32)?,
153 capture: base.create_param("CAPTURE", ParamType::Int32)?,
154 delete_driver_file: base.create_param("DELETE_DRIVER_FILE", ParamType::Int32)?,
155 lazy_open: base.create_param("LAZY_OPEN", ParamType::Int32)?,
156 create_dir: base.create_param("CREATE_DIR", ParamType::Int32)?,
157 temp_suffix: base.create_param("TEMP_SUFFIX", ParamType::Octet)?,
158
159 attributes_file: base.create_param("ATTRIBUTES_FILE", ParamType::Octet)?,
161 attributes_status: base.create_param("ATTRIBUTES_STATUS", ParamType::Int32)?,
162 attributes_macros: base.create_param("ATTRIBUTES_MACROS", ParamType::Octet)?,
163
164 num_queued_arrays: base.create_param("NUM_QUEUED_ARRAYS", ParamType::Int32)?,
166
167 wait_for_plugins: base.create_param("WAIT_FOR_PLUGINS", ParamType::Int32)?,
169 })
170 }
171}
172
173#[cfg(test)]
174mod tests {
175 use super::*;
176 use asyn_rs::port::PortFlags;
177
178 #[test]
179 fn test_create_ndarray_driver_params() {
180 let mut base = PortDriverBase::new("test", 1, PortFlags::default());
181 let params = NDArrayDriverParams::create(&mut base).unwrap();
182 assert!(base.find_param("ARRAY_COUNTER").is_some());
183 assert!(base.find_param("FILE_PATH").is_some());
184 assert!(base.find_param("POOL_MAX_MEMORY").is_some());
185 assert!(base.find_param("NDARRAY_DATA").is_some());
186 assert!(base.find_param("ATTRIBUTES_FILE").is_some());
187 assert_eq!(params.array_counter, base.find_param("ARRAY_COUNTER").unwrap());
188 }
189
190 #[test]
191 fn test_ndarray_driver_param_count() {
192 let mut base = PortDriverBase::new("test", 1, PortFlags::default());
193 let _ = NDArrayDriverParams::create(&mut base).unwrap();
194 assert!(base.params.len() >= 45);
196 }
197}