Skip to content

Commit

Permalink
Merge pull request #550 from necst-telescope/#535-add_11713b
Browse files Browse the repository at this point in the history
#535 add 11713b
  • Loading branch information
TatsumiISHIKAWA committed Jun 24, 2024
2 parents 5a6946c + 536c048 commit 3ecded0
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 2 deletions.
5 changes: 3 additions & 2 deletions neclib/devices/attenuator/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from .rhio10 import RHIO10 # noqa: F401
from .a11713b import A11713B # noqa: F401
from .cpz340516 import CPZ340516 # noqa: F401
from .simulator import NetworkAttenuator # noqa: F401
from .rhio10 import RHIO10 # noqa: F401
from .simulator import CurrentAttenuator # noqa: F401
from .simulator import NetworkAttenuator # noqa: F401
57 changes: 57 additions & 0 deletions neclib/devices/attenuator/a11713b.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import astropy.units as u
import ogameasure

from ...core.security import busy
from ...utils import skip_on_simulator
from .attenuator_base import NetworkAttenuator


class A11713B(NetworkAttenuator):
"""Attenuator, which can attennuate IF sigal power.
Notes
-----
Configuration items for this device:
host : str
IP address for GPIB communicator.
port : int
GPIB port of using devices.
channel : Dict[str]
Human-readable channel name. The value should be
mapping from human readableversion (str) to
device level identifier (int). You can assign any name to the
channels up to two channels: "X", "Y".
For example: `{ 2R = X, 2L = Y}`
"""

Manufacturer = "Agilent"
Model = "11713B"

Identifier = "host"

@skip_on_simulator
def __init__(self) -> None:
com = ogameasure.gpib_prologix(host=self.Config.host, gpibport=self.Config.port)
self.io = ogameasure.Agilent.agilent_11713B(com)

def get_loss(self, id: str) -> u.Quantity:
with busy(self, "busy"):
ch = self.Config.channel[id]
try:
return self.io.att_level_query(ch) * u.dB
except IndexError:
pass
raise ValueError(f"Invalid channel: {ch}")

def set_loss(self, dB: int, id: str) -> None:
with busy(self, "busy"):
ch = self.Config.channel[id]
self.io.att_level_set(dB, ch)

def finalize(self) -> None:
self.io.com.close()

0 comments on commit 3ecded0

Please sign in to comment.