static void sample_tile(texgz_tex_t* src, texgz_tex_t* dst, int month, int x, int y, double latT, double lonL, double latB, double lonR) { assert(src); assert(dst); int m; int n; for(m = 0; m < SUBTILE_SIZE; ++m) { for(n = 0; n < SUBTILE_SIZE; ++n) { sample_data(src, dst, x, y, m, n, latT, lonL, latB, lonR); } } // export the tile char fname[256]; snprintf(fname, 256, "png256/%i/9/%i/%i.png", month, x, y); fname[255] = '\0'; mymkdir(fname); texgz_png_export(dst, fname); }
std::shared_ptr<dataset> generic_sample_factory::create_sample(const std::string & path_sample) { std::shared_ptr<dataset> sample_data(new dataset); size_t sample_dimension = 0; std::ifstream file_sample(path_sample); if (file_sample.is_open()) { std::string file_line; while(std::getline(file_sample, file_line)) { if (file_line.empty()) continue; double value = 0.0; point sample_point; std::istringstream stream_value(file_line); while(stream_value >> value) { sample_point.push_back(value); } if (sample_dimension == 0) { sample_dimension = sample_point.size(); } else { if (sample_dimension != sample_point.size()) { throw std::runtime_error("Points from input data set should have the same dimension."); } } sample_data->push_back(sample_point); } }
void loop() { PWR.deepSleep("00:00:10:00",RTC_OFFSET,RTC_ALM1_MODE2,ALL_OFF); if( intFlag & RTC_INT ) { Utils.blinkLEDs(1000); Utils.blinkLEDs(1000); Utils.blinkLEDs(1000); sample_data(); intFlag &= ~(RTC_INT); } PWR.clearInts(); }
/* * the disengage() method is responsible for deactivating the periodic * task and, if logging was enabled, for logging the final sample. This * method is called from before_exit() in java.cpp and is only called * after the WatcherThread has been stopped. */ void StatSampler::disengage() { if (!UsePerfData) return; if (!is_active()) return; // remove StatSamplerTask _task->disenroll(); delete _task; _task = NULL; // force a final sample sample_data(_sampled); }
// Every time the spi timer expires, we begin data collection one channel at a time static void spi_data_collection_evt_handler(void *pvParameter) { //static int intan_convert_channel = 0; //if (m_transfer_completed) //{ //while(app_uart_put(72) != NRF_SUCCESS); //m_transfer_completed = false; //} //while(app_uart_put(71) != NRF_SUCCESS); UNUSED_PARAMETER(pvParameter); //nrf_drv_gpiote_out_toggle(20); //printf("Ready to sample\r\n"); sample_data(); //while(app_uart_put(72) != NRF_SUCCESS); }
/* * the collect_sample() method is the method invoked by the * WatcherThread via the PeriodicTask::task() method. This method * is responsible for collecting data samples from sampled * PerfData instances every PerfDataSamplingInterval milliseconds. * It is also responsible for logging the requested set of * PerfData instances every _sample_count milliseconds. While * logging data, it will output a column header after every _print_header * rows of data have been logged. */ void StatSampler::collect_sample() { // future - check for new PerfData objects. PerfData objects might // get added to the PerfDataManager lists after we have already // built our local copies. // // if (PerfDataManager::count() > previous) { // // get a new copy of the sampled list // if (_sampled != NULL) { // delete(_sampled); // _sampled = NULL; // } // _sampled = PerfDataManager::sampled(); // } assert(_sampled != NULL, "list not initialized"); sample_data(_sampled); }
static void sample_subtile(texgz_tex_t* src, pak_file_t* pak, int x, int y, int i, int j, double latT, double lonL, double latB, double lonR) { assert(src); assert(pak); LOGD("debug x=%i, y=%i, i=%i, j=%i, latT=%lf, lonL=%lf, latB=%lf, lonR=%lf", x, y, i, j, latT, lonL, latB, lonR); // create dst texgz_tex_t* dst = texgz_tex_new(SUBTILE_SIZE, SUBTILE_SIZE, SUBTILE_SIZE, SUBTILE_SIZE, TEXGZ_UNSIGNED_BYTE, TEXGZ_RGB, NULL); if(dst == NULL) { return; } int m; int n; for(m = 0; m < SUBTILE_SIZE; ++m) { for(n = 0; n < SUBTILE_SIZE; ++n) { sample_data(src, dst, x, y, i, j, m, n, latT, lonL, latB, lonR); } } // convert dst to 565 texgz_tex_convert(dst, TEXGZ_UNSIGNED_SHORT_5_6_5, TEXGZ_RGB); char key[256]; snprintf(key, 256, "%i_%i", j, i); pak_file_writek(pak, key); texgz_tex_exportf(dst, pak->f); texgz_tex_delete(&dst); }
int main(void) { int ret = 0; SMS_HIS sms_his, sms_his2; MYSQL_RES *result; MYSQL_ROW row; unsigned int duration = 0; char subscriber[SMS_MAX_SUBSID_LEN]; memset(&sms_his, 0x00, sizeof(SMS_HIS)); sample_data(&sms_his); ret = Connect_DB(); if ( ret < 0 ) { printf("BAD GUY!! mysql connection fail..err=%s\n", mysql_error(&sql)); return -1; } else printf("NICE GUY!! mysql connection success..\n"); // Got Block RDR From RDRANA : Subscribers ID = '01012345678' and Special Pkg ID = 100 // Select SUBS_ID, MAX(DELIV_TIME) From sms_history Where SUBS_ID = '01012345678'; ret = Select_DB(sms_his.info.subsID); if ( ret < 0 ) { // select query 가 실패. 가입자가 table에 있는지 없는지 모르는 상태 printf("BAD GUY!! select query fail..\n"); } else { printf("NICE GUY!! select success...\n"); } result = mysql_store_result(conn); row = mysql_fetch_row(result); if ( row == NULL ) // select 결과 가입자가 없음. { printf("NICE GUY!! Not Exist Subscriber[%s] In Table. This is first Subs Info.\n", sms_his.info.subsID); // DELIVER() To SMS Server ret = Insert_DB(sms_his); if( ret < 0 ) { printf("BAD GUY!! Insert query fail..\n"); } else printf("NICE GUY!! Fisrt Insert OK...\n"); } else // select 결과 가입자가 있음. { // row[0] : Select 문의 첫번째 칼럼 -> SUBS_ID 값을 담고 있다. // row[1] : Select 문의 두번째 칼럼 -> 현재 시간 - DELIV_TIME 의 시간 차이를 갖고 있다. strncpy(subscriber, row[0], strlen(row[0])); duration = (unsigned int)row[1]; if ( duration > MAX_DURATION ) // duration이 지났다. { // DELIVER() To SMS Server memset(&sms_his2, 0x00, sizeof(SMS_HIS)); sample_data(&sms_his2); sms_his2.cid = 1; sms_his2.delivSts = 5; ret = Insert_DB(sms_his2); if( ret < 0 ) { printf("BAD GUY!!. Insert query fail..\n"); } else printf("NICE GUY!!. Duration Over... Second Insert OK...\n"); } else { printf("NICE GUY!! Duration Not Yet passed...Nothing To Do.\n"); } } // Delive Ack Received.. sms_his.delivSts = delivAckSts; ret = Update_DB(sms_his, DELIV); if ( ret < 0 ) { printf("BAD GUY!! Update deliv Ack fail....\n"); } else { printf("NICE GUY!! Update deliv Ack succss...\n"); } // Report Received. sms_his.reportTm = time(0); sms_his.reportSts = 4; ret = Update_DB(sms_his, REPORT); if ( ret < 0 ) { printf("BAD GUY!! Update Report fail....\n"); } else { printf("NICE GUY!! Update Report succss...\n"); } // Report Ack Send.... printf("NICE GUY!! Bye Bye~~~\n"); return 0; }
static Ref<Sound> load_wave_data (const Ptr<IData> data) { DecoderT decoder = NULL; Shared<Buffer> buffer = data->buffer(); std::size_t i = 4; uint32_t chunk_length; int32_t magic; i += buffer->read(i, chunk_length, LITTLE); i += buffer->read(i, magic, BIG); if (magic != 'WAVE') throw LoadError("Could not load WAV data"); bool found_header; uint16_t audio_format, channel_count, block_align, bits_per_sample; uint32_t sample_frequency, byte_rate; while (i < buffer->size()) { i += buffer->read(i, magic, BIG); i += buffer->read(i, chunk_length, LITTLE); if (magic == 'fmt ') { // Decode header found_header = true; i += buffer->read(i, audio_format, LITTLE); i += buffer->read(i, channel_count, LITTLE); i += buffer->read(i, sample_frequency, LITTLE); i += buffer->read(i, byte_rate, LITTLE); i += buffer->read(i, block_align, LITTLE); i += buffer->read(i, bits_per_sample, LITTLE); i += chunk_length - 16; if (audio_format == 1) { if (bits_per_sample == 8) // Copy samples verbatim. decoder = decode_linear_codec; else // Use PCM16 decoder - will pass through if endian doesn't need to be converted. decoder = decode_pcm16_codec; } else if (audio_format == 7) { //bits_per_sample *= 2; //decoder = decode_ulaw_codec; throw LoadError("Unsupported WAV encoding (ULaw)"); } else { throw LoadError("Unsupported WAV encoding (Unknown)"); } } else if (magic == 'data') { if (!found_header) throw LoadError("Corrupt or truncated data"); StaticBuffer sample_data(&(*buffer)[i], chunk_length); DREAM_ASSERT(decoder != NULL); return decoder(&sample_data, channel_count, bits_per_sample, sample_frequency); } else { // Unknown header i += chunk_length; } } throw LoadError("Corrupt or truncated data"); }
/**@brief Handler for SPI0 master events. * * @param[in] event SPI master event. */ void spi_master_0_event_handler(nrf_drv_spi_evt_type_t* event) { uint32_t err_code = NRF_SUCCESS; //uint32_t c_buff; // Temporarily store the buffer index of the buffer ready to be compressed switch (*event) { //while(app_uart_put(73) != NRF_SUCCESS); // Transfer complete; store in buffer. case NRF_DRV_SPI_EVENT_DONE: nrf_drv_spi_uninit(&m_spi_master_0); // Transfer done after this point m_transfer_completed = true; //printf("Data received\r\n"); //while(app_uart_put(69) != NRF_SUCCESS); //printf("%d\r\n", ++counter); //err_code = bsp_indication_set(BSP_INDICATE_RCV_OK); //APP_ERROR_CHECK(err_code);*/ // All buffers are in use; The just acquired data will be lost. if(buffers_ready[active_buffer]) { while(app_uart_put(70) != NRF_SUCCESS); //while(app_uart_put(70) != NRF_SUCCESS); //printf("All buffers in use. Data lost\r\n"); } // Still have space to store data. else { // Current buffer still has space if(ab_capacity > 0) { *(data_buffers[active_buffer] + DATA_BUF_SIZE - ab_capacity) = m_rx_data_spi[0]; // Buffer is filled after this storage. Set the next buffer as active. Call compression, if compression is not in progress. if(--ab_capacity == 0) { buffers_ready[active_buffer] = true; ab_capacity = DATA_BUF_SIZE; if(active_buffer == NUM_DATA_BUFFERS - 1) { active_buffer = 0; } else { active_buffer++; } // Compress //if(!compression_in_progress) //{ //printf("Compressing\r\n"); //while(app_uart_put(73) != NRF_SUCCESS); //compression_in_progress = true; //err_code = app_timer_start(comp_timer, 5, &c_buff); //while(app_uart_put(74) != NRF_SUCCESS); //printf("%d\r\n", err_code); //while(1); //APP_ERROR_CHECK(err_code); //while(app_uart_put(75) != NRF_SUCCESS); //compress(c_buff, DATA_BUF_SIZE); //printf("Compress is done\r\n"); //while(app_uart_put(71) != NRF_SUCCESS); //} } } } // If not all channels have been sampled, continue sampling from the other channels. if(intan_convert_channel == NUM_CHANNELS) { intan_convert_channel = 0; } else { sample_data(); } break; default: // No implementation needed. break; } }