Loading noctua/__init__.py +0 −1 Original line number Diff line number Diff line ''' Main package ''' noctua/config/constants.py +3 −2 Original line number Diff line number Diff line Loading @@ -12,7 +12,8 @@ alt = 1469 # [m] Altitude above sea level. ############ dome_park_position = 57 # azimuth telescope_flat_position = [24, 240] # alt, az to point the screen with dome parked # alt, az to point the screen with dome parked telescope_flat_position = [24, 240] open_state = { 0: "Open", Loading noctua/devices/__init__.py +14 −11 Original line number Diff line number Diff line Loading @@ -6,12 +6,12 @@ Import devices using configuration files ''' # System modules import importlib import configparser import importlib import sys from pathlib import Path # Custom modules # Other templates from ..utils.url_stuff import build_url this_module = sys.modules[__name__] Loading @@ -22,6 +22,7 @@ devs = configparser.ConfigParser() nodes.read(Path(__file__).parent.parent / 'config' / 'nodes.ini') devs.read(Path(__file__).parent.parent / 'config' / 'devices.ini') def dynamic_import(this, dev): """Dynamically import into this module the devices from the nodes.ini and devices.ini files. Loading @@ -33,7 +34,8 @@ def dynamic_import(this, dev): """ module = importlib.import_module(__package__ +"."+ devs.get(dev, "module") ) module = importlib.import_module( __package__ + "." + devs.get(dev, "module")) cls = getattr(module, devs.get(dev, "class")) node = devs.get(dev, "node") Loading @@ -59,6 +61,7 @@ def dynamic_import(this, dev): # Set the instance as an attribute of the current object setattr(this, instance_name, instance) for dev in devs.sections(): print(f"importing {dev}") dynamic_import(this_module, dev) noctua/devices/alpaca.py +6 −6 Original line number Diff line number Diff line Loading @@ -8,11 +8,11 @@ from urllib.parse import urlencode # Third-party modules import requests # Custom modules from .basedevice import BaseDevice # Other templates from ..config.constants import dome_park_position from ..utils import check from ..utils.logger import log from .basedevice import BaseDevice class AlpacaDevice(BaseDevice): Loading Loading @@ -128,7 +128,7 @@ class AlpacaDevice(BaseDevice): try: float(value) return float(value) except: except BaseException: return value def commandblind(self, val): Loading noctua/devices/astelco.py +51 −50 Original line number Diff line number Diff line Loading @@ -8,10 +8,11 @@ Interface with an Astelco OpenTSI-based device # System modules import telnetlib # Custom modules from .basedevice import BaseDevice # Other templates from ..utils import check from ..utils.logger import log from .basedevice import BaseDevice class OpenTSI(BaseDevice): '''Base wrapper class for astelco OpenTSI stuff''' Loading Loading @@ -56,8 +57,10 @@ class OpenTSI(BaseDevice): msglist = message # GET: Transforming every string in "1 get string\n2 get string\n" # SET: Transforming every string in "1 set string=val\n2 set string=val" msg = [f"{i+1} {get_or_set.upper()} {j}\n" for i, j in enumerate(msglist)] # SET: Transforming every string in "1 set string=val\n2 set # string=val" msg = [f"{i + 1} {get_or_set.upper()} {j}\n" for i, j in enumerate(msglist)] # From list to string, and byte-coded msg = bytes("".join(msg), "utf+8") Loading Loading @@ -113,10 +116,10 @@ class OpenTSI(BaseDevice): try: telnet_dict[k] = int(v) except: except BaseException: try: telnet_dict[k] = float(v) except: except BaseException: try: telnet_dict[k] = str(v.replace('"', '')) except ValueError as e: Loading @@ -131,7 +134,6 @@ class OpenTSI(BaseDevice): else: return res[0] def get(self, message): '''Send a telnet message to the cabinet to retrieve a value or a set of values.''' Loading Loading @@ -503,7 +505,6 @@ class Rotator(OpenTSI): return self._absolute class Sensor(OpenTSI): '''Implementation of a Sensor class.''' Loading Loading
noctua/config/constants.py +3 −2 Original line number Diff line number Diff line Loading @@ -12,7 +12,8 @@ alt = 1469 # [m] Altitude above sea level. ############ dome_park_position = 57 # azimuth telescope_flat_position = [24, 240] # alt, az to point the screen with dome parked # alt, az to point the screen with dome parked telescope_flat_position = [24, 240] open_state = { 0: "Open", Loading
noctua/devices/__init__.py +14 −11 Original line number Diff line number Diff line Loading @@ -6,12 +6,12 @@ Import devices using configuration files ''' # System modules import importlib import configparser import importlib import sys from pathlib import Path # Custom modules # Other templates from ..utils.url_stuff import build_url this_module = sys.modules[__name__] Loading @@ -22,6 +22,7 @@ devs = configparser.ConfigParser() nodes.read(Path(__file__).parent.parent / 'config' / 'nodes.ini') devs.read(Path(__file__).parent.parent / 'config' / 'devices.ini') def dynamic_import(this, dev): """Dynamically import into this module the devices from the nodes.ini and devices.ini files. Loading @@ -33,7 +34,8 @@ def dynamic_import(this, dev): """ module = importlib.import_module(__package__ +"."+ devs.get(dev, "module") ) module = importlib.import_module( __package__ + "." + devs.get(dev, "module")) cls = getattr(module, devs.get(dev, "class")) node = devs.get(dev, "node") Loading @@ -59,6 +61,7 @@ def dynamic_import(this, dev): # Set the instance as an attribute of the current object setattr(this, instance_name, instance) for dev in devs.sections(): print(f"importing {dev}") dynamic_import(this_module, dev)
noctua/devices/alpaca.py +6 −6 Original line number Diff line number Diff line Loading @@ -8,11 +8,11 @@ from urllib.parse import urlencode # Third-party modules import requests # Custom modules from .basedevice import BaseDevice # Other templates from ..config.constants import dome_park_position from ..utils import check from ..utils.logger import log from .basedevice import BaseDevice class AlpacaDevice(BaseDevice): Loading Loading @@ -128,7 +128,7 @@ class AlpacaDevice(BaseDevice): try: float(value) return float(value) except: except BaseException: return value def commandblind(self, val): Loading
noctua/devices/astelco.py +51 −50 Original line number Diff line number Diff line Loading @@ -8,10 +8,11 @@ Interface with an Astelco OpenTSI-based device # System modules import telnetlib # Custom modules from .basedevice import BaseDevice # Other templates from ..utils import check from ..utils.logger import log from .basedevice import BaseDevice class OpenTSI(BaseDevice): '''Base wrapper class for astelco OpenTSI stuff''' Loading Loading @@ -56,8 +57,10 @@ class OpenTSI(BaseDevice): msglist = message # GET: Transforming every string in "1 get string\n2 get string\n" # SET: Transforming every string in "1 set string=val\n2 set string=val" msg = [f"{i+1} {get_or_set.upper()} {j}\n" for i, j in enumerate(msglist)] # SET: Transforming every string in "1 set string=val\n2 set # string=val" msg = [f"{i + 1} {get_or_set.upper()} {j}\n" for i, j in enumerate(msglist)] # From list to string, and byte-coded msg = bytes("".join(msg), "utf+8") Loading Loading @@ -113,10 +116,10 @@ class OpenTSI(BaseDevice): try: telnet_dict[k] = int(v) except: except BaseException: try: telnet_dict[k] = float(v) except: except BaseException: try: telnet_dict[k] = str(v.replace('"', '')) except ValueError as e: Loading @@ -131,7 +134,6 @@ class OpenTSI(BaseDevice): else: return res[0] def get(self, message): '''Send a telnet message to the cabinet to retrieve a value or a set of values.''' Loading Loading @@ -503,7 +505,6 @@ class Rotator(OpenTSI): return self._absolute class Sensor(OpenTSI): '''Implementation of a Sensor class.''' Loading