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

📄 measure.c

📁 基于东南大学开发的SEP3203的ARM7中的所有驱动
💻 C
📖 第 1 页 / 共 5 页
字号:
/*************************************************************************
 *
 *  Copyright (C) Asic Center. 2001
 *  All Rights Reserved
 *
 *  Filename : testcode.c
 *  Function : Some tasks for testing system prototype, such as SHELL, TIMER
 *			   TASK, IDLE TASK, TASK A,B,C, and so on.
 *  Revision :
 *          2001/10/9  Pessia      Create this file
 *
 ************************************************************************/
#include <stdio.h>
#include <string.h> 
#include <math.h>

#include "asixwin.h"
#include "asixapp.h"

#include "keydef.h"

#include "bitmap.h"
#include "asix_lb.h"

#include "measure.h"

#include "atv.h"

extern unsigned char	measure_logo[];
extern unsigned char	map_bkg001[];
extern unsigned char	map_bkg002[];
extern unsigned char	seu_map[];
extern const unsigned char seu_map1[];

extern void MeasureMain(void);

//TASKDESCRIPTION	MeasureTskDesp =
//{ "土地测量",	ASIX_APP,	0,		xh1,	2048,	1,	LCD_WIDTH,	LCD_HEIGHT,	MeasureMain,	APP_PRI};

#ifdef DEBUG
BYTE Parameter[4];
#endif

BYTE PointInfo[POINT_NUM_MAX];//暂存点信息
//DWORD	CmcCurrentAddress = CMC_START_ADDRESS;//定义一个全局变量用来控制每次保存cmc文件的起始地址
DWORD	FileCurrentAddress = FILE_START_ADDRESS;//定义一个全局变量用来控制每次保存文件的起始地址
MESSAGE_20	mes20;
ROOT_DIR	rootdir[10];
BYTE		DirPos = 0;

//初始化全局变量
void InitGobal( void )
{
	memset( &mes20, 0, sizeof(MESSAGE_20) );
	memset( rootdir, 0, 10 * sizeof(ROOT_DIR) );
	DirPos = 0;
//	FileCurrentAddress = FILE_START_ADDRESS;
//	ERASEAREA( FILE_START_ADDRESS );
//	ERASEAREA( CMC_START_ADDRESS );
}

PARSELECT	ParSelect = 
{
	{ 0, 0, 0, 0, 0	},
	0
};

// 省
struct LBOX_ITEM	province[] =
{	
	ICON_ENABLE,	UNUNDERLINE,	"江苏",
//	ICON_ENABLE,	UNUNDERLINE,	"安徽",
//	ICON_ENABLE,	UNUNDERLINE,	"浙江",
	ICON_END,		UNUNDERLINE,	NULL	
};
// 市
struct LBOX_ITEM	city[MAX_CITY_NUM];
// 县
struct LBOX_ITEM	county[MAX_COUNTY_NUM];
// 乡
struct LBOX_ITEM	countryside[MAX_COUNTRYSIDE_NUM];
// 村
struct LBOX_ITEM	village[MAX_VILLAGE_NUM];

// 图形参数
struct LBOX_ITEM	graph_par[] =
{	
	ICON_ENABLE,	UNUNDERLINE,	"1.1倍",
	ICON_ENABLE,	UNUNDERLINE,	"1.2倍",
	ICON_ENABLE,	UNUNDERLINE,	"1.3倍",
	ICON_ENABLE,	UNUNDERLINE,	"1.4倍",
	ICON_ENABLE,	UNUNDERLINE,	"1.5倍",
	ICON_ENABLE,	UNUNDERLINE,	"1.6倍",
	ICON_ENABLE,	UNUNDERLINE,	"1.7倍",
	ICON_ENABLE,	UNUNDERLINE,	"1.8倍",
	ICON_ENABLE,	UNUNDERLINE,	"1.9倍",
	ICON_END,		UNUNDERLINE,	NULL	
};

