Commit 04127e9ecfb4ff32cfd6fbbfff3bbc74dcd3b143
1 parent
4e974e9c
Exists in
master
Alguma observações, não deu tempo de arrumar todas
Showing
6 changed files
with
19 additions
and
12 deletions
Show diff stats
cacic-daemon/cacicD/cacicd.cpp
... | ... | @@ -37,6 +37,7 @@ void cacicD::start() { |
37 | 37 | Ocacictimer->setPeriodicidadeExecucao(result["codestatus"].toInt()); |
38 | 38 | Ocacictimer->iniciarTimer(); |
39 | 39 | }else{ |
40 | + //TODO: deve iniciar com um timer default (4 horas é um tempo bom), pra não ficar freezado pra sempre. | |
40 | 41 | QLogger::QLog_Error("Cacic Daemon", QString("getConfig.json não encontrado.")); |
41 | 42 | } |
42 | 43 | //QLogger::QLog_Info("Cacic Daemon", "Serviço finalizado."); | ... | ... |
cacic-daemon/cacicD/cacictimer.cpp
... | ... | @@ -46,6 +46,7 @@ void CacicTimer::mslot(){ |
46 | 46 | foreach( QString nome, nomesModulos ) { |
47 | 47 | if( nome == "gercols" ) { |
48 | 48 | definirDirGercols(getApplicationDirPath()); |
49 | + //iniciarModulo não se refere à aplicação 'gercols' | |
49 | 50 | iniciarModulo(); |
50 | 51 | |
51 | 52 | //Envio do json gerado na coleta |
... | ... | @@ -54,6 +55,7 @@ void CacicTimer::mslot(){ |
54 | 55 | OCacicComm->comm("/ws/neo/coleta", &ok, jsonColeta ); |
55 | 56 | } else if( nome == "mapas" ) { |
56 | 57 | definirDirMapas(getApplicationDirPath()); |
58 | + //iniciarModulo não se refere à aplicação 'mapas' | |
57 | 59 | iniciarModulo(); |
58 | 60 | } |
59 | 61 | } |
... | ... | @@ -85,8 +87,9 @@ bool CacicTimer::getTest(){ |
85 | 87 | // return false; |
86 | 88 | // } |
87 | 89 | try{ |
88 | - ccacic->setJsonToFile(jsonresult, this->applicationDirPath + "/getTest.json"); | |
89 | - return true; | |
90 | + ccacic->setJsonToFile(jsonresult.contains("reply") ? jsonresult["reply"].toObject() : jsonresult, | |
91 | + this->applicationDirPath + "/getTest.json"); | |
92 | + return true; //acho que seria melhor retornar a variável 'ok'. Se der erro na conexão eu acho que não cai no catch. | |
90 | 93 | } catch (...) { |
91 | 94 | qDebug() << "Erro ao salvar o arquivo de configurações."; |
92 | 95 | return false; |
... | ... | @@ -107,8 +110,9 @@ bool CacicTimer::getConfig(){ |
107 | 110 | // return false; |
108 | 111 | // } |
109 | 112 | try{ |
110 | - ccacic->setJsonToFile(jsonresult, this->applicationDirPath + "/getConfigNew.json"); | |
111 | - return true; | |
113 | + ccacic->setJsonToFile(jsonresult.contains("reply") ? jsonresult["reply"].toObject() : jsonresult, | |
114 | + this->applicationDirPath + "/getConfigNew.json"); | |
115 | + return true; //mesma observação do getTest | |
112 | 116 | } catch (...) { |
113 | 117 | qDebug() << "Erro ao salvar o arquivo de configurações."; |
114 | 118 | return false; |
... | ... | @@ -221,10 +225,11 @@ void CacicTimer::iniciarInstancias(){ |
221 | 225 | |
222 | 226 | void CacicTimer::verificarPeriodicidadeJson() |
223 | 227 | { |
228 | + //adaptar ao getConfig. | |
224 | 229 | QJsonObject result = ccacic->getJsonFromFile(this->applicationDirPath + "/getConfig.json"); |
225 | 230 | if(!result.contains("error") && !result.isEmpty()){ |
226 | - if(getPeriodicidadeExecucao() != result["codestatus"].toInt()){ | |
227 | - setPeriodicidadeExecucao(result["codestatus"].toInt()); | |
231 | + if(getPeriodicidadeExecucao() != result["nu_intervalo_exec"].toInt()){ | |
232 | + setPeriodicidadeExecucao(result["nu_intervalo_exec"].toInt()); | |
228 | 233 | reiniciarTimer(); |
229 | 234 | } |
230 | 235 | }else{ |
... | ... | @@ -235,7 +240,7 @@ void CacicTimer::verificarPeriodicidadeJson() |
235 | 240 | |
236 | 241 | void CacicTimer::definirDirGercols(QString appDirPath){ |
237 | 242 | #if defined (Q_OS_WIN) |
238 | - setDirProgram(appDirPath + "\cacic-gercols.exe"); | |
243 | + setDirProgram(appDirPath + "\\cacic-gercols.exe"); | |
239 | 244 | #elif defined (Q_OS_LINUX) |
240 | 245 | setDirProgram(appDirPath + "/cacic-gercols"); |
241 | 246 | #endif |
... | ... | @@ -243,7 +248,7 @@ void CacicTimer::definirDirGercols(QString appDirPath){ |
243 | 248 | |
244 | 249 | void CacicTimer::definirDirMapas(QString appDirPath){ |
245 | 250 | #if defined (Q_OS_WIN) |
246 | - setDirProgram(appDirPath + "\cacic-mapas.exe"); | |
251 | + setDirProgram(appDirPath + "\\cacic-mapas.exe"); | |
247 | 252 | #elif defined (Q_OS_LINUX) |
248 | 253 | setDirProgram(appDirPath + "/cacic-mapas"); |
249 | 254 | #endif | ... | ... |
cacic-teste/testcacic.cpp
... | ... | @@ -259,6 +259,7 @@ void CTestCacic::testColeta() |
259 | 259 | oColeta.configuraColetas(); |
260 | 260 | oColeta.run(); |
261 | 261 | oColeta.waitToCollect(); |
262 | +// OCacic.setJsonToFile(oColeta.toJsonObject(), "/home/eric/coleta.json"); | |
262 | 263 | // qDebug() << oColeta.toJsonObject(); |
263 | 264 | QVERIFY(!oColeta.toJsonObject()["software"].toObject().isEmpty() && |
264 | 265 | !oColeta.toJsonObject()["hardware"].toObject().isEmpty()); | ... | ... |
gercols/gercols.cpp
src/cacic_computer.cpp
... | ... | @@ -59,7 +59,7 @@ QJsonObject CACIC_Computer::toJsonObject() |
59 | 59 | /* |
60 | 60 | * PegarUsu() |
61 | 61 | * @return: std::string; |
62 | - * retorna o usuario logado no sistema. | |
62 | + * retorna o usuario logado no sistema. (erro, retorna o usuário que está executando.) | |
63 | 63 | */ |
64 | 64 | std::string CACIC_Computer::pegarUsu(){ |
65 | 65 | QString text; | ... | ... |
src/cacic_computer.h
... | ... | @@ -3,8 +3,8 @@ |
3 | 3 | |
4 | 4 | #include <QObject> |
5 | 5 | #include <QStringList> |
6 | -#include <QtSerialPort/QtSerialPort> | |
7 | -#include <QtSerialPort/QSerialPortInfo> | |
6 | +//#include <QtSerialPort/QtSerialPort> | |
7 | +//#include <QtSerialPort/QSerialPortInfo> | |
8 | 8 | #include <QtNetwork/QtNetwork> |
9 | 9 | #include <QSysInfo> |
10 | 10 | #include "operatingsystem.h" | ... | ... |