From 9b965e6313b6cb50a74f188335d504de571eaf80 Mon Sep 17 00:00:00 2001 From: Ferdi Franceschini Date: Mon, 28 Jul 2014 10:10:18 +1000 Subject: [PATCH] Minimal scan.tcl and dingo_configuration.tcl FIX: The scan fails to update the motor positions in the camera server meta data. --- .../instrument/dingo/config/scan/scan.tcl | 162 +++--------------- .../instrument/dingo/dingo_configuration.tcl | 44 +---- 2 files changed, 26 insertions(+), 180 deletions(-) diff --git a/site_ansto/instrument/dingo/config/scan/scan.tcl b/site_ansto/instrument/dingo/config/scan/scan.tcl index f6035eeb..126f8109 100644 --- a/site_ansto/instrument/dingo/config/scan/scan.tcl +++ b/site_ansto/instrument/dingo/config/scan/scan.tcl @@ -1,154 +1,30 @@ -source $cfPath(scan)/scan_common_1.tcl -proc ::scan::pre_hmm_scan_prepare {} {} +namespace eval ::scan { } + +proc scan_file { fname {description ""} } { + set file_cmd "set file,path=D:\Data,basename=${fname},startnumber=1,imageformat=tif,experimentdetail=${description}" + cmserver send $file_cmd +} +publish scan_file user proc ::scan::cm_count {sobj uobj point mode preset} { - # send "clear meta" command to the camera server - clientput "sending clear meta" - set cmd "clear meta\r\n" - cm1 send $cmd - # send motor position + cm1 send "clear meta" + foreach m "[sicslist type motor]" { - if {$m == "motor" || $m == "dummy_motor"} { - # skipit - } else { - set cmd "set camera, " - append cmd "[$m]" - append cmd "\r\n" - cm1 send $cmd + if {$m != "dummy_motor"} { + set meta_cmd "set meta,[$m]" + cm1 send $meta_cmd } } cm1 count $preset } -proc ::scan::cm_scan_prepare {sobj uobj} { - - variable save_filetype - variable check_instrument_ready - variable force_scan - - # [::plc::inst_ready] - if {$force_scan || $check_instrument_ready} { - set force_scan false - if [catch { - ::scan::check_scanvar $sobj $uobj - ::scan::pre_hmm_scan_prepare - }] { - return -code error "ISCAN ABORTED: $::errorInfo" - } - - # send "shutter auto" command over - shutter auto - # send "focusflight off" command over - focuslight off - # send "clear meta" command to the camera server - clientput "sending clear meta" - set cmd "clear meta\r\n" - cm1 send $cmd - # send motor position - foreach m "[sicslist type motor]" { - if {$m == "motor" || $m == "dummy_motor"} { - # skipit - } else { - set cmd "set camera, " - append cmd "[$m]" - append cmd "\r\n" - cm1 send $cmd - } - } - - if [catch { - #TODO Parameterise varindex in some way - set varindex 0; - - set numpoints [SplitReply [$sobj np]] - set vlist [split [$sobj getvarpar $varindex] = ] - set scanstart [lindex $vlist 1] - set scanstep [lindex $vlist 2] - #::scan::camscan_cmd -set NP $numpoints - #::scan::camscan_cmd -set scan_variable [string trim [lindex [split [lindex $vlist 0] . ] 1]]; - #::scan::camscan_cmd -set scan_start $scanstart - #::scan::camscan_cmd -set scan_increment $scanstep - set scanvar_pts [SplitReply [$sobj getvardata $varindex]] - - #::scan::camscan_cmd -set feedback status BUSY - clientput "run_mode camscan" - run_mode "camscan" - - #::nexus::newfile BEAM_MONITOR $save_filetype - stdscan prepare $sobj $uobj; - clientput "Scan start: $scanstart, Scan step: $scanstep, Number of points: $numpoints" - }] { - run_mode "normal" - return -code error $::errorInfo - } - } else { - return -code error "ISCAN ABORTED: Instrument not ready" - } -} - -proc ::scan::cm_scan_collect {sobj uobj point} { - set vlist [split [$sobj getvarpar 0] = ]; - - set w(NP) $point - set sv [string trim [lindex [split [lindex $vlist 0] . ] 1]] - set header [format "%-4.4s %-9.9s %-14s %-7.7s" NP $sv Counts Time] - set varval [SplitReply [$sv]] - set counts [SplitReply [::histogram_memory::total_counts]] - set time [SplitReply [::histogram_memory::time]] - set data [format "%-4d %-9.3f %-14d %-7.2f" $point $varval $counts $time] - clientput $header - clientput $data - for {set bmn 1} {$bmn <= $::counter::isc_numchannels} {incr bmn} { - set bmon bm$bmn - clientput "Monitor $bmn [SplitReply [$bmon getcounts]]" - } -} - publish ::scan::cm_count user -publish ::scan::cm_scan_prepare user -publish ::scan::cm_scan_collect user proc ::scan::isc_initialize {} { - #::scan::ic_initialize - - if [ catch { - variable ic_runscanpar - variable ic_hmm_datatype - - set ic_hmm_datatype HISTOGRAM_XYT - - MakeScanCommand camscan cm1 $::cfPath(scan)/scan_common_1.hdd recover.bin - - camscan configure script - #camscan function writeheader ::scan::donothing - #camscan function writepoint ::scan:cm_writepoint - camscan function count ::scan::cm_count - #camscan function collect ::scan::cm_scan_collect - camscan function prepare ::scan::cm_scan_prepare - #camscan function finish ::scan::cm_scan_finish - - # TODO Use ic_runscanpar to create the ::scan::runscan command and - # to validate the "runscan" proc parameters. - array set ic_runscanpar [subst { - scanvar text=drivable - start float - stop float - numpoints int=0,inf - mode text=[join [concat [list time unlimited period count frame] $::counter::isc_beam_monitor_list ] , ] - preset float=0,inf - datatype text=[join [array names ::nexus::histmem_filetype_spec] , ] - savetype text=save,nosave - force boolean - }] - #scriptcallback connect hmscan SCANEND ::scan::hmscanend_event - #scriptcallback connect bmonscan SCANEND ::scan::bmonscanend_event - scriptcallback connect camscan SCANEND ::scan::cmscanend_event - } message ] { - if {$::errorCode=="NONE"} {return $message} - return -code error $message - } - + MakeAsyncQueue cmserver CAMERA [dict get $::CAMERA_HOSTPORT HOST] [dict get $::CAMERA_HOSTPORT PORT] + MakeCounter cm1 anstocamera cmserver foreach {n v} { + debug 0 clock 1 bin 1 size 2048 @@ -158,12 +34,16 @@ proc ::scan::isc_initialize {} { ystart 1 xend 2048 yend 2048 - exposure 0.777 - temperature -50 + exposure 60 + temperature -80 threshold 800 shutteropentime 100 shutterclosetime 200 } { cm1 setpar $n 0 $v } + + MakeScanCommand camscan cm1 $::cfPath(scan)/dingo.hdd recover.bin + camscan configure script + camscan function count ::scan::cm_count } diff --git a/site_ansto/instrument/dingo/dingo_configuration.tcl b/site_ansto/instrument/dingo/dingo_configuration.tcl index d80c379f..d808ae00 100644 --- a/site_ansto/instrument/dingo/dingo_configuration.tcl +++ b/site_ansto/instrument/dingo/dingo_configuration.tcl @@ -1,8 +1,8 @@ -# Author: Jing Chen (jgn@ansto.gov.au) +# Author: Ferdi Franceschini (ffr@ansto.gov.au) # Required by server_config.tcl VarMake Instrument Text Internal -Instrument dingo +Instrument bare_dingo Instrument lock #START SERVER CONFIGURATION SECTION @@ -14,46 +14,12 @@ MakeDrive ######################################## # INSTRUMENT SPECIFIC CONFIGURATION - -source $cfPath(hipadaba)/hipadaba_configuration.tcl - fileeval $cfPath(source)/source.tcl -fileeval $cfPath(motors)/motor_configuration.tcl -#fileeval $cfPath(motors)/positmotor_configuration.tcl -#fileeval $cfPath(motors)/extraconfig.tcl fileeval $cfPath(plc)/plc.tcl -fileeval $cfPath(counter)/counter.tcl -fileeval $cfPath(hmm)/hmm_configuration.tcl -fileeval $cfPath(nexus)/nxscripts.tcl +fileeval $cfPath(motors)/motor_configuration.tcl fileeval $cfPath(scan)/scan.tcl -fileeval $cfPath(commands)/commands.tcl -fileeval $cfPath(commands)/pulser.tcl -fileeval $cfPath(commands)/hvcommands.tcl -fileeval $cfPath(anticollider)/anticollider.tcl - -source gumxml.tcl - -#::utility::mkVar ::anticollider::protect_detector text manager protect_detector false detector true false -#::anticollider::protect_detector "true" - -# fix all motors -if {1} { - set motorlist "[sicslist type motor]" - puts $motorlist - foreach m $motorlist { - if {$m == "motor" || $m == "dummy_motor"} { - # skipit - } else { - $m fixed 1 - } - } -} server_init - +exe batchpath ../batch +exe syspath ../batch clientput "serverport [get_portnum $::serverport]" - -########################################### -# WARNING: Do not add any code below server_init, if you do SICS may fail to initialise properly. - -# You can add extra-configuration code in ../extraconfig.tcl