mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
[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:
@@ -0,0 +1,82 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* 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/AnalogTriggerData.h>
|
||||
|
||||
#include "CallbackStore.h"
|
||||
|
||||
namespace frc {
|
||||
namespace sim {
|
||||
class AnalogTriggerSim {
|
||||
public:
|
||||
explicit AnalogTriggerSim(int index) { m_index = index; }
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterInitializedCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelAnalogTriggerInitializedCallback);
|
||||
store->SetUid(HALSIM_RegisterAnalogTriggerInitializedCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
bool GetInitialized() const {
|
||||
return HALSIM_GetAnalogTriggerInitialized(m_index);
|
||||
}
|
||||
|
||||
void SetInitialized(bool initialized) {
|
||||
HALSIM_SetAnalogTriggerInitialized(m_index, initialized);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterTriggerLowerBoundCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback,
|
||||
&HALSIM_CancelAnalogTriggerTriggerLowerBoundCallback);
|
||||
store->SetUid(HALSIM_RegisterAnalogTriggerTriggerLowerBoundCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
double GetTriggerLowerBound() const {
|
||||
return HALSIM_GetAnalogTriggerTriggerLowerBound(m_index);
|
||||
}
|
||||
|
||||
void SetTriggerLowerBound(double triggerLowerBound) {
|
||||
HALSIM_SetAnalogTriggerTriggerLowerBound(m_index, triggerLowerBound);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterTriggerUpperBoundCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback,
|
||||
&HALSIM_CancelAnalogTriggerTriggerUpperBoundCallback);
|
||||
store->SetUid(HALSIM_RegisterAnalogTriggerTriggerUpperBoundCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
double GetTriggerUpperBound() const {
|
||||
return HALSIM_GetAnalogTriggerTriggerUpperBound(m_index);
|
||||
}
|
||||
|
||||
void SetTriggerUpperBound(double triggerUpperBound) {
|
||||
HALSIM_SetAnalogTriggerTriggerUpperBound(m_index, triggerUpperBound);
|
||||
}
|
||||
|
||||
void ResetData() { HALSIM_ResetAnalogTriggerData(m_index); }
|
||||
|
||||
private:
|
||||
int m_index;
|
||||
};
|
||||
} // namespace sim
|
||||
} // namespace frc
|
||||
Reference in New Issue
Block a user