engineering college of aarhus microsoft windows mobilestaff.iha.dk/ma/files/windows mobile.pdf ·...

30
1 Dec. 2007 1 Microsoft Windows Mobile Engineering College of Aarhus 2 About speaker Name: Michael Alrøe, Associate Professor Email: [email protected] Education: Software Engineer Experience: Worked with software development since 1988 (Army, Space, Avionic, Hydrography). PC and embedded applications. Professions: Software Engineer Software Project Manager Vice President

Upload: nguyentuyen

Post on 24-May-2018

227 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Engineering College of Aarhus Microsoft Windows Mobilestaff.iha.dk/ma/Files/Windows Mobile.pdf · Windows CE Microsoft Windows XP Smart Personal Objects ... • Visual Basic .NET

1

Dec. 2007 1

Microsoft Windows Mobile

Engineering College of Aarhus

2

About speaker

• Name: Michael Alrøe, Associate Professor• Email: [email protected]

• Education:Software Engineer• Experience:

• Worked with software development since 1988 (Army, Space, Avionic, Hydrography).

• PC and embedded applications.

• Professions:• Software Engineer• Software Project Manager• Vice President

Page 2: Engineering College of Aarhus Microsoft Windows Mobilestaff.iha.dk/ma/Files/Windows Mobile.pdf · Windows CE Microsoft Windows XP Smart Personal Objects ... • Visual Basic .NET

2

3

We educate

• B.Eng. (Diplomingeniører)• Architectural Design• Bioprocess Eng. *• Civil Eng.• Electronics• Information Technology (IKT)• Mechanical Eng. • Business Eng. (+½ year)**

• *) in cooperation with Aarhus Technical College• **) in cooperation with Vitus Bering Denmark

4

With University of Aarhus we educate

• M.Eng. (Civilingeniører)• Architectural Engineering• Biomedical Engineering• Electro-Optics• Process Technology • Technical Information

Technology

• Applied Mechanics *

• * Being planned

Page 3: Engineering College of Aarhus Microsoft Windows Mobilestaff.iha.dk/ma/Files/Windows Mobile.pdf · Windows CE Microsoft Windows XP Smart Personal Objects ... • Visual Basic .NET

3

5

IHA in numbers

• 1500 students• 150 employees

• Turnover: 110 mill. Kr.

Planning moving to Katrinebjerg and harbour area!

Peter Bang & Svend Olufsen at IHA in 1924

6

”Hård kamp om at styre de mobile enheder”, Computerworld

• Spillere på markedet:• Symbian / Ovi• Windows Mobile• Blackberry (Resarch in Motion)• Apple OS X• Linux• Android ( Google m.fl.)!

• Markedet for PDA og SmartPhone smelter sammen!

http://www.computerworld.dk/art/39099?a=related&i=41599

Page 4: Engineering College of Aarhus Microsoft Windows Mobilestaff.iha.dk/ma/Files/Windows Mobile.pdf · Windows CE Microsoft Windows XP Smart Personal Objects ... • Visual Basic .NET

4

7Increasing Functionality

Medical Devices

Windows-based Terminals

Retail Point-of-Sale

Entertainment Devices

Microsoft .NET Technology

Windows XP Embedded

Windows CEMicrosoft

Windows XP

Smart PersonalObjects

Windows MobileSmartphone

Windows Automotive

MobileHandhelds

Portable Media CenterVoIP Phones

GatewaysSet-top Box

Tablet PC

Notebook PC

Windows MobilePocket PC Phone

Mobile and Embedded Devices

(Microsoft .NET Micro)

8

Windows CE vs. Windows Mobile

• Windows CE• An operating system• Sold via Platform Builder• OEMs have complete freedom

• Windows Mobile• A system based on Windows CE OS• Includes Microsoft-designed shell and apps• OEMs work closely with Microsoft

