00001
00002 #pragma once
00003 #include "serial.h"
00009 class cViscaCalibRaw
00010 {
00011 public:
00012 virtual int Degrees2Pan( int pan ) { return pan; }
00013 virtual int Pan2Degrees( int pan ) { return pan; }
00014 virtual int Degrees2Tilt( int tilt ) { return tilt; }
00015 virtual int Tilt2Degrees( int tilt ) { return tilt; }
00016 virtual int Degrees2Zoom( int zoom ) { return zoom; }
00017 virtual int Zoom2Degrees( int zoom ) { return zoom; }
00018 };
00024 class cViscaCalibBRC300 : public cViscaCalibRaw
00025 {
00026 public:
00027 virtual int Pan2Degrees( int pan ) { return (int) ( (float) pan / 208.3f ); }
00028 virtual int Degrees2Pan( int pan ) { return (int) ( (float) pan * 208.3f ); }
00029 virtual int Tilt2Degrees( int tilt ) { return (int) ( (float) tilt / 208.3f ); }
00030 virtual int Degrees2Tilt( int tilt ) { return (int) ( (float) tilt * 208.3f ); }
00031 virtual int Degrees2Zoom( int fov );
00032 virtual int Zoom2Degrees( int zoom );
00033 };
00034
00035
00036
00037
00038
00039
00042
00043
00044
00045
00046 class cViscaTest;
00047
00071 class cVISCA
00072 {
00073 public:
00074 int myError;
00075
00076 cVISCA();
00077 ~cVISCA();
00078 void Log( int flag = 1 );
00079 void NoCameraResponse( int flag = 1 );
00080 void ResetOnError( int flag = 1 );
00081
00082 void setCameraIndex( int i );
00083
00084 int SerialOpen( const char *device_name);
00085 void SerialClose();
00086
00087 int Reset();
00088 int SetAddress( int *camera_num);
00089 int clear();
00090 int get_camera_info( int& vendor, int& model );
00091 int setLive( int i );
00092
00093 int pantilt_set(
00094 unsigned int pan_speed, unsigned int tilt_speed,
00095 int pan_position, int tilt_position);
00096 int pantilt_get_value( int& pan_pos, int& tilt_pos );
00097 int pantilt_drive_start( int leftright, int speed );
00098 int pantilt_drive_stop();
00099 int pantilt_home();
00100
00101 int zoom_set_value( int value );
00102 int zoom_get_value();
00103 int zoom_drive_start( int LRUDIO, int speed );
00104 int zoom_drive_stop();
00105
00106 int set_focus_value( int value );
00107
00108 int IsSim() { return myFlagSim; }
00109 int IsOpen() { return myFlagOpen || myFlagSim; }
00110
00111
00112
00113
00114 private:
00115 int myflagLog;
00116 int myFlagOpen;
00117 int myFlagNoResponse;
00118 int myFlagSim;
00119 int myFlagSimCam;
00120 int myFlagResetOnError;
00121
00122 int myWait;
00123
00124 int sim_pan;
00125 int sim_tilt;
00126 int sim_zoom;
00127
00128 CSerial myCom;
00129 int myCamera;
00130 int myCameraNumber;
00131 FILE* myFPLog;
00132
00133 cViscaCalibRaw * myCalibration;
00134
00135 void EncodeInteger( unsigned char* pOut, int value, int digits = 4 );
00136 int DecodeInteger( unsigned char* buf, int digits = 4 );
00137
00138 int PacketRead( BYTE * p, int timeout = 100 );
00139 int PacketSend( BYTE* szMessage );
00140 void PacketSink();
00141 int PacketLength( BYTE* szMessage );
00142 int PacketWaitForAck();
00143 int PacketWaitForCompletion( int timeout = 100 );
00144 void PacketLog( BYTE* szMessage );
00145 int IsSyntaxError( BYTE * packet, int len );
00146
00147 friend cViscaTest;
00148
00149
00150 };
00151
00152
00153
00154
00155
00156
00157 class cViscaTest
00158 {
00159 public:
00160 void EncodeInteger( unsigned char* pOut, int value )
00161 {
00162 cVISCA visca;
00163 visca.EncodeInteger( pOut, value );
00164 }
00165 int DecodeInteger( unsigned char* buf )
00166 {
00167 cVISCA visca;
00168 return visca.DecodeInteger( buf );
00169 }
00170 };