#!/usr/bin/env python

# Author: Dr. Konstantin Selyunin
# License: MIT
# Created: {{ today }}

import logging
import os.path
import struct

from abc import abstractmethod, ABC
from typing import Union, Tuple

from rsl_xml_svd.rsl_svd_parser import RslSvdParser


class UM7Registers(ABC):

    def __init__(self, **kwargs):
        self.svd_parser = RslSvdParser(svd_file=UM7Registers.find_svd('um7.svd'))

    @staticmethod
    def find_svd(svd_file_name: str):
        parent_dir = os.path.join(os.path.dirname(__file__), os.pardir)
        for root, dirs, files in os.walk(parent_dir):
            if svd_file_name in files:
                return os.path.join(root, svd_file_name)

    @abstractmethod
    def connect(self, *args, **kwargs):
        pass

    @abstractmethod
    def read_register(self, reg_addr: int, **kw) -> bytes:
        pass

    @abstractmethod
    def write_register(self, reg_addr: int, reg_value: Union[int, bytes, float], **kw):
        pass

{{ generated_code_for_main_register_map }}
{{ generated_code_for_hidden_register_map }}
if __name__ == '__main__':
    pass