Page 5: Engineering College of Aarhus Microsoft Windows Mobilestaff.iha.dk/ma/Files/Windows Mobile.pdf · Windows CE Microsoft Windows XP Smart Personal Objects ... • Visual Basic .NET

5

9

• A preemptively multitasked operating system designed for “small” devices• Virtual memory, multithreaded• Completely 32-bit

• Uses a subset of the Win32 API• Win32 defined by Windows XP• + CE realtime extensions• Over 2,000 functions

What Is Windows CE?

10

Windows CE history (1/3)• Windows CE 1.0 (Nov96)

• New development from the ground up• Exclusively for handheld PC’s• Windows 95 look & feel• Grayscale• ½ million sold devices

• Windows CE 2.0 (Sep97)• Modularization• Diverse range of devices – ATM’s, cars, game consoles• Competitors: Psion• Network support• Color display support• ”Palm-sized PC” introduced

• Windows CE 3.0 (Jun00)• Pocket PC 2000 & Smartphone 2000 platform introduction• Compete with Palm Pilot’s• Redevelopment of user interface• Kernel rewritten• Real-time deterministic

Page 6: Engineering College of Aarhus Microsoft Windows Mobilestaff.iha.dk/ma/Files/Windows Mobile.pdf · Windows CE Microsoft Windows XP Smart Personal Objects ... • Visual Basic .NET

6

11

Windows CE history (2/3)

• Windows CE .NET 4.2 (Jun03)• Pocket PC 2003 & SmartPhone 2003 introduction• Memory enhancements• Wireless LAN & Bluetooth profiles• .NET Compact framework 1.0• SQL Server CE• VOIP• Shared Source (2mill. lines)• New license model• Many drivers...

• Windows CE 5.0 (Oct04)• Direct 3D Mobile graphics• Testing framework• Error reporting• .NET Compact framework 1.0 SP2• More shared source (2.5mill. lines)• Many drivers...

12

Windows CE history (3/3)

• Windows CE 6.0 (Nov 06)Fundamental enhancements to the Windows CE kernel:• Multitasking enhancements:

• Supports up to 32,000 processes with 2 GB of virtual memory per process

• OS processes are moved to kernel space• Addition of kernel mode drivers

(CE 5.0 only supported user mode drivers)• More shared source (3.9mill. lines)

Page 7: Engineering College of Aarhus Microsoft Windows Mobilestaff.iha.dk/ma/Files/Windows Mobile.pdf · Windows CE Microsoft Windows XP Smart Personal Objects ... • Visual Basic .NET

7

13

Windows CE Platforms

14

Core Operating System Architecture

Page 8: Engineering College of Aarhus Microsoft Windows Mobilestaff.iha.dk/ma/Files/Windows Mobile.pdf · Windows CE Microsoft Windows XP Smart Personal Objects ... • Visual Basic .NET

8

15

Kernel Module (CE 5.0)

• Hard real-time• Deterministic ISR latencies & jitter timings• Deterministic threading and OS API• ISR latency < 5us (Intel StrongARM SA-1110 @ 206MHz)

• Virtual Memory• 4GB Flat memory space• Virtual memory protection between processes• No paging file supported• 512MB maximum physical memory• Depend paging support (only page used code in process)

• Preemptive Multitasking• Supports a maximum of 32 separate processes• Each process supports an unlimited number of threads (470)• 256 thread priority levels• Round-robin at the same priority level• Thread quantum level (time-slice) control• Priority boosting only to correct priority inversion

• Multiple processor family support• ARM, MIPS, SuperH, x86• 200+ different processors supported

16

Virtual Memory Map

Page 9: Engineering College of Aarhus Microsoft Windows Mobilestaff.iha.dk/ma/Files/Windows Mobile.pdf · Windows CE Microsoft Windows XP Smart Personal Objects ... • Visual Basic .NET

9

17

Application Development

18

.NET Compact Framework

