# # Simple driver generator for the non-motor galil controls on mc4 # vim: ts=8 sts=2 sw=2 expandtab autoindent smartindent nocindent # driver shutters = { usecreatenode = false vendor = galil; device = mc4; protocol = dmc2280; class = instrument simulation_group = motor_simulation # # Unnamed group has variables at device level # # # The named group is at the device level, variables below that # group = { type = text priv = user group_property 'data' = 'true' group_property 'nxsave' = 'true' property 'type' = 'part' property 'klass' = 'collimator' property 'sdsinfo' = '::nexus::scobj::sdsinfo' var fast_shutter = { readable = 1 read_command = 'MG @IN[5], @IN[6]' read_function = read_switch_pair property 'nxalias' = 'fast_shutter' } var rough_40 = { readable = 1; read_function = read_switch_pair; read_command = 'MG @IN[13], @IN[14]' writeable = 1 write_function = write_switch; write_command = '10' allowed = 'in,out' property 'nxalias' = 'rough_40' } var rough_100 = { readable = 1; read_function = read_switch_pair; read_command = 'MG @IN[15], @IN[16]' writeable = 1 write_function = write_switch; write_command = '11' allowed = 'in,out' property 'nxalias' = 'rough_100' } }; # # Code lines start with '@' which is stripped before being emitted # The code is emitted at the appropriate place in the given function # code read_function read_switch_pair = { @ if { [string equal -nocase -length 1 "${data}" "?"] } { @ sct geterror "Galil error in: '${data}'" @ } else { @ set data_list [split [string trim "${data}"]] @ if { [llength ${data_list}] > 2 && [lindex ${data_list} end] == ":" } { @ set data_list [lrange ${data_list} 0 1] @ } @ if { [llength ${data_list}] == 2 } { @ set left [expr [lindex ${data_list} 0]] @ set right [expr [lindex ${data_list} 1]] @ if { ${left} == 1 && ${right} == 0 } { # open @ set data "out" @ } elseif { ${left} == 0 && ${right} == 1 } { # closed @ set data "in" @ } else { # indeterminate @ set data "moving" @ } @ } else { @ sct geterror "Syntax error in: '${data}'=>'${data_list}'" @ } @ } } code write_function write_switch = { @ if { [string equal -nocase -length 2 "${par}" "in"] } { @ set cmd "SB${cmd_str}" @ } elseif { [string equal -nocase -length 2 "${par}" "out"] } { @ set cmd "CB${cmd_str}" @ } else { @ sct geterror "Value error: '${par}' not in ('in', 'out')" @ } } # # This code is after database creation # code mkDriver = { } };