Add a driver for the Omron ZS-HLDC Laser Displacement device
This commit is contained in:
48
site_ansto/instrument/config/environment/omron_hldc.sct
Normal file
48
site_ansto/instrument/config/environment/omron_hldc.sct
Normal file
@@ -0,0 +1,48 @@
|
||||
# Simple driver generator for the Omron ZS-HLDC Laser Displacement
|
||||
# vim: ts=8 sts=2 sw=2 expandtab autoindent smartindent
|
||||
#
|
||||
driver omron_hldc = {
|
||||
debug_threshold = 5;
|
||||
vendor = Omron; device = 'ZS-HDLC'; protocol = std;
|
||||
class = environment;
|
||||
simulation_group = environment_simulation;
|
||||
|
||||
group = {
|
||||
readable = 1;
|
||||
var id = {
|
||||
type = text
|
||||
read_function = read_id; read_command = '0501';
|
||||
}
|
||||
var distance = {
|
||||
type = float
|
||||
read_function = read_mm; read_command = '0201C02030008001'; }
|
||||
}
|
||||
|
||||
code getValue = {%%
|
||||
set cmd "00000${cmd}"
|
||||
%%}
|
||||
|
||||
code read_id = {%%
|
||||
if {[string length ${data}] < 14} {
|
||||
sct geterror "read_id short response ${data}"
|
||||
} else {
|
||||
set data [string range ${data} 14 end]
|
||||
}
|
||||
%%}
|
||||
|
||||
code read_mm = {%%
|
||||
if {[string length "${data}"] < 34} {
|
||||
sct geterror "read_mm short response ${data}"
|
||||
} else {
|
||||
set hex [string range ${data} 26 end]
|
||||
debug_log ${tc_root} 1 "hex = ${hex}"
|
||||
set n [scan "${hex}" "%x" val]
|
||||
if {${n} == 1} {
|
||||
set data [expr {0.000001 * ${val}}]
|
||||
} else {
|
||||
sct geterror "read_mm n = ${n} for hex = ${hex}"
|
||||
}
|
||||
}
|
||||
%%}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user