# --------------------------------------------------------------------------
# Initialization script for the TRICS instrument
#
#
# Dr. Mark Koennecke November, 1996
#---------------------------------------------------------------------------
#                        O P T I O N S
set home /data/koenneck/src/sics/tmp

# 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  7000 
# 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 LogFileDir $home/log 
#LogFileDir is the directory where the command log is going

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


ServerOption ServerPort 2911
# 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 InterruptPort 2914
# 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

ServerOption DefaultTclDirectory $home/bin

#------ a port for broadcasting UDP messages
ServerOption QuieckPort 2108

TokenInit connan

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

# than the SICS users are specified
# Syntax: SicsUser name password userRightsCode
SicsUser Jurg   willibald 1
SicsUser Spy    007     3

#--------------------------------------------------------------------------
#               S I M P L E     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 Instrument Text Internal
Instrument  "TRICS" #initialisation
Instrument lock

VarMake Title Text User
VarMake sample Text User
sample "Scheferit"
VarMake User  Text User
User  "Jurg"
VarMake distance Float User
VarMake monochromator  Text User
VarMake lambda Float Mugger

#--------------------------------------------------------------------------
#                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 D1V EL734 lnsp22.psi.ch 4000 3 3

#------------ Monochromator Motors
ClientPut "Initialising Elephant"
Motor MOMU  EL734 lnsp18.psi.ch 4000 4 9
Motor MTVU  EL734 lnsp18.psi.ch 4000 4 11
Motor MTPU  EL734 lnsp18.psi.ch 4000 4 10
Motor MGVU  EL734 lnsp18.psi.ch 4000 4 5
Motor MGPU  EL734 lnsp18.psi.ch 4000 4 12
Motor MCVU  EL734 lnsp18.psi.ch 4000 4 6
Motor MOML  EL734 lnsp18.psi.ch 4000 4 7
Motor MTVL  EL734 lnsp18.psi.ch 4000 4 1
Motor MTPL  EL734 lnsp18.psi.ch 4000 4 8
Motor MGVL  EL734 lnsp18.psi.ch 4000 4 3
Motor MGPL  EL734 lnsp18.psi.ch 4000 4 2
Motor MCVL  EL734 lnsp18.psi.ch 4000 4 4
Motor MEXZ  EL734 lnsp18.psi.ch 4000 5 1

#------------- Sample Table Motors
ClientPut "Initialising Sample Table Motors"
Motor SOM   EL734 lnsp18.psi.ch 4000 2 2
Motor STT   EL734 lnsp18.psi.ch 4000 2 1
Motor SCH   EL734 lnsp18.psi.ch 4000 2 3
Motor SPH   EL734 lnsp18.psi.ch 4000 2 4
Motor DG1   EL734 lnsp18.psi.ch 4000 2 5
Motor DG2   EL734 lnsp18.psi.ch 4000 2 6
Motor DG3   EL734 lnsp18.psi.ch 4000 2 7

#------------- Collimators
Motor CEX1   EL734 lnsp18.psi.ch 4000 3 1
Motor CEX2   EL734 lnsp18.psi.ch 4000 3 2

#------------- Motor Aliases
#SicsAlias CEX1 A17
#SicsAlias CEX2 A18
SicsAlias MOMU A1
SicsAlias MTVU A12
SicsAlias MTPU A13
SicsAlias MGVU A14
SicsAlias MGPU A15
SicsAlias MCVU A16
SicsAlias MOML B1
SicsAlias MTVL A22
SicsAlias MTPL A23
SicsAlias MGVL A24
SicsAlias MGPL A25
SicsAlias MCVL A26
SicsAlias MEXZ A37
SicsAlias SOM A3
SicsAlias SOM OM
SicsAlias STT A4
SicsAlias STT TH
SicsAlias SCH A10
SicsAlias SPH A20
SicsAlias SCH CH
SicsAlias SPH PH
SicsAlias DG1 A31
SicsAlias DG2 A32
SicsAlias DG3 A33

#--------------------------------------------------------------------------
#                      C O U N T E R S
MakeCounter counter EL737 lnsp18.psi.ch 4000 6

MakeO2T  O2T OM TH
#--------------------------------------------------------------------------
#             P R O C E D U R E S
MakeDrive
MakeRuenBuffer
#---------------- TestVariables for Storage 
VarMake SicsDataPath Text Mugger
SicsDataPath "$home/data/"
SicsDataPath lock
VarMake SicsDataPrefix Text Mugger
SicsDataPrefix trics
SicsDataPrefix lock
VarMake SicsDataPostFix Text Mugger
SicsDataPostFix ".asc"
SicsDataPostFix lock

VarMake Adress Text User
VarMake phone  Text User
VarMake fax    Text User
VarMake email  Text User
VarMake sample_mur Float User

MakeDataNumber SicsDataNumber "$home/data/DataNumber"

VarMake lastscancommand Text Spy
MakeScanCommand  xxxscan counter $home/bin/trics.hdd recover.bin
MakePeakCenter xxxscan


source $home/bin/topsicom.tcl
set home /home/TRICS
source $home/bin/cscan.tcl
source $home/bin/log.tcl
Publish cscan User
Publish scan Spy
Publish scaninfo Spy
Publish sscan User
Publish sftime Spy
SerialInit
Publish serialport User
Publish p1 User
#------------------ 4 circle stuff
MakeHKL TH OM CH PH
HKL lambda 0.70379
HKL setub -0.1247023 0.0016176 -0.0413566  \
          -0.1044479 -0.0013264 0.0493878 \
          0.0007513  0.0840941 0.0015745
MakeOptimise opti counter

ClientPut "DONE initialsing TRICS"
