# --------------------------------------------------------------------------
# Initialization script for a simulated FOCUS instrument
#
#
# Dr. Mark Koennecke November 1998
#---------------------------------------------------------------------------
#                        O P T I O N S
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 /data/koenneck/src/sics/tmp
#LogFileDir is the directory where the command log is going

ServerOption LogFileBaseName  /data/koenneck/src/sics/tmp/server
# 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 /data/koenneck/src/sics/tcl

#------ 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 Mugger Diethelm  1
SicsUser User   Rosy      2
SicsUser Spy    007       1

#--------------------------------------------------------------------------
#               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  "FOCUS" #initialisation
Instrument lock

VarMake Title Text User
VarMake sample Text User
sample "Altorferit"
VarMake Temperature Float User
Temperature 21.5
Title "Hochdestillierter Schrott"
VarMake User  Text User
User  "Stefan & Felix & Lothar"

#--------- FOCUS special variables
VarMake BeStatus Int User
BeStatus 0
VarMake flightpath Text Mugger
flightpath "Standard"
VarMake flightpathlength Float Mugger
flightpathlength 3000
VarMake ferminame Text Mugger
ferminame "Dornier Fermi Chopper"
ferminame lock
VarMake fermidist Float Mugger
fermidist 3000
VarMake detectordist Float Mugger
detectordist 2500
VarMake sampledist Float Mugger
sampledist 499.7
sampledist lock
VarMake chopperrot Float User
chopperrot 10000
VarMake fermirot Float User
fermirot 12000
VarMake fermiphase Float User
fermiphase 22.23
VarMake environment Text User
environment Void
VarMake delay Float User
delay 155.8
VarMake sampleangle Float User
sampleangle 0.0
#--------------------------------------------------------------------------
#                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
Motor A1 SIM 30.0 120. .1 2.   # Monochromator Theta
Motor A2 SIM 30. 120.  .1 1.   # Monochromator 2Theta
Motor MTL SIM -30. 30.  .1 3.   # mono lower translation
Motor MTU SIM -30. 30.  .1 3.   # mono upper translation
Motor MGU SIM -50. 50.  .1 3.   # mono upper goniometer
Motor MGL SIM -50. 50.  .1 3.   # mono lower goniometer

ClientPut "Motors done"
#--------------------------------------------------------------------------
#                      C O U N T E R S
MakeCounter counter SIM 
#MakeCounter counter EL737 lnsp19.psi.ch 4000 4

#--------------------------------------------------------------------------
#         M U L T I D E V I C E  V A R I A B L E S 
MakeMono Mono "Ge-111" A1 A2
MakeWaveLength lambda Mono
MakeEnergy     qi     Mono
#--------------------------------------------------------------------------
#             P R O C E D U R E S

MakeDrive
MakeRuenBuffer
#---------------- TestVariables for Storage 
VarMake SicsDataPath Text Mugger
SicsDataPath "/data/koenneck/src/sics/"
SicsDataPath lock
VarMake SicsDataPrefix Text Mugger
SicsDataPrefix test
SicsDataPrefix lock
VarMake SicsDataPostFix Text Mugger
SicsDataPostFix ".hdf"
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 "/data/koenneck/src/sics/danu.dat"

SerialInit
Publish serialport User
Publish p1 User
Publish HakleGet User
#------------------ Focus tests
proc chopper {text } {
    ClientPut "chopper.speed = 17050"
    ClientPut "chopper.phase = 13.33" 
}
Publish chopper Spy
#--------- create a time array for histogramming
MakeHM banana SIM 
banana configure HistMode TOF
banana configure OverFlowMode    Ceil
banana configure Rank     1
banana configure Length   76800
banana configure BinWidth 4
banana preset 100.
banana CountMode Timer
banana genbin 120. 35. 512
banana init
MakeFocusAverager average banana

FocusInstall banana focus.dic
