From 04127e9ecfb4ff32cfd6fbbfff3bbc74dcd3b143 Mon Sep 17 00:00:00 2001 From: eric Date: Thu, 25 Sep 2014 01:28:50 -0300 Subject: [PATCH] Alguma observações, não deu tempo de arrumar todas --- cacic-daemon/cacicD/cacicd.cpp | 1 + cacic-daemon/cacicD/cacictimer.cpp | 21 +++++++++++++-------- cacic-teste/testcacic.cpp | 1 + gercols/gercols.cpp | 2 +- src/cacic_computer.cpp | 2 +- src/cacic_computer.h | 4 ++-- 6 files changed, 19 insertions(+), 12 deletions(-) diff --git a/cacic-daemon/cacicD/cacicd.cpp b/cacic-daemon/cacicD/cacicd.cpp index 99cddae..d0d8494 100644 --- a/cacic-daemon/cacicD/cacicd.cpp +++ b/cacic-daemon/cacicD/cacicd.cpp @@ -37,6 +37,7 @@ void cacicD::start() { Ocacictimer->setPeriodicidadeExecucao(result["codestatus"].toInt()); Ocacictimer->iniciarTimer(); }else{ + //TODO: deve iniciar com um timer default (4 horas é um tempo bom), pra não ficar freezado pra sempre. QLogger::QLog_Error("Cacic Daemon", QString("getConfig.json não encontrado.")); } //QLogger::QLog_Info("Cacic Daemon", "Serviço finalizado."); diff --git a/cacic-daemon/cacicD/cacictimer.cpp b/cacic-daemon/cacicD/cacictimer.cpp index 86bedfb..4b6272a 100644 --- a/cacic-daemon/cacicD/cacictimer.cpp +++ b/cacic-daemon/cacicD/cacictimer.cpp @@ -46,6 +46,7 @@ void CacicTimer::mslot(){ foreach( QString nome, nomesModulos ) { if( nome == "gercols" ) { definirDirGercols(getApplicationDirPath()); + //iniciarModulo não se refere à aplicação 'gercols' iniciarModulo(); //Envio do json gerado na coleta @@ -54,6 +55,7 @@ void CacicTimer::mslot(){ OCacicComm->comm("/ws/neo/coleta", &ok, jsonColeta ); } else if( nome == "mapas" ) { definirDirMapas(getApplicationDirPath()); + //iniciarModulo não se refere à aplicação 'mapas' iniciarModulo(); } } @@ -85,8 +87,9 @@ bool CacicTimer::getTest(){ // return false; // } try{ - ccacic->setJsonToFile(jsonresult, this->applicationDirPath + "/getTest.json"); - return true; + ccacic->setJsonToFile(jsonresult.contains("reply") ? jsonresult["reply"].toObject() : jsonresult, + this->applicationDirPath + "/getTest.json"); + 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. } catch (...) { qDebug() << "Erro ao salvar o arquivo de configurações."; return false; @@ -107,8 +110,9 @@ bool CacicTimer::getConfig(){ // return false; // } try{ - ccacic->setJsonToFile(jsonresult, this->applicationDirPath + "/getConfigNew.json"); - return true; + ccacic->setJsonToFile(jsonresult.contains("reply") ? jsonresult["reply"].toObject() : jsonresult, + this->applicationDirPath + "/getConfigNew.json"); + return true; //mesma observação do getTest } catch (...) { qDebug() << "Erro ao salvar o arquivo de configurações."; return false; @@ -221,10 +225,11 @@ void CacicTimer::iniciarInstancias(){ void CacicTimer::verificarPeriodicidadeJson() { + //adaptar ao getConfig. QJsonObject result = ccacic->getJsonFromFile(this->applicationDirPath + "/getConfig.json"); if(!result.contains("error") && !result.isEmpty()){ - if(getPeriodicidadeExecucao() != result["codestatus"].toInt()){ - setPeriodicidadeExecucao(result["codestatus"].toInt()); + if(getPeriodicidadeExecucao() != result["nu_intervalo_exec"].toInt()){ + setPeriodicidadeExecucao(result["nu_intervalo_exec"].toInt()); reiniciarTimer(); } }else{ @@ -235,7 +240,7 @@ void CacicTimer::verificarPeriodicidadeJson() void CacicTimer::definirDirGercols(QString appDirPath){ #if defined (Q_OS_WIN) - setDirProgram(appDirPath + "\cacic-gercols.exe"); + setDirProgram(appDirPath + "\\cacic-gercols.exe"); #elif defined (Q_OS_LINUX) setDirProgram(appDirPath + "/cacic-gercols"); #endif @@ -243,7 +248,7 @@ void CacicTimer::definirDirGercols(QString appDirPath){ void CacicTimer::definirDirMapas(QString appDirPath){ #if defined (Q_OS_WIN) - setDirProgram(appDirPath + "\cacic-mapas.exe"); + setDirProgram(appDirPath + "\\cacic-mapas.exe"); #elif defined (Q_OS_LINUX) setDirProgram(appDirPath + "/cacic-mapas"); #endif diff --git a/cacic-teste/testcacic.cpp b/cacic-teste/testcacic.cpp index 3e99ed7..f04fdf5 100644 --- a/cacic-teste/testcacic.cpp +++ b/cacic-teste/testcacic.cpp @@ -259,6 +259,7 @@ void CTestCacic::testColeta() oColeta.configuraColetas(); oColeta.run(); oColeta.waitToCollect(); +// OCacic.setJsonToFile(oColeta.toJsonObject(), "/home/eric/coleta.json"); // qDebug() << oColeta.toJsonObject(); QVERIFY(!oColeta.toJsonObject()["software"].toObject().isEmpty() && !oColeta.toJsonObject()["hardware"].toObject().isEmpty()); diff --git a/gercols/gercols.cpp b/gercols/gercols.cpp index 5f3209e..4a96607 100644 --- a/gercols/gercols.cpp +++ b/gercols/gercols.cpp @@ -28,7 +28,7 @@ Gercols::Gercols(QObject *parent) void Gercols::run() { - + qDebug() << "run..."; emit iniciaConfiguracao(); //emite sinal para começar a coleta emit iniciaColeta(); diff --git a/src/cacic_computer.cpp b/src/cacic_computer.cpp index 01ca997..7f0ada1 100644 --- a/src/cacic_computer.cpp +++ b/src/cacic_computer.cpp @@ -59,7 +59,7 @@ QJsonObject CACIC_Computer::toJsonObject() /* * PegarUsu() * @return: std::string; - * retorna o usuario logado no sistema. + * retorna o usuario logado no sistema. (erro, retorna o usuário que está executando.) */ std::string CACIC_Computer::pegarUsu(){ QString text; diff --git a/src/cacic_computer.h b/src/cacic_computer.h index 06bf21a..576c42c 100644 --- a/src/cacic_computer.h +++ b/src/cacic_computer.h @@ -3,8 +3,8 @@ #include #include -#include -#include +//#include +//#include #include #include #include "operatingsystem.h" -- libgit2 0.21.2