Proof-of-concept works
This commit is contained in:
parent
8338e2f5cd
commit
1d89b5401d
@ -36,6 +36,8 @@ ModelUrlMsg::ModelUrlMsg(unsigned char networkId, Thing *thing) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
unsigned char ModelUrlMsg::Serialize(char *buffer) {
|
unsigned char ModelUrlMsg::Serialize(char *buffer) {
|
||||||
|
if (this->urlLength == 0 || this->url == nullptr)
|
||||||
|
return 0;
|
||||||
unsigned char ix = 0;
|
unsigned char ix = 0;
|
||||||
buffer[ix++] = this->id;
|
buffer[ix++] = this->id;
|
||||||
buffer[ix++] = this->networkId;
|
buffer[ix++] = this->networkId;
|
||||||
|
@ -33,6 +33,9 @@ NameMsg::NameMsg(unsigned char networkId, Thing *thing) {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
unsigned char NameMsg::Serialize(char *buffer) {
|
unsigned char NameMsg::Serialize(char *buffer) {
|
||||||
|
if (this->nameLength == 0 || this->name == nullptr)
|
||||||
|
return 0;
|
||||||
|
|
||||||
unsigned char ix = 0;
|
unsigned char ix = 0;
|
||||||
buffer[ix++] = this->id;
|
buffer[ix++] = this->id;
|
||||||
buffer[ix++] = this->networkId;
|
buffer[ix++] = this->networkId;
|
||||||
|
@ -6,12 +6,14 @@
|
|||||||
#include <list>
|
#include <list>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
Thing::Thing(unsigned char networkId, unsigned char thingType) {
|
Thing::Thing(Type thingType) : Thing((unsigned char)thingType) {}
|
||||||
|
|
||||||
|
Thing::Thing(unsigned char thingType) {
|
||||||
// this->position = Spherical16::zero;
|
// this->position = Spherical16::zero;
|
||||||
// this->orientation = SwingTwist16::identity;
|
// this->orientation = SwingTwist16::identity;
|
||||||
|
|
||||||
this->type = thingType;
|
this->type = thingType;
|
||||||
this->networkId = networkId;
|
this->networkId = 0;
|
||||||
this->Init();
|
this->Init();
|
||||||
|
|
||||||
int thingId = Thing::Add(this);
|
int thingId = Thing::Add(this);
|
||||||
|
51
Thing.h
51
Thing.h
@ -19,6 +19,27 @@ public:
|
|||||||
/// @char The id of the thing
|
/// @char The id of the thing
|
||||||
unsigned char id = 0;
|
unsigned char id = 0;
|
||||||
|
|
||||||
|
/// @brief Basic Thing types
|
||||||
|
enum class Type {
|
||||||
|
Undetermined,
|
||||||
|
// Sensor,
|
||||||
|
Switch,
|
||||||
|
DistanceSensor,
|
||||||
|
DirectionalSensor,
|
||||||
|
TemperatureSensor,
|
||||||
|
// Motor,
|
||||||
|
ControlledMotor,
|
||||||
|
UncontrolledMotor,
|
||||||
|
Servo,
|
||||||
|
// Other
|
||||||
|
Roboid,
|
||||||
|
Humanoid,
|
||||||
|
ExternalSensor,
|
||||||
|
};
|
||||||
|
|
||||||
|
Thing(Type thingType = Type::Undetermined);
|
||||||
|
Thing(unsigned char thingType);
|
||||||
|
|
||||||
Thing *FindThing(const char *name);
|
Thing *FindThing(const char *name);
|
||||||
// Thing *FindChild(unsigned char id);
|
// Thing *FindChild(unsigned char id);
|
||||||
|
|
||||||
@ -53,24 +74,6 @@ public:
|
|||||||
float modelScale = 1;
|
float modelScale = 1;
|
||||||
// protected Sensor sensor;
|
// protected Sensor sensor;
|
||||||
|
|
||||||
/// @brief Basic Thing types
|
|
||||||
enum class Type {
|
|
||||||
Undetermined,
|
|
||||||
// Sensor,
|
|
||||||
Switch,
|
|
||||||
DistanceSensor,
|
|
||||||
DirectionalSensor,
|
|
||||||
TemperatureSensor,
|
|
||||||
// Motor,
|
|
||||||
ControlledMotor,
|
|
||||||
UncontrolledMotor,
|
|
||||||
Servo,
|
|
||||||
// Other
|
|
||||||
Roboid,
|
|
||||||
Humanoid,
|
|
||||||
ExternalSensor,
|
|
||||||
};
|
|
||||||
|
|
||||||
void SetPosition(Spherical16 position);
|
void SetPosition(Spherical16 position);
|
||||||
Spherical16 GetPosition();
|
Spherical16 GetPosition();
|
||||||
void SetOrientation(SwingTwist16 orientation);
|
void SetOrientation(SwingTwist16 orientation);
|
||||||
@ -97,8 +100,6 @@ public:
|
|||||||
virtual Spherical16 GetAngularVelocity();
|
virtual Spherical16 GetAngularVelocity();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Thing(unsigned char networkId = 0,
|
|
||||||
unsigned char thingType = (unsigned char)Type::Undetermined);
|
|
||||||
/// @brief Terminated thins are no longer updated
|
/// @brief Terminated thins are no longer updated
|
||||||
void Terminate();
|
void Terminate();
|
||||||
|
|
||||||
@ -111,13 +112,13 @@ public:
|
|||||||
|
|
||||||
/// @brief Updates the state of the thing
|
/// @brief Updates the state of the thing
|
||||||
/// @param currentTimeMs The current clock time in milliseconds
|
/// @param currentTimeMs The current clock time in milliseconds
|
||||||
virtual void Update(unsigned long currentTimeMs) { currentTimeMs; };
|
virtual void Update(unsigned long currentTimeMs) { (void)currentTimeMs; };
|
||||||
|
|
||||||
virtual void SendBytes(char *buffer, unsigned char *ix) {
|
virtual void SendBytes(char *buffer, unsigned char *ix) {
|
||||||
buffer;
|
(void)buffer;
|
||||||
ix;
|
(void)ix;
|
||||||
};
|
};
|
||||||
virtual void ProcessBytes(char *bytes) { bytes; };
|
virtual void ProcessBytes(char *bytes) { (void)bytes; };
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void Init();
|
virtual void Init();
|
||||||
@ -130,7 +131,7 @@ public:
|
|||||||
static void Remove(Thing *thing);
|
static void Remove(Thing *thing);
|
||||||
static void UpdateAll(unsigned long currentTimeMs);
|
static void UpdateAll(unsigned long currentTimeMs);
|
||||||
|
|
||||||
//private:
|
// private:
|
||||||
// static Thing *allThings[];
|
// static Thing *allThings[];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user