# --------------------------------------------------------------------------
# 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 3006 
# 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/status.tcl

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

# Telnet Options
ServerOption TelnetPort 1301
ServerOption TelWord sicslogin

#The UDP port for sending quieck messages, telling the world of new data
ServerOption QuieckPort 2108

#the token system + the token force grab password
TokenInit connan
#---------------------------------------------------------------------------
#                        U S E R S

# than the SICS users are specified
# Syntax: SicsUser name password userRightsCode
SicsUser Manager Lucas    1
SicsUser lnsmanager lnsSICSlns   1
SicsUser User    DMC      2
SicsUser lnsuser 98lns2   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
ClientPut "Installing Motors"
Motor  OmegaM    EL734 lnsp19.psi.ch 4000 2 1
Motor  TwoThetaM EL734 lnsp19.psi.ch 4000 2 2
Motor  MonoX     EL734 lnsp19.psi.ch 4000 2 5
Motor  MonoY     EL734 lnsp19.psi.ch 4000 2 6
Motor  CurveM    EL734 lnsp19.psi.ch 4000 2 9
Motor  MonoPhi   EL734 lnsp19.psi.ch 4000 2 7
Motor  MonoChi   EL734 lnsp19.psi.ch 4000 2 8

# sample Table
Motor  Table     EL734 lnsp19.psi.ch 4000 2 3
Motor  TwoThetaD EL734 lnsp19.psi.ch 4000 2 4
#--------------------------------------------------------------------------
#                          Configure Detector
# needs a EL737 or simualation for count control
ClientPut "Installing counter"
MakeCounter counter EL737 lnsp19.psi.ch 4000 4
counter SetExponent 6

MakeHM banana SINQHM        
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 lnse01.psi.ch
banana configure HMPort 2400
banana configure Counter counter
banana init
banana exponent 6

#--------------------------------------------------------------------------
#                        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/data/"
VarMake DetStepWidth Float Internal
DetStepWidth 0.2
DetStepWidth lock


VarMake Instrument Text Internal 
Instrument "DMC"
Instrument lock 
#initialisation

VarMake Title Text User
VarMake User  Text User
VarMake Collimation Text User
VarMake Sample Text User
Sample Kellerit
VarMake comment1 Text User
VarMake comment2 Text User
VarMake comment3 Text User

VarMake SicsDataPrefix Text Internal
SicsDataPrefix dmc
#--------- make data number
MakeDataNumber SicsDataNumber /home/DMC/data/DataNumber

VarMake SicsDataPostFix Text Internal
SicsDataPostFix ".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
SicsAlias MonoX     A5
SicsAlias MonoY     A6
SicsAlias MonoPhi   A7
SicsAlias MonoChi   A8
SicsAlias CurveM    A9
InitDMC

#----- The Logbook stuff
source "/home/DMC/bin/log.tcl"
Publish LogBook Spy
#------ 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

#---------install beam command
source beamdt.tcl
