More servicesWindows Live
HomeHotmailSpacesOneCare
 
MSN
Sign in
 
 
Spaces home  Beatle's BlogPhotosProfileFriendsMore Tools Explore the Spaces community
There are no photo albums.
Blogs/WebSites of past ACES team members

Beatle's Blog

July 21

In-Process DLL SimConnect Client Sample

Hey All,

In my last blog post, I mentioned we had a new download area with some new samples and that I had a couple of samples that needed some minor cleaning up and then they would be posted there.  Well one of those has been posted there, the In-Process DLL SimConnect Client sample (actually, it was posted almost 2 months ago, I'm just now getting around to blogging about it :-> ).

I wrote this sample because I noticed we didn't have any in-proc DLL samples in the SDK. 

First off, what does that mean, In-Process?  It means that the DLL SimConnect client is loaded within the ESP/FSX process space instead of within its own process space like an external .EXE based SimConnect client.  This has some good points and some bad points (depending on what you are trying to do). 

The good points are that you register a callback function once, right after the SimConnect_Open call, and that callback will get called directly by the Server Side SimConnect code when messages are available for your client.  This bypasses all of the networking layer (ie no TCP/IP, no Named Pipes, you get a direct function call into your code from the Sim side code).  This also means you don't have to run your own HWND based message pump, you don't need to use a background thread with an Event Handle, you don't need to use a timer based query scheme, etc - in other words, it makes life much easier.

The bad points are that you can't really do standard windows based UI this way - well, you can but its not guaranteed to work (DirectX and GDI get into fights with each other sometimes, especially in full screen mode) unless you put the Sim into Dialog Mode first.  You can still add menu items, use the SimConnect_Text function to display both scrolling text and simple "select one of the below" style dialog boxes.  Another bad point, in some folks eyes anyway, is you can only use C++ to write an In-Proc DLL client.  Also, since your client is running within the ESP/FSX process space, if your client code goes nuts (causes a fault of some sort, or goes into an infinite loop) you can take down the entire Sim.

So, if you want to write a client with lots of UI and/or you want to use managed code, stick with an out-of-proc EXE style client, but if you can live within the above restrictions, then an in-proc DLL style client may be the way to go.

Things that would make a good in-proc DLL style client:

  • adding Custom Action support for missions
  • transferring data between the Sim and some external app
  • interfacing custom hardware to the Sim

 

What the sample does

The sample is fairly simple in what it does.  It adds a couple of menu items to the AddOn menu (Show Weather Menu and Show Time Menu).  Selecting one of these menu items will use SimConnect_Text to show a "Select on of these options" dialogs, the weather dialog allows you to query the dialog from either the current location or from SeaTac, the time dialog lets you set the time to either 12:00 Local or 00:00 Zulu.  Selecting one of the weather reporting options will query for the Metar string at the requested location, and then use SimConnect_Text to display the Metar string as a scrolling message across the top of the screen.  Selecting one of the time set options will, surprisingly enough, set the time accordingly :->

Hopefully a few of you will find the sample useful.  If you do, or you have any questions about it, drop by the Microsoft ESP Forum to discuss it/ask questions.

Tim "Beatle" Gregson

May 13

New Microsoft ESP OnLine Resources

Hey All,

I'm a little late with this news, but Todd, our Developer Evangelist, has been hard at work getting lots of new resources for Microsoft ESP developers online.  We now have our own MSDN Microsoft ESP Developer Center, which includes:

and if you have an MSDN subscription, you can also download the ESP runtime and SDK from the Subscriber's Download area (I'd provide a link, but my subscription expired and my renewal hasn't gone through yet :-> ).

Over time we'll be adding additional content to the ESP Developer Center (I've got a couple of samples I need to get cleaned up a little so Todd can post them), so check back often (the team blog and forum area both have RSS feeds available).

I want to draw a little extra attention to the SDK docs being online.  For those of you who bought the Standard version of FSX or those who just don't want to install the whole SDK, you can now lookup the format and options available in the various configuration files (aircraft.cfg, panel.cfg, etc) online.  If you are trying to find the Microsoft ESP section within the MSDN online docs, just remember that we are under the "Servers and Enterprise Developement" top-level section :->

Tim

February 23

ESP in the news

I've got another round of ESP news articles for ya.

Business Week

This one is a little old, from back in December, but if you haven't seen it yet, take a look:

Business Week ESP Article

I particularly like the part about Northrup Grumman using ESP to create a prototype/Proof of Concept on page 2 of the article, since I got to spend a week up in Reston, VA working with this team to pull this off :->  I doubt every Service Provider who uses ESP is going to get a week of my time to help them out, but it was a lot of fun and they were a great group of developers to work with.

Training & Simulation Journal

TSJOnline.com has 2 articles on ESP:

First TSJOnline article - this one mentions Lockheed Martin and FlightSafety have signed up as partners.

Second TSJOnline article - this one is a more general article on Microsoft entering the Visual Sim market.

Games Developer Conference / Serious Games Summit

This next one is an article on Gamasutra about the GDC / SGS last week in San Francisco and the Microsoft ESP presence there - you even get to see a picture of our studio head, Shawn :->

