mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-25 01:41:43 +00:00
Adds JNI Simulator interface and updated Sim API (#1002)
The simulator was generated by https://github.com/ThadHouse/SimulatorGenerator
This commit is contained in:
committed by
Peter Johnson
parent
1046371349
commit
337e89cf6e
105
hal/src/main/native/include/Simulation/PWMSim.h
Normal file
105
hal/src/main/native/include/Simulation/PWMSim.h
Normal file
@@ -0,0 +1,105 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2018 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
|
||||
|
||||
#ifndef __FRC_ROBORIO__
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
#include "CallbackStore.h"
|
||||
#include "MockData/PWMData.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 std::move(store);
|
||||
}
|
||||
bool GetInitialized() { 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 std::move(store);
|
||||
}
|
||||
int GetRawValue() { 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 std::move(store);
|
||||
}
|
||||
double GetSpeed() { 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 std::move(store);
|
||||
}
|
||||
double GetPosition() { 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 std::move(store);
|
||||
}
|
||||
int GetPeriodScale() { 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 std::move(store);
|
||||
}
|
||||
bool GetZeroLatch() { 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
|
||||
#endif // __FRC_ROBORIO__
|
||||
Reference in New Issue
Block a user