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 , "2400,n,8,1" ) && !CCom::Open(2 , "2400,n,8,1" ))
  23. CWnd::GetActiveWindow()->MessageBox("没有可用的端口","解码器控制",MB_ICONSTOP | MB_OK);
  24. }
  25. void CPelcod::ClosePort(void)
  26. {
  27. CCom::Close();
  28. }
  29. void CPelcod::DoWork(int cmd,int addr,BOOL work)
  30. {
  31. switch(cmd)
  32. {
  33. case UP : this->Up(addr,work); break;
  34. case DOWN : this->Down(addr,work); break;
  35. case LEFT : this->Left(addr,work); break;
  36. case RIGHT : this->Right(addr,work);break;
  37. case AUTO : this->Auto(addr,true); break;
  38. case FOCUS_LESSEN : this->FocusLessen(addr,work); break;
  39. case FOCUS_LARGEN : this->FocusLargen(addr,work); break;
  40. case ZOOM_LESSEN : this->ZoomLessen(addr,work); break;
  41. case ZOOM_LARGEN : this->ZoomLargen(addr,work); break;
  42. case IRIS_LESSEN : this->IrisLessen(addr,work); break;
  43. case IRIS_LARGEN : this->IrisLargen(addr,work); break;
  44. }
  45. }
  46. // Up    ffh,addr,00h,08h,0ah,0ah,CRC : ffh,addr,00h,00h,00h,00h,CRC
  47. void CPelcod::Up(int addr,BOOL work)
  48. {
  49. BYTE cmd[7] = {0xff,addr,0x00,0x08,0x0a,0x0a,0x1c + addr};
  50. if(!work)
  51. {
  52. memset(cmd + 2,0,sizeof(BYTE) * 5);
  53. cmd[6] = addr;
  54. }
  55. CCom::Write(cmd,sizeof(cmd) / sizeof(BYTE));
  56. }
  57. // Down  ffh,addr,00h,10h,0ah,0ah,CRC;    ffh,addr,00h,00h,00h,00h,CRC 
  58. void CPelcod::Down(int addr,BOOL work)
  59. {
  60. BYTE cmd[7] = {0xff,addr,0x00,0x10,0x0a,0x0a,0x24 + addr};
  61. if(!work)
  62. {
  63. memset(cmd + 2,0,sizeof(BYTE) * 5);
  64. cmd[6] = addr;
  65. }
  66. CCom::Write(cmd,sizeof(cmd) / sizeof(BYTE));
  67. }
  68. // Left    ffh,addr,00h,04h,0ah,0ah,CRC;   ffh,addr,00h,00h,00h,00h,CRC
  69. void CPelcod::Left(int addr,BOOL work)
  70. {
  71. BYTE cmd[7] = {0xff,addr,0x00,0x04,0x0a,0x0a,0x18 + addr};
  72. if(!work)
  73. {
  74. memset(cmd + 2,0,sizeof(BYTE) * 5);
  75. cmd[6] = addr;
  76. }
  77. CCom::Write(cmd,sizeof(cmd) / sizeof(BYTE));
  78. }
  79. // Right   ffh,addr,00h,02h,0ah,0ah,CRC;   ffh,addr,00h,00h,00h,00h,CRC
  80. void CPelcod::Right(int addr,BOOL work)
  81. {
  82. BYTE cmd[7] = {0xff,addr,0x00,0x02,0x0a,0x0a,0x16 + addr};
  83. if(!work)
  84. {
  85. memset(cmd + 2,0,sizeof(BYTE) * 5);
  86. cmd[6] = addr;
  87. }
  88. CCom::Write(cmd,sizeof(cmd) / sizeof(BYTE));
  89. }
  90. // Auto    ffh,addr,00h,03h,00h,01h,CRC;   ffh,addr,00h,03h,00h,02h,CRC
  91. void CPelcod::Auto(int addr,BOOL work)
  92. {
  93. BYTE cmd[7] = {0xff,addr,0x00,0x03,0x00,0x01,0x04 + addr};
  94. if(!work)
  95. {
  96. cmd[5] = 0x02; cmd[6] += 0x01;
  97. }
  98. CCom::Write(cmd,sizeof(cmd) / sizeof(BYTE));
  99. }
  100. // Focus-  ffh,addr,01h,00h,0ah,0ah,CRC;   ffh,addr,00h,00h,00h,00h,CRC
  101. void CPelcod::FocusLessen(int addr,BOOL work)
  102. {
  103. BYTE cmd[7] = {0xff,addr,0x01,0x00,0x0a,0x0a,0x15 + addr};
  104. if(!work)
  105. {
  106. memset(cmd + 2,0,sizeof(BYTE) * 5);
  107. cmd[6] = addr;
  108. }
  109. CCom::Write(cmd,sizeof(cmd) / sizeof(BYTE));
  110. }
  111. // Focus+  ffh,addr,00h,80h,0ah,0ah,CRC;   ffh,addr,00h,00h,00h,00h,CRC
  112. void CPelcod::FocusLargen(int addr,BOOL work)
  113. {
  114. BYTE cmd[7] = {0xff,addr,0x00,0x80,0x0a,0x0a,0x94 + addr};
  115. if(!work)
  116. {
  117. memset(cmd + 2,0,sizeof(BYTE) * 5);
  118. cmd[6] = addr;
  119. }
  120. CCom::Write(cmd,sizeof(cmd) / sizeof(BYTE));
  121. }
  122. // Zoom-  ffh,addr,00h,40h,0ah,0ah,CRC;   ffh,addr,00h,00h,00h,00h,CRC
  123. void CPelcod::ZoomLessen(int addr,BOOL work)
  124. {
  125. BYTE cmd[7] = {0xff,addr,0x00,0x40,0x0a,0x0a,0x54 + addr};
  126. if(!work)
  127. {
  128. memset(cmd + 2,0,sizeof(BYTE) * 5);
  129. cmd[6] = addr;
  130. }
  131. CCom::Write(cmd,sizeof(cmd) / sizeof(BYTE));
  132. }
  133. // Zoom+  ffh,addr,00h,20h,0ah,0ah,CRC;   ffh,addr,00h,00h,00h,00h,CRC
  134. void CPelcod::ZoomLargen(int addr,BOOL work)
  135. {
  136. BYTE cmd[7] = {0xff,addr,0x00,0x20,0x0a,0x0a,0x34 + addr};
  137. if(!work)
  138. {
  139. memset(cmd + 2,0,sizeof(BYTE) * 5);
  140. cmd[6] = addr;
  141. }
  142. CCom::Write(cmd,sizeof(cmd) / sizeof(BYTE));
  143. }
  144. // Iris-    ffh,addr,04h,00h,0ah,0ah,CRC;   ffh,addr,00h,00h,00h,00h,CRC
  145. void CPelcod::IrisLessen(int addr,BOOL work)
  146. {
  147. BYTE cmd[7] = {0xff,addr,0x04,0x00,0x0a,0x0a,0x18 + addr};
  148. if(!work)
  149. {
  150. memset(cmd + 2,0,sizeof(BYTE) * 5);
  151. cmd[6] = addr;
  152. }
  153. CCom::Write(cmd,sizeof(cmd) / sizeof(BYTE));
  154. }
  155. // Iris+    ffh,addr,02h,00h,0ah,0ah,CRC;   ffh,addr,00h,00h,00h,00h,CRC
  156. void CPelcod::IrisLargen(int addr,BOOL work)
  157. {
  158. BYTE cmd[7] = {0xff,addr,0x02,0x00,0x0a,0x0a,0x16 + addr};
  159. if(!work)
  160. {
  161. memset(cmd + 2,0,sizeof(BYTE) * 5);
  162. cmd[6] = addr;
  163. }
  164. CCom::Write(cmd,sizeof(cmd) / sizeof(BYTE));
  165. }