⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pthread_ptzctrl.c

📁 1、基于韩国at2041芯片开发的Linux环境的DVR代码。 2、以原来代码进行了修改。 3、主要修改网络通讯出现异常问题处理 4、硬盘覆盖录像不起作用
💻 C
字号:
/* set tabstop=4 */
/********************************************************************************
 *                                                                              *
 * Copyright(C) 2004  Penta-Micro                                               *
 *                                                                              *
 * ALL RIGHT RESERVED                                                           *
 *                                                                              *
 * This software is the property of Penta-Micro and is furnished under          *
 * license by Penta-Micro. This software may be used only in accordance         *	
 * with the terms of said license. This copyright notice may not be             *
 * removed, modified or obliterated without the prior written permission        *
 * of Penta-Micro.                                                              *
 *                                                                              *
 * This software may not be copyed, transmitted, provided to or otherwise       *
 * made available to any other person, company, corporation	or other entity     *
 * except as specified in the terms of said license.                            *
 *                                                                              *
 * No right, title, ownership or other interest in the software is hereby       *
 * granted or transferred.                                                      *
 *                                                                              *
 * The information contained herein is subject to change without notice and     *
 * should not be construed as a commitment by Penta-Micro.                      *
 *                                                                              *
 ********************************************************************************
 
  MODULE NAME:  pthread_ptzctrl.c
  
  REVISION HISTORY:
  
  Date       Ver Name                  Description
  ---------- --- --------------------- -----------------------------------------
  07/09/2003 1.0 Mhpark                Created   
  02/01/2005 1.1 JiGwanKang(xchannel)  Modify(arrangement)  
 ...............................................................................
 
  DESCRIPTION:
  
  This Module contains functions for Search.
  
 ...............................................................................
*/  

/** ************************************************************************* ** 
 ** includes
 ** ************************************************************************* **/
#include <stdio.h>

#include "main.h"
#include "pthread_ptzctrl.h"

/** ************************************************************************* ** 
 ** defines
 ** ************************************************************************* **/
//#define m_DEBUG(format, args...)  printf(format, ## args);fflush(stdout);
#define m_DEBUG(format, args...)  
#define m_MSG(format, args...)      printf(format, ## args);fflush(stdout);
#define m_ERROR(format, args...)  printf(format, ## args);fflush(stdout);

/** ************************************************************************* ** 
 ** typedefs
 ** ************************************************************************* **/
	 
/** ************************************************************************* ** 
 ** globals
 ** ************************************************************************* **/
extern PTHREAD_STATE	 *gp_state_thread;
extern SETUP_PARAM	 *gp_setup_param;
UNS16                            ptz_id_local[MAX_CMD];

/** ************************************************************************* ** 
 ** locals
 ** ************************************************************************* **/

/** ************************************************************************* ** 
 ** forward declarations
 ** ************************************************************************* **/

