It supports the new "fakedev" simulation mode which runs SICS with real drivers for devices which have simulated controllers. There are advance options which allow multiple instances of SICS to be launched on development and test environments. Also we no longer depend on having serverport numbers in /etc/services.
345 lines
10 KiB
Tcl
345 lines
10 KiB
Tcl
# SICS common configuration
|
|
|
|
# Author: Ferdi Franceschini (ffr@ansto.gov.au)
|
|
|
|
#set sicsroot /usr/local/sics
|
|
VarMake sicsdebug Int Mugger
|
|
sicsdebug 0
|
|
set telnetport 60001
|
|
set interruptport 60002
|
|
set serverport 60003
|
|
set quieckport 60004
|
|
|
|
# Simulation flags, possible values = true or false
|
|
# true: The simulated driver will be used.
|
|
# false: The real driver will be used.
|
|
# icsval column = settings when running on the Instrument Control Server (ie SICS_SIMULATION not defined)
|
|
# fakedev column = settings for test platforms (ie SICS_SIMULATION=fakedev)
|
|
foreach {simflag icsval fakedev} {
|
|
opal_simulation true true
|
|
detector_simulation false true
|
|
hmm_simulation false true
|
|
environment_simulation false true
|
|
counter_simulation false false
|
|
motor_simulation false false
|
|
chopper_simulation false false
|
|
velsel_simulation false false
|
|
plc_simulation false true
|
|
rfgen_simulation false false
|
|
goniometer_simulation false true
|
|
magnetic_simulation false true
|
|
} {
|
|
dict set SIMFLAG_VAL $simflag ICSVAL $icsval
|
|
dict set SIMFLAG_VAL $simflag FAKEDEV $fakedev
|
|
VarMake $simflag Text internal
|
|
}
|
|
|
|
VarMake sics_simulation Text internal
|
|
|
|
source util/utility.tcl
|
|
source util/script_context_util.tcl
|
|
|
|
proc syncbackup {file} {
|
|
backup motorSave
|
|
backup $file
|
|
backup motorSave
|
|
}
|
|
publish syncbackup Spy
|
|
if [info exists env(SOCKOFFSET)] {
|
|
set telnetport [expr {$telnetport + $env(SOCKOFFSET)}]
|
|
set interruptport [expr {$interruptport + $env(SOCKOFFSET)}]
|
|
set serverport [expr {$serverport + $env(SOCKOFFSET)}]
|
|
set quieckport [expr {$quieckport + $env(SOCKOFFSET)}]
|
|
}
|
|
if {[info exists env(SICS_SIMULATION)] != 1} {
|
|
set sicsroot ../
|
|
source sics_ports.tcl
|
|
sics_simulation false
|
|
dict for {simflag d} $SIMFLAG_VAL {
|
|
$simflag [dict get $d ICSVAL]
|
|
}
|
|
if [file exists hostport_config.tcl] {
|
|
fileeval hostport_config.tcl
|
|
} else {
|
|
#TODO SICS-587 Abort with error when all instruments have been refactored.
|
|
clientput WARNING: hostport_config.tcl is missing
|
|
# sics_exitus
|
|
}
|
|
} else {
|
|
if [file exists hostport_config_test.tcl] {
|
|
fileeval hostport_config_test.tcl
|
|
} else {
|
|
#TODO SICS-587 Abort with error when all instruments have been refactored.
|
|
clientput ERROR: hostport_config_test.tcl is missing
|
|
sics_exitus
|
|
}
|
|
switch $env(SICS_SIMULATION) {
|
|
"full" {
|
|
set sicsroot ../
|
|
sics_simulation true
|
|
}
|
|
"fakedev" {
|
|
set sicsroot ../
|
|
sics_simulation fakedev
|
|
}
|
|
"script_validator" {
|
|
VarMake sics_script_validator Text internal
|
|
sics_script_validator true
|
|
set sicsroot ../script_validator/
|
|
set telnetport [expr {$telnetport + 10}]
|
|
set interruptport [expr {$interruptport + 10}]
|
|
set serverport [expr {$serverport + 10}]
|
|
set quieckport [expr {$quieckport + 10}]
|
|
sics_simulation true
|
|
MakeSync localhost $serverport spy 007 ../log/syncfile.tcl
|
|
}
|
|
default {
|
|
error "ERROR: SICS_SIMULATION must be full, script_validator, or fakedev, not $env(SICS_SIMULATION)"
|
|
sics_exitus
|
|
}
|
|
}
|
|
|
|
# Set obj_simulation flags for each SICS_SIMULATION mode
|
|
switch $env(SICS_SIMULATION) {
|
|
"full" - "simdriv" - "script_validator" {
|
|
dict for {simflag d} $SIMFLAG_VAL {
|
|
$simflag true
|
|
}
|
|
}
|
|
"fakedev" {
|
|
dict for {simflag d} $SIMFLAG_VAL {
|
|
$simflag [dict get $d FAKEDEV]
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
set cfParent config
|
|
|
|
#WARNING Make sure there are no spaces after the back-slashes
|
|
array set cfPath [list\
|
|
parameters $cfParent/parameters\
|
|
source $cfParent/source\
|
|
anticollider $cfParent/anticollider\
|
|
motors $cfParent/motors\
|
|
optics $cfParent/optics\
|
|
counter $cfParent/counter\
|
|
chopper $cfParent/chopper\
|
|
environment $cfParent/environment\
|
|
hmm $cfParent/hmm\
|
|
scan $cfParent/scan\
|
|
velsel $cfParent/velsel\
|
|
nexus $cfParent/nexus\
|
|
hipadaba $cfParent/hipadaba\
|
|
plc $cfParent/plc\
|
|
commands $cfParent/commands\
|
|
beamline $cfParent/beamline\
|
|
goniometer $cfParent/goniometer\
|
|
tasmad $cfParent/tasmad\
|
|
robots $cfParent/robots\
|
|
]
|
|
|
|
ServerOption LogFileBaseName $sicsroot/log/serverlog
|
|
|
|
installprotocolhandler
|
|
|
|
|
|
ServerOption statusfile $sicsroot/log/status.tcl
|
|
ServerOption RedirectFile $sicsroot/log/stdout
|
|
ServerOption LogFileDir $sicsroot/log
|
|
ServerOption QuieckPort [get_portnum $quieckport ]
|
|
ServerOption ServerPort [get_portnum $serverport ]
|
|
ServerOption InterruptPort [get_portnum $interruptport ]
|
|
ServerOption TelWord sicslogin
|
|
ServerOption TelnetPort [get_portnum $telnetport ]
|
|
ServerOption ReadUserPasswdTimeout 600000
|
|
ServerOption AcceptTimeOut 10
|
|
ServerOption ReadTimeOut 10
|
|
SicsUser manager ansto 1
|
|
SicsUser user sydney 2
|
|
SicsUser spy 007 3
|
|
|
|
MakeDataNumber SicsDataNumber $sicsroot/DataNumber
|
|
|
|
#Instrument specific configs must set the Instrument variable
|
|
::utility::mkVar SicsDataPrefix Text internal
|
|
SicsDataPrefix [SplitReply [Instrument]]
|
|
|
|
::utility::mkVar SicsDataPostFix Text manager
|
|
SicsDataPostFix nx.hdf
|
|
|
|
foreach {var val klass priv} {
|
|
program_name "SICS" entry manager
|
|
run_mode "normal" entry user
|
|
} {
|
|
::utility::mkVar $var Text $priv $var true $klass true true
|
|
$var $val
|
|
}
|
|
|
|
::utility::mkVar SicsDataPath Text internal
|
|
SicsDataPath $sicsroot/data/
|
|
SicsDataPath lock
|
|
::utility::mkVar Title Text user title true experiment true true
|
|
::utility::mkVar SampleDescription Text user description true sample true true
|
|
::utility::mkVar SampleName Text user name true sample true true
|
|
::utility::mkVar SampleTitle Text user short_title true sample true true
|
|
::utility::mkVar User Text user name true user true true
|
|
::utility::mkVar Email Text user email true user true true
|
|
::utility::mkVar Phone Text user phone true user true true
|
|
::utility::mkVar starttime Text user start true experiment true true
|
|
|
|
exe batchpath ../batch
|
|
exe syspath ../batch
|
|
|
|
|
|
::utility::mkVar dataFileName Text user file_name true experiment true true
|
|
|
|
##
|
|
# @brief Internal action command procedure
|
|
proc _action {drivecmd obj action args} {
|
|
if [ catch {
|
|
if { [SplitReply [sicslist $obj type]] != "ActionObject" } {
|
|
error "ERROR: $obj must be an ActionObject"
|
|
}
|
|
$obj act $action
|
|
$drivecmd $obj 1
|
|
} message ] {
|
|
if {$::errorCode=="NONE"} {return $message}
|
|
return -code error $message
|
|
}
|
|
}
|
|
|
|
##
|
|
# @brief Non-blocking action command
|
|
proc action {obj action args} {
|
|
if [ catch {
|
|
_action run $obj $action $args
|
|
} message ] {
|
|
if {$::errorCode=="NONE"} {return $message}
|
|
return -code error $message
|
|
}
|
|
}
|
|
publish action user
|
|
|
|
##
|
|
# @brief Blocking action command, this will wait for the action to complete.
|
|
proc waitaction {obj action args} {
|
|
if [ catch {
|
|
_action drive $obj $action $args
|
|
} message ] {
|
|
if {$::errorCode=="NONE"} {return $message}
|
|
return -code error $message
|
|
}
|
|
}
|
|
publish waitaction user
|
|
|
|
proc server_set_sobj_attributes {} {
|
|
if [ catch {
|
|
motor_set_sobj_attributes
|
|
::utility::set_motor_attributes
|
|
#XXX::utility::set_histomem_attributes
|
|
::utility::set_sobj_attributes
|
|
::utility::set_envcontrol_attributes
|
|
::plc::set_sobj_attributes
|
|
::counter::set_sobj_attributes
|
|
::nexus::set_sobj_attributes
|
|
::histogram_memory::set_sobj_attributes
|
|
::utility::set_chopper_attributes
|
|
::utility::set_sct_object_attributes
|
|
## TODO move the following to the new ansto gumxml.tcl
|
|
sicslist setatt getgumtreexml privilege internal
|
|
clientput "serverport [get_portnum $::serverport]"
|
|
} message ] {
|
|
if {$::errorCode=="NONE"} {return $message}
|
|
return -code error $message
|
|
}
|
|
}
|
|
|
|
proc server_init {} {
|
|
global AUTOSAVE_STATE
|
|
|
|
set catch_status [ catch {
|
|
::source::isc_initialize
|
|
::counter::isc_initialize
|
|
::histogram_memory::isc_initialize
|
|
::scan::isc_initialize
|
|
::anticollider::init
|
|
::commands::isc_initialize
|
|
::nexus::isc_initialize
|
|
########
|
|
# Parameters set above the restore command will be clobbered by
|
|
# the values in the status.tcl file
|
|
if [file exists $::sicsroot/log/status.tcl ] {
|
|
restore
|
|
}
|
|
file_status "UNKNOWN"
|
|
|
|
MakeStateMon hmscan
|
|
sicslist setatt sics_suid privilege readonly
|
|
sicslist setatt sics_suid klass data
|
|
sicslist setatt sics_suid kind hobj
|
|
sicslist setatt sics_suid mutable true
|
|
sicslist setatt sics_suid data true
|
|
sicslist setatt sics_suid control true
|
|
sicslist setatt sics_suid nxsave true
|
|
sicslist setatt sics_suid long_name sics_suid
|
|
|
|
set AUTOSAVE_STATE "DISABLED"
|
|
|
|
if [file exists ../extraconfig.tcl] {
|
|
fileeval ../extraconfig.tcl
|
|
}
|
|
server_set_sobj_attributes
|
|
buildHDB instrument_dictionary
|
|
|
|
} message ]
|
|
handle_exception $catch_status $message
|
|
}
|
|
|
|
proc doAutosave {} {
|
|
global AUTOSAVE_STATE
|
|
|
|
# Reset the AUTOSAVE_STATE variable in case some naughty user sets it directly
|
|
set AUTOSAVE_STATE "ENABLED"
|
|
set HMSTATE [SplitReply [hmm configure daq]]
|
|
set FSTATE [SplitReply [file_status]]
|
|
#broadcast CALLED: [info level 0], HMSTATE = $HMSTATE, FSTATE = $FSTATE
|
|
if { $FSTATE != "UNKNOWN" && $FSTATE != "OPEN" && $HMSTATE == "Started"} {
|
|
set saveIndex [SplitReply [autosaveIndex] ]
|
|
broadcast autosave $saveIndex
|
|
save $saveIndex "autosave"
|
|
}
|
|
}
|
|
publish doAutosave user
|
|
proc autosave { {interval 300} } {
|
|
global AUTOSAVE_STATE
|
|
|
|
if {$interval == "check"} {
|
|
if { $AUTOSAVE_STATE == "ENABLED" } {
|
|
return "AUTOSAVE $AUTOSAVE_STATE [sicspoll intervall doAutosave]"
|
|
} else {
|
|
return "AUTOSAVE $AUTOSAVE_STATE"
|
|
}
|
|
} elseif {[string is integer $interval]} {
|
|
if {$interval <= 0} {
|
|
if { $AUTOSAVE_STATE == "ENABLED" } {
|
|
sicspoll del doAutosave
|
|
set AUTOSAVE_STATE "DISABLED"
|
|
}
|
|
} else {
|
|
if {$AUTOSAVE_STATE == "DISABLED"} {
|
|
sicspoll add doAutosave script $interval doAutosave
|
|
# sicspoll listen # WARNING:When the listening client exits it leaves SICSPOLL task with a corrupt connection object.
|
|
set AUTOSAVE_STATE "ENABLED"
|
|
} else {
|
|
sicspoll intervall doAutosave $interval
|
|
}
|
|
}
|
|
} else {
|
|
return -code error "ERROR: Invalid argument in '[info level 0]', should be an integer or 'check'"
|
|
}
|
|
|
|
|
|
}
|
|
publish autosave user
|