use epics_base_rs::server::iocsh::registry::*;
use epics_ca_rs::server::ioc_app::IocApplication;
pub fn plugin_arg_defs() -> Vec<ArgDesc> {
vec![
ArgDesc {
name: "portName",
arg_type: ArgType::String,
optional: false,
},
ArgDesc {
name: "queueSize",
arg_type: ArgType::Int,
optional: true,
},
ArgDesc {
name: "blockingCallbacks",
arg_type: ArgType::Int,
optional: true,
},
ArgDesc {
name: "NDArrayPort",
arg_type: ArgType::String,
optional: true,
},
ArgDesc {
name: "NDArrayAddr",
arg_type: ArgType::Int,
optional: true,
},
ArgDesc {
name: "maxBuffers",
arg_type: ArgType::Int,
optional: true,
},
ArgDesc {
name: "maxMemory",
arg_type: ArgType::Int,
optional: true,
},
ArgDesc {
name: "priority",
arg_type: ArgType::Int,
optional: true,
},
ArgDesc {
name: "stackSize",
arg_type: ArgType::Int,
optional: true,
},
ArgDesc {
name: "maxThreads",
arg_type: ArgType::Int,
optional: true,
},
]
}
pub fn extract_plugin_args(args: &[ArgValue]) -> Result<(String, usize, String), String> {
let port_name = match &args[0] {
ArgValue::String(s) => s.clone(),
_ => return Err("portName required".into()),
};
let queue_size = match args.get(1) {
Some(ArgValue::Int(n)) => *n as usize,
_ => 20,
};
let ndarray_port = match args.get(3) {
Some(ArgValue::String(s)) => s.clone(),
_ => String::new(),
};
Ok((port_name, queue_size, ndarray_port))
}
pub fn dtyp_from_port(port_name: &str) -> String {
format!("asyn{port_name}")
}
pub fn register_noop_commands(mut app: IocApplication) -> IocApplication {
for cmd in &["startPVAServer", "callbackSetQueueSize"] {
let name = *cmd;
app = app.register_startup_command(CommandDef::new(
name,
vec![
ArgDesc {
name: "arg1",
arg_type: ArgType::String,
optional: true,
},
ArgDesc {
name: "arg2",
arg_type: ArgType::String,
optional: true,
},
],
format!("{name} [args...] - no-op (not implemented)"),
move |_args: &[ArgValue], _ctx: &CommandContext| Ok(CommandOutcome::Continue),
));
}
app
}