#%TITLE% SHUT.MAC
#%NAME%
# A simple macro package to pulse, open or close a shutter (ICV196)
#%DESCRIPTION%
# A shutter (or any other relay) can be opened or closed.
#%EXAMPLE%
#%DL%
#%DT% shutopen 0 %DD% (opens shutter 0)
#%DT% shutclose %DD% (closes shutter 0, remembers last channel used)
#%DT% shutpuls 10 %DD% (opens the shutter 0 for 10 seconds)
#%DT% shutwait Close %DD% (wait until shutter is closed again)
#%XDL%
#%END%
global SHUTMACLOADED
#%UU% [relay device name] [pulsed relay device name]
#%MDESC%
# The name of the device servers are used in all the macros. Input the
# first two parts of the device server name only (for ex. ID/ID112pulsed)
# The last part will be the number of the channel.
def shutsetup '{
local devr devp
if ($# > 2) {
print "Usage: shutsetup [relay device name] [pulsed relay device name]"
}
if ($# < 1) {
devr = getval("How is your relay device called? ",devr)
}
else {
devr = "$1"
}
if ($# < 2) {
devp = getval("How is your pulsed relay device called? ", devp)
}
else {
devp = "$2"
}
shutsetupf (devr, devp)
}'
#%UU% (relay device name, pulsed relay device name)
#%MDESC%
# Same as shutsetup, but defined as a function. If one of the relay types
# is not used, NULL has to be specified.
def shutsetupf (rel, pulsed) '{
global SHUT_DEVR SHUT_DEVP
global RELAY_NO
SHUT_DEVR = rel
SHUT_DEVP = pulsed
}'
#%UU% [channel]
#%MDESC%
# Opens the shutter. If no channel is given the channel will be taken
# from the last shutter command.
def shutopen '{
if ($#)
RELAY_NO = "$1"
esrf_io(sprintf("%s/%s",SHUT_DEVR,RELAY_NO),"DevOpen")
}'
#%UU% [channel]
#%MDESC%
# Like above. Closes the shutter
def shutclose '{
if ($#)
RELAY_NO = "$1"
esrf_io(sprintf("%s/%s",SHUT_DEVR,RELAY_NO),"DevClose")
}'
#%UU% [channel]
#%MDESC%
# Reads the current shutter state (Open or Closed)
def shutread '{
if ($#)
RELAY_NO = "$1"
printf("Relay No %d state:%s\n",RELAY_NO,(esrf_io(sprintf("%s/%s",SHUT_DEVR,RELAY_NO),"DevReadValue")==3)?"Closed" : "Open")
}'
#%UU% <time in s> [channel]
#%MDESC%
# Pulses (opens for a certain time) the shutter. The timing will be done on
# OS9 level.
def shutpuls '{
if ($# == 0)
print "Usage: shutpuls <time in s> [channel no]"
if ($# > 1 )
RELAY_NO = "$2"
esrf_io(sprintf("%s/%s",SHUT_DEVP,RELAY_NO),"DevReset",$1*256)
}'
#%UU% O[pen]|C[lose] [channel]
#%MDESC%
# Waits until the given shutter is Open or Closed
def shutwait '{
local ans state
if ($# == 0)
print "Usage: shutwait Open|Close [channel no]"
ans = substr("$1",0,1)
state = 4
if ((ans == "O") || (ans == "o"))
state = 4
else if ((ans == "C") || (ans == "c"))
state = 3
else
print "Usage: shutwait Open|Close [channel no]"
if ($# > 1)
RELAY_NO = "$2"
while (esrf_io(sprintf("%s/%s",SHUT_DEVP,RELAY_NO),"DevReadValue") != state) {}
}'
#%MACROS%
#%IMACROS%
#%DEPENDECIES%
#%UL%
#%LI% The device server %B%Relay%B% or(and) %B%Pulsed relay%B% has to run
#on the OS9 crate
#%LI% The %B%shut.mac%B% file has to be loaded done by: startup script
#%LI% The device has to be setup : shutsetup done by: startup script
# (the device server for the pulsed relay and
# normal relay has to be different)
#%XUL%
#%AUTHOR%Jorg Klora
#$Revision: 2.3 $, $Date: 1999/07/30 10:14:45 $
#%TOC%
|