int main(int argc, char *argv[]) { #if _DEBUG || (__GNUC__ && !NDEBUG) #ifdef _WIN32 const char *logfilepath = "./resultsviewer.log"; #else const char *logfilepath = "/var/log/resultsviewer.log"; #endif openstudio::Logger::instance().standardOutLogger().setLogLevel(Debug); openstudio::FileLogSink fileLog(openstudio::toPath(logfilepath)); fileLog.setLogLevel(Debug); #else openstudio::Logger::instance().standardOutLogger().setLogLevel(Warn); #endif bool cont = true; while(cont) { cont = false; // Make the run path the default plugin search location QCoreApplication::addLibraryPath(openstudio::toQString(openstudio::getApplicationRunDirectory())); QApplication qApplication(argc,argv); openstudio::Application::instance().setApplication(&qApplication); try { resultsviewer::MainWindow w; w.show(); return qApplication.exec(); } catch (const std::exception &e) { LOG_FREE(Fatal, "ResultsViewer", "An unhandled exception has occurred: " << e.what()); cont = true; QMessageBox msgBox; msgBox.setWindowTitle("Unhandled Exception"); msgBox.setIcon(QMessageBox::Critical); msgBox.setText("An unhandled exception has occurred."); msgBox.setInformativeText(e.what()); msgBox.setStandardButtons(QMessageBox::Retry | QMessageBox::Close); msgBox.button(QMessageBox::Retry)->setText("Relaunch"); if (msgBox.exec() == QMessageBox::Close) { cont = false; } } catch (...) { LOG_FREE(Fatal, "ResultsViewer", "An unknown exception has occurred."); cont = true; QMessageBox msgBox; msgBox.setWindowTitle("Unknown Exception"); msgBox.setIcon(QMessageBox::Critical); msgBox.setText("An unknown exception has occurred."); msgBox.setStandardButtons(QMessageBox::Retry | QMessageBox::Close); msgBox.button(QMessageBox::Retry)->setText("Relaunch"); if (msgBox.exec() == QMessageBox::Close) { cont = false; } } } }
void CCropDialog::PrintToOutput(QString strOutput) { QDateTime DateTime = QDateTime::currentDateTime(); ui.listWidgetOutput->addItem( DateTime.toString("yyyy.MM.dd hh:mm:ss ap") + " - " + strOutput); ui.listWidgetOutput->scrollToBottom(); QFile fileLog(tr("%1/log.txt").arg(ui.lineEditDestFolder->text())); fileLog.open(QIODevice::Append | QIODevice::Text); QTextStream txtstrmOut(&fileLog); txtstrmOut << DateTime.toString("yyyy.MM.dd hh:mm:ss ap") << " - " << strOutput << "\n"; fileLog.close(); }
/* popis: otvori logovaci subor; globalna premenna logfile obsahuje handle * vracia: on success, returns 0 * on error, returns 1 */ short int initLog(const char *fname){ fileLog(); #if defined(LOG_TO_FILE) logfile = fopen(fname, "wt"); used = (logfile == NULL)? 1: 0; #elif defined(LOG_TO_STDOUT) logfile = stdout; used = 0; #elif defined(LOG_TO_ANDROID) used = 0; #else #error Unsupported logging model (use _LOG_TO_STDOUT or _LOG_TO_FILE) #endif return used; // 1: failure, 0: success }
int main() { //txtEzFactory fileLog(TT_H); txtEzFactory fileLog(TT_V); fileLog.Add("line one is me!!"); fileLog.Add("line two is me!!"); fileLog.Add("line three is me!!"); fileLog.Add("line four is me!!"); fileLog.Add("line five is me!!"); fileLog.Add("line six is me!!"); fileLog.Show(); // system("PAUSE"); return 0; }
int main(int argc, char *argv[]) { ruby_sysinit(&argc, &argv); { RUBY_INIT_STACK; ruby_init(); } #if _DEBUG || (__GNUC__ && !NDEBUG) #ifdef _WIN32 const char *logfilepath = "./openstudio_pat.log"; #else const char *logfilepath = "/var/log/openstudio_pat.log"; #endif openstudio::Logger::instance().standardOutLogger().setLogLevel(Debug); openstudio::FileLogSink fileLog(openstudio::toPath(logfilepath)); fileLog.setLogLevel(Debug); #else openstudio::Logger::instance().standardOutLogger().setLogLevel(Warn); #endif // list of Ruby modules we want to load into the interpreter std::vector<std::string> modules; modules.push_back("openstudioutilitiescore"); modules.push_back("openstudioutilitiesbcl"); modules.push_back("openstudioutilitiesidd"); modules.push_back("openstudioutilitiesidf"); modules.push_back("openstudioutilities"); modules.push_back("openstudiomodel"); modules.push_back("openstudiomodelcore"); modules.push_back("openstudiomodelsimulation"); modules.push_back("openstudiomodelresources"); modules.push_back("openstudiomodelgeometry"); modules.push_back("openstudiomodelhvac"); modules.push_back("openstudiomodelrefrigeration"); modules.push_back("openstudioenergyplus"); modules.push_back("openstudioruleset"); bool cont = true; while(cont) { cont = false; // Initialize the embedded Ruby interpreter std::shared_ptr<openstudio::detail::RubyInterpreter> rubyInterpreter( new openstudio::detail::RubyInterpreter(openstudio::getOpenStudioRubyPath(), openstudio::getOpenStudioRubyScriptsPath(), modules)); // Initialize the argument getter QSharedPointer<openstudio::ruleset::RubyUserScriptInfoGetter> infoGetter( new openstudio::ruleset::EmbeddedRubyUserScriptInfoGetter<openstudio::detail::RubyInterpreter>(rubyInterpreter)); // Make the run path the default plugin search location QCoreApplication::addLibraryPath(openstudio::toQString(openstudio::getApplicationRunDirectory())); openstudio::pat::PatApp app(argc, argv, infoGetter); openstudio::Application::instance().setApplication(&app); try { return app.exec(); } catch (const std::exception &e) { LOG_FREE(Fatal, "PatApp", "An unhandled exception has occurred: " << e.what()); cont = true; QMessageBox msgBox; msgBox.setWindowTitle("Unhandled Exception"); msgBox.setIcon(QMessageBox::Critical); msgBox.setText("An unhandled exception has occurred."); msgBox.setInformativeText(e.what()); msgBox.setStandardButtons(QMessageBox::Retry | QMessageBox::Close); msgBox.button(QMessageBox::Retry)->setText("Relaunch"); if (msgBox.exec() == QMessageBox::Close) { cont = false; } } catch (...) { LOG_FREE(Fatal, "PatApp", "An unknown exception has occurred."); cont = true; QMessageBox msgBox; msgBox.setWindowTitle("Unknown Exception"); msgBox.setIcon(QMessageBox::Critical); msgBox.setText("An unknown exception has occurred."); msgBox.setStandardButtons(QMessageBox::Retry | QMessageBox::Close); msgBox.button(QMessageBox::Retry)->setText("Relaunch"); if (msgBox.exec() == QMessageBox::Close) { cont = false; } } } }
BOOL CGridFlashDlg::OnInitDialog() { CDialog::OnInitDialog(); GetDlgItem(IDC_BUTTON1)->ShowWindow(SW_HIDE); m_strLogFilePath=g_strExePth+_T("burn_hex_Log"); CreateDirectory(m_strLogFilePath,NULL);//create directory file m_FlexGrid.put_TextMatrix(0,1,_T("Serial#")); m_FlexGrid.put_TextMatrix(0,2,_T("ID")); m_FlexGrid.put_TextMatrix(0,3,_T("Baudrate")); m_FlexGrid.put_TextMatrix(0,4,_T("H/W ver")); m_FlexGrid.put_TextMatrix(0,5,_T("Device")); m_FlexGrid.put_TextMatrix(0,6,_T("S/W ver")); m_FlexGrid.put_TextMatrix(0,7,_T("EP size")); m_FlexGrid.put_TextMatrix(0,8,_T("Hex File")); m_FlexGrid.put_TextMatrix(0,9,_T("Enable")); m_FlexGrid.put_TextMatrix(0,10,_T("Status")); m_FlexGrid.put_TextMatrix(0,11,_T("Connetion")); m_FlexGrid.put_TextMatrix(0,12,_T("Burn Event")); m_FlexGrid.put_ColWidth(0,0); m_FlexGrid.put_ColWidth(1,800); m_FlexGrid.put_ColWidth(2,500); m_FlexGrid.put_ColWidth(3,800); m_FlexGrid.put_ColWidth(4,800); m_FlexGrid.put_ColWidth(5,700); m_FlexGrid.put_ColWidth(6,800); m_FlexGrid.put_ColWidth(7,900); m_FlexGrid.put_ColWidth(8,3200); m_FlexGrid.put_ColWidth(9,800); m_FlexGrid.put_ColWidth(10,700); m_FlexGrid.put_ColWidth(11,900); m_FlexGrid.put_ColWidth(12,1500); saved_path=g_strExePth+_T("burn_hex_Log"); file_directory=saved_path; log_file_path=g_strExePth+_T("\\flash_log.txt"); CreateDirectory(saved_path.GetString(),NULL);//create directory file CMainFrame* pFrame=(CMainFrame*)(AfxGetApp()->m_pMainWnd); m_grid_flash.clear(); for(int i=0;i<(int)pFrame->m_product.size();i++) { int j=pFrame->m_product.at(i).product_id; grid_flash temp_grid_flash; temp_grid_flash.ID=pFrame->m_product.at(i).product_id; //j;//ID for get_serialnumber function temp_grid_flash.baudrate=pFrame->m_product.at(i).baudrate; //baudrate temp_grid_flash.serialnumber =pFrame->m_product.at(i).serial_number ; //serialnumber temp_grid_flash.flash_or_no=true; temp_grid_flash.hardware_revisin=(short)pFrame->m_product.at(i).hardware_version; //read_one(j ,8); ; temp_grid_flash.device=pFrame->m_product.at(i).product_class_id ; temp_grid_flash.software_version=pFrame->m_product.at(i).software_version; //get_tstat_version(j); temp_grid_flash.EpSize=pFrame->m_product.at(i).nEPsize; //if(temp_grid_flash.software_version>0) { // if(make_sure_isp_mode(j)==1) //temp_grid_flash.software_version=p_mode; } // 屏蔽NC的设备信息 /* if(PM_NC==temp_grid_flash.device||NET_WORK_OR485_PRODUCT_MODEL==temp_grid_flash.device) continue; */ m_grid_flash.push_back(temp_grid_flash); } CString stemp; m_FlexGrid.put_Rows(m_grid_flash.size()+2); for(int i=0;i<(int)m_grid_flash.size();i++) { stemp.Format(_T("%ld"),m_grid_flash.at(i).serialnumber); m_FlexGrid.put_TextMatrix(i+1,1,stemp);//serialnumber stemp.Format(_T("%d"),m_grid_flash.at(i).ID); m_FlexGrid.put_TextMatrix(i+1,2,stemp); stemp.Format(_T("%d"),m_grid_flash.at(i).baudrate); m_FlexGrid.put_TextMatrix(i+1,3,stemp);//baudrate stemp.Format(_T("%d"),m_grid_flash.at(i).hardware_revisin); m_FlexGrid.put_TextMatrix(i+1,4,stemp);//hardware revision stemp.Format(_T("%d"),m_grid_flash.at(i).device); switch(m_grid_flash.at(i).device) { //case 2:stemp=g_strTstat5a;break;//Tstat5A //case 1:stemp=g_strTstat5b;break;//Tstat5A //case 3:stemp=g_strTstat5b;break;//Tstat5A //case 4:stemp=g_strTstat5c;break;//Tstat5A //case 12:stemp=g_strTstat5d;break;//Tstat5A //case 17:stemp=g_strTstat5f;break; //case 18:stemp=g_strTstat5g;break; //case 16:stemp=g_strTstat5e;break; //case 19:stemp=g_strTstat5h;break; //case 6:stemp=g_strTstat6;break; //case 7:stemp=g_strTstat7;break; //case PM_NC:stemp=g_strnetWork;break; //case LED_PRODUCT_MODEL:stemp=_T("Led");break;//Others //case PM_SOLAR: stemp=_T("Solar");break; //case PM_ZIGBEE: stemp=_T("ZigBee");break; //case T3_32I_PRODUCT_MODEL:stemp=_T("T3-32I");break; //case T3_8I_16O_PRODUCT_MODEL:stemp=_T("T3-8I-16O");break; //case PM_T3IOA:stemp=_T("T3-8O");break; //case PM_T38AIOD:stemp=_T("T3-8IOD");break; //default:stemp=_T("Others");break; case PM_TSTAT5A: stemp="TStat5A"; break; case PM_TSTAT5B: stemp="TStat5B"; break; case PM_TSTAT5B2: stemp="TStat5B2"; break; case PM_TSTAT5C: stemp="TStat5C"; break; case PM_TSTAT5D: stemp="TStat5D"; break; case PM_TSTAT5E: stemp="TStat5E"; break; case PM_PM5E: stemp="PM5E"; break; case PM_TSTATRUNAR: stemp="TStatRunar"; break; case PM_TSTAT5F: stemp="TStat5F"; break; case PM_TSTAT5G: stemp="TStat5G"; break; case PM_TSTAT5H: stemp="TStat5H"; break; case PM_TSTAT6: stemp="TStat6"; break; case PM_TSTAT5i: stemp="TStat5i"; break; case PM_TSTAT8: stemp="TStat8"; break; case PM_TSTAT7: stemp="TStat7"; break; case PM_NC: stemp="NC"; break; case PM_CM5: stemp ="CM5"; break; case PM_LightingController: stemp = "LC"; break; case PM_CO2_NET: stemp = "CO2 Net"; break; case PM_CO2_RS485: stemp = "CO2"; break; case STM32_CO2_NET: stemp = "CO2 Net"; break; case STM32_CO2_RS485: stemp = "CO2"; break; case PM_PRESSURE_SENSOR: stemp = "Pressure"; break; case PM_CO2_NODE: stemp = "CO2 Node"; break; case PM_TSTAT6_HUM_Chamber: stemp =g_strHumChamber; break; case PM_T3PT10 : stemp="T3-PT10"; break; case PM_T3IOA : stemp="T3-8O"; break; case PM_T332AI : stemp="T3-32AI"; break; case PM_T38AI16O : stemp="T3-8AI160"; break; case PM_T38I13O : stemp="T3-8I13O"; break; case PM_T3PERFORMANCE : stemp="T3-Performance"; break; case PM_T34AO : stemp="T3-4AO"; break; case PM_T36CT : stemp="T3-6CT"; break; case PM_T322AI: stemp="T3-22I"; break; case PM_T38AI8AO6DO: stemp="T3-8AI8AO6DO"; break; default: stemp="TStat"; break; } m_FlexGrid.put_TextMatrix(i+1,5,stemp);//product model ===== software version if(m_grid_flash.at(i).software_version==p_mode) stemp=_T("ISP"); else stemp.Format(_T("%.1f"),m_grid_flash.at(i).software_version); m_FlexGrid.put_TextMatrix(i+1,6,stemp);//product model ===== software version m_FlexGrid.put_TextMatrix(i+1,10,_T("")); CString strSerial; strSerial.Format(_T("%d_burn_log"),m_grid_flash.at(i).serialnumber); CString strLogFile; strLogFile=file_directory+_T("\\")+strSerial+_T(".txt"); WIN32_FIND_DATA fData; HANDLE hFile=NULL; hFile = FindFirstFile(strLogFile,&fData); if(hFile != INVALID_HANDLE_VALUE) { CFileStatus st; CStdioFile fileLog(strLogFile,CFile::modeReadWrite | CFile::modeNoTruncate|CFile::typeText); // TCHAR pbuf[50]; CString strLine; CString strLastLine; fileLog.GetStatus(st); if(st.m_size>50) { fileLog.Seek(-50,fileLog.end); while(fileLog.ReadString(strLine)) { strLastLine.Empty(); strLastLine=strLine; } if(strLastLine.Find(_T("Success"))>=0) { SYSTEMTIME stUTC, stLocal; CString strDatatime; FileTimeToSystemTime(&(fData.ftLastWriteTime), &stUTC); SystemTimeToTzSpecificLocalTime(NULL, &stUTC, &stLocal); strDatatime.Format(_T("%d. %d %d, %d:%d"), stLocal.wDay,stLocal.wMonth,stLocal.wYear,stLocal.wHour,stLocal.wMinute); m_FlexGrid.put_TextMatrix(i+1,12,strDatatime); } } fileLog.Close(); } FindClose(hFile); for(int k=0;k<=12;k++) { if (i%2==1) { m_FlexGrid.put_Row(i+1);m_FlexGrid.put_Col(k);m_FlexGrid.put_CellBackColor(RGB(255,255,255)); } else { m_FlexGrid.put_Row(i+1);m_FlexGrid.put_Col(k);m_FlexGrid.put_CellBackColor(RGB(236,232,230)); } } } m_pBackCheckThread->m_bAutoDelete=FALSE; SetTimer(1,10,NULL); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
int main(int argc, char *argv[]) { #if RUBY_API_VERSION_MAJOR && RUBY_API_VERSION_MAJOR==2 ruby_sysinit(&argc, &argv); { RUBY_INIT_STACK; ruby_init(); } #endif #if _DEBUG || (__GNUC__ && !NDEBUG) openstudio::Logger::instance().standardOutLogger().setLogLevel(Debug); openstudio::FileLogSink fileLog(openstudio::toPath(logfilepath)); fileLog.setLogLevel(Debug); #else openstudio::Logger::instance().standardOutLogger().setLogLevel(Warn); #endif bool cont = true; while(cont) { cont = false; std::vector<std::string> modules; modules.push_back("openstudioutilitiescore"); modules.push_back("openstudioutilitiesbcl"); modules.push_back("openstudioutilitiesidd"); modules.push_back("openstudioutilitiesidf"); modules.push_back("openstudioutilities"); modules.push_back("openstudiomodel"); modules.push_back("openstudiomodelcore"); modules.push_back("openstudiomodelsimulation"); modules.push_back("openstudiomodelresources"); modules.push_back("openstudiomodelgeometry"); modules.push_back("openstudiomodelhvac"); modules.push_back("openstudioenergyplus"); modules.push_back("openstudioruleset"); //try { // Initialize the embedded Ruby interpreter boost::shared_ptr<openstudio::detail::RubyInterpreter> rubyInterpreter( new openstudio::detail::RubyInterpreter(openstudio::getOpenStudioRubyPath(), openstudio::getOpenStudioRubyScriptsPath(), modules)); // Initialize the argument getter QSharedPointer<openstudio::ruleset::RubyUserScriptArgumentGetter> argumentGetter( new openstudio::ruleset::detail::RubyUserScriptArgumentGetter_Impl<openstudio::detail::RubyInterpreter>(rubyInterpreter)); openstudio::OpenStudioApp app(argc, argv, argumentGetter); openstudio::Application::instance().setApplication(&app); try { return app.exec(); } catch (const std::exception &e) { LOG_FREE(Fatal, "OpenStudio", "An unhandled exception has occurred: " << e.what()); cont = true; QMessageBox msgBox; msgBox.setWindowTitle("Unhandled Exception"); msgBox.setIcon(QMessageBox::Critical); msgBox.setText("An unhandled exception has occurred."); msgBox.setInformativeText(e.what()); msgBox.setStandardButtons(QMessageBox::Retry | QMessageBox::Close); msgBox.button(QMessageBox::Retry)->setText("Relaunch"); if (msgBox.exec() == QMessageBox::Close) { cont = false; } } catch (...) { LOG_FREE(Fatal, "OpenStudio", "An unknown exception has occurred."); cont = true; QMessageBox msgBox; msgBox.setWindowTitle("Unknown Exception"); msgBox.setIcon(QMessageBox::Critical); msgBox.setText("An unknown exception has occurred."); msgBox.setStandardButtons(QMessageBox::Retry | QMessageBox::Close); msgBox.button(QMessageBox::Retry)->setText("Relaunch"); if (msgBox.exec() == QMessageBox::Close) { cont = false; } } } }
/*! \brief Manage the generation of the doxygen configuration and log files. * * \param prj cbProject* The project. * \return int 0 on success, -1 on failure. * \todo Revisit the path management code and add support for allowing the docs to be created in a different location * to the doxyfile via the OUTPUT_PATH setting e.g. using something like ../docs. */ int DoxyBlocks::GenerateDocuments(cbProject *prj) { wxString sMsg; // First, I need to change into the project directory. All following actions // will work with relative pathes. This way, stored pathes in doxygen // configuration files won't cause problems after moving to other places. // The current path is to be restored after my actions... wxString sOldPath = wxGetCwd(); wxFileName fnProject; fnProject.Assign(prj->GetFilename(), ::wxPATH_NATIVE); wxString sPrjPath = fnProject.GetPath(wxPATH_GET_VOLUME); wxSetWorkingDirectory(sPrjPath); // project name, name and path of base config file and logfile wxString sPrjName = fnProject.GetName(); wxString sOutputDir = m_pConfig->GetOutputDirectory(); wxString sDoxygenDir = wxT("doxygen"); wxString sCfgBaseFile = wxT("doxyfile"); wxString sLogFile = wxT("doxygen.log"); if(!sOutputDir.IsEmpty()){ sDoxygenDir = sOutputDir; } wxFileName fnOutput(sDoxygenDir, wxT("")); wxFileName fnDoxyfile(sDoxygenDir + wxFileName::GetPathSeparator() + sCfgBaseFile); wxFileName fnDoxygenLog(sDoxygenDir + wxFileName::GetPathSeparator() + sLogFile); fnOutput.Normalize(); fnDoxyfile.Normalize(); fnDoxygenLog.Normalize(); if (!fnOutput.Mkdir(0777, wxPATH_MKDIR_FULL)){ wxString sMsg = _("Failed. ") + fnOutput.GetFullPath() + _(" was not created."); AppendToLog(sMsg, LOG_WARNING); wxSetWorkingDirectory(sOldPath); return -1; } // I'm in the project directory, now create the doxygen configuration files WriteConfigFiles(prj, sPrjName, sPrjPath, sDoxygenDir, fnDoxyfile, fnDoxygenLog); if(!wxFile::Exists(fnDoxyfile.GetFullPath())){ wxString sMsg = _("Failed. ") + fnDoxyfile.GetFullPath() + _(" was not created."); AppendToLog(sMsg, LOG_WARNING); wxSetWorkingDirectory(sOldPath); return -1; } // Drop into the doxygen dir. wxSetWorkingDirectory(sPrjPath + wxFileName::GetPathSeparator() + sDoxygenDir); // now tango, launch doxygen... wxArrayString sOutput; wxArrayString sErrors; long ret; // Default command. wxString cmd = wxT("doxygen"); // If a path is configured, use that instead. wxString sDoxygenPath = Manager::Get()->GetMacrosManager()->ReplaceMacros(m_pConfig->GetPathDoxygen()); if(!sDoxygenPath.IsEmpty()){ cmd = sDoxygenPath; } ret = wxExecute(cmd + wxT(" ") + fnDoxyfile.GetFullPath(), sOutput, sErrors); if(ret != -1){ // Write doxygen logfile to the log or remove it if it's empty if(wxFile::Exists(fnDoxygenLog.GetFullPath())){ wxString sText; wxFFile fileLog(fnDoxygenLog.GetFullPath()); if(fileLog.IsOpened()){ fileLog.ReadAll(&sText); fileLog.Close(); } else{ AppendToLog(_("Failed to open ") + sLogFile, LOG_WARNING); } if(!sText.IsEmpty()){ AppendToLog(_("\nContents of doxygen's log file:")); AppendToLog(sText, LOG_WARNING); } else{ wxRemoveFile(sLogFile); } } // Run docs if HTML was created. if(m_pConfig->GetGenerateHTML()){ // Open the newly created HTML docs, if prefs allow. if(m_pConfig->GetRunHTML()){ RunHTML(); } if(m_pConfig->GetGenerateHTMLHelp()){ // Open the newly created CHM if prefs allow. if(m_pConfig->GetRunCHM()){ RunCompiledHelp(fnDoxyfile.GetPathWithSep() , sPrjName); } } } // tell the user where to find the docs sMsg = wxT("Success.\nYour documents are in: "); AppendToLog(sMsg + fnDoxyfile.GetPathWithSep()); } else{ // please google, install doxygen, set your path and... AppendToLog(wxString::Format(_("Execution of '%s' failed."), cmd.c_str()), LOG_ERROR); AppendToLog(_("Please ensure that the doxygen 'bin' directory is in your path or provide the specific path in DoxyBlocks' preferences.\n")); } // restore to before saved path and bye... wxSetWorkingDirectory(sOldPath); return ret; }