# Path: cbus/common.py
# class PriorityClass(IntEnum):
#     CLASS_4 = 0x00  # lowest
#     CLASS_3 = 0x01  # medium low
#     CLASS_2 = 0x02  # medium high
#     CLASS_1 = 0x03  # highest
# 
# class DestinationAddressType(IntEnum):
#     """
#     Destination Address Type (DAT).
# 
#     Ref: Serial Interface Guide, s3.4. Other values reserved.
#     """
#     UNSET = 0x00
#     POINT_TO_POINT_TO_MULTIPOINT = 0x03
#     POINT_TO_MULTIPOINT = 0x05
#     POINT_TO_POINT = 0x06
# 
# def add_cbus_checksum(i: bytes) -> bytes:
#     """
#     Appends a C-Bus checksum to a given message.
# 
#     :param i: The C-Bus message to append a checksum to. Must not be in base16
#               format.
#     :type i: bytes
# 
#     :returns: The C-Bus message with the checksum appended to it.
#     :rtype: bytes
#     """
#     c = cbus_checksum(i)
#     return i + bytes([c])
# 
# Path: cbus/protocol/base_packet.py
# class BasePacket(abc.ABC):
#     def __init__(
#             self,
#             checksum: bool = True,
#             destination_address_type:
#             DestinationAddressType = DestinationAddressType.UNSET,
#             rc: int = 0,
#             dp: bool = False,
#             priority_class: PriorityClass = PriorityClass.CLASS_4):
#         # base packet implementation.
#         self.checksum = checksum
# 
#         self.destination_address_type = destination_address_type
#         self.rc = rc
#         self.dp = dp
#         self.priority_class = priority_class
#         self.confirmation = None
#         self.source_address = None
# 
#     @property
#     def flags(self) -> int:
#         return ((self.destination_address_type & 0x07) |
#                 ((self.rc & 0x02) << 3) |
#                 (0x20 if self.dp else 0) |
#                 ((self.priority_class & 0x03) << 6))
# 
#     @abc.abstractmethod
#     def encode(self) -> bytes:
#         if self.source_address is None:
#             return bytes([self.flags])
#         else:
#             source_address = self.source_address & 0xff
#             return bytes([self.flags, source_address])
# 
#     def encode_packet(self) -> bytes:
#         return b16encode(self.encode())


from cbus.common import (
    PriorityClass, DestinationAddressType, add_cbus_checksum)
from cbus.protocol.base_packet import BasePacket
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this library.  If not, see <http://www.gnu.org/licenses/>.

from __future__ import absolute_import
from __future__ import annotations



class DeviceManagementPacket(BasePacket):
    def __init__(
            self, checksum: bool = True,
            priority_class: PriorityClass = PriorityClass.CLASS_2,
            parameter: int = 0,
            value: int = 0):
        super().__init__(
            checksum=checksum,
            destination_address_type=DestinationAddressType
            .POINT_TO_POINT_TO_MULTIPOINT,
            dp=True,
            priority_class=priority_class,
        )

        self.parameter = parameter
        self.value = value

    @staticmethod
    def decode_packet(data: bytes, checksum: bool,

# Path: cbus/common.py
# class PriorityClass(IntEnum):
#     CLASS_4 = 0x00  # lowest
#     CLASS_3 = 0x01  # medium low
#     CLASS_2 = 0x02  # medium high
#     CLASS_1 = 0x03  # highest
# 
# class DestinationAddressType(IntEnum):
#     """
#     Destination Address Type (DAT).
# 
#     Ref: Serial Interface Guide, s3.4. Other values reserved.
#     """
#     UNSET = 0x00
#     POINT_TO_POINT_TO_MULTIPOINT = 0x03
#     POINT_TO_MULTIPOINT = 0x05
#     POINT_TO_POINT = 0x06
# 
# def add_cbus_checksum(i: bytes) -> bytes:
#     """
#     Appends a C-Bus checksum to a given message.
# 
#     :param i: The C-Bus message to append a checksum to. Must not be in base16
#               format.
#     :type i: bytes
# 
#     :returns: The C-Bus message with the checksum appended to it.
#     :rtype: bytes
#     """
#     c = cbus_checksum(i)
#     return i + bytes([c])
# 
# Path: cbus/protocol/base_packet.py
# class BasePacket(abc.ABC):
#     def __init__(
#             self,
#             checksum: bool = True,
#             destination_address_type:
#             DestinationAddressType = DestinationAddressType.UNSET,
#             rc: int = 0,
#             dp: bool = False,
#             priority_class: PriorityClass = PriorityClass.CLASS_4):
#         # base packet implementation.
#         self.checksum = checksum
# 
#         self.destination_address_type = destination_address_type
#         self.rc = rc
#         self.dp = dp
#         self.priority_class = priority_class
#         self.confirmation = None
#         self.source_address = None
# 
#     @property
#     def flags(self) -> int:
#         return ((self.destination_address_type & 0x07) |
#                 ((self.rc & 0x02) << 3) |
#                 (0x20 if self.dp else 0) |
#                 ((self.priority_class & 0x03) << 6))
# 
#     @abc.abstractmethod
#     def encode(self) -> bytes:
#         if self.source_address is None:
#             return bytes([self.flags])
#         else:
#             source_address = self.source_address & 0xff
#             return bytes([self.flags, source_address])
# 
#     def encode_packet(self) -> bytes:
#         return b16encode(self.encode())


# Path: cbus/protocol/dm_packet.py
from cbus.common import (
    PriorityClass, DestinationAddressType, add_cbus_checksum)
from cbus.protocol.base_packet import BasePacket

# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this library.  If not, see <http://www.gnu.org/licenses/>.

from __future__ import absolute_import
from __future__ import annotations



class DeviceManagementPacket(BasePacket):
    def __init__(
            self, checksum: bool = True,
            priority_class: PriorityClass = PriorityClass.CLASS_2,
            parameter: int = 0,
            value: int = 0):
        super().__init__(
            checksum=checksum,
            destination_address_type=DestinationAddressType
            .POINT_TO_POINT_TO_MULTIPOINT,
            dp=True,
            priority_class=priority_class,
        )

        self.parameter = parameter
        self.value = value

    @staticmethod
    def decode_packet(data: bytes, checksum: bool,

                      priority_class: PriorityClass) -> DeviceManagementPacket: