You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

531 lines
15 KiB

7 years ago
​
​
​
​
7 years ago
7 years ago
7 years ago
​
​
​
​
​
​
​
​
7 years ago
​
​
​
​
​
7 years ago
​
​
​
​
7 years ago
7 years ago
​
7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
7 years ago
7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
7 years ago
​
​
​
​
​
7 years ago
​
​
​
​
​
7 years ago
​
​
​
​
​
​
​
​
​
7 years ago
​
​
​
​
​
7 years ago
​
​
​
​
​
​
7 years ago
​
​
​
​
​
7 years ago
​
​
​
​
​
​
7 years ago
​
​
​
​
​
​
​
7 years ago
​
​
​
​
​
​
7 years ago
​
​
​
​
​
​
​
7 years ago
​
​
​
​
​
​
7 years ago
​
​
​
​
​
7 years ago
​
​
​
​
​
​
7 years ago
​
​
​
​
​
7 years ago
​
​
​
​
​
​
​
​
​
7 years ago
​
​
​
​
7 years ago
​
​
​
​
​
​
​
​
7 years ago
​
​
​
​
​
​
7 years ago
​
​
​
​
​
​
7 years ago
​
​
​
​
​
​
7 years ago
​
​
​
​
​
​
7 years ago
​
​
​
​
​
7 years ago
​
​
​
​
​
​
7 years ago
​
​
​
​
​
​
​
7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
7 years ago
​
7 years ago
​
​
7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
7 years ago
​
​
​
​
7 years ago
7 years ago
​
7 years ago
​
​
​
​
​
​
​
7 years ago
​
​
​
​
​
7 years ago
​
​
​
​
​
7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
7 years ago
​
​
  1. #include "protocolPTZ_PELCO.h"
  2. #define LOG( X ) m_pLog->Log( "Proto[PELCO]", this, X )
  3. #define LOG_ERROR( X ) m_pLog->Log( "Proto[PELCO]", this, _LOG_ERROR, X )
  4. protocolPTZ_PELCO::protocolPTZ_PELCO(config_setting_t *Settings): protocolPTZ(), m_mInquiryMutex(){
  5. m_pLog = basicLogCollection::getInstance();
  6. m_pSettings = Settings;
  7. m_bReplyRequired = false;
  8. m_bDPlusEna = false;
  9. m_bProtocolDeviceID = 1;
  10. m_bLastCommandIssued = CMD_PTZ_NOOP;
  11. };
  12. protocolPTZ_PELCO::protocolPTZ_PELCO( uint8_t CAM_ID ): protocolPTZ(), m_mInquiryMutex(){
  13. m_pLog = basicLogCollection::getInstance();
  14. m_pSettings = NULL;
  15. m_bReplyRequired = false;
  16. m_bDPlusEna = false;
  17. m_bProtocolDeviceID = CAM_ID;
  18. m_bLastCommandIssued = CMD_PTZ_NOOP;
  19. };
  20. protocolPTZ_PELCO::~protocolPTZ_PELCO(){
  21. };
  22. U8 protocolPTZ_PELCO::finishUpPackage(U8 *pBuffer){
  23. U8 nChecksum = 0;
  24. pBuffer[SYNC_IDX] = 0xFF;
  25. pBuffer[ADR_IDX] = m_bProtocolDeviceID;
  26. for (U8 i = ADR_IDX; i < CHKSUM_IDX; i++) nChecksum += pBuffer[i];
  27. pBuffer[CHKSUM_IDX] = nChecksum;
  28. return 7;
  29. };
  30. int protocolPTZ_PELCO::packetChecker(U8* Buffer, size_t BufferSize) {
  31. if( Buffer[0] == 0xFF ) {
  32. if( BufferSize > 1 ){
  33. if( Buffer[1] == 0x00 || Buffer[1] == m_bProtocolDeviceID ) {
  34. U8 tChSumm;
  35. // Check 4 Bytes Responce
  36. if( BufferSize > 3 ){
  37. tChSumm = 0;
  38. for (U8 i = 1; i< 4; i++) tChSumm += Buffer[i];
  39. if (Buffer[4] == tChSumm){
  40. #ifdef DEBUG
  41. LOG("PacketChecker: 4 Byte Packet Is Recognized");
  42. #endif
  43. return 0;
  44. };
  45. };
  46. // Check 7 Bytes Responce
  47. if( BufferSize > 6 ){
  48. U8 tChSumm = 0;
  49. for( U8 i=1; i< 6; i++ ) tChSumm += Buffer[ i ];
  50. if( Buffer[6] == tChSumm ){
  51. #ifdef DEBUG
  52. LOG("PacketChecker: 7 Byte Packet Is Recognized");
  53. #endif
  54. return 0;
  55. };
  56. };
  57. // Check 18 Bytes Responce
  58. if (BufferSize > 17){
  59. U8 tChSumm = 0;
  60. for( U8 i = 1; i< 17; i++ ) tChSumm += Buffer[i];
  61. if( Buffer[17] == tChSumm ){
  62. #ifdef DEBUG
  63. LOG("PacketChecker: 18 Byte Packet Is Recognized");
  64. #endif
  65. return 0;
  66. };
  67. };
  68. } else return -1;
  69. };
  70. return 1;
  71. };
  72. #ifdef DEBUG
  73. LOG("PacketChecker: Packet Not Recognized");
  74. #endif
  75. return -1;
  76. };
  77. protocolPackage *protocolPTZ_PELCO::packetExtractor(unsigned char *Buffer, size_t BufferSize){
  78. protocolPackage *RetVal;
  79. if( BufferSize < 4 ) return NULL;
  80. RetVal = (protocolPackage*)malloc(sizeof(protocolPackage));
  81. if( RetVal != NULL ){
  82. RetVal->m_pData = (U8*) malloc(18);
  83. if (RetVal->m_pData != NULL){
  84. U8 tChSumm = 0;
  85. U8 i;
  86. RetVal->m_pData[tChSumm] = Buffer[tChSumm];
  87. for (i = 1; i < 18; i++){
  88. tChSumm += RetVal->m_pData[i] = Buffer[i];
  89. if ((i == 17 || i == 6 || i == 3) && (Buffer[i] == tChSumm)){
  90. RetVal->m_nSize = i + 1;
  91. return RetVal;
  92. };
  93. };
  94. free(RetVal->m_pData);
  95. };
  96. free(RetVal);
  97. };
  98. return NULL;
  99. };
  100. bool protocolPTZ_PELCO::packetHandler(protocolPackage *Package){
  101. U8 Com_Mode;
  102. U8 Cat_Code;
  103. #ifdef DEBUG_EXTRA
  104. LOG( "PacketHandler: Packet Is Handling");
  105. #endif
  106. Com_Mode = Package->m_pData[1];
  107. Cat_Code = Package->m_pData[2];
  108. m_bLastCommandIssued = CMD_PTZ_NOOP;
  109. free( Package->m_pData );
  110. free( Package );
  111. return true;
  112. };
  113. bool protocolPTZ_PELCO::create( void ){
  114. config_setting_t *pSetting;
  115. int tPort, tSpeed;
  116. m_bStatus = 0;
  117. if ( !protocolPTZ::create() ) return false;
  118. if ( m_oDataTransport == NULL ) {
  119. LOG_ERROR("Transport Not Assigned!");
  120. return false;
  121. };
  122. if( m_pSettings != NULL ) {
  123. pSetting = config_setting_get_member(m_pSettings, PPTZ_TAG_COM_PORT);
  124. if (pSetting == NULL) return false;
  125. tPort = config_setting_get_int(pSetting);
  126. pSetting = config_setting_get_member(m_pSettings, PPTZ_TAG_COM_SPEED);
  127. if (pSetting == NULL) return false;
  128. tSpeed = config_setting_get_int(pSetting);
  129. pSetting = config_setting_get_member(m_pSettings, PPTZ_TAG_CAM_ID);
  130. if (pSetting == NULL) return false;
  131. m_bProtocolDeviceID = (U8)config_setting_get_int(pSetting);
  132. pSetting = config_setting_get_member(m_pSettings, PELCO_D_PLUS_ENABLE);
  133. if (pSetting != NULL) {
  134. m_bDPlusEna = (bool)config_setting_get_bool(pSetting);
  135. };
  136. /*
  137. char tBuf[16];
  138. #ifdef __linux__
  139. sprintf( tBuf,"/dev/ttyS%d",tPort);
  140. #else
  141. sprintf(tBuf, "com%d", tPort);
  142. #endif
  143. m_oDataTransport = new serialPort(tBuf,tSpeed);
  144. if (m_oDataTransport != NULL){
  145. if (m_oDataTransport->addRecipient(this)){
  146. setConnectionStatus(CS_CONNECTED);
  147. m_bStatus = 1;
  148. return true;
  149. };
  150. };
  151. */
  152. };
  153. m_bStatus = 1;
  154. return true;
  155. };
  156. bool protocolPTZ_PELCO::initCamera(void){
  157. return setPowerSaveMode( false );
  158. };
  159. bool protocolPTZ_PELCO::setPowerSaveMode( bool nMode ){
  160. U8 Buffer[8];
  161. if (m_bStatus == 0) return false;
  162. //if (m_bReplyRequired) if (m_bLastCommandIssued != CMD_PTZ_NOOP) return false;
  163. m_bPowerSave_Mode = !nMode;
  164. m_bLastCommandIssued =( m_bPowerSave_Mode )?CMD_PTZ_POWER_ON:CMD_PTZ_POWER_OFF;
  165. memset(Buffer, 0, 8);
  166. Buffer[DCMD1_IDX] = (m_bPowerSave_Mode) ? 0x88 : 0x08;
  167. LOG("Sending POWER ON/OFF");
  168. return m_oDataTransport->sendData(Buffer, finishUpPackage(Buffer));
  169. };
  170. bool protocolPTZ_PELCO::getPowerSaveMode( void ){
  171. U8 Buffer[16];
  172. if (m_bStatus == 0) return false;
  173. //if (m_bReplyRequired) if (m_bLastCommandIssued != CMD_PTZ_NOOP) return false;
  174. Buffer[0] = 0x80 + m_bProtocolDeviceID;
  175. Buffer[1]=0x09;
  176. Buffer[2]=0x04;
  177. Buffer[3]=0x00;
  178. Buffer[4]=0xFF;
  179. m_mInquiryMutex.lock();
  180. LOG("Ask POWER mode");
  181. m_oDataTransport->sendData( Buffer, 5 );
  182. m_mInquiryMutex.lock();
  183. m_mInquiryMutex.unlock();
  184. LOG("Ask POWER mode -> Done");
  185. return m_bPowerSave_Mode;
  186. };
  187. bool protocolPTZ_PELCO::startZoomWide( void ){
  188. U8 Buffer[16];
  189. if (m_bStatus == 0) return false;
  190. //if (m_bReplyRequired) if (m_bLastCommandIssued != CMD_PTZ_NOOP) return false;
  191. Buffer[0] = 0x80 + m_bProtocolDeviceID;
  192. Buffer[1]=0x01;
  193. Buffer[2]=0x04;
  194. Buffer[3]=0x07;
  195. Buffer[4]=0x03;
  196. Buffer[5]=0xFF;
  197. LOG("Start Zoom Wide(standard)");
  198. m_oDataTransport->sendData( Buffer, 6 );
  199. return true;
  200. };
  201. bool protocolPTZ_PELCO::startZoomTele( void ){
  202. U8 Buffer[16];
  203. if (m_bStatus == 0) return false;
  204. //if (m_bReplyRequired) if (m_bLastCommandIssued != CMD_PTZ_NOOP) return false;
  205. Buffer[0] = 0x80 + m_bProtocolDeviceID;
  206. Buffer[1]=0x01;
  207. Buffer[2]=0x04;
  208. Buffer[3]=0x07;
  209. Buffer[4]=0x02;
  210. Buffer[5]=0xFF;
  211. LOG("Start Zoom Tele(standard)");
  212. m_oDataTransport->sendData( Buffer, 6 );
  213. return true;
  214. };
  215. bool protocolPTZ_PELCO::startZoomWide( double nSpeed ){
  216. U8 Buffer[16];
  217. if (m_bStatus == 0) return false;
  218. //if (m_bReplyRequired) if (m_bLastCommandIssued != CMD_PTZ_NOOP) return false;
  219. Buffer[0] = 0x80 + m_bProtocolDeviceID;
  220. Buffer[1]=0x01;
  221. Buffer[2]=0x04;
  222. Buffer[3]=0x07;
  223. U8 Param;
  224. Param = ((U8)( 2 + nSpeed * 5 )) & 0x07;
  225. Buffer[4]=0x30 | Param;
  226. Buffer[5]=0xFF;
  227. LOG("Start Zoom Wide(parameter)");
  228. m_oDataTransport->sendData( Buffer, 6 );
  229. return true;
  230. };
  231. bool protocolPTZ_PELCO::startZoomTele( double nSpeed ){
  232. U8 Buffer[16];
  233. if (m_bStatus == 0) return false;
  234. //if (m_bReplyRequired) if (m_bLastCommandIssued != CMD_PTZ_NOOP) return false;
  235. Buffer[0] = 0x80 + m_bProtocolDeviceID;
  236. Buffer[1]=0x01;
  237. Buffer[2]=0x04;
  238. Buffer[3]=0x07;
  239. U8 Param;
  240. Param = ((U8)( 2 + nSpeed * 5 )) & 0x07;
  241. Buffer[4]=0x20 | Param;
  242. Buffer[5]=0xFF;
  243. LOG("Start Zoom Tele(parameter)");
  244. m_oDataTransport->sendData( Buffer, 6 );
  245. return true;
  246. };
  247. bool protocolPTZ_PELCO::stopZoom( void ){
  248. U8 Buffer[16];
  249. if (m_bStatus == 0) return false;
  250. //if (m_bReplyRequired) if (m_bLastCommandIssued != CMD_PTZ_NOOP) return false;
  251. Buffer[0] = 0x80 + m_bProtocolDeviceID;
  252. Buffer[1]=0x01;
  253. Buffer[2]=0x04;
  254. Buffer[3]=0x07;
  255. Buffer[4]=0x00;
  256. Buffer[5]=0xFF;
  257. LOG("Stop Zoom");
  258. m_oDataTransport->sendData( Buffer, 6 );
  259. return true;
  260. };
  261. /*double protocolPTZ_PELCO::getZoom( void ){
  262. U8 Buffer[16];
  263. if (m_bStatus == 0) return false;
  264. if (m_bReplyRequired) if (m_bLastCommandIssued != CMD_PTZ_NOOP) return false;
  265. Buffer[0] = 0x80 + m_bProtocolDeviceID;
  266. Buffer[1]=0x09;
  267. Buffer[2]=0x04;
  268. Buffer[3]=0x47;
  269. Buffer[4]=0xFF;
  270. m_mInquiryMutex.lock();
  271. LOG("Ask Zoom");
  272. m_oDataTransport->sendData( Buffer, 5 );
  273. m_mInquiryMutex.lock();
  274. m_mInquiryMutex.unlock();
  275. LOG("Ask Zoom -> Done");
  276. return m_dZoom;
  277. };
  278. */
  279. bool protocolPTZ_PELCO::resetPTZDrive( void ){
  280. U8 Buffer[16];
  281. if (m_bStatus == 0) return false;
  282. memset(Buffer, 0, 16);
  283. Buffer[DCMD1_IDX] = 0x00;
  284. Buffer[DCMD2_IDX] = 0x0F;
  285. Buffer[DATA1_IDX] = 0x00;
  286. Buffer[DATA2_IDX] = 0x00;
  287. LOG("Reset PTZ");
  288. return m_oDataTransport->sendData(Buffer, finishUpPackage(Buffer));
  289. };
  290. bool protocolPTZ_PELCO::goHomePosition( void ){
  291. U8 Buffer[8];
  292. if (m_bStatus == 0) return false;
  293. memset(Buffer, 0, 8);
  294. Buffer[DCMD2_IDX] = 0x07;
  295. Buffer[DATA2_IDX] = 0x22;
  296. LOG("Go Home");
  297. return m_oDataTransport->sendData(Buffer, finishUpPackage(Buffer));
  298. };
  299. bool protocolPTZ_PELCO::setPanPos( double dPan ){
  300. uint8_t Buffer[16];
  301. uint16_t SPan;
  302. // -1 == 0 deg ... 1 = 360 deg
  303. SPan = (( uint16_t )( 18000.0 + 18000.0 * dPan ) ) % 36000;
  304. memset(Buffer, 0, 16);
  305. Buffer[DCMD2_IDX] = 0x4B;
  306. Buffer[DATA1_IDX] = ( SPan >> 8 ) & 0xFF;
  307. Buffer[DATA2_IDX] = SPan & 0xFF;
  308. #ifdef DEBUG
  309. char tBuffer[64];
  310. sprintf(tBuffer, "setPanPos %.3f", dPan );
  311. LOG(tBuffer);
  312. #endif
  313. return m_oDataTransport->sendData(Buffer, finishUpPackage(Buffer));
  314. };
  315. bool protocolPTZ_PELCO::setTiltPos( double dTilt ){
  316. uint8_t Buffer[16];
  317. uint16_t STlt;
  318. //STlt = ((U16)(18000.0 + 18000.0 * ((dTilt + 1.f) / 2.f))) % 18000;
  319. STlt = (( uint16_t )( 18000.0 + 18000.0 * dTilt ) ) % 18000;
  320. memset(Buffer, 0, 16);
  321. Buffer[DCMD2_IDX] = 0x4D;
  322. Buffer[DATA1_IDX] = ( STlt >> 8 ) & 0xFF;
  323. Buffer[DATA2_IDX] = STlt & 0xFF;
  324. #ifdef DEBUG
  325. char tBuffer[64];
  326. sprintf(tBuffer, "setTiltPos %.3f -> %d", dTilt, STlt);
  327. LOG(tBuffer);
  328. #endif
  329. return m_oDataTransport->sendData(Buffer, finishUpPackage(Buffer));
  330. };
  331. bool protocolPTZ_PELCO::setZoom( double dZoom ){
  332. U8 Buffer[16];
  333. U16 SZum;
  334. SZum = (U16)(65535 * dZoom );
  335. memset(Buffer, 0, 16);
  336. Buffer[DCMD2_IDX] = 0x4F;
  337. Buffer[DATA1_IDX] = ( SZum >> 8 ) & 0xFF;
  338. Buffer[DATA2_IDX] = SZum & 0xFF;
  339. #ifdef DEBUG
  340. char tBuffer[64];
  341. sprintf(tBuffer, "setZoomPos %.3f", dZoom);
  342. LOG(tBuffer);
  343. #endif
  344. return m_oDataTransport->sendData(Buffer, finishUpPackage(Buffer));
  345. };
  346. bool protocolPTZ_PELCO::move(uint32_t MoveMatrix){
  347. U8 Buffer[16];
  348. U8 Param1, Param2;
  349. if (m_bStatus == 0) return false;
  350. // if (m_bReplyRequired) if (m_bLastCommandIssued != CMD_PTZ_NOOP) return false;
  351. Param1 = (U8)(m_dPanSpeed * 64.0) & 0xFF;
  352. Param2 = (U8)(m_dTiltSpeed * 64.0) & 0xFF;
  353. memset(Buffer, 0, 16);
  354. if ((MoveMatrix & PTZ_DRIVE_PAN_MASK) != 0){
  355. if ((MoveMatrix & PTZ_DRIVE_PAN_LEFT) != 0){
  356. Buffer[DCMD2_IDX] |= 0x04;
  357. } else {
  358. Buffer[DCMD2_IDX] |= 0x02;
  359. };
  360. };
  361. if ((MoveMatrix & PTZ_DRIVE_TILT_MASK) != 0){
  362. if ((MoveMatrix & PTZ_DRIVE_TILT_UP) != 0){
  363. Buffer[DCMD2_IDX] |= 0x08;
  364. } else {
  365. Buffer[DCMD2_IDX] |= 0x10;
  366. };
  367. };
  368. if ((MoveMatrix & PTZ_DRIVE_ZOOM_MASK) != 0){
  369. if ((MoveMatrix & PTZ_DRIVE_ZOOM_WIDE) != 0){
  370. Buffer[DCMD2_IDX] |= 0x40;
  371. } else {
  372. Buffer[DCMD2_IDX] |= 0x20;
  373. };
  374. };
  375. Buffer[DATA1_IDX] = Param1; // Max = 3f Turbo Pan = FF
  376. Buffer[DATA2_IDX] = Param2;
  377. LOG("Make move");
  378. bool tv = m_oDataTransport->sendData(Buffer, finishUpPackage(Buffer));
  379. if( tv ) SLEEP(500);
  380. return tv;
  381. };
  382. bool protocolPTZ_PELCO::goAbsolute( float dPan, float dTilt, float dZoom) {
  383. if( m_bStatus == 0 ) return false;
  384. // if (m_bReplyRequired) if (m_bLastCommandIssued != CMD_PTZ_NOOP) return false;
  385. if( m_bDPlusEna ) {
  386. U8 Buffer[16];
  387. U8 Param1, Param2;
  388. memset(Buffer, 0, 16 );
  389. Buffer[0] = 0x80 + m_bProtocolDeviceID;
  390. Buffer[1] = 0x01;
  391. Buffer[2] = 0x06;
  392. Buffer[3] = 0x02;
  393. Buffer[4] = 0x18;//Max Pan Speed
  394. Buffer[5] = 0x14;//Max Tilt Speed
  395. uint16_t pPos, tPos;
  396. //-880 .. 880
  397. pPos = (uint16_t)(880.0 * dPan);
  398. Buffer[6] = 0x0F & (pPos >> 12);
  399. Buffer[7] = 0x0F & (pPos >> 8);
  400. Buffer[8] = 0x0F & (pPos >> 4);
  401. Buffer[9] = 0x0F & pPos;
  402. //-300 .. 300
  403. tPos = (uint16_t)(300.0 * dTilt);
  404. Buffer[10] = 0x0F & (tPos >> 12);
  405. Buffer[11] = 0x0F & (tPos >> 8);
  406. Buffer[12] = 0x0F & (tPos >> 4);
  407. Buffer[13] = 0x0F & tPos;
  408. Buffer[14] = 0xFF;
  409. LOG("ABS move");
  410. bool tv = m_oDataTransport->sendData(Buffer, 15);
  411. if( tv ) SLEEP(500);
  412. return tv;
  413. } else {
  414. LOG("ABS move");
  415. if( setPanPos( dPan ) ){
  416. SLEEP( 500 );
  417. if( setTiltPos(dTilt) ){
  418. SLEEP( 500 );
  419. if( setZoom(dZoom)){
  420. SLEEP( 500 );
  421. return true;
  422. };
  423. };
  424. };
  425. };
  426. return false;
  427. };
  428. bool protocolPTZ_PELCO::setAutoFocus(bool nMode){
  429. m_bAutoFocus_Mode = nMode;
  430. U8 Buffer[8];
  431. if (m_bStatus == 0) return false;
  432. memset(Buffer, 0, 8);
  433. Buffer[DCMD2_IDX] = 0x2B;
  434. Buffer[DATA2_IDX] = (m_bAutoFocus_Mode) ? 0x01 : 0x02;
  435. LOG("setAutoFocus");
  436. return m_oDataTransport->sendData(Buffer, finishUpPackage(Buffer));
  437. };
  438. bool protocolPTZ_PELCO::setOSD( bool nMode ){
  439. U8 Buffer[16];
  440. if (m_bStatus == 0) return false;
  441. //if (m_bReplyRequired) if (m_bLastCommandIssued != CMD_PTZ_NOOP) return false;
  442. Buffer[0] = 0x80 + m_bProtocolDeviceID;
  443. Buffer[1]=0x01;
  444. Buffer[2]=0x06;
  445. Buffer[3]=0x06;
  446. Buffer[4]=(nMode)?0x02:0x03;
  447. Buffer[5]=0xFF;
  448. LOG("Set On Screen Display mode");
  449. m_oDataTransport->sendData( Buffer, 6 );
  450. return true;
  451. };
  452. /*
  453. bool protocolPTZ_PELCO::setPSpeed(double Speed) {
  454. m_dPanSpeed = Speed;
  455. LOG("setPanSpeed");
  456. return move(0);
  457. };
  458. bool protocolPTZ_PELCO::setTSpeed(double Speed) {
  459. m_dTiltSpeed = Speed;
  460. LOG("setTiltSpeed");
  461. return move(0);
  462. };
  463. bool protocolPTZ_PELCO::setPTZSpeed(double pSpeed, double tSpeed, double zSpeed) {
  464. m_dPanSpeed = pSpeed;
  465. m_dTiltSpeed = tSpeed;
  466. m_dZoomSpeed = zSpeed;
  467. LOG("setPTZSpeed");
  468. return move(0);
  469. };
  470. bool protocolPTZ_PELCO::setZSpeed(double Speed) {
  471. m_dZoomSpeed = Speed;
  472. U8 Buffer[8];
  473. if (m_bStatus == 0) return false;
  474. memset(Buffer, 0, 8);
  475. Buffer[DCMD2_IDX] = 0x25;
  476. U8 sValue = (U8)floor(m_dZoomSpeed * 3.f);
  477. Buffer[DATA2_IDX] = sValue;
  478. LOG("setZoomSpeed");
  479. return m_oDataTransport->sendData(Buffer, finishUpPackage(Buffer));
  480. };
  481. bool protocolPTZ_PELCO::setFSpeed(double Speed) {
  482. m_dZoomSpeed = Speed;
  483. U8 Buffer[8];
  484. if (m_bStatus == 0) return false;
  485. memset(Buffer, 0, 8);
  486. Buffer[DCMD2_IDX] = 0x27;
  487. U8 sValue = (U8)floor( m_dZoomSpeed * 3.f );
  488. Buffer[DATA2_IDX] = sValue;
  489. LOG("setFocusSpeed");
  490. return m_oDataTransport->sendData(Buffer, finishUpPackage(Buffer));
  491. };
  492. */
  493. #undef LOG
  494. #undef LOG_ERROR