NodeTransitPtr VRMLFile::scanStream(std::istream &is) { startTime = getSystemTime(); _pSceneRootNode = NULL; _pCurrentFC = NULL; _nameFCMap.clear(); #ifdef OSG_DEBUG_VRML VRMLNodeHelper::resetIndent(); #endif if(is) { Inherited::scanStream(is); } SceneFileHandler::the()->updateReadProgress(100); NodeTransitPtr returnValue(_pSceneRootNode); _pSceneRootNode = NULL; _pCurrentFC = NULL; FINFO(("Full Time : %lf | Use Time %lf\n", getSystemTime() - startTime, useTime)); return returnValue; }
// redraw the window void display(void) { if(runBench) { static Int32 preframes = 5; // some drivers don't like to be swamped early if(--preframes < 0) { Time start,stop; start = getSystemTime(); for(UInt32 i = 0; i < 100; i++) { mgr->redraw(); } stop = getSystemTime(); FLOG(( "100 frames a %d parts in %.2f secs (%.0f parts/sec)\n", numParticles, stop-start, 100 * numParticles / (stop-start) )); exit(0); } } mgr->redraw(); }
bool InternalWindow::takeFocus(bool Temporary) { if(getFocused() && getDrawingSurface() != NULL && getDrawingSurface()->getFocusedWindow() == InternalWindowRefPtr(this)) { return true; } setFocused(true); if(Temporary || getDrawingSurface() == NULL) { focusGained(FocusEvent::create(ComponentRefPtr(this),getSystemTime(),Temporary, NULL)); } else { if(getDrawingSurface()->getFocusedWindow() != NULL) { getDrawingSurface()->getFocusedWindow()->giveFocus(this); } getDrawingSurface()->setFocusedWindow(this); focusGained(FocusEvent::create(ComponentRefPtr(this),getSystemTime(),Temporary, getDrawingSurface()->getFocusedWindow())); } return true; }
int save_json_to_file(const char* file_name, struct json_object *obj) { int len = strlen(json_object_get_string(obj)); char arr[len+1] ; memcpy(arr, json_object_get_string(obj), len); //fprintf(stdout,"%s Save json to file. filename=%s jsonContent=%s\n", getSystemTime( timeChar), file_name, arr); FILE *fp = fopen(file_name, "w"); if (NULL == fp) { fprintf(stderr, "%s Open file failed ! filename=%s\n", getSystemTime( timeChar),file_name); }else { int ret = fwrite(arr, len, 1, fp); if ( ret < 1) { fprintf(stderr, "%s write to file failed ! file_name=%s\n",getSystemTime( timeChar), file_name); } fclose(fp); } json_object_put(obj); //free the space. return 0; }
bool InternalWindow::takeFocus(bool Temporary) { if(getFocused() && getParentDrawingSurface() != NULL && getParentDrawingSurface()->getFocusedWindow() == this) { return true; } setFocused(true); if(Temporary || getParentDrawingSurface() == NULL) { FocusEventDetailsUnrecPtr Details(FocusEventDetails::create(this,getSystemTime(),Temporary, NULL)); focusGained(Details); } else { if(getParentDrawingSurface()->getFocusedWindow() != NULL) { getParentDrawingSurface()->getFocusedWindow()->giveFocus(this); } getParentDrawingSurface()->setFocusedWindow(this); FocusEventDetailsUnrecPtr Details(FocusEventDetails::create(this,getSystemTime(),Temporary, getParentDrawingSurface()->getFocusedWindow())); focusGained(Details); } return true; }
bool SharePtrGraphOp::traverse(Node *root) { if(!_includeSet.empty() && !_excludeSet.empty()) { FFATAL(("SharePtrGraphOp : Setting both the includes and excludes" "is not allowed!\n")); return false; } _typeMap .clear(); _shareCount.clear(); _totalTime = 0.0f; _compareTime = 0.0f; Time startTime = getSystemTime(); shareFC(root); _totalTime = getSystemTime() - startTime; // DEBUG SINFO << "SharePtrGraphOp::traverse: _totalTime: " << _totalTime << " _compareTime: " << _compareTime << "\n"; SINFO << "SharePtrGraphOp::traverse: Unique containers by type:\n"; FCTypeMapIt tmIt = _typeMap.begin(); FCTypeMapIt tmEnd = _typeMap.end (); for(; tmIt != tmEnd; ++tmIt) { UInt32 typeId = tmIt->first; FieldContainerType *fcType = FieldContainerFactory::the()->findType(typeId); SINFO << "TypeId [" << typeId << "] [" << (fcType != NULL ? fcType->getCName() : "") << "] -- [" << tmIt->second.size() << "]\n"; } SINFO << "SharePtrGraphOp::traverse: Shared containers by type:\n"; ShareCountIt scIt = _shareCount.begin(); ShareCountIt scEnd = _shareCount.end (); for(; scIt != scEnd; ++scIt) { UInt32 typeId = scIt->first; FieldContainerType *fcType = FieldContainerFactory::the()->findType(typeId); SINFO << "TypeId [" << typeId << "] [" << (fcType != NULL ? fcType->getCName() : "") << "] -- [" << scIt->second << "]\n"; } SINFO << std::flush; _typeMap .clear(); _shareCount.clear(); return true; }
/* load interface * @todo Evaluate options, see ScanParseSkel... * This interface will change due to AMZ modifications * @todo Option to trigger cleanup/free of allocated memory? May be faster * sometimes when you load many files not to clean up after every file but only * after loading all! */ NodeTransitPtr DXFFile::load(std::istream &is) { Time startTime = getSystemTime(); if ( ! _the->_entityTypeHierarchy.empty() ) { FWARNING(("DXFFile::load(): BUG! " "DXF entity structure not completely resolved! " "Unknown entity types will be ignored!\n")); for(StringToStringMMap::iterator itr = _the->_entityTypeHierarchy.begin(); itr != _the->_entityTypeHierarchy.end(); ++ itr) { FWARNING((" unresolved: %s <-- %s\n", itr->first.c_str(), itr->second.c_str() )); } } if(is) { if(DXFRecord::setStream(is)) { _the->read( NULL ); } } #if 0 //TODO: raus! if(szFilename != NULL) { std::string tmpName; _pathHandler.setBaseFile(szFilename); tmpName = _pathHandler.findFile(szFilename); if(tmpName.size() != 0) { if(DXFRecord::openStream(tmpName.c_str())) { _the->read( NULL ); DXFRecord::closeStream(); } } } #endif fprintf(stderr, "Full Time : %lf\n", getSystemTime() - startTime); NodeTransitPtr returnValue(_rootNodeP); _the->cleanup(); return returnValue; }
unsigned long NodeTime::getElapsedSince(unsigned long last_time){ unsigned long etime = getSystemTime()-last_time; if(etime>0){ return etime; } else{ return 4294967295 - last_time + getSystemTime(); } }
//#define TEST int main(int argc, char **argv){ #ifdef TEST BitMap bi(11); std::cout<<"initailize the bitmap"<<std::endl; bi.printBitMap(); std::cout<<"set the first bit to 1"<<std::endl; bi.setBit(1,true); bi.printBitMap(); std::cout<<"set the twenty bit to 1"<<std::endl; bi.setBit(2,true); bi.printBitMap(); bool tp=bi.getBit(2); std::cout<<"is the twenty bit 1? "<< tp<<std::endl; #endif const int init_length=10000000; const int am_factor=1; std::cout<<"bit_length:"<<init_length<<std::endl; std::cout<<"amplification factor:"<<am_factor<<std::endl; time_t t1; time(&t1); long tb1=getSystemTime(); std::cout<<"time: "<<ctime(&t1)<<std::endl; std::cout<<"our BitMap to execut ... "<<std::endl; BitMap bit(init_length); for(int t=0;t<am_factor;t++){ for(int i=0;i<init_length;i++) bit.setBit(i,true); } time_t t2; time(&t2); long tb2=getSystemTime(); std::cout<<"time: "<<ctime(&t2)<<std::endl; std::cout<<"using c++ bitset to execut ... "<<std::endl; std::bitset<init_length> bvec; for(int t=0;t<am_factor;t++){ for(int i=0;i<init_length;i++) bvec.set(i); } time_t t3; time(&t3); long tb3=getSystemTime(); std::cout<<"time: "<<ctime(&t3)<<std::endl; std::cout<<"tb1="<<tb1<<"\ttb2="<<tb2<<"\ttb3="<<tb3<<std::endl; std::cout<<"BitMap elapsed: "<<tb2-tb1<<"ms"<<std::endl; std::cout<<"bitset elapsed: "<<tb3-tb2<<"ms"<<std::endl; }
void bluetoothTest(void) { printf("Please disconnect, wait 10s, then reconnect!\n"); printf("All data will be logged, then printed after 15s.\n"); time_t start = getSystemTime(); while ((getSystemTime() - start) <= 15000); // Wait while (serialHasChar(BLUETOOTH)) { // Check serialWrite(USB, serialGet(BLUETOOTH)); } printf("\n\nDone!\n"); }
void XWindow::setFocused(bool Focused) { if(Focused) { XSetInputFocus(this->getDisplay(),this->getWindow(),RevertToParent, getSystemTime()); } else { XSetInputFocus(this->getDisplay(),None,RevertToParent, getSystemTime()); } }
void ledTask(void) { /* * Basic example of executing a task with a given frequency. * last contains the last time this task was executed. */ static time_t last = 0; if ((getSystemTime() - last) > 125) { // 125ms have passed xyLed(LED_ALL, LED_TOGGLE); // Do something... last = getSystemTime(); // Store new execution time } }
void VRMLFile::use(const Char8 *szName) { SceneFileHandler::the()->updateReadProgress(); Time beginUse = getSystemTime(); FieldContainerUnrecPtr pUsedFC; // try to find a container with the given name attachment #ifdef OSG_DEBUG_VRML indentLog(VRMLNodeHelper::getIndent(), PINFO); PINFO << "VRMLFile::use : looking for " << szName << std::endl; VRMLNodeHelper::incIndent(); #endif pUsedFC = findReference(szName); if(pUsedFC == NULL) { PWARNING << "No fieldContainer with name found to use" << szName << std::endl; } else { // assign nodepointer to current sf|mf field if(_pCurrNodeHelper != NULL) { if(pUsedFC->getType().isNode()) { Node *pRootNode = dynamic_pointer_cast<Node>(pUsedFC); pUsedFC = cloneTree(pRootNode); } _pCurrNodeHelper->setContainerFieldValue( pUsedFC, _pCurrentFieldDesc, _pCurrentFieldFC ); } } #ifdef OSG_DEBUG_VRML VRMLNodeHelper::decIndent(); #endif useTime += (getSystemTime() - beginUse); }
// use_cuda_time = 1: use cudaEventElapsedTime() // or use getSystemTime() void test_2gpu(float *d_send_data, float *d_recv_data, int size, int id0, int id1, bool use_cuda_time) { if(use_cuda_time) { cudaEvent_t start_event, stop_event; float time_memcpy; // version I //cudaEventCreate(&start_event); //cudaEventCreate(&stop_event); //cudaEventRecord(start_event, 0); // version II int eventflags = cudaEventBlockingSync; cudaEventCreateWithFlags(&start_event, eventflags); cudaEventCreateWithFlags(&stop_event, eventflags); cudaEventRecord(start_event, 0); for(int i=0; i<CNT; i++) { cudaMemcpy(d_recv_data, d_send_data, size*sizeof(float), cudaMemcpyDeviceToDevice); } std::cout << "hello, use_cuda_time" << std::endl; cudaEventRecord(stop_event, 0); cudaEventSynchronize(stop_event); cudaEventElapsedTime(&time_memcpy, start_event, stop_event); // ms std::cout << "Time is " << time_memcpy/1000. << "s" << std::endl; std::cout << "GPU" << id0 << " ---> GPU" << id1 << " :" << WIDTH*HEIGHT*sizeof(float)*CNT*1000./(1024*1024*time_memcpy) << "MB/s" << std::endl; cudaEventDestroy(start_event); cudaEventDestroy(stop_event); } else { //cudaEvent_t start_event; //cudaEventCreate(&start_event); long long start = getSystemTime(); for(int i=0; i<CNT; i++) { cudaMemcpy(d_recv_data, d_send_data, size*sizeof(float), cudaMemcpyDeviceToDevice); //cudaMemcpyPeer(d_recv_data, id1, d_send_data, id0, size*sizeof(float)); } //cudaEventRecord(start_event, 0); //cudaEventSynchronize(start_event); long long end = getSystemTime(); std::cout << "Time is " << (end-start)/1000. << "s" << std::endl; std::cout << "GPU" << id0 << " ---> GPU" << id1 << " :" << WIDTH*HEIGHT*sizeof(float)*CNT*1000./(1024*1024*(end - start+1)) << "MB/s" << std::endl; } //WIDTH*HEIGHT*4.*CNT/(1000*(end - start)) << "Mb/s" << std::endl; }
Log::Log(const Char8 *fileName, LogLevel logLevel) : std::ostream (_nilbufP == NULL ? _nilbufP = new Log::nilbuf() : _nilbufP), _logType (LOG_FILE ), _logLevel (logLevel ), _fileStream ( ), _logBuf ( ), _headerElem ( 0), _moduleHandling(LOG_MODULE_ALL), _moduleList ( ), _refTime ( 0) { if(_nilstreamP == NULL) _nilstreamP = new std::ostream(_nilbufP); for(UInt32 i = 0; i < sizeof(_streamVec)/sizeof(LogOStream *); i++) { #ifdef OSG_HAS_NILBUF _streamVec[i] = new LogOStream(_nilbufP); #else _streamVec[i] = new LogOStream(_nilStreamP->rdbuf()); #endif } _refTime = getSystemTime(); setHeaderElem(LOG_TYPE_HEADER); setLogFile (fileName); setLogLevel (logLevel); }
void CtrlAttiAng(void) { static float yawHold=0; static uint32_t tPrev=0; float yawRateTarget=0; float angTarget[3]={0}; float dt=0,t=0; // t=micros(); t = getSystemTime(); dt=(tPrev>0)?(t-tPrev):0; tPrev=t; angTarget[ROLL]=(float)(RC_DATA.ROOL); angTarget[PITCH]=(float)(RC_DATA.PITCH); // if(headFreeMode) // { // #ifdef YAW_CORRECT // float radDiff = -(imu.yaw - headHold) * M_PI_F / 180.0f; // #else // float radDiff = (imu.yaw - headHold) * M_PI_F / 180.0f; // #endif // float cosDiff = cosf(radDiff); // float sinDiff = sinf(radDiff); // float tarPitFree = angTarget[PITCH] * cosDiff + angTarget[ROLL] * sinDiff; // angTarget[ROLL] = angTarget[ROLL] * cosDiff - angTarget[PITCH] * sinDiff; // angTarget[PITCH] = tarPitFree; // } PID_Postion_Cal(&pitch_angle_PID,angTarget[PITCH],imu.pitch,dt); PID_Postion_Cal(&roll_angle_PID,angTarget[ROLL],imu.roll,dt); }
/*void servoRealese() { servo_position(180); _delay_ms(1000); servo_position(250); _delay_ms(1000); }*/ void Timer_Hook(void) { if(matchIsStarted() == 1 && getSystemTime() > 90000) { PORTG = 0xff; stop(HARD_STOP); while(1); } }
void DialogWindow::produceDialogWindowClosed(UInt32 intOption, std::string strInput) { const DialogWindowEventUnrecPtr TheEvent = DialogWindowEvent::create( this,getSystemTime(),intOption,strInput); for(DialogWindowListenerSetConstItor SetItor(_DialogWindowListeners.begin()) ; SetItor != _DialogWindowListeners.end() ; ++SetItor) { (*SetItor)->dialogClosed(TheEvent); } _Producer.produceEvent(DialogWindowClosedMethodId,TheEvent); }
//------------------------------------------------------------------------------------------------ void ChsEngine::run( void )const{ double currentTime = getSystemTime(); double timeInterval = currentTime - lastTime; lastTime = currentTime; this->getGame()->onUpdate(); ChsSceneManager::sharedInstance()->update( timeInterval ); ChsHUDManager::sharedInstance()->update( timeInterval ); this->getRenderSystem()->render(); }
void WindowEventProducer::produceKeyTyped(const KeyEventDetails::Key& TheKey, const UInt32& Modifiers) { //Check if Input is blocked if(_BlockInput) { return; } KeyEventDetailsUnrecPtr Details = KeyEventDetails::create( this, getSystemTime(), TheKey, Modifiers, this ); WindowEventProducerBase::produceKeyTyped(Details); }
void PopupMenu::removeItem(MenuItemRefPtr Item) { MFChildrenType::iterator FindResult = editMFChildren()->find(Item); if(FindResult != editMFChildren()->end()) { editMFChildren()->erase(FindResult); producePopupMenuContentsChanged(PopupMenuEvent::create(PopupMenuRefPtr(this), getSystemTime())); } }
DWORD WINAPI runServer() { enum bool sAdded = false; unsigned char c; while ( 1 ) { Sleep( 40 ); if ( sAdded == false && ( getSystemTime() % 30 ) == 0 ) { sAdded = true; AddStamp(); } else if ( getSystemTime() % 30 == 15 ) sAdded = false; detectKey(); } }
void DragGestureRecognizer::produceDragGestureRecognized(ComponentRefPtr TheComponent, const Pnt2f &DragLocation) const { const DragGestureEventUnrecPtr e = DragGestureEvent::create(TheComponent, getSystemTime(), DragLocation); DragGestureListenerSet Listeners(_DragGestureListeners); for(DragGestureListenerSetConstItor SetItor(Listeners.begin()) ; SetItor != Listeners.end() ; ++SetItor) { (*SetItor)->draqGestureRecognized(e); } }
void PopupMenu::cancel(void) { if(getVisible()) { clearSelection(); setVisible(false); producePopupMenuCanceled(PopupMenuEvent::create(PopupMenuRefPtr(this), getSystemTime())); } }
void statusTask(void) { static time_t last = 100; // Don't begin immediately static uint32_t lastDuration = 0; if (((getSystemTime() - last) >= STATUSDELAY) && (!(state & STATE_OUTPUT))) { last = getSystemTime(); printf("p%.2f %.2f %.2f\n", orientation.vPitch, orientation.vRoll, orientation.vYaw); printf("q%li %li\n", sumFlightTask / countFlightTask, lastDuration); printf("r%.2f %.2f\n", pidStates[0].intMin, pidStates[0].intMax); printf("s%.2f %.2f\n", pidStates[0].outMin, pidStates[0].outMax); printf("t%.3f %.3f %.3f\n", pidStates[0].kp, pidStates[0].ki, pidStates[0].kd); printf("u%.2f %.2f\n", pidOutput[PITCH], pidOutput[ROLL]); printf("v%i %i %i %i\n", motorSpeed[0], motorSpeed[1], motorSpeed[2], motorSpeed[3]); printf("w%.2f\n", orientation.pitch); printf("x%.2f\n", orientation.roll); printf("y%.2f\n", orientation.yaw); printf("z%.2f\n", getVoltage()); lastDuration = getSystemTime() - last; } }
void UIViewport::changed(ConstFieldMaskArg whichField, UInt32 origin, BitVector details) { Inherited::changed(whichField, origin, details); if(whichField & ViewComponentFieldMask) { clearChildren(); if(getViewComponent() != NULL) { pushToChildren(getViewComponent()); } } if((whichField & ViewSizeFieldMask) && getViewComponent() != NULL) { updateViewComponentSize(); produceStateChanged(ChangeEvent::create(UIViewportRefPtr(this), getSystemTime())); } if((whichField & ViewPositionFieldMask) && getViewComponent() != NULL) { getViewComponent()->editPosition().setValues(-getViewPosition().x(),-getViewPosition().y()); produceStateChanged(ChangeEvent::create(UIViewportRefPtr(this), getSystemTime())); } if((whichField & ViewSizeFieldMask) || (whichField & ViewPositionFieldMask) || (whichField & SizeFieldMask)) { produceStateChanged(ChangeEvent::create(UIViewportRefPtr(this), getSystemTime())); } if(whichField & SizeFieldMask && getViewComponent() != NULL && (getViewComponent()->getScrollableTracksViewportHeight() || getViewComponent()->getScrollableTracksViewportWidth())) { updateViewComponentSize(); } }
void AbstractMutableComboBoxModel::produceSelectionChanged(FieldContainerRefPtr Source, const Int32& CurrentIndex, const Int32& PreviousIndex) { const ComboBoxSelectionEventUnrecPtr e = ComboBoxSelectionEvent::create(Source, getSystemTime(), CurrentIndex, PreviousIndex); ComboBoxSelectionListenerSet SelectionListenerSet(_SelectionListeners); for(ComboBoxSelectionListenerSetConstIter SetItor(SelectionListenerSet.begin()) ; SetItor != SelectionListenerSet.end() ; ++SetItor) { (*SetItor)->selectionChanged(e); } _Producer.produceEvent(SelectionChangedMethodId,e); }
void AbstractMutableComboBoxModel::produceListDataContentsChanged(FieldContainerRefPtr Source, UInt32 index0, UInt32 index1) { const ListDataEventUnrecPtr e = ListDataEvent::create(Source, getSystemTime(), index0, index1); ListDataListenerSet DataListenerSet(_DataListeners); for(ListDataListenerSetConstIter SetItor(DataListenerSet.begin()) ; SetItor != DataListenerSet.end() ; ++SetItor) { (*SetItor)->contentsChanged(e); } _Producer.produceEvent(ListDataContentsChangedMethodId,e); }
void VideoWrapper::produceCycled(void) { VideoEventUnrecPtr TheEvent = VideoEvent::create(VideoWrapperRefPtr(this), getSystemTime()); VideoListenerSet Listeners(_VideoListeners); for(VideoListenerSetConstItor SetItor(Listeners.begin()) ; SetItor != Listeners.end() ; ++SetItor) { (*SetItor)->cycled(TheEvent); } _Producer.produceEvent(VideoCycledMethodId,TheEvent); }
void AbstractCellEditor::produceEditingStopped(void) { const ChangeEventUnrecPtr TheEvent = ChangeEvent::create(NULL, getSystemTime()); CellEditorListenerSet CellEditorListenerSet(_CellEditorListeners); for(CellEditorListenerSetConstItor SetItor(CellEditorListenerSet.begin()) ; SetItor != CellEditorListenerSet.end() ; ++SetItor) { (*SetItor)->editingStopped(TheEvent); } _Producer.produceEvent(EditingStoppedMethodId,TheEvent); }