00001 #ifndef EF232LENS_H
00002 #define EF232LENS_H
00003
00004 #include "../Lens.h"
00005 #include <string>
00006 #include <pthread.h>
00007 #include <queue>
00008
00009 #include "EF232LensDatabase.h"
00010
00011 namespace FCam { namespace F2 {
00012
00013
00014
00015 class Lens: public FCam::Lens {
00016
00017 public:
00018 Lens();
00019 Lens(const std::string &tty_);
00020 ~Lens();
00021
00022 void setFocus(float diopters, float speed = -1);
00023 float getFocus();
00024 float farFocus();
00025 float nearFocus();
00026 bool focusChanging();
00027 int focusLatency();
00028
00029 float minFocusSpeed();
00030 float maxFocusSpeed();
00031
00032 void setZoom(float focal_length_mm, float speed = -1);
00033 float getZoom();
00034 float minZoom();
00035 float maxZoom();
00036 bool zoomChanging();
00037 int zoomLatency();
00038 float minZoomSpeed();
00039 float maxZoomSpeed();
00040
00041 void setAperture(float f_number, float speed = -1);
00042 float getAperture();
00043 float wideAperture(float focal_length_mm = -1);
00044 float narrowAperture(float focal_length_mm = -1);
00045 bool apertureChanging();
00046 int apertureLatency();
00047 float minApertureSpeed();
00048 float maxApertureSpeed();
00049
00050 void tagFrame(FCam::Frame *);
00051
00052 class Tags: public FCam::Lens {
00053 public:
00054 };
00055
00056 void reset();
00057
00058 private:
00059 const std::string tty;
00060 int serial_fd;
00061
00062 enum {
00063 NOT_INITIALIZED,
00064 NO_LENS,
00065 READY,
00066 BUSY
00067 } state;
00068
00069 EF232LensDatabase lensDB;
00070
00071 const EF232LensInfo *currentLens;
00072
00073
00074
00075 unsigned int focalLength;
00076 unsigned int aperture;
00077 unsigned int focusDist;
00078
00079
00080 std::string buf;
00081
00082
00083 unsigned int focusEncoderMax;
00084 float diopScaleFactor;
00085
00086 float encToDiopter(unsigned int encoder);
00087 unsigned int diopToEncoder(float diopters);
00088
00089
00090
00091 void init();
00092 void calibrateLens();
00093
00094
00095 pthread_t controlThread;
00096 void runLensControlThread();
00097
00098
00099
00100 std::string cmd_GetID();
00101 unsigned int cmd_GetFocalLength(std::string idStr="");
00102 unsigned int cmd_GetMinAperture(std::string idStr="");
00103
00104 void cmd_GetZoomRange(unsigned int &min,
00105 unsigned int &max);
00106 void cmd_GetFocusBracket(unsigned int &min,
00107 unsigned int &max);
00108 unsigned int cmd_GetFocusEncoder();
00109
00110 void cmd_SetFocusEncoder(unsigned int val);
00111
00112 void cmd_DoInitialize();
00113
00114 unsigned int cmd_DoApertureOpen();
00115 unsigned int cmd_DoAperture(unsigned int val);
00116 unsigned int cmd_DoApertureClose();
00117
00118 void cmd_DoFocusAtZero();
00119 unsigned int cmd_DoFocus(unsigned int val);
00120 void cmd_DoFocusAtInf();
00121
00122
00123
00124 void send(const std::string&);
00125 template<typename T>
00126 void read(T &val);
00127 void expect(const std::string& desired);
00128 void expect(const std::string& desired, std::string& remainder);
00129 };
00130
00131 }
00132 }
00133
00134 #endif