Skip to content

Commit

Permalink
Errors
Browse files Browse the repository at this point in the history
  • Loading branch information
GraysonBellamy committed May 23, 2024
1 parent a1efc6b commit cb5aeb0
Show file tree
Hide file tree
Showing 3 changed files with 149 additions and 102 deletions.
32 changes: 21 additions & 11 deletions pyalicat/daq.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"""

import device
from typing import Any
from trio import run


Expand All @@ -28,14 +29,14 @@ def __init__(self) -> None:
return

@classmethod
async def init(cls, devs: dict[str, str]) -> "DAQ":
async def init(cls, devs: dict[str, str | device.Device]) -> "DAQ":
"""Initializes the DAQ.
Example:
Daq = run(DAQ.init, {'A':'/dev/ttyUSB0', 'B':'/dev/ttyUSB1'})
Args:
devs (dict[str, str]): The dictionary of devices to add. Name:Port
devs (dict[str, str | device.Device]): The dictionary of devices to add. Name:Port
Returns:
DAQ: The DAQ object.
Expand All @@ -44,19 +45,26 @@ async def init(cls, devs: dict[str, str]) -> "DAQ":
await daq.add_device(devs)
return daq

async def add_device(self, devs: dict[str, str]) -> None:
async def add_device(
self, devs: dict[str, str | device.Device], **kwargs: Any
) -> None:
"""Creates and initializes the devices.
Args:
devs (dict[str, str]): The dictionary of devices to add. Name:Port
devs (dict[str, str | Device]): The dictionary of devices to add. Name:Port or Name:Device
**kwargs: Any
"""
if isinstance(devs, str):
devs = devs.split()
# This works if the string is the format "Name Port"
devs = {devs[0]: devs[1]}
for name in devs:
dev = await device.Device.new_device(devs[name])
dev_list.update({name: dev})
if devs:
if isinstance(devs, str):
devs = devs.split()
# This works if the string is the format "Name Port"
devs = {devs[0]: devs[1]}
for name in devs:
if isinstance(devs[name], str):
dev = await device.Device.new_device(devs[name], **kwargs)
dev_list.update({name: dev})
elif isinstance(devs[name], device.Device):
dev_list.update({name: devs[name]})
return

async def remove_device(self, name: list[str]) -> None:
Expand Down Expand Up @@ -148,5 +156,7 @@ def __init__(self, config: dict) -> None:
----------
config : dict
The configuration dictionary. {Name : port}
Device, quality, and rate are required.
Prototype with a .csv, eventually .hdf5 when ready.
"""
pass
Loading

0 comments on commit cb5aeb0

Please sign in to comment.