Skip to content

Commit

Permalink
Remove EPICS from CryoCard.
Browse files Browse the repository at this point in the history
  • Loading branch information
tristpinsm committed Mar 12, 2024
1 parent 27236e4 commit 57bb5a4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 24 deletions.
8 changes: 6 additions & 2 deletions python/pysmurf/client/base/base_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,12 @@ def __init__(self, log=None, server_addr="localhost", server_port=9000, atca_por
self.trigger_root = self.amctiming + 'EvrV2CoreTriggers.'
self.timing_status = self.amctiming + 'TimingFrameRx.'

self.C = CryoCard(self.rtm_spi_cryo_root + 'read',
self.rtm_spi_cryo_root + 'write')
self.C = CryoCard(
self.rtm_spi_cryo_root + 'read',
self.rtm_spi_cryo_root + 'write',
self._server_addr,
self._server_port
)
self.freq_resp = {}

# RTM slow DAC parameters (used, e.g., for TES biasing). The
Expand Down
36 changes: 14 additions & 22 deletions python/pysmurf/client/command/cryo_card.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@
#-----------------------------------------------------------------------------
import time
import os

try:
import epics
except ModuleNotFoundError:
print("cryo_card.py - epics not found.")
import pyrogue

def write_csv(filename, header, line):
should_write_header = os.path.exists(filename)
Expand All @@ -30,7 +26,7 @@ def write_csv(filename, header, line):
f.write(line+'\n')

class CryoCard():
def __init__(self, readpv_in, writepv_in):
def __init__(self, readpv_in, writepv_in, server_addr="localhost", server_port=9000):
"""
Interact with the cryocard via the PIC. To interact via the RTM, use SmurfCommandMixin.
Needs to be compatible with the C02 and C04 cryocards.
Expand All @@ -39,8 +35,9 @@ def __init__(self, readpv_in, writepv_in):
Ref https://github.com/slaclab/smurfc/blob/C04/firmware/src/ccard.h
"""

self.readpv = epics.PV(readpv_in)
self.writepv = epics.PV(writepv_in)
self._client = pyrogue.interfaces.VirtualClient(addr=server_addr, port=server_port)
self.readpv = self._client.root.getNode(readpv_in)
self.writepv = self._client.root.getNode(writepv_in)

self.fw_version_address = 0x0
self.relay_address = 0x2
Expand All @@ -60,18 +57,13 @@ def __init__(self, readpv_in, writepv_in):
self.list_of_c04_amps = ['50k1', '50k2', 'hemt1', 'hemt2']
self.list_of_c02_and_c04_amps = self.list_of_c02_amps + self.list_of_c04_amps

def do_read(self, address, use_monitor=False):
def do_read(self, address):
r"""Writes query to cryostat card PIC and reads reply.
Args
----
address : int
Address of PIC register to read.
use_monitor : bool, optional, default False
Passed directly to the underlying pyepics `epics.caget`
function call. This was added to maintain default
behavior because this option was changed from default
`False` to default `True` in later versions of pyepics.
Returns
-------
Expand All @@ -80,16 +72,16 @@ def do_read(self, address, use_monitor=False):
typically means no cryostat card is connected).
"""
#need double write to make sure buffer is updated
self.writepv.put(cmd_make(1, address, 0))
self.writepv.set(cmd_make(1, address, 0))
for self.retry in range(0, self.max_retries):
self.writepv.put(cmd_make(1, address, 0))
data = self.readpv.get(use_monitor=use_monitor)
self.writepv.set(cmd_make(1, address, 0))
data = self.readpv.get()
addrrb = cmd_address(data)
if (addrrb == address):
return (data)
return (0)

return (self.readpv.get(use_monitor=use_monitor))
return (self.readpv.get())

def do_write(self, address, value):
"""Write the given value directly to the address on the PIC. Make sure
Expand All @@ -100,12 +92,12 @@ def do_write(self, address, value):
:param address the address on the PIC (e.g. 0x2)
:returns the response from caput
"""
return self.writepv.put(cmd_make(0, address, value))
return self.writepv.set(cmd_make(0, address, value))

def write_relays(self, relay): # relay is the bit partern to set
self.writepv.put(cmd_make(0, self.relay_address, relay))
self.writepv.set(cmd_make(0, self.relay_address, relay))
time.sleep(0.1)
self.writepv.put(cmd_make(0, self.relay_address, relay))
self.writepv.set(cmd_make(0, self.relay_address, relay))

def read_relays(self):
for self.busy_retry in range(0, self.max_retries):
Expand Down Expand Up @@ -228,7 +220,7 @@ def write_ps_en(self, enables):
-------
Nothing
"""
self.writepv.put(cmd_make(0, self.ps_en_address, enables))
self.writepv.set(cmd_make(0, self.ps_en_address, enables))

def read_ps_en(self):
"""
Expand Down

0 comments on commit 57bb5a4

Please sign in to comment.