-
Notifications
You must be signed in to change notification settings - Fork 0
20191114
Dan Avner edited this page Nov 14, 2019
·
1 revision
Diving into azcam focus routine and communicating with galil server
- to communicate with the remote instrument server, we must open and close the socket each time.
CLASS InstrumentServerInterface
Open
- creates a socket with a timeout of 60 seconds
- host =
- port =
Close
- closes the socket
Command
- opens the socket
- sends ENCODED string “UTF-8”
- sends the command and terminator
- terminator = “\r\n”
- gets reply and checks reply[0] if it equals “OK”
- if so, decodes the reply and runs through function recv with parameters (-1, “\n”)
- closes socket
- returns reply
Command1
- dont know if this is used
Send
- sends the command and the terminator
Recv
- receives a reply from the socket
- terminates the socket when length bytes are received or terminator is received
- terminator = “\n”
- passes a -1 to length to read through the terminator
- passes a -2 to length to read 1024 bytes
- passes a length parameter to read that amount of bytes
- must DECODE what received
- if length is -1 (or end on terminator)
- reads in chunks 1 byte at a time and decodes that byte
- checks to see if byte is “” (empty)
- if so adds to a loop variable and if that loop variable gets bigger than 10, issues error and returns
- guess it does this is the terminator never arrives
- builds the message
- resets loop to 0
- checks to see if the chunk is the terminator and if so stop, if not continue looping
- returns the msg chopping off the CR/LF
CLASS PrimeFocusInstrument
- port = 9874
- host = 10.30.1.2 which is bart
- locked = needed to lock communications with galilserver
- uses bokpop
- creates an Iserver with that host and port so use that to talk to galil server with a timeout of 20.
command
- turns lock to true
- if lock is already true, sleep for 0.01
- sends command with no terminator since it is automatically applied
- receives with length (-2) so reads 1024 bytes
- sets reply to reply[1] so passes over reply[0]
- sends command “CLIENTDONE” with no terminator
- receives that command with length -2 so reads 1024 bytes
- ignores it
- closes the socket
- REPLIES
- valid replies starts with “OK: “ and errors start with “?: “
- if reply startswith “OK: “
- slices reply from [4:]
- removes the lock
- closes the iserver
- returns reply
- if not
- removes the lock
- closes the iserver
- returns reply
SKIPPING FILTERS FOR NOW
get_focus
- calls get_focus_all and returns a single LVDT focus position
get_focus_all
- return string is formatted as “LVDT_ALVDT_BLVDT_C”
- “01.12301.12301.123”
- sends command “SHOWALLLVDTVALS” to get current LVDT values
- uses command function and cmd string
- I believe it will fully return “OK: LVDT_ALVDT_BLVDT_C”
step_focus
- moves all 3 actuators for instrument focus by specified amount all relative stepper motor steps
- one focus actuator step is 2.645 microns which is -0.0005 LVDT unites. So conversion is -1322.5 um/LVDT unit
- command is ALLFOCUS XXX where XXX is the integer amount to relative move stepper motor
- uses command function above
- then grabs all lvdt values and calculates the mean
- if the delta of the initial mean and current mean is less than 2 then break and everything is happy
get_mean_focus
- grabs LVDT values A, B, C and calculates the mean for them
set_focus
- reported as wrong
set_focus_all
- moves each of the 3 actuators for instrument focus by a specified amount in relative stepper motor steps
- command is FOCUS XXX YYY ZZZ where
- XXX is actuator A
- YYY is actuator B
- ZZZ is actuator C
- dont know what it returns, I assume “OK: “ + something
CSS email Hi Alex,
Here is what I have pieced together so far for your focus scripts.
All communication must go through galilserver which runs on Bart Host IP: 10.30.1.2 Port: 9874
Successful commands return “OK: “ + message Errors return “?: “ + message
Send ends in “\r\n” Received end in “\n”
To send a command, follow the procedure:
- Open socket
- Receive reply
- each reply ends with “\n”
- Receive reply
- Send command
- each command must end with “\r\n”
- Receive reply
- Send command “CLIENTDONE”
- Must shutdown socket like this
- Receive reply
- Close socket
One focus actuator step is 2.645 microns which is -0.0005 LVDT units Conversion: -1322.5 microns per LVDT unit