/************************************************************************************** ** Get the Data ***************************************************************************************/ void RadioSim::grabData() { if(InCapture) { int len = to_read * 8 / PrimaryDetector.getBPS(); LOG_INFO("Downloading..."); InCapture = false; dsp_stream_p stream = dsp_stream_new(); dsp_stream_add_dim(stream, len); dsp_stream_alloc_buffer(stream, len); dsp_signals_sinewave(stream, PrimaryDetector.getSampleRate(), ((rand() % (int)PrimaryDetector.getSampleRate()) + 1)); dsp_buffer_stretch(stream->buf, stream->len, 0, RESOLUTION0 * 255 / RESOLUTION); for(int x = 0; x < stream->len; x++) { stream->buf[x] *= PrimaryDetector.getGain(); stream->buf[x] += (rand() % 255); } dsp_buffer_normalize(stream->buf, stream->len, 0, 4096); continuum = PrimaryDetector.getContinuumBuffer(); dsp_buffer_copy(stream->buf, continuum, stream->len); dsp_stream_free_buffer(stream); dsp_stream_free(stream); //Create the spectrum spectrum = PrimaryDetector.getSpectrumBuffer(); Spectrum(continuum, spectrum, to_read, SPECTRUM_SIZE * 8 / PrimaryDetector.getBPS(), PrimaryDetector.getBPS()); LOG_INFO("Download complete."); CaptureComplete(&PrimaryDetector); } }
/************************************************************************************** ** Create a random image and return it to client ***************************************************************************************/ void SimpleDetector::grabFrame() { // Set length of continuum int len = PrimaryDetector.getSampleRate() * PrimaryDetector.getCaptureDuration() * PrimaryDetector.getBPS() / 8; PrimaryDetector.setContinuumBufferSize(len); // Let's get a pointer to the frame buffer uint8_t *continuum = PrimaryDetector.getContinuumBuffer(); // Fill buffer with random pattern for (int i = 0; i < len; i++) continuum[i] = rand() % 255; // Set length of spectrum len = 1000; PrimaryDetector.setSpectrumBufferSize(len); // Let's get a pointer to the frame buffer double *spectrum = PrimaryDetector.getSpectrumBuffer(); // Fill buffer with random pattern for (int i = 0; i < len; i++) spectrum[i] = rand() % 255; IDMessage(getDeviceName(), "Download complete."); // Let INDI::Detector know we're done filling the image buffer CaptureComplete(&PrimaryDetector); }
/************************************************************************************** ** Get the Data ***************************************************************************************/ void RadioSim::grabData() { int to_read; int len = static_cast<int>RESOLUTION_PX(DishSize); double val = 0; int x = static_cast<int>(Ra * IMAGE_WIDTH / FOV_DEG); int y = static_cast<int>(Dec * IMAGE_HEIGHT / FOV_DEG); PrimaryDetector.setContinuumBufferSize(1); continuum = PrimaryDetector.getContinuumBuffer(); for(to_read = 0; to_read < len && x + to_read < IMAGE_WIDTH; to_read++) val += MagickImage[x + (y * IMAGE_WIDTH) + to_read]; continuum[0] = static_cast<unsigned char>(val / (to_read)); IDMessage (getDeviceName(), "value: %d", continuum[0]); LOG_INFO("Download complete."); // Let INDI::Detector know we're done filling the data buffers CaptureComplete(&PrimaryDetector); }