From cd38fa1f618360db74b8c0ea5b8500bf6ab6c681 Mon Sep 17 00:00:00 2001 From: Nathan Schulte <8540239+nmschulte@users.noreply.github.com> Date: Fri, 14 Jun 2024 14:17:09 -0500 Subject: [PATCH] remove functionpointer sensor (#442) * remove functionpointer sensor * remove function_pointer_sensor.cpp from tests.mk --- .../sensors/core/function_pointer_sensor.h | 40 ------------------- .../tests/sensor/function_pointer_sensor.cpp | 27 ------------- unit_tests/tests/tests.mk | 1 - 3 files changed, 68 deletions(-) delete mode 100644 firmware/controllers/sensors/core/function_pointer_sensor.h delete mode 100644 unit_tests/tests/sensor/function_pointer_sensor.cpp diff --git a/firmware/controllers/sensors/core/function_pointer_sensor.h b/firmware/controllers/sensors/core/function_pointer_sensor.h deleted file mode 100644 index cfaddacdd6..0000000000 --- a/firmware/controllers/sensors/core/function_pointer_sensor.h +++ /dev/null @@ -1,40 +0,0 @@ -/** - * @file function_pointer_sensor.h - * @brief A sensor to provide a bridge from old getX()-style functions to the new sensor registry. - * - * @date September 12, 2019 - * @author Matthew Kennedy, (c) 2019 - */ - -#pragma once - -#include "sensor.h" - -/* This class is intended as a bridge to bridge from old getMySensor() functions - * to the new system. This way, producers and consumers can be independently - * updated to the new system, with sensors being usable either way for some time. - */ -class FunctionPointerSensor final : public Sensor { -public: - FunctionPointerSensor(SensorType type, float (*func)()) - : Sensor(type) - , m_func(func) {} - - SensorResult get() const final { - float result = m_func(); - - // check for NaN - bool valid = !(result != result); - - if (!valid) { - return unexpected; - } - - return result; - } - - void showInfo(const char* /*sensorName*/) const override {} - -private: - float (*m_func)(); -}; diff --git a/unit_tests/tests/sensor/function_pointer_sensor.cpp b/unit_tests/tests/sensor/function_pointer_sensor.cpp deleted file mode 100644 index ff922c5228..0000000000 --- a/unit_tests/tests/sensor/function_pointer_sensor.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include "pch.h" - -#include "function_pointer_sensor.h" - -class SensorFunctionPointer : public ::testing::Test { -protected: - void SetUp() override { - Sensor::resetRegistry(); - } - - void TearDown() override { - Sensor::resetRegistry(); - } -}; - -float testFunc() { - return 23; -} - -TEST_F(SensorFunctionPointer, TestValue) { - FunctionPointerSensor dut(SensorType::Clt, testFunc); - ASSERT_TRUE(dut.Register()); - - auto result = Sensor::get(SensorType::Clt); - EXPECT_TRUE(result.Valid); - EXPECT_FLOAT_EQ(result.Value, 23); -} diff --git a/unit_tests/tests/tests.mk b/unit_tests/tests/tests.mk index e1da0be795..2a46801f7f 100644 --- a/unit_tests/tests/tests.mk +++ b/unit_tests/tests/tests.mk @@ -79,7 +79,6 @@ TESTS_SRC_CPP = \ tests/test_lambda_monitor.cpp \ tests/sensor/basic_sensor.cpp \ tests/sensor/func_sensor.cpp \ - tests/sensor/function_pointer_sensor.cpp \ tests/sensor/mock_sensor.cpp \ tests/sensor/sensor_reader.cpp \ tests/sensor/lin_func.cpp \