// Auto-generated. Do not edit!

// (in-package pi4_peristaltic_pump_msgs.msg)


"use strict";

const _serializer = _ros_msg_utils.Serialize;
const _arraySerializer = _serializer.Array;
const _deserializer = _ros_msg_utils.Deserialize;
const _arrayDeserializer = _deserializer.Array;
const _finder = _ros_msg_utils.Find;
const _getByteLength = _ros_msg_utils.getByteLength;

//-----------------------------------------------------------

class DispenserCommand {
  constructor(initObj={}) {
    if (initObj === null) {
      // initObj === null is a special case for deserialization where we don't initialize fields
      this.dispenser_command = null;
      this.dispenser_speed = null;
      this.dispenser_time = null;
      this.dispenser_ml = null;
    }
    else {
      if (initObj.hasOwnProperty('dispenser_command')) {
        this.dispenser_command = initObj.dispenser_command
      }
      else {
        this.dispenser_command = 0;
      }
      if (initObj.hasOwnProperty('dispenser_speed')) {
        this.dispenser_speed = initObj.dispenser_speed
      }
      else {
        this.dispenser_speed = 0.0;
      }
      if (initObj.hasOwnProperty('dispenser_time')) {
        this.dispenser_time = initObj.dispenser_time
      }
      else {
        this.dispenser_time = 0;
      }
      if (initObj.hasOwnProperty('dispenser_ml')) {
        this.dispenser_ml = initObj.dispenser_ml
      }
      else {
        this.dispenser_ml = 0.0;
      }
    }
  }

  static serialize(obj, buffer, bufferOffset) {
    // Serializes a message object of type DispenserCommand
    // Serialize message field [dispenser_command]
    bufferOffset = _serializer.int32(obj.dispenser_command, buffer, bufferOffset);
    // Serialize message field [dispenser_speed]
    bufferOffset = _serializer.float32(obj.dispenser_speed, buffer, bufferOffset);
    // Serialize message field [dispenser_time]
    bufferOffset = _serializer.int32(obj.dispenser_time, buffer, bufferOffset);
    // Serialize message field [dispenser_ml]
    bufferOffset = _serializer.float32(obj.dispenser_ml, buffer, bufferOffset);
    return bufferOffset;
  }

  static deserialize(buffer, bufferOffset=[0]) {
    //deserializes a message object of type DispenserCommand
    let len;
    let data = new DispenserCommand(null);
    // Deserialize message field [dispenser_command]
    data.dispenser_command = _deserializer.int32(buffer, bufferOffset);
    // Deserialize message field [dispenser_speed]
    data.dispenser_speed = _deserializer.float32(buffer, bufferOffset);
    // Deserialize message field [dispenser_time]
    data.dispenser_time = _deserializer.int32(buffer, bufferOffset);
    // Deserialize message field [dispenser_ml]
    data.dispenser_ml = _deserializer.float32(buffer, bufferOffset);
    return data;
  }

  static getMessageSize(object) {
    return 16;
  }

  static datatype() {
    // Returns string type for a message object
    return 'pi4_peristaltic_pump_msgs/DispenserCommand';
  }

  static md5sum() {
    //Returns md5sum for a message object
    return '19eeefa89e53cf5a80032222d498cad3';
  }

  static messageDefinition() {
    // Returns full string definition for message
    return `
    # 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
    
    `;
  }

  static Resolve(msg) {
    // deep-construct a valid message object instance of whatever was passed in
    if (typeof msg !== 'object' || msg === null) {
      msg = {};
    }
    const resolved = new DispenserCommand(null);
    if (msg.dispenser_command !== undefined) {
      resolved.dispenser_command = msg.dispenser_command;
    }
    else {
      resolved.dispenser_command = 0
    }

    if (msg.dispenser_speed !== undefined) {
      resolved.dispenser_speed = msg.dispenser_speed;
    }
    else {
      resolved.dispenser_speed = 0.0
    }

    if (msg.dispenser_time !== undefined) {
      resolved.dispenser_time = msg.dispenser_time;
    }
    else {
      resolved.dispenser_time = 0
    }

    if (msg.dispenser_ml !== undefined) {
      resolved.dispenser_ml = msg.dispenser_ml;
    }
    else {
      resolved.dispenser_ml = 0.0
    }

    return resolved;
    }
};

// Constants for message
DispenserCommand.Constants = {
  ON: 0,
  OFF: 1,
  RESET: 2,
  REVERSE: 3,
  DISPENSEINDEF: 4,
  DISPENSEINDEFREV: 5,
  DISPENSE: 6,
  DISPENSEREV: 7,
  DISPENSEPID: 8,
}

module.exports = DispenserCommand;
