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


from io import BytesIO
import struct

class lcmt_acrobot_y(object):

    __slots__ = ["timestamp", "theta1", "theta2", "tau"]

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

    __dimensions__ = [None, None, None, None]

    def __init__(self):
        self.timestamp = 0
        """ LCM Type: int64_t """
        self.theta1 = 0.0
        """ LCM Type: double """
        self.theta2 = 0.0
        """
        measured position
        LCM Type: double
        """

        self.tau = 0.0
        """ LCM Type: double """

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

    def _encode_one(self, buf):
        buf.write(struct.pack(">qddd", self.timestamp, self.theta1, self.theta2, self.tau))

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

    @staticmethod
    def _decode_one(buf):
        self = lcmt_acrobot_y()
        self.timestamp, self.theta1, self.theta2, self.tau = struct.unpack(">qddd", buf.read(32))
        return self

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

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

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