Page 10: Engineering College of Aarhus Microsoft Windows Mobilestaff.iha.dk/ma/Files/Windows Mobile.pdf · Windows CE Microsoft Windows XP Smart Personal Objects ... • Visual Basic .NET

10

19

What is Compact FrameworkDesign Goals

Target mobile and embedded devices

• Portable subset of .NET Framework• No new ‘compact’ namespaces• Visual Basic .NET & C# compiler support

• Not suited to real-time programming!

20

OS (Windows) (COM+ services)

Common Language Runtime

Base Class Library

Overliggende frameworks: Data, …

ASP.NETWeb Forms Web ServicesWeb Forms Web Services

Mobile Internet ToolkitMobile Internet ToolkitWindows Forms

Common Language Specification

VB C++ C#

Visual S

tudio

JScript …

Framework: languages & tools

Page 11: Engineering College of Aarhus Microsoft Windows Mobilestaff.iha.dk/ma/Files/Windows Mobile.pdf · Windows CE Microsoft Windows XP Smart Personal Objects ... • Visual Basic .NET

11

21

Common Language Runtime

Class Loader

IL to NativeCompilers

CodeManager

GarbageCollector

Security Engine Debug Engine

Type Checker Exception Manager

Thread Support COM Marshaller

Base Class Library Support

22

Execution model

VBVB C#C# ...... ScriptScript

IL CodeIL CodeNativeNativeCodeCode

JITJITCompilerCompiler

NativeNativeCodeCode

Common Language Runtime

Page 12: Engineering College of Aarhus Microsoft Windows Mobilestaff.iha.dk/ma/Files/Windows Mobile.pdf · Windows CE Microsoft Windows XP Smart Personal Objects ... • Visual Basic .NET

12

Common Language Runtime (CLR) Common Features with .NET

• Verifiable type safe execution• No uninitialized variables, unsafe casts, bad array

indexing, bad pointer math• Garbage Collection

• Means no ref-counting and no leaks• Not generational in .NET CF!

• JIT compilation• Error handling with exceptions• Common type system

• Call, inherit, and source-level debug across different languages

Common Language Runtime (CLR) Differences

• COM Interop• Good support for calling native DLLs• Support for calling COM objects• No support for ActiveX object

• No Install-time JIT (nGen)• No Remoting

• Client web services is fully supported!• No Generic Serialization

• Datasets can be serialized to XML!• Subsets of other areas of functionality

Page 13: Engineering College of Aarhus Microsoft Windows Mobilestaff.iha.dk/ma/Files/Windows Mobile.pdf · Windows CE Microsoft Windows XP Smart Personal Objects ... • Visual Basic .NET

13

25

Framework Size

• Framework size (RAM or ROM)• ~1.5 MB+

• Running RAM needs• 1 MB+ (depends on app)

• Typical application sizes• 5 - 100 KB• Apps often smaller due to use of platform features in the

framework

26

Differences between .NET compact Framework Version 1.0 and Version 2.0

@ Windows Mobile 2003, 400 MHz XScale

Page 14: Engineering College of Aarhus Microsoft Windows Mobilestaff.iha.dk/ma/Files/Windows Mobile.pdf · Windows CE Microsoft Windows XP Smart Personal Objects ... • Visual Basic .NET

14

27

Development tools and SDK’s

• Microsoft Visual Studio 2005/2008• ActiveSync

• SDKs:• Windows Mobile 2003 SDKs

• Smartphone 2003 SDK• Pocket PC 2003 SDK

• Windows Mobile 5.0 SDKs• Windows Mobile 5.0 SDK for Pocket PC• Windows Mobile 5.0 SDK for Smartphone

• Windows Mobile 6.0 SDKs• Windows Mobile 6.0 Standard SDK• Windows Mobile 6.0 Professional SDK

• .NET Compact Framework 1.0 SDK• .NET Compact Framework 2.0 SDK

