Pelcod.cpp
资源名称:视频会议系统.rar [点击查看]
上传用户:popouu88
上传日期:2013-02-11
资源大小:2894k
文件大小:5k
源码类别:
IP电话/视频会议
开发平台:
Visual C++
- // Pelcod.cpp: implementation of the CPelcod class.
- //
- //////////////////////////////////////////////////////////////////////
- #include "....stdafx.h"
- #include "Pelcod.h"
- #ifdef _DEBUG
- #undef THIS_FILE
- static char THIS_FILE[]=__FILE__;
- #define new DEBUG_NEW
- #endif
- //////////////////////////////////////////////////////////////////////
- // Construction/Destruction
- //////////////////////////////////////////////////////////////////////
- CPelcod::CPelcod()
- {
- }
- CPelcod::~CPelcod()
- {
- }
- void CPelcod::OpenPort(void)
- {
- if(!CCom::Open(1) && !CCom::Open(2))
- {
- }
- }
- void CPelcod::ClosePort(void)
- {
- CCom::Close();
- }
- void CPelcod::DoWork(int cmd,int addr,BOOL work)
- {
- switch(cmd)
- {
- case UP : this->Up(addr,work); break;
- case DOWN : this->Down(addr,work); break;
- case LEFT : this->Left(addr,work); break;
- case RIGHT : this->Right(addr,work);break;
- case AUTO : this->Auto(addr,work); break;
- case FOCUS_LESSEN : this->FocusLessen(addr,work); break;
- case FOCUS_LARGEN : this->FocusLargen(addr,work); break;
- case ZOOM_LESSEN : this->ZoomLessen(addr,work); break;
- case ZOOM_LARGEN : this->ZoomLargen(addr,work); break;
- case IRIS_LESSEN : this->IrisLessen(addr,work); break;
- case IRIS_LARGEN : this->IrisLargen(addr,work); break;
- }
- }
- // Up ffh,addr,00h,08h,0ah,0ah,CRC : ffh,addr,00h,00h,00h,00h,CRC
- void CPelcod::Up(int addr,BOOL work)
- {
- BYTE cmd[7] = {0xff,addr,0x00,0x08,0x0a,0x0a,0x1c + addr};
- if(!work)
- {
- memset(cmd + 2,0,sizeof(BYTE) * 5);
- cmd[6] = addr;
- }
- CCom::Write(cmd,sizeof(cmd) / sizeof(BYTE));
- }
- // Down ffh,addr,00h,10h,0ah,0ah,CRC; ffh,addr,00h,00h,00h,00h,CRC
- void CPelcod::Down(int addr,BOOL work)
- {
- BYTE cmd[7] = {0xff,addr,0x00,0x10,0x0a,0x0a,0x24 + addr};
- if(!work)
- {
- memset(cmd + 2,0,sizeof(BYTE) * 5);
- cmd[6] = addr;
- }
- CCom::Write(cmd,sizeof(cmd) / sizeof(BYTE));
- }
- // Left ffh,addr,00h,04h,0ah,0ah,CRC; ffh,addr,00h,00h,00h,00h,CRC
- void CPelcod::Left(int addr,BOOL work)
- {
- BYTE cmd[7] = {0xff,addr,0x00,0x04,0x0a,0x0a,0x18 + addr};
- if(!work)
- {
- memset(cmd + 2,0,sizeof(BYTE) * 5);
- cmd[6] = addr;
- }
- CCom::Write(cmd,sizeof(cmd) / sizeof(BYTE));
- }
- // Right ffh,addr,00h,02h,0ah,0ah,CRC; ffh,addr,00h,00h,00h,00h,CRC
- void CPelcod::Right(int addr,BOOL work)
- {
- BYTE cmd[7] = {0xff,addr,0x00,0x02,0x0a,0x0a,0x16 + addr};
- if(!work)
- {
- memset(cmd + 2,0,sizeof(BYTE) * 5);
- cmd[6] = addr;
- }
- CCom::Write(cmd,sizeof(cmd) / sizeof(BYTE));
- }
- // Auto ffh,addr,00h,03h,00h,01h,CRC; ffh,addr,00h,03h,00h,02h,CRC
- void CPelcod::Auto(int addr,BOOL work)
- {
- BYTE cmd[7] = {0xff,addr,0x00,0x03,0x00,0x01,0x04 + addr};
- if(!work)
- {
- cmd[5] = 0x02; cmd[6] += 0x01;
- }
- CCom::Write(cmd,sizeof(cmd) / sizeof(BYTE));
- }
- // Focus- ffh,addr,01h,00h,0ah,0ah,CRC; ffh,addr,00h,00h,00h,00h,CRC
- void CPelcod::FocusLessen(int addr,BOOL work)
- {
- BYTE cmd[7] = {0xff,addr,0x01,0x00,0x0a,0x0a,0x15 + addr};
- if(!work)
- {
- memset(cmd + 2,0,sizeof(BYTE) * 5);
- cmd[6] = addr;
- }
- CCom::Write(cmd,sizeof(cmd) / sizeof(BYTE));
- }
- // Focus+ ffh,addr,00h,80h,0ah,0ah,CRC; ffh,addr,00h,00h,00h,00h,CRC
- void CPelcod::FocusLargen(int addr,BOOL work)
- {
- BYTE cmd[7] = {0xff,addr,0x00,0x80,0x0a,0x0a,0x94 + addr};
- if(!work)
- {
- memset(cmd + 2,0,sizeof(BYTE) * 5);
- cmd[6] = addr;
- }
- CCom::Write(cmd,sizeof(cmd) / sizeof(BYTE));
- }
- // Zoom- ffh,addr,00h,40h,0ah,0ah,CRC; ffh,addr,00h,00h,00h,00h,CRC
- void CPelcod::ZoomLessen(int addr,BOOL work)
- {
- BYTE cmd[7] = {0xff,addr,0x00,0x40,0x0a,0x0a,0x54 + addr};
- if(!work)
- {
- memset(cmd + 2,0,sizeof(BYTE) * 5);
- cmd[6] = addr;
- }
- CCom::Write(cmd,sizeof(cmd) / sizeof(BYTE));
- }
- // Zoom+ ffh,addr,00h,20h,0ah,0ah,CRC; ffh,addr,00h,00h,00h,00h,CRC
- void CPelcod::ZoomLargen(int addr,BOOL work)
- {
- BYTE cmd[7] = {0xff,addr,0x00,0x20,0x0a,0x0a,0x34 + addr};
- if(!work)
- {
- memset(cmd + 2,0,sizeof(BYTE) * 5);
- cmd[6] = addr;
- }
- CCom::Write(cmd,sizeof(cmd) / sizeof(BYTE));
- }
- // Iris- ffh,addr,04h,00h,0ah,0ah,CRC; ffh,addr,00h,00h,00h,00h,CRC
- void CPelcod::IrisLessen(int addr,BOOL work)
- {
- BYTE cmd[7] = {0xff,addr,0x04,0x00,0x0a,0x0a,0x18 + addr};
- if(!work)
- {
- memset(cmd + 2,0,sizeof(BYTE) * 5);
- cmd[6] = addr;
- }
- CCom::Write(cmd,sizeof(cmd) / sizeof(BYTE));
- }
- // Iris+ ffh,addr,02h,00h,0ah,0ah,CRC; ffh,addr,00h,00h,00h,00h,CRC
- void CPelcod::IrisLargen(int addr,BOOL work)
- {
- BYTE cmd[7] = {0xff,addr,0x02,0x00,0x0a,0x0a,0x16 + addr};
- if(!work)
- {
- memset(cmd + 2,0,sizeof(BYTE) * 5);
- cmd[6] = addr;
- }
- CCom::Write(cmd,sizeof(cmd) / sizeof(BYTE));
- }