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

📄 atv.c

📁 一个操作系统源代码 用于嵌入式设备 在Vc++环境下仿真 成功移植到多款处理器上
💻 C
📖 第 1 页 / 共 3 页
字号:
/*************************************************************************
*
* Copyright  2000 National ASIC Center, All right Reserved
*
* FILE NAME: atv.c
* PROGRAMMER: Jinjing
* Date of Creation: 2001/10/21
* 
* DESCRIPTION: The operation about Active Area. Include the
*  creating, deleting, reading, suspending, translating.
*
* NOTE: 
* 
* FUNCTIONS LIST:
* -------------------------------------------------------------------------
* STATUS SysActiveAreaEnable(P_U32 areaId,U32 type,U32 mode,S16 xSrc,S16 ySrc,S16 xDest,S16 yDest,DWORD wndId)
* STATUS SysActiveAreaDisable(U32 areaId)
* STATUS SysActiveAreaSuspend(U32 areaId,U32 flag)
* STATUS SysActiveAreaRead(U32 areaId,P_S16 xSrc, P_S16 ySrc, P_S16 xDest, P_S16 yDest)
* void   SysTransMsg(MSG *ROSmsg,ATVCB p,MSG *PPSMmsg)
* 
*(Below functions are not implemented!!!)
* 	STATUS SysActiveAreaToFront(U32 areaId)
* 	STATUS SysActiveAreaPosition(U32 areaId,S16 xSrc, S16 ySrc,S16 xDest,S16 yDest)
* 	STATUS SysActiveListPush(void)
* 	STATUS SysActiveListPop(void)
**************************************************************************
* MODIFICATION HISTORY
*
* 2001/10/21 by Jinjing Creation of this file
* 2001/11/05 by Jinjing add the function of :SysActiveAreaToFront
*                                            SysActiveAreaPosition
*											 SysActiveListPush
* 											 SysActiveListPop
* 2001/12/20 by Jinjing add the function about InputPad
* 2002/03/15 by Jinjing add the WndId in the structure of Atv
*************************************************************************/ 
#include <sys\systsk.h>
#include <sys\ppsmmsg.h>
#include <sys\atv.h>
#include <sys\lmalloc.h>
#include <sys\gpc.h>
#include <sys\systmr.h>
#include <sys\sysdebug.h>
#include <asixwin.h>
#include "xatv.h"


#define INPUTPADOPEN  1
#define INPUTPADCLOSE 0

#define HandWriteRecognizeNum	10

/* this pointer should be deleted! Current ATVCB is determind by the running task */
ATVCB *p;

PUBLIC ATV *findId( ATV *start,DWORD areaId );
static ATV *searchATV( MSG *ROSmsg,ATVCB *p);
static void AtvTimerOutProcess( InPutPad *pad );
static void ClearPenTrack( InPutPad *pad );

PUBLIC ATVCB *SysInitATVCB( void );

PUBLIC void   SysTransMsg(MSG *ROSmsg, ATVCB *p, MSG *PPSMmsg);
PUBLIC STATUS SysFreeATVCB( ATVCB *p );
PUBLIC STATUS SysActiveAreaEnable(PDWORD areaId,DWORD type,DWORD mode,SHORT xSrc,SHORT ySrc,SHORT xDest,SHORT yDest, DWORD wndId);
PUBLIC STATUS SysActiveAreaDisable(DWORD areaId);
PUBLIC STATUS SysActiveAreaSuspend(DWORD areaId,DWORD flag);
PUBLIC STATUS SysActiveAreaRead(DWORD areaId,PSHORT xSrc, PSHORT ySrc, PSHORT xDest, PSHORT yDest);
unsigned short * WTRecognize(unsigned char * PointBuf,short PointsNumber,unsigned short *CandidateResult);
/*****************************************************************
*  Function Name: ActiveAreaEnable
*  Param in: P_U32 areaId,U32 type,U32 mode,S16 xSrc,S16 ySrc,S16 xDest,S16 yDest
*  Result code: status
*  Description: creating a  active  area
*****************************************************************/ 
STATUS SysActiveAreaEnable(PDWORD areaId,DWORD type,DWORD mode,SHORT xSrc,SHORT ySrc,SHORT xDest,SHORT yDest,DWORD wndId )
{
	ATV *start,*info;
	ID id;
	ATVCB *p;
	
	if( areaId == NULL )
		return PPSM_ERR_AREA_ID;

	if( ( xDest <= xSrc ) || ( yDest <= ySrc ) ) 
		return PPSM_ERR_COORDINATE;
		
	if( ( type != ICON_AREA ) && ( type != INPUT_AREA ) )
		return PPSM_ERR_AREA_CODE;
	
	/* Get id of the running task */
	get_tid(&id);
	/* Get pointer to ATVCB of the running task */
	p = gSysTcbTbl[id-1].atvcb;
	
	start=p->stack[ p->top ];
	
	info=( ATV* )SysLmalloc( sizeof( ATV ) );

	// longn_qi 2002/01/25 for monitor memory leak
//	memdbgprintf( "appeal mem for ATV" );
	
	if( info == NULL )
		return PPSM_ERR_NO_MEMORY;
	else
		{
			/* Now, we just support CONTINUOUS_MODE INPUTAREA */
			if((type == INPUT_AREA)&&(mode != CONTINUOUS_MODE))
					return PPSM_ERR_AREA_CODE;
				
			info->mode=mode;
			info->areaId=( DWORD )info;
			info->flag=AREA_REENABLE;
			info->previous=NULL;
			info->next=start;
			if( start != NULL )
				start->previous=info;
			info->type=type;
			info->xsrc=xSrc;
			info->ysrc=ySrc;
			info->xdest=xDest;
			info->ydest=yDest;
			info->wndId=wndId;
			start=info;
			p->stack[ p->top ]=start;
			*areaId=start->areaId;
			
			return PPSM_OK;
		}
}

