|
|
|
|
#include "AngleModeStructData.h"
|
|
|
|
|
#include <sstream>
|
|
|
|
|
#include <iomanip>
|
|
|
|
|
#include <ctime>
|
|
|
|
|
|
|
|
|
|
#include "Utils.h"
|
|
|
|
|
|
|
|
|
|
AngleModeStructData::AngleModeStructData()
|
|
|
|
|
: m_data(0)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AngleModeStructData::AngleModeStructData(std::list<short> data)
|
|
|
|
|
{
|
|
|
|
|
m_data = data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Data* AngleModeStructData::clone()
|
|
|
|
|
{
|
|
|
|
|
Data* data = new AngleModeStructData(m_data);
|
|
|
|
|
return data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AngleModeStructData::copy(Data* data)
|
|
|
|
|
{
|
|
|
|
|
AngleModeStructData *dt = dynamic_cast<AngleModeStructData *>(data);
|
|
|
|
|
m_data = dt->getData();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AngleModeStructData::copy(Data& data)
|
|
|
|
|
{
|
|
|
|
|
AngleModeStructData *dt = dynamic_cast<AngleModeStructData *>(&data);
|
|
|
|
|
m_data = dt->getData();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int AngleModeStructData::length()
|
|
|
|
|
{
|
|
|
|
|
return m_data.size()*2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string AngleModeStructData::toStr()
|
|
|
|
|
{
|
|
|
|
|
std::stringstream ss;
|
|
|
|
|
std::list<short>::iterator iter = m_data.begin();
|
|
|
|
|
while(iter != m_data.end())
|
|
|
|
|
{
|
|
|
|
|
ss << "max angle : " << *iter << std::endl;
|
|
|
|
|
iter++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ss.str();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 1. 第1个字节/共1字节: 类型
|
|
|
|
|
// 2. 第2,3,4,5字节/共4字节: 数量
|
|
|
|
|
// 3. 第6,7,8,9,10,11,12,13,14,15字节/共10字节:名称
|
|
|
|
|
// 4. 第16,17,18,19字节/共4字节:系数
|
|
|
|
|
// 重复3和4
|
|
|
|
|
std::string AngleModeStructData::toByteStr()
|
|
|
|
|
{
|
|
|
|
|
std::string s;
|
|
|
|
|
|
|
|
|
|
std::list<short>::iterator iter = m_data.begin();
|
|
|
|
|
while(iter != m_data.end())
|
|
|
|
|
{
|
|
|
|
|
s.append(Utils::shortToByteStr(*iter));
|
|
|
|
|
iter++;
|
|
|
|
|
}
|
|
|
|
|
return s;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string AngleModeStructData::toHexStr()
|
|
|
|
|
{
|
|
|
|
|
std::string s = toByteStr();
|
|
|
|
|
return Utils::strToHexStr(s);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool AngleModeStructData::fromByteStr(std::string str)
|
|
|
|
|
{
|
|
|
|
|
m_data.clear();
|
|
|
|
|
if(str.length() < 2)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
std::string s;
|
|
|
|
|
s = str.substr(0, 2);
|
|
|
|
|
m_data.push_back( Utils::byteStrToShort(s));
|
|
|
|
|
|
|
|
|
|
if(str.length() == 4)
|
|
|
|
|
{
|
|
|
|
|
s = str.substr(2, 2);
|
|
|
|
|
m_data.push_back( Utils::byteStrToShort(s));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AngleModeStructData::setData(std::list<short> data)
|
|
|
|
|
{
|
|
|
|
|
m_data.clear();
|
|
|
|
|
std::copy(data.begin(), data.end(), std::back_inserter(m_data));
|
|
|
|
|
}
|