Windows Mobile下GPS程序开发详解

需积分: 3 4 下载量 108 浏览量 更新于2024-09-20 收藏 42KB DOC 举报
"WM--GPS开发文档,讲解了在Windows Mobile平台上进行GPS程序开发的相关知识,包括GPS接收器的工作原理、开发的三种选择、GPSIntermediateDriver的使用,以及提供的示例代码和参考文章。" 在Windows Mobile平台下进行GPS程序开发是一项常见的任务,尤其对于需要定位服务的应用来说至关重要。本文档主要探讨了如何在该环境下开发一个测试GPS的程序,并分享了作者的开发经验和见解。 首先,GPS(全球定位系统)在移动设备中的应用是通过GPS接收器实现的,这个接收器负责捕获来自卫星的信号并将其转化为可处理的数据,通常以NMEA(导航电子消息协议)数据格式输出。NMEA数据包含了经纬度、速度、时间等位置信息。 开发GPS程序有三种主要途径: 1. 直接利用串行接口与GPS接收器通信,处理NMEA数据。 2. 使用GPSIntermediateDriver,这是Windows Mobile 5.0及以上版本内置的驱动,可以简化获取GPS数据的过程。 3. 引入第三方类库,如opennetcf,这些库提供了更高级别的API,便于开发者使用。 在WM5.0及更高版本中,GPSIntermediateDriver成为了推荐的选项,因为它提供了一个简便的接口来获取GPS信息。不过,它也有一些限制,可能需要开发者根据具体需求进行调整。 微软的Windows Mobile Software Development Kit (WMSDK)中包含了GPS Intermediate Driver的示例代码,位于"WindowsMobile6 SDK\Samples\PocketPC\CS\GPS"目录下。这些示例展示了如何使用GPS.cs、GpsDeviceState.cs、GpsPosition.cs和LocationChangedEventArgs.cs等类进行操作。例如,GPS.cs包含Open()、Close()和Connect()等方法,用于初始化和控制GPS连接;GpsDeviceState.cs用于获取GPS设备的状态;GpsPosition.cs则用于存储每次更新的GPS位置信息;而LocationChangedEventArgs.cs则用于处理位置变化的事件。 开发过程中,通过监听和处理LocationChangedEventArgs事件,可以实时获取到设备的位置变化。在Open()函数中创建GPS事件的句柄,以便在位置发生变化时触发相应的处理逻辑。 此外,开发者还可以参考相关的技术文章,如30Days of .NET [Windows Mobile Applications] - Day 03: GPS Compass 和 .NET Compact Framework下的GPS NMEA数据解析,这些资料能进一步加深对GPS编程的理解。 Windows Mobile平台上的GPS开发涉及硬件接口、协议解析、事件处理等多个方面,而GPSIntermediateDriver为开发者提供了一个相对简单的起点,结合微软提供的示例代码和外部资源,可以快速构建起GPS应用程序。

const ServerParam & SP = ServerParam::i(); const int self_min = wm.interceptTable()->selfReachCycle(); const int mate_min = wm.interceptTable()->teammateReachCycle(); int opp_min = wm.interceptTable()->opponentReachCycle(); const PlayerObject * opp_fastest = wm.interceptTable()->fastestOpponent(); if ( opp_fastest && opp_fastest->goalie() && wm.gameMode().isPenaltyKickMode() && opp_fastest->pos().dist( wm.ball().pos() ) >= 3.0 ) // MAGIC NUMBER { M_tackle_situation = false; M_opponent_ball = false; dlog.addText( Logger::TEAM, __FILE__":(update) penalty shootouts. not a tackle situation" ); return; } if ( opp_fastest && wm.gameMode().isPenaltyKickMode() && ! opp_fastest->goalie() ) { const AbstractPlayerObject * opponent_goalie = wm.getTheirGoalie(); if ( opponent_goalie ) { /* //yz del std::map< const AbstractPlayerObject*, int >::const_iterator player_map_it = wm.interceptTable()->playerMap().find( opponent_goalie ); if ( player_map_it != wm.interceptTable()->playerMap().end() ) { // considering only opponent goalie in penalty-kick mode opp_min = player_map_it->second; dlog.addText( Logger::TEAM, __FILE__":(update) replaced min_opp with goalie's reach cycle (%d).", opp_min ); } else { opp_min = 1000000; // practically canceling the fastest non-goalie opponent player dlog.addText( Logger::TEAM, __FILE__":%d: (update) set opp_min as 1000000 so as not to consider the fastest opponent.", __LINE__ ); } */ } else { opp_min = 1000000; // practically canceling the fastest non-goalie opponent player dlog.addText( Logger::TEAM, __FILE__":%d (update) set opp_min as 1000000 so as not to consider the fastest opponent.", __LINE__); } }

2023-07-25 上传