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


from io import BytesIO
import struct

class lcmt_force_torque(object):

    __slots__ = ["timestamp", "fx", "fy", "fz", "tx", "ty", "tz"]

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

    __dimensions__ = [None, None, None, None, None, None, None]

    def __init__(self):
        self.timestamp = 0
        """
        The timestamp in milliseconds.
        LCM Type: int64_t
        """

        self.fx = 0.0
        """ LCM Type: double """
        self.fy = 0.0
        """ LCM Type: double """
        self.fz = 0.0
        """ LCM Type: double """
        self.tx = 0.0
        """ LCM Type: double """
        self.ty = 0.0
        """ LCM Type: double """
        self.tz = 0.0
        """ LCM Type: double """

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

    def _encode_one(self, buf):
        buf.write(struct.pack(">qdddddd", self.timestamp, self.fx, self.fy, self.fz, self.tx, self.ty, self.tz))

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

    @staticmethod
    def _decode_one(buf):
        self = lcmt_force_torque()
        self.timestamp, self.fx, self.fy, self.fz, self.tx, self.ty, self.tz = struct.unpack(">qdddddd", buf.read(56))
        return self

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

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

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

