Removed reconstruct thing and thingtype in constructor

This commit is contained in:
Pascal Serrarens 2025-06-02 12:35:53 +02:00
parent 2883f5e0fa
commit 57cf14b487
8 changed files with 21 additions and 43 deletions

View File

@ -47,9 +47,9 @@ namespace RoboidControl
//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->positionUpdated = true;
@ -73,13 +73,6 @@ namespace RoboidControl
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
void Thing::SetName(const char *name)

View File

@ -58,8 +58,7 @@ class Thing {
/// 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
/// without a parent will be a root thing.
Thing(unsigned char thingType = Thing::Type::Undetermined,
Thing* parent = LocalRoot());
Thing(Thing* parent = LocalRoot());
/// @brief Create a new child thing
/// @param parent The parent thing
@ -70,10 +69,6 @@ class Thing {
~Thing();
static Thing Reconstruct(Participant* owner,
unsigned char thingType,
unsigned char thingId);
#pragma endregion Init
public:

View File

@ -4,8 +4,8 @@
namespace RoboidControl {
DifferentialDrive::DifferentialDrive(Thing* parent)
: Thing(Type::DifferentialDrive, parent) {
DifferentialDrive::DifferentialDrive(Thing* parent) : Thing(parent) {
this->type = Type::DifferentialDrive;
this->name = "Differential drive";
this->leftWheel = new Motor(this);
@ -18,7 +18,8 @@ DifferentialDrive::DifferentialDrive(Thing* parent)
DifferentialDrive::DifferentialDrive(Motor* leftMotor,
Motor* rightMotor,
Thing* parent)
: Thing(Type::DifferentialDrive, parent) {
: Thing(parent) {
this->type = Type::DifferentialDrive;
this->name = "Differential drive";
this->leftWheel = leftMotor;
this->rightWheel = rightMotor;

View File

@ -2,18 +2,9 @@
namespace RoboidControl {
//DigitalSensor::DigitalSensor() : Thing(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) {}
DigitalSensor::DigitalSensor(Thing* parent) : Thing(parent) {
this->type = Type::Switch;
}
int DigitalSensor::GenerateBinary(char* bytes, unsigned char* ix) {
bytes[(*ix)++] = state ? 1 : 0;

View File

@ -2,7 +2,9 @@
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) {
this->targetVelocity = targetSpeed;

View File

@ -2,8 +2,9 @@
namespace RoboidControl {
RelativeEncoder::RelativeEncoder(Thing* parent)
: Thing(Type::IncrementalEncoder, parent) {}
RelativeEncoder::RelativeEncoder(Thing* parent) : Thing(parent) {
this->type = Type::IncrementalEncoder;
}
float RelativeEncoder::GetRotationSpeed() {
return rotationSpeed;

View File

@ -4,15 +4,9 @@
namespace RoboidControl {
// TemperatureSensor::TemperatureSensor(Participant* participant,
// unsigned char thingId)
// : 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) {}
TemperatureSensor::TemperatureSensor(Thing* parent) : Thing(parent) {
this->type = Type::TemperatureSensor;
}
void TemperatureSensor::SetTemperature(float temp) {
this->temperature = temp;

View File

@ -2,7 +2,8 @@
namespace RoboidControl {
TouchSensor::TouchSensor(Thing* parent) : Thing(Type::TouchSensor, parent) {
TouchSensor::TouchSensor(Thing* parent) : Thing(parent) {
this->type = Type::TouchSensor;
this->name = "Touch sensor";
}