// Auto-generated. Do not edit!

// (in-package shiyan2.srv)


"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 FFTRequest {
  constructor(initObj={}) {
    if (initObj === null) {
      // initObj === null is a special case for deserialization where we don't initialize fields
      this.data_x = null;
      this.data_y = null;
      this.window_size = null;
    }
    else {
      if (initObj.hasOwnProperty('data_x')) {
        this.data_x = initObj.data_x
      }
      else {
        this.data_x = [];
      }
      if (initObj.hasOwnProperty('data_y')) {
        this.data_y = initObj.data_y
      }
      else {
        this.data_y = [];
      }
      if (initObj.hasOwnProperty('window_size')) {
        this.window_size = initObj.window_size
      }
      else {
        this.window_size = 0;
      }
    }
  }

  static serialize(obj, buffer, bufferOffset) {
    // Serializes a message object of type FFTRequest
    // Serialize message field [data_x]
    bufferOffset = _arraySerializer.float64(obj.data_x, buffer, bufferOffset, null);
    // Serialize message field [data_y]
    bufferOffset = _arraySerializer.float64(obj.data_y, buffer, bufferOffset, null);
    // Serialize message field [window_size]
    bufferOffset = _serializer.int32(obj.window_size, buffer, bufferOffset);
    return bufferOffset;
  }

  static deserialize(buffer, bufferOffset=[0]) {
    //deserializes a message object of type FFTRequest
    let len;
    let data = new FFTRequest(null);
    // Deserialize message field [data_x]
    data.data_x = _arrayDeserializer.float64(buffer, bufferOffset, null)
    // Deserialize message field [data_y]
    data.data_y = _arrayDeserializer.float64(buffer, bufferOffset, null)
    // Deserialize message field [window_size]
    data.window_size = _deserializer.int32(buffer, bufferOffset);
    return data;
  }

  static getMessageSize(object) {
    let length = 0;
    length += 8 * object.data_x.length;
    length += 8 * object.data_y.length;
    return length + 12;
  }

  static datatype() {
    // Returns string type for a service object
    return 'shiyan2/FFTRequest';
  }

  static md5sum() {
    //Returns md5sum for a message object
    return '733f3e62b6715209e5e8aea0162ecd43';
  }

  static messageDefinition() {
    // Returns full string definition for message
    return `
    float64[] data_x
    float64[] data_y
    int32 window_size
    
    `;
  }

  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 FFTRequest(null);
    if (msg.data_x !== undefined) {
      resolved.data_x = msg.data_x;
    }
    else {
      resolved.data_x = []
    }

    if (msg.data_y !== undefined) {
      resolved.data_y = msg.data_y;
    }
    else {
      resolved.data_y = []
    }

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

    return resolved;
    }
};

class FFTResponse {
  constructor(initObj={}) {
    if (initObj === null) {
      // initObj === null is a special case for deserialization where we don't initialize fields
      this.magnitude_x = null;
      this.magnitude_y = null;
      this.phase_x = null;
      this.phase_y = null;
    }
    else {
      if (initObj.hasOwnProperty('magnitude_x')) {
        this.magnitude_x = initObj.magnitude_x
      }
      else {
        this.magnitude_x = [];
      }
      if (initObj.hasOwnProperty('magnitude_y')) {
        this.magnitude_y = initObj.magnitude_y
      }
      else {
        this.magnitude_y = [];
      }
      if (initObj.hasOwnProperty('phase_x')) {
        this.phase_x = initObj.phase_x
      }
      else {
        this.phase_x = [];
      }
      if (initObj.hasOwnProperty('phase_y')) {
        this.phase_y = initObj.phase_y
      }
      else {
        this.phase_y = [];
      }
    }
  }

  static serialize(obj, buffer, bufferOffset) {
    // Serializes a message object of type FFTResponse
    // Serialize message field [magnitude_x]
    bufferOffset = _arraySerializer.float64(obj.magnitude_x, buffer, bufferOffset, null);
    // Serialize message field [magnitude_y]
    bufferOffset = _arraySerializer.float64(obj.magnitude_y, buffer, bufferOffset, null);
    // Serialize message field [phase_x]
    bufferOffset = _arraySerializer.float64(obj.phase_x, buffer, bufferOffset, null);
    // Serialize message field [phase_y]
    bufferOffset = _arraySerializer.float64(obj.phase_y, buffer, bufferOffset, null);
    return bufferOffset;
  }

  static deserialize(buffer, bufferOffset=[0]) {
    //deserializes a message object of type FFTResponse
    let len;
    let data = new FFTResponse(null);
    // Deserialize message field [magnitude_x]
    data.magnitude_x = _arrayDeserializer.float64(buffer, bufferOffset, null)
    // Deserialize message field [magnitude_y]
    data.magnitude_y = _arrayDeserializer.float64(buffer, bufferOffset, null)
    // Deserialize message field [phase_x]
    data.phase_x = _arrayDeserializer.float64(buffer, bufferOffset, null)
    // Deserialize message field [phase_y]
    data.phase_y = _arrayDeserializer.float64(buffer, bufferOffset, null)
    return data;
  }

  static getMessageSize(object) {
    let length = 0;
    length += 8 * object.magnitude_x.length;
    length += 8 * object.magnitude_y.length;
    length += 8 * object.phase_x.length;
    length += 8 * object.phase_y.length;
    return length + 16;
  }

  static datatype() {
    // Returns string type for a service object
    return 'shiyan2/FFTResponse';
  }

  static md5sum() {
    //Returns md5sum for a message object
    return '66df876c396498ba109714197bb49c4c';
  }

  static messageDefinition() {
    // Returns full string definition for message
    return `
    float64[] magnitude_x
    float64[] magnitude_y
    float64[] phase_x
    float64[] phase_y
    
    `;
  }

  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 FFTResponse(null);
    if (msg.magnitude_x !== undefined) {
      resolved.magnitude_x = msg.magnitude_x;
    }
    else {
      resolved.magnitude_x = []
    }

    if (msg.magnitude_y !== undefined) {
      resolved.magnitude_y = msg.magnitude_y;
    }
    else {
      resolved.magnitude_y = []
    }

    if (msg.phase_x !== undefined) {
      resolved.phase_x = msg.phase_x;
    }
    else {
      resolved.phase_x = []
    }

    if (msg.phase_y !== undefined) {
      resolved.phase_y = msg.phase_y;
    }
    else {
      resolved.phase_y = []
    }

    return resolved;
    }
};

module.exports = {
  Request: FFTRequest,
  Response: FFTResponse,
  md5sum() { return '1c6bb3ace645464ed07f169d1723447f'; },
  datatype() { return 'shiyan2/FFT'; }
};
