Extended use of CoreThing
This commit is contained in:
parent
66c4b4ca7a
commit
7bcd80087a
@ -8,31 +8,31 @@ CoreThing::CoreThing(
|
|||||||
this->type = thingType;
|
this->type = thingType;
|
||||||
this->networkId = networkId;
|
this->networkId = networkId;
|
||||||
this->Init();
|
this->Init();
|
||||||
// CoreThings::Add(this);
|
CoreThing::Add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CoreThing::Init() {}
|
void CoreThing::Init() {}
|
||||||
|
|
||||||
// CoreThing *CoreThings::allThings[256] = {nullptr};
|
CoreThing *CoreThing::allThings[256] = {nullptr};
|
||||||
|
|
||||||
// CoreThing *CoreThings::Get(unsigned char networkId, unsigned char thingId) {
|
CoreThing *CoreThing::Get(unsigned char networkId, unsigned char thingId) {
|
||||||
// for (unsigned char ix = 0; ix < 256; ix++) {
|
for (unsigned char ix = 0; ix < 256; ix++) {
|
||||||
// CoreThing *thing = allThings[ix];
|
CoreThing *thing = allThings[ix];
|
||||||
// if (thing == nullptr)
|
if (thing == nullptr)
|
||||||
// continue;
|
continue;
|
||||||
// if (thing->networkId == networkId && thing->id == thingId)
|
if (thing->networkId == networkId && thing->id == thingId)
|
||||||
// return thing;
|
return thing;
|
||||||
// }
|
}
|
||||||
// return nullptr;
|
return nullptr;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// bool CoreThings::Add(CoreThing *newThing) {
|
bool CoreThing::Add(CoreThing *newThing) {
|
||||||
// for (unsigned char ix = 0; ix < 256; ix++) {
|
for (unsigned char ix = 0; ix < 256; ix++) {
|
||||||
// CoreThing *thing = allThings[ix];
|
CoreThing *thing = allThings[ix];
|
||||||
// if (thing == nullptr) {
|
if (thing == nullptr) {
|
||||||
// allThings[ix] = newThing;
|
allThings[ix] = newThing;
|
||||||
// return true;
|
return true;
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// return false;
|
return false;
|
||||||
// }
|
}
|
@ -15,27 +15,19 @@ public:
|
|||||||
const char *modelUrl;
|
const char *modelUrl;
|
||||||
// protected Sensor sensor;
|
// protected Sensor sensor;
|
||||||
|
|
||||||
|
static CoreThing *allThings[];
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CoreThing(
|
CoreThing(
|
||||||
// Participant *client,
|
// Participant *client,
|
||||||
unsigned char networkId, unsigned char thingId,
|
unsigned char networkId, unsigned char thingId,
|
||||||
unsigned char thingType = 0);
|
unsigned char thingType = 0);
|
||||||
|
|
||||||
|
static CoreThing *Get(unsigned char networkId, unsigned char thingId);
|
||||||
|
static bool Add(CoreThing *thing);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void Init();
|
virtual void Init();
|
||||||
|
|
||||||
// Things
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// class CoreThings {
|
|
||||||
// friend class CoreThing;
|
|
||||||
|
|
||||||
// public:
|
|
||||||
// static CoreThing *allThings[];
|
|
||||||
|
|
||||||
// public:
|
|
||||||
// static CoreThing *Get(unsigned char networkId, unsigned char thingId);
|
|
||||||
// static bool Add(CoreThing *thing);
|
|
||||||
// };
|
|
||||||
|
|
||||||
} // namespace Passer::Control
|
} // namespace Passer::Control
|
||||||
|
10
Thing.cpp
10
Thing.cpp
@ -6,8 +6,8 @@ using namespace Passer::RoboidControl;
|
|||||||
|
|
||||||
int Thing::lastThingId = 1;
|
int Thing::lastThingId = 1;
|
||||||
|
|
||||||
Thing::Thing() {
|
Thing::Thing()
|
||||||
//: CoreThing(0, lastThingId++, (unsigned char)Type::Undetermined) {
|
: CoreThing(0, lastThingId++, (unsigned char)Type::Undetermined) {
|
||||||
this->id = lastThingId++;
|
this->id = lastThingId++;
|
||||||
this->type = (unsigned int)Type::Undetermined;
|
this->type = (unsigned int)Type::Undetermined;
|
||||||
this->childCount = 0;
|
this->childCount = 0;
|
||||||
@ -15,14 +15,14 @@ Thing::Thing() {
|
|||||||
this->children = nullptr;
|
this->children = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Thing::Thing(unsigned char id) {
|
Thing::Thing(unsigned char id)
|
||||||
//: CoreThing(0, id, (unsigned char)Type::Undetermined) {
|
: CoreThing(0, id, (unsigned char)Type::Undetermined) {
|
||||||
this->id = id;
|
this->id = id;
|
||||||
// this->position = SphericalOf<signed short>::zero;
|
|
||||||
this->type = (unsigned int)Type::Undetermined;
|
this->type = (unsigned int)Type::Undetermined;
|
||||||
this->childCount = 0;
|
this->childCount = 0;
|
||||||
this->parent = nullptr;
|
this->parent = nullptr;
|
||||||
this->children = nullptr;
|
this->children = nullptr;
|
||||||
|
// this->position = SphericalOf<signed short>::zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Thing::SetName(const char *name) { this->name = name; }
|
void Thing::SetName(const char *name) { this->name = name; }
|
||||||
|
2
Thing.h
2
Thing.h
@ -10,7 +10,7 @@ namespace Passer {
|
|||||||
namespace RoboidControl {
|
namespace RoboidControl {
|
||||||
|
|
||||||
/// @brief A thing is a functional component on a robot
|
/// @brief A thing is a functional component on a robot
|
||||||
class Thing { //: public CoreThing {
|
class Thing : public CoreThing {
|
||||||
public:
|
public:
|
||||||
Thing();
|
Thing();
|
||||||
/// @brief Default constructor for a Thing
|
/// @brief Default constructor for a Thing
|
||||||
|
Loading…
x
Reference in New Issue
Block a user