28 lines
577 B
C++
28 lines
577 B
C++
#include "DistanceSensor.h"
|
|
|
|
DistanceSensor::DistanceSensor() {
|
|
this->type = Thing::DistanceSensorType;
|
|
}
|
|
|
|
DistanceSensor::DistanceSensor(float triggerDistance) {
|
|
this->triggerDistance = triggerDistance;
|
|
}
|
|
|
|
float DistanceSensor::GetDistance() {
|
|
return distance;
|
|
};
|
|
|
|
void DistanceSensor::SetDistance(float distance) {
|
|
this->distance = distance;
|
|
}; // for simulation purposes
|
|
|
|
bool DistanceSensor::IsOn() {
|
|
bool isOn = GetDistance() <= triggerDistance;
|
|
return isOn;
|
|
}
|
|
|
|
bool DistanceSensor::isOff() {
|
|
bool isOff = GetDistance() > triggerDistance;
|
|
return isOff;
|
|
}
|