小糊涂学symbian日记(10)(转)

接下来,我们谈谈开发的利器——仿真器
Overviw
-----------
仿真器提供了一个完整的运行环境,可以运行在PC端的Windows上,这种Symbian平台的执行被认为是WINS——一个单个进程的Windows平台。

有了仿真器我们可以充分的利用基于PC的开发环境,只在最后测试成功后才放在目标硬件(如手机上)。但如果你要编写低层代码,要直接访问设备硬件——如为一个物理设备编写程序,那就不能使用仿真器了。

仿真器是SymbianSDK的一部分,并且支持多种开发语言,包括C++,Java以及symbian的BASIC。

Emulator highlights
---------------------
仿真器包括很多可扩展的特性:
1、Function key mappings to emulate real device hardware condition not on a PC, e.g power off.

2、提供很好的调试功能,When a thread is panicked, the debugger provides comprehensive information about the panic.

3、可以使用初始化脚本来进行完全的配置,如指定屏幕尺寸以及灰度/颜色深度等。

4、Full integration with the Windows run time environment providing support for comms, Internet, and IrDA through the host PC.

[Language-specific development]
仿真器可以支持不同语言的开发,下面就做些讨论:
Java
---------
在设计时,程序的屏幕尺寸,外观外貌,以及所支持的UI特性都有不同,因此一般来说Java程序都是为一个特定目标设计的,尽管有些很简单的Java程序确实能运行在不同的平台上。

Java程序利用特定的SDK编写,可以从仿真器上直接拷贝到其他相关平台上,因为Java是设备无关的,可以不用再编译。

C++
-----
C++开发要面对很复杂的状况,如操作系统的进程线程都直接可被程序操作,仿真器是个单进程的环境,不象真正的目标环境那样是多进程多任务的, as each process is emulated by a Windows thread. There are, however, issues regarding launching some executables, such as console applications and servers. For more information, see the C++ build tools documentation.

[Using the PC keyboard, mouse, screen, and sound]
Overview
---------
仿真器允许开发者使用PC端的鼠标、屏幕和声音,就好象实际在硬件中操作一样方便。
下面就来介绍一下具体情况

Using the PC keyboard
-------------------------
PC上的键盘可以直接发送命令到仿真器上。
下面展现额外定义的特殊功能键
F1 如果按下可以最大化菜单列表,或是切换到下个菜单项。
Alt+F2 帮助键:按下可以得到当前环境下有关上下文的帮助
F8 记录按钮,第一次按下可以开始记录,再次按下就停止记录了

Using the screen and mouse
------------------------------
你可以使用鼠标在仿真器窗口上操作,来模拟Tap,这里鼠标上只有左键被支持。

Other special hardware features
----------------------------------
Special features typical of Symbian devices are also available when developing using the Emulator, through special key assignments.

*Removable media support
The Emulator can simulate two PC-Card devices using two files in the PC's temp directory. When the Emulator is started, each device is equivalent to an empty, unformatted, volume. An F32 client under WINS may access the removable media using the y: drive

F5 Open removable media door.
F4 Switch between two simulated devices while door open

Power off/shutdown
---------------------
仿真器能用下列键模拟出一些开关事件。此外,在一段时间后仿真器会模拟出自动关闭——仿真器程序最小化自己,在模拟开启后再恢复原状。

F10 电源关闭:这将最小化仿真器窗口,你可以通过恢复窗口来重新开启
F10 紧急关闭:如果目标设备在电池耗尽时可能会发生这样的时间——the machine hasn't enough power to function normally, so it falls into a state in which data on the machine is preserved while there is still power in the main and backup batteries but no user operations are allowed。
F11 Case close toggle:在仿真器窗口栏上显示“CASE CLOSED”,这时窗口变得不可用,再次按下F11就可以退出本状态。

Using sound
---------------
仿真器可以驱动PC的声音,只需要装上声卡即可。

[files and locations]
overview
----------
仿真器在pc的文件系统上映射出symbian的文件系统。这样的设备映射是在运行时发生的。symbian平台生成两个缺省的盘符:z:,在目标硬件上它映射rom,和c:,一个ram drive.

考虑到仿真器沙锅内不同程序的不同需求,the default location for the virtual drives vary depending on where the emulator itself is installed. this section describles the different cases.

you can also add further virtual drives, and reconfigure the standard drives to map to alternative locations.

virtual drives
----------------
有两个缺省的虚拟驱动,z:和c:,可以修改它们,并且可以加上新的驱动盘——如模拟一个cf卡做为一个可移动的盘处理。

有很多方法可以完成,但最好使用修改配置文件的方法。如果需要,you can also override the loation of the emulated c: drive using command-line.

