#pragma once #include #include #include #include #include "data/Data.h" /* * 结构类型数据 *TorqueMode * */ // 扭矩参数 class TorqueModeParam { public: TorqueModeParam(std::string name, int value, unsigned short valueAmpere) : m_name(name), m_value(value),m_valueAmpere(valueAmpere) {}; virtual ~TorqueModeParam() {}; std::string getName() { return m_name; } int getValue() { return m_value; } unsigned short getValueAmpere() { return m_valueAmpere; } private: const std::string m_name; const int m_value; const unsigned short m_valueAmpere; }; typedef struct { std::list datas; }TorqueModeParam_t; class TorqueModeStructData : public Data { public: TorqueModeStructData(); TorqueModeStructData(TorqueModeParam_t *data); virtual ~TorqueModeStructData() {}; Data* clone() override; void copy(Data* data) override; void copy(Data& data) override; int length() override; // 转换为字符串格式 virtual std::string toStr() override; // 转换为Byte字符串 virtual std::string toByteStr() override; // 转换为十六进制字符串 virtual std::string toHexStr() override; // 根据Byte字符串解析数据 virtual bool fromByteStr(std::string str = "") override; TorqueModeParam_t& getData() { return m_data; } void setData(TorqueModeParam_t& data); // void setType(int type) { m_type = type; } // int getType() { return m_type; } private: const int m_prefixLength; TorqueModeParam_t m_data; };