42 #include "commandmanager.h"
49 #include <QStringList>
50 #include <QJsonObject>
51 #include <QJsonDocument>
57 using namespace COMMUNICATIONLIB;
72 Subject::t_Observers::Iterator itObservers;
73 for(itObservers = this->
observers().begin(); itObservers != this->
observers().end(); ++itObservers)
86 if(p_sInput.size() <= 0)
89 p_qListCommandsParsed.clear();
93 if(QString::compare(p_sInput.at(0), QString(
"{")) == 0)
98 qDebug() <<
"JSON command recognized";
100 QJsonObject t_jsonObjectCommand;
101 QJsonObject t_jsonObjectParameters;
102 QJsonDocument t_jsonDocument(QJsonDocument::fromJson(p_sInput.toUtf8()));
105 if(t_jsonDocument.isObject() && t_jsonDocument.object().value(QString(
"commands")) != QJsonValue::Undefined)
106 t_jsonObjectCommand = t_jsonDocument.object().value(QString(
"commands")).toObject();
111 QJsonObject::Iterator it;
112 QJsonObject::Iterator itParam;
113 for(it = t_jsonObjectCommand.begin(); it != t_jsonObjectCommand.end(); ++it)
116 printf(
"%s\r\n", it.key().toUtf8().constData());
121 m_rawCommand = t_rawCommand;
122 t_jsonObjectParameters = it.value().toObject();
125 p_qListCommandsParsed.push_back(it.key());
128 for(itParam= t_jsonObjectParameters.begin(); itParam != t_jsonObjectParameters.end(); ++itParam)
130 printf(
" %s", itParam.value().toString().toUtf8().constData());
132 m_rawCommand.
pValues().append(itParam.value().toString());
144 QStringList t_qCommandList = p_sInput.split(
" ");
147 printf(
"%s\r\n", t_qCommandList[0].toUtf8().constData());
149 if(!
exists(t_qCommandList[0]))
155 RawCommand t_rawCommand(t_qCommandList[0],
false);
156 m_rawCommand = t_rawCommand;
159 p_qListCommandsParsed.push_back(t_qCommandList[0]);
161 if(t_qCommandList.size() > 1)
164 for(qint32 i = 1; i < t_qCommandList.size(); ++i)
166 printf(
" %s", t_qCommandList[i].toUtf8().constData());
167 m_rawCommand.
pValues().append(t_qCommandList[i]);