#ifndef FRC_REVLIB_SRC_MAIN_NATIVE_INCLUDE_REV_SPARKSIM_H_
#define FRC_REVLIB_SRC_MAIN_NATIVE_INCLUDE_REV_SPARKSIM_H_
#include <memory>
#include <string>
#include <frc/simulation/SimDeviceSim.h>
#include <frc/system/plant/DCMotor.h>
#include "rev/SparkBase.h"
#include "rev/sim/MovingAverageFilterSim.h"
#include "rev/sim/SparkAbsoluteEncoderSim.h"
#include "rev/sim/SparkAnalogSensorSim.h"
#include "rev/sim/SparkLimitSwitchSim.h"
#include "rev/sim/SparkRelativeEncoderSim.h"
#include "rev/sim/SparkSimFaultManager.h"
namespace rev::spark {
class SparkSim {
public:
SparkSim(SparkBase* spark, frc::DCMotor* motor);
double GetAppliedOutput() const;
void SetAppliedOutput(double appliedOutput);
double GetSetpoint() const;
ClosedLoopSlot GetClosedLoopSlot() const;
void iterate(double velocity, double vbus, double dt);
double GetVelocity() const;
void SetVelocity(double velocity);
double GetPosition() const;
void SetPosition(double position);
double GetBusVoltage() const;
void SetBusVoltage(double voltage);
double GetMotorCurrent() const;
void SetMotorCurrent(double current);
void enable();
void disable();
void useDriverStationEnable();
SparkRelativeEncoderSim GetRelativeEncoderSim();
SparkAbsoluteEncoderSim GetAbsoluteEncoderSim();
SparkAnalogSensorSim GetAnalogSensorSim();
SparkLimitSwitchSim GetForwardLimitSwitchSim();
SparkLimitSwitchSim GetReverseLimitSwitchSim();
SparkSimFaultManager GetFaultManager();
private:
bool runLimitLogic(bool forward);
hal::SimDouble m_appliedOutput;
hal::SimDouble m_velocity;
hal::SimDouble m_position;
hal::SimDouble m_busVoltage;
hal::SimDouble m_motorCurrent;
hal::SimDouble m_setpoint;
hal::SimDouble m_arbFF;
hal::SimInt m_closedLoopSlot;
hal::SimInt m_arbFFUnits;
SparkBase* m_spark;
frc::DCMotor* m_dcMotor;
hal::SimInt m_controlMode;
MovingAverageFilterSim m_velocityAverage;
std::unique_ptr<bool> m_enable;
std::string m_deviceName;
std::string m_unknownDeviceTypeMessage;
};
}
#endif