Removed reconstruct thing and thingtype in constructor
This commit is contained in:
parent
2883f5e0fa
commit
57cf14b487
11
Thing.cpp
11
Thing.cpp
@ -47,9 +47,9 @@ namespace RoboidControl
|
|||||||
//std::cout << this->owner->name << ": New root thing " << std::endl;
|
//std::cout << this->owner->name << ": New root thing " << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
Thing::Thing(unsigned char thingType, Thing *parent)
|
Thing::Thing(Thing *parent)
|
||||||
{
|
{
|
||||||
this->type = thingType;
|
this->type = Type::Undetermined;
|
||||||
|
|
||||||
this->position = Spherical::zero;
|
this->position = Spherical::zero;
|
||||||
this->positionUpdated = true;
|
this->positionUpdated = true;
|
||||||
@ -73,13 +73,6 @@ namespace RoboidControl
|
|||||||
std::cout << "Destroy thing " << this->name << std::endl;
|
std::cout << "Destroy thing " << this->name << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
Thing Thing::Reconstruct(Participant *owner, unsigned char thingType, unsigned char thingId)
|
|
||||||
{
|
|
||||||
Thing thing = Thing(thingType, owner->root);
|
|
||||||
thing.id = thingId;
|
|
||||||
return thing;
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma endregion Init
|
#pragma endregion Init
|
||||||
|
|
||||||
void Thing::SetName(const char *name)
|
void Thing::SetName(const char *name)
|
||||||
|
7
Thing.h
7
Thing.h
@ -58,8 +58,7 @@ class Thing {
|
|||||||
/// The owner will be the same as the owner of the parent thing, it will
|
/// The owner will be the same as the owner of the parent thing, it will
|
||||||
/// be Participant::LocalParticipant if the parent is not specified. A thing
|
/// be Participant::LocalParticipant if the parent is not specified. A thing
|
||||||
/// without a parent will be a root thing.
|
/// without a parent will be a root thing.
|
||||||
Thing(unsigned char thingType = Thing::Type::Undetermined,
|
Thing(Thing* parent = LocalRoot());
|
||||||
Thing* parent = LocalRoot());
|
|
||||||
|
|
||||||
/// @brief Create a new child thing
|
/// @brief Create a new child thing
|
||||||
/// @param parent The parent thing
|
/// @param parent The parent thing
|
||||||
@ -70,10 +69,6 @@ class Thing {
|
|||||||
|
|
||||||
~Thing();
|
~Thing();
|
||||||
|
|
||||||
static Thing Reconstruct(Participant* owner,
|
|
||||||
unsigned char thingType,
|
|
||||||
unsigned char thingId);
|
|
||||||
|
|
||||||
#pragma endregion Init
|
#pragma endregion Init
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
|
|
||||||
namespace RoboidControl {
|
namespace RoboidControl {
|
||||||
|
|
||||||
DifferentialDrive::DifferentialDrive(Thing* parent)
|
DifferentialDrive::DifferentialDrive(Thing* parent) : Thing(parent) {
|
||||||
: Thing(Type::DifferentialDrive, parent) {
|
this->type = Type::DifferentialDrive;
|
||||||
this->name = "Differential drive";
|
this->name = "Differential drive";
|
||||||
|
|
||||||
this->leftWheel = new Motor(this);
|
this->leftWheel = new Motor(this);
|
||||||
@ -18,7 +18,8 @@ DifferentialDrive::DifferentialDrive(Thing* parent)
|
|||||||
DifferentialDrive::DifferentialDrive(Motor* leftMotor,
|
DifferentialDrive::DifferentialDrive(Motor* leftMotor,
|
||||||
Motor* rightMotor,
|
Motor* rightMotor,
|
||||||
Thing* parent)
|
Thing* parent)
|
||||||
: Thing(Type::DifferentialDrive, parent) {
|
: Thing(parent) {
|
||||||
|
this->type = Type::DifferentialDrive;
|
||||||
this->name = "Differential drive";
|
this->name = "Differential drive";
|
||||||
this->leftWheel = leftMotor;
|
this->leftWheel = leftMotor;
|
||||||
this->rightWheel = rightMotor;
|
this->rightWheel = rightMotor;
|
||||||
|
@ -2,18 +2,9 @@
|
|||||||
|
|
||||||
namespace RoboidControl {
|
namespace RoboidControl {
|
||||||
|
|
||||||
//DigitalSensor::DigitalSensor() : Thing(Type::Switch) {}
|
DigitalSensor::DigitalSensor(Thing* parent) : Thing(parent) {
|
||||||
|
this->type = Type::Switch;
|
||||||
// DigitalSensor::DigitalSensor(Participant* owner, unsigned char thingId)
|
}
|
||||||
// : Thing(owner, Type::Switch, thingId) {}
|
|
||||||
|
|
||||||
// DigitalSensor::DigitalSensor(Thing* parent, unsigned char thingId)
|
|
||||||
// : Thing(parent, Type::Switch) {}
|
|
||||||
|
|
||||||
// DigitalSensor::DigitalSensor(Participant* owner) : Thing(owner, Type::Switch) {}
|
|
||||||
|
|
||||||
// DigitalSensor::DigitalSensor(Thing* parent) : Thing(parent, Type::Switch) {}
|
|
||||||
DigitalSensor::DigitalSensor(Thing* parent) : Thing(Type::Switch, parent) {}
|
|
||||||
|
|
||||||
int DigitalSensor::GenerateBinary(char* bytes, unsigned char* ix) {
|
int DigitalSensor::GenerateBinary(char* bytes, unsigned char* ix) {
|
||||||
bytes[(*ix)++] = state ? 1 : 0;
|
bytes[(*ix)++] = state ? 1 : 0;
|
||||||
|
@ -2,7 +2,9 @@
|
|||||||
|
|
||||||
namespace RoboidControl {
|
namespace RoboidControl {
|
||||||
|
|
||||||
Motor::Motor(Thing* parent) : Thing(Type::UncontrolledMotor, parent) {}
|
Motor::Motor(Thing* parent) : Thing(parent) {
|
||||||
|
this->type = Type::UncontrolledMotor;
|
||||||
|
}
|
||||||
|
|
||||||
void Motor::SetTargetVelocity(float targetSpeed) {
|
void Motor::SetTargetVelocity(float targetSpeed) {
|
||||||
this->targetVelocity = targetSpeed;
|
this->targetVelocity = targetSpeed;
|
||||||
|
@ -2,8 +2,9 @@
|
|||||||
|
|
||||||
namespace RoboidControl {
|
namespace RoboidControl {
|
||||||
|
|
||||||
RelativeEncoder::RelativeEncoder(Thing* parent)
|
RelativeEncoder::RelativeEncoder(Thing* parent) : Thing(parent) {
|
||||||
: Thing(Type::IncrementalEncoder, parent) {}
|
this->type = Type::IncrementalEncoder;
|
||||||
|
}
|
||||||
|
|
||||||
float RelativeEncoder::GetRotationSpeed() {
|
float RelativeEncoder::GetRotationSpeed() {
|
||||||
return rotationSpeed;
|
return rotationSpeed;
|
||||||
|
@ -4,15 +4,9 @@
|
|||||||
|
|
||||||
namespace RoboidControl {
|
namespace RoboidControl {
|
||||||
|
|
||||||
// TemperatureSensor::TemperatureSensor(Participant* participant,
|
TemperatureSensor::TemperatureSensor(Thing* parent) : Thing(parent) {
|
||||||
// unsigned char thingId)
|
this->type = Type::TemperatureSensor;
|
||||||
// : Thing(participant, Type::TemperatureSensor, thingId) {}
|
}
|
||||||
|
|
||||||
// TemperatureSensor::TemperatureSensor(Participant* owner) : Thing(owner, Type::TemperatureSensor) {}
|
|
||||||
|
|
||||||
TemperatureSensor::TemperatureSensor(Thing* parent) : Thing(Type::TemperatureSensor, parent) {}
|
|
||||||
|
|
||||||
// TemperatureSensor::TemperatureSensor(Thing* parent) : Thing(parent, Type::TemperatureSensor) {}
|
|
||||||
|
|
||||||
void TemperatureSensor::SetTemperature(float temp) {
|
void TemperatureSensor::SetTemperature(float temp) {
|
||||||
this->temperature = temp;
|
this->temperature = temp;
|
||||||
|
@ -2,7 +2,8 @@
|
|||||||
|
|
||||||
namespace RoboidControl {
|
namespace RoboidControl {
|
||||||
|
|
||||||
TouchSensor::TouchSensor(Thing* parent) : Thing(Type::TouchSensor, parent) {
|
TouchSensor::TouchSensor(Thing* parent) : Thing(parent) {
|
||||||
|
this->type = Type::TouchSensor;
|
||||||
this->name = "Touch sensor";
|
this->name = "Touch sensor";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user