# This Python file uses the following encoding: utf-8
"""autogenerated by genpy from pi4_peristaltic_pump_msgs/DispenserCommand.msg. Do not edit."""
import codecs
import sys
python3 = True if sys.hexversion > 0x03000000 else False
import genpy
import struct


class DispenserCommand(genpy.Message):
  _md5sum = "19eeefa89e53cf5a80032222d498cad3"
  _type = "pi4_peristaltic_pump_msgs/DispenserCommand"
  _has_header = False  # flag to mark the presence of a Header object
  _full_text = """# Available commands to use the Fisher Scientific PPS4102 Top Pan balance 
int32 ON = 0
int32 OFF = 1
int32 RESET = 2
int32 REVERSE = 3
int32 DISPENSEINDEF = 4
int32 DISPENSEINDEFREV = 5
int32 DISPENSE = 6
int32 DISPENSEREV = 7
int32 DISPENSEPID = 8

int32 dispenser_command
float32 dispenser_speed
int32 dispenser_time
float32 dispenser_ml
"""
  # Pseudo-constants
  ON = 0
  OFF = 1
  RESET = 2
  REVERSE = 3
  DISPENSEINDEF = 4
  DISPENSEINDEFREV = 5
  DISPENSE = 6
  DISPENSEREV = 7
  DISPENSEPID = 8

  __slots__ = ['dispenser_command','dispenser_speed','dispenser_time','dispenser_ml']
  _slot_types = ['int32','float32','int32','float32']

  def __init__(self, *args, **kwds):
    """
    Constructor. Any message fields that are implicitly/explicitly
    set to None will be assigned a default value. The recommend
    use is keyword arguments as this is more robust to future message
    changes.  You cannot mix in-order arguments and keyword arguments.

    The available fields are:
       dispenser_command,dispenser_speed,dispenser_time,dispenser_ml

    :param args: complete set of field values, in .msg order
    :param kwds: use keyword arguments corresponding to message field names
    to set specific fields.
    """
    if args or kwds:
      super(DispenserCommand, self).__init__(*args, **kwds)
      # message fields cannot be None, assign default values for those that are
      if self.dispenser_command is None:
        self.dispenser_command = 0
      if self.dispenser_speed is None:
        self.dispenser_speed = 0.
      if self.dispenser_time is None:
        self.dispenser_time = 0
      if self.dispenser_ml is None:
        self.dispenser_ml = 0.
    else:
      self.dispenser_command = 0
      self.dispenser_speed = 0.
      self.dispenser_time = 0
      self.dispenser_ml = 0.

  def _get_types(self):
    """
    internal API method
    """
    return self._slot_types

  def serialize(self, buff):
    """
    serialize message into buffer
    :param buff: buffer, ``StringIO``
    """
    try:
      _x = self
      buff.write(_get_struct_ifif().pack(_x.dispenser_command, _x.dispenser_speed, _x.dispenser_time, _x.dispenser_ml))
    except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(locals().get('_x', self)))))
    except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(locals().get('_x', self)))))

  def deserialize(self, str):
    """
    unpack serialized message in str into this message instance
    :param str: byte array of serialized message, ``str``
    """
    if python3:
      codecs.lookup_error("rosmsg").msg_type = self._type
    try:
      end = 0
      _x = self
      start = end
      end += 16
      (_x.dispenser_command, _x.dispenser_speed, _x.dispenser_time, _x.dispenser_ml,) = _get_struct_ifif().unpack(str[start:end])
      return self
    except struct.error as e:
      raise genpy.DeserializationError(e)  # most likely buffer underfill


  def serialize_numpy(self, buff, numpy):
    """
    serialize message with numpy array types into buffer
    :param buff: buffer, ``StringIO``
    :param numpy: numpy python module
    """
    try:
      _x = self
      buff.write(_get_struct_ifif().pack(_x.dispenser_command, _x.dispenser_speed, _x.dispenser_time, _x.dispenser_ml))
    except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(locals().get('_x', self)))))
    except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(locals().get('_x', self)))))

  def deserialize_numpy(self, str, numpy):
    """
    unpack serialized message in str into this message instance using numpy for array types
    :param str: byte array of serialized message, ``str``
    :param numpy: numpy python module
    """
    if python3:
      codecs.lookup_error("rosmsg").msg_type = self._type
    try:
      end = 0
      _x = self
      start = end
      end += 16
      (_x.dispenser_command, _x.dispenser_speed, _x.dispenser_time, _x.dispenser_ml,) = _get_struct_ifif().unpack(str[start:end])
      return self
    except struct.error as e:
      raise genpy.DeserializationError(e)  # most likely buffer underfill

_struct_I = genpy.struct_I
def _get_struct_I():
    global _struct_I
    return _struct_I
_struct_ifif = None
def _get_struct_ifif():
    global _struct_ifif
    if _struct_ifif is None:
        _struct_ifif = struct.Struct("<ifif")
    return _struct_ifif
