"""LCM type definitions
This file automatically generated by lcm.
DO NOT MODIFY BY HAND!!!!
"""

try:
    import cStringIO.StringIO as BytesIO
except ImportError:
    from io import BytesIO
import struct

class rtidvl_nmea_t(object):
    __slots__ = ["utime", "timeStartup", "sample", "temperature", "btv", "altitude", "wtv", "wtv_layer", "bit", "subsystem", "subsystem_index"]

    __typenames__ = ["int64_t", "int64_t", "int32_t", "double", "double", "double", "double", "double", "double", "int32_t", "int32_t"]

    __dimensions__ = [None, None, None, None, [4], None, [4], None, None, None, None]

    def __init__(self):
        self.utime = 0
        self.timeStartup = 0
        self.sample = 0
        self.temperature = 0.0
        self.btv = [ 0.0 for dim0 in range(4) ]
        self.altitude = 0.0
        self.wtv = [ 0.0 for dim0 in range(4) ]
        self.wtv_layer = 0.0
        self.bit = 0.0
        self.subsystem = 0
        self.subsystem_index = 0

    def encode(self):
        buf = BytesIO()
        buf.write(rtidvl_nmea_t._get_packed_fingerprint())
        self._encode_one(buf)
        return buf.getvalue()

    def _encode_one(self, buf):
        buf.write(struct.pack(">qqid", self.utime, self.timeStartup, self.sample, self.temperature))
        buf.write(struct.pack('>4d', *self.btv[:4]))
        buf.write(struct.pack(">d", self.altitude))
        buf.write(struct.pack('>4d', *self.wtv[:4]))
        buf.write(struct.pack(">ddii", self.wtv_layer, self.bit, self.subsystem, self.subsystem_index))

    def decode(data):
        if hasattr(data, 'read'):
            buf = data
        else:
            buf = BytesIO(data)
        if buf.read(8) != rtidvl_nmea_t._get_packed_fingerprint():
            raise ValueError("Decode error")
        return rtidvl_nmea_t._decode_one(buf)
    decode = staticmethod(decode)

    def _decode_one(buf):
        self = rtidvl_nmea_t()
        self.utime, self.timeStartup, self.sample, self.temperature = struct.unpack(">qqid", buf.read(28))
        self.btv = struct.unpack('>4d', buf.read(32))
        self.altitude = struct.unpack(">d", buf.read(8))[0]
        self.wtv = struct.unpack('>4d', buf.read(32))
        self.wtv_layer, self.bit, self.subsystem, self.subsystem_index = struct.unpack(">ddii", buf.read(24))
        return self
    _decode_one = staticmethod(_decode_one)

    def _get_hash_recursive(parents):
        if rtidvl_nmea_t in parents: return 0
        tmphash = (0x2a793dd9726e2227) & 0xffffffffffffffff
        tmphash  = (((tmphash<<1)&0xffffffffffffffff) + (tmphash>>63)) & 0xffffffffffffffff
        return tmphash
    _get_hash_recursive = staticmethod(_get_hash_recursive)
    _packed_fingerprint = None

    def _get_packed_fingerprint():
        if rtidvl_nmea_t._packed_fingerprint is None:
            rtidvl_nmea_t._packed_fingerprint = struct.pack(">Q", rtidvl_nmea_t._get_hash_recursive([]))
        return rtidvl_nmea_t._packed_fingerprint
    _get_packed_fingerprint = staticmethod(_get_packed_fingerprint)

    def get_hash(self):
        """Get the LCM hash of the struct"""
        return struct.unpack(">Q", rtidvl_nmea_t._get_packed_fingerprint())[0]

