00001 #include "../F2.h"
00002
00003 int main(int argc, char **argv) {
00004 FCam::F2::Lens lens;
00005
00006 lens.setFocus(lens.farFocus());
00007 std::cout << "Tried to focus at 0 diop, actual: "<<lens.getFocus() << std::endl;
00008
00009 lens.setFocus(lens.nearFocus());
00010 std::cout << "Tried to focus at "<<lens.nearFocus()<<" diop, actual: "<<lens.getFocus() << std::endl;
00011
00012 std::cout << "Lens focus speed range: " << lens.minFocusSpeed() << " to "<< lens.minFocusSpeed()<<" diopters/sec" << std::endl;
00013
00014 std::cout << "Lens focal length: " << lens.getZoom() <<std::endl;
00015
00016 lens.setAperture(lens.wideAperture());
00017 std::cout << "Tried to open aperture, actual: "<<lens.getAperture() << std::endl;
00018
00019 lens.setAperture(lens.narrowAperture());
00020 std::cout << "Tried to close aperture, actual: "<<lens.getAperture() << std::endl;
00021
00022 FCam::EF232LensDatabase db;
00023
00024 const FCam::EF232LensInfo *currentLens = db.find(lens.minZoom(),
00025 lens.maxZoom());
00026
00027 std::cout << "Database for the current lens" <<std::endl;
00028 currentLens->print(std::cout);
00029
00030
00031 if (argc > 1) {
00032 std::string arg1(argv[1]);
00033
00034 if (arg1 == "-c") {
00035 std::cout << "Starting full lens calibration"<<std::endl;
00036
00037
00038 std::cout << "Please move lens to the minimum focal length (largest field of view)" << std::endl;
00039 int timeout_count = 0;
00040 while (timeout_count < 50) {
00041 if (lens.getZoom() == lens.minZoom()) break;
00042 timeout_count++;
00043 usleep(100000);
00044 }
00045 if (timeout_count == 50) {
00046 std::cout << "Timeout on calibration, bye!\n";
00047 return 1;
00048 }
00049
00050 std::cout << "Please move lens to the maximum focal length (smallest field of view)" << std::endl;
00051 timeout_count = 0;
00052 while (timeout_count < 500) {
00053 if (lens.getZoom() == lens.maxZoom()) break;
00054 timeout_count++;
00055 usleep(10000);
00056 }
00057 if (timeout_count == 50) {
00058 std::cout << "Timeout on calibration, bye!\n";
00059 return 1;
00060 }
00061 currentLens = db.find(lens.minZoom(),
00062 lens.maxZoom());
00063
00064
00065 if (currentLens->name == "Unknown") {
00066 FCam::EF232LensInfo updatedLens = *currentLens;
00067 std::cout << "Please enter name for current lens: "<<std::endl;
00068 std::getline(std::cin, updatedLens.name);
00069 currentLens = db.update(updatedLens);
00070 }
00071
00072 std::cout << "Calibrated database for the current lens" <<std::endl;
00073 currentLens->print(std::cout);
00074
00075 std::cout << "Ok to save? (y/n)"<<std::endl;
00076 std::string tmp;
00077 std::cin>>std::ws;
00078 std::cin>>tmp;
00079 if (tmp == "y"){
00080 std::cout << "Saving database" << std::endl;
00081 db.save();
00082 }
00083 }
00084 }
00085 }