Added temperature type
This commit is contained in:
parent
2d83c0296b
commit
1f85c6cc4b
@ -224,7 +224,7 @@ void NetworkSync::BroadcastPerception(Roboid *roboid) {
|
|||||||
if (perception == nullptr)
|
if (perception == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (int sensorIx = 0; sensorIx < perception->sensorCount; sensorIx++) {
|
for (unsigned int sensorIx = 0; sensorIx < perception->sensorCount; sensorIx++) {
|
||||||
Sensor* sensor = perception->sensors[sensorIx];
|
Sensor* sensor = perception->sensors[sensorIx];
|
||||||
if (sensor == nullptr)
|
if (sensor == nullptr)
|
||||||
continue;
|
continue;
|
||||||
@ -362,7 +362,7 @@ void NetworkSync::SendText(const char* s) {
|
|||||||
if (length >= 253)
|
if (length >= 253)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
unsigned char ix;
|
unsigned char ix = 0;
|
||||||
buffer[ix++] = 0xB0;
|
buffer[ix++] = 0xB0;
|
||||||
buffer[ix++] = length;
|
buffer[ix++] = length;
|
||||||
for (int urlIx = 0; urlIx < length; urlIx++)
|
for (int urlIx = 0; urlIx < length; urlIx++)
|
||||||
@ -375,7 +375,7 @@ void NetworkSync::SendInt(const int x) {
|
|||||||
String s = String(x);
|
String s = String(x);
|
||||||
byte length = s.length();
|
byte length = s.length();
|
||||||
|
|
||||||
unsigned char ix;
|
unsigned char ix = 0;
|
||||||
buffer[ix++] = 0xB0;
|
buffer[ix++] = 0xB0;
|
||||||
buffer[ix++] = length;
|
buffer[ix++] = length;
|
||||||
for (int urlIx = 0; urlIx < length; urlIx++)
|
for (int urlIx = 0; urlIx < length; urlIx++)
|
||||||
|
4
Sensor.h
4
Sensor.h
@ -17,10 +17,6 @@ public:
|
|||||||
|
|
||||||
virtual void BroadcastState() {};
|
virtual void BroadcastState() {};
|
||||||
|
|
||||||
enum SensorType {
|
|
||||||
Unknown = 0,
|
|
||||||
Temperature = 1,
|
|
||||||
};
|
|
||||||
virtual void* GetValue() { return nullptr; };
|
virtual void* GetValue() { return nullptr; };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
TemperatureSensor::TemperatureSensor()
|
TemperatureSensor::TemperatureSensor()
|
||||||
{
|
{
|
||||||
this->type = (unsigned int) SensorType::Temperature;
|
this->type = Thing::TemperatureSensorType;
|
||||||
}
|
}
|
||||||
|
|
||||||
float TemperatureSensor::InCelsius()
|
float TemperatureSensor::InCelsius()
|
||||||
|
@ -11,7 +11,6 @@ public:
|
|||||||
|
|
||||||
float InCelsius();
|
float InCelsius();
|
||||||
virtual void* GetValue() override;
|
virtual void* GetValue() override;
|
||||||
// virtual void BroadcastState() override;
|
|
||||||
protected:
|
protected:
|
||||||
float temperature = 0; // in Celsius
|
float temperature = 0; // in Celsius
|
||||||
};
|
};
|
||||||
|
@ -13,6 +13,9 @@ Thing::Thing(unsigned char id) : id(id) {
|
|||||||
const unsigned int Thing::SwitchType = SensorType | (unsigned int)Type::Switch;
|
const unsigned int Thing::SwitchType = SensorType | (unsigned int)Type::Switch;
|
||||||
const unsigned int Thing::DistanceSensorType =
|
const unsigned int Thing::DistanceSensorType =
|
||||||
SensorType | (unsigned int)Type::DistanceSensor;
|
SensorType | (unsigned int)Type::DistanceSensor;
|
||||||
|
const unsigned int Thing::TemperatureSensorType =
|
||||||
|
SensorType | (unsigned int)Type::TemperatureSensor;
|
||||||
|
|
||||||
const unsigned int Thing::ControlledMotorType =
|
const unsigned int Thing::ControlledMotorType =
|
||||||
MotorType | (unsigned int)Type::ControlledMotor;
|
MotorType | (unsigned int)Type::ControlledMotor;
|
||||||
const unsigned int Thing::UncontrolledMotorType =
|
const unsigned int Thing::UncontrolledMotorType =
|
||||||
|
5
Thing.h
5
Thing.h
@ -1,6 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// #include "LinearAlgebra/Polar.h"
|
|
||||||
#include "LinearAlgebra/Quaternion.h"
|
#include "LinearAlgebra/Quaternion.h"
|
||||||
#include "LinearAlgebra/Spherical.h"
|
#include "LinearAlgebra/Spherical.h"
|
||||||
|
|
||||||
@ -18,10 +17,13 @@ class Thing {
|
|||||||
/// @brief The type of Thing
|
/// @brief The type of Thing
|
||||||
unsigned int type;
|
unsigned int type;
|
||||||
|
|
||||||
|
// I hate this, better is to have an additional field stating the thing classificaton
|
||||||
|
// Motor, Sensor etc.
|
||||||
/// @brief The type of a switch sensor
|
/// @brief The type of a switch sensor
|
||||||
static const unsigned int SwitchType;
|
static const unsigned int SwitchType;
|
||||||
/// @brief The type of a distance sensor
|
/// @brief The type of a distance sensor
|
||||||
static const unsigned int DistanceSensorType;
|
static const unsigned int DistanceSensorType;
|
||||||
|
static const unsigned int TemperatureSensorType;
|
||||||
/// @brief The type of a controlled motor
|
/// @brief The type of a controlled motor
|
||||||
static const unsigned int ControlledMotorType;
|
static const unsigned int ControlledMotorType;
|
||||||
/// @brief The type of an uncontrolled motor
|
/// @brief The type of an uncontrolled motor
|
||||||
@ -96,6 +98,7 @@ class Thing {
|
|||||||
// Sensor,
|
// Sensor,
|
||||||
Switch,
|
Switch,
|
||||||
DistanceSensor,
|
DistanceSensor,
|
||||||
|
TemperatureSensor,
|
||||||
// Motor,
|
// Motor,
|
||||||
ControlledMotor,
|
ControlledMotor,
|
||||||
UncontrolledMotor,
|
UncontrolledMotor,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user