void *pthread_ptzctrl(void *args)
{
    PTHREAD_BUF		signal;
	PTZ_STR   get_proto_str ;
    UNS16 cam_speed;

    gp_state_thread->state_ptz.state = BUSY;
    cam_speed = gp_setup_param->sys.ptz.cam_speed; /* 10 level control */
    ptz_id_local[3] = gp_setup_param->sys.ptz.cam_vendor; /* cam_vendor set */

    m_MSG("\n\t!!!! pthread PTZCTRL !!!!\n");
   	ptz_set_defaults(ptz_id_local[3]);

    while (1) {
		/* waiting signal from input thread */
		pthread_read_signal(&signal, PTHREAD_PTZ, TRUE); 
		m_MSG("\n\tsignal> [ptzctrl][id:%02d][value:0x%04x]\n", signal.start_id, signal.m_value);
		
		switch (signal.m_value) {
			case PTZ_CONTROL: /* PTZ Control On/Off */
				m_MSG( "\nPTZ OFF");
				gp_state_thread->state_main.state = IDLE;
                        gp_state_thread->state_ptz.state = IDLE;
				return 0;
			break;
		case PTZ_ZOOMIN:	//PTZ Zoom IN		
			if( ptz_id_local[2] == CMD_OFF) {
				ptz_id_local[2] = CMD_ON;
				ptz_id_local[1] = ZIN;
			}
			else if( ptz_id_local[2] == CMD_ON) {
				ptz_id_local[2] = CMD_OFF;
				ptz_id_local[1] = PTZFSTOP;
			}			
//			get_proto_str.iCamID = (char)ptz_id_local[0]+1;
			get_proto_str.cmd = ptz_id_local[1];
			get_proto_str.bEnable = (char)ptz_id_local[2];
			get_proto_str.cam_vendor = ptz_id_local[3];			
			get_proto_str.iSpeed= cam_speed+1;			
			GetProtocol_ptz_server((PTZ_STR *)&get_proto_str);			
			m_MSG( "\nZoom IN %s", ptz_id_local[1]==0 ? "STOP": "RUN");		
			break;
		case PTZ_ZOOMOUT:	////PTZ Zoom OUT		
		       if( ptz_id_local[2] == CMD_OFF) {
				ptz_id_local[2] = CMD_ON;
				ptz_id_local[1] = ZOUT;
			}
			else if( ptz_id_local[2] == CMD_ON) {
				ptz_id_local[2] = CMD_OFF;
				ptz_id_local[1] = PTZFSTOP;
			}
//			get_proto_str.iCamID = (char)ptz_id_local[0]+1;
			get_proto_str.cmd = ptz_id_local[1];
			get_proto_str.bEnable = (char)ptz_id_local[2];
			get_proto_str.cam_vendor = ptz_id_local[3];		
			get_proto_str.iSpeed  = cam_speed+1;			
			GetProtocol_ptz_server((PTZ_STR *)&get_proto_str);			
			m_MSG( "\nZoom OUT %s", ptz_id_local[1]==0 ? "STOP": "RUN");
			break;
		case UP:////PTZ UP
			if( ptz_id_local[2] == CMD_OFF) {
				ptz_id_local[2] = CMD_ON;
				ptz_id_local[1] = PTUP; 
			}
			else if( ptz_id_local[2] == CMD_ON) {
				ptz_id_local[2] = CMD_OFF;
				ptz_id_local[1] = PTZFSTOP; 
			}
//			get_proto_str.iCamID = (char)ptz_id_local[0]+1;
			get_proto_str.cmd = ptz_id_local[1];
			get_proto_str.bEnable = (char)ptz_id_local[2];
			get_proto_str.cam_vendor = ptz_id_local[3];		
			get_proto_str.iSpeed  = cam_speed+1;			
			GetProtocol_ptz_server((PTZ_STR *)&get_proto_str);			
			m_MSG( "\nUP %s", ptz_id_local[1]==0 ? "STOP": "RUN");
			break;
		case DOWN:////PTZ DOWN
			if( ptz_id_local[2] == CMD_OFF) {
				ptz_id_local[2] = CMD_ON;
				ptz_id_local[1] = PTDOWN;
			}
			else if( ptz_id_local[2] == CMD_ON) {
				ptz_id_local[2] = CMD_OFF;
				ptz_id_local[1] = PTZFSTOP;
			}			
//			get_proto_str.iCamID = (char)ptz_id_local[0]+1;
			get_proto_str.cmd = ptz_id_local[1];
			get_proto_str.bEnable = (char)ptz_id_local[2];
			get_proto_str.cam_vendor = ptz_id_local[3];	
			get_proto_str.iSpeed  = cam_speed+1;			
			GetProtocol_ptz_server((PTZ_STR *)&get_proto_str);			
			m_MSG( "\nDOWN %s", ptz_id_local[1]==0 ? "STOP": "RUN");
			break;
		case LEFT:////PTZ LEFT
			if( ptz_id_local[2] == CMD_OFF) {
				ptz_id_local[2] = CMD_ON;
				ptz_id_local[1] = PTLEFT;
			}
			else if( ptz_id_local[2] == CMD_ON) {
				ptz_id_local[2] = CMD_OFF;
				ptz_id_local[1] = PTZFSTOP;
			}			
//			get_proto_str.iCamID = (char)ptz_id_local[0]+1;
			get_proto_str.cmd = ptz_id_local[1];
			get_proto_str.bEnable = (char)ptz_id_local[2];
			get_proto_str.cam_vendor = ptz_id_local[3];	
			get_proto_str.iSpeed  = cam_speed+1;			
			GetProtocol_ptz_server((PTZ_STR *)&get_proto_str);			
			m_MSG( "\nLEFT %s", ptz_id_local[1]==0 ? "STOP": "RUN");
			break;
		case RIGHT:////PTZ RIGHT
			if( ptz_id_local[2] == CMD_OFF) {
				ptz_id_local[2] = CMD_ON;
				ptz_id_local[1] = PTRIGHT;
			}
			else if( ptz_id_local[2] == CMD_ON) {
				ptz_id_local[2] = CMD_OFF;
				ptz_id_local[1] = PTZFSTOP;
			}			
//			get_proto_str.iCamID = (char)ptz_id_local[0]+1;
			get_proto_str.cmd = ptz_id_local[1];
			get_proto_str.bEnable = (char)ptz_id_local[2];
			get_proto_str.cam_vendor = ptz_id_local[3];	
			get_proto_str.iSpeed  = cam_speed+1;			
			GetProtocol_ptz_server((PTZ_STR *)&get_proto_str);		
			m_MSG( "\nRIGHT %s", ptz_id_local[1]==0 ? "STOP": "RUN");	
			break;
		case PTZ_FOCUSIN:////PTZ FOCUS IN
			if( ptz_id_local[2] == CMD_OFF) {
				ptz_id_local[2] = CMD_ON;
				ptz_id_local[1] = FIN;
			}
			else if( ptz_id_local[2] == CMD_ON) {
				ptz_id_local[2] = CMD_OFF;
				ptz_id_local[1] = PTZFSTOP;
			}
//			get_proto_str.iCamID = (char)ptz_id_local[0]+1;
			get_proto_str.cmd = ptz_id_local[1];
			get_proto_str.bEnable = (char)ptz_id_local[2];
			get_proto_str.cam_vendor = ptz_id_local[3];
			get_proto_str.iSpeed  = cam_speed+1;			
			GetProtocol_ptz_server((PTZ_STR *)&get_proto_str);		
	 		m_MSG( "\nFocus IN %s", ptz_id_local[1]==0 ? "STOP": "RUN");	
			break;
		case PTZ_FOCUSOUT:////PTZ FOCUS OUT
			if( ptz_id_local[2] == CMD_OFF) {
				ptz_id_local[2] = CMD_ON;
				ptz_id_local[1] =FOUT;
			}
			else if( ptz_id_local[2] == CMD_ON) {
				ptz_id_local[2] = CMD_OFF;
				ptz_id_local[1] = PTZFSTOP;
			}			
//			get_proto_str.iCamID = (char)ptz_id_local[0]+1;
			get_proto_str.cmd = ptz_id_local[1];
			get_proto_str.bEnable = (char)ptz_id_local[2];
			get_proto_str.cam_vendor = ptz_id_local[3];	
			get_proto_str.iSpeed  = cam_speed+1;			
			GetProtocol_ptz_server((PTZ_STR *)&get_proto_str);		
			m_MSG( "\nFocus OUT %s", ptz_id_local[1]==0 ? "STOP": "RUN");	
			break;
		case REC :	
			/* display REC monitoring */
			signal.start_id = PTHREAD_MAIN;
			if (pthread_send_signal(&signal, PTHREAD_MANAGER) == FALSE) {
				m_ERROR("pthread_ptzctrl.c:error: In function 'pthread_send_signal'\n");
			} 
			break;
        case NUMBER0:
        case NUMBER1:        	
        case NUMBER2:        	        	
        case NUMBER3:
        case NUMBER4:        	
        case NUMBER5:        	        	
        case NUMBER6:
        case NUMBER7:        	        	
        case OSD:        	        	        	
			if (pthread_send_signal(&signal, PTHREAD_LIVE) == FALSE) {
				m_ERROR("pthread_ptzctrl.c:error: In function 'pthread_send_signal'\n");
			}
			break;
		default:
			break;
		}
 	} /* end of while (!QUIT_SDVR_MAIN) */

    return 0;
}

