From fe16f25859bbf64aefbb5624940777b76e07de60 Mon Sep 17 00:00:00 2001 From: Pascal Serrarens Date: Sat, 30 Dec 2023 09:28:09 +0100 Subject: [PATCH] Add external sensing support --- Thing.cpp | 13 ++++--------- Thing.h | 11 +++++++---- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/Thing.cpp b/Thing.cpp index 67f3e4b..1fc973c 100644 --- a/Thing.cpp +++ b/Thing.cpp @@ -2,9 +2,7 @@ using namespace Passer::RoboidControl; -Thing::Thing() { - this->type = (unsigned int)Type::Undetermined; -} +Thing::Thing() { this->type = (unsigned int)Type::Undetermined; } const unsigned int Thing::SwitchType = SensorType | (unsigned int)Type::Switch; const unsigned int Thing::DistanceSensorType = @@ -13,11 +11,8 @@ const unsigned int Thing::ControlledMotorType = MotorType | (unsigned int)Type::ControlledMotor; const unsigned int Thing::UncontrolledMotorType = MotorType | (unsigned int)Type::UncontrolledMotor; +const unsigned int Thing::ExternalType = (unsigned int)Type::ExternalSensor; -bool Thing::IsMotor() { - return (type & Thing::MotorType) != 0; -} +bool Thing::IsMotor() { return (type & Thing::MotorType) != 0; } -bool Thing::IsSensor() { - return (type & Thing::SensorType) != 0; -} \ No newline at end of file +bool Thing::IsSensor() { return (type & Thing::SensorType) != 0; } \ No newline at end of file diff --git a/Thing.h b/Thing.h index e35cc9b..14db035 100644 --- a/Thing.h +++ b/Thing.h @@ -5,7 +5,7 @@ namespace RoboidControl { /// @brief A thing is a functional component on a robot class Thing { - public: +public: /// @brief Default constructor for a Thing Thing(); @@ -16,6 +16,7 @@ class Thing { static const unsigned int DistanceSensorType; static const unsigned int ControlledMotorType; static const unsigned int UncontrolledMotorType; + static const unsigned int ExternalType; /// @brief Check if the Thing is a Motor /// @returns True when the Thing is a Motor and False otherwise @@ -24,7 +25,7 @@ class Thing { /// @returns True when the Thing is a Sensor and False otherwise bool IsSensor(); - protected: +protected: /// @brief Bitmask for Motor type static const unsigned int MotorType = 0x8000; /// @brief Bitmap for Sensor type @@ -39,9 +40,11 @@ class Thing { // Motor, ControlledMotor, UncontrolledMotor, + // Other + ExternalSensor, }; }; -} // namespace RoboidControl -} // namespace Passer +} // namespace RoboidControl +} // namespace Passer using namespace Passer::RoboidControl; \ No newline at end of file