注意对z:驱动的影射所指定的目录名必须为z

[emulator in c++ sdk]
dirves z: 和 c:都映射在下列子目录中
c: .epoc32winsc
z: .epoc32 eleasewinsurelz, or .epoc32 eleasewinsudebz

因此,如果是一个z:systemappshelloworldhelloworld.app应用程序,就映射到.epoc32 eleasewinsudebzsystemappshelloworldhelloworld.app(这是经过unicode debug模式编译的)

仿真器的配置文件在epoc32data中

note
where epocroot is set to point to the active epoc32 directory the drive letter must not be included.

[alternative emulator location]
在某些产品中,仿真器能在另一个位置epoc32 eleasewinsuild运行。

[location of executable programs]
gui应用程序必须放在z:systemapps目录中
this usual configuration is determined by the way that the emulator locates a library file that is to be loaded.in detail, this is as follows:
1、如果文件名包括一个drive,the filename is mapped using the appropriate virtual drive mapping
2、如果文件名没有指定设备盘符,then the virtual z: parent directory is searched
3、如果库没有找到,an attempt is made to find the library in the same way as on a target machine:i.e virtual drvies y: to a:, then z:systemlibs, are searched.可执行的应用程序,如text console applications,必须同那些能被静态连接的dll文件放在一个目录中。the usual approach is to build both exe and dll files to the z: parent directory. the location of emulated drives is calculated from the directory containing the exe.

[application data files]
application data files can be copied from a symbian machine, using epoc connect, onto a emulator virtual drive and opened from within the emulator. this is not true of application code which must be re-compiled to run on each platform.

installation .sis files can be installed on the emulator, using the application install program from the emulator's application launcher. the install program dispalys a list of .sis files to install. these should be located in .epoc32winsc. (在nokia手机里为.epoc32winsc okiainstalls)

applications are installed to .epoc32 eleasewinsudebzsystemapps for debug builds or .epoc32 eleasewinsurelzsystemapps for release builds.

以上资料非常有用,是充分利用模拟器的好帮手:)

[debug facilities]
overview
----------
仿真器是symbian程序设计的主要开发和调试环境。
in debug builds, the gui provides special key combinations for resource checking and redraw testing, which can help to trap memory leaks early in the development cycle. all debug keys are accessed using a ctrl+alt+shift prefix.

debugging keys
----------------
all gui applications may be exited using ctrl+e. additionally the window server provides ctrl+alt+shift+k kill the application with current keyboard focus.

*drawing:
t——可以显示一个任务列表,我们可以随意的切换或关闭任务,note that this is a debugging aid only.
r——重绘整个屏幕,来测试程序是否完成了适当的重绘。
f——enable window server auto-flush for all programs using the current control environment
g——disable window server auto-flush for all programs using the current control environment

*miscellaneous features
v——turn on or off verbose information messages
z——send keys a through j in fast sequence to application, to test its ability to handle fast repeated keys

*resource allocation
a——show number of heap cells allocated on user heap by the current prgram
b——show number of file server resource in use by the current program
c——show number of window server resources in use by the current program
p——show dialog for the heap failure tool: see below for details
q——turn off heap failure mode

the heap failure tool artificially generates resource allocation failures. it is used by developers to test that an application copes properly with such failures. the dialog options are as follows:

(1)app heap failure type: 为程序中的资源分配需求产生错误,random means that requests fail at a random rate. deterministic means that requests fail at the rate specified in the rate box.

(2)wserv heap failure type: generates failures for resource allocation requests from the symbian platform window server. the options are as for app heap failure.

(3)file failure tool: selecting this option generates failures for file access attempts.

*window server logging keys
e——start(enable) window server logging
d——stop(disable) window server logging
w——dumps the full window tree
h——dumps the contents of the window server's heap.

[Dial-up networking]
Overview
------------
可以通过PC上的外加设备来测试仿真器里的Internet应用程序。

Using Internet applications
-------------------------------
实际设备中,网络程序利用拨号网络来连接到ISP上,一个般的ISP设置都存储在控制面板里,电子邮件和WAP帐号也都是使用这里的信息来配置。

如果要在仿真器上运行Internet程序,你应该
1、有个带modem的PC机
2、一个ISP帐号
3、SMTP/POP3电子邮件帐号

注意,仿真器的网络工具不是为基于PC的LAN设计的,(哎,可惜了我们的宽带),因此你的机器应该有个猫来做这件事情:)

另外,你应该在仿真器的控制面板里设置好你的ISP配置,因为它是不能共享你的PC控制面板里的相关信息的:)另外你的邮箱也应该在相关email程序里设置好,以便接受和发送电子邮件。

