Skip to content

Commit

Permalink
Made some of the changes requested by Brian
Browse files Browse the repository at this point in the history
  • Loading branch information
simonscryo committed Sep 7, 2024
2 parents 750da62 + 416bc37 commit 6cb267b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions socs/agents/scpi_psu/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from ocs.ocs_twisted import TimeoutLock
from socs.agents.scpi_psu.drivers import PsuInterface


class ScpiPsuAgent:
def __init__(self, agent, ip_address, gpib_slot):
self.agent = agent
Expand Down Expand Up @@ -38,7 +39,7 @@ def init(self, session, params=None):
"""
if self.psu is not None:
return True, "Already Initialized Module"

with self.lock.acquire_timeout(0) as acquired:
if not acquired:
return False, "Could not acquire lock"
Expand All @@ -50,7 +51,7 @@ def init(self, session, params=None):
def _initialize_module(self):
"""Initialize the ScpiPsu module."""
try:
self.psu = PsuInterface(self.ip_address, self.gpib_slot) #this is only necessary if the ip_address or gpib_slot has changed. I could declare a self.connected flag if this is uneeded.
self.psu = PsuInterface(self.ip_address, self.gpib_slot) # this is only necessary if the ip_address or gpib_slot has changed. I could declare a self.connected flag if this is uneeded.
self.idn = self.psu.identify()
except Exception as e: #socket.tiout OR OSError 113 No route to host.
self.log.warn(f"Error establishing connection: {e}")
Expand Down Expand Up @@ -223,4 +224,4 @@ def main(args=None):


if __name__ == '__main__':
main()
main()
2 changes: 1 addition & 1 deletion socs/agents/scpi_psu/drivers.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,4 @@ def clear(self):
#Clear all the event registers and error queue, using a query such as *ESR? or MEAS:X?
#instead of *CLS can confuse the PSU
self.write('*CLS')
return True
return True

0 comments on commit 6cb267b

Please sign in to comment.