Skip to content

remove analog_names and digital interrupt _names #714

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions src/viam/components/board/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,7 @@


async def create_status(component: Board) -> Status:
(analog_names, digital_interrupt_names) = await asyncio.gather(component.analog_names(), component.digital_interrupt_names())
analogs, digital_interrupts = {}, {}
for x in analog_names:
analog = await component.analog_by_name(x)
read = await analog.read()
analogs[x] = read.value

for y in digital_interrupt_names:
digital_interrupt = await component.digital_interrupt_by_name(y)
val = await digital_interrupt.value()
digital_interrupts[y] = val

s = BoardStatus(analogs=analogs, digital_interrupts=digital_interrupts)
return Status(name=Board.get_resource_name(component.name), status=message_to_struct(s))

Expand Down
38 changes: 0 additions & 38 deletions src/viam/components/board/board.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,44 +364,6 @@ async def gpio_pin_by_name(self, name: str) -> GPIOPin:
"""
...

@abc.abstractmethod
async def analog_names(self) -> List[str]:
"""
Get the names of all known analog readers and/or writers.

::

my_board = Board.from_robot(robot=robot, name="my_board")

# Get the name of every Analog configured on the board.
names = await my_board.analog_names()

Returns:
List[str]: The list of names of all known analog readers/writers.

For more information, see `Board component <https://docs.viam.com/components/board/>`_.
"""
...

@abc.abstractmethod
async def digital_interrupt_names(self) -> List[str]:
"""
Get the names of all known digital interrupts.

::

my_board = Board.from_robot(robot=robot, name="my_board")

# Get the name of every DigitalInterrupt configured on the board.
names = await my_board.digital_interrupt_names()

Returns:
List[str]: The names of the digital interrupts.

For more information, see `Board component <https://docs.viam.com/components/board/>`_.
"""
...

@abc.abstractmethod
async def set_power_mode(
self, mode: PowerMode.ValueType, duration: Optional[timedelta] = None, *, timeout: Optional[float] = None, **kwargs
Expand Down
32 changes: 0 additions & 32 deletions tests/test_board.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,38 +92,12 @@ async def test_gpio_pin_by_name(self, board: MockBoard):
pin = await board.gpio_pin_by_name("pin1")
assert pin.name == "pin1"

@pytest.mark.asyncio
async def test_analog_names(self, board: MockBoard):
names = await board.analog_names()
assert names == ["reader1", "writer1"]

@pytest.mark.asyncio
async def test_digital_interrupt_names(self, board: MockBoard):
names = await board.digital_interrupt_names()
assert names == ["interrupt1"]

@pytest.mark.asyncio
async def test_do(self, board: MockBoard):
command = {"command": "args"}
resp = await board.do_command(command)
assert resp == {"command": command}

@pytest.mark.asyncio
async def test_status(self, board: MockBoard):
status = await create_status(board)
read1 = await board.analogs["reader1"].read()
# Analog writers typically don't have read statuses, but the mock board
# doesn't make that distinction.
read2 = await board.analogs["writer1"].read()
val = await board.digital_interrupts["interrupt1"].value()
assert status.name == MockBoard.get_resource_name(board.name)
assert status.status == message_to_struct(
BoardStatus(
analogs={"reader1": int(read1.value), "writer1": int(read2.value)},
digital_interrupts={"interrupt1": val},
)
)

@pytest.mark.asyncio
async def test_set_power_mode(self, board: MockBoard):
pm_mode = PowerMode.POWER_MODE_OFFLINE_DEEP
Expand Down Expand Up @@ -391,9 +365,6 @@ async def test_analog_names(self, board: MockBoard, service: BoardRPCService):
reader = await client.analog_by_name("reader1")
assert reader.name == "reader1"

names = await client.analog_names()
assert names == ["reader1"]

@pytest.mark.asyncio
async def test_digital_interrupt_names(self, board: MockBoard, service: BoardRPCService):
async with ChannelFor([service]) as channel:
Expand All @@ -402,9 +373,6 @@ async def test_digital_interrupt_names(self, board: MockBoard, service: BoardRPC
interrupt = await client.digital_interrupt_by_name("interrupt1")
assert interrupt.name == "interrupt1"

names = await client.digital_interrupt_names()
assert names == ["interrupt1"]

@pytest.mark.asyncio
async def test_do(self, board: MockBoard, service: BoardRPCService):
async with ChannelFor([service]) as channel:
Expand Down
Loading