From 0ea068cc31bc027ff32d6fa41e3a27e6139aa4e0 Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Wed, 19 Feb 2014 12:06:22 +1100 Subject: [PATCH] Generate code to report errors in script context hook code --- site_ansto/instrument/util/gen_sct.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/site_ansto/instrument/util/gen_sct.py b/site_ansto/instrument/util/gen_sct.py index 7db82017..1d03a201 100755 --- a/site_ansto/instrument/util/gen_sct.py +++ b/site_ansto/instrument/util/gen_sct.py @@ -768,6 +768,10 @@ def put_write_function(MyDriver, func): txt += ['# hook code starts'] txt += MyDriver['Funcs'][func]['text'] txt += ['# hook code ends'] + txt += [' if { [hpropexists [sct] geterror] } {'] + txt += [' debug_log 1 "[sct] error: [sct geterror]"'] + txt += [' return -code error "[sct geterror]"'] + txt += [' }'] txt += [' debug_log 1 "%s sct send ${cmd}"' % func] txt += [' sct send "${cmd}"'] txt += [' return ${nextState}'] @@ -800,6 +804,10 @@ def put_fetch_function(MyDriver, func): txt += ['# hook code starts'] txt += MyDriver['Funcs'][func]['text'] txt += ['# hook code ends'] + txt += [' if { [hpropexists [sct] geterror] } {'] + txt += [' debug_log 1 "[sct] error: [sct geterror]"'] + txt += [' return -code error "[sct geterror]"'] + txt += [' }'] txt += [' debug_log 1 "%s sct send ${cmd}"' % func] txt += [' sct send "${cmd}"'] txt += [' return ${nextState}'] @@ -825,10 +833,10 @@ def put_read_function(MyDriver, func): txt += ['# hook code starts'] txt += MyDriver['Funcs'][func]['text'] txt += ['# hook code ends'] - txt += [' if { [hpropexists [sct] geterror] } {'] - txt += [' debug_log 1 "[sct] error: [sct geterror]"'] - txt += [' return -code error "[sct geterror]"'] - txt += [' }'] + txt += [' if { [hpropexists [sct] geterror] } {'] + txt += [' debug_log 1 "[sct] error: [sct geterror]"'] + txt += [' return -code error "[sct geterror]"'] + txt += [' }'] txt += [' if { ${data} != [sct oldval] } {'] txt += [' debug_log 1 "[sct] changed to new:${data}, from old:[sct oldval]"'] txt += [' sct oldval ${data}']