diff --git a/hal/src/main/native/include/hal/HAL.h b/hal/src/main/native/include/hal/HAL.h index 992a2c28d8..974be0a54a 100644 --- a/hal/src/main/native/include/hal/HAL.h +++ b/hal/src/main/native/include/hal/HAL.h @@ -39,6 +39,7 @@ #include "hal/Solenoid.h" #include "hal/Threads.h" #include "hal/Types.h" +#include "hal/Value.h" #ifdef __cplusplus #include "hal/FRCUsageReporting.h" diff --git a/hal/src/main/native/include/hal/Types.h b/hal/src/main/native/include/hal/Types.h index 3d3065627e..5ce600933a 100644 --- a/hal/src/main/native/include/hal/Types.h +++ b/hal/src/main/native/include/hal/Types.h @@ -53,6 +53,10 @@ typedef HAL_Handle HAL_SerialPortHandle; typedef HAL_Handle HAL_CANHandle; +typedef HAL_Handle HAL_SimDeviceHandle; + +typedef HAL_Handle HAL_SimValueHandle; + typedef HAL_CANHandle HAL_PDPHandle; typedef int32_t HAL_Bool; diff --git a/hal/src/main/native/include/mockdata/HAL_Value.h b/hal/src/main/native/include/hal/Value.h similarity index 73% rename from hal/src/main/native/include/mockdata/HAL_Value.h rename to hal/src/main/native/include/hal/Value.h index 4beefa6455..70e465ce02 100644 --- a/hal/src/main/native/include/mockdata/HAL_Value.h +++ b/hal/src/main/native/include/hal/Value.h @@ -31,37 +31,45 @@ struct HAL_Value { enum HAL_Type type; }; -inline HAL_Value MakeBoolean(HAL_Bool v) { - HAL_Value value; +#ifdef __cplusplus +extern "C" { +#endif + +inline struct HAL_Value HAL_MakeBoolean(HAL_Bool v) { + struct HAL_Value value; value.type = HAL_BOOLEAN; value.data.v_boolean = v; return value; } -inline HAL_Value MakeEnum(int v) { - HAL_Value value; +inline struct HAL_Value HAL_MakeEnum(int v) { + struct HAL_Value value; value.type = HAL_ENUM; value.data.v_enum = v; return value; } -inline HAL_Value MakeInt(int v) { - HAL_Value value; +inline struct HAL_Value HAL_MakeInt(int v) { + struct HAL_Value value; value.type = HAL_INT; value.data.v_int = v; return value; } -inline HAL_Value MakeLong(int64_t v) { - HAL_Value value; +inline struct HAL_Value HAL_MakeLong(int64_t v) { + struct HAL_Value value; value.type = HAL_LONG; value.data.v_long = v; return value; } -inline HAL_Value MakeDouble(double v) { - HAL_Value value; +inline struct HAL_Value HAL_MakeDouble(double v) { + struct HAL_Value value; value.type = HAL_DOUBLE; value.data.v_double = v; return value; } + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/hal/src/main/native/include/mockdata/CanData.h b/hal/src/main/native/include/mockdata/CanData.h index bb821a08e0..0d48290783 100644 --- a/hal/src/main/native/include/mockdata/CanData.h +++ b/hal/src/main/native/include/mockdata/CanData.h @@ -7,9 +7,9 @@ #pragma once -#include "HAL_Value.h" #include "NotifyListener.h" #include "hal/Types.h" +#include "hal/Value.h" typedef void (*HAL_CAN_SendMessageCallback)(const char* name, void* param, uint32_t messageID, diff --git a/hal/src/main/native/include/mockdata/NotifyListener.h b/hal/src/main/native/include/mockdata/NotifyListener.h index 73dff63524..a4558030fd 100644 --- a/hal/src/main/native/include/mockdata/NotifyListener.h +++ b/hal/src/main/native/include/mockdata/NotifyListener.h @@ -7,7 +7,7 @@ #pragma once -#include "HAL_Value.h" +#include "hal/Value.h" typedef void (*HAL_NotifyCallback)(const char* name, void* param, const struct HAL_Value* value); diff --git a/hal/src/main/native/include/simulation/CallbackStore.h b/hal/src/main/native/include/simulation/CallbackStore.h index 8b554a8e14..b2d4bdf58f 100644 --- a/hal/src/main/native/include/simulation/CallbackStore.h +++ b/hal/src/main/native/include/simulation/CallbackStore.h @@ -11,7 +11,7 @@ #include -#include "mockdata/HAL_Value.h" +#include "hal/Value.h" namespace frc { namespace sim { diff --git a/hal/src/main/native/sim/Interrupts.cpp b/hal/src/main/native/sim/Interrupts.cpp index 1a9cdd0252..a7dd285da5 100644 --- a/hal/src/main/native/sim/Interrupts.cpp +++ b/hal/src/main/native/sim/Interrupts.cpp @@ -19,12 +19,12 @@ #include "PortsInternal.h" #include "hal/AnalogTrigger.h" #include "hal/Errors.h" +#include "hal/Value.h" #include "hal/handles/HandlesInternal.h" #include "hal/handles/LimitedHandleResource.h" #include "hal/handles/UnlimitedHandleResource.h" #include "mockdata/AnalogInDataInternal.h" #include "mockdata/DIODataInternal.h" -#include "mockdata/HAL_Value.h" #ifdef _WIN32 #pragma warning(disable : 4996 4018 6297 26451 4334) diff --git a/hal/src/main/native/sim/jni/BufferCallbackStore.cpp b/hal/src/main/native/sim/jni/BufferCallbackStore.cpp index fbf3adce66..3c9941e2cd 100644 --- a/hal/src/main/native/sim/jni/BufferCallbackStore.cpp +++ b/hal/src/main/native/sim/jni/BufferCallbackStore.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018 FIRST. All Rights Reserved. */ +/* Copyright (c) 2018-2019 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. */ @@ -13,8 +13,8 @@ #include "SimulatorJNI.h" #include "hal/Types.h" +#include "hal/Value.h" #include "hal/handles/UnlimitedHandleResource.h" -#include "mockdata/HAL_Value.h" #include "mockdata/NotifyListener.h" using namespace wpi::java; diff --git a/hal/src/main/native/sim/jni/BufferCallbackStore.h b/hal/src/main/native/sim/jni/BufferCallbackStore.h index b9d49acf6f..6b472ac830 100644 --- a/hal/src/main/native/sim/jni/BufferCallbackStore.h +++ b/hal/src/main/native/sim/jni/BufferCallbackStore.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018 FIRST. All Rights Reserved. */ +/* Copyright (c) 2018-2019 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. */ @@ -13,8 +13,8 @@ #include "SimulatorJNI.h" #include "hal/Types.h" +#include "hal/Value.h" #include "hal/handles/UnlimitedHandleResource.h" -#include "mockdata/HAL_Value.h" #include "mockdata/NotifyListener.h" namespace sim { diff --git a/hal/src/main/native/sim/jni/CallbackStore.cpp b/hal/src/main/native/sim/jni/CallbackStore.cpp index abef9b010a..318ab1e50c 100644 --- a/hal/src/main/native/sim/jni/CallbackStore.cpp +++ b/hal/src/main/native/sim/jni/CallbackStore.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018 FIRST. All Rights Reserved. */ +/* Copyright (c) 2018-2019 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. */ @@ -13,8 +13,8 @@ #include "SimulatorJNI.h" #include "hal/Types.h" +#include "hal/Value.h" #include "hal/handles/UnlimitedHandleResource.h" -#include "mockdata/HAL_Value.h" #include "mockdata/NotifyListener.h" using namespace wpi::java; diff --git a/hal/src/main/native/sim/jni/CallbackStore.h b/hal/src/main/native/sim/jni/CallbackStore.h index 94454b05d4..eacf3149e3 100644 --- a/hal/src/main/native/sim/jni/CallbackStore.h +++ b/hal/src/main/native/sim/jni/CallbackStore.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018 FIRST. All Rights Reserved. */ +/* Copyright (c) 2018-2019 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. */ @@ -13,8 +13,8 @@ #include "SimulatorJNI.h" #include "hal/Types.h" +#include "hal/Value.h" #include "hal/handles/UnlimitedHandleResource.h" -#include "mockdata/HAL_Value.h" #include "mockdata/NotifyListener.h" namespace sim { diff --git a/hal/src/main/native/sim/jni/ConstBufferCallbackStore.cpp b/hal/src/main/native/sim/jni/ConstBufferCallbackStore.cpp index 781725b1b7..d68198378f 100644 --- a/hal/src/main/native/sim/jni/ConstBufferCallbackStore.cpp +++ b/hal/src/main/native/sim/jni/ConstBufferCallbackStore.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018 FIRST. All Rights Reserved. */ +/* Copyright (c) 2018-2019 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. */ @@ -13,8 +13,8 @@ #include "SimulatorJNI.h" #include "hal/Types.h" +#include "hal/Value.h" #include "hal/handles/UnlimitedHandleResource.h" -#include "mockdata/HAL_Value.h" #include "mockdata/NotifyListener.h" using namespace wpi::java; diff --git a/hal/src/main/native/sim/jni/ConstBufferCallbackStore.h b/hal/src/main/native/sim/jni/ConstBufferCallbackStore.h index 1b0f54e19d..2164a74796 100644 --- a/hal/src/main/native/sim/jni/ConstBufferCallbackStore.h +++ b/hal/src/main/native/sim/jni/ConstBufferCallbackStore.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018 FIRST. All Rights Reserved. */ +/* Copyright (c) 2018-2019 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. */ @@ -13,8 +13,8 @@ #include "SimulatorJNI.h" #include "hal/Types.h" +#include "hal/Value.h" #include "hal/handles/UnlimitedHandleResource.h" -#include "mockdata/HAL_Value.h" #include "mockdata/NotifyListener.h" namespace sim { diff --git a/hal/src/main/native/sim/jni/SimulatorJNI.h b/hal/src/main/native/sim/jni/SimulatorJNI.h index 60d0ca38cb..de74a1cd32 100644 --- a/hal/src/main/native/sim/jni/SimulatorJNI.h +++ b/hal/src/main/native/sim/jni/SimulatorJNI.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018 FIRST. All Rights Reserved. */ +/* Copyright (c) 2018-2019 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. */ @@ -10,8 +10,8 @@ #include #include "hal/Types.h" +#include "hal/Value.h" #include "jni.h" -#include "mockdata/HAL_Value.h" typedef HAL_Handle SIM_JniHandle; diff --git a/hal/src/main/native/sim/jni/SpiReadAutoReceiveBufferCallbackStore.cpp b/hal/src/main/native/sim/jni/SpiReadAutoReceiveBufferCallbackStore.cpp index 935c8bf7d4..b75bb1e9de 100644 --- a/hal/src/main/native/sim/jni/SpiReadAutoReceiveBufferCallbackStore.cpp +++ b/hal/src/main/native/sim/jni/SpiReadAutoReceiveBufferCallbackStore.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018 FIRST. All Rights Reserved. */ +/* Copyright (c) 2018-2019 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. */ @@ -13,8 +13,8 @@ #include "SimulatorJNI.h" #include "hal/Types.h" +#include "hal/Value.h" #include "hal/handles/UnlimitedHandleResource.h" -#include "mockdata/HAL_Value.h" #include "mockdata/NotifyListener.h" using namespace wpi::java; diff --git a/hal/src/main/native/sim/jni/SpiReadAutoReceiveBufferCallbackStore.h b/hal/src/main/native/sim/jni/SpiReadAutoReceiveBufferCallbackStore.h index 643a874a66..1a03f59fe2 100644 --- a/hal/src/main/native/sim/jni/SpiReadAutoReceiveBufferCallbackStore.h +++ b/hal/src/main/native/sim/jni/SpiReadAutoReceiveBufferCallbackStore.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018 FIRST. All Rights Reserved. */ +/* Copyright (c) 2018-2019 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. */ @@ -13,8 +13,8 @@ #include "SimulatorJNI.h" #include "hal/Types.h" +#include "hal/Value.h" #include "hal/handles/UnlimitedHandleResource.h" -#include "mockdata/HAL_Value.h" #include "mockdata/NotifyListener.h" #include "mockdata/SPIData.h" diff --git a/hal/src/main/native/sim/mockdata/AccelerometerDataInternal.h b/hal/src/main/native/sim/mockdata/AccelerometerDataInternal.h index 15e55acc53..9db087584f 100644 --- a/hal/src/main/native/sim/mockdata/AccelerometerDataInternal.h +++ b/hal/src/main/native/sim/mockdata/AccelerometerDataInternal.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */ +/* Copyright (c) 2017-2019 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. */ @@ -19,16 +19,16 @@ class AccelerometerData { HAL_SIMDATAVALUE_DEFINE_NAME(Z) static inline HAL_Value MakeRangeValue(HAL_AccelerometerRange value) { - return MakeEnum(value); + return HAL_MakeEnum(value); } public: - SimDataValue active{false}; + SimDataValue active{false}; SimDataValue range{ static_cast(0)}; - SimDataValue x{0.0}; - SimDataValue y{0.0}; - SimDataValue z{0.0}; + SimDataValue x{0.0}; + SimDataValue y{0.0}; + SimDataValue z{0.0}; virtual void ResetData(); }; diff --git a/hal/src/main/native/sim/mockdata/AnalogGyroDataInternal.h b/hal/src/main/native/sim/mockdata/AnalogGyroDataInternal.h index 8dfcb52862..427d2fb19e 100644 --- a/hal/src/main/native/sim/mockdata/AnalogGyroDataInternal.h +++ b/hal/src/main/native/sim/mockdata/AnalogGyroDataInternal.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */ +/* Copyright (c) 2017-2019 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. */ @@ -17,9 +17,10 @@ class AnalogGyroData { HAL_SIMDATAVALUE_DEFINE_NAME(Initialized) public: - SimDataValue angle{0.0}; - SimDataValue rate{0.0}; - SimDataValue initialized{false}; + SimDataValue angle{0.0}; + SimDataValue rate{0.0}; + SimDataValue initialized{ + false}; virtual void ResetData(); }; diff --git a/hal/src/main/native/sim/mockdata/AnalogInDataInternal.h b/hal/src/main/native/sim/mockdata/AnalogInDataInternal.h index 94121ca8da..99f8893912 100644 --- a/hal/src/main/native/sim/mockdata/AnalogInDataInternal.h +++ b/hal/src/main/native/sim/mockdata/AnalogInDataInternal.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */ +/* Copyright (c) 2017-2019 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. */ @@ -23,16 +23,20 @@ class AnalogInData { HAL_SIMDATAVALUE_DEFINE_NAME(AccumulatorDeadband) public: - SimDataValue initialized{false}; - SimDataValue averageBits{7}; - SimDataValue oversampleBits{0}; - SimDataValue voltage{0.0}; - SimDataValue + SimDataValue initialized{ + false}; + SimDataValue averageBits{7}; + SimDataValue oversampleBits{0}; + SimDataValue voltage{0.0}; + SimDataValue accumulatorInitialized{false}; - SimDataValue accumulatorValue{0}; - SimDataValue accumulatorCount{0}; - SimDataValue accumulatorCenter{0}; - SimDataValue + SimDataValue accumulatorValue{ + 0}; + SimDataValue accumulatorCount{ + 0}; + SimDataValue + accumulatorCenter{0}; + SimDataValue accumulatorDeadband{0}; virtual void ResetData(); diff --git a/hal/src/main/native/sim/mockdata/AnalogOutDataInternal.h b/hal/src/main/native/sim/mockdata/AnalogOutDataInternal.h index 84af837159..da7d49fa9f 100644 --- a/hal/src/main/native/sim/mockdata/AnalogOutDataInternal.h +++ b/hal/src/main/native/sim/mockdata/AnalogOutDataInternal.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */ +/* Copyright (c) 2017-2019 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. */ @@ -16,8 +16,8 @@ class AnalogOutData { HAL_SIMDATAVALUE_DEFINE_NAME(Initialized) public: - SimDataValue voltage{0.0}; - SimDataValue initialized{0}; + SimDataValue voltage{0.0}; + SimDataValue initialized{0}; virtual void ResetData(); }; diff --git a/hal/src/main/native/sim/mockdata/AnalogTriggerDataInternal.h b/hal/src/main/native/sim/mockdata/AnalogTriggerDataInternal.h index 131ba7a709..61b3c1964c 100644 --- a/hal/src/main/native/sim/mockdata/AnalogTriggerDataInternal.h +++ b/hal/src/main/native/sim/mockdata/AnalogTriggerDataInternal.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */ +/* Copyright (c) 2017-2019 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. */ @@ -19,15 +19,15 @@ class AnalogTriggerData { static LLVM_ATTRIBUTE_ALWAYS_INLINE HAL_Value MakeTriggerModeValue(HALSIM_AnalogTriggerMode value) { - return MakeEnum(value); + return HAL_MakeEnum(value); } public: - SimDataValue initialized{0}; - SimDataValue triggerLowerBound{ - 0}; - SimDataValue triggerUpperBound{ - 0}; + SimDataValue initialized{0}; + SimDataValue + triggerLowerBound{0}; + SimDataValue + triggerUpperBound{0}; SimDataValue triggerMode{static_cast(0)}; diff --git a/hal/src/main/native/sim/mockdata/DIODataInternal.h b/hal/src/main/native/sim/mockdata/DIODataInternal.h index 0b022f9f62..8ad11271a4 100644 --- a/hal/src/main/native/sim/mockdata/DIODataInternal.h +++ b/hal/src/main/native/sim/mockdata/DIODataInternal.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */ +/* Copyright (c) 2017-2019 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. */ @@ -19,11 +19,12 @@ class DIOData { HAL_SIMDATAVALUE_DEFINE_NAME(FilterIndex) public: - SimDataValue initialized{false}; - SimDataValue value{true}; - SimDataValue pulseLength{0.0}; - SimDataValue isInput{true}; - SimDataValue filterIndex{-1}; + SimDataValue initialized{ + false}; + SimDataValue value{true}; + SimDataValue pulseLength{0.0}; + SimDataValue isInput{true}; + SimDataValue filterIndex{-1}; virtual void ResetData(); }; diff --git a/hal/src/main/native/sim/mockdata/DigitalPWMDataInternal.h b/hal/src/main/native/sim/mockdata/DigitalPWMDataInternal.h index 00d8b4a808..09d5903b5a 100644 --- a/hal/src/main/native/sim/mockdata/DigitalPWMDataInternal.h +++ b/hal/src/main/native/sim/mockdata/DigitalPWMDataInternal.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */ +/* Copyright (c) 2017-2019 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. */ @@ -17,9 +17,10 @@ class DigitalPWMData { HAL_SIMDATAVALUE_DEFINE_NAME(Pin) public: - SimDataValue initialized{false}; - SimDataValue dutyCycle{0.0}; - SimDataValue pin{0}; + SimDataValue initialized{ + false}; + SimDataValue dutyCycle{0.0}; + SimDataValue pin{0}; virtual void ResetData(); }; diff --git a/hal/src/main/native/sim/mockdata/DriverStationDataInternal.h b/hal/src/main/native/sim/mockdata/DriverStationDataInternal.h index f7eb132b8c..fdeb3c62a9 100644 --- a/hal/src/main/native/sim/mockdata/DriverStationDataInternal.h +++ b/hal/src/main/native/sim/mockdata/DriverStationDataInternal.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */ +/* Copyright (c) 2017-2019 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. */ @@ -29,7 +29,7 @@ class DriverStationData { static LLVM_ATTRIBUTE_ALWAYS_INLINE HAL_Value MakeAllianceStationIdValue(HAL_AllianceStationID value) { - return MakeEnum(value); + return HAL_MakeEnum(value); } public: @@ -58,16 +58,17 @@ class DriverStationData { void NotifyNewData(); - SimDataValue enabled{false}; - SimDataValue autonomous{false}; - SimDataValue test{false}; - SimDataValue eStop{false}; - SimDataValue fmsAttached{false}; - SimDataValue dsAttached{true}; + SimDataValue enabled{false}; + SimDataValue autonomous{false}; + SimDataValue test{false}; + SimDataValue eStop{false}; + SimDataValue fmsAttached{ + false}; + SimDataValue dsAttached{true}; SimDataValue allianceStationId{static_cast(0)}; - SimDataValue matchTime{0.0}; + SimDataValue matchTime{0.0}; private: wpi::spinlock m_joystickDataMutex; diff --git a/hal/src/main/native/sim/mockdata/EncoderDataInternal.h b/hal/src/main/native/sim/mockdata/EncoderDataInternal.h index 2f4894e2c1..d382962c8f 100644 --- a/hal/src/main/native/sim/mockdata/EncoderDataInternal.h +++ b/hal/src/main/native/sim/mockdata/EncoderDataInternal.h @@ -27,17 +27,20 @@ class EncoderData { public: std::atomic digitalChannelA{0}; - SimDataValue initialized{false}; - SimDataValue count{0}; - SimDataValue period{ - (std::numeric_limits::max)()}; - SimDataValue reset{false}; - SimDataValue maxPeriod{0}; - SimDataValue direction{false}; - SimDataValue reverseDirection{ + SimDataValue initialized{ false}; - SimDataValue samplesToAverage{0}; - SimDataValue distancePerPulse{1}; + SimDataValue count{0}; + SimDataValue period{ + (std::numeric_limits::max)()}; + SimDataValue reset{false}; + SimDataValue maxPeriod{0}; + SimDataValue direction{false}; + SimDataValue + reverseDirection{false}; + SimDataValue samplesToAverage{ + 0}; + SimDataValue + distancePerPulse{1}; virtual void ResetData(); }; diff --git a/hal/src/main/native/sim/mockdata/HALValueInternal.h b/hal/src/main/native/sim/mockdata/HALValueInternal.h deleted file mode 100644 index f6594036f9..0000000000 --- a/hal/src/main/native/sim/mockdata/HALValueInternal.h +++ /dev/null @@ -1,27 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2017-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 - -#include -#include - -#include "mockdata/HALValue.h" -#include "mockdata/wpi/StringRef.h" - -namespace hal { - -class Value; - -void ConvertToC(const Value& in, HAL_Value* out); -std::shared_ptr ConvertFromC(const HAL_Value& value); -void ConvertToC(wpi::StringRef in, HALString* out); -inline wpi::StringRef ConvertFromC(const HALString& str) { - return wpi::StringRef(str.str, str.len); -} - -} // namespace hal diff --git a/hal/src/main/native/sim/mockdata/I2CDataInternal.h b/hal/src/main/native/sim/mockdata/I2CDataInternal.h index 1c2df0e3a7..c799bb7d0d 100644 --- a/hal/src/main/native/sim/mockdata/I2CDataInternal.h +++ b/hal/src/main/native/sim/mockdata/I2CDataInternal.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */ +/* Copyright (c) 2017-2019 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. */ @@ -22,7 +22,8 @@ class I2CData { int32_t sendSize); void Read(int32_t deviceAddress, uint8_t* buffer, int32_t count); - SimDataValue initialized{false}; + SimDataValue initialized{ + false}; SimCallbackRegistry read; SimCallbackRegistry write; diff --git a/hal/src/main/native/sim/mockdata/PCMDataInternal.h b/hal/src/main/native/sim/mockdata/PCMDataInternal.h index 4144987451..0c7b99b3d6 100644 --- a/hal/src/main/native/sim/mockdata/PCMDataInternal.h +++ b/hal/src/main/native/sim/mockdata/PCMDataInternal.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */ +/* Copyright (c) 2017-2019 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. */ @@ -31,21 +31,22 @@ class PCMData { } public: - SimDataValue solenoidInitialized[kNumSolenoidChannels]; - SimDataValue solenoidOutput[kNumSolenoidChannels]; - SimDataValue + SimDataValue compressorInitialized{false}; - SimDataValue compressorOn{false}; - SimDataValue - closedLoopEnabled{true}; - SimDataValue pressureSwitch{ + SimDataValue compressorOn{ false}; - SimDataValue compressorCurrent{ - 0.0}; + SimDataValue + closedLoopEnabled{true}; + SimDataValue pressureSwitch{ + false}; + SimDataValue + compressorCurrent{0.0}; virtual void ResetData(); }; diff --git a/hal/src/main/native/sim/mockdata/PDPDataInternal.h b/hal/src/main/native/sim/mockdata/PDPDataInternal.h index a7170c7b87..8d45416f93 100644 --- a/hal/src/main/native/sim/mockdata/PDPDataInternal.h +++ b/hal/src/main/native/sim/mockdata/PDPDataInternal.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */ +/* Copyright (c) 2017-2019 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. */ @@ -23,10 +23,11 @@ class PDPData { } public: - SimDataValue initialized{false}; - SimDataValue temperature{0.0}; - SimDataValue voltage{12.0}; - SimDataValue + SimDataValue initialized{ + false}; + SimDataValue temperature{0.0}; + SimDataValue voltage{12.0}; + SimDataValue current[kNumPDPChannels]; virtual void ResetData(); diff --git a/hal/src/main/native/sim/mockdata/PWMDataInternal.h b/hal/src/main/native/sim/mockdata/PWMDataInternal.h index 85eae44870..248b7b3788 100644 --- a/hal/src/main/native/sim/mockdata/PWMDataInternal.h +++ b/hal/src/main/native/sim/mockdata/PWMDataInternal.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */ +/* Copyright (c) 2017-2019 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. */ @@ -20,12 +20,13 @@ class PWMData { HAL_SIMDATAVALUE_DEFINE_NAME(ZeroLatch) public: - SimDataValue initialized{false}; - SimDataValue rawValue{0}; - SimDataValue speed{0}; - SimDataValue position{0}; - SimDataValue periodScale{0}; - SimDataValue zeroLatch{false}; + SimDataValue initialized{ + false}; + SimDataValue rawValue{0}; + SimDataValue speed{0}; + SimDataValue position{0}; + SimDataValue periodScale{0}; + SimDataValue zeroLatch{false}; virtual void ResetData(); }; diff --git a/hal/src/main/native/sim/mockdata/RelayDataInternal.h b/hal/src/main/native/sim/mockdata/RelayDataInternal.h index 88e79ff125..cb38388132 100644 --- a/hal/src/main/native/sim/mockdata/RelayDataInternal.h +++ b/hal/src/main/native/sim/mockdata/RelayDataInternal.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */ +/* Copyright (c) 2017-2019 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. */ @@ -18,12 +18,12 @@ class RelayData { HAL_SIMDATAVALUE_DEFINE_NAME(Reverse) public: - SimDataValue + SimDataValue initializedForward{false}; - SimDataValue + SimDataValue initializedReverse{false}; - SimDataValue forward{false}; - SimDataValue reverse{false}; + SimDataValue forward{false}; + SimDataValue reverse{false}; virtual void ResetData(); }; diff --git a/hal/src/main/native/sim/mockdata/RoboRioDataInternal.h b/hal/src/main/native/sim/mockdata/RoboRioDataInternal.h index 92aa0c863e..cc74fa2429 100644 --- a/hal/src/main/native/sim/mockdata/RoboRioDataInternal.h +++ b/hal/src/main/native/sim/mockdata/RoboRioDataInternal.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */ +/* Copyright (c) 2017-2019 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. */ @@ -29,22 +29,26 @@ class RoboRioData { HAL_SIMDATAVALUE_DEFINE_NAME(UserFaults3V3) public: - SimDataValue fpgaButton{false}; - SimDataValue vInVoltage{0.0}; - SimDataValue vInCurrent{0.0}; - SimDataValue userVoltage6V{6.0}; - SimDataValue userCurrent6V{0.0}; - SimDataValue userActive6V{false}; - SimDataValue userVoltage5V{5.0}; - SimDataValue userCurrent5V{0.0}; - SimDataValue userActive5V{false}; - SimDataValue userVoltage3V3{3.3}; - SimDataValue userCurrent3V3{0.0}; - SimDataValue userActive3V3{ + SimDataValue fpgaButton{false}; + SimDataValue vInVoltage{0.0}; + SimDataValue vInCurrent{0.0}; + SimDataValue userVoltage6V{6.0}; + SimDataValue userCurrent6V{0.0}; + SimDataValue userActive6V{ false}; - SimDataValue userFaults6V{0}; - SimDataValue userFaults5V{0}; - SimDataValue userFaults3V3{0}; + SimDataValue userVoltage5V{5.0}; + SimDataValue userCurrent5V{0.0}; + SimDataValue userActive5V{ + false}; + SimDataValue userVoltage3V3{ + 3.3}; + SimDataValue userCurrent3V3{ + 0.0}; + SimDataValue userActive3V3{ + false}; + SimDataValue userFaults6V{0}; + SimDataValue userFaults5V{0}; + SimDataValue userFaults3V3{0}; virtual void ResetData(); }; diff --git a/hal/src/main/native/sim/mockdata/SPIAccelerometerDataInternal.h b/hal/src/main/native/sim/mockdata/SPIAccelerometerDataInternal.h index ee9f79d068..661e01bfb7 100644 --- a/hal/src/main/native/sim/mockdata/SPIAccelerometerDataInternal.h +++ b/hal/src/main/native/sim/mockdata/SPIAccelerometerDataInternal.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */ +/* Copyright (c) 2017-2019 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. */ @@ -19,11 +19,11 @@ class SPIAccelerometerData { HAL_SIMDATAVALUE_DEFINE_NAME(Z) public: - SimDataValue active{false}; - SimDataValue range{0}; - SimDataValue x{0.0}; - SimDataValue y{0.0}; - SimDataValue z{0.0}; + SimDataValue active{false}; + SimDataValue range{0}; + SimDataValue x{0.0}; + SimDataValue y{0.0}; + SimDataValue z{0.0}; virtual void ResetData(); }; diff --git a/hal/src/main/native/sim/mockdata/SPIDataInternal.h b/hal/src/main/native/sim/mockdata/SPIDataInternal.h index b10e741ba4..44868d2d15 100644 --- a/hal/src/main/native/sim/mockdata/SPIDataInternal.h +++ b/hal/src/main/native/sim/mockdata/SPIDataInternal.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */ +/* Copyright (c) 2017-2019 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. */ @@ -27,7 +27,8 @@ class SPIData { int32_t ReadAutoReceivedData(uint32_t* buffer, int32_t numToRead, double timeout, int32_t* status); - SimDataValue initialized{false}; + SimDataValue initialized{ + false}; SimCallbackRegistry read; SimCallbackRegistry write; SimCallbackRegistry diff --git a/simulation/halsim_adx_gyro_accelerometer/src/main/native/include/ADXRS450_SpiGyroWrapperData.h b/simulation/halsim_adx_gyro_accelerometer/src/main/native/include/ADXRS450_SpiGyroWrapperData.h index 25e83766fa..d444019b98 100644 --- a/simulation/halsim_adx_gyro_accelerometer/src/main/native/include/ADXRS450_SpiGyroWrapperData.h +++ b/simulation/halsim_adx_gyro_accelerometer/src/main/native/include/ADXRS450_SpiGyroWrapperData.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */ +/* Copyright (c) 2017-2019 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. */ @@ -38,7 +38,7 @@ class ADXRS450_SpiGyroWrapper { HAL_SIMDATAVALUE_DEFINE_NAME(Angle) - SimDataValue m_angle{0.0}; + SimDataValue m_angle{0.0}; double m_angleDiff = 0.0; static const double kAngleLsb; diff --git a/simulation/halsim_adx_gyro_accelerometer/src/main/native/include/ThreeAxisAccelerometerData.h b/simulation/halsim_adx_gyro_accelerometer/src/main/native/include/ThreeAxisAccelerometerData.h index 67412e59d5..4b70264545 100644 --- a/simulation/halsim_adx_gyro_accelerometer/src/main/native/include/ThreeAxisAccelerometerData.h +++ b/simulation/halsim_adx_gyro_accelerometer/src/main/native/include/ThreeAxisAccelerometerData.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */ +/* Copyright (c) 2017-2019 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. */ @@ -30,9 +30,9 @@ class ThreeAxisAccelerometerData { double GetZ() { return z; } void SetZ(double z_) { z = z_; } - SimDataValue x{0.0}; - SimDataValue y{0.0}; - SimDataValue z{0.0}; + SimDataValue x{0.0}; + SimDataValue y{0.0}; + SimDataValue z{0.0}; virtual void ResetData(); }; diff --git a/simulation/halsim_print/src/main/native/cpp/PrintPWM.cpp b/simulation/halsim_print/src/main/native/cpp/PrintPWM.cpp index fe82ccdaa5..d271ef10e5 100644 --- a/simulation/halsim_print/src/main/native/cpp/PrintPWM.cpp +++ b/simulation/halsim_print/src/main/native/cpp/PrintPWM.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */ +/* Copyright (c) 2017-2019 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. */ @@ -9,7 +9,7 @@ #include -#include +#include #include #include