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


from io import BytesIO
import struct

class lcmt_iiwa_status_telemetry(object):

    __slots__ = ["host_utime", "iiwa_utime", "estimated_dt_host_minus_iiwa"]

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

    __dimensions__ = [None, None, None]

    def __init__(self):
        self.host_utime = 0
        """
        Host's timestamp in micro seconds when the status packet is received.
        LCM Type: int64_t
        """

        self.iiwa_utime = 0
        """
        Iiwa controller's timestamp in micro seconds for the status packet.
        LCM Type: int64_t
        """

        self.estimated_dt_host_minus_iiwa = 0
        """
        Estimated offset defined as: host - iiwa
        LCM Type: int64_t
        """


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

    def _encode_one(self, buf):
        buf.write(struct.pack(">qqq", self.host_utime, self.iiwa_utime, self.estimated_dt_host_minus_iiwa))

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

    @staticmethod
    def _decode_one(buf):
        self = lcmt_iiwa_status_telemetry()
        self.host_utime, self.iiwa_utime, self.estimated_dt_host_minus_iiwa = struct.unpack(">qqq", buf.read(24))
        return self

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

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

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

