mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11:42 +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,100 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* 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/AccelerometerData.h>
|
||||
|
||||
#include "CallbackStore.h"
|
||||
|
||||
namespace frc {
|
||||
namespace sim {
|
||||
class AccelerometerSim {
|
||||
public:
|
||||
explicit AccelerometerSim(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_CancelAccelerometerActiveCallback);
|
||||
store->SetUid(HALSIM_RegisterAccelerometerActiveCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
bool GetActive() const { return HALSIM_GetAccelerometerActive(m_index); }
|
||||
|
||||
void SetActive(bool active) {
|
||||
HALSIM_SetAccelerometerActive(m_index, active);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterRangeCallback(NotifyCallback callback,
|
||||
bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelAccelerometerRangeCallback);
|
||||
store->SetUid(HALSIM_RegisterAccelerometerRangeCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
HAL_AccelerometerRange GetRange() const {
|
||||
return HALSIM_GetAccelerometerRange(m_index);
|
||||
}
|
||||
|
||||
void SetRange(HAL_AccelerometerRange range) {
|
||||
HALSIM_SetAccelerometerRange(m_index, range);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterXCallback(NotifyCallback callback,
|
||||
bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelAccelerometerXCallback);
|
||||
store->SetUid(HALSIM_RegisterAccelerometerXCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
double GetX() const { return HALSIM_GetAccelerometerX(m_index); }
|
||||
|
||||
void SetX(double x) { HALSIM_SetAccelerometerX(m_index, x); }
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterYCallback(NotifyCallback callback,
|
||||
bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelAccelerometerYCallback);
|
||||
store->SetUid(HALSIM_RegisterAccelerometerYCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
double GetY() const { return HALSIM_GetAccelerometerY(m_index); }
|
||||
|
||||
void SetY(double y) { HALSIM_SetAccelerometerY(m_index, y); }
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterZCallback(NotifyCallback callback,
|
||||
bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelAccelerometerZCallback);
|
||||
store->SetUid(HALSIM_RegisterAccelerometerZCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
double GetZ() const { return HALSIM_GetAccelerometerZ(m_index); }
|
||||
|
||||
void SetZ(double z) { HALSIM_SetAccelerometerZ(m_index, z); }
|
||||
|
||||
void ResetData() { HALSIM_ResetAccelerometerData(m_index); }
|
||||
|
||||
private:
|
||||
int m_index;
|
||||
};
|
||||
} // namespace sim
|
||||
} // namespace frc
|
||||
@@ -0,0 +1,72 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* 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/AnalogGyroData.h>
|
||||
|
||||
#include "CallbackStore.h"
|
||||
|
||||
namespace frc {
|
||||
namespace sim {
|
||||
class AnalogGyroSim {
|
||||
public:
|
||||
explicit AnalogGyroSim(int index) { m_index = index; }
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterAngleCallback(NotifyCallback callback,
|
||||
bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelAnalogGyroAngleCallback);
|
||||
store->SetUid(HALSIM_RegisterAnalogGyroAngleCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
double GetAngle() const { return HALSIM_GetAnalogGyroAngle(m_index); }
|
||||
|
||||
void SetAngle(double angle) { HALSIM_SetAnalogGyroAngle(m_index, angle); }
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterRateCallback(NotifyCallback callback,
|
||||
bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelAnalogGyroRateCallback);
|
||||
store->SetUid(HALSIM_RegisterAnalogGyroRateCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
double GetRate() const { return HALSIM_GetAnalogGyroRate(m_index); }
|
||||
|
||||
void SetRate(double rate) { HALSIM_SetAnalogGyroRate(m_index, rate); }
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterInitializedCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelAnalogGyroInitializedCallback);
|
||||
store->SetUid(HALSIM_RegisterAnalogGyroInitializedCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
bool GetInitialized() const {
|
||||
return HALSIM_GetAnalogGyroInitialized(m_index);
|
||||
}
|
||||
|
||||
void SetInitialized(bool initialized) {
|
||||
HALSIM_SetAnalogGyroInitialized(m_index, initialized);
|
||||
}
|
||||
|
||||
void ResetData() { HALSIM_ResetAnalogGyroData(m_index); }
|
||||
|
||||
private:
|
||||
int m_index;
|
||||
};
|
||||
} // namespace sim
|
||||
} // namespace frc
|
||||
178
wpilibc/src/main/native/include/frc/simulation/AnalogInSim.h
Normal file
178
wpilibc/src/main/native/include/frc/simulation/AnalogInSim.h
Normal file
@@ -0,0 +1,178 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* 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/AnalogInData.h>
|
||||
|
||||
#include "CallbackStore.h"
|
||||
|
||||
namespace frc {
|
||||
namespace sim {
|
||||
class AnalogInSim {
|
||||
public:
|
||||
explicit AnalogInSim(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_CancelAnalogInInitializedCallback);
|
||||
store->SetUid(HALSIM_RegisterAnalogInInitializedCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
bool GetInitialized() const { return HALSIM_GetAnalogInInitialized(m_index); }
|
||||
|
||||
void SetInitialized(bool initialized) {
|
||||
HALSIM_SetAnalogInInitialized(m_index, initialized);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterAverageBitsCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelAnalogInAverageBitsCallback);
|
||||
store->SetUid(HALSIM_RegisterAnalogInAverageBitsCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
int GetAverageBits() const { return HALSIM_GetAnalogInAverageBits(m_index); }
|
||||
|
||||
void SetAverageBits(int averageBits) {
|
||||
HALSIM_SetAnalogInAverageBits(m_index, averageBits);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterOversampleBitsCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelAnalogInOversampleBitsCallback);
|
||||
store->SetUid(HALSIM_RegisterAnalogInOversampleBitsCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
int GetOversampleBits() const {
|
||||
return HALSIM_GetAnalogInOversampleBits(m_index);
|
||||
}
|
||||
|
||||
void SetOversampleBits(int oversampleBits) {
|
||||
HALSIM_SetAnalogInOversampleBits(m_index, oversampleBits);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterVoltageCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelAnalogInVoltageCallback);
|
||||
store->SetUid(HALSIM_RegisterAnalogInVoltageCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
double GetVoltage() const { return HALSIM_GetAnalogInVoltage(m_index); }
|
||||
|
||||
void SetVoltage(double voltage) {
|
||||
HALSIM_SetAnalogInVoltage(m_index, voltage);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterAccumulatorInitializedCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback,
|
||||
&HALSIM_CancelAnalogInAccumulatorInitializedCallback);
|
||||
store->SetUid(HALSIM_RegisterAnalogInAccumulatorInitializedCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
bool GetAccumulatorInitialized() const {
|
||||
return HALSIM_GetAnalogInAccumulatorInitialized(m_index);
|
||||
}
|
||||
|
||||
void SetAccumulatorInitialized(bool accumulatorInitialized) {
|
||||
HALSIM_SetAnalogInAccumulatorInitialized(m_index, accumulatorInitialized);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterAccumulatorValueCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelAnalogInAccumulatorValueCallback);
|
||||
store->SetUid(HALSIM_RegisterAnalogInAccumulatorValueCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
int64_t GetAccumulatorValue() const {
|
||||
return HALSIM_GetAnalogInAccumulatorValue(m_index);
|
||||
}
|
||||
|
||||
void SetAccumulatorValue(int64_t accumulatorValue) {
|
||||
HALSIM_SetAnalogInAccumulatorValue(m_index, accumulatorValue);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterAccumulatorCountCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelAnalogInAccumulatorCountCallback);
|
||||
store->SetUid(HALSIM_RegisterAnalogInAccumulatorCountCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
int64_t GetAccumulatorCount() const {
|
||||
return HALSIM_GetAnalogInAccumulatorCount(m_index);
|
||||
}
|
||||
|
||||
void SetAccumulatorCount(int64_t accumulatorCount) {
|
||||
HALSIM_SetAnalogInAccumulatorCount(m_index, accumulatorCount);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterAccumulatorCenterCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelAnalogInAccumulatorCenterCallback);
|
||||
store->SetUid(HALSIM_RegisterAnalogInAccumulatorCenterCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
int GetAccumulatorCenter() const {
|
||||
return HALSIM_GetAnalogInAccumulatorCenter(m_index);
|
||||
}
|
||||
|
||||
void SetAccumulatorCenter(int accumulatorCenter) {
|
||||
HALSIM_SetAnalogInAccumulatorCenter(m_index, accumulatorCenter);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterAccumulatorDeadbandCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback,
|
||||
&HALSIM_CancelAnalogInAccumulatorDeadbandCallback);
|
||||
store->SetUid(HALSIM_RegisterAnalogInAccumulatorDeadbandCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
int GetAccumulatorDeadband() const {
|
||||
return HALSIM_GetAnalogInAccumulatorDeadband(m_index);
|
||||
}
|
||||
|
||||
void SetAccumulatorDeadband(int accumulatorDeadband) {
|
||||
HALSIM_SetAnalogInAccumulatorDeadband(m_index, accumulatorDeadband);
|
||||
}
|
||||
|
||||
void ResetData() { HALSIM_ResetAnalogInData(m_index); }
|
||||
|
||||
private:
|
||||
int m_index;
|
||||
};
|
||||
} // namespace sim
|
||||
} // namespace frc
|
||||
@@ -0,0 +1,61 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* 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/AnalogOutData.h>
|
||||
|
||||
#include "CallbackStore.h"
|
||||
|
||||
namespace frc {
|
||||
namespace sim {
|
||||
class AnalogOutSim {
|
||||
public:
|
||||
explicit AnalogOutSim(int index) { m_index = index; }
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterVoltageCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelAnalogOutVoltageCallback);
|
||||
store->SetUid(HALSIM_RegisterAnalogOutVoltageCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
double GetVoltage() const { return HALSIM_GetAnalogOutVoltage(m_index); }
|
||||
|
||||
void SetVoltage(double voltage) {
|
||||
HALSIM_SetAnalogOutVoltage(m_index, voltage);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterInitializedCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelAnalogOutInitializedCallback);
|
||||
store->SetUid(HALSIM_RegisterAnalogOutInitializedCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
bool GetInitialized() const {
|
||||
return HALSIM_GetAnalogOutInitialized(m_index);
|
||||
}
|
||||
|
||||
void SetInitialized(bool initialized) {
|
||||
HALSIM_SetAnalogOutInitialized(m_index, initialized);
|
||||
}
|
||||
|
||||
void ResetData() { HALSIM_ResetAnalogOutData(m_index); }
|
||||
|
||||
private:
|
||||
int m_index;
|
||||
};
|
||||
} // namespace sim
|
||||
} // namespace frc
|
||||
@@ -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
|
||||
@@ -0,0 +1,88 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* 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 <functional>
|
||||
|
||||
#include <hal/Value.h>
|
||||
#include <wpi/StringRef.h>
|
||||
|
||||
namespace frc {
|
||||
namespace sim {
|
||||
|
||||
using NotifyCallback = std::function<void(wpi::StringRef, const HAL_Value*)>;
|
||||
typedef void (*CancelCallbackFunc)(int32_t index, int32_t uid);
|
||||
typedef void (*CancelCallbackNoIndexFunc)(int32_t uid);
|
||||
typedef void (*CancelCallbackChannelFunc)(int32_t index, int32_t channel,
|
||||
int32_t uid);
|
||||
|
||||
void CallbackStoreThunk(const char* name, void* param, const HAL_Value* value);
|
||||
|
||||
class CallbackStore {
|
||||
public:
|
||||
CallbackStore(int32_t i, NotifyCallback cb, CancelCallbackNoIndexFunc ccf) {
|
||||
index = i;
|
||||
callback = cb;
|
||||
this->ccnif = ccf;
|
||||
cancelType = NoIndex;
|
||||
}
|
||||
|
||||
CallbackStore(int32_t i, int32_t u, NotifyCallback cb,
|
||||
CancelCallbackFunc ccf) {
|
||||
index = i;
|
||||
uid = u;
|
||||
callback = cb;
|
||||
this->ccf = ccf;
|
||||
cancelType = Normal;
|
||||
}
|
||||
|
||||
CallbackStore(int32_t i, int32_t c, int32_t u, NotifyCallback cb,
|
||||
CancelCallbackChannelFunc ccf) {
|
||||
index = i;
|
||||
channel = c;
|
||||
uid = u;
|
||||
callback = cb;
|
||||
this->cccf = ccf;
|
||||
cancelType = Channel;
|
||||
}
|
||||
|
||||
~CallbackStore() {
|
||||
switch (cancelType) {
|
||||
case Normal:
|
||||
ccf(index, uid);
|
||||
break;
|
||||
case Channel:
|
||||
cccf(index, channel, uid);
|
||||
break;
|
||||
case NoIndex:
|
||||
ccnif(uid);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void SetUid(int32_t uid) { this->uid = uid; }
|
||||
|
||||
friend void CallbackStoreThunk(const char* name, void* param,
|
||||
const HAL_Value* value);
|
||||
|
||||
private:
|
||||
int32_t index;
|
||||
int32_t channel;
|
||||
int32_t uid;
|
||||
|
||||
NotifyCallback callback;
|
||||
union {
|
||||
CancelCallbackFunc ccf;
|
||||
CancelCallbackChannelFunc cccf;
|
||||
CancelCallbackNoIndexFunc ccnif;
|
||||
};
|
||||
enum CancelType { Normal, Channel, NoIndex };
|
||||
CancelType cancelType;
|
||||
};
|
||||
} // namespace sim
|
||||
} // namespace frc
|
||||
100
wpilibc/src/main/native/include/frc/simulation/DIOSim.h
Normal file
100
wpilibc/src/main/native/include/frc/simulation/DIOSim.h
Normal file
@@ -0,0 +1,100 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* 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/DIOData.h>
|
||||
|
||||
#include "CallbackStore.h"
|
||||
|
||||
namespace frc {
|
||||
namespace sim {
|
||||
class DIOSim {
|
||||
public:
|
||||
explicit DIOSim(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_CancelDIOInitializedCallback);
|
||||
store->SetUid(HALSIM_RegisterDIOInitializedCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
bool GetInitialized() const { return HALSIM_GetDIOInitialized(m_index); }
|
||||
|
||||
void SetInitialized(bool initialized) {
|
||||
HALSIM_SetDIOInitialized(m_index, initialized);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterValueCallback(NotifyCallback callback,
|
||||
bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelDIOValueCallback);
|
||||
store->SetUid(HALSIM_RegisterDIOValueCallback(m_index, &CallbackStoreThunk,
|
||||
store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
bool GetValue() const { return HALSIM_GetDIOValue(m_index); }
|
||||
|
||||
void SetValue(bool value) { HALSIM_SetDIOValue(m_index, value); }
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterPulseLengthCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelDIOPulseLengthCallback);
|
||||
store->SetUid(HALSIM_RegisterDIOPulseLengthCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
double GetPulseLength() const { return HALSIM_GetDIOPulseLength(m_index); }
|
||||
|
||||
void SetPulseLength(double pulseLength) {
|
||||
HALSIM_SetDIOPulseLength(m_index, pulseLength);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterIsInputCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelDIOIsInputCallback);
|
||||
store->SetUid(HALSIM_RegisterDIOIsInputCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
bool GetIsInput() const { return HALSIM_GetDIOIsInput(m_index); }
|
||||
|
||||
void SetIsInput(bool isInput) { HALSIM_SetDIOIsInput(m_index, isInput); }
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterFilterIndexCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelDIOFilterIndexCallback);
|
||||
store->SetUid(HALSIM_RegisterDIOFilterIndexCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
int GetFilterIndex() const { return HALSIM_GetDIOFilterIndex(m_index); }
|
||||
|
||||
void SetFilterIndex(int filterIndex) {
|
||||
HALSIM_SetDIOFilterIndex(m_index, filterIndex);
|
||||
}
|
||||
|
||||
void ResetData() { HALSIM_ResetDIOData(m_index); }
|
||||
|
||||
private:
|
||||
int m_index;
|
||||
};
|
||||
} // namespace sim
|
||||
} // namespace frc
|
||||
@@ -0,0 +1,74 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* 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/DigitalPWMData.h>
|
||||
|
||||
#include "CallbackStore.h"
|
||||
|
||||
namespace frc {
|
||||
namespace sim {
|
||||
class DigitalPWMSim {
|
||||
public:
|
||||
explicit DigitalPWMSim(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_CancelDigitalPWMInitializedCallback);
|
||||
store->SetUid(HALSIM_RegisterDigitalPWMInitializedCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
bool GetInitialized() const {
|
||||
return HALSIM_GetDigitalPWMInitialized(m_index);
|
||||
}
|
||||
|
||||
void SetInitialized(bool initialized) {
|
||||
HALSIM_SetDigitalPWMInitialized(m_index, initialized);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterDutyCycleCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelDigitalPWMDutyCycleCallback);
|
||||
store->SetUid(HALSIM_RegisterDigitalPWMDutyCycleCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
double GetDutyCycle() const { return HALSIM_GetDigitalPWMDutyCycle(m_index); }
|
||||
|
||||
void SetDutyCycle(double dutyCycle) {
|
||||
HALSIM_SetDigitalPWMDutyCycle(m_index, dutyCycle);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterPinCallback(NotifyCallback callback,
|
||||
bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelDigitalPWMPinCallback);
|
||||
store->SetUid(HALSIM_RegisterDigitalPWMPinCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
int GetPin() const { return HALSIM_GetDigitalPWMPin(m_index); }
|
||||
|
||||
void SetPin(int pin) { HALSIM_SetDigitalPWMPin(m_index, pin); }
|
||||
|
||||
void ResetData() { HALSIM_ResetDigitalPWMData(m_index); }
|
||||
|
||||
private:
|
||||
int m_index;
|
||||
};
|
||||
} // namespace sim
|
||||
} // namespace frc
|
||||
@@ -0,0 +1,110 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* 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/DriverStationData.h>
|
||||
|
||||
#include "CallbackStore.h"
|
||||
|
||||
namespace frc {
|
||||
namespace sim {
|
||||
class DriverStationSim {
|
||||
public:
|
||||
std::unique_ptr<CallbackStore> RegisterEnabledCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
-1, callback, &HALSIM_CancelDriverStationEnabledCallback);
|
||||
store->SetUid(HALSIM_RegisterDriverStationEnabledCallback(
|
||||
&CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
bool GetEnabled() const { return HALSIM_GetDriverStationEnabled(); }
|
||||
|
||||
void SetEnabled(bool enabled) { HALSIM_SetDriverStationEnabled(enabled); }
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterAutonomousCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
-1, callback, &HALSIM_CancelDriverStationAutonomousCallback);
|
||||
store->SetUid(HALSIM_RegisterDriverStationAutonomousCallback(
|
||||
&CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
bool GetAutonomous() const { return HALSIM_GetDriverStationAutonomous(); }
|
||||
|
||||
void SetAutonomous(bool autonomous) {
|
||||
HALSIM_SetDriverStationAutonomous(autonomous);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterTestCallback(NotifyCallback callback,
|
||||
bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
-1, callback, &HALSIM_CancelDriverStationTestCallback);
|
||||
store->SetUid(HALSIM_RegisterDriverStationTestCallback(
|
||||
&CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
bool GetTest() const { return HALSIM_GetDriverStationTest(); }
|
||||
|
||||
void SetTest(bool test) { HALSIM_SetDriverStationTest(test); }
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterEStopCallback(NotifyCallback callback,
|
||||
bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
-1, callback, &HALSIM_CancelDriverStationEStopCallback);
|
||||
store->SetUid(HALSIM_RegisterDriverStationEStopCallback(
|
||||
&CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
bool GetEStop() const { return HALSIM_GetDriverStationEStop(); }
|
||||
|
||||
void SetEStop(bool eStop) { HALSIM_SetDriverStationEStop(eStop); }
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterFmsAttachedCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
-1, callback, &HALSIM_CancelDriverStationFmsAttachedCallback);
|
||||
store->SetUid(HALSIM_RegisterDriverStationFmsAttachedCallback(
|
||||
&CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
bool GetFmsAttached() const { return HALSIM_GetDriverStationFmsAttached(); }
|
||||
|
||||
void SetFmsAttached(bool fmsAttached) {
|
||||
HALSIM_SetDriverStationFmsAttached(fmsAttached);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterDsAttachedCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
-1, callback, &HALSIM_CancelDriverStationDsAttachedCallback);
|
||||
store->SetUid(HALSIM_RegisterDriverStationDsAttachedCallback(
|
||||
&CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
bool GetDsAttached() const { return HALSIM_GetDriverStationDsAttached(); }
|
||||
|
||||
void SetDsAttached(bool dsAttached) {
|
||||
HALSIM_SetDriverStationDsAttached(dsAttached);
|
||||
}
|
||||
|
||||
void NotifyNewData() { HALSIM_NotifyDriverStationNewData(); }
|
||||
|
||||
void ResetData() { HALSIM_ResetDriverStationData(); }
|
||||
};
|
||||
} // namespace sim
|
||||
} // namespace frc
|
||||
@@ -0,0 +1,72 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2019-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/DutyCycleData.h>
|
||||
|
||||
#include "CallbackStore.h"
|
||||
|
||||
namespace frc {
|
||||
namespace sim {
|
||||
class DutyCycleSim {
|
||||
public:
|
||||
explicit DutyCycleSim(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_CancelDutyCycleInitializedCallback);
|
||||
store->SetUid(HALSIM_RegisterDutyCycleInitializedCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
bool GetInitialized() const {
|
||||
return HALSIM_GetDutyCycleInitialized(m_index);
|
||||
}
|
||||
|
||||
void SetInitialized(bool initialized) {
|
||||
HALSIM_SetDutyCycleInitialized(m_index, initialized);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterFrequencyCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelDutyCycleFrequencyCallback);
|
||||
store->SetUid(HALSIM_RegisterDutyCycleFrequencyCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
int GetFrequency() const { return HALSIM_GetDutyCycleFrequency(m_index); }
|
||||
|
||||
void SetFrequency(int count) { HALSIM_SetDutyCycleFrequency(m_index, count); }
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterOutputCallback(NotifyCallback callback,
|
||||
bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelDutyCycleOutputCallback);
|
||||
store->SetUid(HALSIM_RegisterDutyCycleOutputCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
double GetOutput() const { return HALSIM_GetDutyCycleOutput(m_index); }
|
||||
|
||||
void SetOutput(double period) { HALSIM_SetDutyCycleOutput(m_index, period); }
|
||||
|
||||
void ResetData() { HALSIM_ResetDutyCycleData(m_index); }
|
||||
|
||||
private:
|
||||
int m_index;
|
||||
};
|
||||
} // namespace sim
|
||||
} // namespace frc
|
||||
174
wpilibc/src/main/native/include/frc/simulation/EncoderSim.h
Normal file
174
wpilibc/src/main/native/include/frc/simulation/EncoderSim.h
Normal file
@@ -0,0 +1,174 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* 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/EncoderData.h>
|
||||
|
||||
#include "CallbackStore.h"
|
||||
|
||||
namespace frc {
|
||||
namespace sim {
|
||||
class EncoderSim {
|
||||
public:
|
||||
explicit EncoderSim(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_CancelEncoderInitializedCallback);
|
||||
store->SetUid(HALSIM_RegisterEncoderInitializedCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
bool GetInitialized() const { return HALSIM_GetEncoderInitialized(m_index); }
|
||||
|
||||
void SetInitialized(bool initialized) {
|
||||
HALSIM_SetEncoderInitialized(m_index, initialized);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterCountCallback(NotifyCallback callback,
|
||||
bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelEncoderCountCallback);
|
||||
store->SetUid(HALSIM_RegisterEncoderCountCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
int GetCount() const { return HALSIM_GetEncoderCount(m_index); }
|
||||
|
||||
void SetCount(int count) { HALSIM_SetEncoderCount(m_index, count); }
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterPeriodCallback(NotifyCallback callback,
|
||||
bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelEncoderPeriodCallback);
|
||||
store->SetUid(HALSIM_RegisterEncoderPeriodCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
double GetPeriod() const { return HALSIM_GetEncoderPeriod(m_index); }
|
||||
|
||||
void SetPeriod(double period) { HALSIM_SetEncoderPeriod(m_index, period); }
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterResetCallback(NotifyCallback callback,
|
||||
bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelEncoderResetCallback);
|
||||
store->SetUid(HALSIM_RegisterEncoderResetCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
bool GetReset() const { return HALSIM_GetEncoderReset(m_index); }
|
||||
|
||||
void SetReset(bool reset) { HALSIM_SetEncoderReset(m_index, reset); }
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterMaxPeriodCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelEncoderMaxPeriodCallback);
|
||||
store->SetUid(HALSIM_RegisterEncoderMaxPeriodCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
double GetMaxPeriod() const { return HALSIM_GetEncoderMaxPeriod(m_index); }
|
||||
|
||||
void SetMaxPeriod(double maxPeriod) {
|
||||
HALSIM_SetEncoderMaxPeriod(m_index, maxPeriod);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterDirectionCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelEncoderDirectionCallback);
|
||||
store->SetUid(HALSIM_RegisterEncoderDirectionCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
bool GetDirection() const { return HALSIM_GetEncoderDirection(m_index); }
|
||||
|
||||
void SetDirection(bool direction) {
|
||||
HALSIM_SetEncoderDirection(m_index, direction);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterReverseDirectionCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelEncoderReverseDirectionCallback);
|
||||
store->SetUid(HALSIM_RegisterEncoderReverseDirectionCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
bool GetReverseDirection() const {
|
||||
return HALSIM_GetEncoderReverseDirection(m_index);
|
||||
}
|
||||
|
||||
void SetReverseDirection(bool reverseDirection) {
|
||||
HALSIM_SetEncoderReverseDirection(m_index, reverseDirection);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterSamplesToAverageCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelEncoderSamplesToAverageCallback);
|
||||
store->SetUid(HALSIM_RegisterEncoderSamplesToAverageCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
int GetSamplesToAverage() const {
|
||||
return HALSIM_GetEncoderSamplesToAverage(m_index);
|
||||
}
|
||||
|
||||
void SetSamplesToAverage(int samplesToAverage) {
|
||||
HALSIM_SetEncoderSamplesToAverage(m_index, samplesToAverage);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterDistancePerPulseCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelEncoderDistancePerPulseCallback);
|
||||
store->SetUid(HALSIM_RegisterEncoderDistancePerPulseCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
double GetDistancePerPulse() const {
|
||||
return HALSIM_GetEncoderDistancePerPulse(m_index);
|
||||
}
|
||||
|
||||
void SetDistancePerPulse(double distancePerPulse) {
|
||||
HALSIM_SetEncoderDistancePerPulse(m_index, distancePerPulse);
|
||||
}
|
||||
|
||||
void ResetData() { HALSIM_ResetEncoderData(m_index); }
|
||||
|
||||
void SetDistance(double distance) {
|
||||
HALSIM_SetEncoderDistance(m_index, distance);
|
||||
}
|
||||
|
||||
double GetDistance() { return HALSIM_GetEncoderDistance(m_index); }
|
||||
|
||||
void SetRate(double rate) { HALSIM_SetEncoderRate(m_index, rate); }
|
||||
|
||||
double GetRate() { return HALSIM_GetEncoderRate(m_index); }
|
||||
|
||||
private:
|
||||
int m_index;
|
||||
};
|
||||
} // namespace sim
|
||||
} // namespace frc
|
||||
158
wpilibc/src/main/native/include/frc/simulation/PCMSim.h
Normal file
158
wpilibc/src/main/native/include/frc/simulation/PCMSim.h
Normal file
@@ -0,0 +1,158 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* 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/PCMData.h>
|
||||
|
||||
#include "CallbackStore.h"
|
||||
|
||||
namespace frc {
|
||||
namespace sim {
|
||||
class PCMSim {
|
||||
public:
|
||||
explicit PCMSim(int index) { m_index = index; }
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterSolenoidInitializedCallback(
|
||||
int channel, NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, channel, -1, callback,
|
||||
&HALSIM_CancelPCMSolenoidInitializedCallback);
|
||||
store->SetUid(HALSIM_RegisterPCMSolenoidInitializedCallback(
|
||||
m_index, channel, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
bool GetSolenoidInitialized(int channel) const {
|
||||
return HALSIM_GetPCMSolenoidInitialized(m_index, channel);
|
||||
}
|
||||
|
||||
void SetSolenoidInitialized(int channel, bool solenoidInitialized) {
|
||||
HALSIM_SetPCMSolenoidInitialized(m_index, channel, solenoidInitialized);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterSolenoidOutputCallback(
|
||||
int channel, NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, channel, -1, callback,
|
||||
&HALSIM_CancelPCMSolenoidOutputCallback);
|
||||
store->SetUid(HALSIM_RegisterPCMSolenoidOutputCallback(
|
||||
m_index, channel, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
bool GetSolenoidOutput(int channel) const {
|
||||
return HALSIM_GetPCMSolenoidOutput(m_index, channel);
|
||||
}
|
||||
|
||||
void SetSolenoidOutput(int channel, bool solenoidOutput) {
|
||||
HALSIM_SetPCMSolenoidOutput(m_index, channel, solenoidOutput);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterCompressorInitializedCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelPCMCompressorInitializedCallback);
|
||||
store->SetUid(HALSIM_RegisterPCMCompressorInitializedCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
bool GetCompressorInitialized() const {
|
||||
return HALSIM_GetPCMCompressorInitialized(m_index);
|
||||
}
|
||||
|
||||
void SetCompressorInitialized(bool compressorInitialized) {
|
||||
HALSIM_SetPCMCompressorInitialized(m_index, compressorInitialized);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterCompressorOnCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelPCMCompressorOnCallback);
|
||||
store->SetUid(HALSIM_RegisterPCMCompressorOnCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
bool GetCompressorOn() const { return HALSIM_GetPCMCompressorOn(m_index); }
|
||||
|
||||
void SetCompressorOn(bool compressorOn) {
|
||||
HALSIM_SetPCMCompressorOn(m_index, compressorOn);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterClosedLoopEnabledCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelPCMClosedLoopEnabledCallback);
|
||||
store->SetUid(HALSIM_RegisterPCMClosedLoopEnabledCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
bool GetClosedLoopEnabled() const {
|
||||
return HALSIM_GetPCMClosedLoopEnabled(m_index);
|
||||
}
|
||||
|
||||
void SetClosedLoopEnabled(bool closedLoopEnabled) {
|
||||
HALSIM_SetPCMClosedLoopEnabled(m_index, closedLoopEnabled);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterPressureSwitchCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelPCMPressureSwitchCallback);
|
||||
store->SetUid(HALSIM_RegisterPCMPressureSwitchCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
bool GetPressureSwitch() const {
|
||||
return HALSIM_GetPCMPressureSwitch(m_index);
|
||||
}
|
||||
|
||||
void SetPressureSwitch(bool pressureSwitch) {
|
||||
HALSIM_SetPCMPressureSwitch(m_index, pressureSwitch);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterCompressorCurrentCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelPCMCompressorCurrentCallback);
|
||||
store->SetUid(HALSIM_RegisterPCMCompressorCurrentCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
double GetCompressorCurrent() const {
|
||||
return HALSIM_GetPCMCompressorCurrent(m_index);
|
||||
}
|
||||
|
||||
void SetCompressorCurrent(double compressorCurrent) {
|
||||
HALSIM_SetPCMCompressorCurrent(m_index, compressorCurrent);
|
||||
}
|
||||
|
||||
uint8_t GetAllSolenoidOutputs() {
|
||||
uint8_t ret = 0;
|
||||
HALSIM_GetPCMAllSolenoids(m_index, &ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void SetAllSolenoidOutputs(uint8_t outputs) {
|
||||
HALSIM_SetPCMAllSolenoids(m_index, outputs);
|
||||
}
|
||||
|
||||
void ResetData() { HALSIM_ResetPCMData(m_index); }
|
||||
|
||||
private:
|
||||
int m_index;
|
||||
};
|
||||
} // namespace sim
|
||||
} // namespace frc
|
||||
97
wpilibc/src/main/native/include/frc/simulation/PDPSim.h
Normal file
97
wpilibc/src/main/native/include/frc/simulation/PDPSim.h
Normal file
@@ -0,0 +1,97 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* 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/PDPData.h>
|
||||
|
||||
#include "CallbackStore.h"
|
||||
|
||||
namespace frc {
|
||||
namespace sim {
|
||||
class PDPSim {
|
||||
public:
|
||||
explicit PDPSim(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_CancelPDPInitializedCallback);
|
||||
store->SetUid(HALSIM_RegisterPDPInitializedCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
bool GetInitialized() const { return HALSIM_GetPDPInitialized(m_index); }
|
||||
|
||||
void SetInitialized(bool initialized) {
|
||||
HALSIM_SetPDPInitialized(m_index, initialized);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterTemperatureCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelPDPTemperatureCallback);
|
||||
store->SetUid(HALSIM_RegisterPDPTemperatureCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
double GetTemperature() const { return HALSIM_GetPDPTemperature(m_index); }
|
||||
|
||||
void SetTemperature(double temperature) {
|
||||
HALSIM_SetPDPTemperature(m_index, temperature);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterVoltageCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelPDPVoltageCallback);
|
||||
store->SetUid(HALSIM_RegisterPDPVoltageCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
double GetVoltage() const { return HALSIM_GetPDPVoltage(m_index); }
|
||||
|
||||
void SetVoltage(double voltage) { HALSIM_SetPDPVoltage(m_index, voltage); }
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterCurrentCallback(
|
||||
int channel, NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, channel, -1, callback, &HALSIM_CancelPDPCurrentCallback);
|
||||
store->SetUid(HALSIM_RegisterPDPCurrentCallback(
|
||||
m_index, channel, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
double GetCurrent(int channel) const {
|
||||
return HALSIM_GetPDPCurrent(m_index, channel);
|
||||
}
|
||||
|
||||
void SetCurrent(int channel, double current) {
|
||||
HALSIM_SetPDPCurrent(m_index, channel, current);
|
||||
}
|
||||
|
||||
void GetAllCurrents(double* currents) {
|
||||
HALSIM_GetPDPAllCurrents(m_index, currents);
|
||||
}
|
||||
|
||||
void SetAllCurrents(const double* currents) {
|
||||
HALSIM_SetPDPAllCurrents(m_index, currents);
|
||||
}
|
||||
|
||||
void ResetData() { HALSIM_ResetPDPData(m_index); }
|
||||
|
||||
private:
|
||||
int m_index;
|
||||
};
|
||||
} // namespace sim
|
||||
} // namespace frc
|
||||
115
wpilibc/src/main/native/include/frc/simulation/PWMSim.h
Normal file
115
wpilibc/src/main/native/include/frc/simulation/PWMSim.h
Normal file
@@ -0,0 +1,115 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* 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/PWMData.h>
|
||||
|
||||
#include "CallbackStore.h"
|
||||
|
||||
namespace frc {
|
||||
namespace sim {
|
||||
class PWMSim {
|
||||
public:
|
||||
explicit PWMSim(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_CancelPWMInitializedCallback);
|
||||
store->SetUid(HALSIM_RegisterPWMInitializedCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
bool GetInitialized() const { return HALSIM_GetPWMInitialized(m_index); }
|
||||
|
||||
void SetInitialized(bool initialized) {
|
||||
HALSIM_SetPWMInitialized(m_index, initialized);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterRawValueCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelPWMRawValueCallback);
|
||||
store->SetUid(HALSIM_RegisterPWMRawValueCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
int GetRawValue() const { return HALSIM_GetPWMRawValue(m_index); }
|
||||
|
||||
void SetRawValue(int rawValue) { HALSIM_SetPWMRawValue(m_index, rawValue); }
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterSpeedCallback(NotifyCallback callback,
|
||||
bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelPWMSpeedCallback);
|
||||
store->SetUid(HALSIM_RegisterPWMSpeedCallback(m_index, &CallbackStoreThunk,
|
||||
store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
double GetSpeed() const { return HALSIM_GetPWMSpeed(m_index); }
|
||||
|
||||
void SetSpeed(double speed) { HALSIM_SetPWMSpeed(m_index, speed); }
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterPositionCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelPWMPositionCallback);
|
||||
store->SetUid(HALSIM_RegisterPWMPositionCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
double GetPosition() const { return HALSIM_GetPWMPosition(m_index); }
|
||||
|
||||
void SetPosition(double position) {
|
||||
HALSIM_SetPWMPosition(m_index, position);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterPeriodScaleCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelPWMPeriodScaleCallback);
|
||||
store->SetUid(HALSIM_RegisterPWMPeriodScaleCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
int GetPeriodScale() const { return HALSIM_GetPWMPeriodScale(m_index); }
|
||||
|
||||
void SetPeriodScale(int periodScale) {
|
||||
HALSIM_SetPWMPeriodScale(m_index, periodScale);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterZeroLatchCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelPWMZeroLatchCallback);
|
||||
store->SetUid(HALSIM_RegisterPWMZeroLatchCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
bool GetZeroLatch() const { return HALSIM_GetPWMZeroLatch(m_index); }
|
||||
|
||||
void SetZeroLatch(bool zeroLatch) {
|
||||
HALSIM_SetPWMZeroLatch(m_index, zeroLatch);
|
||||
}
|
||||
|
||||
void ResetData() { HALSIM_ResetPWMData(m_index); }
|
||||
|
||||
private:
|
||||
int m_index;
|
||||
};
|
||||
} // namespace sim
|
||||
} // namespace frc
|
||||
89
wpilibc/src/main/native/include/frc/simulation/RelaySim.h
Normal file
89
wpilibc/src/main/native/include/frc/simulation/RelaySim.h
Normal file
@@ -0,0 +1,89 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* 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/RelayData.h>
|
||||
|
||||
#include "CallbackStore.h"
|
||||
|
||||
namespace frc {
|
||||
namespace sim {
|
||||
class RelaySim {
|
||||
public:
|
||||
explicit RelaySim(int index) { m_index = index; }
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterInitializedForwardCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelRelayInitializedForwardCallback);
|
||||
store->SetUid(HALSIM_RegisterRelayInitializedForwardCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
bool GetInitializedForward() const {
|
||||
return HALSIM_GetRelayInitializedForward(m_index);
|
||||
}
|
||||
|
||||
void SetInitializedForward(bool initializedForward) {
|
||||
HALSIM_SetRelayInitializedForward(m_index, initializedForward);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterInitializedReverseCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelRelayInitializedReverseCallback);
|
||||
store->SetUid(HALSIM_RegisterRelayInitializedReverseCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
bool GetInitializedReverse() const {
|
||||
return HALSIM_GetRelayInitializedReverse(m_index);
|
||||
}
|
||||
|
||||
void SetInitializedReverse(bool initializedReverse) {
|
||||
HALSIM_SetRelayInitializedReverse(m_index, initializedReverse);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterForwardCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelRelayForwardCallback);
|
||||
store->SetUid(HALSIM_RegisterRelayForwardCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
bool GetForward() const { return HALSIM_GetRelayForward(m_index); }
|
||||
|
||||
void SetForward(bool forward) { HALSIM_SetRelayForward(m_index, forward); }
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterReverseCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelRelayReverseCallback);
|
||||
store->SetUid(HALSIM_RegisterRelayReverseCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
bool GetReverse() const { return HALSIM_GetRelayReverse(m_index); }
|
||||
|
||||
void SetReverse(bool reverse) { HALSIM_SetRelayReverse(m_index, reverse); }
|
||||
|
||||
void ResetData() { HALSIM_ResetRelayData(m_index); }
|
||||
|
||||
private:
|
||||
int m_index;
|
||||
};
|
||||
} // namespace sim
|
||||
} // namespace frc
|
||||
274
wpilibc/src/main/native/include/frc/simulation/RoboRioSim.h
Normal file
274
wpilibc/src/main/native/include/frc/simulation/RoboRioSim.h
Normal file
@@ -0,0 +1,274 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* 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/RoboRioData.h>
|
||||
|
||||
#include "CallbackStore.h"
|
||||
|
||||
namespace frc {
|
||||
namespace sim {
|
||||
class RoboRioSim {
|
||||
public:
|
||||
explicit RoboRioSim(int index) { m_index = index; }
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterFPGAButtonCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelRoboRioFPGAButtonCallback);
|
||||
store->SetUid(HALSIM_RegisterRoboRioFPGAButtonCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
bool GetFPGAButton() const { return HALSIM_GetRoboRioFPGAButton(m_index); }
|
||||
|
||||
void SetFPGAButton(bool fPGAButton) {
|
||||
HALSIM_SetRoboRioFPGAButton(m_index, fPGAButton);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterVInVoltageCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelRoboRioVInVoltageCallback);
|
||||
store->SetUid(HALSIM_RegisterRoboRioVInVoltageCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
double GetVInVoltage() const { return HALSIM_GetRoboRioVInVoltage(m_index); }
|
||||
|
||||
void SetVInVoltage(double vInVoltage) {
|
||||
HALSIM_SetRoboRioVInVoltage(m_index, vInVoltage);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterVInCurrentCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelRoboRioVInCurrentCallback);
|
||||
store->SetUid(HALSIM_RegisterRoboRioVInCurrentCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
double GetVInCurrent() const { return HALSIM_GetRoboRioVInCurrent(m_index); }
|
||||
|
||||
void SetVInCurrent(double vInCurrent) {
|
||||
HALSIM_SetRoboRioVInCurrent(m_index, vInCurrent);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterUserVoltage6VCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelRoboRioUserVoltage6VCallback);
|
||||
store->SetUid(HALSIM_RegisterRoboRioUserVoltage6VCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
double GetUserVoltage6V() const {
|
||||
return HALSIM_GetRoboRioUserVoltage6V(m_index);
|
||||
}
|
||||
|
||||
void SetUserVoltage6V(double userVoltage6V) {
|
||||
HALSIM_SetRoboRioUserVoltage6V(m_index, userVoltage6V);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterUserCurrent6VCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelRoboRioUserCurrent6VCallback);
|
||||
store->SetUid(HALSIM_RegisterRoboRioUserCurrent6VCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
double GetUserCurrent6V() const {
|
||||
return HALSIM_GetRoboRioUserCurrent6V(m_index);
|
||||
}
|
||||
|
||||
void SetUserCurrent6V(double userCurrent6V) {
|
||||
HALSIM_SetRoboRioUserCurrent6V(m_index, userCurrent6V);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterUserActive6VCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelRoboRioUserActive6VCallback);
|
||||
store->SetUid(HALSIM_RegisterRoboRioUserActive6VCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
bool GetUserActive6V() const {
|
||||
return HALSIM_GetRoboRioUserActive6V(m_index);
|
||||
}
|
||||
|
||||
void SetUserActive6V(bool userActive6V) {
|
||||
HALSIM_SetRoboRioUserActive6V(m_index, userActive6V);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterUserVoltage5VCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelRoboRioUserVoltage5VCallback);
|
||||
store->SetUid(HALSIM_RegisterRoboRioUserVoltage5VCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
double GetUserVoltage5V() const {
|
||||
return HALSIM_GetRoboRioUserVoltage5V(m_index);
|
||||
}
|
||||
|
||||
void SetUserVoltage5V(double userVoltage5V) {
|
||||
HALSIM_SetRoboRioUserVoltage5V(m_index, userVoltage5V);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterUserCurrent5VCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelRoboRioUserCurrent5VCallback);
|
||||
store->SetUid(HALSIM_RegisterRoboRioUserCurrent5VCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
double GetUserCurrent5V() const {
|
||||
return HALSIM_GetRoboRioUserCurrent5V(m_index);
|
||||
}
|
||||
|
||||
void SetUserCurrent5V(double userCurrent5V) {
|
||||
HALSIM_SetRoboRioUserCurrent5V(m_index, userCurrent5V);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterUserActive5VCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelRoboRioUserActive5VCallback);
|
||||
store->SetUid(HALSIM_RegisterRoboRioUserActive5VCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
bool GetUserActive5V() const {
|
||||
return HALSIM_GetRoboRioUserActive5V(m_index);
|
||||
}
|
||||
|
||||
void SetUserActive5V(bool userActive5V) {
|
||||
HALSIM_SetRoboRioUserActive5V(m_index, userActive5V);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterUserVoltage3V3Callback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelRoboRioUserVoltage3V3Callback);
|
||||
store->SetUid(HALSIM_RegisterRoboRioUserVoltage3V3Callback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
double GetUserVoltage3V3() const {
|
||||
return HALSIM_GetRoboRioUserVoltage3V3(m_index);
|
||||
}
|
||||
|
||||
void SetUserVoltage3V3(double userVoltage3V3) {
|
||||
HALSIM_SetRoboRioUserVoltage3V3(m_index, userVoltage3V3);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterUserCurrent3V3Callback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelRoboRioUserCurrent3V3Callback);
|
||||
store->SetUid(HALSIM_RegisterRoboRioUserCurrent3V3Callback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
double GetUserCurrent3V3() const {
|
||||
return HALSIM_GetRoboRioUserCurrent3V3(m_index);
|
||||
}
|
||||
|
||||
void SetUserCurrent3V3(double userCurrent3V3) {
|
||||
HALSIM_SetRoboRioUserCurrent3V3(m_index, userCurrent3V3);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterUserActive3V3Callback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelRoboRioUserActive3V3Callback);
|
||||
store->SetUid(HALSIM_RegisterRoboRioUserActive3V3Callback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
bool GetUserActive3V3() const {
|
||||
return HALSIM_GetRoboRioUserActive3V3(m_index);
|
||||
}
|
||||
|
||||
void SetUserActive3V3(bool userActive3V3) {
|
||||
HALSIM_SetRoboRioUserActive3V3(m_index, userActive3V3);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterUserFaults6VCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelRoboRioUserFaults6VCallback);
|
||||
store->SetUid(HALSIM_RegisterRoboRioUserFaults6VCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
int GetUserFaults6V() const { return HALSIM_GetRoboRioUserFaults6V(m_index); }
|
||||
|
||||
void SetUserFaults6V(int userFaults6V) {
|
||||
HALSIM_SetRoboRioUserFaults6V(m_index, userFaults6V);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterUserFaults5VCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelRoboRioUserFaults5VCallback);
|
||||
store->SetUid(HALSIM_RegisterRoboRioUserFaults5VCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
int GetUserFaults5V() const { return HALSIM_GetRoboRioUserFaults5V(m_index); }
|
||||
|
||||
void SetUserFaults5V(int userFaults5V) {
|
||||
HALSIM_SetRoboRioUserFaults5V(m_index, userFaults5V);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterUserFaults3V3Callback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelRoboRioUserFaults3V3Callback);
|
||||
store->SetUid(HALSIM_RegisterRoboRioUserFaults3V3Callback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
int GetUserFaults3V3() const {
|
||||
return HALSIM_GetRoboRioUserFaults3V3(m_index);
|
||||
}
|
||||
|
||||
void SetUserFaults3V3(int userFaults3V3) {
|
||||
HALSIM_SetRoboRioUserFaults3V3(m_index, userFaults3V3);
|
||||
}
|
||||
|
||||
void ResetData() { HALSIM_ResetRoboRioData(m_index); }
|
||||
|
||||
private:
|
||||
int m_index;
|
||||
};
|
||||
} // namespace sim
|
||||
} // namespace frc
|
||||
@@ -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
|
||||
@@ -0,0 +1,80 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2019-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 <functional>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <hal/SimDevice.h>
|
||||
#include <hal/simulation/SimDeviceData.h>
|
||||
|
||||
#include "CallbackStore.h"
|
||||
|
||||
namespace frc {
|
||||
namespace sim {
|
||||
class SimDeviceSim {
|
||||
public:
|
||||
explicit SimDeviceSim(const char* name)
|
||||
: m_handle{HALSIM_GetSimDeviceHandle(name)} {}
|
||||
|
||||
hal::SimValue GetValue(const char* name) const {
|
||||
return HALSIM_GetSimValueHandle(m_handle, name);
|
||||
}
|
||||
|
||||
hal::SimDouble GetDouble(const char* name) const {
|
||||
return HALSIM_GetSimValueHandle(m_handle, name);
|
||||
}
|
||||
|
||||
hal::SimEnum GetEnum(const char* name) const {
|
||||
return HALSIM_GetSimValueHandle(m_handle, name);
|
||||
}
|
||||
|
||||
hal::SimBoolean GetBoolean(const char* name) const {
|
||||
return HALSIM_GetSimValueHandle(m_handle, name);
|
||||
}
|
||||
|
||||
static std::vector<std::string> GetEnumOptions(hal::SimEnum val) {
|
||||
int32_t numOptions;
|
||||
const char** options = HALSIM_GetSimValueEnumOptions(val, &numOptions);
|
||||
std::vector<std::string> rv;
|
||||
rv.reserve(numOptions);
|
||||
for (int32_t i = 0; i < numOptions; ++i) rv.emplace_back(options[i]);
|
||||
return rv;
|
||||
}
|
||||
|
||||
template <typename F>
|
||||
void EnumerateValues(F callback) const {
|
||||
return HALSIM_EnumerateSimValues(
|
||||
m_handle, &callback,
|
||||
[](const char* name, void* param, HAL_SimValueHandle handle,
|
||||
HAL_Bool readonly, const struct HAL_Value* value) {
|
||||
std::invoke(*static_cast<F*>(param), name, handle, readonly, value);
|
||||
});
|
||||
}
|
||||
|
||||
operator HAL_SimDeviceHandle() const { return m_handle; }
|
||||
|
||||
template <typename F>
|
||||
static void EnumerateDevices(const char* prefix, F callback) {
|
||||
return HALSIM_EnumerateSimDevices(
|
||||
prefix, &callback,
|
||||
[](const char* name, void* param, HAL_SimDeviceHandle handle) {
|
||||
std::invoke(*static_cast<F*>(param), name, handle);
|
||||
});
|
||||
}
|
||||
|
||||
static void ResetData() { HALSIM_ResetSimDeviceData(); }
|
||||
|
||||
private:
|
||||
HAL_SimDeviceHandle m_handle;
|
||||
};
|
||||
} // namespace sim
|
||||
} // namespace frc
|
||||
34
wpilibc/src/main/native/include/frc/simulation/SimHooks.h
Normal file
34
wpilibc/src/main/native/include/frc/simulation/SimHooks.h
Normal file
@@ -0,0 +1,34 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* 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 <hal/simulation/MockHooks.h>
|
||||
|
||||
namespace frc {
|
||||
namespace sim {
|
||||
|
||||
void SetRuntimeType(HAL_RuntimeType type) { HALSIM_SetRuntimeType(type); }
|
||||
|
||||
void WaitForProgramStart() { HALSIM_WaitForProgramStart(); }
|
||||
|
||||
void SetProgramStarted() { HALSIM_SetProgramStarted(); }
|
||||
|
||||
bool GetProgramStarted() { return HALSIM_GetProgramStarted(); }
|
||||
|
||||
void RestartTiming() { HALSIM_RestartTiming(); }
|
||||
|
||||
void PauseTiming() { HALSIM_PauseTiming(); }
|
||||
|
||||
void ResumeTiming() { HALSIM_ResumeTiming(); }
|
||||
|
||||
bool IsTimingPaused() { return HALSIM_IsTimingPaused(); }
|
||||
|
||||
void StepTiming(uint64_t delta) { HALSIM_StepTiming(delta); }
|
||||
|
||||
} // namespace sim
|
||||
} // namespace frc
|
||||
Reference in New Issue
Block a user