// 记录间隔时间
struct LBOX_ITEM	gap_par[] =
{	
	ICON_ENABLE,	UNUNDERLINE,	"0.1秒",
	ICON_ENABLE,	UNUNDERLINE,	"1秒",
	ICON_END,		UNUNDERLINE,	NULL,
};

// 连续记录时间
struct LBOX_ITEM	seq_par[] =
{	
	ICON_ENABLE,	UNUNDERLINE,	"10秒",
	ICON_ENABLE,	UNUNDERLINE,	"20秒",
	ICON_ENABLE,	UNUNDERLINE,	"30秒",
	ICON_END,		UNUNDERLINE,	NULL	
};

// 新旧地类
struct LBOX_ITEM	type_par[] =
{	
	ICON_ENABLE,	UNUNDERLINE,	"新三类",
	ICON_ENABLE,	UNUNDERLINE,	"旧八类",
	ICON_END,		UNUNDERLINE,	NULL	
};

static void StartMeasure( void );
static U16 OpenBackGroundMap( void );
static void PreviewBackGroundMap( void );
static void SetCode( void );
static void SetParameter( void );
static void ChangeSurvey( void );
static void Survey( void );
static U16	PropertyPopupWin( void );

void MeasureMain(void)
{
	MSG 	msg;
 	U32		mainwin;
	U32		hGC;
 	U8		quit=0;
	U32		bt_start, bt_help, bt_quit;
	U16		caption_x, caption_y;
	S8		*caption = "调查之星V2.0数据采集系统";
	U32		hbmp;
	
	const U16	title_x = 1, title_y = 1;
	const U16	title_w = PHY_LCD_W -2, title_h = 30;
	const U16	bt_w = 40, bt_h = 20, bt_y = 210;

	/* 创建主窗口 */
 	mainwin = CreateWindow(	WNDCLASS_WIN,
							NULL,
							WS_BORDER,
							0,0,
							PHY_LCD_W,PHY_LCD_H,
							0,
							0,
							NULL);
	
	
	bt_start = CreateWindow(WNDCLASS_BUTTON, "开始", WS_CHILD|BS_REGULAR, 10,bt_y,bt_w,bt_h,mainwin,0,NULL);
	bt_help = CreateWindow(WNDCLASS_BUTTON, "帮助", WS_CHILD|BS_REGULAR, 60,bt_y,bt_w,bt_h,mainwin,0,NULL);
	bt_quit = CreateWindow(WNDCLASS_BUTTON, "退出", WS_CHILD|BS_REGULAR, 110,bt_y,bt_w,bt_h,mainwin,0,NULL);

	/* 用户可以在此绘图,但该图形不会被保存 */
	hGC = GetGC();
	
	caption_x = AlignString( caption, 1, title_w, GPC_ALIGN_CENTER );
	caption_y = title_y + ( title_h - CHINESE_CHAR_HEIGHT )/2;
	ClearRec( hGC, GPC_GREEN, title_x, title_y, title_w, title_h, GPC_REPLACE_STYLE );
	TextOut( hGC, caption, caption_x, caption_y, NULL, GPC_BLACK, GPC_REPLACE_STYLE );

	hbmp = LoadBitmap( infor_icon,NULL );
	DisplayBMP( hGC, 6, 70, hbmp );

//	InitGobal();

	// 消息处理
	while(!quit)
	{
		ASIXGetMessage(&msg, NULL, 0, 0);
		switch(msg.message)
		{
			case WM_COMMAND:
				if( msg.lparam == bt_quit )
				{
					quit = 1;
					// 退出处理
					
				}
				else if( msg.lparam == bt_start )
				{
					// 启动
					StartMeasure();
				}
				else if( msg.lparam == bt_help )
				{
					// 帮助
				}
				break;
			case WM_REPAINT:
				ClearRec( hGC, GPC_GREEN, title_x, title_y, title_w, title_h, GPC_REPLACE_STYLE );
				TextOut( hGC, caption, caption_x, caption_y, NULL, GPC_BLACK, GPC_REPLACE_STYLE );
				DisplayBMP( hGC, 6, 70, hbmp );
				break;
		}
		DefWindowProc(msg.message, msg.lparam, msg.data, msg.wparam); 
	}

	FreeBitmap( hbmp );
	
	DestroyWindow( mainwin );

	EndofTask();
}

