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.hal;
006
007/** A wrapper around a simulator double value handle. */
008public class SimDouble extends SimValue {
009  /**
010   * Wraps a simulated value handle as returned by SimDeviceJNI.createSimValueDouble().
011   *
012   * @param handle simulated value handle
013   */
014  public SimDouble(int handle) {
015    super(handle);
016  }
017
018  /**
019   * Gets the simulated value.
020   *
021   * @return The current value
022   */
023  public double get() {
024    return SimDeviceJNI.getSimValueDouble(m_handle);
025  }
026
027  /**
028   * Sets the simulated value.
029   *
030   * @param value the value to set
031   */
032  public void set(double value) {
033    SimDeviceJNI.setSimValueDouble(m_handle, value);
034  }
035
036  /**
037   * Resets the simulated value to 0. Use this instead of Set(0) for resetting incremental sensor
038   * values like encoder counts or gyro accumulated angle to ensure correct behavior in a
039   * distributed system (e.g. WebSockets).
040   */
041  public void reset() {
042    SimDeviceJNI.resetSimValue(m_handle);
043  }
044}