///|
enum Profile {
KeysightE36300
}
///|
fn profile_from_json(value : Json?) -> Profile? raise ScpiError {
match value {
None => None
Some(String("keysight-e36300")) => Some(KeysightE36300)
_ => raise PlanError("plan.profile must be keysight-e36300")
}
}
///|
fn Profile::scalar_query(
self : Profile,
query : String,
channel : Json?,
path : String,
) -> (String, String) raise ScpiError {
match self {
KeysightE36300 => {
let header = query.to_upper().trim_start(chars=":")
guard header == "MEAS:VOLT?" || header == "MEAS:CURR?" else {
raise PlanError(
path +
".query must be MEAS:VOLT? or MEAS:CURR? for the keysight-e36300 profile",
)
}
guard channel is Some(Number(n, repr=_)) &&
(n == 1.0 || n == 2.0 || n == 3.0) else {
raise PlanError(
path +
".channel must be the integer 1, 2 or 3 for the keysight-e36300 profile",
)
}
let unit = if header == "MEAS:VOLT?" { "V" } else { "A" }
(header.to_owned() + " (@" + n.to_int().to_string() + ")", unit)
}
}
}
///|
fn Profile::verify_identity(
self : Profile,
identity : String,
) -> Unit raise ScpiError {
match self {
KeysightE36300 => {
guard identity.split(",").to_array() is [brand, model, serial, firmware] &&
brand.trim() == "Keysight Technologies" &&
["E36311A", "E36312A", "E36313A"].contains(model.trim().to_owned()) &&
!serial.trim().is_empty() &&
!firmware.trim().is_empty() else {
raise MeasurementError(
"instrument identification does not match keysight-e36300 (E36311A, E36312A or E36313A)",
)
}
}
}
}