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


from io import BytesIO
import struct

class trajectory_status_t(object):

    __slots__ = ["set_point", "goal", "slew_rate", "is_moving"]

    __typenames__ = ["double", "double", "double", "boolean"]

    __dimensions__ = [None, None, None, None]

    def __init__(self):
        self.set_point = 0.0
        """ LCM Type: double """
        self.goal = 0.0
        """ LCM Type: double """
        self.slew_rate = 0.0
        """ LCM Type: double """
        self.is_moving = False
        """ LCM Type: boolean """

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

    def _encode_one(self, buf):
        buf.write(struct.pack(">dddb", self.set_point, self.goal, self.slew_rate, self.is_moving))

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

    @staticmethod
    def _decode_one(buf):
        self = trajectory_status_t()
        self.set_point, self.goal, self.slew_rate = struct.unpack(">ddd", buf.read(24))
        self.is_moving = bool(struct.unpack('b', buf.read(1))[0])
        return self

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

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

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

