Introducing the Extensible Emulator
[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]
The extensible hardware emulator enables you to create a program in software that emulates your hardware.
What Is the Extensible Emulator?
The hardware emulator provided with the Microsoft .NET Micro Framework is a set of objects and tools that enables you to create a program that emulates your hardware in software. Specifically, the emulator consists of the following components:
An executable program — The emulator enables you to create a native Microsoft Windows application that runs managed programs targeted to the .NET Micro Framework common language runtime (CLR). It simulates the environment in which your managed applications run when the hardware is complete. To do so, you derive a custom class from the Emulator class provided by the framework. You then use your custom class in a standard Windows Forms application.
A collection of classes — To enable you to create your emulator components rapidly, the emulator offers a set of classes that perform common tasks relevant to creating emulator programs. In particular, you can use the emulator component base classes to create your own custom emulator components quickly and easily. This capability makes it possible for you to emulate many types of hardware that can be used with the .NET Micro Framework.
An XML-based configuration engine — All emulator components, whether provided with the .NET Micro Framework or created by you, must be properly configured. The configuration engine included with the emulator enables your emulator program to use data in XML files to configure and initialize all emulator components.
As this diagram shows, the emulator uses the configuration engine to configure the emulator components that mimic your hardware device. The emulator components can emulate such hardware as I2C, GPIO, SPI, and serial ports. You can also add your own custom emulator components. Once the emulator and the emulator components are properly configured and running, you can use them to develop and test your managed application.
What Peripheral Hardware Does the Emulator Support?
The extensible emulator supports the types of peripheral hardware most common to .NET Micro Framework platforms, including serial ports, I2C, and GPIO, among others. The emulator is specifically designed to be extensible so that you can make it support whatever hardware devices you are planning to use.
Extending the Emulator
To use the emulator, you create a version of it that simulates the peripheral hardware that you intend to use in your device. When you add emulation for a particular type of peripheral hardware, you can either use and extend existing emulator components or create new ones from scratch.
Configuring Existing Emulator Components
All emulator components must be initialized and configured to function properly. You store your emulator component configurations in XML files that the configuration engine reads and uses to perform the needed initializations and configurations. For details, see Configuring Emulator Components.
Creating Custom Emulator Components
When creating your own emulator components, you must build a managed driver for each component. The drivers you build must be based on existing communications components provided with the .NET Micro Framework. For example, one way to implement a component would be to write a managed driver on top of the framework's GPIO component.
Managed drivers can use a variety of methods to emulate communication with a device. For instance, if your device receives data over a serial port, you can write an emulator driver that uses the SerialPort class to send messages to the client application that is running in the emulator.
Building a User Interface
You can give your hardware emulator any user interface that you want. Typically, you create your user interface by using standard Windows Forms programming. However, your user interface does not have to be an exact mirror image of the device's interface. You can add to your emulator extra user interface elements that are strictly for debugging and informational purposes.
If your embedded device does not require a user interface, you do not need to have one in your emulator. You may choose to implement one for debugging purposes, but this is entirely optional. An alternative to building a user interface into your emulator would be to have your emulator log input and output to files. The emulator imposes no restrictions on what you do in this respect. You are free to implement the interface in any way you choose.