GDC / SGS coverage

Microsoft MSDN

For those of you with a Microsoft MSDN account, you can now download the ISOs for Microsoft ESP for testing purposes from the MSDN Subscriber downloads section.

Microsoft ESP Home Page

Our home page has been updated with a short demo video, click and enjoy :->

 

That's all for now, till next time

Tim "Beatle" Gregson

February 11

SimConnect and WPF

I've noticed some folks having problems using SimConnect with WPF based apps because there's no easily accessed hWnd and no easily overridden DefWndProc.  Here's a solution that works around those problems and is also usable in WinForms apps if you like.

In the existing managed samples provided in the SDK, the 2nd param of the new SimConnect(...) line is the hWnd and the 3rd param is the WM_Xxx based message to send to the main window.  For this solution, we will instead pass 0 for both of those params and pass an AutoReset EventWaitHandle object as the 4th param to that call.  Then we will create a background thread that waits for this event to fire and then calls the ReceiveMessage function to handle data received from SimConnect.

Here's a couple of code snippets:

This first snippet shows the data used:

// data
Microsoft.ESP.SimConnect.SimConnect sc;
System.Threading.EventWaitHandle scReady = new System.Threading.EventWaitHandle(false, System.Threading.EventResetMode.AutoReset);
System.Threading.Thread bgThread = null;
public delegate void MyDelegate();

And this next snippet shows the code that uses these data items:

// code
private void ConnectToSimConnect(void)
{
    sc = new Microsoft.ESP.SimConnect.SimConnect("VE_SC_WPF", (IntPtr)0, 0, scReady, 0);
 
    bgThread = new System.Threading.Thread(new System.Threading.ThreadStart(scMessageThread));
    bgThread.IsBackground = true;
    bgThread.Start();
}
 
private void scMessageThread()
{
    while (true)
    {
        scReady.WaitOne();
        this.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new MyDelegate(scMessageProcess));
    }
}
 
private void scMessageProcess()
{
    sc.ReceiveMessage();
}

With the code above, all of the OnRecvXxx callbacks will still happen on the UI thread context, meaning the rest of your code can stay the same as it was when using the hWnd and WM_Xxx message with an overridden DefWndProc. 

If you would prefer that the message handling and the OnRecvXxx callbacks occur on the background thread context, you can do that with this code snippet instead:

// code
private void ConnectToSimConnect(void)
{
    sc = new Microsoft.ESP.SimConnect.SimConnect("VE_SC_WPF", (IntPtr)0, 0, scReady, 0);
 
    bgThread = new System.Threading.Thread(new System.Threading.ThreadStart(scMessageThread));
    bgThread.IsBackground = true;
    bgThread.Start();
}
 
private void scMessageThread()
{
    while (true)
    {
        scReady.WaitOne();
        sc.ReceiveMessage();
    }
}

Doing things this way will require you to handle any thread synchronization that might be required to access any UI elements within each OnRecvXxx callback, but if you aren't accessing UI elements much in your callbacks, then the 2nd way might be more efficient overall, but will require more work on your part to insure things happen on the correct thread.

I've been playing around with WPF for the last couple of weeks and its a lot of fun and can do some really cool things (repeat after me, DataTemplates are your friend :-> ).  Hopefully the above code snippets will let folks out there write some cool WPF based SimConnect clients.

Tim "Beatle" Gregson

November 29

Microsoft ESP Buzz

We've posted case studies from a couple of our launch partners on the ESP Website.  They are located on the Resources page.

Adacel MaxSim Flight Trainer

The first one, from Adacel, is a .DOC file describing their MaxSim Flight Trainer program.  I'm going to quote the Executive Overview paragraph here, because it really says it all about what ESP is, but do go read the entire Case Study Document.

Adacel wanted to be first to market with an integrated flight and air traffic control (ATC) simulation solution for flight schools not served by multi-million dollar offerings. It created the MaxSim Flight Trainer based on its own speech-driven Air Traffic Control simulation technology and the Microsoft® ESP™ visual simulation platform. Adacel created the integrated solution in just three weeks with a single developer, and produced a rich, immersive flight simulation experience that it estimates would have taken millions of dollars and months of work to create from scratch. The extensive after-market of add-ons for Microsoft ESP helps to ensure that Adacel and its customers can easily extend the simulation. And the low-cost Windows® hardware on which it runs helps to ensure that the MaxSim Flight Trainer is more cost-effective, scalable, and transportable than traditional, proprietary offerings.

Acron Capability Engineering

The second one, from Acron, is a Windows Media Video file produced by Acron describing the ways they are using Microsoft ESP.  Here's a link to some news/press releases from Acron, including information about a couple of support products they will be offering including a 3D modeling program and a HLA interface for Microsoft ESP.

Northrop Grumman

This one isn't on our Resources page, but Northrop Grumman has put out a Press Release announcing they will be using Microsoft ESP as part of their C4ISR Route and Mission planning system.  In fact, I'll be up in Reston, VA all next week, at the Microsoft Technology Center, helping them work on a Proof of Concept for this.

 

Well, that's all the case studies/press releases I've come across so far, will post again as I find more of these.

Beatle

View more entries