void GetProtocol_ptz_server (void *args)
{	
	PTZ_STR *get_proto_str = (PTZ_STR *)args ;

	get_proto_str->No = 0; 
	ptz_status_struct.isr_table[get_proto_str->cmd].isr_ptr((PTZ_STR *)get_proto_str);		
}

void ptz_set_defaults(UNS16 vendor)
{
	

	switch(vendor) {
		case PTZ_LVCA720_ID:
			m_DEBUG("\nSet Fun ptr,  PTZ Vendor ID = %s", PTZ_LVCA720);
	        CLVCA720();
			break;
		case PTZ_DRX502A_ID:
			m_DEBUG("\nSet Fun ptr,  PTZ Vendor ID = %s", PTZ_DRX502A);
		    CDRX502A();
			break;
		case PTZ_PelcoD_ID:
			m_DEBUG("\nSet Fun ptr,  PTZ Vendor ID = %s", PTZ_PelcoD);
            CPelcoD();
			break;
		case PTZ_NK97CHE_ID:
			m_DEBUG("\nSet Fun ptr,  PTZ Vendor ID = %s", PTZ_NK97CHE);
            CNK97CHE();
			break;
		case PTZ_SCC641_ID:
			m_DEBUG("\nSet Fun ptr,  PTZ Vendor ID = %s", PTZ_SCC641);
            CSCC641();
			break;
		case PTZ_PelcoP_ID:
			m_DEBUG("\nSet Fun ptr,  PTZ Vendor ID = %s", PTZ_PelcoP);
            CPelcoP();
			break;
		case PTZ_SJ2819RX_ID:
			m_DEBUG("\nSet Fun ptr,  PTZ Vendor ID = %s", PTZ_SJ2819RX);
			CSJ2819RX();
			break;
		case PTZ_MRX1000_ID:
			m_DEBUG("\nSet Fun ptr,  PTZ Vendor ID = %s", PTZ_MRX1000);
            CMRX1000();
			break;
		case PTZ_SPD1600_ID:
			m_DEBUG("\nSet Fun ptr,  PTZ Vendor ID = %s", PTZ_SPD1600);
            CSPD1600();
			break;
		case PTZ_WPT101_ID:
			m_DEBUG("\nSet Fun ptr,  PTZ Vendor ID = %s", PTZ_WPT101);
            CWPT101();	
			break;
		default:
			m_DEBUG("UNKNOWN VENDOR ID !\n");		
			break;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -