Add external sensing support
This commit is contained in:
		
							parent
							
								
									4f7e911be1
								
							
						
					
					
						commit
						fe16f25859
					
				
							
								
								
									
										13
									
								
								Thing.cpp
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								Thing.cpp
									
									
									
									
									
								
							@ -2,9 +2,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
using namespace Passer::RoboidControl;
 | 
					using namespace Passer::RoboidControl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Thing::Thing() {
 | 
					Thing::Thing() { this->type = (unsigned int)Type::Undetermined; }
 | 
				
			||||||
  this->type = (unsigned int)Type::Undetermined;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
const unsigned int Thing::SwitchType = SensorType | (unsigned int)Type::Switch;
 | 
					const unsigned int Thing::SwitchType = SensorType | (unsigned int)Type::Switch;
 | 
				
			||||||
const unsigned int Thing::DistanceSensorType =
 | 
					const unsigned int Thing::DistanceSensorType =
 | 
				
			||||||
@ -13,11 +11,8 @@ const unsigned int Thing::ControlledMotorType =
 | 
				
			|||||||
    MotorType | (unsigned int)Type::ControlledMotor;
 | 
					    MotorType | (unsigned int)Type::ControlledMotor;
 | 
				
			||||||
const unsigned int Thing::UncontrolledMotorType =
 | 
					const unsigned int Thing::UncontrolledMotorType =
 | 
				
			||||||
    MotorType | (unsigned int)Type::UncontrolledMotor;
 | 
					    MotorType | (unsigned int)Type::UncontrolledMotor;
 | 
				
			||||||
 | 
					const unsigned int Thing::ExternalType = (unsigned int)Type::ExternalSensor;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool Thing::IsMotor() {
 | 
					bool Thing::IsMotor() { return (type & Thing::MotorType) != 0; }
 | 
				
			||||||
  return (type & Thing::MotorType) != 0;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool Thing::IsSensor() {
 | 
					bool Thing::IsSensor() { return (type & Thing::SensorType) != 0; }
 | 
				
			||||||
  return (type & Thing::SensorType) != 0;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
							
								
								
									
										11
									
								
								Thing.h
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								Thing.h
									
									
									
									
									
								
							@ -5,7 +5,7 @@ namespace RoboidControl {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
/// @brief A thing is a functional component on a robot
 | 
					/// @brief A thing is a functional component on a robot
 | 
				
			||||||
class Thing {
 | 
					class Thing {
 | 
				
			||||||
 public:
 | 
					public:
 | 
				
			||||||
  /// @brief Default constructor for a Thing
 | 
					  /// @brief Default constructor for a Thing
 | 
				
			||||||
  Thing();
 | 
					  Thing();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -16,6 +16,7 @@ class Thing {
 | 
				
			|||||||
  static const unsigned int DistanceSensorType;
 | 
					  static const unsigned int DistanceSensorType;
 | 
				
			||||||
  static const unsigned int ControlledMotorType;
 | 
					  static const unsigned int ControlledMotorType;
 | 
				
			||||||
  static const unsigned int UncontrolledMotorType;
 | 
					  static const unsigned int UncontrolledMotorType;
 | 
				
			||||||
 | 
					  static const unsigned int ExternalType;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /// @brief Check if the Thing is a Motor
 | 
					  /// @brief Check if the Thing is a Motor
 | 
				
			||||||
  /// @returns True when the Thing is a Motor and False otherwise
 | 
					  /// @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
 | 
					  /// @returns True when the Thing is a Sensor and False otherwise
 | 
				
			||||||
  bool IsSensor();
 | 
					  bool IsSensor();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 protected:
 | 
					protected:
 | 
				
			||||||
  /// @brief Bitmask for Motor type
 | 
					  /// @brief Bitmask for Motor type
 | 
				
			||||||
  static const unsigned int MotorType = 0x8000;
 | 
					  static const unsigned int MotorType = 0x8000;
 | 
				
			||||||
  /// @brief Bitmap for Sensor type
 | 
					  /// @brief Bitmap for Sensor type
 | 
				
			||||||
@ -39,9 +40,11 @@ class Thing {
 | 
				
			|||||||
    // Motor,
 | 
					    // Motor,
 | 
				
			||||||
    ControlledMotor,
 | 
					    ControlledMotor,
 | 
				
			||||||
    UncontrolledMotor,
 | 
					    UncontrolledMotor,
 | 
				
			||||||
 | 
					    // Other
 | 
				
			||||||
 | 
					    ExternalSensor,
 | 
				
			||||||
  };
 | 
					  };
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}  // namespace RoboidControl
 | 
					} // namespace RoboidControl
 | 
				
			||||||
}  // namespace Passer
 | 
					} // namespace Passer
 | 
				
			||||||
using namespace Passer::RoboidControl;
 | 
					using namespace Passer::RoboidControl;
 | 
				
			||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user