2018-05-11 12:38:23 -07:00
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
/* 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"
|
2018-07-20 00:03:45 -07:00
|
|
|
#include "mockdata/PCMData.h"
|
2018-05-11 12:38:23 -07:00
|
|
|
|
|
|
|
|
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));
|
2018-05-16 19:45:46 -07:00
|
|
|
return store;
|
2018-05-11 12:38:23 -07:00
|
|
|
}
|
2018-08-16 01:17:59 -04:00
|
|
|
|
|
|
|
|
bool GetSolenoidInitialized(int channel) const {
|
2018-05-11 12:38:23 -07:00
|
|
|
return HALSIM_GetPCMSolenoidInitialized(m_index, channel);
|
|
|
|
|
}
|
2018-08-16 01:17:59 -04:00
|
|
|
|
2018-05-11 12:38:23 -07:00
|
|
|
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));
|
2018-05-16 19:45:46 -07:00
|
|
|
return store;
|
2018-05-11 12:38:23 -07:00
|
|
|
}
|
2018-08-16 01:17:59 -04:00
|
|
|
|
|
|
|
|
bool GetSolenoidOutput(int channel) const {
|
2018-05-11 12:38:23 -07:00
|
|
|
return HALSIM_GetPCMSolenoidOutput(m_index, channel);
|
|
|
|
|
}
|
2018-08-16 01:17:59 -04:00
|
|
|
|
2018-05-11 12:38:23 -07:00
|
|
|
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));
|
2018-05-16 19:45:46 -07:00
|
|
|
return store;
|
2018-05-11 12:38:23 -07:00
|
|
|
}
|
2018-08-16 01:17:59 -04:00
|
|
|
|
|
|
|
|
bool GetCompressorInitialized() const {
|
2018-05-11 12:38:23 -07:00
|
|
|
return HALSIM_GetPCMCompressorInitialized(m_index);
|
|
|
|
|
}
|
2018-08-16 01:17:59 -04:00
|
|
|
|
2018-05-11 12:38:23 -07:00
|
|
|
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));
|
2018-05-16 19:45:46 -07:00
|
|
|
return store;
|
2018-05-11 12:38:23 -07:00
|
|
|
}
|
2018-08-16 01:17:59 -04:00
|
|
|
|
|
|
|
|
bool GetCompressorOn() const { return HALSIM_GetPCMCompressorOn(m_index); }
|
|
|
|
|
|
2018-05-11 12:38:23 -07:00
|
|
|
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));
|
2018-05-16 19:45:46 -07:00
|
|
|
return store;
|
2018-05-11 12:38:23 -07:00
|
|
|
}
|
2018-08-16 01:17:59 -04:00
|
|
|
|
|
|
|
|
bool GetClosedLoopEnabled() const {
|
2018-05-11 12:38:23 -07:00
|
|
|
return HALSIM_GetPCMClosedLoopEnabled(m_index);
|
|
|
|
|
}
|
2018-08-16 01:17:59 -04:00
|
|
|
|
2018-05-11 12:38:23 -07:00
|
|
|
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));
|
2018-05-16 19:45:46 -07:00
|
|
|
return store;
|
2018-05-11 12:38:23 -07:00
|
|
|
}
|
2018-08-16 01:17:59 -04:00
|
|
|
|
|
|
|
|
bool GetPressureSwitch() const {
|
|
|
|
|
return HALSIM_GetPCMPressureSwitch(m_index);
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-11 12:38:23 -07:00
|
|
|
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));
|
2018-05-16 19:45:46 -07:00
|
|
|
return store;
|
2018-05-11 12:38:23 -07:00
|
|
|
}
|
2018-08-16 01:17:59 -04:00
|
|
|
|
|
|
|
|
double GetCompressorCurrent() const {
|
2018-05-11 12:38:23 -07:00
|
|
|
return HALSIM_GetPCMCompressorCurrent(m_index);
|
|
|
|
|
}
|
2018-08-16 01:17:59 -04:00
|
|
|
|
2018-05-11 12:38:23 -07:00
|
|
|
void SetCompressorCurrent(double compressorCurrent) {
|
|
|
|
|
HALSIM_SetPCMCompressorCurrent(m_index, compressorCurrent);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ResetData() { HALSIM_ResetPCMData(m_index); }
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
int m_index;
|
|
|
|
|
};
|
|
|
|
|
} // namespace sim
|
|
|
|
|
} // namespace frc
|
|
|
|
|
#endif // __FRC_ROBORIO__
|