bool qConsole::writeMessagesToFile(string strFilename) { ofstream fOutputFile(strFilename.c_str(), ios::app); if(!fOutputFile) { setMessage(MSG_ERROR, "qConsole", "writeMessagesToFile : Cannot open file '" + strFilename + "' for console output"); return false; } /* _ftime stuff ripped out of MSDN entry for time -> getting current */ struct __timeb64 timebuffer; char *timeline; char *test = (char*)malloc(sizeof(char) * 100); _ftime64( &timebuffer ); timeline = _ctime64( & ( timebuffer.time ) ); sprintf(test, "%.19s.%hu %s", timeline, timebuffer.millitm, &timeline[20] ); fOutputFile << "qConsole Console Output (Messages/Errors) for run at " << test; for(unsigned int i = 0; i < m_vMessageBuffer.size(); ++i) { fOutputFile << m_vMessageBuffer[i] << endl; } fOutputFile <<"--------------------------------------------"<<endl; free(test); fOutputFile.close(); return true; }
bool cLog::Print(const char *szText, ...) ///////////////////////////////////////////////////////////////////////////////////// { va_list l_va; __time64_t ltime; _time64( <ime ); char timedate [ 80 ]; sprintf ( timedate, _ctime64 ( <ime )); timedate[strlen(timedate) - 1] = 0; //Initialize variable argument list va_start(l_va, szText); //Open the log file for append if((m_file= fopen(LOG_FILENAME, "a+"))==NULL) return false; //Write the text and a newline fprintf (m_file, "%s : ", timedate); vfprintf(m_file, szText, l_va); putc('\n', m_file); //Close the file fclose(m_file); va_end(l_va); return true; }
char *wnt_ctime(const time_t *t) { static char future[] = "Fri Dec 31 23:59:59 1999"; char *buf = _ctime64(t); if(!buf) /* Y2.038K bug in 32bit... */ buf=future; else if(buf[8]=='0') buf[8]=' '; return buf; }
long WINAPI DLLExport GetFullString(LPRDATA rdPtr, long param1) { long p1=CNC_GetFirstExpressionParameter(rdPtr, param1, TYPE_INT); rdPtr->rHo.hoFlags |= HOF_STRING; if(p1==-1) return (long)"Error: Invalid TimeStamp"; __time64_t timestamp=(unsigned)p1; char* temp; if((temp=_ctime64(×tamp))==0) return (long)"Error: Invalid TimeStamp"; else return (long)temp; }
void InitLog() { FILE* pFile; pFile = fopen( "patchlog.txt", "w"); if ( pFile == NULL) return; __time64_t ltime; _time64( <ime); fprintf( pFile, "Log start : %s\n", _ctime64( <ime)); char szDir[ 512]; GetCurrentDirectory( sizeof( szDir), szDir); fprintf( pFile, "Current Directory : %s\n", szDir); fclose( pFile); }
CSEdDesktop::CSEdDesktop() : CGUIDesktop() { try{ assert(!SEdDesktop); SEdDesktop=this; RemoveFromTrash(); MsgAcceptConsume(MsgMouseL|MsgMouseM|MsgMouseR); // MsgSetProduce(MsgAll); CGUIWindowPanel* panel = new CGUIWindowPanel(0,sy-STD_PANEL_HEIGHT-STD_PANEL_SHIFT,styleSet->Get("Panel"),this,true,false,0,0); //0,-STD_PANEL_SHIFT (pridani nahoru) push=false; iconDefaultHandler = new CSEdDesktopIconHandler(); iconDefaultHandler->icons = new typeID[4]; // zadat velikost pole dle poctu icon (polozek typeID) SEdOpenedFiles = new CSEdOpenedFiles(); AddStartMenu(); InitDefaultIcons(); iconDefaultHandler->ShowFileBrowser(); AddToTrash(); } catch(CExc c) { mainGUI->LogError(c); // vypis informace o chybe na obrazovce jako DebugMessage (prozatimni reseni) __time64_t ltime; _time64( <ime ); DebugMessage(0,"%s : %2d:%2d - %s",_ctime64( <ime ), c.errnum, c.param, c.errstr); desktop=0; throw CExc(eGUI, E_INTERNAL,"CSEdDesktop::CSEdDesktop> Fatal error - cannot creat DESKTOP"); } }
void Ctr2SufManager::ctr2sufProc(vector<vector<Point_3> >& MeshBoundingProfile3D,vector<Point_3>& vecTestPoint) { clock_t start = clock(); struct __timeb64 timebuffer; char *timeline; _ftime64( &timebuffer ); timeline = _ctime64( & ( timebuffer.time ) ); printf( "The time is %.19s.%hu %s", timeline, timebuffer.millitm, &timeline[20] ); //common line case //compute the common line if( isComnCase ) { float tempparam[ 8 ]; for( int i = 0; i < 8; i ++) { tempparam[ i ] = pparam[ i ]; } ////////////////////////////////////////////////////////////////////////// /*for( int i = 0 ; i < 8; i ++ ) { cout<<tempparam[ i ]<<","; } cout<<endl;*/ ////////////////////////////////////////////////////////////////////////// computeComnLine( tempparam, tempparam + 4, comndir, comnpt); ////////////////////////////////////////////////////////////////////////// /*for( int i = 0 ; i < 8; i ++ ) { cout<<tempparam[ i ]<<","; } cout<<endl;*/ ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// //writeComnLineDB( tempparam, tempparam + 4, comndir, comnpt); ////////////////////////////////////////////////////////////////////////// } ////////////////////////////////////////////////////////////////////////// /*for( int i = 0; i < planenum + 4; i ++ ) { cout<<pparam[ 4* i ]<<"," <<pparam[ 4*i + 1]<<"," <<pparam[ 4*i + 2]<<"," <<pparam[ 4*i + 3]<<endl; } cout<<endl;*/ ////////////////////////////////////////////////////////////////////////// //preprocess data first int** pctrvermark; if( !ispreproced || isComnCase) { pctrvermark = preProcData(isComnCase); //reset showcontourvers for( int i = 0; i < showplanenum; i ++) delete []showctrvers[ i ]; delete []showctrvers; //copy the data from processed data, and reset size showplanenum = planenum; showctrvers = new float*[ showplanenum ]; showctredgenum = new int[ showplanenum ]; showctredges = new int*[ showplanenum ]; for( int i = 0; i < showplanenum; i++ ) { int versize = pctrvernum[ i ]*3; showctrvers[ i ] = new float[ versize ]; for( int j = 0 ; j < versize; j ++ ) showctrvers[ i ][ j ] = pctrvers[ i ][ j ]*DIM/PROCSIZE; showctredgenum[ i ] = pctredgenum[ i ]; int edgesize = pctredgenum[ i ] * 2; showctredges[ i ] = new int[ edgesize ]; for( int j = 0; j < showctredgenum[ i ]; j ++) { showctredges[ i ][ 2*j ] = pctredges[ i ][ 4*j ]; showctredges[ i ][ 2*j + 1 ] = pctredges[ i ][ 4*j + 1]; } } for( int i = 0; i < planenum; i ++) { int iVerIndBase=0; vector<Point_3> CurrentProfile3D; for( int j = 0;j < showctredgenum[ i ]; j++) { int v1 = showctredges[ i ][ 2*j ]; int v2 = showctredges[ i ][ 2*j + 1 ]; CurrentProfile3D.push_back(Point_3(showctrvers[ i ][ v1* 3], showctrvers[ i ][ v1* 3+1], showctrvers[ i ][ v1* 3+2])); if (v2==iVerIndBase) { iVerIndBase=iVerIndBase+CurrentProfile3D.size(); MeshBoundingProfile3D.push_back(CurrentProfile3D); CurrentProfile3D.clear(); } } } //for( int i = 0; i < planenum; i ++) //{ // vector<Point_3> CurrentProfile3D; // for( int j = 0;j < showctredgenum[ i ]; j++) // { // int v1 = showctredges[ i ][ 2*j ]; // glVertex3fv( &showctrvers[ i ][ v1* 3] ); // CurrentProfile3D.push_back(Point_3(showctrvers[ i ][ v1* 3], // showctrvers[ i ][ v1* 3+1], // showctrvers[ i ][ v1* 3+2])); // } // MeshBoundingProfile3D.push_back(CurrentProfile3D); //} } ////////////////////////////////////////////////////////////////////////// //for( int i = 0; i < planenum + 4; i ++ ) //{ // cout<<pparam[ 4* i ]<<"," // <<pparam[ 4*i + 1]<<"," // <<pparam[ 4*i + 2]<<"," // <<pparam[ 4*i + 3]<<endl; //} //cout<<endl; ////////////////////////////////////////////////////////////////////////// //partition // cout<<"------------------ PARTITION ------------------"<<endl; // cout<<"Starting............"<<endl; partition(); ///////////////////////////////////////////////////////////B/////////////// /*writePartitionOut("mmdebug/partition.txt");*/ ////////////////////////////////////////////////////////////////////////// // cout<<"DONE!"<<endl<<endl; //process data // cout<<"------------------ PUT CONTOUR INTO FACE ------------------"<<endl; putContourIntoFace( pctrvermark ); //SaveCtr2FaceInfo(); if( isComnCase ) { for( int i = 0; i < planenum; i ++ ) delete []pctrvermark[ i ]; delete []pctrvermark; } ////////////////////////////////////////////////////////////////////////// // ContourHandler::writeContourInFace( ssfacenum, ctrfvernum, ctrfverpos, ctrfvertype, // ctrfverval, ctrfedgenum, ctrfedge, ctrfedgetype, ctrfedgeval ); ////////////////////////////////////////////////////////////////////////// // cout<<"DONE!"<<endl<<endl; //go through each subspace to generate mesh // cout<<"-------- GENERATING MESH IN EACH SUBSPACE ------------"<<endl; //kw noted: vertices, edges and faces in each subspace //stitch them together finally floatvector* subMeshVer; intvector* subMeshEdge; intvector* subMeshFace; subMeshVer = new floatvector[ ssspacenum ]; subMeshEdge = new intvector[ ssspacenum ]; subMeshFace = new intvector[ ssspacenum ]; //initialize registration informaiton for stitching sverreg = new intvector[ ssvernum ]; sedgereg = new vector<intvector>[ ssedgenum ]; sedgesubedgemark = new intvector[ ssedgenum ]; sfacectrei = new intset[ ssfacenum ]; sfacespaci = new int[ ssfacenum * 2 ]; sfaceregface = new vector<intvector>[ ssfacenum ]; sfaceregver = new intvector[ ssfacenum ]; sfaceregedgever = new intvector[ ssfacenum ]; for( int i = 0; i < ssfacenum*2; i ++) { sfacespaci[ i ] = -1; } for( int spacei = 0; spacei < ssspacenum; spacei ++) { for( int facej = 0; facej < ssspacefacenum[ spacei ]; facej ++) { int facei = ssspace[ spacei ][ facej ]; if( sfacespaci[ 2 * facei ] == -1) sfacespaci[ 2 * facei ] = spacei; else sfacespaci[ 2*facei + 1 ] = spacei; } } ////////////////////////////////////////////////////////////////////////// /*ancestorlist.resize( ssfacenum * 2 ); ancestorlist_split.resize( ssfacenum * 2 );*/ ////////////////////////////////////////////////////////////////////////// //return; dbSpaceNum = ssspacenum; if( dbOneSpaceMode ) { if( dbCurSpace < dbSpaceNum ) { ctr2sufSubspaceProc( dbCurSpace, subMeshVer[ dbCurSpace ], subMeshEdge[ dbCurSpace ], subMeshFace[ dbCurSpace ]); //submeshedge is useless for stitching! subMeshEdge[ dbCurSpace ].clear(); } } //kw: here can use multi-thread to compute each submesh in parallel else{ // for( int i = 7; i< 8; i ++) for( int i = 0; i < ssspacenum; i ++) // for( int i = 2; i < 3; i ++) // for( int i = 54; i < 55; i ++) // for(int i = 0; i < 12; i ++) // for( int i = 14; i < 15; i ++) { cout<<"--- subspace " << i <<endl; ctr2sufSubspaceProc( i, subMeshVer[ i ], subMeshEdge[ i ], subMeshFace[ i ]); //submeshedge is useless for stitching! subMeshEdge[ i ].clear(); } } delete []subMeshEdge; ////////////////////////////////////////////////////////////////////////// //cout<<"before splitting, ancestors:"<<endl; //for( int i = 0; i < ssfacenum*2; i +=2 ) //{ // if( ancestorlist[ i ].size() == 0 ) // { // if( ancestorlist[ i + 1].size() == 0 ) // continue; // } // intset::iterator iter = ancestorlist[ i ].begin(); //// intset::iterator iter2 = ancestorlist[ i + 1].begin(); // while( iter != ancestorlist[ i ].end() ) // { // cout<<*iter<<" "; // iter++; // } // cout<<endl; // iter = ancestorlist[ i+1 ].begin(); // while( iter != ancestorlist[ i + 1 ].end() ) // { // cout<<*iter <<" "; // iter ++; // } // cout<<endl; // cout<<"\n"; //} //cout<<"=============================\n"; //cout<<"after splitting ancestors:"<<endl; //for( int i= 0; i < ssfacenum*2; i += 2 ) //{ // if( ancestorlist_split[ i ].size() == 0 ) // { // if( ancestorlist_split[ i + 1].size() == 0) // continue; // } // intset::iterator iter = ancestorlist_split[ i ].begin(); // while( iter != ancestorlist_split[ i ].end() ) // { // cout<<*iter <<" "; // iter++; // // cout<<endl; // } // cout<<endl; // iter = ancestorlist_split[ i + 1].begin(); // while( iter != ancestorlist_split[ i + 1].end() ) // { // cout<<*iter <<" "; // iter ++; // } // cout<<endl<<endl; //} ////////////////////////////////////////////////////////////////////////// //cout the faces registered on the contour edges /*for( int i = 0; i < ssfacenum; i ++ ) { int ctrnum = sfaceregface[ i ].size()/2; if( ctrnum == 0 ) continue; intset::iterator iter = ancestorlist_split[2* i ].begin(); for( int j = 0; j < ctrnum; j ++ ) { cout<<"("<<*iter<<":"<<sfaceregface[ i ][ 2*j ] .size()<<","<< sfaceregface[ i ][ 2*j +1 ].size()<<") "; iter++; } cout<<endl; }*/ ////////////////////////////////////////////////////////////////////////// //for( int i = 0; i < ssfacenum; i ++) //{ // ancestorlist[ i].clear(); // ancestorlist_split[ i ].clear(); //} //ancestorlist_split.clear(); //ancestorlist.clear(); ////////////////////////////////////////////////////////////////////////// //stitch all the subspaces together stitchMesh(subMeshVer,subMeshFace); clock_t endt = clock(); cout<<"time difference is:"<<endt - start<<endl; // struct __timeb64 timebuffer; // char *timeline; _ftime64( &timebuffer ); timeline = _ctime64( & ( timebuffer.time ) ); printf( "The time is %.19s.%hu %s", timeline, timebuffer.millitm, &timeline[20] ); // FaceGenerator::writeSubMeshOut( mver, mface, 99); //clear all the allocated space //for( int i = 0; i < ssspacenum; i ++) //{ // //subMeshVer[ i ].clear(); //// subMeshEdge[ i ].clear(); // subMeshFace[ i ].clear(); //} ////delete []subMeshVer; ////delete []subMeshEdge; //delete []subMeshFace; /*subMeshFace = NULL; subMeshVer = NULL;*/ //clear the registration information for subspace vertex, edge and face //sverreg for( int i = 0; i < ssvernum; i ++) sverreg[ i ].clear(); delete []sverreg; sverreg = NULL; //sedgereg for( int i= 0; i < ssedgenum; i ++) { for(unsigned int j = 0; j < sedgereg[ i ].size(); j ++) sedgereg[ i ][ j ].clear(); sedgereg[ i ].clear(); } delete []sedgereg; sedgereg = NULL; //sfacectrei, sfacespaci, sfaceregface, sfaceregver for( int i= 0; i < ssfacenum; i ++) { sfacectrei[ i ].clear(); // for( int j = 0; j < sfaceregface[ i ].size(); j ++ ) // sfaceregface[ i ][ j ].clear(); // sfaceregface[ i ].clear(); sfaceregver[ i ].clear(); } delete []sfacectrei; delete []sfacespaci; //delete []sfaceregface; delete []sfaceregver; sfacectrei = NULL; sfacespaci = NULL; //sfaceregface = NULL; sfaceregver = NULL; //set the mesh //clear if( mesh!= NULL ) delete mesh; //set mesh = new Mesh( mver, mface, ctrmedge, center, unitlen, PROCSIZE ); ////kw: get constrained vertices //set<int> ConstrVer; //for (unsigned int i=0;i<ctrmedge.size();i++) //{ // ConstrVer.insert(ctrmedge.at(i)); //} //for (set<int>::iterator SetIter=ConstrVer.begin();SetIter!=ConstrVer.end();SetIter++) //{ // vecTestPoint.push_back(Point_3(mver.at(3*(*SetIter))*DIM/PROCSIZE,mver.at(3*(*SetIter)+1)*DIM/PROCSIZE, // mver.at(3*(*SetIter)+2)*DIM/PROCSIZE)); //} mesh->setGLParam( width, height, nearplane, farplane); //clear mver.clear(); mface.clear(); ctrmedge.clear(); }
/*=========================================================================== * ReadContinuousLogData *--------------------------------------------------------------------------- * Description: Puts the node in continuous mode, reads the sensor data and * prints to the screen and logs data to user file until the user * interrupts. * * Return: HANDLE - handle to the opened comport *===========================================================================*/ void ReadContinuousLogData(int portNum) { int iCount = 0; BOOL bStopContinuous = FALSE; DWORD dwcharsRead = 0; I3dmgx3Set Record; BYTE cmd_return; int Curs_posY = 0; int Curs_posX = 0; int status = 0; int error_record = 0; int valid_check = 0; int valid_count = 0; char consoleBuff[60] = {0}; long valid_rec = 0; unsigned char error_cmd; char ComLogFile[256]; FILE *m_logFile; int LogFlag = 0; int error_count = 0; int errorCode =0, i=0; char fw[20] = {0}; char sn[20] = {0}; char mListSep[4]; char mDecSep[4]; LANGID langId; char szLanguage[256]; /*MAX_PATH]; */ char idchar[] = {'\x02', '\x00', '\x01', '\x03', '\x04'}; int m_timerconst = 62500; unsigned long AA_Time_Stamp=0; unsigned long AA_s_prev =0; float AA_convert = 0.0; float AA_prev = 0.0; struct __timeb64 timebuffer; char *timeline; _ftime64( &timebuffer ); timeline = _ctime64( & ( timebuffer.time ) ); while (LogFlag != 1){ printf("Enter Name of LogFile to use:"); scanf("%s", &ComLogFile); // 255); printf("logFile %s\n", ComLogFile); if ( ( m_logFile= fopen( ComLogFile, "w")) == NULL){ printf("File: %s not opened\n", ComLogFile); if(++error_count > 2) return; }else LogFlag = 1; } fprintf(m_logFile, "[SESSION START TAG]\n"); fprintf(m_logFile, "Session Start Time:%.19s.%hu \n", timeline, timebuffer.millitm ); fprintf(m_logFile, "Time Source: HOST\n"); GetLocaleInfo(LOCALE_SYSTEM_DEFAULT,LOCALE_SLIST,mListSep,4); fprintf(m_logFile, "List Separator: %s\n", mListSep); GetLocaleInfo(LOCALE_SYSTEM_DEFAULT,LOCALE_SDECIMAL,mDecSep,4); fprintf(m_logFile, "Decimal Separator: %s\n", mDecSep); langId = GetSystemDefaultLangID (); i = VerLanguageName (langId, szLanguage, 256); //dwSize = MAX_PATH; fprintf(m_logFile, "Language: %s\n", szLanguage); while(valid_check == 0) { errorCode = i3dmgx3_getFirmwareVersion(portNum, &fw[0]); if (errorCode < 0){ purge_port(portNum); printf("Firmware Error %d\n",errorCode); if (valid_count++ > 6) { printf("Please Halt Current Data Display and Retry, count %d\n", valid_count); return; } }else if (errorCode >= 0){ valid_check = 1; } } /*------------------------------------------------------------------ * 0xEA get serial information number, model and options (as string) *-----------------------------------------------------------------*/ valid_count =0; for ( i=0; i<4; i++){ //cycles through the valid device options errorCode = i3dmgx3_getDeviceIdentiy(portNum, idchar[i], &sn[0]); if (errorCode < 0){ purge_port(portNum); i--; if (valid_count++ >6){ printf("Error Read Device Identity: %s\n", explainError(errorCode)); } } else{ switch( i ) { case 0: fprintf(m_logFile, "Device Name: %s\n",sn); break; case 1: fprintf(m_logFile, "Device Model: %s\n",sn); break; case 2: fprintf(m_logFile, "Device FirmWare Version: %s\n", fw); fprintf(m_logFile, "Device Serial Number: %s\n", sn); break; case 3: fprintf(m_logFile, "Device Options: %s\n", sn); break; case 4: default: break; } } } fprintf(m_logFile, "Command C2\n[DATA START TAG]\n\t Time%s Accel X%s Accel Y%s Accel Z%s AngRate X%s AngRate Y%s AngRate Z%s Ticks\n", mListSep, mListSep, mListSep, mListSep, mListSep, mListSep, mListSep); //put the node in continuous mode status =SetContinuousMode(portNum, 0xC2); printf("setcontinuous is %d", status); //set up the output for the data printf("\n\n"); printf("Reading streaming data (hit s to Stop streaming).\n"); printf("C2___________________________Acceleration_______________________________\n"); printf(" X Y Z \n"); /* acceleration values go here */ printf("\n\n\n"); printf("C2____________________________Angular_Rate______________________________\n"); printf(" X Y Z \n"); /* angle rate values go here */ getConXY(&Curs_posX, &Curs_posY); printf("\n\n\n\n"); //continue until the user hits the <s>top key while(!bStopContinuous) { if(ReadNextRecord(portNum, &Record, &cmd_return) != SUCCESS) error_record++; if (cmd_return == 0xC2){ if (AA_s_prev == 0){ fprintf(m_logFile, "\t 0.00"); AA_s_prev = Record.timer; //AA_Time_Stamp; } else { AA_convert = ((float)(Record.timer - AA_s_prev)/m_timerconst); //19660800); AA_s_prev = Record.timer; //AA_Time_Stamp; AA_prev = AA_prev + AA_convert; fprintf(m_logFile, "\t%6.2f", AA_prev); } //move to the acceleration position and print the data sprintf(consoleBuff, "\t%2.6f\t\t%2.6f\t\t%2.6f", Record.setA[0], Record.setA[1], Record.setA[2]); fprintf(m_logFile, "%s %2.6f%s %2.6f%s %2.6f%s ", mListSep, Record.setA[0],mListSep, Record.setA[1], mListSep, Record.setA[2], mListSep); setConXY(Curs_posX, Curs_posY -5, &consoleBuff[0]); sprintf(consoleBuff, "\t%2.6f\t\t%2.6f\t\t%2.6f", Record.setB[0], Record.setB[1], Record.setB[2]); fprintf(m_logFile, "%2.6f%s %2.6f%s %2.6f%s %u\n", Record.setB[0], mListSep, Record.setB[1], mListSep, Record.setB[2], mListSep, Record.timer); setConXY(Curs_posX, Curs_posY, &consoleBuff[0]); valid_rec++; }else if (cmd_return != 0xc4){ if((cmd_return == 0xCB || cmd_return == 0xD3) && error_record == 0) error_cmd = cmd_return; else error_record++; } //check for a key every 50 iterations if(iCount++ > 50) { int ch = 0; if(ReadCharNoReturn(&ch)){ bStopContinuous = (ch == 's' || ch == 'S'); } //reset the counter iCount = 0; } } printf("\n\n\nStopping Continuous Mode..."); StopContinuousMode(portNum); printf("stopped.\n"); fclose(m_logFile); if (error_record > 0) printf("Number of records received in error were %d and received successfully %d\n", error_record, valid_rec); else printf("All %d records read successfully.\n", valid_rec); }