Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds restart_rssi script #448

Merged
merged 1 commit into from
Nov 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions scripts/restart_rssi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import epics
import sys
import time
import argparse

parser = argparse.ArgumentParser()
parser.add_argument('slot', type=int)
parser.add_argument('--debug', action='store_true')

args = parser.parse_args()

slot=args.slot
debug=args.debug

# levels
pcie_root='pcie_test0'
pcie_top='pcie:'
pcie_core='Core:'
pcie_udpgrp='UdpGrp:'
pcie_udpengine='UdpEngine[{}]:'
pcie_rssiclient='RssiClient[{}]:'

# regs
client_remote_ip0=pcie_root+':'+pcie_top+pcie_core+pcie_udpgrp+pcie_udpengine+'ClientRemoteIp[0]'
rssi_validcnt=pcie_root+':'+pcie_top+pcie_core+pcie_udpgrp+pcie_rssiclient+'ValidCnt'
rssi_restartconn=pcie_root+':'+pcie_top+pcie_core+pcie_udpgrp+pcie_rssiclient+'C_RestartConn'

# which slots are assigned to which udp engines
slot2udpe={}
nudpe=6
ipbyeng=[epics.PV(name).get(as_string=True) for name in [client_remote_ip0.format(iudpe) for iudpe in range(nudpe)]]

slots={}
for idx,ibe in enumerate(ipbyeng):
s=int(ibe.split('.')[-1])-100
if s>0:
slots[s]={}
slots[s]['engine']=idx

if slot not in slots.keys():
print(f'Requested slot {slot} not one of the available slots (={[int(k) for k in slots.keys()]}). Doing nothing!')
sys.exit(1)
else:
print(f'Restarting RSSI connection for slot {slot}.')
validcntpv=epics.PV(rssi_validcnt.format(slots[slot]['engine']))
restartconnpv=epics.PV(rssi_restartconn.format(slots[slot]['engine']))

if debug:
print(f'Pre-ValidCnt {validcntpv.get()}')
restartconnpv.put(1,wait=True)
if debug:
time.sleep(2)
print(f'Post-ValidCnt {validcntpv.get()}')
time.sleep(2)
print(f'Post-ValidCnt {validcntpv.get()}')
time.sleep(2)
print(f'Post-ValidCnt {validcntpv.get()}')
Loading