bool executeIfPythonFunctionObject::condition() { if(!parallelNoRun()) { setRunTime(time()); } if(writeDebug()) { Info << "Evaluating " << conditionCode_ << endl; } bool result=evaluateCodeTrueOrFalse(conditionCode_,true); if(writeDebug()) { Info << "Evaluated to " << result << endl; } return result; }
dynamicFunctionObjectListProxy::dynamicFunctionObjectListProxy ( const word& name, const Time& t, const dictionary& dict, const char *providerNameStr ) : functionObjectListProxy( name, t, dict, false ) { word providerName(providerNameStr); if(providerName.size()==0) { providerName=word(dict.lookup("dictionaryProvider")); } provider_=dynamicDictionaryProvider::New( providerName, dict, (*this) ); if( readBool(dict.lookup("readDuringConstruction")) ) { if(writeDebug()) { Info << this->name() << " list initialized during construction" << endl; } read(dict); } }
void *_main_thread_start(void* dummmy) { _thread_sethere(_place_first()); _task * t = (_task*)malloc(sizeof(_task)); /*t -> total_memory = 0; t -> total_memory_string=0; t -> total_memory_value_class=0; t -> total_memory_value_array=0; t -> total_memory_class=0; t -> total_memory_update_array=0;*/ _thread_setspecific((void*)t); runmain(); //fprintf(stderr, "MAIN TOTAL MEMORY USED =%lu=\n", (((_task*) _thread_getspecific()) -> total_memory)); // print_memory(((_task*) _thread_getspecific())); int32_t success = _terminate_all_places(); //free the mainthread task if(success== EXIT_SUCCESS) { writeDebug("Wrote all termination messages"); }else { writeError("termination messages Failed"); } }
void MapWidget::paintGL() { QTime time; time.start(); g_debugWidget->reset(); g_dataResource->getMapObject()->newFrame(); if (m_width < 1 || m_height < 1) { return; } QOpenGLFunctions gl(context()); m_transform.setGl(&gl); m_transform.setTransform(m_width, m_height, *m_transform.getMapParam()); glClearColor(0.05, 0.05, 0.1f, 1); glClear(GL_COLOR_BUFFER_BIT); glEnable(GL_MULTISAMPLE); double starPlus = m_transform.getMapParam()->m_starMagAdd; QEasingCurve curve(QEasingCurve::InExpo); m_transform.getMapParam()->m_maxStarMag = starPlus + 5 + 12.0 * curve.valueForProgress(FRAC(m_transform.getMapParam()->m_fov, SkMath::toRad(90), SkMath::toRad(0.5))); m_transform.getMapParam()->m_fov = CLAMP(m_transform.getMapParam()->m_fov, SkMath::toRad(0.01), R90); //qDebug() << m_transform.getMapParam()->m_maxStarMag; //qDebug() << SkMath::toDeg(m_transform.getMapParam()->m_fov); m_renderer->render(&m_transform); /* QPainter p; m_overlayImage->fill(Qt::transparent); static int a = 100; a++; p.begin(m_overlayImage); p.setRenderHint(QPainter::Antialiasing); p.setPen(Qt::green); p.drawLine(0, 0, 1000, 1000); p.drawLine(500, 10, 5000, 1000); p.fillRect(QRect(10, 10, 100, 100 + a), QColor(255, 255, 0, 128)); p.end(); m_painterOverlay->render(&m_transform, m_overlayImage); */ g_debugWidget->addText("FSP", QString::number(1000 / (float)time.elapsed())); //qDebug() << time.elapsed() << 1000 / (float)time.elapsed(); //qDebug() << SkMath::toDeg(mapParam.m_fov); writeDebug(); }
int main(void) { _place_init(); //writeDebug("relayer places init"); int max_places = _max_places(); pthread_t streams[max_places]; _init_relay(); int i = 0; int pl = 0; int relayhere = _here(); writeDebug("relayer started"); for(i=0; i<max_places; i++){ pl = i+10+(max_places*relayhere); pthread_create(&streams[i], NULL, _faninany_start, (void *)pl); writeDebug("relayer started thread"); } for(i=0; i<max_places; i++){ pthread_join(streams[i], NULL); } }
void scriptError(const char *msg, ...) { char *buf = new char[50]; va_list args; va_start (args, msg); vsprintf (buf,msg, args); perror (buf); va_end (args); writeDebug("[Script error] %s", buf); }
void dynamicFunctionObjectListProxy::initFunctions() { string text(provider_->getDictionaryText()); if(Pstream::parRun()) { string localText=text; Pstream::scatter(text); if(text!=localText) { Pout << "WARNING: In dynamicFunctionObjectListProxy::initFunctions() " << "for " << name() << " the text of the dictionary is different from the master" << endl << " Overwritten local version with master"; } } { fileName fName=obr_.time().path()/word(this->name()+".dictionaryText"); OFstream o(fName); o << text.c_str(); } IStringStream inStream( text ); dynamicDict_.set( new dictionary(inStream) ); { fileName fName=obr_.time().path()/word(this->name()+".dictionaryDump"); OFstream o(fName); o << dynamicDict_(); } if(!dynamicDict_->found("functions")) { FatalErrorIn("dynamicFunctionObjectListProxy::initFunctions()") << "Dictionary for" << this->name() << " does not have an entry 'functions'" << endl << exit(FatalError); } functions_.set( new functionObjectList( time(), dynamicDict_() ) ); if(writeDebug()) { Info << this->name() << " list initialized with " << functions_->size() << " FOs" << endl; } }
void topoSet::writeDebug ( Ostream& os, const pointField& coords, const label maxLen ) const { // Bounding box of contents. boundBox bb(pointField(coords, toc()), true); os << "Set bounding box: min = " << bb.min() << " max = " << bb.max() << " meters. " << endl << endl; label n = 0; topoSet::const_iterator iter = begin(); if (size() <= maxLen) { writeDebug(os, coords, maxLen, iter, n); } else { label halfLen = maxLen/2; os << "Size larger than " << maxLen << ". Printing first and last " << halfLen << " elements:" << endl << endl; writeDebug(os, coords, halfLen, iter, n); os<< endl << " .." << endl << endl; for (; n < size() - halfLen; ++n) { ++iter; } writeDebug(os, coords, halfLen, iter, n); } }
void moveFile(char* from, char* destination) // TODO: try to reduce the amount of dynamic memory allocation { char* filename = strrfind(from, '/') + 1; size_t name_len = strlen(destination) + strlen(filename) + 1; char* end_name; if (!strend(destination, "/")) { ++name_len; end_name = malloc(name_len); snprintf(end_name, name_len, "%s/%s", destination, filename); } else { end_name = malloc(name_len); snprintf(end_name, name_len, "%s%s", destination, filename); } // add (some number) to the end of the filename to avoid overwriting data char* safe_name = malloc(name_len); strcpy(safe_name, end_name); size_t safe_len; for (int m = 1; access(safe_name, F_OK) != -1; ++m) { free(safe_name); safe_len = name_len + getDigitCount(m) + 3; safe_name = malloc(safe_len); snprintf(safe_name, safe_len, "%s (%d)", end_name, m); } free(end_name); end_name = safe_name; name_len = safe_len; // shouldn't be necessary, but it keeps a safe state // write to status log writeDebug("Rename \"%s\" to \"%s\"", from, end_name); if (rename(from, end_name) < 0) { writeWarning("Unable to move file to destination"); } else { // send notification char notify_message[FILE_NAME_MAX]; snprintf(notify_message, FILE_NAME_MAX, "Rename \"%s\" to \"%s\"", from , end_name); if (isPaused()) { sendPausedNotification(from, end_name); } else { sendMovingNotification(from, end_name); } } free(end_name); }
bool writeAndEndPythonFunctionObject::endRunNow() { if(!parallelNoRun()) { setRunTime(time()); } if(writeDebug()) { Info << "Evaluating " << conditionCode_ << endl; } bool result=evaluateCodeTrueOrFalse(conditionCode_,true); if(writeDebug()) { Info << "Evaluated to " << result << endl; } if(result) { Info << "Stopping because python code " << conditionCode_ << " evaluated to 'true' in " << name() << endl; } return result; }
int WriteMsg(place_t placeToWriteMsg, int msgType, uint64_t sizeOfBlob, void * blob) { writeDebug("started writing msg"); int success = ProcessMsg(placeToWriteMsg, msgType, sizeOfBlob, blob); writeDebugExtraPlace("Finished writing msg to place ",placeToWriteMsg); if (success == EXIT_SUCCESS) { return EXIT_SUCCESS; } else { return EXIT_FAILURE; } }
int32_t _terminate_all_places(){ int32_t success = -1; //tell everyone else to exit int32_t i; //writeDebug("Starting thread _terminate_all_places at place"); for (i = _max_places()-1; i >= 0 ; --i) { success = dispatcher_terminate(_toplace(i)); if (success != EXIT_SUCCESS) { writeError("ERROR: Failed thread _terminate_all_places at place"); return EXIT_FAILURE; } } writeDebug("Finished thread _terminate_all_places at place"); return success; }
int ReadMsg(struct Msg* messageStruct, place_t _rec_from) { writeDebug("Read Msg started reading messages"); //struct Msg messageStruct; int success = DecodeMsg(messageStruct, _rec_from); if (success) { return EXIT_SUCCESS; } else { return EXIT_FAILURE; } }
scalar setDeltaTWithPythonFunctionObject::deltaT() { if(!parallelNoRun()) { setRunTime(time()); } if(writeDebug()) { Pbug << "Evaluating " << deltaTCode_ << endl; } scalar result=evaluateCodeScalar(deltaTCode_,true); if(writeDebug()) { Pbug << "Evaluated to " << result << endl; } if(result!=time().deltaT().value()) { Info << "Changing timestep because " << deltaTCode_ << " evaluated to " << result << "(current deltaT: " << time().deltaT().value() << " in " << name() << endl; } return result; }
bool executeIfEnvironmentVariableFunctionObject::condition() { bool exists=env(variableName_); if(writeDebug()) { Info << "Variable " << variableName_ << " " << (exists ? "exists" : "does not exist") << endl; } string content; switch(fitVariableMode_) { case fvmExists: return exists; case fvmDoesNotExist: return !exists; case fvmFitsRegexp: if(exists) { content=getEnv(variableName_); if(writeDebug()) { Info << "Content of " << variableName_ << ": " << content << (contentRegexp_.match(content) ? " fits " : " does not fit ") << endl; } return contentRegexp_.match(content); } break; default: FatalErrorIn("executeIfEnvironmentVariableFunctionObject::condition()") << "The fitting mode " << fitVariableModeNames_[fitVariableMode_] << " is not implemented" << endl << exit(FatalError); } return false; }
bool Save::write(){ if (imfat){ file = fopen("midicontrol.cfg", "w"); writeGeneral(); writeDebug(); writeMidiIn(); writeKaoss(); writeMixer(); writeSliders(); fclose(file); return true; } else { return false; } }
bool WriteIfInterpreterFunctionObject<Wrapper>::executeCode(const string code) { if(!this->parallelNoRun()) { this->setRunTime(this->time()); } this->dictionariesToInterpreterStructs(); if(this->writeDebug()) { Info << "Evaluating " << code << endl; } bool result=this->evaluateCodeTrueOrFalse(code,true); if(writeDebug()) { Info << "Evaluated to " << result << endl; } return result; }
void tarch::logging::CommandLineLogger::debug(const long int& timestampMS, const std::string& timestampHumanReadable, const std::string& machineName, const std::string& trace, const std::string& message) { if (writeDebug(trace)) { #if !defined(Debug) assertion(false); #endif std::string outputMessage = constructMessageString( "debug", timestampMS, timestampHumanReadable, machineName, trace, message ); tarch::multicore::Lock lockCout( _semaphore ); out() << outputMessage; out().flush(); } }
int main(){ Film *film; int n = 200, vTot, k; double alpha, *prt, *Ft, *Fexp; film = (Film*)allocArrayMemory(sizeof(Film), n); //citirea readInputFile("DateFilme.txt", film, n, &vTot); qsort(film, n, sizeof(Film), cmpFilm);//sortarea reRank(film, n, vTot);//calculul rangurilor writeDebug(film, n); scrierePuncte("NumeLeader2.txt", film, n); //partea de pana aici calculeaza alpha; alpha = 0.897675610478; prt = Zipf(alpha, n); writeOutputFiles(film, n, prt); calcVectRep(prt, film, n, &Ft, &Fexp); for(k=0;(k<n) && (Ft[k]<0.75);k++);// ";" nu e din greasala!!!!!!!!! printf("\nNumarul de file salvate in cache este k = %d\n", k); simulareVizualizari(Ft, n, k); simulareVizualizari(Fexp, n, k); if(prt) free(prt); if(Ft) free(prt); if(Fexp) free(prt); free(film); getch(); return 0; }
void *_faninany_start(void* _rec_from_ptr) { int _rec_from = (int)_rec_from_ptr; int exit = 1; //writeDebug("thread faninany started at relay"); while (exit) { struct Msg* msgStruct = (struct Msg*) malloc(sizeof(struct Msg)); int fdToReadFrom = _rec_from; tpl_node * tn; tpl_bin tb; tn = tpl_map("S(iiU)B", msgStruct, &tb); //writeDebug("MSG Mapped"); int validity = (fcntl(fdToReadFrom, F_GETFL) != -1); if (validity) { writeDebugExtraPlace("File descriptor is accessible", fdToReadFrom); } else { writeErrorExtraPlace("File descriptor is not accessible", fdToReadFrom); } //writeDebug("started trying to load msg"); int success = tpl_load(tn, TPL_FD, fdToReadFrom); //writeDebug("Finished loading"); if (success == 0) { writeDebugExtraPlace("msg read on file descriptor", fdToReadFrom); } else { writeErrorExtraPlace("msg failed to read on file descriptor", fdToReadFrom); // return EXIT_FAILURE; } tpl_unpack(tn, 0); tpl_pack(tn, 0); int fdToWrite = 99;//_get_write_fd(_write_to); //writeDebug("unpacking reading msg"); int pthreadRet1; int pthreadRet2; pthread_mutex_t writeLock = getMutexLock(); pthreadRet1 = pthread_mutex_lock(&writeLock); success = tpl_dump(tn, TPL_FD, fdToWrite); pthreadRet2 = pthread_mutex_unlock(&writeLock); if (pthreadRet1 == EXIT_FAILURE) { writeError("Thread locked unsuccessful msg"); } else if (pthreadRet2 == EXIT_FAILURE) { writeError("Thread unlocked unsuccessful"); } else { writeDebug("thread locked and unlocked successful"); } if(msgStruct->msgType == TERMINATE){ exit = 0; } //writeDebug("tpl will be freed"); tpl_free(tn); _deallocate_msg(msgStruct); //writeDebug("tpl freed"); if (success == 0) { writeDebugExtraPlace("msg written on file descriptor", fdToReadFrom); } else { writeErrorExtraPlace("msg failed to read on file descriptor", fdToReadFrom); } } }
void* Run(cv::VideoCapture& capture) { int size = ivWidth*ivHeight; int count = 1; DebugInfo dbgInfo; cv::CascadeClassifier cascade; std::vector<cv::Rect> detectedFaces; std::vector<ObjectBox> trackBoxes; ObjectBox detectBox; // Initialize MultiObjectTLD #if LOADCLASSIFIERATSTART MultiObjectTLD p = MultiObjectTLD::loadClassifier((char*)CLASSIFIERFILENAME); #else MOTLDSettings settings(COLOR_MODE_RGB); settings.useColor = false; MultiObjectTLD p(ivWidth, ivHeight, settings); #endif if(cascadePath != "") cascade.load( cascadePath ); Matrix maRed; Matrix maGreen; Matrix maBlue; unsigned char img[size*3]; while(!ivQuit) { /* if(reset){ p = *(new MultiObjectTLD(ivWidth, ivHeight, COLOR_MODE_RGB)); reset = false; } if(load){ p = MultiObjectTLD::loadClassifier(CLASSIFIERFILENAME); load = false; } */ #if TIMING c_end = std::clock(); std::cout << "Total: " << (c_end-c_start) << std::endl; c_start = std::clock(); #endif // Grab an image if(!capture.grab()){ std::cout << "error grabbing frame" << std::endl; break; } cv::Mat frame; capture.retrieve(frame); frame.copyTo(curImage); //BGR to RGB // for(int j = 0; j<size; j++){ // img[j] = frame.at<cv::Vec3b>(j).val[2]; // img[j+size] = frame.at<cv::Vec3b>(j).val[1]; // img[j+2*size] = frame.at<cv::Vec3b>(j).val[0]; // } #if TIMING c_start1 = std::clock(); #endif for(int i = 0; i < ivHeight; ++i){ for(int j = 0; j < ivWidth; ++j){ img[i*ivWidth+j] = curImage.at<cv::Vec3b>(i,j).val[2]; img[i*ivWidth+j+size] = curImage.at<cv::Vec3b>(i,j).val[1]; img[i*ivWidth+j+2*size] = curImage.at<cv::Vec3b>(i,j).val[0]; } } #if TIMING c_end1 = std::clock(); std::cout << "time1: " << (c_end1-c_start1) << std::endl; #endif // for(int i = 0; i < ivHeight; ++i){ // for(int j = 0; j < ivWidth; ++j){ // curImage.at<cv::Vec3b>(i,j).val[2] = 0; // curImage.at<cv::Vec3b>(i,j).val[1] = 0; // curImage.at<cv::Vec3b>(i,j).val[0] = 0; // } // } // cv::imshow("MOCTLD", curImage); #if TIMING c_start2 = std::clock(); #endif // Process it with motld p.processFrame(img); #if TIMING c_end2 = std::clock(); std::cout << "time2: " << (c_end2-c_start2) << std::endl; #endif // Add new box if(mouseMode == MOUSE_MODE_ADD_BOX){ p.addObject(mouseBox); mouseMode = MOUSE_MODE_IDLE; } if(mouseMode == MOUSE_MODE_ADD_GATE){ p.addGate(gate); mouseMode = MOUSE_MODE_IDLE; } if(((count%20)==0) && cascadeDetect) { cascade.detectMultiScale( frame, detectedFaces, 1.1, 2, 0 //|CASCADE_FIND_BIGGEST_OBJECT //|CASCADE_DO_ROUGH_SEARCH |cv::CASCADE_SCALE_IMAGE, cv::Size(30, 30) ); Ndetections = detectedFaces.size(); for( std::vector<cv::Rect>::const_iterator r = detectedFaces.begin(); r != detectedFaces.end(); r++ ) { detectBox.x = r->x; detectBox.y = r->y; detectBox.width = r->width; detectBox.height = r->height; if(p.isNewObject(detectBox)) p.addObject(detectBox); } //printf("size detectedFaces: %i\n", detectedFaces.size()); } count++; // Display result HandleInput(); p.getDebugImage(img, maRed, maGreen, maBlue, drawMode); #if TIMING c_start3 = std::clock(); #endif BGR2RGB(maRed, maGreen, maBlue); #if TIMING c_end3 = std::clock(); std::cout << "time3: " << (c_end3-c_start3) << std::endl; #endif drawGate(); drawMouseBox(); dbgInfo.NObjects = p.getObjectTotal(); dbgInfo.side0Cnt = p.getSide0Cnt(); dbgInfo.side1Cnt = p.getSide1Cnt(); writeDebug(dbgInfo); cv::imshow("MOCTLD", curImage); p.enableLearning(learningEnabled); if(save){ p.saveClassifier((char*)CLASSIFIERFILENAME); save = false; } } //delete[] img; capture.release(); return 0; }