/*****************************************************************
*  Function Name: ActiveAreaDisable
*  Param in: U32 areaId
*  Result code: status 
*  Description: deleting a active area
*****************************************************************/ 
STATUS SysActiveAreaDisable(DWORD areaId)
{
	ATV *start,*info;
	int id;
	ATVCB *p;
	
	/* Get id of the running task */
	get_tid(&id);
	/* Get pointer to ATVCB of the running task */
	p = gSysTcbTbl[id-1].atvcb;

	start=p->stack[ p->top ];
	
	if( ( info=findId( start,areaId ) ) == NULL )
		return PPSM_ERR_AREA_ID;
	
	//info = (ATV *)areaId;
	if( start == info )    /*找到的在头部*/
	{
		start=info->next;
		if ( start != NULL )
			start->previous=NULL;
	}
	else   /*当不在头部*/
	{
		info->previous->next=info->next;
		if( info->next != NULL )   /*在中部时,尾部直接删掉*/
			info->previous->next->previous=info->previous;
	}
	SysLfree( info );

	// longn_qi 2002/01/25 for monitor memory leak
//	memdbgprintf( "free mem of ATV" );

	p->stack[ p->top ]=start;
	
	return PPSM_OK;
	
	/* Since we don't check areaId's value is right or wrong, 
	   PPSM_ERR_AREA_ID will never be returned. */
	//return PPSM_ERR_AREA_ID;
}

/*****************************************************************
*  Function Name: ActiveAreaSuspend 
*  Param in: U32 areaId,U32 flag 
*  Result code: status
*  Description: suspending a active area
*****************************************************************/ 
/*STATUS SysActiveAreaSuspend(DWORD areaId,DWORD flag)
{
	ATV *info,*start;
	int id;
	ATVCB *p;
	
	
	get_tid(&id);

	p = gSysTcbTbl[id-1].atvcb;
	
	start=p->stack[ p->top ];
	
	if( ( info=findId( start,areaId ) ) == NULL )
		return PPSM_ERR_AREA_ID;
	
	//info = (ATV *)areaId;
	info->flag=flag;
	
	return PPSM_OK;	
}*/
STATUS SysActiveAreaSuspend(DWORD areaId,DWORD flag)
{
	ATV *p;
	
	p = (ATV *)areaId; 
	if( p == NULL)
		return PPSM_ERR_AREA_ID;

	p->flag = flag;

	return PPSM_OK;
}
/*****************************************************************
*  Function Name: ActiveAreaRead
*  Param in: U32 areaId,P_S16 xSrc, P_S16 ySrc, P_S16 xDest, P_S16 yDest
*  Result code: status
*  Description: reading a active area
*****************************************************************/ 
STATUS SysActiveAreaRead(DWORD areaId,PSHORT xSrc, PSHORT ySrc, PSHORT xDest, PSHORT yDest)
{
	ATV *info,*start;
	int id;
	ATVCB *p;
	
	/* Get id of the running task */
	get_tid(&id);
	/* Get pointer to ATVCB of the running task */
	p = gSysTcbTbl[id-1].atvcb;
	
	start=p->stack[ p->top ];
	
	if( ( info=findId( start,areaId ) ) == NULL )
		return PPSM_ERR_AREA_ID;
	if( xSrc == NULL || ySrc == NULL || xDest == NULL || yDest == NULL )
		return PPSM_ERROR;

	//info = (ATV *)areaId;
	*xSrc=info->xsrc;
	*ySrc=info->ysrc;
	*xDest=info->xdest;
	*yDest=info->ydest;
	
	return PPSM_OK;	
}


