2020-12-26 14:12:05 -08:00
|
|
|
// Copyright (c) FIRST and other WPILib contributors.
|
|
|
|
|
// Open Source Software; you can modify and/or share it under the terms of
|
|
|
|
|
// the WPILib BSD license file in the root directory of this project.
|
2017-08-18 21:35:53 -07:00
|
|
|
|
|
|
|
|
#include "../PortsInternal.h"
|
|
|
|
|
#include "RelayDataInternal.h"
|
|
|
|
|
|
|
|
|
|
using namespace hal;
|
|
|
|
|
|
2017-12-10 19:38:53 -08:00
|
|
|
namespace hal {
|
|
|
|
|
namespace init {
|
|
|
|
|
void InitializeRelayData() {
|
|
|
|
|
static RelayData srd[kNumRelayHeaders];
|
|
|
|
|
::hal::SimRelayData = srd;
|
|
|
|
|
}
|
|
|
|
|
} // namespace init
|
|
|
|
|
} // namespace hal
|
|
|
|
|
|
|
|
|
|
RelayData* hal::SimRelayData;
|
2017-08-18 21:35:53 -07:00
|
|
|
void RelayData::ResetData() {
|
2018-09-03 16:08:07 -07:00
|
|
|
initializedForward.Reset(false);
|
|
|
|
|
initializedReverse.Reset(false);
|
|
|
|
|
forward.Reset(false);
|
|
|
|
|
reverse.Reset(false);
|
2017-08-18 21:35:53 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
|
void HALSIM_ResetRelayData(int32_t index) { SimRelayData[index].ResetData(); }
|
|
|
|
|
|
2018-09-03 16:08:07 -07:00
|
|
|
#define DEFINE_CAPI(TYPE, CAPINAME, LOWERNAME) \
|
|
|
|
|
HAL_SIMDATAVALUE_DEFINE_CAPI(TYPE, HALSIM, Relay##CAPINAME, SimRelayData, \
|
|
|
|
|
LOWERNAME)
|
2017-08-18 21:35:53 -07:00
|
|
|
|
2018-09-03 16:08:07 -07:00
|
|
|
DEFINE_CAPI(HAL_Bool, InitializedForward, initializedForward)
|
|
|
|
|
DEFINE_CAPI(HAL_Bool, InitializedReverse, initializedReverse)
|
|
|
|
|
DEFINE_CAPI(HAL_Bool, Forward, forward)
|
|
|
|
|
DEFINE_CAPI(HAL_Bool, Reverse, reverse)
|
2017-08-18 21:35:53 -07:00
|
|
|
|
2018-09-03 16:08:07 -07:00
|
|
|
#define REGISTER(NAME) \
|
|
|
|
|
SimRelayData[index].NAME.RegisterCallback(callback, param, initialNotify)
|
2017-10-22 01:45:41 -04:00
|
|
|
|
2017-12-30 14:54:18 +11:00
|
|
|
void HALSIM_RegisterRelayAllCallbacks(int32_t index,
|
2017-10-22 01:45:41 -04:00
|
|
|
HAL_NotifyCallback callback, void* param,
|
|
|
|
|
HAL_Bool initialNotify) {
|
2018-09-03 16:08:07 -07:00
|
|
|
REGISTER(initializedForward);
|
|
|
|
|
REGISTER(initializedReverse);
|
|
|
|
|
REGISTER(forward);
|
|
|
|
|
REGISTER(reverse);
|
2017-10-22 01:45:41 -04:00
|
|
|
}
|
2017-10-16 19:56:08 -07:00
|
|
|
} // extern "C"
|