symbian平台的串口设备一般是COMM::0和COMM::1,COMM:0映射的是PC的COM1端口,COMM::1映射了COM2。

[How to start the emulator]
仿真器有两个版本,一个是调式版本,一个是发布版本。分别定位在
release: .epoc32 eleasewinsurel

debug: .epoc32 eleasewinsudeb

可以直接去那双击epoc.exe来执行或者在命令行里键入epoc即可:)

Note
--------
文本控制程序是为了提供测试用的,如果你要运行这样的程序,那可以直接键入他们的exe文件名即可,如那个helloworld程序。

[How to close the emulator]
仿真器是一个windows程序,可以使用一般window关闭的方法,如Alt+F4,此外在调式模式下还可以使用Ctrl+alt+shift+E来关闭。

Note:
When the Emulator simulates a power-off, it minimises the Emulator window. Restoring the application simulates a power-on.

[How to emulate c: using a command-line option]
我们可以使用命令行选项来指定c:驱动器的定位,这是非常有用的,因为我们可以直接从CD-ROM上运行仿真器了-necessary because some apps try to create files in the emulated C: drive on startup.

如果你要覆盖缺省的设置以及配置文件中的_EPOC_DRIVE_C,那就按如下步骤来做:
1、开启命令行程序(进入dos)
2、键入如下的命令
epoc -T epoc -C

T, C 和的含义如下
-C——这个参数表明将要模拟成C驱动器的目录的路径。
-T——指明将要做为C驱动器的系统临时路径。

例如:
将d: est目录映射为虚拟C盘
epoc -Cd: est --

[How to emulate drives using the configuration file]
你也可以通过仿真器的配置文件(一般是epoc.ini)来修改virtual drive,你能替换z:和c:两个缺省驱动,或指定额外的驱动器,步骤是:

1、打开epoc.ini,(在.epoc32data)
2、Enter the keyword _EPOC_DRIVE_, followed immediately by the letter for the drive, a space, and the location on the PC file system it maps to. For example: _EPOC_DRIVE_
3、Save the file

Example
指定额外的虚拟驱动d:,将它映射到A盘,可以使用如下设置
_EPOC_DRIVE_D A:
This would allow the Emulator to treat your PC’s diskette drive as its own removable drive — which is usually mapped to d: on target machines.


[How to configure Emulator memory capacity]
The maximum total heap size can be set in the initialisaton file --- epoc.ini.这就允许开发者能模拟出不同内存容量的目标机器。按以下步骤做:
1、打开epoc.ini文件(在.epoc32data)
2、输入MegabytesOfFreeMemory,后面写上堆上的剩余内存M数,例如
MegabytesOfFreeMemory megabytes-of-free-memory
3、Save the file

注意
If the parameter is not specified, the amount of free memory defaults to 64MB.

If you wish to limit the heap, it is conventional to allow one megabyte for Symbian system use: for example, specify 7 to simulate a 8MB machine.

[How to configure the key map]
KeyMap关键字可以把设备上的真实键映射到PC键盘和facia bitmap上,这些也是在epoc.ini
步骤为
1、Open epoc.ini in a text editor. It can be found at .epoc32data.

2、Enter the keyword KeyMap, followed by the PC keyboard name and the Symbian key code. For example:

KeyMap PC-keyboard-name key-code

3、Save the file.

Example
KeyMap F1 EStdKeyMenu
注意,键代码定义在.epoc32includee32keys.h

[How to configure virual keys]
Virtual keys are represented as rectangular regions of the screen. The VirtualKey keyword allows developers to emulate target machine keys drawn on the fascia bitmap. The process is:
1、打开epoc.ini
2、Enter the keyword VirtualKey, followed by the key code the region is to produce, the shape of the region and the shape parameters. For example:

VirtualKey key-code shape shape-parameters

3、Save the file.

Example
VirtualKey EStdKeyMenu rect 50,60 30,20

注意
1、symbian键代码的名字定义在.epoc32includeE32keys.h
2、The syntax will allow different shapes, but the only shape supported is rect which specifies a rectangle
3、The additional parameters are the co-ordinateds for the top left of the rectangle and its width and height
4、A non rectangular key can be approximated with one or more rectangles, for example an elliptical key can be approximated with 3 or 5 rectangles.
5、The cursor will change into a hand when over a virtual key.

[How to specify aliases for device keys]
DefineKeyName可以为设备键代码定制别名,在epoc.ini中用如下命令即可
DefineKeyName alias key-code

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10294527/viewspace-126259/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/10294527/viewspace-126259/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值