Add external sensing support

This commit is contained in:
Pascal Serrarens 2023-12-30 09:28:09 +01:00
parent 4f7e911be1
commit fe16f25859
2 changed files with 11 additions and 13 deletions

View File

@ -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;
}
bool Thing::IsSensor() { return (type & Thing::SensorType) != 0; }

11
Thing.h
View File

@ -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;