void StartMeasure( void )
{
	MSG 	msg;
 	U32		mainwin;
	U32		hGC;
 	U8		quit=0;
	U32		bt_open_map, bt_modify, bt_set_code, bt_set_par, bt_back;
	U16		caption_x, caption_y;
	S8		*caption = "调查之星V2.0数据采集系统";

	const U16	title_x = 1, title_y = 1;
	const U16	title_w = PHY_LCD_W -2, title_h = 30;
	const U16	bt_w = 80, bt_h = 20, bt_x = 40;

 	mainwin = CreateWindow(	WNDCLASS_WIN,
							NULL,
							WS_BORDER,
							0,0,
							PHY_LCD_W,PHY_LCD_H,
							0,
							0,
							NULL);
	
	
	bt_open_map = CreateWindow(WNDCLASS_BUTTON, "打开底图", WS_CHILD|BS_REGULAR, bt_x,80,bt_w,bt_h,mainwin,0,NULL);
	bt_modify = CreateWindow(WNDCLASS_BUTTON, "变更调查", WS_CHILD|BS_REGULAR, bt_x,100,bt_w,bt_h,mainwin,0,NULL);
	bt_set_code = CreateWindow(WNDCLASS_BUTTON, "设置代码", WS_CHILD|BS_REGULAR, bt_x,120,bt_w,bt_h,mainwin,0,NULL);
	bt_set_par = CreateWindow(WNDCLASS_BUTTON, "设置参数", WS_CHILD|BS_REGULAR, bt_x,140,bt_w,bt_h,mainwin,0,NULL);
	bt_back = CreateWindow(WNDCLASS_BUTTON, "返回", WS_CHILD|BS_REGULAR, bt_x,160,bt_w,bt_h,mainwin,0,NULL);

	hGC = GetGC();
	//初始化全局变量	
	memset( &mes20, 0, sizeof(MESSAGE_20) );
	memset( rootdir, 0, 10 * sizeof(ROOT_DIR) );
	DirPos = 0;

	caption_x = AlignString( caption, 1, title_w, GPC_ALIGN_CENTER );
	caption_y = title_y + ( title_h - CHINESE_CHAR_HEIGHT )/2;
	ClearRec( hGC, GPC_GREEN, title_x, title_y, title_w, title_h, GPC_REPLACE_STYLE );
	TextOut( hGC, caption, caption_x, caption_y, NULL, GPC_BLACK, GPC_REPLACE_STYLE );

	while(!quit)
	{
		ASIXGetMessage(&msg, NULL, 0, 0);
		switch(msg.message)
		{
			case WM_COMMAND:
				if( msg.lparam == bt_back )
				{
					quit = 1;
					// 退出处理
					
				}
				else if( msg.lparam == bt_open_map )
				{
					// 打开底图
					if( OpenBackGroundMap() == IDOK )
					{
						PreviewBackGroundMap();
					}
					else
					{
					}
				}
				else if( msg.lparam == bt_modify )
				{
					// 变更调查
					ChangeSurvey();
				}
				else if( msg.lparam == bt_set_code )
				{
					// 设置代码
					SetCode();
				}
				else if( msg.lparam == bt_set_par )
				{
					// 设置参数
					SetParameter();
				}
				break;
			case WM_REPAINT:
				ClearRec( hGC, GPC_GREEN, title_x, title_y, title_w, title_h, GPC_REPLACE_STYLE );
				TextOut( hGC, caption, caption_x, caption_y, NULL, GPC_BLACK, GPC_REPLACE_STYLE );
				break;
		}
		DefWindowProc(msg.message, msg.lparam, msg.data, msg.wparam); 
	}
	
	DestroyWindow( mainwin );
}

