void test() { Repository repository; ModulePtr module1 = repository.getModule("mock1"); module1->open(); #if 0 moduletest(module1); #else { ModuleDescriptorPtr descriptor1 = module1->getDescriptor(); std::cout << descriptor1->name() << ", " << descriptor1->version() << std::endl; } #endif module1->close(); ModulePtr module2 = repository.getModule("mock2"); module2->open(); #if 0 moduletest(module2); #else { ModuleDescriptorPtr descriptor2 = module2->getDescriptor(); std::cout << descriptor2->name() << ", " << descriptor2->version() << std::endl; } #endif module2->close(); }
void Mock1Test::testMock1() { debug(LOG_DEBUG, DEBUG_LOG, 0, "Mock1Test begin"); ModulePtr module = repository->getModule("mock1"); debug(LOG_DEBUG, DEBUG_LOG, 0, "got module"); module->open(); debug(LOG_DEBUG, DEBUG_LOG, 0, "module open"); DeviceLocatorPtr cl = module->getDeviceLocator(); debug(LOG_DEBUG, DEBUG_LOG, 0, "get DeviceLocator"); std::vector<std::string> cameras = cl->getDevicelist(); debug(LOG_DEBUG, DEBUG_LOG, 0, "get %d devices", cameras.size()); CPPUNIT_ASSERT(cameras.size() == 10); CameraPtr camera = cl->getCamera("camera:mock1/5"); // for every CCD, take an image for (unsigned int i = 0; i < camera->nCcds(); i++) { CcdPtr ccd = camera->getCcd(i); Exposure exposure; ImageRectangle frame(ImagePoint(1,1), ImageSize(ccd->getSize().width() - 2, ccd->getSize().height() - 2)); exposure.frame(frame); ccd->startExposure(exposure); while (ccd->exposureStatus() == Exposure::exposing) { sleep(1); } if (ccd->exposureStatus() == Exposure::exposed) { ImagePtr image = ccd->getImage(); debug(LOG_DEBUG, DEBUG_LOG, 0, "result image size: %d x %d", image->size().width(), image->size().height()); } } debug(LOG_DEBUG, DEBUG_LOG, 0, "Mock1Test end"); }
void RepositoryTest::testOpen() { debug(LOG_DEBUG, DEBUG_LOG, 0, "testOpen() begin"); ModulePtr module = repository->getModule("mock1"); module->open(); CPPUNIT_ASSERT(module->isloaded()); module->close(); CPPUNIT_ASSERT(!module->isloaded()); debug(LOG_DEBUG, DEBUG_LOG, 0, "testOpen() end"); }
void RepositoryTest::testDescriptor() { debug(LOG_DEBUG, DEBUG_LOG, 0, "testDescriptor() begin"); ModulePtr module = repository->getModule("mock1"); Module::dlclose_on_close = false; module->open(); moduleTest(module); module->close(); debug(LOG_DEBUG, DEBUG_LOG, 0, "testDescriptor() end"); }
int main(int argc, char *argv[]) { const char *modulename = "uvc"; int cameraid = 0; int ccdid = 0; int c; debugtimeprecision = 3; debugthreads = true; while (EOF != (c = getopt(argc, argv, "dC:c:m:"))) switch (c) { case 'd': debuglevel = LOG_DEBUG; break; case 'C': cameraid = atoi(optarg); break; case 'c': ccdid = atoi(optarg); break; case 'm': modulename = strdup(optarg); break; } std::cout << "main" << std::endl; // open repository Repository repository; ModulePtr module = repository.getModule(modulename); module->open(); // Device locator for the module DeviceLocatorPtr locator = module->getDeviceLocator(); // get cameras std::vector<std::string> cameras = locator->getDevicelist(); debug(LOG_DEBUG, DEBUG_LOG, 0, "found %d devices", cameras.size()); if (cameraid >= cameras.size()) { debug(LOG_ERR, DEBUG_LOG, 0, "not enough devices"); throw std::runtime_error("camera id too large"); } CameraPtr camera = locator->getCamera(cameras[cameraid]); CcdPtr ccd = camera->getCcd(ccdid); // now initialize the GUI stuff QApplication app(argc, argv); CaptureWindow capturewindow; capturewindow.setCamera(camera); capturewindow.setCcd(ccd); capturewindow.show(); app.installEventFilter(&capturewindow); return app.exec(); }
/** * \brief main function for the focus program */ int main(int argc, char *argv[]) { int c; double exposuretime = 0.1; unsigned int cameraid = 0; unsigned int ccdid = 0; int length = 512; std::string cameratype("uvc"); while (EOF != (c = getopt(argc, argv, "de:m:c:C:l:"))) switch (c) { case 'd': debuglevel = LOG_DEBUG; break; case 'm': cameratype = std::string(optarg); break; case 'C': cameraid = atoi(optarg); break; case 'c': ccdid = atoi(optarg); break; case 'e': exposuretime = atof(optarg); break; case 'l': length = atoi(optarg); break; } // get the camera Repository repository; debug(LOG_DEBUG, DEBUG_LOG, 0, "loading module %s", cameratype.c_str()); ModulePtr module = repository.getModule(cameratype); module->open(); // get the camera DeviceLocatorPtr locator = module->getDeviceLocator(); std::vector<std::string> cameras = locator->getDevicelist(); if (0 == cameras.size()) { std::cerr << "no cameras found" << std::endl; return EXIT_FAILURE; } if (cameraid >= cameras.size()) { std::string msg = stringprintf("camera %d out of range", cameraid); debug(LOG_ERR, DEBUG_LOG, 0, "%s\n", msg.c_str()); throw std::range_error(msg); } std::string cameraname = cameras[cameraid]; CameraPtr camera = locator->getCamera(cameraname); debug(LOG_DEBUG, DEBUG_LOG, 0, "camera loaded: %s", cameraname.c_str()); // get the ccd CcdPtr ccd = camera->getCcd(ccdid); debug(LOG_DEBUG, DEBUG_LOG, 0, "get a ccd: %s", ccd->getInfo().toString().c_str()); // get a centerd length x length frame ImageSize framesize(length, length); ImageRectangle frame = ccd->getInfo().centeredRectangle(framesize); Exposure exposure(frame, exposuretime); debug(LOG_DEBUG, DEBUG_LOG, 0, "exposure prepared: %s", exposure.toString().c_str()); // retrieve an image ccd->startExposure(exposure); ImagePtr image = ccd->getImage(); // write image unlink("test.fits"); FITSout out("test.fits"); out.write(image); // apply a mask to keep the border out CircleFunction circle(ImagePoint(length/2, length/2), length/2, 0.8); mask(circle, image); unlink("masked.fits"); FITSout maskout("masked.fits"); maskout.write(image); #if 0 // compute the FOM double fom = focusFOM(image, true, Subgrid(ImagePoint(1, 0), ImageSize(1, 1))); std::cout << "FOM: " << fom << std::endl; #endif return EXIT_SUCCESS; }