Note:• Windows Mobile 6 Standard (Smartphones!)• Windows Mobile 6 Classic (Pocket PCs /PDA!)• Windows Mobile 6 Professional (Pocket PC Phone Edition!)

28

Choosing the .NET Compact Framework version

Page 15: Engineering College of Aarhus Microsoft Windows Mobilestaff.iha.dk/ma/Files/Windows Mobile.pdf · Windows CE Microsoft Windows XP Smart Personal Objects ... • Visual Basic .NET

15

29

Choosing the .NET Compact Framework versionWindows Mobile 5.0

30

Choosing the .NET Compact Framework versionWindows Mobile 6

Page 16: Engineering College of Aarhus Microsoft Windows Mobilestaff.iha.dk/ma/Files/Windows Mobile.pdf · Windows CE Microsoft Windows XP Smart Personal Objects ... • Visual Basic .NET

16

31

Building a Microsoft Windows Forms GUI

32

Building a Microsoft Windows Forms GUI

• Demo!

Page 17: Engineering College of Aarhus Microsoft Windows Mobilestaff.iha.dk/ma/Files/Windows Mobile.pdf · Windows CE Microsoft Windows XP Smart Personal Objects ... • Visual Basic .NET

17

33

Community Resources

• UI guidelines for the Pocket PC and Smartphone platforms

http://msdn.microsoft.com/mobility/windowsmobile/partners/mobile2market/participatevendors.aspx

• Information on Controlshttp://msdn2.microsoft.com/en-us/library/hf2k718k.aspx

34

Threading

Page 18: Engineering College of Aarhus Microsoft Windows Mobilestaff.iha.dk/ma/Files/Windows Mobile.pdf · Windows CE Microsoft Windows XP Smart Personal Objects ... • Visual Basic .NET

18

35

Threads

• Windows CE is a fully multitasking and multithreading operating system with a preemptive scheduler.

• Thread context switch typically each 25/100 ms• Round-Robin for threads at equal priority level• Each process has a primary thread• Each thread has its own stack• All threads within a process share the process heap• Threads are scheduled by their priority, independent of

the owning process • Namespace: System.Threading

• Wraps Win32 threading primitives

36

Threads: Control.Invoke

• “Touch UI elements Only from the Thread That Created Them”• In practical terms only the main thread may “touch” controls

• The solution is invocation (Invoke or BeginInvokemethods)

• Each control holds a InvokeRequired property, which is safe to call from any thread

• Note that putting a MessageBox on the screen is the only UI operation a worker thread is allowed to make!

Page 19: Engineering College of Aarhus Microsoft Windows Mobilestaff.iha.dk/ma/Files/Windows Mobile.pdf · Windows CE Microsoft Windows XP Smart Personal Objects ... • Visual Basic .NET

19

37

ThreadPool

• ThreadPool is a pool of threads• The thread pool is generated at startup.• Typically performance gain (both at create and destroy!) • The thread pool has a default size of 25 worker threads.• The maximum number of threads in the thread pool can

be changed using the SetMaxThreads method (max 1000 for Windows Mobile!)

• Each thread uses the default stack size and runs at the default priority.

• IsBackground = true!• Single line : ThreadPool.QueueUserWorkItem(…)

38

Thread Synchronizing

• Synchronization• Monitor class

• Monitor.Enter(obj) / Monitor.TryEnter (obj, ms)• Monitor.Exit(obj)• Lock(obj)

• Mutex class

(Interprocess communication is not supported for Mutex class!)

Page 20: Engineering College of Aarhus Microsoft Windows Mobilestaff.iha.dk/ma/Files/Windows Mobile.pdf · Windows CE Microsoft Windows XP Smart Personal Objects ... • Visual Basic .NET

20

39

Priority Levels (0 to 255)

Windows CE:• Real-time range (0 – 96)• Driver IST range (97 – 152)• Below real-time range (153 – 247)• Application priority levels (248 – 255)

