You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.2 KiB
C++
48 lines
1.2 KiB
C++
#include "CamConfig.h"
|
|
#include "QZkJsonParser.h"
|
|
|
|
#define WHEEL_CAMERACONFIG_FILE "\\config\\camera.json"
|
|
CamConfig::CamConfig(QString strPath)
|
|
{
|
|
m_appRoot = strPath;
|
|
init();
|
|
}
|
|
|
|
|
|
CamConfig::~CamConfig()
|
|
{
|
|
}
|
|
|
|
void CamConfig::init()
|
|
{
|
|
QString fileCam = m_appRoot + WHEEL_CAMERACONFIG_FILE;
|
|
QJsonObject jsMyself = QZkJsonParser::ReadJsonAuto(fileCam);
|
|
QJsonObject m_deviceObj = jsMyself.value("devices").toObject();
|
|
QJsonObject::iterator pObj = m_deviceObj.begin();
|
|
QString objname = pObj.key();
|
|
QStringList m_strList = objname.split(" ");
|
|
m_CamType = m_strList.at(0);
|
|
m_CamSerial = m_strList.at(1);
|
|
}
|
|
|
|
QString CamConfig::getCamType() const
|
|
{
|
|
return m_CamType;
|
|
}
|
|
|
|
QString CamConfig::getCamSerial() const
|
|
{
|
|
return m_CamSerial;
|
|
}
|
|
|
|
void CamConfig::save()
|
|
{
|
|
QString fileMyself = m_appRoot + WHEEL_CAMERACONFIG_FILE;
|
|
QJsonObject jsMyself = QZkJsonParser::ReadJsonAuto(fileMyself);
|
|
QJsonObject objDevice = jsMyself.value("devices").toObject();
|
|
QJsonObject CamObj = (*objDevice.begin()).toObject();
|
|
QString objName = QString("%1 %2").arg(m_CamType).arg(m_CamSerial);
|
|
jsMyself.insert("devices", objDevice);
|
|
QZkJsonParser::WriteJsonObject(fileMyself, jsMyself);
|
|
}
|