Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,15 @@ _mcl_write_z(position::Float64, id::Int) =
@ccall libmadlib.MCL_SingleWriteZ(position::Cdouble, id::Cint)::Cint

function checked_mcl_value(value, operation)
if !isfinite(value) || value < 0
code = isfinite(value) && isinteger(value) ? get(HardwareReturn, Int(value), "unknown error") : "invalid value"
error("MCLStage $operation failed: $code ($value)")
if !isfinite(value)
error("MCLStage $operation failed: invalid value ($value)")
end
# Madlib signals a failure with one of the integer codes in HardwareReturn
# (-1 to -8). A position is not one of those: a stage resting at its zero
# reads a few nanometres negative, because the capacitive sensor is noisy
# about the origin, and that is a position, not an error.
if value < 0 && isinteger(value) && haskey(HardwareReturn, Int(value))
error("MCLStage $operation failed: $(HardwareReturn[Int(value)]) ($value)")
end
return value
end
Expand Down