import dds
import ddsutil
import std_msgs/msg/Header_.std_msgs.msg.dds_
import struct

class Range___TypeSupport(dds.TypeSupport):

    _typename = 'sensor_msgs::msg::dds_::Range_'
    _keylist = ''
    _metadescriptor = '<MetaData version="1.0.0"><Module name="builtin_interfaces"><Module name="msg"><Module name="dds_"><Struct name="Time_"><Member name="sec_"><Long/></Member><Member name="nanosec_"><ULong/></Member></Struct></Module></Module></Module><Module name="std_msgs"><Module name="msg"><Module name="dds_"><Struct name="Header_"><Member name="stamp_"><Type name="::builtin_interfaces::msg::dds_::Time_"/></Member><Member name="frame_id_"><String/></Member></Struct></Module></Module></Module><Module name="sensor_msgs"><Module name="msg"><Module name="dds_"><Struct name="Range_"><Member name="header_"><Type name="::std_msgs::msg::dds_::Header_"/></Member><Member name="radiation_type_"><Octet/></Member><Member name="field_of_view_"><Float/></Member><Member name="min_range_"><Float/></Member><Member name="max_range_"><Float/></Member><Member name="range_"><Float/></Member></Struct></Module></Module></Module></MetaData>'

    def __init__(self):
        super(Range___TypeSupport, self).__init__(self._typename,
              self._keylist,
              self._metadescriptor,
              struct.calcsize(Range_()._get_packing_fmt()))

    def _serialize(self, o):
        if not isinstance(o, Range_):
            raise TypeError('Incorrect data type')
        result = o._serialize()
        return result

    def _deserialize(self, buf):
        result = Range_()
        data = struct.unpack(result._get_packing_fmt(), buf)
        result._deserialize(list(data))
        return result

class Range_(ddsutil.TopicDataClass):

    @staticmethod
    def get_type_support():
        ''' Return type support information required for dds.Topic constructor '''
        return Range___TypeSupport()

    @property
    def header_(self):
        '''
        a DDS std_msgs::msg::dds_::Header_ value
        @rtype: std_msgs/msg/Header_.std_msgs.msg.dds_.Header_
        '''
        return self._header__

    _header__checker = ddsutil._class_checker(std_msgs/msg/Header_.std_msgs.msg.dds_.Header_)
    @header_.setter
    def header_(self, value):
        self._header__checker(value)
        self._header__ = value

    @property
    def radiation_type_(self):
        '''
        a DDS octet value
        @rtype: int
        '''
        return self._radiation_type__

    _radiation_type__checker = ddsutil._octet_checker
    @radiation_type_.setter
    def radiation_type_(self, value):
        self._radiation_type__checker(value)
        self._radiation_type__ = value

    @property
    def field_of_view_(self):
        '''
        a DDS float value
        @rtype: float
        '''
        return self._field_of_view__

    _field_of_view__checker = ddsutil._float_checker
    @field_of_view_.setter
    def field_of_view_(self, value):
        self._field_of_view__checker(value)
        self._field_of_view__ = value

    @property
    def min_range_(self):
        '''
        a DDS float value
        @rtype: float
        '''
        return self._min_range__

    _min_range__checker = ddsutil._float_checker
    @min_range_.setter
    def min_range_(self, value):
        self._min_range__checker(value)
        self._min_range__ = value

    @property
    def max_range_(self):
        '''
        a DDS float value
        @rtype: float
        '''
        return self._max_range__

    _max_range__checker = ddsutil._float_checker
    @max_range_.setter
    def max_range_(self, value):
        self._max_range__checker(value)
        self._max_range__ = value

    @property
    def range_(self):
        '''
        a DDS float value
        @rtype: float
        '''
        return self._range__

    _range__checker = ddsutil._float_checker
    @range_.setter
    def range_(self, value):
        self._range__checker(value)
        self._range__ = value

    _member_attributes = ('header_', 'radiation_type_', 'field_of_view_', 'min_range_', 'max_range_', 'range_')

    def __init__(self, **kwargs):
        ''' Create a Range_ instance, optionally initializing fields by name '''
        # init attributes to default value
        self.header_ = std_msgs/msg/Header_.std_msgs.msg.dds_.Header_()
        self.radiation_type_ = 0
        self.field_of_view_ = 0.0
        self.min_range_ = 0.0
        self.max_range_ = 0.0
        self.range_ = 0.0
        # set values for attributes passed in
        for key, value in kwargs.items():
            if key not in self._member_attributes:
                raise TypeError('Invalid argument name : %s' %(key))
            setattr(self, key, value)

    _packing_fmt = None

    @staticmethod
    def _get_packing_fmt():
        ''' Returns packing format of this class data '''
        if Range_._packing_fmt is not None:
            return Range_._packing_fmt
        fmt = ''
        fmt += ddsutil._align(fmt, std_msgs/msg/Header_.std_msgs.msg.dds_.Header_._get_packing_fmt())
        fmt += 'B'
        fmt += 'f'
        fmt += 'f'
        fmt += 'f'
        fmt += 'f'

        Range_._packing_fmt = ddsutil._pad_fmt(fmt)
        return Range_._packing_fmt

    def _serialize(self):
        ''' Serialize data for writing '''
        fmt = self._get_packing_fmt()
        args = self._get_packing_args()
        result = struct.pack(fmt, *args)
        return result

    def _deserialize(self, data):
        ''' Initialize values from data returned by struct.unpack()'''
        self.header_ = std_msgs/msg/Header_.std_msgs.msg.dds_.Header_()._deserialize(data)
        self.radiation_type_ = data.pop(0)
        self.field_of_view_ = data.pop(0)
        self.min_range_ = data.pop(0)
        self.max_range_ = data.pop(0)
        self.range_ = data.pop(0)
        return self;

    def _get_packing_args(self):
        ''' Return an list of data suitable for struct.pack '''
        args = []
        args.extend(self.header_._get_packing_args())
        args.append(self.radiation_type_)
        args.append(self.field_of_view_)
        args.append(self.min_range_)
        args.append(self.max_range_)
        args.append(self.range_)
        return args

