#include "StdAfx.h" #include "Msmain.h" #include "_log.h" #include "olv.h" //******************************************************************************************* Msmain::Msmain(void) { pirate =false; } //******************************************************************************************* Msmain::~Msmain(void) { } //******************************************************************************************* bool Msmain::Despacha_log() { StrArray msgs; if(log.dame(msgs)) { #if _DEBUG //logea mensages(); for(int i = 0; i0) { ms = "echo " + std::string(st2); system(ms.c_str()); } st2 = 0; } } if(st2) { ms = "echo " + std::string(st2); system(ms.c_str()); } } #endif return true; } return false; } //******************************************************************************************* void Msmain::Despacha() { MSG msg; while (!pirate) { while ( PeekMessage (&msg,NULL,NULL,NULL, PM_NOREMOVE) ) { PeekMessage (&msg,NULL,NULL,NULL, PM_REMOVE); TranslateMessage(&msg); DispatchMessage(&msg); } if(!Despacha_log()) Sleep(100); if(olv->isDebug && (olv->tarea == OLV_TAREA_FIN_SEC || olv->tarea == OLV_TAREA_FIN_PLANIF)) { //C_log::log("Msmain", olv->msg_proce); olv->cancela(); } } } //******************************************************************************************* void Msmain::log_ext( __time64_t tiemp, char *modulo, char *fmt ) { char tiem[32]; char str[1024]; strftime(tiem, 20, "%Y-%m-%d %H:%M:%S", localtime(&tiemp)); sprintf_s(str,1024, "%s %-12s %s\r\n", (char *) LPCTSTR (tiem), (char *) LPCTSTR (modulo), (char *) LPCTSTR (fmt)); log.pon(str); } //******************************************************************************************* bool Cstr_Msg::dame( StrArray& stout ) { if(n_i<=0) return false; if(stout.ind) free(stout.ind); if(stout.str) free(stout.str); lock_cola.entro(); stout.ind=ind; stout.str=str; stout.m_str=m_str; stout.m_i=m_i; stout.n_str=n_str; stout.n_i=n_i; m_str=m_i=n_i=n_str=0; str=NULL; ind=NULL; lock_cola.salgo(); return true; } //************************************************************************************ void Cstr_Msg::pon( char* str) { lock_cola.entro(); add(str); lock_cola.salgo(); } //************************************************************************************