Added temperature type

This commit is contained in:
Pascal Serrarens 2024-09-07 17:43:07 +02:00
parent 2d83c0296b
commit 1f85c6cc4b
6 changed files with 11 additions and 10 deletions

View File

@ -224,7 +224,7 @@ void NetworkSync::BroadcastPerception(Roboid *roboid) {
if (perception == nullptr)
return;
for (int sensorIx = 0; sensorIx < perception->sensorCount; sensorIx++) {
for (unsigned int sensorIx = 0; sensorIx < perception->sensorCount; sensorIx++) {
Sensor* sensor = perception->sensors[sensorIx];
if (sensor == nullptr)
continue;
@ -362,7 +362,7 @@ void NetworkSync::SendText(const char* s) {
if (length >= 253)
return;
unsigned char ix;
unsigned char ix = 0;
buffer[ix++] = 0xB0;
buffer[ix++] = length;
for (int urlIx = 0; urlIx < length; urlIx++)
@ -375,7 +375,7 @@ void NetworkSync::SendInt(const int x) {
String s = String(x);
byte length = s.length();
unsigned char ix;
unsigned char ix = 0;
buffer[ix++] = 0xB0;
buffer[ix++] = length;
for (int urlIx = 0; urlIx < length; urlIx++)

View File

@ -17,10 +17,6 @@ public:
virtual void BroadcastState() {};
enum SensorType {
Unknown = 0,
Temperature = 1,
};
virtual void* GetValue() { return nullptr; };
};

View File

@ -2,7 +2,7 @@
TemperatureSensor::TemperatureSensor()
{
this->type = (unsigned int) SensorType::Temperature;
this->type = Thing::TemperatureSensorType;
}
float TemperatureSensor::InCelsius()

View File

@ -11,7 +11,6 @@ public:
float InCelsius();
virtual void* GetValue() override;
// virtual void BroadcastState() override;
protected:
float temperature = 0; // in Celsius
};

View File

@ -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::DistanceSensorType =
SensorType | (unsigned int)Type::DistanceSensor;
const unsigned int Thing::TemperatureSensorType =
SensorType | (unsigned int)Type::TemperatureSensor;
const unsigned int Thing::ControlledMotorType =
MotorType | (unsigned int)Type::ControlledMotor;
const unsigned int Thing::UncontrolledMotorType =

View File

@ -1,6 +1,5 @@
#pragma once
// #include "LinearAlgebra/Polar.h"
#include "LinearAlgebra/Quaternion.h"
#include "LinearAlgebra/Spherical.h"
@ -18,10 +17,13 @@ class Thing {
/// @brief The type of Thing
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
static const unsigned int SwitchType;
/// @brief The type of a distance sensor
static const unsigned int DistanceSensorType;
static const unsigned int TemperatureSensorType;
/// @brief The type of a controlled motor
static const unsigned int ControlledMotorType;
/// @brief The type of an uncontrolled motor
@ -96,6 +98,7 @@ class Thing {
// Sensor,
Switch,
DistanceSensor,
TemperatureSensor,
// Motor,
ControlledMotor,
UncontrolledMotor,