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


from io import BytesIO
import struct

class lcmt_schunk_wsg_status(object):

    __slots__ = ["utime", "actual_position_mm", "actual_force", "actual_speed_mm_per_s"]

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

    __dimensions__ = [None, None, None, None]

    def __init__(self):
        self.utime = 0
        """ LCM Type: int64_t """
        self.actual_position_mm = 0.0
        """
        < The timestamp in microseconds.
        LCM Type: double
        """

        self.actual_force = 0.0
        """
        The combined force being applied by both gripper fingers in newtons.
        While some implementations may report a negative value for this field
        under some circumstances, it should always be interpreted as an unsigned
        quantity (absolute value).
        LCM Type: double
        """

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

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

    def _encode_one(self, buf):
        buf.write(struct.pack(">qddd", self.utime, self.actual_position_mm, self.actual_force, self.actual_speed_mm_per_s))

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

    @staticmethod
    def _decode_one(buf):
        self = lcmt_schunk_wsg_status()
        self.utime, self.actual_position_mm, self.actual_force, self.actual_speed_mm_per_s = struct.unpack(">qddd", buf.read(32))
        return self

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

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

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

