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

📄 measure.c

📁 基于东南大学开发的SEP3203的ARM7中的所有驱动
💻 C
📖 第 1 页 / 共 5 页
字号:
											  point_info[i].point.y - orireg.top + map_y - 2,
											  point_info[i].point.x - orireg.left + map_x + 2,
											  point_info[i].point.y - orireg.top + map_y + 2,
											  GPC_SOLID_LINE, GPC_REPLACE_STYLE );
									DrawLine( hGC, GPC_BLACK, 
											  point_info[i].point.x - orireg.left + map_x + 2,
											  point_info[i].point.y - orireg.top + map_y - 2,
											  point_info[i].point.x - orireg.left + map_x - 2,
											  point_info[i].point.y - orireg.top + map_y + 2,
											  GPC_SOLID_LINE, GPC_REPLACE_STYLE );
									DrawLine( hGC, GPC_DARKGREY, 
											  point_info[i].point.x - orireg.left + map_x,
											  point_info[i].point.y - orireg.top + map_y,
											  point_info[i].relat[j].relat_point.x - orireg.left + map_x,
											  point_info[i].relat[j].relat_point.y - orireg.top + map_y,
											  GPC_SOLID_LINE, GPC_REPLACE_STYLE );
								}
							}
						}
					}
				}
				else if( msg.lparam == bt_move )
				{
					// 平移
					if( state != STATE_MOVING )
					{
						oldstate = state;
						state = STATE_MOVING;
						
						//Enable响应区
						for ( i = 0; i < 4; i++ )
						{
							ActiveAreaSuspend( area[i], AREA_REENABLE );
						}
					}
					else
					{
						state = oldstate;
						//Disable响应区
						for ( i = 0; i < 4; i++ )
						{
							ActiveAreaSuspend( area[i], AREA_SUSPEND );
						}
					}
				}
				else if( msg.lparam == bt_propert )
				{
					// 属性
					if( state != STATE_RECORD_PROPERTY )
					{
						oldstate = state;
						state = STATE_RECORD_PROPERTY;
						EnableWindow( bt_survey, FALSE );
						//Enable响应区
						for ( i = 0; i < 4; i++ )
						{
							ActiveAreaSuspend( area[i], AREA_REENABLE );
						}
					}
					else
					{
						state = oldstate;
						EnableWindow( bt_survey, TRUE );
						//Disable响应区
						for ( i = 0; i < 4; i++ )
						{
							ActiveAreaSuspend( area[i], AREA_SUSPEND );
						}
					}
				}
				else if( msg.lparam == bt_mode )
				{
					// 模式
					meas_mode = ! meas_mode;	// 切换模式
					if( meas_mode )	// 间断测量模式
						SetWindowText( bt_mode, "间断", NULL );
					else	// 连续测量模式
						SetWindowText( bt_mode, "连续", NULL );
				}
				else if( msg.lparam == bt_survey )
				{
					// 测量
					if( state != STATE_SURVEY )
					{
						state = STATE_SURVEY;
//						first_message = 1;//开始接收数据。
						latitude = 0;
						longitude = 0;
						mes20_num = 0;

						//启动读串口
//						get_tid( &tskID );
//						pmsg->lparam = tskID;
//						pmsg->wparam = SM_START;
//						SysSendMessage( MESSAGE_ID, pmsg );

						SetWindowText( bt_survey, "暂停", NULL );
						EnableWindow( bt_propert, FALSE );
						EnableWindow( bt_mode, FALSE );
					}
					else//暂停。不再读取串口
					{
						state = STATE_STOP;

//						get_tid( &tskID );
//						pmsg->lparam = tskID;
//						pmsg->wparam = SM_END;
//						SysSendMessage( MESSAGE_ID, pmsg );

						SetWindowText( bt_survey, "测量", NULL );
						EnableWindow( bt_propert, TRUE );
						EnableWindow( bt_mode, TRUE );

						//在图上记录点,并保存点
#ifdef DEBUG
						latitude = MAP_BOTTOM_LATITUDE + 0.0001;//for test
						longitude =  MAP_LEFT_LONGITUDE+ 0.0001;//for test
#else
						if ( mes20_num > 0 )//如果测量到不止一次20号电文,取平均
						{
							/*
							latitude = 1.0;//for test
							memcpy( charstar_num, &latitude, 8 );//for test
							memcpy( &latitude, test1, 8 );//for test
							memcpy( &latitude, test2, 8 );//for test
							*/
							//经度和纬度转换成角度为单位的,并取其平均值
							latitude = latitude * 180 / PI_VALUE / mes20_num;
							longitude = longitude * 180 / PI_VALUE / mes20_num;
							mes20_num = 0;//设为0,重新开始
						}
						else//否则取上一次20号电文的值
						{
							latitude = mes20.latitude;
							longitude = mes20.longitude;
						}
#endif
						if ( longitude > MAP_LEFT_LONGITUDE && longitude < MAP_RIGHT_LONGITUDE
							&& latitude > MAP_BOTTOM_LATITUDE && latitude < MAP_TOP_LATITUDE )
							//记录的点在地图范围内
						{
#ifdef DEBUG
							{
								POINT	position[] = {
									{ 230, 15 }, { 9, 123 }, { 98, 23 }, { 100, 50 }
								};
								
								if ( point_num < POINT_NUM_MAX )//数组未存满
								{
									for ( i = 0; i < 4; i++, point_num++ )
									{
										point_info[point_num].point.x = position[i].x;
										point_info[point_num].point.y = position[i].y;
										
										//点不在屏幕范围内
										if ( point_info[point_num].point.x < orireg.left
											 || point_info[point_num].point.x > orireg.right
											 || point_info[point_num].point.y < orireg.top
											 || point_info[point_num].point.y > orireg.bottom )
										{
											orireg.left = point_info[point_num].point.x - 78;
											orireg.right = point_info[point_num].point.x + 78;
											orireg.top = point_info[point_num].point.y - 74;
											orireg.bottom = point_info[point_num].point.y + 74;
											if ( orireg.left < 0 )
											{
												orireg.left = 0;
												orireg.right = 156;
											}
											if ( orireg.right > MAP_RIGHT )
											{
												orireg.right = MAP_RIGHT;
												orireg.left = MAP_RIGHT - 156;
											}
											if ( orireg.top < 0 )
											{
												orireg.top = 0;
												orireg.bottom = 148;
											}
											if ( orireg.bottom > MAP_BOTTOM )
											{
												orireg.bottom = MAP_BOTTOM;
												orireg.top = MAP_BOTTOM - 148;
											}
											SysDspCutBMP( hGC, map_x, map_y, hbmp, &orireg, 1 );
										}
										//在屏幕上画出点(此处用两条交叉点为测量点的斜线画出)
										two_line.left = map_x + position[i].x - orireg.left - 2;
										two_line.right = map_x + position[i].x - orireg.left + 2;
										two_line.top = map_y + position[i].y - orireg.top - 2;
										two_line.bottom = map_y + position[i].y - orireg.top + 2;
										DrawLine( hGC, GPC_BLACK, two_line.left, two_line.top, two_line.right,
												 two_line.bottom, GPC_SOLID_LINE, GPC_REPLACE_STYLE );
										DrawLine( hGC, GPC_BLACK, two_line.right, two_line.top, two_line.left,
												 two_line.bottom, GPC_SOLID_LINE, GPC_REPLACE_STYLE );
										//在此点处创建ActiveArea
										ActiveAreaEnable( &point_area[point_num],INPUT_AREA, CONTINUOUS_MODE, two_line.left, 
															two_line.top, two_line.right, two_line.bottom, NULL );
										//与前一点相连
										if ( point_num > 0 )
										{
											if ( position[i].x >= orireg.left &&
												 position[i].y >= orireg.top && 
												 point_info[point_num - 1].point.x >= orireg.left &&
												 point_info[point_num - 1].point.y >= orireg.top )
											{
												DrawLine( hGC, GPC_DARKGREY, 
													(map_x + position[i].x - orireg.left),
													(map_y + position[i].y - orireg.top), 
													(map_x + point_info[point_num - 1].point.x - orireg.left),
													(map_y + point_info[point_num - 1].point.y - orireg.top), 
													GPC_SOLID_LINE, GPC_REPLACE_STYLE );
											}
											//加入关联关系
											while( point_info[point_num - 1].relat[point_info[point_num - 1].cur_pos].relat_flag != NOTUSED )
												point_info[point_num - 1].cur_pos++;
											if ( point_info[point_num - 1].cur_pos < RELAT_POINT_NUM_MAX )
											{
												while( point_info[point_num].relat[point_info[point_num].cur_pos].relat_flag != NOTUSED )
													point_info[point_num].cur_pos++;
												if ( point_info[point_num].cur_pos < RELAT_POINT_NUM_MAX )
												{
													point_info[point_num - 1].relat[point_info[point_num - 1].cur_pos].relat_point.x = point_info[point_num].point.x;
													point_info[point_num - 1].relat[point_info[point_num - 1].cur_pos].relat_point.y = point_info[point_num].point.y;
													point_info[point_num - 1].relat[point_info[point_num - 1].cur_pos].relat_flag = BEUSED;
													point_info[point_num - 1].cur_pos++;
													point_info[point_num].relat[point_info[point_num].cur_pos].relat_point.x = point_info[point_num - 1].point.x;
													point_info[point_num].relat[point_info[point_num].cur_pos].relat_point.y = point_info[point_num - 1].point.y;
													point_info[point_num].relat[point_info[point_num].cur_pos].relat_flag = BEUSED;
													point_info[point_num].cur_pos++;
												}
											}
										}
									}
								}
							}
#else
							//将点的经纬度转换成在底图中的坐标,并将latitude和longitude清零
							xpos = (DWORD)(( MAP_RIGHT * ( longitude - MAP_LEFT_LONGITUDE ) ) / MAP_WIDTH_LONGITUDE);
							ypos = (DWORD)(( MAP_BOTTOM * ( latitude - MAP_BOTTOM_LATITUDE ) ) / MAP_HEIGHT_LATITUDE);
							latitude = 0;
							longitude = 0;
							//将底图中的坐标转换成屏幕坐标
							//记录的点在屏幕范围内,直接画出点;否则,将图移到以此点为中心的位置
//							if ( xpos >= orireg.left && xpos < orireg.right
//								 && ypos >= orireg.top && ypos < orireg.bottom )//判断点是否在屏幕范围内
							if ( xpos < orireg.left || xpos > orireg.right
								 || ypos < orireg.top || ypos > orireg.bottom )//点不在屏幕范围内
							{
								orireg.left = xpos - 78;
								orireg.right = xpos + 78;
								orireg.top = ypos - 74;
								orireg.bottom = ypos + 74;
								if ( orireg.left < 0 )
								{
									orireg.left = 0;
									orireg.right = 156;
								}
								if ( orireg.right > MAP_RIGHT )
								{
									orireg.right = MAP_RIGHT;
									orireg.left = MAP_RIGHT - 156;
								}
								if ( orireg.top < 0 )
								{
									orireg.top = 0;
									orireg.bottom = 148;
								}
								if ( orireg.bottom > MAP_BOTTOM )
								{
									orireg.bottom = MAP_BOTTOM;
									orireg.top = MAP_BOTTOM - 148;
								}
								//放大时未考虑
								SysDspCutBMP( hGC, map_x, map_y, hbmp, &orireg, 1 );
							}
							//保存进点信息的数组
							if ( point_num < POINT_NUM_MAX )//数组未存满
							{
								//将该点的信息存入文件
								point_file[point_num].latitude = latitude;
								point_file[point_num].longitude = longitude;
								point_file[point_num].endhour = mes20.hour;
								point_file[point_num].endminute = mes20.minute;
								point_file[point_num].endsecond = mes20.second;
								point_file[point_num].year = mes20.year;
								point_file[point_num].month = mes20.month;
								point_file[point_num].day = mes20.day;
								point_file[point_num].index = point_num;

								point_info[point_num].point.x = xpos;
								point_info[point_num].point.y = ypos;

								//在屏幕上画出点(此处用两条交叉点为测量点的斜线画出)
								two_line.left = map_x + xpos - orireg.left - 2;
								two_line.right = map_x + xpos - orireg.left + 2;
								two_line.top = map_y + ypos - orireg.top - 2;
								two_line.bottom = map_y + ypos - orireg.top + 2;
								DrawLine( hGC, GPC_BLACK, two_line.left, two_line.top, two_line.right,
										 two_line.bottom, GPC_SOLID_LINE, GPC_REPLACE_STYLE );
								DrawLine( hGC, GPC_BLACK, two_line.right, two_line.top, two_line.left,
										 two_line.bottom, GPC_SOLID_LINE, GPC_REPLACE_STYLE );
								
								//在此点处创建ActiveArea
								ActiveAreaEnable( &point_area[point_num],INPUT_AREA, CONTINUOUS_MODE, two_line.left, 
													two_line.top, two_line.right, two_line.bottom, NULL );
								//与前一点相连
								if ( point_num > 0 )
								{
									if ( xpos >= orireg.left &&
										 ypos >= orireg.top && 
										 point_info[point_num - 1].point.x >= orireg.left &&
										 point_info[point_num - 1].point.y >= orireg.top )
									{
										DrawLine( hGC, GPC_DARKGREY, 
											(map_x + xpos - orireg.left),
											(map_y + ypos - orireg.top), 
											(map_x + point_info[point_num - 1].point.x - orireg.left),
											(map_y + point_info[point_num - 1].point.y - orireg.top), 
											GPC_SOLID_LINE, GPC_REPLACE_STYLE );
									}
									//加入关联关系
									while( point_info[point_num - 1].relat[point_info[point_num - 1].cur_pos].relat_flag != NOTUSED )
										;
									if ( point_info[point_num - 1].cur_pos < RELAT_POINT_NUM_MAX )
									{
										while( point_info[point_num].relat[point_info[point_num].cur_pos++].relat_flag != NOTUSED )
											;
										if ( point_info[point_num].cur_pos < RELAT_POINT_NUM_MAX )
										{
											point_info[point_num - 1].relat[point_info[point_num - 1].cur_pos].relat_point.x = xpos;
											point_info[point_num - 1].relat[point_info[point_num - 1].cur_pos].relat_point.y = ypos;
											point_info[point_num - 1].relat[point_info[point_num - 1].cur_pos].relat_serial = point_num + 1;
											point_info[point_num - 1].relat[point_info[point_num - 1].cur_pos].relat_flag = BEUSED;
											point_info[point_num - 1].cur_pos++;
											point_info[point_num].relat[point_info[point_num].cur_pos].relat_point.x = point_info[point_num - 1].point.x;
											point_info[point_num].relat[point_info[point_num].cur_pos].relat_point.y = point_info[point_num - 1].point.y;
											point_info[point_num].relat[point_info[point_num].cur_pos].relat_serial = (point_num - 1) + 1;
											point_info[point_num].relat[point_info[point_num].cur_pos].relat_flag = BEUSED;
											point_info[point_num].cur_pos++;
										}
									}
								}
								point_num++;
							}
#endif
						}
					}
				}
				else if( msg.lparam == bt_save )
				{
					// 保存.pot
					for ( i = 0; i < point_num; i++ )
					{
						for ( j = 0; j < RELAT_POINT_NUM_MAX; j++ )
						{
							if ( point_info[i].relat[j].relat_flag == BEUSED )
							{
								point_file[i].connection[j] = point_info[i].relat[j].relat_serial;
							}
						}
					}

					rootdir[DirPos].file_type = POT_FILE;
					memcpy( rootdir[DirPos].file_name, "G32010200020020924.pot", 22 );
					rootdir[DirPos].file_address = FileCurrentAddress;
					rootdir[DirPos].file_length = point_num * sizeof(POINT_FILE);

					if ( cur_area + rootdir[DirPos].file_length > area + FLASH_LENGTH )
					{
//						WriteRecord( area[200], FileCurrentAddress, cur_area - (BYTE *)&area[200] );
//						FileCurrentAddress += (cur_area - (BYTE *)&area[200]);
						cur_area = (BYTE *)&area[200];
					}
					for ( i = 0; i < point_num; i++ )
						memcpy( cur_area, &point_file[i], sizeof(POINT_FILE) );
					cur_area += rootdir[DirPos].file_length;

					DirPos++;
				}
//				else if( msg.lparam == bt_rcv_data )
//				{
//					// 接收
//				}
				else if( msg.lparam == bt_hide )
				{
					// 隐藏
					disp_mode = !disp_mode;
					if( disp_mode )	// 底图隐藏模式
					{
						ClearRec( hGC, GPC_WHITE, map_x, map_y, PHY_LCD_W-2, PHY_LCD_H-90, GPC_REPLACE_STYLE );
						//重新画点
						for ( i = 0; i < point_num; i++ )
						{
							for ( j = 0; j < RELAT_POINT_NUM_MAX; j++ )
							{
								if ( point_info[i].relat[j].relat_flag == BEUSED )
								{

⌨️ 快捷键说明

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