"""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 vn_100_Carson2014_t(object):
    __slots__ = ["utime", "byteGroups", "bytesG1", "bytesG2", "bytesG3", "timeStartup", "rpy", "quaternion", "angRateComp", "accelComp", "angRateUncomp", "accelUncomp", "magFieldComp", "Temperature", "Pressure", "insStatus", "syncInCnt", "magFieldUncomp"]

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

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

    def __init__(self):
        self.utime = 0
        self.byteGroups = 0
        self.bytesG1 = 0
        self.bytesG2 = 0
        self.bytesG3 = 0
        self.timeStartup = 0
        self.rpy = [ 0.0 for dim0 in range(3) ]
        self.quaternion = [ 0.0 for dim0 in range(4) ]
        self.angRateComp = [ 0.0 for dim0 in range(3) ]
        self.accelComp = [ 0.0 for dim0 in range(3) ]
        self.angRateUncomp = [ 0.0 for dim0 in range(3) ]
        self.accelUncomp = [ 0.0 for dim0 in range(3) ]
        self.magFieldComp = [ 0.0 for dim0 in range(3) ]
        self.Temperature = 0.0
        self.Pressure = 0.0
        self.insStatus = 0
        self.syncInCnt = 0
        self.magFieldUncomp = [ 0.0 for dim0 in range(3) ]

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

    def _encode_one(self, buf):
        buf.write(struct.pack(">qbhhhq", self.utime, self.byteGroups, self.bytesG1, self.bytesG2, self.bytesG3, self.timeStartup))
        buf.write(struct.pack('>3d', *self.rpy[:3]))
        buf.write(struct.pack('>4d', *self.quaternion[:4]))
        buf.write(struct.pack('>3d', *self.angRateComp[:3]))
        buf.write(struct.pack('>3d', *self.accelComp[:3]))
        buf.write(struct.pack('>3d', *self.angRateUncomp[:3]))
        buf.write(struct.pack('>3d', *self.accelUncomp[:3]))
        buf.write(struct.pack('>3d', *self.magFieldComp[:3]))
        buf.write(struct.pack(">ddhi", self.Temperature, self.Pressure, self.insStatus, self.syncInCnt))
        buf.write(struct.pack('>3d', *self.magFieldUncomp[:3]))

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

    def _decode_one(buf):
        self = vn_100_Carson2014_t()
        self.utime, self.byteGroups, self.bytesG1, self.bytesG2, self.bytesG3, self.timeStartup = struct.unpack(">qbhhhq", buf.read(23))
        self.rpy = struct.unpack('>3d', buf.read(24))
        self.quaternion = struct.unpack('>4d', buf.read(32))
        self.angRateComp = struct.unpack('>3d', buf.read(24))
        self.accelComp = struct.unpack('>3d', buf.read(24))
        self.angRateUncomp = struct.unpack('>3d', buf.read(24))
        self.accelUncomp = struct.unpack('>3d', buf.read(24))
        self.magFieldComp = struct.unpack('>3d', buf.read(24))
        self.Temperature, self.Pressure, self.insStatus, self.syncInCnt = struct.unpack(">ddhi", buf.read(22))
        self.magFieldUncomp = struct.unpack('>3d', buf.read(24))
        return self
    _decode_one = staticmethod(_decode_one)

    def _get_hash_recursive(parents):
        if vn_100_Carson2014_t in parents: return 0
        tmphash = (0x5dcecdc8173c73bf) & 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 vn_100_Carson2014_t._packed_fingerprint is None:
            vn_100_Carson2014_t._packed_fingerprint = struct.pack(">Q", vn_100_Carson2014_t._get_hash_recursive([]))
        return vn_100_Carson2014_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", vn_100_Carson2014_t._get_packed_fingerprint())[0]

