# --------------------------------------------------------------------------
# Initialization script for DMC at SINQ, SICS server.
#
# Dr. Mark Koennecke Juli 1997
#---------------------------------------------------------------------------
#                        O P T I O N S

set auto_path "/home/DMC/bin"

# first all the server options are set

ServerOption ReadTimeOut  100 
# timeout when checking for commands. In the main loop SICS checks for
# pending commands on each connection with the above timeout, has 
# PERFORMANCE impact!

ServerOption AcceptTimeOut  100 
# timeout when checking for connection req.
# Similar to above, but for connections

ServerOption ReadUserPasswdTimeout  500000 
# time to wiat for a user/passwd to be sent from a client. Increase this
# if there is a problem connecting to a server due to network overload\

ServerOption LogFileBaseName  "/home/DMC/log/dmclog"
# the path and base name of the internal server logfile to which all
# activity will be logged.

ServerOption ServerPort 3009
# the port number the server is going to listen at. The client MUST know
# this number in order to connect. It is in client.ini

ServerOption StatusFile /home/DMC/log/simstatus.tcl

ServerOption InterruptPort 3010
# The UDP port where the server will wait for Interrupts from clients.
# Obviously, clients wishing to interrupt need to know this number.

#---------------------------------------------------------------------------
#                        U S E R S

# than the SICS users are specified
# Syntax: SicsUser name password userRightsCode
SicsUser Manager Lucas    1
SicsUser User    DMC      2
SicsUser Spy    007       3
#--------------------------------------------------------------------------
#                D E V I C E S :  M O T O R S

#Motor a4 EL734 LNSP22 4000 5 6
# EL734 motor with parameters: hostname PortNumber Channel MotorID

# Motor nam SIM -20. 20. 5. 1.0
# Simulated motor with name nam, lower limit -20, upper limit +20,
# error ratio 5% and speed 1.0. Speed may be omitted 

# Monochromator motors
Motor  OmegaM    SIM 0 120 1 2.0
Motor  TwoThetaM SIM 30 100 1 1.0
Motor  MonoX     SIM -30 30 1 3.0
Motor  MonoY     SIM -30 30 1 3.0
Motor  CurveM    SIM 0 20 1 3.0
Motor  MonoPhi   SIM -30 30 1 3.0
Motor  MonoChi   SIM -30 30 1 3.0

# sample Table
Motor  Table     SIM -180 360 1 2.
Motor  TwoThetaD SIM -10  120 1 1.
#--------------------------------------------------------------------------
#                          Configure Detector
# needs a EL737 or simualation for count control
MakeCounter counter SIM

MakeHM banana SIM     
banana configure HistMode Normal
banana configure OverFlowMode    Ceil
banana configure Rank     1
banana configure Length   400
banana configure BinWidth 4
banana preset 100.
banana CountMode Timer
#banana configure HMComputer psds04.psi.ch
#banana configure HMPort 2400
#banana configure Counter counter
banana init
#--------------------------------------------------------------------------
#     C O N F I G U R E     D E V I C E S     T O    H A L T  I N
#                        I N T E R R U P T 
AddHalt  OmegaM TwoThetaM MonoX MonoY MonoChi MonoPhi CurveM Table TwoThetaD
#--------------------------------------------------------------------------
#                        V A R I A B L E S

# now a few general variables are created
# Syntax: VarMake name type access
# type can be one of: Text, Int, Float
#access can be one of: Internal, Mugger, User, Spy


VarMake SicsDataPath Text Internal
SicsDataPath "/home/DMC/sim/"
VarMake DetStepWidth Float Internal
DetStepWidth 0.02


VarMake Instrument Text Internal 
Instrument "DMC at SINQ,PSI" 
#initialisation

VarMake Title Text User
VarMake User  Text User
VarMake Collimation Text User
VarMake Sample Text User
Sample Kellerit
VarMake Temperature Float User
Temperature  21.3897
VarMake comment1 Text User
VarMake comment2 Text User
VarMake comment3 Text User

VarMake SicsDataPrefix Text Internal
SicsDataPrefix dmc
VarMake SicsDataNumber Int Mugger
SicsDataNumber 0
VarMake SicsDataPostFix Text Internal
SicsDataPostFix "97.hdf"
VarMake Adress Text User
VarMake phone  Text User
VarMake fax    Text User
VarMake email  Text User
VarMake sample_mur Float User

  

# Monochromator variables 
# Syntax MakeMono name type  OmegaMotor 2ThetaMotor CurveMotor1 CurveMotor2
MakeMono Mono "Ge-111" OmegaM TwoThetaM 
Mono DD 3.3537
# Syntax MakeWaveLength name MonochromatorToUse
MakeWaveLength lambda  Mono
 
             
#--------------------------------------------------------------------------
#                           P R O C E D U R E S

# create the drive command
MakeDrive
#start RuenBuffer system
MakeRuenBuffer

# aliases
SicsAlias OmegaM    A1
SicsAlias TwoThetaM A2
SicsAlias Table     A3
SicsAlias TwoThetaD A4
InitDMC

#----- The Logbook stuff
source "/home/DMC/bin/log.tcl"
Publish LogBook User
#------ The count command 
source "/home/DMC/bin/count.tcl"
Publish count   User
Publish Repeat  User
#------ The scan command for Managers
source "/home/DMC/bin/scan.tcl"
Publish scan    Mugger

