ad_plugins_rs/
passthrough.rs1use ad_core_rs::ndarray::NDArray;
7use ad_core_rs::ndarray_pool::NDArrayPool;
8use ad_core_rs::plugin::runtime::{NDPluginProcess, ProcessResult};
9
10pub struct PassthroughProcessor {
12 plugin_type: String,
13}
14
15impl PassthroughProcessor {
16 pub fn new(plugin_type: &str) -> Self {
17 Self {
18 plugin_type: plugin_type.to_string(),
19 }
20 }
21}
22
23impl NDPluginProcess for PassthroughProcessor {
24 fn plugin_type(&self) -> &str {
25 &self.plugin_type
26 }
27
28 fn process_array(&mut self, _array: &NDArray, _pool: &NDArrayPool) -> ProcessResult {
29 ProcessResult::empty()
30 }
31
32 fn register_params(
33 &mut self,
34 base: &mut asyn_rs::port::PortDriverBase,
35 ) -> asyn_rs::error::AsynResult<()> {
36 use asyn_rs::param::ParamType;
37 if self.plugin_type.as_str() == "NDPvaConfigure" {
39 base.create_param("PV_NAME", ParamType::Octet)?;
40 }
41 Ok(())
42 }
43}
44
45#[cfg(test)]
46mod tests {
47 use super::*;
48
49 #[test]
50 fn test_passthrough_plugin_type() {
51 let p = PassthroughProcessor::new("NDPluginAttribute");
52 assert_eq!(p.plugin_type(), "NDPluginAttribute");
53 }
54}