/*****************************************************************
*  Function Name: ActiveListPush
*  Param in: void
*  Result code: status
*  Description: push active area list into background
*****************************************************************/ 
STATUS SysActiveListPush(  )
{
	ATVCB *p;
	int id;
		
	/* Get id of the running task */
	get_tid(&id);
	/* Get pointer to ATVCB of the running task */
	p = gSysTcbTbl[id-1].atvcb;
	
	if( p->top == ( ATVSTK_LAYER-1 ) )
		return PPSM_ERR_ACTIVE_PUSH;
	else
	{
		p->top++;
		/*p->stack[p->top]=start;*/
		return PPSM_OK;
	}	
}

/*****************************************************************
*  Function Name: ActiveListPop
*  Param in: void
*  Result code: status
*  Description: pop active area to foreground
*****************************************************************/
STATUS SysActiveListPop(  )
{
	ATV *start,*info;
	ATVCB *p;
	int id;
	
	/* Get id of the running task */
	get_tid(&id);
	/* Get pointer to ATVCB of the running task */
	p = gSysTcbTbl[id-1].atvcb;
	
	if( p->top==0 )
		return PPSM_ERROR;
	else
	{
		start=p->stack[ p->top ];
		while( start != NULL )
		{
			info=start;
			start=start->next;
			SysLfree(info);

			// longn_qi 2002/01/25 for monitor memory leak
//			memdbgprintf( "free mem of ATV" );

		}
		/*free(start);*/
		p->stack[ p->top ] = start;
		p->top--;
		/*start=p->stack[ p->top ];*/
		return PPSM_OK;
	}
}      

/*****************************************************************
*  Function Name: ActiveAreaToFront
*  Param in: U32 areaId
*  Result code: status
*  Description: put active area to front of list
*****************************************************************/
STATUS SysActiveAreaToFront( DWORD areaId )
{
	ATV *start,*info;
	
	start=p->stack[ p->top ];
	if( ( info=findId( start,areaId ) ) != NULL )
	{
		if( start == info )
			start->flag=AREA_REENABLE;
		else
		{
			info->previous->next=info->next;
			if( info->next != NULL )
				info->previous->next->previous=info->previous;
				
			info->flag=AREA_REENABLE;
			info->previous=NULL;
			info->next=start;
			if( start != NULL )
				start->previous=info;
			start=info;
			p->stack[ p->top ]=start;
		}
		return PPSM_OK; 
	}
	else
		return PPSM_ERR_AREA_ID;
}

/*****************************************************************
*  Function Name: ActiveAreaPosition
*  Param in: U32 areaId,S16 xSrc, S16 ySrc,S16 xDest,S16 yDest
*  Result code: status
*  Description: change the position and the size of the active area 
				specified by areaId
*****************************************************************/ 
STATUS SysActiveAreaPosition( DWORD areaId,SHORT xSrc, SHORT ySrc,SHORT xDest,SHORT yDest )
{
	ATV *start,*info;

	if( ( xDest <= xSrc ) || ( yDest <= ySrc ) ) 
		return PPSM_ERR_COORDINATE;
		
	start=p->stack[ p->top ];
	if( ( info=findId( start,areaId ) ) != NULL )
	{
		info->xsrc=xSrc;
		info->ysrc=ySrc;
		info->xdest=xDest;
		info->ydest=yDest;
		return PPSM_OK;
	}
	else
		return PPSM_ERR_AREA_ID;
}


/*****************************************************************
*  Function Name: findId
*  Param in: ATV *start,areaId
*  Result code: ATV * 
*  Description: finding atv by areaId
*****************************************************************/         
PUBLIC ATV *findId( ATV *start,DWORD areaId )

⌨️ 快捷键说明

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