From 2cb70741b1cb51a407d07c2fe460c7dc435b1361 Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Tue, 19 Aug 2014 13:57:46 +1000 Subject: [PATCH] Add hupdateif [] for conditional update of hipadaba --- site_ansto/instrument/util/utility.tcl | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/site_ansto/instrument/util/utility.tcl b/site_ansto/instrument/util/utility.tcl index 594785e0..04032f36 100644 --- a/site_ansto/instrument/util/utility.tcl +++ b/site_ansto/instrument/util/utility.tcl @@ -917,6 +917,27 @@ proc handle_exception {status message args} { } } +proc hupdateif {path new_value {cmp_format ""}} { + if { ${cmp_format} == "" } { + if { [hpropexists ${path} compare_format] } { + set compare_format [hgetpropval ${path} compare_format] + } else { + set compare_format "" + } + } else { + set compare_format ${cmp_format} + } + if { ${compare_format} == "" } { + if { [hval ${path}] != ${new_value} } { + hupdate ${path} ${new_value} + } + } else { + if { [format ${compare_format} [hval ${path}]] != [format ${compare_format} ${new_value}] } { + hupdate ${path} ${new_value} + } + } +} + namespace import ::utility::*; Publish getinfo spy Publish setpos user