.NET CF:• Highest• Above Normal• Normal (252!)• BelowNormal• Lowest

40

Threading

• Demo!

Page 21: Engineering College of Aarhus Microsoft Windows Mobilestaff.iha.dk/ma/Files/Windows Mobile.pdf · Windows CE Microsoft Windows XP Smart Personal Objects ... • Visual Basic .NET

21

41

Networking

42

Networking

• Complications of Networking and Mobile Devices• Web Services• System.Net• IrDA and BlueTooth• Serial Ports• System.Messaging

Page 22: Engineering College of Aarhus Microsoft Windows Mobilestaff.iha.dk/ma/Files/Windows Mobile.pdf · Windows CE Microsoft Windows XP Smart Personal Objects ... • Visual Basic .NET

22

43

Complications of Networking and Mobile Devices

• Networking can be more difficult than for a static computer• Intermittent network availability• Cost based on volume of network traffic• No binary serialization (3.thrd part: CompactFormatter!)

• Alternatively use ASCII (half size of Unicode!)• Handle network connection drops during an operation• Only send data when a specific network connection is

active• Initiating a connection from the server to a device can

be made difficult by changing IP addresses (third-party middleware is available!).

44

Web Services

• Self-describing, platform independent remote method calls

• Browse and generate code with Visual Studio!• Makes calling a Web service just the same as calling

a local method• Issues:

• No current network available• Low-bandwidth connections• Reducing volume of data transferred due to charge of

network traffic

Page 23: Engineering College of Aarhus Microsoft Windows Mobilestaff.iha.dk/ma/Files/Windows Mobile.pdf · Windows CE Microsoft Windows XP Smart Personal Objects ... • Visual Basic .NET

23

45

System.Net

• System.Net holds networking functionality• WebRequest classes for HTTP/HTTPS communication

• No FTP support!• Socket class for lower level two-way communication

• Supports UDP and TCP/IP• Additional support for IrDA

46

IrDA and BlueTooth

• IrDA

• Fundamentally working the same way as sockets programming

• IrDAClient and IrDAListener classes

• Complications of Networking and Mobile Devices

• BlueTooth• No built-in support in the .NET CF

• BlueTooth stack might vary

• Typically either a Microsoft stack or a Widcomm stack

• Microsoft provides a native API (C++)

• Widcom provides a native API/SDK (price?)• Third party libraries for C#/.NET CF programming

Page 24: Engineering College of Aarhus Microsoft Windows Mobilestaff.iha.dk/ma/Files/Windows Mobile.pdf · Windows CE Microsoft Windows XP Smart Personal Objects ... • Visual Basic .NET

24

47

Serial Ports

• System.IO.Ports.SerialPort in .NET Compact Framwork 2.0 supports direct access to serial ports

• Key properties:• PortName (“COM1”)• BaudRate• StopBits• NewLine

• Virtual Serial Ports• Might be used for mapping BlueTooth devices (i.e. GPS

devices)

48

System.Messaging

• New set of functionality in .NET CF 2.0• Wraps Microsoft Message Queuing (MSMQ)• Provides loosely coupled messaging between

applications and different computers.• Is an optional component – installation required!• Supports only basic transaction – no multimessage

transaction• Support XmlMessageFormatter – custom formatters

possible (ie. binary!)

Page 25: Engineering College of Aarhus Microsoft Windows Mobilestaff.iha.dk/ma/Files/Windows Mobile.pdf · Windows CE Microsoft Windows XP Smart Personal Objects ... • Visual Basic .NET

25

49

Networking

• Demo!

50

Community Resources

Bluetooth:• 32Feet

http://www.32feet.net

• Fransonhttp://www.franson.com

• Windows Embedded Source Tools for Bluetooth Technology

http://msdn2.microsoft.com/en-us/embedded/aa714533.aspx

