from __future__ import annotations

from dataclasses import dataclass
from typing import Dict, List

from .pid import PID, PIDRegistry
from ..automotive import NoResponseFromBus


@dataclass
class Frame:
    pids: PIDRegistry

    def value_for_pid(self, pid: int) -> List[int]:
        if pid % 0x20 == 0:
            return self.pids.supported(pid)
        if pid not in self.pids:
            raise NoResponseFromBus()
        return self.pids[pid].content
