// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.

package org.wpilib.math.controller.struct;

import java.nio.ByteBuffer;
import org.wpilib.math.controller.DifferentialDriveFeedforward;
import org.wpilib.util.struct.Struct;

public final class DifferentialDriveFeedforwardStruct
    implements Struct<DifferentialDriveFeedforward> {
  @Override
  public Class<DifferentialDriveFeedforward> getTypeClass() {
    return DifferentialDriveFeedforward.class;
  }

  @Override
  public String getTypeName() {
    return "DifferentialDriveFeedforward";
  }

  @Override
  public int getSize() {
    return DOUBLE_SIZE * 4;
  }

  @Override
  public String getSchema() {
    return "double kVLinear;double kALinear;double kVAngular;double kAAngular";
  }

  @Override
  public DifferentialDriveFeedforward unpack(ByteBuffer bb) {
    double kVLinear = bb.getDouble();
    double kALinear = bb.getDouble();
    double kVAngular = bb.getDouble();
    double kAAngular = bb.getDouble();
    return new DifferentialDriveFeedforward(kVLinear, kALinear, kVAngular, kAAngular);
  }

  @Override
  public void pack(ByteBuffer bb, DifferentialDriveFeedforward value) {
    bb.putDouble(value.kVLinear);
    bb.putDouble(value.kALinear);
    bb.putDouble(value.kVAngular);
    bb.putDouble(value.kAAngular);
  }
}
