2017-08-18 21:35:53 -07:00
|
|
|
/*----------------------------------------------------------------------------*/
|
2018-01-02 09:20:21 -08:00
|
|
|
/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */
|
2017-08-18 21:35:53 -07:00
|
|
|
/* 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. */
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
#include "../PortsInternal.h"
|
|
|
|
|
#include "PCMDataInternal.h"
|
|
|
|
|
|
|
|
|
|
using namespace hal;
|
|
|
|
|
|
2017-12-10 19:38:53 -08:00
|
|
|
namespace hal {
|
|
|
|
|
namespace init {
|
|
|
|
|
void InitializePCMData() {
|
|
|
|
|
static PCMData spd[kNumPCMModules];
|
|
|
|
|
::hal::SimPCMData = spd;
|
|
|
|
|
}
|
|
|
|
|
} // namespace init
|
|
|
|
|
} // namespace hal
|
|
|
|
|
|
|
|
|
|
PCMData* hal::SimPCMData;
|
2017-08-18 21:35:53 -07:00
|
|
|
void PCMData::ResetData() {
|
|
|
|
|
for (int i = 0; i < kNumSolenoidChannels; i++) {
|
2018-09-03 16:08:07 -07:00
|
|
|
solenoidInitialized[i].Reset(false);
|
|
|
|
|
solenoidOutput[i].Reset(false);
|
2017-08-18 21:35:53 -07:00
|
|
|
}
|
2018-09-03 16:08:07 -07:00
|
|
|
compressorInitialized.Reset(false);
|
|
|
|
|
compressorOn.Reset(false);
|
|
|
|
|
closedLoopEnabled.Reset(true);
|
|
|
|
|
pressureSwitch.Reset(false);
|
|
|
|
|
compressorCurrent.Reset(0.0);
|
2017-08-18 21:35:53 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
|
void HALSIM_ResetPCMData(int32_t index) { SimPCMData[index].ResetData(); }
|
|
|
|
|
|
2018-09-03 16:08:07 -07:00
|
|
|
#define DEFINE_CAPI(TYPE, CAPINAME, LOWERNAME) \
|
|
|
|
|
HAL_SIMDATAVALUE_DEFINE_CAPI(TYPE, HALSIM, PCM##CAPINAME, SimPCMData, \
|
|
|
|
|
LOWERNAME)
|
2017-08-18 21:35:53 -07:00
|
|
|
|
2018-09-03 16:08:07 -07:00
|
|
|
HAL_SIMDATAVALUE_DEFINE_CAPI_CHANNEL(HAL_Bool, HALSIM, PCMSolenoidInitialized,
|
|
|
|
|
SimPCMData, solenoidInitialized)
|
|
|
|
|
HAL_SIMDATAVALUE_DEFINE_CAPI_CHANNEL(HAL_Bool, HALSIM, PCMSolenoidOutput,
|
|
|
|
|
SimPCMData, solenoidOutput)
|
|
|
|
|
DEFINE_CAPI(HAL_Bool, CompressorInitialized, compressorInitialized)
|
|
|
|
|
DEFINE_CAPI(HAL_Bool, CompressorOn, compressorOn)
|
|
|
|
|
DEFINE_CAPI(HAL_Bool, ClosedLoopEnabled, closedLoopEnabled)
|
|
|
|
|
DEFINE_CAPI(HAL_Bool, PressureSwitch, pressureSwitch)
|
|
|
|
|
DEFINE_CAPI(double, CompressorCurrent, compressorCurrent)
|
2017-08-18 21:35:53 -07:00
|
|
|
|
2018-09-03 16:08:07 -07:00
|
|
|
#define REGISTER(NAME) \
|
|
|
|
|
SimPCMData[index].NAME.RegisterCallback(callback, param, initialNotify)
|
2017-10-22 01:45:41 -04:00
|
|
|
|
|
|
|
|
void HALSIM_RegisterPCMAllNonSolenoidCallbacks(int32_t index,
|
|
|
|
|
HAL_NotifyCallback callback,
|
|
|
|
|
void* param,
|
|
|
|
|
HAL_Bool initialNotify) {
|
2018-09-03 16:08:07 -07:00
|
|
|
REGISTER(compressorInitialized);
|
|
|
|
|
REGISTER(compressorOn);
|
|
|
|
|
REGISTER(closedLoopEnabled);
|
|
|
|
|
REGISTER(pressureSwitch);
|
|
|
|
|
REGISTER(compressorCurrent);
|
2017-10-22 01:45:41 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void HALSIM_RegisterPCMAllSolenoidCallbacks(int32_t index, int32_t channel,
|
|
|
|
|
HAL_NotifyCallback callback,
|
|
|
|
|
void* param,
|
|
|
|
|
HAL_Bool initialNotify) {
|
2018-09-03 16:08:07 -07:00
|
|
|
REGISTER(solenoidInitialized[channel]);
|
|
|
|
|
REGISTER(solenoidOutput[channel]);
|
2017-10-22 01:45:41 -04:00
|
|
|
}
|
2017-10-16 19:56:08 -07:00
|
|
|
} // extern "C"
|