20#include <units/dimensionless.h>
37 std::map<uint32_t, std::unique_ptr<BaseStatusSignalValue>> _signalValues;
38 std::recursive_mutex _signalValuesLck;
43 std::shared_ptr<controls::ControlRequest> _controlReq = std::make_shared<controls::EmptyControl>();
44 std::mutex _controlReqLck;
46 units::time::second_t _resetTimestamp{};
54 std::lock_guard<std::recursive_mutex> lock{_signalValuesLck};
56 const uint32_t totalHash = spn | ((uint32_t)mapper_iter << 16);
58 auto iter = _signalValues.find(totalHash);
59 if (iter != _signalValues.end())
62 toFind = iter->second.get();
64 reportOnConstruction =
true;
73 _signalValues.emplace(totalHash, std::unique_ptr<StatusSignalValue<T>>{
new StatusSignalValue<T>{
76 map_filler, std::move(signalName)}});
81 _signalValues.emplace(totalHash, std::unique_ptr<StatusSignalValue<T>>{
new StatusSignalValue<T>{
84 std::move(signalName)}});
88 iter = _signalValues.find(totalHash);
89 toFind = iter->second.get();
94 StatusSignalValue<T> *ret =
dynamic_cast<StatusSignalValue<T> *
>(toFind);
105 ret->Refresh(reportOnConstruction);
164 template <
typename T>
167 std::function<std::map<int, StatusSignalValue<T>>()> emptyMapFiller = []
169 return std::map<int, StatusSignalValue<T>>{};
171 return LookupCommon<T>(spn, 0, emptyMapFiller, std::move(signalName), reportOnConstruction);
174 template <
typename T>
177 return LookupCommon<T>(spn, mapper_iter, map_filler, std::move(signalName), reportOnConstruction);
181 template <
typename T,
typename U>
@ InvalidParamValue
Incorrect argument passed into function/VI.
Definition: StatusCodes.h:1425
Definition: StatusSignalValue.hpp:40
Definition: StatusSignalValue.hpp:320
Abstract Control Request class that other control requests extend for use.
Definition: ControlRequest.hpp:65
Definition: DeviceIdentifier.hpp:19
int deviceID
Definition: DeviceIdentifier.hpp:23
std::string network
Definition: DeviceIdentifier.hpp:21
Parent class for all devices.
Definition: ParentDevice.hpp:30
static constexpr double kDefaultControlRatePeriodsSec
Definition: ParentDevice.hpp:133
std::shared_ptr< controls::ControlRequest > GetAppliedControl()
Get the latest applied control.
Definition: ParentDevice.hpp:156
std::shared_ptr< const controls::ControlRequest > GetAppliedControl() const
Get the latest applied control.
Definition: ParentDevice.hpp:143
StatusSignalValue< T > & LookupStatusSignalValue(uint16_t spn, uint16_t mapper_iter, std::function< std::map< int, StatusSignalValue< T > >()> map_filler, std::string signalName, bool reportOnConstruction)
Definition: ParentDevice.hpp:175
void ReportIfTooOld(int minMajor, int minMinor, int minBugfix, int minBuild)
StatusSignalValue< T > LookupDimensionlessStatusSignalValue(uint16_t spn, std::string signalName)
Returns a unitless version of the StatusSignalValue by value.
Definition: ParentDevice.hpp:182
ParentDevice(int deviceID, std::string model, std::string canbus)
Definition: ParentDevice.hpp:111
int GetDeviceID() const
Definition: ParentDevice.hpp:120
const std::string & GetCANBus() const
Definition: ParentDevice.hpp:128
virtual void ReportIfTooOld()=0
virtual ctre::phoenix::StatusCode SetControlPrivate(controls::ControlRequest &request)
StatusSignalValue< T > & LookupStatusSignalValue(uint16_t spn, std::string signalName, bool reportOnConstruction)
Definition: ParentDevice.hpp:165
DeviceIdentifier deviceIdentifier
Definition: ParentDevice.hpp:32
Definition: string_util.hpp:14