"""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 L13Wind(object):
    __slots__ = ["direction", "magnitude"]

    def __init__(self):
        self.direction = 0.0
        self.magnitude = 0

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

    def _encode_one(self, buf):
        buf.write(struct.pack(">fb", self.direction, self.magnitude))

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

    def _decode_one(buf):
        self = L13Wind()
        self.direction, self.magnitude = struct.unpack(">fb", buf.read(5))
        return self
    _decode_one = staticmethod(_decode_one)

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

