001// Copyright (c) FIRST and other WPILib contributors.
002// Open Source Software; you can modify and/or share it under the terms of
003// the WPILib BSD license file in the root directory of this project.
004
005package edu.wpi.first.wpilibj.simulation;
006
007import edu.wpi.first.hal.SimDouble;
008import edu.wpi.first.wpilibj.ADXL362;
009import java.util.Objects;
010
011public class ADXL362Sim {
012  protected SimDouble m_simX;
013  protected SimDouble m_simY;
014  protected SimDouble m_simZ;
015
016  /**
017   * Constructor.
018   *
019   * @param device The device to simulate
020   */
021  public ADXL362Sim(ADXL362 device) {
022    SimDeviceSim wrappedSimDevice =
023        new SimDeviceSim("Accel:ADXL362" + "[" + device.getPort() + "]");
024    initSim(wrappedSimDevice);
025  }
026
027  private void initSim(SimDeviceSim wrappedSimDevice) {
028    m_simX = wrappedSimDevice.getDouble("x");
029    m_simY = wrappedSimDevice.getDouble("y");
030    m_simZ = wrappedSimDevice.getDouble("z");
031
032    Objects.requireNonNull(m_simX);
033    Objects.requireNonNull(m_simY);
034    Objects.requireNonNull(m_simZ);
035  }
036
037  public void setX(double x) {
038    m_simX.set(x);
039  }
040
041  public void setY(double y) {
042    m_simY.set(y);
043  }
044
045  public void setZ(double z) {
046    m_simZ.set(z);
047  }
048}