cmvr-es/include/devices/abstract_device.h

42 lines
1014 B
C++

//
// Created by xtkuang on 2025/5/6.
//
#ifndef CMVR_ES_ABSTRACT_DEVICES_H
#define CMVR_ES_ABSTRACT_DEVICES_H
#include <thread>
#include <jsoncpp/json/json.h>
#include "rapidxml/xml_parser.h"
#include "state_define.h"
#pragma warning(disable:4996)
#define GLOG_USE_GLOG_EXPORT
#include <glog/logging.h>
namespace cmvr::device {
class AbstractDevice {
public:
explicit AbstractDevice(const XmlNode& config) {cfg_ = config;}
virtual ~AbstractDevice() = default;
[[maybe_unused]] XmlNode getConfig() {return cfg_;}
virtual void getState() {}
virtual void init() {}
virtual void start() {}
virtual void stop() {}
virtual void update() {}
virtual void updateParams(const std::pair<std::string, std::string>& param) {}
virtual void customCommand(const Json::Value &cmd, Json::Value &feedback) {}
protected:
XmlNode cfg_;
std::string id_; // 设备名称
};
}
#endif //CMVR_ES_ABSTRACT_DEVICES_H