Pelcod.cpp
上传用户:popouu88
上传日期:2013-02-11
资源大小:2894k
文件大小:5k
源码类别:

IP电话/视频会议

开发平台:

Visual C++

  1. // Pelcod.cpp: implementation of the CPelcod class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #include "....stdafx.h"
  5. #include "Pelcod.h"
  6. #ifdef _DEBUG
  7. #undef THIS_FILE
  8. static char THIS_FILE[]=__FILE__;
  9. #define new DEBUG_NEW
  10. #endif
  11. //////////////////////////////////////////////////////////////////////
  12. // Construction/Destruction
  13. //////////////////////////////////////////////////////////////////////
  14. CPelcod::CPelcod() 
  15. {
  16. }
  17. CPelcod::~CPelcod()
  18. {
  19. }
  20. void CPelcod::OpenPort(void)
  21. {
  22. if(!CCom::Open(1) && !CCom::Open(2))
  23. {
  24. }
  25. }
  26. void CPelcod::ClosePort(void)
  27. {
  28. CCom::Close();
  29. }
  30. void CPelcod::DoWork(int cmd,int addr,BOOL work)
  31. {
  32. switch(cmd)
  33. {
  34. case UP : this->Up(addr,work); break;
  35. case DOWN : this->Down(addr,work); break;
  36. case LEFT : this->Left(addr,work); break;
  37. case RIGHT : this->Right(addr,work);break;
  38. case AUTO : this->Auto(addr,work); break;
  39. case FOCUS_LESSEN : this->FocusLessen(addr,work); break;
  40. case FOCUS_LARGEN : this->FocusLargen(addr,work); break;
  41. case ZOOM_LESSEN : this->ZoomLessen(addr,work); break;
  42. case ZOOM_LARGEN : this->ZoomLargen(addr,work); break;
  43. case IRIS_LESSEN : this->IrisLessen(addr,work); break;
  44. case IRIS_LARGEN : this->IrisLargen(addr,work); break;
  45. }
  46. }
  47. // Up    ffh,addr,00h,08h,0ah,0ah,CRC : ffh,addr,00h,00h,00h,00h,CRC
  48. void CPelcod::Up(int addr,BOOL work)
  49. {
  50. BYTE cmd[7] = {0xff,addr,0x00,0x08,0x0a,0x0a,0x1c + addr};
  51. if(!work)
  52. {
  53. memset(cmd + 2,0,sizeof(BYTE) * 5);
  54. cmd[6] = addr;
  55. }
  56. CCom::Write(cmd,sizeof(cmd) / sizeof(BYTE));
  57. }
  58. // Down  ffh,addr,00h,10h,0ah,0ah,CRC;    ffh,addr,00h,00h,00h,00h,CRC 
  59. void CPelcod::Down(int addr,BOOL work)
  60. {
  61. BYTE cmd[7] = {0xff,addr,0x00,0x10,0x0a,0x0a,0x24 + addr};
  62. if(!work)
  63. {
  64. memset(cmd + 2,0,sizeof(BYTE) * 5);
  65. cmd[6] = addr;
  66. }
  67. CCom::Write(cmd,sizeof(cmd) / sizeof(BYTE));
  68. }
  69. // Left    ffh,addr,00h,04h,0ah,0ah,CRC;   ffh,addr,00h,00h,00h,00h,CRC
  70. void CPelcod::Left(int addr,BOOL work)
  71. {
  72. BYTE cmd[7] = {0xff,addr,0x00,0x04,0x0a,0x0a,0x18 + addr};
  73. if(!work)
  74. {
  75. memset(cmd + 2,0,sizeof(BYTE) * 5);
  76. cmd[6] = addr;
  77. }
  78. CCom::Write(cmd,sizeof(cmd) / sizeof(BYTE));
  79. }
  80. // Right   ffh,addr,00h,02h,0ah,0ah,CRC;   ffh,addr,00h,00h,00h,00h,CRC
  81. void CPelcod::Right(int addr,BOOL work)
  82. {
  83. BYTE cmd[7] = {0xff,addr,0x00,0x02,0x0a,0x0a,0x16 + addr};
  84. if(!work)
  85. {
  86. memset(cmd + 2,0,sizeof(BYTE) * 5);
  87. cmd[6] = addr;
  88. }
  89. CCom::Write(cmd,sizeof(cmd) / sizeof(BYTE));
  90. }
  91. // Auto    ffh,addr,00h,03h,00h,01h,CRC;   ffh,addr,00h,03h,00h,02h,CRC
  92. void CPelcod::Auto(int addr,BOOL work)
  93. {
  94. BYTE cmd[7] = {0xff,addr,0x00,0x03,0x00,0x01,0x04 + addr};
  95. if(!work)
  96. {
  97. cmd[5] = 0x02; cmd[6] += 0x01;
  98. }
  99. CCom::Write(cmd,sizeof(cmd) / sizeof(BYTE));
  100. }
  101. // Focus-  ffh,addr,01h,00h,0ah,0ah,CRC;   ffh,addr,00h,00h,00h,00h,CRC
  102. void CPelcod::FocusLessen(int addr,BOOL work)
  103. {
  104. BYTE cmd[7] = {0xff,addr,0x01,0x00,0x0a,0x0a,0x15 + addr};
  105. if(!work)
  106. {
  107. memset(cmd + 2,0,sizeof(BYTE) * 5);
  108. cmd[6] = addr;
  109. }
  110. CCom::Write(cmd,sizeof(cmd) / sizeof(BYTE));
  111. }
  112. // Focus+  ffh,addr,00h,80h,0ah,0ah,CRC;   ffh,addr,00h,00h,00h,00h,CRC
  113. void CPelcod::FocusLargen(int addr,BOOL work)
  114. {
  115. BYTE cmd[7] = {0xff,addr,0x00,0x80,0x0a,0x0a,0x94 + addr};
  116. if(!work)
  117. {
  118. memset(cmd + 2,0,sizeof(BYTE) * 5);
  119. cmd[6] = addr;
  120. }
  121. CCom::Write(cmd,sizeof(cmd) / sizeof(BYTE));
  122. }
  123. // Zoom-  ffh,addr,00h,40h,0ah,0ah,CRC;   ffh,addr,00h,00h,00h,00h,CRC
  124. void CPelcod::ZoomLessen(int addr,BOOL work)
  125. {
  126. BYTE cmd[7] = {0xff,addr,0x00,0x40,0x0a,0x0a,0x54 + addr};
  127. if(!work)
  128. {
  129. memset(cmd + 2,0,sizeof(BYTE) * 5);
  130. cmd[6] = addr;
  131. }
  132. CCom::Write(cmd,sizeof(cmd) / sizeof(BYTE));
  133. }
  134. // Zoom+  ffh,addr,00h,20h,0ah,0ah,CRC;   ffh,addr,00h,00h,00h,00h,CRC
  135. void CPelcod::ZoomLargen(int addr,BOOL work)
  136. {
  137. BYTE cmd[7] = {0xff,addr,0x00,0x20,0x0a,0x0a,0x34 + addr};
  138. if(!work)
  139. {
  140. memset(cmd + 2,0,sizeof(BYTE) * 5);
  141. cmd[6] = addr;
  142. }
  143. CCom::Write(cmd,sizeof(cmd) / sizeof(BYTE));
  144. }
  145. // Iris-    ffh,addr,04h,00h,0ah,0ah,CRC;   ffh,addr,00h,00h,00h,00h,CRC
  146. void CPelcod::IrisLessen(int addr,BOOL work)
  147. {
  148. BYTE cmd[7] = {0xff,addr,0x04,0x00,0x0a,0x0a,0x18 + addr};
  149. if(!work)
  150. {
  151. memset(cmd + 2,0,sizeof(BYTE) * 5);
  152. cmd[6] = addr;
  153. }
  154. CCom::Write(cmd,sizeof(cmd) / sizeof(BYTE));
  155. }
  156. // Iris+    ffh,addr,02h,00h,0ah,0ah,CRC;   ffh,addr,00h,00h,00h,00h,CRC
  157. void CPelcod::IrisLargen(int addr,BOOL work)
  158. {
  159. BYTE cmd[7] = {0xff,addr,0x02,0x00,0x0a,0x0a,0x16 + addr};
  160. if(!work)
  161. {
  162. memset(cmd + 2,0,sizeof(BYTE) * 5);
  163. cmd[6] = addr;
  164. }
  165. CCom::Write(cmd,sizeof(cmd) / sizeof(BYTE));
  166. }