Page 26: Engineering College of Aarhus Microsoft Windows Mobilestaff.iha.dk/ma/Files/Windows Mobile.pdf · Windows CE Microsoft Windows XP Smart Personal Objects ... • Visual Basic .NET

26

51

The Windows Mobile API

52

Windows MobileAccessing Platform Features from .NET CF

• Windows Mobile 5.0 brought about a change• Platform features exposed as managed classes and native

APIs

• Many new features much more high-level than in the past• Encapsulate complete behaviors and forms

Page 27: Engineering College of Aarhus Microsoft Windows Mobilestaff.iha.dk/ma/Files/Windows Mobile.pdf · Windows CE Microsoft Windows XP Smart Personal Objects ... • Visual Basic .NET

27

53

Pocket Outlook Classes

• Pocket Outlook Object Model (POOM)• Managed API provided with Windows Mobile 5.0• Simplifies Outlook Mobile programming

• Exposes data as collection of folders

• Provides .NET CF types for POOM object types

Class Description

OutlookSession Represents the Pocket Outlook application exposing properties for Appointments, Contacts,

Tasks, in addition to e-mail and SMS accounts.

AppointmentRepresents a scheduled block of time. Includes properties identifying the appointment

details and how the appointment reminder should be signaled. Provides events applications

can handle to be notified of changes to an appointment.

Contact Represents an information record for an individual or organization. Includes more then 60

distinct properties for tracking contact information with corresponding events, making it

easy for applications to track changes that the user or applications makes to contact data.

Task Represents an actionable to-do item. Includes a variety of properties identifying task details,

including progress and how the task reminder should be signaled. Provides events

applications can handle to be notified of changes to a task.

54

MessagingComposing and Manipulating

• Classes for composing and manipulating messages• SMSMessage

• Allows you to compose & manipulate SMS messages• Properties exposed for To, body text, etc.

• EmailMessage• Allows you to compose & manipulate SMS messages• Properties To, CC, Subject, body text, attachments, etc.

Page 28: Engineering College of Aarhus Microsoft Windows Mobilestaff.iha.dk/ma/Files/Windows Mobile.pdf · Windows CE Microsoft Windows XP Smart Personal Objects ... • Visual Basic .NET

28

55

MessagingReceiving Messages

• MessageInterceptor class• Raises an event when a qualifying message arrives

• Message is contained in the notification• Can notify your application & allow default behavior

to continue• Can notify your application & delete message

• Can optionally start the app that requested notification

• MessageCondition class• Allows you to specify the criteria for a qualifying message

56

System StateState and Notifications Broker

• State and Notifications Broker (SNB)• Makes system state information available• Can query for current state• Can request notification of a change in a particular state• Exposes most events of interest

• System events• User events• Extensive information on network state

• Windows Mobile 5.0 exposes more then 100 state values• Windows Mobile 6 exposes approximately 150 state values

Page 29: Engineering College of Aarhus Microsoft Windows Mobilestaff.iha.dk/ma/Files/Windows Mobile.pdf · Windows CE Microsoft Windows XP Smart Personal Objects ... • Visual Basic .NET

29

57

Pocket Outlook Object Model (POOM)

• Demo!

58

Fremtiden tilhører ”enhederne”...

Page 30: Engineering College of Aarhus Microsoft Windows Mobilestaff.iha.dk/ma/Files/Windows Mobile.pdf · Windows CE Microsoft Windows XP Smart Personal Objects ... • Visual Basic .NET

30

59

Community Resources

• Tools: Windows Mobile Developer Centerhttp://msdn2.microsoft.com/en-us/windowsmobile/bb264337.aspx

• MSDN• MSDN Newsgroups• Microsoft patterns & practices Mobile

Application Block (Microsoft open source!)http://www.codeplex.com/smartclient

• OpenNETCF Smart Device Framework- Started by MVPs- Version 1.4 source is free!

http://www.opennetcf.org

……….and many more!