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

class MultiEchoLaserScan___TypeSupport(dds.TypeSupport):

    _typename = 'sensor_msgs::msg::dds_::MultiEchoLaserScan_'
    _keylist = ''
    _metadescriptor = '<MetaData version="1.0.0"><Module name="sensor_msgs"><Module name="msg"><Module name="dds_"><Struct name="LaserEcho_"><Member name="echoes_"><Sequence><Float/></Sequence></Member></Struct></Module></Module></Module><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="MultiEchoLaserScan_"><Member name="header_"><Type name="::std_msgs::msg::dds_::Header_"/></Member><Member name="angle_min_"><Float/></Member><Member name="angle_max_"><Float/></Member><Member name="angle_increment_"><Float/></Member><Member name="time_increment_"><Float/></Member><Member name="scan_time_"><Float/></Member><Member name="range_min_"><Float/></Member><Member name="range_max_"><Float/></Member><Member name="ranges_"><Sequence><Type name="LaserEcho_"/></Sequence></Member><Member name="intensities_"><Sequence><Type name="LaserEcho_"/></Sequence></Member></Struct></Module></Module></Module></MetaData>'

    def __init__(self):
        super(MultiEchoLaserScan___TypeSupport, self).__init__(self._typename,
              self._keylist,
              self._metadescriptor,
              struct.calcsize(MultiEchoLaserScan_()._get_packing_fmt()))

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

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

class MultiEchoLaserScan_(ddsutil.TopicDataClass):

    @staticmethod
    def get_type_support():
        ''' Return type support information required for dds.Topic constructor '''
        return MultiEchoLaserScan___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 angle_min_(self):
        '''
        a DDS float value
        @rtype: float
        '''
        return self._angle_min__

    _angle_min__checker = ddsutil._float_checker
    @angle_min_.setter
    def angle_min_(self, value):
        self._angle_min__checker(value)
        self._angle_min__ = value

    @property
    def angle_max_(self):
        '''
        a DDS float value
        @rtype: float
        '''
        return self._angle_max__

    _angle_max__checker = ddsutil._float_checker
    @angle_max_.setter
    def angle_max_(self, value):
        self._angle_max__checker(value)
        self._angle_max__ = value

    @property
    def angle_increment_(self):
        '''
        a DDS float value
        @rtype: float
        '''
        return self._angle_increment__

    _angle_increment__checker = ddsutil._float_checker
    @angle_increment_.setter
    def angle_increment_(self, value):
        self._angle_increment__checker(value)
        self._angle_increment__ = value

    @property
    def time_increment_(self):
        '''
        a DDS float value
        @rtype: float
        '''
        return self._time_increment__

    _time_increment__checker = ddsutil._float_checker
    @time_increment_.setter
    def time_increment_(self, value):
        self._time_increment__checker(value)
        self._time_increment__ = value

    @property
    def scan_time_(self):
        '''
        a DDS float value
        @rtype: float
        '''
        return self._scan_time__

    _scan_time__checker = ddsutil._float_checker
    @scan_time_.setter
    def scan_time_(self, value):
        self._scan_time__checker(value)
        self._scan_time__ = value

    @property
    def range_min_(self):
        '''
        a DDS float value
        @rtype: float
        '''
        return self._range_min__

    _range_min__checker = ddsutil._float_checker
    @range_min_.setter
    def range_min_(self, value):
        self._range_min__checker(value)
        self._range_min__ = value

    @property
    def range_max_(self):
        '''
        a DDS float value
        @rtype: float
        '''
        return self._range_max__

    _range_max__checker = ddsutil._float_checker
    @range_max_.setter
    def range_max_(self, value):
        self._range_max__checker(value)
        self._range_max__ = value

    @property
    def ranges_(self):
        '''
        a DDS sequence<sensor_msgs::msg::dds_::LaserEcho_> value
        @rtype: list
        '''
        return self._ranges__

    _ranges__checker = ddsutil._seq_checker(0,ddsutil._class_checker(LaserEcho_))
    @ranges_.setter
    def ranges_(self, value):
        self._ranges__checker(value)
        self._ranges__ = value

    @property
    def intensities_(self):
        '''
        a DDS sequence<sensor_msgs::msg::dds_::LaserEcho_> value
        @rtype: list
        '''
        return self._intensities__

    _intensities__checker = ddsutil._seq_checker(0,ddsutil._class_checker(LaserEcho_))
    @intensities_.setter
    def intensities_(self, value):
        self._intensities__checker(value)
        self._intensities__ = value

    _member_attributes = ('header_', 'angle_min_', 'angle_max_', 'angle_increment_', 'time_increment_', 'scan_time_', 'range_min_', 'range_max_', 'ranges_', 'intensities_')

    def __init__(self, **kwargs):
        ''' Create a MultiEchoLaserScan_ instance, optionally initializing fields by name '''
        # init attributes to default value
        self.header_ = std_msgs/msg/Header_.std_msgs.msg.dds_.Header_()
        self.angle_min_ = 0.0
        self.angle_max_ = 0.0
        self.angle_increment_ = 0.0
        self.time_increment_ = 0.0
        self.scan_time_ = 0.0
        self.range_min_ = 0.0
        self.range_max_ = 0.0
        self.ranges_ = []
        self.intensities_ = []
        # 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 MultiEchoLaserScan_._packing_fmt is not None:
            return MultiEchoLaserScan_._packing_fmt
        fmt = ''
        fmt += ddsutil._align(fmt, std_msgs/msg/Header_.std_msgs.msg.dds_.Header_._get_packing_fmt())
        fmt += 'f'
        fmt += 'f'
        fmt += 'f'
        fmt += 'f'
        fmt += 'f'
        fmt += 'f'
        fmt += 'f'
        fmt += ddsutil._align(fmt, ddsutil._pad_fmt('iiP?'))
        fmt += ddsutil._align(fmt, ddsutil._pad_fmt('iiP?'))

        MultiEchoLaserScan_._packing_fmt = ddsutil._pad_fmt(fmt)
        return MultiEchoLaserScan_._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.angle_min_ = data.pop(0)
        self.angle_max_ = data.pop(0)
        self.angle_increment_ = data.pop(0)
        self.time_increment_ = data.pop(0)
        self.scan_time_ = data.pop(0)
        self.range_min_ = data.pop(0)
        self.range_max_ = data.pop(0)
        self.ranges_ = ddsutil._deserialize_seq(data, LaserEcho_._get_packing_fmt(), lambda seq_data: LaserEcho_()._deserialize(seq_data))
        self.intensities_ = ddsutil._deserialize_seq(data, LaserEcho_._get_packing_fmt(), lambda seq_data: LaserEcho_()._deserialize(seq_data))
        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.angle_min_)
        args.append(self.angle_max_)
        args.append(self.angle_increment_)
        args.append(self.time_increment_)
        args.append(self.scan_time_)
        args.append(self.range_min_)
        args.append(self.range_max_)
        args.extend(ddsutil._serialize_seq(self.ranges_, LaserEcho_._get_packing_fmt(), lambda seq_args, v: seq_args.extend(v._get_packing_args())))
        args.extend(ddsutil._serialize_seq(self.intensities_, LaserEcho_._get_packing_fmt(), lambda seq_args, v: seq_args.extend(v._get_packing_args())))
        return args

