From 6738a0844d237b12b66252245b99f4796a8a49d3 Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Mon, 8 Sep 2014 15:56:20 +1000 Subject: [PATCH] Add the Robots (Robbie and Rosie) for Echidna --- .../instrument/config/robots/epson_pandp.sct | 15 ++ .../config/robots/sct_epson_pandp.tcl | 144 ++++++++++++++++++ .../instrument/hrpd/echidna_configuration.tcl | 1 + .../instrument/hrpd/util/sics_config.ini | 23 +++ 4 files changed, 183 insertions(+) create mode 100644 site_ansto/instrument/config/robots/epson_pandp.sct create mode 100644 site_ansto/instrument/config/robots/sct_epson_pandp.tcl diff --git a/site_ansto/instrument/config/robots/epson_pandp.sct b/site_ansto/instrument/config/robots/epson_pandp.sct new file mode 100644 index 00000000..865ebb6c --- /dev/null +++ b/site_ansto/instrument/config/robots/epson_pandp.sct @@ -0,0 +1,15 @@ +# Simple driver generator for the Epson Pick and Place Robots +# vim: ts=8 sts=2 sw=2 expandtab autoindent smartindent +driver epson_pandp = { + vendor = Epson; device = 'Pick and Place Robot'; protocol = std; + class = environment; + simulation_group = environment_simulation; + add_args = "robot_name" + make_args = "robot_name" + wrapper_property nosctcontroller = True; + + code mkWrapper = {%% + clientput "add_robot ${robot_name} ${ip_address} ${tcp_port}" + add_robot ${robot_name} ${ip_address} ${tcp_port} + %%} +} diff --git a/site_ansto/instrument/config/robots/sct_epson_pandp.tcl b/site_ansto/instrument/config/robots/sct_epson_pandp.tcl new file mode 100644 index 00000000..a2bb8796 --- /dev/null +++ b/site_ansto/instrument/config/robots/sct_epson_pandp.tcl @@ -0,0 +1,144 @@ +# Generated driver for epson_pandp +# vim: ft=tcl tabstop=8 softtabstop=2 shiftwidth=2 nocindent smartindent +# + +namespace eval ::scobj::epson_pandp { + set debug_threshold 5 +} + +proc ::scobj::epson_pandp::debug_log {tc_root debug_level debug_string} { + set catch_status [ catch { + set debug_threshold [hgetpropval ${tc_root} debug_threshold] + if {${debug_level} >= ${debug_threshold}} { + set fd [open "../log/epson_pandp_[basename ${tc_root}].log" "a"] + set line "[clock format [clock seconds] -format "%T"] ${debug_string}" + puts ${fd} "${line}" + close ${fd} + } + } catch_message ] +} + +proc ::scobj::epson_pandp::sics_log {debug_level debug_string} { + set catch_status [ catch { + set debug_threshold ${::scobj::epson_pandp::debug_threshold} + if {${debug_level} >= ${debug_threshold}} { + sicslog "::scobj::epson_pandp::${debug_string}" + } + } catch_message ] +} + +proc ::scobj::epson_pandp::mkDriver { sct_controller name ip_address tcp_port robot_name } { + ::scobj::epson_pandp::sics_log 9 "::scobj::epson_pandp::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port} ${robot_name}" + set ns "[namespace current]" + set catch_status [ catch { + +# mkWrapper hook code starts + clientput "add_robot ${robot_name} ${ip_address} ${tcp_port}" + add_robot ${robot_name} ${ip_address} ${tcp_port} +# mkWrapper hook code ends + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +namespace eval ::scobj::epson_pandp { + namespace export debug_threshold + namespace export debug_log + namespace export sics_log + namespace export mkDriver +} + +proc add_epson_pandp {name ip_address tcp_port robot_name} { + set catch_status [ catch { + ::scobj::epson_pandp::sics_log 9 "add_epson_pandp ${name} ${ip_address} ${tcp_port} ${robot_name}" + ::scobj::epson_pandp::sics_log 9 "No sctcontroller for epson_pandp" + ::scobj::epson_pandp::sics_log 1 "::scobj::epson_pandp::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${robot_name}" + ::scobj::epson_pandp::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${robot_name} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +clientput "file evaluation of sct_epson_pandp.tcl" +::scobj::epson_pandp::sics_log 9 "file evaluation of sct_epson_pandp.tcl" + +proc ::scobj::epson_pandp::read_config {} { + set catch_status [ catch { + set ns "::scobj::epson_pandp" + dict for {k u} $::config_dict { + if { [dict exists $u "implementation"] } { + if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { + continue + } + set enabled [string tolower [dict get $u "enabled"]] + if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { + continue + } + set name [dict get $u name] + set implementation [dict get $u "implementation"] + if { !([dict exists $::config_dict $implementation]) } { + continue + } + set v [dict get $::config_dict $implementation] + if { !([dict exists $v "driver"]) } { + continue + } + if { [string equal -nocase [dict get $v "driver"] "epson_pandp"] } { + if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + set asyncqueue "null" + ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + } elseif { [dict exists $v "asyncqueue"] } { + set asyncqueue [dict get $v "asyncqueue"] + if { [string equal -nocase ${asyncqueue} "sct"] } { + set ip_address [dict get $v ip] + set tcp_port [dict get $v port] + } + } else { + if { [dict exists $v "asyncprotocol"] } { + set asyncprotocol [dict get $v "asyncprotocol"] + } else { + set asyncprotocol ${name}_protocol + MakeAsyncProtocol ${asyncprotocol} + if { [dict exists $v "terminator"] } { + ${asyncprotocol} sendterminator "[dict get $v "terminator"]" + ${asyncprotocol} replyterminator "[dict get $v "terminator"]" + } + } + set asyncqueue ${name}_queue + set ip_address [dict get $v ip] + set tcp_port [dict get $v port] + MakeAsyncQueue ${asyncqueue} ${asyncprotocol} ${ip_address} ${tcp_port} + if { [dict exists $v "timeout"] } { + ${asyncqueue} timeout "[dict get $v "timeout"]" + } + } + set arg_list [list] + set missing_list [list] + foreach arg {robot_name} { + if {[dict exists $u $arg]} { + lappend arg_list "[dict get $u $arg]" + } elseif {[dict exists $v $arg]} { + lappend arg_list "[dict get $v $arg]" + } else { + ${ns}::sics_log 9 "Missing configuration value $arg" + lappend missing_list $arg + } + } + if { [llength $missing_list] > 0 } { + error "$name is missing configuration values $missing_list" + } + if { [string equal -nocase ${asyncqueue} "sct"] } { + add_epson_pandp ${name} ${ip_address} ${tcp_port} {*}$arg_list + } else { + add_epson_pandp ${name} "aqadapter" ${asyncqueue} {*}$arg_list + } + } + } + } + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +if { [info exists ::config_dict] } { + ::scobj::epson_pandp::read_config +} else { + ::scobj::epson_pandp::sics_log 5 "No config dict" +} diff --git a/site_ansto/instrument/hrpd/echidna_configuration.tcl b/site_ansto/instrument/hrpd/echidna_configuration.tcl index b7a27da0..d8b7e518 100644 --- a/site_ansto/instrument/hrpd/echidna_configuration.tcl +++ b/site_ansto/instrument/hrpd/echidna_configuration.tcl @@ -47,6 +47,7 @@ fileeval $cfPath(commands)/commands.tcl fileeval $cfPath(anticollider)/anticollider.tcl #fileeval $cfPath(environment)/robby_configuration.tcl fileeval $cfPath(robots)/sct_pickandplace.tcl +fileeval $cfPath(robots)/sct_epson_pandp.tcl source gumxml.tcl diff --git a/site_ansto/instrument/hrpd/util/sics_config.ini b/site_ansto/instrument/hrpd/util/sics_config.ini index 3a98c09f..b8011634 100644 --- a/site_ansto/instrument/hrpd/util/sics_config.ini +++ b/site_ansto/instrument/hrpd/util/sics_config.ini @@ -94,6 +94,11 @@ id = 2 implementation = none name = volts2 optype = multimeter +[robot] +enabled = True +implementation = robbie +name = robot +optype = pickandplace [sample_stage] enabled = Always implementation = normal_sample_stage @@ -283,6 +288,24 @@ imptype = multimeter ip = 10.157.205.37 port = 4001 +[robbie] +asyncqueue = sct +desc = "Robbie: Epson Pick and Place Robot" +driver = epson_pandp +imptype = pickandplace +ip = 137.157.201.26 +port = 6000 +robot_name = robbie + +[rosie] +asyncqueue = sct +desc = "Rosie: Epson Six Axis Robot in Pick and Place Mode" +driver = epson_pandp +imptype = pickandplace +ip = 137.157.201.26 +port = 6000 +robot_name = rosie + [small_omega] desc = "Load the small omega configuration" imptype = motion_axis