- Fixed a enable PV initialisation bug in MasterMACS

- Made the HRPT axis base itself on V3 of the pmacAxis
- Improved and added utils programs
This commit is contained in:
2024-06-07 08:58:53 +02:00
parent d9d6dae19f
commit 30228adf50
8 changed files with 156 additions and 25 deletions

View File

@ -1,3 +1,4 @@
#!/usr/bin/env python3
"""
Usage: macmaster.py macmasterhost port
Listen for commands to send and returns reponse

58
utils/physhell.tcl Executable file
View File

@ -0,0 +1,58 @@
#!/usr/bin/tclsh
# This is a little program which acts as a shell to the phytron.
# It connects to another program which is supposed to talk to the phytron controller
# It reads from stdin, packages the message into the phytron format and sends it to
# the phytron communication program. Then it reads from the phytron communication program
# and unpacks the reply.
#
# This is also a nice exampe for dealing with binary in Tcl
# Making the binary character only worked with %c
# The only way to do the comparison is with the string comare
#
# Mark Könnecke, September 2016
if {[llength $argv] < 1} {
puts stdout "Usage:\n\t physhell.tcl phytronprogram"
exit
}
set phprogram [lindex $argv 0]
set phyio [open "| $phprogram" "w+b"]
fconfigure $phyio -buffering none
fconfigure $phyio -translation {binary binary}
set etx [format "%c" 0x03]
set stx [format "%c" 0x02]
set ack [format "%c" 0x06]
set nack [format "%c" 0x05]
while {1} {
set inp [gets stdin]
puts -nonewline $phyio [format "%c%s%c" 0x02 $inp 0x03]
set mode start
set reply ""
while {[string compare $mode done] != 0 } {
set c [read $phyio 1]
switch $mode {
start {
if {[string compare $c $stx] == 0} {
set mode data
}
}
data {
if {[string compare $c $etx] == 0} {
puts stdout $reply
set mode done
} elseif {[string compare $c $nack] == 0} {
append reply NACK
} elseif {[string compare $c $ack] == 0} {
append reply ACK
} else {
append reply $c
}
}
}
}
}

View File

@ -11,6 +11,7 @@ Mark Koennecke, January 2023
import socket
import sys
import time
socke = None
sockfd = None
@ -33,6 +34,7 @@ def transact(command):
global socke, sockfd
sockfd.write(command + '\r')
sockfd.flush()
time.sleep(.1)
return sockfd.readline()
def find_commas(rawline):
@ -61,8 +63,10 @@ def fix_line(par_list, index_list):
addridx = index_list.index('ADDR')
motNo = par_list[addridx]
limits = transact('H ' + motNo)
time.sleep(.1)
l = limits.split()
lowidx = index_list.index('DLLM')
# import pdb; pdb.set_trace()
par_list[lowidx] = l[0]
highidx = index_list.index('DHLM')
par_list[highidx] = l[1]
@ -93,7 +97,7 @@ def scan_substitution_file(filename):
newlist = fix_line(l, index_list)
# newline = ','.join(newlist)
newline = pretty_line(newlist, comma_list)
sys.stdout.write('{' + newline)
sys.stdout.write('{' + newline + '\n')
else:
sys.stdout.write(rawline)
rawline = fin.readline()