[sim] Add initialized flag for all solenoids on a PCM (#2897)

This allows much easier/faster checking for whether any solenoid has been
initialized on a particular PCM.
This commit is contained in:
Peter Johnson
2020-11-30 19:20:16 -08:00
committed by GitHub
parent bdf5ba91a4
commit f5a6fc0703
4 changed files with 24 additions and 1 deletions

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2017-2019 FIRST. All Rights Reserved. */
/* Copyright (c) 2017-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. */
@@ -25,6 +25,7 @@ void PCMData::ResetData() {
solenoidInitialized[i].Reset(false);
solenoidOutput[i].Reset(false);
}
anySolenoidInitialized.Reset(false);
compressorInitialized.Reset(false);
compressorOn.Reset(false);
closedLoopEnabled.Reset(true);
@@ -43,6 +44,7 @@ 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, AnySolenoidInitialized, anySolenoidInitialized)
DEFINE_CAPI(HAL_Bool, CompressorInitialized, compressorInitialized)
DEFINE_CAPI(HAL_Bool, CompressorOn, compressorOn)
DEFINE_CAPI(HAL_Bool, ClosedLoopEnabled, closedLoopEnabled)

View File

@@ -15,6 +15,7 @@ namespace hal {
class PCMData {
HAL_SIMDATAVALUE_DEFINE_NAME(SolenoidInitialized)
HAL_SIMDATAVALUE_DEFINE_NAME(SolenoidOutput)
HAL_SIMDATAVALUE_DEFINE_NAME(AnySolenoidInitialized)
HAL_SIMDATAVALUE_DEFINE_NAME(CompressorInitialized)
HAL_SIMDATAVALUE_DEFINE_NAME(CompressorOn)
HAL_SIMDATAVALUE_DEFINE_NAME(ClosedLoopEnabled)
@@ -37,6 +38,8 @@ class PCMData {
SimDataValue<HAL_Bool, HAL_MakeBoolean, GetSolenoidOutputName,
GetSolenoidOutputDefault>
solenoidOutput[kNumSolenoidChannels];
SimDataValue<HAL_Bool, HAL_MakeBoolean, GetAnySolenoidInitializedName>
anySolenoidInitialized{false};
SimDataValue<HAL_Bool, HAL_MakeBoolean, GetCompressorInitializedName>
compressorInitialized{false};
SimDataValue<HAL_Bool, HAL_MakeBoolean, GetCompressorOnName> compressorOn{