robot-rust 0.2.1

The robot-rust project, bindings for wpilib, ctre, and rev in rust.
/*
 * Copyright (C) Cross The Road Electronics.  All rights reserved.
 * License information can be found in CTRE_LICENSE.txt
 * For support and suggestions contact support@ctr-electronics.com or file
 * an issue tracker at https://github.com/CrossTheRoadElec/Phoenix-Releases
 */
#pragma once

#include "ctre/phoenix/StatusCodes.h"
#include "ctre/phoenix6/signals/SpnEnums.hpp"
#include <units/current.h>
#include <units/temperature.h>
#include <units/voltage.h>

namespace ctre {
namespace phoenix6 {

namespace hardware {
namespace core {
	/* forward proto */
	class CoreCANdle;
}
}

namespace sim {

	/**
	 * \brief Class to control the state of a simulated hardware#CANdle.
	 */
	class CANdleSimState
	{
	private:
		int _id;

	public:
		/**
		 * \brief Creates an object to control the state of the given hardware#CANdle.
		 *
		 * \details Note the recommended method of accessing simulation features is to
		 *          use hardware#CANdle#GetSimState.
		 *
		 * \param device Device to which this simulation state is attached
		 */
		CANdleSimState(hardware::core::CoreCANdle const &device);
		/* disallow copy, allow move */
		CANdleSimState(CANdleSimState const &) = delete;
		CANdleSimState(CANdleSimState &&) = default;
		CANdleSimState &operator=(CANdleSimState const &) = delete;
		CANdleSimState &operator=(CANdleSimState &&) = default;

		/**
		 * \brief Gets the last status code generated by a simulation function.
		 *
		 * \details Not all functions return a status code but can potentially report errors.
		 * This function can be used to retrieve those status codes.
		 *
		 * \returns Last status code generated by a simulation function
		 */
		ctre::phoenix::StatusCode GetLastStatusCode() const;

		/**
		 * \brief Gets the simulated VBat modulated output of the CANdle.
		 *
		 * \returns VBat modulation duty cycle
		 */
		units::dimensionless::scalar_t GetVBatModulation() const;

		/**
		 * \brief Sets the simulated supply voltage of the CANdle.
		 *
		 * \details The minimum allowed supply voltage is 4 V - values below this
		 * will be promoted to 4 V.
		 *
		 * \param volts The supply voltage in Volts
		 * \returns Status code
		 */
		ctre::phoenix::StatusCode SetSupplyVoltage(units::voltage::volt_t volts);

		/**
		 * \brief Sets the simulated 5V rail voltage of the CANdle.
		 *
		 * \param volts The 5V rail voltage in Volts
		 * \returns Status code
		 */
		ctre::phoenix::StatusCode SetFiveVRailVoltage(units::voltage::volt_t volts);

		/**
		 * \brief Sets the simulated output current of the CANdle.
		 *
		 * \param amps The output current in Amps
		 * \returns Status code
		 */
		ctre::phoenix::StatusCode SetOutputCurrent(units::current::ampere_t amps);

		/**
		 * \brief Sets the simulated temperature of the CANdle.
		 *
		 * \param temperature The device temperature in ℃
		 * \returns Status code
		 */
		ctre::phoenix::StatusCode SetDeviceTemp(units::temperature::celsius_t temperature);
	};
}

}
}