[sim] Move Sim classes from HAL to wpilibc/j (#2549)

Also move some things in HAL for consistency.

WAS:
C++:
- C APIs: #include "mockdata/AccelerometerData.h"
- User side class: #include "simulation/AccelerometerSim.h"
Java:
- JNI APIs: hal.sim.mockdata.AccelerometerData (and a few classes in hal.sim)
- User side classes: hal.sim.AccelerometerSim

IS:
C++:
- C APIs: #include "hal/simulation/AccelerometerData.h"
- C++ class: #include "frc/simulation/AccelerometerSim.h"
Java:
- JNI APIs: hal.simulation.AccelerometerData
- User side class: wpilibj.simulation.AccelerometerSim
This commit is contained in:
Peter Johnson
2020-06-27 22:11:24 -07:00
committed by GitHub
parent 22c0e2813a
commit ce3bc91946
207 changed files with 1420 additions and 1415 deletions

View File

@@ -0,0 +1,96 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#pragma once
#include <memory>
#include <utility>
#include <hal/simulation/SPIAccelerometerData.h>
#include "CallbackStore.h"
namespace frc {
namespace sim {
class SPIAccelerometerSim {
public:
explicit SPIAccelerometerSim(int index) { m_index = index; }
std::unique_ptr<CallbackStore> RegisterActiveCallback(NotifyCallback callback,
bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelSPIAccelerometerActiveCallback);
store->SetUid(HALSIM_RegisterSPIAccelerometerActiveCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
bool GetActive() const { return HALSIM_GetSPIAccelerometerActive(m_index); }
void SetActive(bool active) {
HALSIM_SetSPIAccelerometerActive(m_index, active);
}
std::unique_ptr<CallbackStore> RegisterRangeCallback(NotifyCallback callback,
bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelSPIAccelerometerRangeCallback);
store->SetUid(HALSIM_RegisterSPIAccelerometerRangeCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
int GetRange() const { return HALSIM_GetSPIAccelerometerRange(m_index); }
void SetRange(int range) { HALSIM_SetSPIAccelerometerRange(m_index, range); }
std::unique_ptr<CallbackStore> RegisterXCallback(NotifyCallback callback,
bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelSPIAccelerometerXCallback);
store->SetUid(HALSIM_RegisterSPIAccelerometerXCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
double GetX() const { return HALSIM_GetSPIAccelerometerX(m_index); }
void SetX(double x) { HALSIM_SetSPIAccelerometerX(m_index, x); }
std::unique_ptr<CallbackStore> RegisterYCallback(NotifyCallback callback,
bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelSPIAccelerometerYCallback);
store->SetUid(HALSIM_RegisterSPIAccelerometerYCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
double GetY() const { return HALSIM_GetSPIAccelerometerY(m_index); }
void SetY(double y) { HALSIM_SetSPIAccelerometerY(m_index, y); }
std::unique_ptr<CallbackStore> RegisterZCallback(NotifyCallback callback,
bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelSPIAccelerometerZCallback);
store->SetUid(HALSIM_RegisterSPIAccelerometerZCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
double GetZ() const { return HALSIM_GetSPIAccelerometerZ(m_index); }
void SetZ(double z) { HALSIM_SetSPIAccelerometerZ(m_index, z); }
void ResetData() { HALSIM_ResetSPIAccelerometerData(m_index); }
private:
int m_index;
};
} // namespace sim
} // namespace frc