src.dualinventive.com/jjacobs/dinetrpcll-sniffer/libdipp/include/di/rpc/class/Sensor.h

63 lines
1.5 KiB
C++

#ifndef INCLUDE_DI_RPC_CLASS_SENSOR_H_
#define INCLUDE_DI_RPC_CLASS_SENSOR_H_
#include <vector>
#include <string>
#include <di/Json.h>
#include <di/rpc/Msg.h>
namespace Di {
namespace Rpc {
class Sensor : public Msg {
public:
enum Type {
SENSOR_TYPE_UNKNOWN,
SENSOR_TYPE_STRING,
SENSOR_TYPE_NUMBER,
SENSOR_TYPE_DOUBLE,
SENSOR_TYPE_BOOL,
SENSOR_TYPE_OBJECT
};
struct sensorInfo {
unsigned int id;
std::string label;
std::string type;
};
struct sensorData {
unsigned int id;
uint64_t time;
Type type;
std::shared_ptr<Json> value;
};
std::vector<sensorInfo> sensorInfoList;
std::vector<sensorData> sensorDataList;
explicit Sensor(std::shared_ptr<Msg> msg);
static std::string getStringValue(const struct sensorData &message);
static int64_t getNumberValue(const struct sensorData &message);
static double getDoubleValue(const struct sensorData &message);
static bool getBoolValue(const struct sensorData &message);
static std::shared_ptr<Json> getObjectValue(const struct sensorData &message);
private:
void __decodePublish(std::shared_ptr<Json> message);
void __decodeMethodInfo(std::shared_ptr<Json> message);
unsigned int __getID(std::shared_ptr<Json> message);
uint64_t __getTime(std::shared_ptr<Json> message);
std::string __getType(std::shared_ptr<Json> message);
std::string __getLabel(std::shared_ptr<Json> message);
std::string __getDescr(std::shared_ptr<Json> message);
};
} // namespace Rpc
} // namespace Di
#endif // INCLUDE_DI_RPC_CLASS_SENSOR_H_