U16 OpenBackGroundMap( void )
{
	MSG 	msg;
 	U32		mainwin;
//	U32		hGC;
 	U8		quit=0;
	U16		result;
	U32		bt_ok, bt_cancel, bt_browser;
	U32		st_prompt, st_file_name, st_descript;

	const U16	dlg_x = 0, dlg_y = 40, dlg_w = PHY_LCD_W, dlg_h = PHY_LCD_H/2;
	const U16	bt_w = 40, bt_h = 20, bt_y = dlg_y + dlg_h - bt_h - 5;
	const U16	st_y = dlg_y + 25, st_h = 20;

	mainwin = CreateWindow(	WNDCLASS_WIN,
							"选择底图",
							WS_OVERLAPPEDWINDOW,
							dlg_x,dlg_y,
							dlg_w,dlg_h,
							0,
							0,
							NULL);
	
	
	bt_ok = CreateWindow(WNDCLASS_BUTTON, "确定", WS_CHILD|BS_REGULAR, 27,bt_y, bt_w, bt_h,mainwin,0,NULL);
	bt_cancel = CreateWindow(WNDCLASS_BUTTON, "取消", WS_CHILD|BS_REGULAR, 93,bt_y, bt_w, bt_h,mainwin,0,NULL);
//	bt_browser = CreateWindow(WNDCLASS_BUTTON, "浏览", WS_CHILD|BS_REGULAR, 115, st_y, bt_w, bt_h,mainwin,0,NULL);
	bt_browser = CreateWindow(WNDCLASS_BUTTON, "查找", WS_CHILD|BS_REGULAR, 115, st_y, bt_w, bt_h,mainwin,0,NULL);

	st_prompt = CreateWindow(WNDCLASS_STATIC, "文件名:", WS_CHILD|SS_TEXT, 5,st_y,48,st_h,mainwin,0, NULL);
	st_file_name = CreateWindow(WNDCLASS_STATIC, NULL, WS_CHILD|SS_TEXT, 55,st_y,48,st_h,mainwin,0, NULL);
	st_descript = CreateWindow(WNDCLASS_STATIC, "文件描述:", WS_CHILD|SS_TEXT, 5,(U16)(st_y+st_h+2),60,st_h,mainwin,0, NULL);

	while(!quit)
	{
		ASIXGetMessage(&msg, NULL, 0, 0);
		switch(msg.message)
		{
			case WM_COMMAND:
				if( msg.lparam == bt_ok )
				{
					// 确定
					quit = 1;
					result = IDOK;					
				}
				else if( msg.lparam == bt_cancel )
				{
					// 取消
					quit = 1;
					result = IDCANCEL;
				}
				else if( msg.lparam == bt_browser )
				{
					// 浏览
				}
				break;
			case WM_QUIT:
				quit = 1;
				result = IDCANCEL;
				break;
		}
		DefWindowProc(msg.message, msg.lparam, msg.data, msg.wparam); 
	}
	
	DestroyWindow( mainwin );

	return result;
}

void PreviewBackGroundMap( void )
{
	MSG 	msg;
 	U32		mainwin;
	U32		hGC;
 	U8		quit=0;
	U8		zoom_state = ZOOM_ZERO, move_state = STATE_STOP;
	U32		bt_back, bt_zoom_in, bt_zoom_out, bt_move;
//	U32		vsb, hsb;
	U32		hbmp;
	RECT	orireg, reginfo, oldreginfo;
	U32		area[4];
	RECT	regs[] = {
		{ 0, 0, 78, 108 },
		{ 79, 0, 157, 108 },
		{ 0, 109, 78, 217 },
		{ 79, 109, 157, 217 },
	};
	U32		i;
	WORD	xpos, ypos;
//	double	right, t1, test, temp;//for test
	BYTE	buffer[] = { 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };//for test

⌨️ 快捷键说明

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