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,6 +37,7 @@ void cacicD::start() { | ||
37 | Ocacictimer->setPeriodicidadeExecucao(result["codestatus"].toInt()); | 37 | Ocacictimer->setPeriodicidadeExecucao(result["codestatus"].toInt()); |
38 | Ocacictimer->iniciarTimer(); | 38 | Ocacictimer->iniciarTimer(); |
39 | }else{ | 39 | }else{ |
40 | + //TODO: deve iniciar com um timer default (4 horas é um tempo bom), pra não ficar freezado pra sempre. | ||
40 | QLogger::QLog_Error("Cacic Daemon", QString("getConfig.json não encontrado.")); | 41 | QLogger::QLog_Error("Cacic Daemon", QString("getConfig.json não encontrado.")); |
41 | } | 42 | } |
42 | //QLogger::QLog_Info("Cacic Daemon", "Serviço finalizado."); | 43 | //QLogger::QLog_Info("Cacic Daemon", "Serviço finalizado."); |
cacic-daemon/cacicD/cacictimer.cpp
@@ -46,6 +46,7 @@ void CacicTimer::mslot(){ | @@ -46,6 +46,7 @@ void CacicTimer::mslot(){ | ||
46 | foreach( QString nome, nomesModulos ) { | 46 | foreach( QString nome, nomesModulos ) { |
47 | if( nome == "gercols" ) { | 47 | if( nome == "gercols" ) { |
48 | definirDirGercols(getApplicationDirPath()); | 48 | definirDirGercols(getApplicationDirPath()); |
49 | + //iniciarModulo não se refere à aplicação 'gercols' | ||
49 | iniciarModulo(); | 50 | iniciarModulo(); |
50 | 51 | ||
51 | //Envio do json gerado na coleta | 52 | //Envio do json gerado na coleta |
@@ -54,6 +55,7 @@ void CacicTimer::mslot(){ | @@ -54,6 +55,7 @@ void CacicTimer::mslot(){ | ||
54 | OCacicComm->comm("/ws/neo/coleta", &ok, jsonColeta ); | 55 | OCacicComm->comm("/ws/neo/coleta", &ok, jsonColeta ); |
55 | } else if( nome == "mapas" ) { | 56 | } else if( nome == "mapas" ) { |
56 | definirDirMapas(getApplicationDirPath()); | 57 | definirDirMapas(getApplicationDirPath()); |
58 | + //iniciarModulo não se refere à aplicação 'mapas' | ||
57 | iniciarModulo(); | 59 | iniciarModulo(); |
58 | } | 60 | } |
59 | } | 61 | } |
@@ -85,8 +87,9 @@ bool CacicTimer::getTest(){ | @@ -85,8 +87,9 @@ bool CacicTimer::getTest(){ | ||
85 | // return false; | 87 | // return false; |
86 | // } | 88 | // } |
87 | try{ | 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 | } catch (...) { | 93 | } catch (...) { |
91 | qDebug() << "Erro ao salvar o arquivo de configurações."; | 94 | qDebug() << "Erro ao salvar o arquivo de configurações."; |
92 | return false; | 95 | return false; |
@@ -107,8 +110,9 @@ bool CacicTimer::getConfig(){ | @@ -107,8 +110,9 @@ bool CacicTimer::getConfig(){ | ||
107 | // return false; | 110 | // return false; |
108 | // } | 111 | // } |
109 | try{ | 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 | } catch (...) { | 116 | } catch (...) { |
113 | qDebug() << "Erro ao salvar o arquivo de configurações."; | 117 | qDebug() << "Erro ao salvar o arquivo de configurações."; |
114 | return false; | 118 | return false; |
@@ -221,10 +225,11 @@ void CacicTimer::iniciarInstancias(){ | @@ -221,10 +225,11 @@ void CacicTimer::iniciarInstancias(){ | ||
221 | 225 | ||
222 | void CacicTimer::verificarPeriodicidadeJson() | 226 | void CacicTimer::verificarPeriodicidadeJson() |
223 | { | 227 | { |
228 | + //adaptar ao getConfig. | ||
224 | QJsonObject result = ccacic->getJsonFromFile(this->applicationDirPath + "/getConfig.json"); | 229 | QJsonObject result = ccacic->getJsonFromFile(this->applicationDirPath + "/getConfig.json"); |
225 | if(!result.contains("error") && !result.isEmpty()){ | 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 | reiniciarTimer(); | 233 | reiniciarTimer(); |
229 | } | 234 | } |
230 | }else{ | 235 | }else{ |
@@ -235,7 +240,7 @@ void CacicTimer::verificarPeriodicidadeJson() | @@ -235,7 +240,7 @@ void CacicTimer::verificarPeriodicidadeJson() | ||
235 | 240 | ||
236 | void CacicTimer::definirDirGercols(QString appDirPath){ | 241 | void CacicTimer::definirDirGercols(QString appDirPath){ |
237 | #if defined (Q_OS_WIN) | 242 | #if defined (Q_OS_WIN) |
238 | - setDirProgram(appDirPath + "\cacic-gercols.exe"); | 243 | + setDirProgram(appDirPath + "\\cacic-gercols.exe"); |
239 | #elif defined (Q_OS_LINUX) | 244 | #elif defined (Q_OS_LINUX) |
240 | setDirProgram(appDirPath + "/cacic-gercols"); | 245 | setDirProgram(appDirPath + "/cacic-gercols"); |
241 | #endif | 246 | #endif |
@@ -243,7 +248,7 @@ void CacicTimer::definirDirGercols(QString appDirPath){ | @@ -243,7 +248,7 @@ void CacicTimer::definirDirGercols(QString appDirPath){ | ||
243 | 248 | ||
244 | void CacicTimer::definirDirMapas(QString appDirPath){ | 249 | void CacicTimer::definirDirMapas(QString appDirPath){ |
245 | #if defined (Q_OS_WIN) | 250 | #if defined (Q_OS_WIN) |
246 | - setDirProgram(appDirPath + "\cacic-mapas.exe"); | 251 | + setDirProgram(appDirPath + "\\cacic-mapas.exe"); |
247 | #elif defined (Q_OS_LINUX) | 252 | #elif defined (Q_OS_LINUX) |
248 | setDirProgram(appDirPath + "/cacic-mapas"); | 253 | setDirProgram(appDirPath + "/cacic-mapas"); |
249 | #endif | 254 | #endif |
cacic-teste/testcacic.cpp
@@ -259,6 +259,7 @@ void CTestCacic::testColeta() | @@ -259,6 +259,7 @@ void CTestCacic::testColeta() | ||
259 | oColeta.configuraColetas(); | 259 | oColeta.configuraColetas(); |
260 | oColeta.run(); | 260 | oColeta.run(); |
261 | oColeta.waitToCollect(); | 261 | oColeta.waitToCollect(); |
262 | +// OCacic.setJsonToFile(oColeta.toJsonObject(), "/home/eric/coleta.json"); | ||
262 | // qDebug() << oColeta.toJsonObject(); | 263 | // qDebug() << oColeta.toJsonObject(); |
263 | QVERIFY(!oColeta.toJsonObject()["software"].toObject().isEmpty() && | 264 | QVERIFY(!oColeta.toJsonObject()["software"].toObject().isEmpty() && |
264 | !oColeta.toJsonObject()["hardware"].toObject().isEmpty()); | 265 | !oColeta.toJsonObject()["hardware"].toObject().isEmpty()); |
gercols/gercols.cpp
@@ -28,7 +28,7 @@ Gercols::Gercols(QObject *parent) | @@ -28,7 +28,7 @@ Gercols::Gercols(QObject *parent) | ||
28 | 28 | ||
29 | void Gercols::run() | 29 | void Gercols::run() |
30 | { | 30 | { |
31 | - | 31 | + qDebug() << "run..."; |
32 | emit iniciaConfiguracao(); | 32 | emit iniciaConfiguracao(); |
33 | //emite sinal para começar a coleta | 33 | //emite sinal para começar a coleta |
34 | emit iniciaColeta(); | 34 | emit iniciaColeta(); |
src/cacic_computer.cpp
@@ -59,7 +59,7 @@ QJsonObject CACIC_Computer::toJsonObject() | @@ -59,7 +59,7 @@ QJsonObject CACIC_Computer::toJsonObject() | ||
59 | /* | 59 | /* |
60 | * PegarUsu() | 60 | * PegarUsu() |
61 | * @return: std::string; | 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 | std::string CACIC_Computer::pegarUsu(){ | 64 | std::string CACIC_Computer::pegarUsu(){ |
65 | QString text; | 65 | QString text; |
src/cacic_computer.h
@@ -3,8 +3,8 @@ | @@ -3,8 +3,8 @@ | ||
3 | 3 | ||
4 | #include <QObject> | 4 | #include <QObject> |
5 | #include <QStringList> | 5 | #include <QStringList> |
6 | -#include <QtSerialPort/QtSerialPort> | ||
7 | -#include <QtSerialPort/QSerialPortInfo> | 6 | +//#include <QtSerialPort/QtSerialPort> |
7 | +//#include <QtSerialPort/QSerialPortInfo> | ||
8 | #include <QtNetwork/QtNetwork> | 8 | #include <QtNetwork/QtNetwork> |
9 | #include <QSysInfo> | 9 | #include <QSysInfo> |
10 | #include "operatingsystem.h" | 10 | #include "operatingsystem.h" |