void ActionRotationMatrix::execute(ExecutionState* state) { DataModelLogger* RUNLOG = state->getLogger(); errno = EOK; SensorHandler* sensor = SensorHandler::setupSensor(SENSOR_TYPE_ROTATION_MATRIX, state); if (!sensor) return; sensor_event_t* event = sensor->retrieveEvent(); delete sensor; if (NULL == event) return; RUNLOG->debug( SSTR( "Retrieved: A_X=" << event->rotation_matrix[1] << " A_Y=" << event->rotation_matrix[2] << " A_Z=" << event->rotation_matrix[3] << " B_X=" << event->rotation_matrix[4] << " B_Y=" << event->rotation_matrix[5] << " B_Z=" << event->rotation_matrix[6] << " C_X=" << event->rotation_matrix[7] << " C_Y=" << event->rotation_matrix[8] << " C_Z=" << event->rotation_matrix[9])); state->setUserProperty("ROT_MAT_A_X", SSTR(event->rotation_matrix[1])); state->setUserProperty("ROT_MAT_A_Y", SSTR(event->rotation_matrix[2])); state->setUserProperty("ROT_MAT_A_Z", SSTR(event->rotation_matrix[3])); state->setUserProperty("ROT_MAT_B_X", SSTR(event->rotation_matrix[4])); state->setUserProperty("ROT_MAT_B_Y", SSTR(event->rotation_matrix[5])); state->setUserProperty("ROT_MAT_B_Z", SSTR(event->rotation_matrix[6])); state->setUserProperty("ROT_MAT_C_X", SSTR(event->rotation_matrix[7])); state->setUserProperty("ROT_MAT_C_Y", SSTR(event->rotation_matrix[8])); state->setUserProperty("ROT_MAT_C_Z", SSTR(event->rotation_matrix[9])); delete event; }
unsigned long NetworkUsage::getBytes(Direction direction, std::string interface) { LOG->trace("getBytes"); std::string raw_data = AdvancedTools::invoke("ifconfig -v " + interface); std::string regex_string = SSTR( (direction == INBOUND ? "input" : "output") << ": +[0-9]+ +[^ ]+ +([0-9]+) +bytes"); regex_t exp; if (0 != regcomp(&exp, regex_string.c_str(), REG_EXTENDED | REG_ICASE)) { LOG->error("Error compiling regular expression."); errno = EIO; return 0; } regmatch_t input_matches[2]; if (0 != regexec(&exp, raw_data.c_str(), 2, input_matches, 0)) { LOG->error(SSTR("Could not match raw data: " << raw_data)); errno = EAGAIN; return 0; } std::string bytes_string = raw_data.substr(input_matches[1].rm_so, input_matches[1].rm_eo - input_matches[1].rm_so); unsigned long bytes = 0; try { bytes = Common::StringToNumber<unsigned long>(bytes_string); } catch (...) { LOG->error(SSTR("Could not convert to unsigned long: " << bytes_string)); errno = EAGAIN; return 0; } errno = EOK; return bytes; }
void TriggerAltimeter::blockUntilActive(ExecutionState* state) { DataModelLogger* RUNLOG = state->getLogger(); SensorHandler* sensor = SensorHandler::setupSensor(SENSOR_TYPE_ALTIMETER, state, isValueTrue(getParameter("HIGH_PRECISION", state))); if (!sensor) throw ExecutionAbortedException(); sensor_event_t* event; std::vector<std::string>* values; for (;;) { // Check if we are still running if (!state->isRunning()) throw ExecutionAbortedException(); // Retrieve event with values event = sensor->retrieveEvent(); // Check if event was successfully retrieved if (NULL == event) continue; // Check returned values values = new std::vector<std::string>(); RUNLOG->debug(SSTR("Retrieved: ALT=" << event->altitude_s.altitude)); values->push_back(/*ALTITUDE*/SSTR(event->altitude_s.altitude)); delete event; if (checkRequirements(state, values)) break; } delete sensor; }
/** * Allows to attempt the sub-m-gram payload retrieval for m==n * @see GenericTrieBase */ inline void get_n_gram_payload(m_gram_query & query, MGramStatusEnum & status) const { //First ensure the context of the given sub-m-gram LAYERED_BASE_ENSURE_CONTEXT(query, status); //If the context is successfully ensured, then move on to the m-gram and try to obtain its payload if (status == MGramStatusEnum::GOOD_PRESENT_MGS) { //Store the shorthand for the context and end word id TLongId & ctx_id = query.get_curr_ctx_ref(); const TShortId & word_id = query.get_curr_end_word_id(); LOG_DEBUG << "ctx_id: " << ctx_id << ", m_end_word_idx: " << SSTR(query.m_curr_end_word_idx) << ", end word id: " << word_id << END_LOG; //Get the next context id const phrase_length & level_idx = query.get_curr_level_m2(); if (get_ctx_id(level_idx, word_id, ctx_id)) { LOG_DEBUG << "ctx_id: " << ctx_id << END_LOG; TNGramsMap::const_iterator result = m_n_gram_map_ptr->find(ctx_id); if (result == m_n_gram_map_ptr->end()) { //The payload could not be found LOG_DEBUG1 << "Unable to find " << SSTR(LM_M_GRAM_LEVEL_MAX) << "-gram data for ctx_id: " << SSTR(ctx_id) << ", word_id: " << SSTR(word_id) << END_LOG; status = MGramStatusEnum::BAD_NO_PAYLOAD_MGS; } else { //There is data found under this context query.set_curr_payload(&result->second); LOG_DEBUG << "The payload is retrieved: " << result->second << END_LOG; } } else { //The payload could not be found LOG_DEBUG << "The payload id could not be found!" << END_LOG; status = MGramStatusEnum::BAD_NO_PAYLOAD_MGS; } LOG_DEBUG << "Context ensure status is: " << status_to_string(status) << END_LOG; } }
void ActionRecordPicture::photoRecordingStatusCallback(camera_handle_t handle, camera_buffer_t* buf, void *context) { (void) handle; ExecutionState* state = (ExecutionState*) context; std::string outfile = state->getExecutionProperty("ACTION_ActionRecordPicture_OUTFILE"); DataModelLogger* RUNLOG = state->getLogger(); if (buf->frametype != CAMERA_FRAMETYPE_JPEG) { RUNLOG->error("Failed to save image: Wrong format"); return; } QFile file(QString::fromStdString(outfile)); if (!file.open(QFile::WriteOnly)) { RUNLOG->error("Failed to save image: Cannot open file"); return; } int fd = file.handle(); int index = 0; while (index < (int) buf->framedesc.jpeg.bufsize) { int rc = write(fd, &buf->framebuf[index], buf->framedesc.jpeg.bufsize - index); if (rc > 0) { index += rc; } else if (rc == -1) { if ((errno == EAGAIN) || (errno == EINTR)) continue; RUNLOG->error(SSTR("Failed to save image: " << strerror(errno))); close(fd); return; } } close(fd); RUNLOG->trace(SSTR("Saved image with size " << buf->framedesc.jpeg.bufsize)); state->getRuntimeResources()->callbackFinished(); }
void Game::HandleView(sf::View &view, sf::View &static_view, sf::RenderWindow &window){ if(sf::Keyboard::isKeyPressed(sf::Keyboard::W)) view.move(0, -16); if(sf::Keyboard::isKeyPressed(sf::Keyboard::A)) view.move(-16, 0); if(sf::Keyboard::isKeyPressed(sf::Keyboard::S)) view.move(0, 16); if(sf::Keyboard::isKeyPressed(sf::Keyboard::D)) view.move(16, 0); window.setView(static_view); money_text.setString("Money: " + SSTR(values.Money())); window.draw(money_text); static bool help_toggled = true; static bool key_released = true; if(sf::Keyboard::isKeyPressed(sf::Keyboard::H) and key_released == true){ help_toggled = !help_toggled; key_released = false; }else if(!sf::Keyboard::isKeyPressed(sf::Keyboard::H)) key_released = true; if(help_toggled){ help_text.setString("building price: " + SSTR(values.BuildingPrice()) + "\nclaim & upgrade price = 10\nmoney cap = " + SSTR(values.MoneyCap()) + "\n\nc = claim\nr = build resource\nb = build bank\nu = improve\np = sell for 10\n\ntoggle help = h"); window.draw(help_text); } }
/** * Allows to attempt the sub-m-gram payload retrieval for m==n * @see GenericTrieBase */ inline void get_n_gram_payload(typename BASE::T_Query_Exec_Data & query, MGramStatusEnum & status) const { //First ensure the context of the given sub-m-gram LAYERED_BASE_ENSURE_CONTEXT(query, status); //If the context is successfully ensured, then move on to the m-gram and try to obtain its payload if (status == MGramStatusEnum::GOOD_PRESENT_MGS) { //Store the shorthand for the context and end word id TLongId & ctx_id = query.m_last_ctx_ids[query.m_begin_word_idx]; const TShortId & word_id = query.m_gram[query.m_end_word_idx]; const TLongId key = TShortId_TShortId_2_TLongId(ctx_id, word_id); //Search for the map for that context id TNGramsMap::const_iterator result = m_n_gram_map_ptr->find(key); if (result == m_n_gram_map_ptr->end()) { //The payload could not be found LOG_DEBUG1 << "Unable to find " << SSTR(MAX_LEVEL) << "-gram data for ctx_id: " << SSTR(ctx_id) << ", word_id: " << SSTR(word_id) << END_LOG; status = MGramStatusEnum::BAD_NO_PAYLOAD_MGS; } else { //There is data found under this context query.m_payloads[query.m_begin_word_idx][query.m_end_word_idx] = &result->second; LOG_DEBUG << "The payload is retrieved: " << result->second << END_LOG; } } }
/** * Allows to attempt the sub-m-gram payload retrieval for m==1. * The retrieval of a uni-gram data is always a success * @see GenericTrieBase */ inline void get_unigram_payload(typename BASE::T_Query_Exec_Data & query) const { //Get the word index for convenience const TModelLevel & word_idx = query.m_begin_word_idx; LOG_DEBUG << "Getting the payload for sub-uni-gram : [" << SSTR(word_idx) << "," << SSTR(word_idx) << "]" << END_LOG; //The data is always present. query.m_payloads[word_idx][word_idx] = &m_1_gram_data[query.m_gram[word_idx]]; };
void writeBufferToFile( int aSampleRate, int aNumChannels, bool broadcastUpdate ) { // quick assertion if ( DiskWriter::cachedBuffer == 0 ) return; aNumChannels = 1; // TODO : currently MONO only (see appendBuffer above) // we improve the use of the CPU resources // by creating a small local thread // TODO: do it ? (this non-threading blocks the renderer, but nicely omits issue w/ continuous writes ;) ) //pthread_t t1; //pthread_create( &t1, NULL, &print_message, NULL ); // copy string contents for appending of filename std::string outputFile = std::string( DiskWriter::outputDirectory.c_str()); int bufferSize = DiskWriter::outputBufferSize; // uh oh.. recorded less than maximum available in buffer ? cut silence if ( DiskWriter::outputWriterIndex < bufferSize ) { bufferSize = DiskWriter::outputWriterIndex; short int* tempBuffer = new short int[ bufferSize ]; for ( int i = 0; i < bufferSize; ++i ) tempBuffer[ i ] = DiskWriter::cachedBuffer[ i ]; write_wav( outputFile.append( SSTR( recordingFileName )), bufferSize, tempBuffer, aSampleRate, aNumChannels ); delete[] tempBuffer; } else { write_wav( outputFile.append( SSTR( recordingFileName )), bufferSize, DiskWriter::cachedBuffer, aSampleRate, aNumChannels ); } DiskWriter::flushOutput(); // free memory if ( broadcastUpdate ) { // broadcast update via JNI, pass buffer identifier name to identify last recording jmethodID native_method_id = getJavaMethod( JavaAPIs::RECORDING_UPDATE ); if ( native_method_id != 0 ) { JNIEnv* env = getEnvironment(); if ( env != 0 ) env->CallStaticVoidMethod( getJavaInterface(), native_method_id, recordingFileName ); } } //void* result; //pthread_join( t1, &result ); }
void mesRecCallback(rc_mes_client::server msg) { if(msg.cell == 1) { if(msg.status == 0) { boost::unique_lock<boost::mutex> lock(_orderMutex); _blue = msg.blue; _red = msg.red; _yellow = msg.yellow; if(_blue == 0 && _red == 0 && _yellow == 0) { // Log printConsole("Empty order received.. Doing nothing!"); } else { _mesOrder = true; // Log printConsole("Order received.. Red: " + SSTR(_red) + " Blue: " + SSTR(_blue) + " Yellow: " + SSTR(_yellow)); printConsole("Waiting for MR!"); } } else { if(_waitForRobot) { // Move forward for 8 seconds moveCoveyerBelt(8); // Log printConsole("MR is at conveyer! Running for 8 seconds!"); _waitForRobot = false; } else { boost::unique_lock<boost::mutex> lock(_startConveyerMutex); _startConveyer = true; startConveyerBelt(); // Log printConsole("MR is at robot! Processing order!"); _waitForRobot = true; } } } }
/** * write the contents of the write buffer into * an output file, this will only write content * up until the point if was written to in case * the buffer wasn't full yet */ void writeBufferToFile( int aSampleRate, int aNumChannels, bool broadcastUpdate ) { // quick assertion if ( DiskWriter::cachedBuffer == 0 ) return; // we can improve the use of the CPU resources // by creating a local thread // TODO: do it ? (this non-threading blocks the renderer, but nicely omits issue w/ continuous writes ;) ) //pthread_t t1; //pthread_create( &t1, NULL, &print_message, NULL ); // copy string contents for appending of filename std::string outputFile = std::string( DiskWriter::outputDirectory.c_str()); int bufferSize = DiskWriter::outputBufferSize; // uh oh.. recorded less than maximum available in buffer ? cut silence if ( DiskWriter::outputWriterIndex < bufferSize ) { bufferSize = DiskWriter::outputWriterIndex; short int* tempBuffer = new short int[ bufferSize ]; for ( int i = 0; i < bufferSize; ++i ) tempBuffer[ i ] = DiskWriter::cachedBuffer[ i ]; write_wav( outputFile.append( SSTR( AudioEngine::recordingFileId )), bufferSize, tempBuffer, aSampleRate, aNumChannels ); delete[] tempBuffer; // free memory of temporary buffer } else { write_wav( outputFile.append( SSTR( AudioEngine::recordingFileId )), bufferSize, DiskWriter::cachedBuffer, aSampleRate, aNumChannels ); } DiskWriter::flushOutput(); // free memory if ( broadcastUpdate ) { // broadcast update via JNI, pass buffer identifier to identify last recording Observer::broadcastRecordingUpdate( AudioEngine::recordingFileId ); } //void* result; //pthread_join( t1, &result ); }
bool ARPAGramBuilder<WordIndexType, CURR_LEVEL>::parse_line(TextPieceReader & line) { LOG_DEBUG << "Processing the " << CURR_LEVEL << "-Gram (?) line: '" << line << "'" << END_LOG; //We expect a good input, so the result is set to false by default. bool result = false; //First tokenize as a pattern "prob \t gram \t back-off" if (parse_to_gram(line)) { //Prepare the N-gram and for being added to the trie m_m_gram.prepare_for_adding(); LOG_DEBUG << "Adding a " << SSTR(CURR_LEVEL) << "-Gram " << (string) m_m_gram << " to the Trie" << END_LOG; //Add the obtained N-gram data to the Trie m_add_garm_func(m_m_gram); } else { //If we could not parse the line to gram then it should //be the beginning of the next m-gram section result = true; } LOG_DEBUG << "Finished processing the " << CURR_LEVEL << "-Gram (?) line: '" << line << "', it is " << (result ? "NOT " : "") << "accepted" << END_LOG; return result; }
std::string MentalState::to_string() const { std::string label = ""; switch (get_happiness()) { case HAPPINESS::DEPRESSED: label = "Depressed"; break; case HAPPINESS::SAD: label = "Sad"; break; case HAPPINESS::TROUBLED: label = "Troubled"; break; case HAPPINESS::NEUTRAL: label = "Whatever"; break; case HAPPINESS::CONTENT: label = "Content"; break; case HAPPINESS::HAPPY: label = "Happy!"; break; case HAPPINESS::EUPHORIC: label = "Euphoric"; break; } return (label + " (" + SSTR(m_value) + ")"); }
void trackAndDrawObjects(cv::Mat& image, int frameNumber, std::vector<cv::LatentSvmDetector::ObjectDetection> detections, std::vector<kstate>& kstates, std::vector<bool>& active, std::vector<cv::Scalar> colors, const sensor_msgs::Image& image_source) { std::vector<kstate> tracked_detections; cv::TickMeter tm; tm.start(); //std::cout << endl << "START tracking..."; doTracking(detections, frameNumber, kstates, active, image, tracked_detections, colors); tm.stop(); //std::cout << "END Tracking time = " << tm.getTimeSec() << " sec" << endl; //ROS int num = tracked_detections.size(); std::vector<cv_tracker::image_rect_ranged> rect_ranged_array; std::vector<int> real_data(num,0); std::vector<int> obj_id(num, 0); std::vector<int> lifespan(num, 0); //ENDROS for (size_t i = 0; i < tracked_detections.size(); i++) { kstate od = tracked_detections[i]; cv_tracker::image_rect_ranged rect_ranged; //od.rect contains x,y, width, height rectangle(image, od.pos, od.color, 3); putText(image, SSTR(od.id), cv::Point(od.pos.x + 4, od.pos.y + 13), cv::FONT_HERSHEY_SIMPLEX, 0.55, od.color, 2); //ROS obj_id[i] = od.id; // ? rect_ranged.rect.x = od.pos.x; rect_ranged.rect.y = od.pos.y; rect_ranged.rect.width = od.pos.width; rect_ranged.rect.height = od.pos.height; rect_ranged.range = od.range; rect_ranged.min_height = od.min_height; rect_ranged.max_height = od.max_height; rect_ranged_array.push_back(rect_ranged); real_data[i] = od.real_data; lifespan[i] = od.lifespan; //ENDROS } //more ros cv_tracker::image_obj_tracked kf_objects_msg; kf_objects_msg.type = object_type; kf_objects_msg.total_num = num; copy(rect_ranged_array.begin(), rect_ranged_array.end(), back_inserter(kf_objects_msg.rect_ranged)); // copy vector copy(real_data.begin(), real_data.end(), back_inserter(kf_objects_msg.real_data)); // copy vector copy(obj_id.begin(), obj_id.end(), back_inserter(kf_objects_msg.obj_id)); // copy vector copy(lifespan.begin(), lifespan.end(), back_inserter(kf_objects_msg.lifespan)); // copy vector kf_objects_msg.header = image_source.header; image_objects.publish(kf_objects_msg); //cout << "."<< endl; }
int main(){ int N; scanf("%d", &N); std::set<int> unvisited; int nums[N+1]; std::string result = ""; for(int i = 1; i <= N; i++){ scanf("%d", &nums[i]); unvisited.insert(nums[i]); } int current = 1; int cycles = 0; while(unvisited.size() > 0){ while(true){ result += SSTR(current); result += " "; if(unvisited.find(current) == unvisited.end()) break; unvisited.erase(current); current = nums[current]; } result += "\n"; current = *unvisited.begin(); cycles++; } printf("%d\n", cycles); printf("%s", result.c_str()); }
void getArdroneBatt(ardrone_autonomy::Navdata X) { float battery = X.batteryPercent; visualization_msgs::Marker batt; batt.header.frame_id = "/cortex"; batt.header.stamp = ros::Time(); batt.ns = "battery_status"; batt.id = 0; batt.type = visualization_msgs::Marker::TEXT_VIEW_FACING; batt.action = visualization_msgs::Marker::ADD; batt.pose.position.x = 3; batt.pose.position.y = -2.5; batt.pose.position.z = 0; batt.scale.z = 0.3; batt.color.a = 1.0; float red = (((100-battery)/100)-.5)/.5; float green = (battery-50/50); if (red>1){red = 1; green = 0;} batt.color.r = red; batt.color.g = green; batt.color.b = 0.0; batt.text = "Battery: "+SSTR(battery)+"%"; batt.lifetime = ros::Duration(); battery_pub.publish(batt); }
std::string BolaEnemigo::serializar(){ std::string buffer; buffer = SSTR(BOLASNOW << " " << posicion.x << " " << posicion.y << " " << angulo << " " << radio); return buffer; }
/** * Tokenise a given piece of text into a space separated list of text pieces. * @param text the piece of text to tokenise * @param gram the gram container to put data into */ inline void set_m_gram_from_text(TextPieceReader &text) { //Set all the "computed hash level" flags to "undefined" memset(m_hash_level_row, M_GRAM_LEVEL_UNDEF, MAX_LEVEL * sizeof (TModelLevel)); //Initialize the actual level with undefined (zero) BASE::m_actual_level = M_GRAM_LEVEL_UNDEF; //Read the tokens one by one backwards and decrement the index while (text.get_first_space(BASE::m_tokens[BASE::m_actual_level])) { //Retrieve the word id BASE::m_word_ids[BASE::m_actual_level] = BASE::m_word_index.get_word_id(BASE::m_tokens[BASE::m_actual_level]); LOG_DEBUG2 << "The word: '" << BASE::m_tokens[BASE::m_actual_level] << "' is: " << SSTR(BASE::m_word_ids[BASE::m_actual_level]) << "!" << END_LOG; //Increment the counter ++BASE::m_actual_level; } //Set the actual end word index BASE::m_actual_end_word_idx = BASE::m_actual_level - 1; ASSERT_SANITY_THROW(((BASE::m_actual_level < M_GRAM_LEVEL_1) || (BASE::m_actual_level > MAX_LEVEL)), string("A broken N-gram query: ") + ((string) * this) + string(", level: ") + std::to_string(BASE::m_actual_level)); }
std::string Metadata::serializar(){ std::string buffer; buffer = SSTR(tipo << " " << posXCamara << " " << posYCamara << " " << altoCamara << " " << anchoCamara << " " << escala << " " << vidas << " " << puntaje << " " << tamanioXMundo << " " << tamanioYMundo << " " << mensaje); return buffer; }
std::string Fireball::serializar(){ std::string buffer; buffer = SSTR(FUEGO << " " << posicion.x << " " << posicion.y << " " << angulo << " " << baseMayor << " " << altura << " " << activeSprite ); return buffer; }
bool TriggerAltimeter::isActive(ExecutionState* state) { DataModelLogger* RUNLOG = state->getLogger(); std::vector<std::string>* values = new std::vector<std::string>(); errno = EOK; SensorHandler* sensor = SensorHandler::setupSensor(SENSOR_TYPE_ALTIMETER, state); if (!sensor) return false; sensor_event_t* event = sensor->retrieveEvent(); delete sensor; if (NULL == event) return false; RUNLOG->debug(SSTR("Retrieved: ALT=" << event->altitude_s.altitude)); values->push_back(/*ALTITUDE*/SSTR(event->altitude_s.altitude)); delete event; return checkRequirements(state, values); }
/** * write the contents of the write buffer into * an output file, this will only write content * up until the point if was written to in case * the buffer wasn't full yet */ void writeBufferToFile( int aSampleRate, int aNumChannels, bool broadcastUpdate ) { // quick assertion if ( cachedBuffer == 0 ) return; // copy string contents for appending of filename std::string outputFile = std::string( outputDirectory.c_str()); int bufferSize = outputBufferSize; // recorded less than maximum available in buffer ? cut silence // by writing recording into temporary buffers if ( outputWriterIndex < bufferSize ) { bufferSize = outputWriterIndex; AudioBuffer* tempBuffer = new AudioBuffer( aNumChannels, bufferSize ); for ( int i = 0; i < bufferSize; ++i ) { for ( int c = 0; c < aNumChannels; ++c ) tempBuffer->getBufferForChannel( c )[ i ] = cachedBuffer->getBufferForChannel( c )[ i ]; } WaveWriter::bufferToFile( outputFile.append( SSTR( AudioEngine::recordingFileId )), tempBuffer, aSampleRate ); // free memory allocated by temporary buffer delete tempBuffer; } else { WaveWriter::bufferToFile( outputFile.append( SSTR( AudioEngine::recordingFileId )), cachedBuffer, aSampleRate ); } flushOutput(); // free memory // broadcast update, pass buffer identifier to identify last recording if ( broadcastUpdate ) Notifier::broadcast( Notifications::RECORDING_STATE_UPDATED, AudioEngine::recordingFileId ); }
void ActionScreenLock::execute(ExecutionState* state) { DataModelLogger* RUNLOG = state->getLogger(); state->getRuntimeResources()->bpsInitialize(); navigator_request_events(NAVIGATOR_DEVICE_LOCK_STATE); bps_event_t* event = state->getRuntimeResources()->bpsGetEvent(navigator_get_domain(), NAVIGATOR_DEVICE_LOCK_STATE); navigator_stop_events(NAVIGATOR_DEVICE_LOCK_STATE); if (event) { RUNLOG->debug(SSTR("Retrieved lock state event")); state->setUserProperty("LOCK_STATE", SSTR( TriggerScreenLock::lockStateToString( navigator_event_get_device_lock_state(event)))); } else { RUNLOG->error("Did not receive lock state information"); } }
void MainWindow::on_createLODB_clicked() { m_gl->createLOD(m_ui->nFaces->value()); QString id = SSTR(m_gl->getLODs().size()).c_str(); m_gl->updateAllLODs(); m_ui->m_lods->addItem(id); m_ui->m_lods->setCurrentRow(m_gl->allModels.size()-1); m_gl->extUpdateGL(); }
/** * Allows to attempt the sub-m-gram payload retrieval for m==1. * The retrieval of a uni-gram data is always a success. * @see GenericTrieBase */ inline void get_unigram_payload(m_gram_query & query) const { //Get the uni-gram word id const word_uid word_id = query.get_curr_uni_gram_word_id(); //Store the uni-gram payload pointer and add the probability to the total conditional probability query.set_curr_payload(&m_1_gram_data[word_id]); LOG_DEBUG << "The uni-gram word id " << SSTR(word_id) << " payload : " << m_1_gram_data[word_id] << END_LOG; }
/** * Allows to attempt the sub-m-gram payload retrieval for m==1. * The retrieval of a uni-gram data is always a success * @see GenericTrieBase */ inline void get_unigram_payload(m_gram_query & query) const { //Get the uni-gram word id const word_uid word_id = query.get_curr_uni_gram_word_id(); //The data is always present. query.set_curr_payload(&m_1_gram_data[word_id]); LOG_DEBUG << "The uni-gram word id " << SSTR(word_id) << " payload : " << m_1_gram_data[word_id] << END_LOG; };
/** * Allows to retrieve the hash value for the sub-m-gram * defined by the parameters * @param begin_word_idx the begin word index of the sub-m-gram * @param end_word_idx the end word index of the sub-m-gram * @return the hash value for the given sub-m-gram */ inline uint64_t get_hash(TModelLevel begin_word_idx, const TModelLevel end_word_idx) const { //Define the reference to the previous level TModelLevel & prev_level_ref = const_cast<TModelLevel &> (m_hash_level_row[begin_word_idx]); LOG_DEBUG1 << "Getting hash values for begin/end index: " << SSTR(begin_word_idx) << "/" << SSTR(end_word_idx) << ", the previous computed begin level " << "is: " << SSTR(prev_level_ref) << END_LOG; //Define the reference to the hash row uint64_t(& hash_row_ref)[MAX_LEVEL] = const_cast<uint64_t(&)[MAX_LEVEL]> (m_hash_matrix[begin_word_idx]); //Compute the current level const TModelLevel curr_level = CURR_LEVEL_MAP[begin_word_idx][end_word_idx]; //Check if the given hash is already available. if (curr_level > prev_level_ref) { //Check if there has its been computed before for this row if (prev_level_ref == M_GRAM_LEVEL_UNDEF) { //If there has not been anything computed yet, //then first initialize the starting word hash_row_ref[begin_word_idx] = BASE::m_word_ids[begin_word_idx]; LOG_DEBUG1 << "word[" << SSTR(begin_word_idx) << "] = " << BASE::m_word_ids[begin_word_idx] << ", hash[" << SSTR(begin_word_idx) << "] = " << hash_row_ref[begin_word_idx] << END_LOG; ++begin_word_idx; } else { //This is the case of at least a bi-gram, but the actual //begin word index is the one stored from before begin_word_idx += prev_level_ref; } //Iterate on and compute the subsequent hashes, if any for (; begin_word_idx <= end_word_idx; ++begin_word_idx) { //Incrementally build up hash, using the previous hash value and the next word id hash_row_ref[begin_word_idx] = combine_hash(BASE::m_word_ids[begin_word_idx], hash_row_ref[begin_word_idx - 1]); LOG_DEBUG1 << "hash[" << SSTR(begin_word_idx) << "] = combine( word[" << SSTR(begin_word_idx) << "] = " << BASE::m_word_ids[begin_word_idx] << ", hash[" << SSTR(begin_word_idx - 1) << "] = " << hash_row_ref[begin_word_idx - 1] << " ) = " << hash_row_ref[begin_word_idx] << END_LOG; } //Set the processed level prev_level_ref = curr_level; } LOG_DEBUG1 << "Resulting hash value: " << hash_row_ref[end_word_idx] << END_LOG; //Return the hash value that must have been pre-computed return hash_row_ref[end_word_idx]; }
/* * * @brief spm_hwio_mmap * */ void spm_hwio_mmap(void) { static DalDeviceHandle *spmDALHandle; DALResult eResult; eResult = DAL_DeviceAttach(DALDEVICEID_HWIO, &spmDALHandle); if (eResult == DAL_SUCCESS) { DalHWIO_MapRegion(spmDALHandle, SSTR(SPM_BASE_NAME), &g_spmBasePtrAddress); } }
void ActionAzimuthPitchRoll::execute(ExecutionState* state) { DataModelLogger* RUNLOG = state->getLogger(); errno = EOK; SensorHandler* sensor = SensorHandler::setupSensor(SENSOR_TYPE_AZIMUTH_PITCH_ROLL, state); if (!sensor) return; sensor_event_t* event = sensor->retrieveEvent(); delete sensor; if (NULL == event) return; RUNLOG->debug( SSTR( "Retrieved: Azimuth=" << event->apr.azimuth << " Pitch=" << event->apr.pitch << " Roll=" << event->apr.roll)); state->setUserProperty("AZIMUTH", SSTR(event->apr.azimuth)); state->setUserProperty("PITCH", SSTR(event->apr.pitch)); state->setUserProperty("ROLL", SSTR(event->apr.roll)); delete event; }
void ActionLed::execute(ExecutionState* state) { DataModelLogger* USERLOG = state->getLogger(); errno = EOK; std::string blinkCountString = getParameter("COUNT"); std::string color = getParameter("COLOR"); int blinkCount = blinkCountString != "" ? Common::StringToNumber<int>(blinkCountString) : 1; state->getRuntimeResources()->bpsInitialize(); if (color == "STOP") { if (BPS_SUCCESS != led_cancel("1")) { StatementLOG->warning(SSTR("Error starting BPS: " << strerror(errno))); USERLOG->error(SSTR("Error stopping LED: " << strerror(errno))); } } else { if (BPS_SUCCESS != led_request_color("1", getColor(getParameter("COLOR")), blinkCount)) { StatementLOG->warning(SSTR("Error blinking LED: " << strerror(errno))); USERLOG->error(SSTR("Error blinking LED: " << strerror(errno))); } } }