2nd production WPF application ever…

About 5 or 6 people have now pointed out to me that Tim Sneath has featured the Regatta Manager as his #7 Great WPF application.  I am truly flattered by his kind words, but more importantly am honored to have had the opportunity to work with him and the others involved in publicizing the Skandia Cowes Week software.

I think however I was most shocked by the fact that the Regatta Manager was only the 2nd application to go into a production environment that made use of WPF.  Whilst surprising I suppose it is understandable; I was in the fortunate position to be in control of the entire develop process, had a fixed deadline of the end of July and made the call that the advantages of using WPF more than outweighed any issues that might arise from using beta software.  Making that call resulted in a fantastic piece of software, as Tim says, that we could really is a testament to the quality of WPF.

Microsoft Case Study

Microsoft have published the case study that they produced for the Skandia Cowes Week Regatta Manager Suite.

Since the Vista Launch is now over, I promise I’ll limit the self-congratulation for a few weeks, but only after dropping the text on my blog for posterity…

 

Skandia Cowes Week Regatta

Regatta Sets Optimal Courses for 1,000 Boats With Pioneering Use of Visual Technology

Skandia Cowes Week Regatta—one of the largest competitions of its type in the world—set its sailing courses using pins and string on a wall-mounted chart of the waters, as it had for most of its 180 years. But that method limited course setters’ ability to create the most accurate and enjoyable courses for participants. So, the regatta’s organizer became one of the first organizations anywhere to use a software solution created with Windows® Presentation Foundation, which helps developers build highly visual solutions quickly and effectively. With Presentation Foundation, software partner SiSoft created the solution’s rendering engine in days rather than the months that it took to create an earlier course-setting solution. The code base was cut by 36 percent while the solution became more useful and powerful, and participants are delighted by the courses that organizers can now create.

Situation

It’s one of the largest and longest-running international sailing regattas in the world. Held every year since 1826—with time off for two world wars—it’s been visited by royalty and world-famous personalities. It attracts more than 1,000 boats, 8,500 participants, and 10,000 spectators per day during its eight-day run.

“It” is the Skandia Cowes Week Regatta, held annually in the Solent channel off Cowes, the home of the Royal Yacht Squadron on the Isle of Wight in the United Kingdom.

What keeps participants returning year after year, according to Stuart Quarrie, Director of Cowes Combined Clubs, the event’s organizer, is the excitement of the “interesting and challenging sailing” for competitors, including more than 30 courses set in one of the busiest commercial stretches of water in the world.

Keeping Courses Challenging

As the regatta has grown, keeping those courses interesting and challenging—as well as safe—has been an increasing challenge for the event’s 14 course setters. Courses can’t have too many boats approaching the same locations at the same time. Managing the boats’ finishes—1,000 boats will arrive at two finish lines within a one-hour period—is another. Understanding the affect of tides and weather on the courses complicates matters further.

Making the courses interesting and challenging means ensuring that they aren’t too long for the smaller boats or too short for the larger boats. They must have legs of varying lengths and a mix of wind angles, so that participants sometimes must zigzag into the wind and sometimes can let the crosswind carry them along stretches that are just “fast and fun,” according to Quarrie. Ensuring that boats can complete the courses within the allotted times, rather than being stymied by unexpectedly light winds, is another concern.

By the late 1990s, the increasing numbers of participants, boats, courses, and classes at Skandia Cowes Week were making those challenges more difficult for the event’s course setters to meet. In 1997, several races had no finishes because of problems with the courses—and the following year, participation in some of the affected classes dropped by 33 percent. That’s when Quarrie was hired as director.

Using Pins and Strings

What he found was a method of course setting little changed from the regatta’s founding in 1826. The course setters—some of whom had been working in that capacity for 20 years—defined courses for the boats by setting pins and string on a paper chart of the waters. When a course didn’t look right, they unwound the string, pulled the pins, and tried again.

“The problem was that you could envisage only four or five bits of string on the board before it became totally unintelligible,” says Quarrie. “And you couldn’t then take off the first courses because they were under other layers of string. We were getting course lengths wrong because we couldn’t take tides properly into account, and we had lots of boats ending up at the same mark at the same time.

“What we were trying to do was too complicated for the human mind to grasp because of all the permutations involved—but it would have been simple for a computer,” says Quarrie.

Solution

Quarrie didn’t have far to go to find a computer-based solution for Skandia Cowes Week Regatta. He turned to his son-in-law, Simon Middlemiss, founder of software company SiSoft.

Middlemiss’s computerized course-setting solution replaces pins, string, and paper charts with an image of the course territory displayed on a pair of high-resolution 30-inch LCD wide-screen monitors—one for small-boat courses and the other for large-boat courses. The course setters design and manage their courses as part of a single, fluid process. By letting the mouse pointer rest on a buoy or mark icon, the course setters can see displays of the classes that are already scheduled to reach that point, when they’re scheduled to do so, and what the tide, wind, and other weather conditions are at that point. Clicking the buoy or mark selects it as part of the course that the setter is creating.

Course setters can choose to view any single course, an overlay of some of the courses, or all courses at once. In response to changing weather conditions or anticipated congestion of boats at a particular point, setters can change a course by dragging and dropping to a different buoy or mark. The user interface keeps each new course separated from the existing courses until the course setter chooses to accept the course and make it part of the race.

That feature allows course setters to experiment with new courses without changing variables for confirmed courses. It also allows course setters to consider 10 or more potential courses at a time before deciding on the one to adopt, without complicating the view of the confirmed courses. Once a course setter accepts a new course, he or she can replicate the course to other classes or days with a few mouse clicks.

Pioneering Use of Visual Technologies

Middlemiss created version 1.0 of the course-setting solution using Managed DirectX® extensions, which required him to code user interaction and data binding manually. This process took months. Then he and Quarrie agreed on the need for a new interface, one that would isolate new courses until they were confirmed by the course setter. Middlemiss needed a faster way to create the new solution.

Middlemiss then created one of the first solutions to go into production based on Windows® Presentation Foundation in Microsoft® .NET Framework version 3.0, an integral component of the Windows operating system that provides a programming model and runtime for Web services, Web applications, and smart client applications. Presentation Foundation is a new presentation subsystem that takes full advantage of modern graphics hardware and an extensible set of managed software classes to facilitate the development of highly visual applications—exactly what Quarrie and Middlemiss were seeking.

Windows Presentation Foundation was an essential ingredient in the solution, according to Middlemiss, given the need for a highly visual solution to make it easy for users with limited computer experience to manage the process of creating new courses. To work with Presentation Foundation, Middlemiss used the Windows Vista™ operating system and the Microsoft Visual Studio® 2005 development system, together with Microsoft Expression® Blend design software and Extensible Application Markup Language (XAML), which enable developers to use an XML-based model to declaratively specify user interface behavior, rather than having to code that behavior into the interface.

Replacing Paper Charts with Rich Graphics

In the solution’s presentation layer, what was once the old paper chart of the manual solution now is re-created as a collection of vector shapes rendered on NVIDIA GeForce 7800 GTX–based hardware for rich, responsive graphics at very high resolution.

The application layer includes a core set of libraries that handles the complex algorithms for calculating estimated times of arrival, positions, and conflicts. Middlemiss designed this core so it can run locally or through Web services—enabling the solution to be easily extended and scaled out. The application layer also includes a reporting engine, a system for transmitting courses to boats by short message service, and a system for transmitting course and estimated time of arrival data to the results center.

In the database layer, the Microsoft SQL Server™ 2005 database makes use of Common Language Runtime integration by deploying managed assemblies that process weather-forecast data.

The production environment consists of six computers:

Two workstations running the course-setter application

A laptop running the weather forecasting application

Three laptops for managing reports, communication with radio operators tracking boats during course runs, and an administrative console to the database

The production environment was mirrored in a test environment used to confirm the solution’s performance, and the entire solution was deployed using the ClickOnce deployment technology in the .NET Framework.

Benefits

The course-setting solution enabled Skandia Cowes Week Regatta organizers to meet their goal of creating more exciting and fun courses to boost participant satisfaction, and it also was created in a fraction of the time—and the size—of the previous, less powerful solution.

Cut Development Time from Months to Days

After developing version 1.0, Middlemiss needed a faster way to build its successor. He got it with the new technologies in Microsoft .NET Framework 3.0 and Windows Presentation Foundation, along with the XAML-based tool Expression Blend. Using these technologies, Middlemiss created the rendering engine—which had taken three months to develop the year before—in a weekend.

“I was amazed to see how much faster I could work with Windows Presentation Foundation to create a visually stunning application,” says Middlemiss. “Using XAML and Expression Blend, I put together an application that did what I wanted very quickly. I could take advantage of data binding, of new objects in.NET Framework 3.0.”

Middlemiss calls the data binding model in Windows Presentation Foundation the best capability of the new development environment. “There’s no business logic whatsoever in the user interface and no massaging of data in code either—it’s all done declaratively,” he says. “I could just assign a data source to a control and design the layout, without having to manage all the plumbing between the two.”

Separating the user interface and business logic meant that Middlemiss could concentrate on optimizing the business logic and then on optimizing the design, without having changes to one affect the other. For larger development teams, he notes, developers and designers can work simultaneously, without impinging on each others’ work.

Reduced Code Size 36 Percent While Boosting Performance

The same rapid application development capabilities in the new development technologies helped Middlemiss cut the code base for the solution by 36 percent—from 110,000 lines to 70,000 lines—while achieving a solution with a richer and more effective interface, more features, and greater performance.

“Basically, with Windows Presentation Foundation, Windows Vista, and Expression Blend, I got the rapid application development of Windows Forms combined with the application performance of DirectX,” says Middlemiss. “I would tell other developers that Windows Presentation Foundation and .NET Framework 3.0 can seriously reduce the amount of code that they have to manage on their user interfaces. And less code means the application is easier to manage.”

Using Windows Presentation Foundation reduced the line count for the CourseSetter portion of the solution by 50 percent.

Increases Participant Satisfaction

The goal of the course-setting solution is to create better courses that give participants the fun and excitement for which they come to Skandia Cowes Week Regatta. After running the 2006 regatta using the software, Quarrie says that’s what the solution delivers.

“What the course setters get from the technology is not an automated answer to where they should send people but feedback on how long a leg will take, what the wing angles will be, and what the interaction is with all the other classes, so that they can make the intelligent decisions,” says Quarrie.

“The result is better courses more quickly, because the course setters can check the feasibility of their design as they create it, rather than having to complete a design and then check it,” Quarrie adds. “They can take more variables into account than they otherwise could, and even can change a course that’s in progress to adjust for changes in wind or weather so we don’t leave boats stranded.”

The ability of the solution to predict the time that it would take to complete courses was so high that at least two predictions differed from actual measures by fewer than five seconds. “Over two hours and 20 miles, that isn’t bad,” says Middlemiss.

“This past year, the courses gave our 8,500 participants and tens of thousands of spectators what they wanted from the regatta,” says Quarrie. “The proof is in happy competitors—and we had many more happy competitors.”

Enables Easy Extensibility

While the course-setting solution was a great success in its debut at Skandia Cowes Week Regatta, Quarrie and Middlemiss already have their sights set on enhancements. The use of the .NET Framework and service-oriented architecture will make it easy for them to create new components and functionality, or to add best-of-breed components from third parties.

For example, because the solution is already able to track participants as well as set courses, Quarrie and Middlemiss envision using Global Positioning System (GPS) technology to boost the accuracy of that capability. A trial with 20 boats tracked through GPS devices was a success in 2006. The two men also envision presenting real-time tracking of races to spectators. The highly visual user interface could be projected on large screens for spectators at the regatta and presented live on the Internet for those who want to follow the regatta from anywhere in the world.

Vista Track – Session 1 : Presentation Advances in the .NET Framework Version 3.0

The first session started with the video of the Regatta Manager from Skandia Cowes Week 2006 that I can’t stop talking about! Whilst not the final version, it was still very cool to see it on the big screen.

The actual session was an excellently presented introduction to WPF by Mark Johnston. He went over most of the basics in a demo that many will have seen before, but nonetheless covered everything you need to see to be impressed by the technology which I think is the major motivation for this event.

The session ended by Rich Griffin from Conchango talking about the work he’s been doing with the Telegraph and Daily Mail.

 

Keynote

First off, a screenshot (an old one I admit and not the one on the left)  of my app was shown in Sanjay Parthasarathy‘s keynote so I’m seriously impressived!

The keynote was the usual inspirational stuff of a Microsoft VP who’s passionate about developers and the new technologies in Vista, .NET 3.0 & Office 2007, but more than that it was an affirmation of what we’ve all been doing for the past 2 years or more. Sanjay referred to it as ‘Generation User’.

Launch Day!

Today is launch day! Well the uk developer launch anyway. It’s the culmination of a lot of work by a lot of people, both at Microsoft and in the community, something that’s been fantastic to be involved in even in such a small capacity.

Unsurprisingly I’ve been concentrating on my stuff, so it’s going to be good to see and hear from other’s.

Over the last couple of weeks I’ve been working with a technical writer on the case study for the Regatta Manager which *should* be being published today.

Will add more as the day progresses.

Skandia Cowes Week – Regatta Manager Videos

As I’ve mentioned before, Microsoft sent a film crew along to Skandia Cowes Week to see the Regatta Manager in action and below are the results. There is a technical and business version of the video.  Thanks again to Tim, Heather, Barbara and Ian at Microsoft who made this happen, and to Bubble Solutions for putting together this great film.  I’ll stop now as this is starting to sound like an Oscar acceptance speech… 

MSN Soapbox

SiSoft Regatta Manager - Business Edition
SiSoft Regatta Manager – Business Edition

SiSoft Regatta Manager - Technical Edition
SiSoft Regatta Manager – Technical Edition

You Tube

SiSoft Regatta Manager - Business Edition
SiSoft Regatta Manager – Business Edition

SiSoft Regatta Manager - Technical Edition
SiSoft Regatta Manager – Technical Edition

Skandia Cowes Week, Microsoft, WPF, Windows Presentation Foundation, SiSoft, Regatta Manager, Simon Middlemiss

Polar diagram generation tool

This is a repost

Update : I haven’t got around to separating the Polar Diagram tool from my main application (which is huge) so anyone who wants me to generate a polar for them please get in touch at simon dot middlemiss at microsoft dot com.

Update : I’ve removed the tool because it didn’t work with the release build of WPF.  I’ll update it if anyone is interested in it. Leave a comment…

Since I’ve had a lot of hits to my blog from Google searching for things along the lines of “J/109 polar diagram” and “X-332 polar diagram” I’ve repurposed a bit of the Regatta Manager to produce a polar diagrams for all the major one design classes with the option to generate one from an IRC rating.

It produces polar diagrams for the following classes:

Laser SB3
Etchells
1720
RSK6
Daring

Dragon
Sonar
707
Flying 15
RS Elite

Redwing
Solent Sunbeam
Squib
Swallow
Mermaid

Victory
XOD
J-109
X-332
Sigma 38

Sigma 33
Sunsail 37
Contessa 32

Shout if anyone wants any more defaults added, I’ll post a link over the weekend.

Wind, Tide and Boat Speed

This is a repost

They are the 3 things you need to work out how long it will take to get from point A to point B in a boat.

Getting the first two is quite easy, all you need is your own personal meteorologist and some help from the Proudman Oceanographic Laboratories in Liverpool, the first one can build you a forecast using the wonderful ‘SiSoft Weather Maker’ the second a library from which you can query tidal speed and direction at specific coordinates.  The third thing isn’t quite so simple…

I have mentioned polars previously but I wanted to expand on that and explain what they are and how I use them in more detail.

When a sailor talks about ‘polars’ they are referring to the graph which describes the behavior of their boat.  It is referred to as a polar because the type of graph used to show this information is a polar diagram.

On a normal graph a position in graph space is defined by using a set of Cartesian coordinates [x,y] on vertical and horizontal axes.  On a polar diagram a position in space is defined using polar coordinates [Θ,r] on an angular axis and a radial axis, with the option of a vertical axis [z].

In our case:


Θ
=
True Wind Angle (TWA)

r
=
Boat Speed (BS)

z
=
Velocity Made Good (VMG)

The TWA is the angle of the wind relative to the boat, BS is the speed of the boat through the water, VMG is the component of the boat speed that is in the direction of the destination.

Skandia Cowes Week has around 38 classes which range from very small to very large, for which we need a polar to describe each class.  So as to reduce the amount of work we had to do we only collected 3 polars.  One which represents a displacement hull, one a sportsboat (or planeing) hull as well as one for multihulls and all of them with an IRC handicap rating of 1.0.  Using this we can then scale the polar values to the equivalent rating for each class in the fleet.  This is easy for the large classes as the IRC rating is easily obtained, for the day boats this is less so.  We in fact use another common handicapping method, the Plymouth Yardstick, and because there is a one design boat which has both a known PY and IRC rating we can workout the scale factor for the small boats in the fleet.

With this background it becomes easier to see what the curves represent, each is fitted through 5 points, representing a different angle of sail, beating, close reaching, beam reaching, dead reaching and running respectively.  The 5 curves then represent a True Wind Speed (TWS), in this case, 6kts, 10kts, 14kts, 18kts and 25kts.  The horizontal lines are the point at which VMG becomes important, they represent the situation where your destination is either directly into the wind, or directly with the wind, because you physically can’t sail directly into the wind, you sail at an angle to it and tack every so often, so as to counteract the perpendicular distance you travel from your target.  So if your destination is 5° from the wind, we assume you are beating and therefore your boat speed will be that at your closest angle to the wind which could be 30°.  Drawing a line from your beating angle to the vertical axis gives us the VMG, which will become important later.

Lastly, if the wind speed lies between two defined curves, we take the upper and lower bound and linearly interpolate between the values, with all of this data it is possible to work out VMG and boatspeed for a given wind angle and wind speed for any boat in the fleet.

To get your boat speed you need to know the angle you are sailing to the wind, so you need to know your ‘Course To Steer’ (CTS) which is the heading you follow so that when tides are accounted for you’ll end up at your destination.  Unfortunately to work out the CTS you need to know your boat speed, and so as you can see we have a dilemma.

We get around this by looping over the function to calculate your CTS until the change in CTS is within a defined threshold, with the initial boat speed obtained by using an angle to the wind equal to the bearing of your destination. 

Once you have the CTS and the corresponding boat speed for that CTS you can work out how long it will take to get to your destination. This is all well and good if the distance to that destination is quite short, but sometimes you will be working out the ETA for a destination that is several tens of miles away, and both the wind and tide will change from the values you originally used as you progress spatially and temporally to your destination.

To overcome this issue we can do one of 2 things; divide the trip into a defined number of segments and calculate the ETA for each segment, which still has the disadvantage of becoming more inaccurate over longer distances, or repeatedly calculate the distance traveled in a defined time interval, using new wind and tide data, until the distance between your current position and your destination is within a defined threshold.

The second method has the added advantage of allowing for the scenario where given the wind, tide and boat speed, the actual direction traveled is back to your start point.  When this occurs an assumption that one is kedged can be made, so the algorithm will add a time increment until either the wind picks up enough that you can continue against the foul tide, or the tidal stream changes to become more favorable.

And that is how you get predicted finish times that are accurate to ±5 seconds over 4 hours.

Where have all my klocs gone…?

This is a repost

I’ve never thought counting the number of lines of code in a project was a terribly accurate metric. It gives no view on the quality or efficiency of code and can lead to a mentality of more is better when it most certainly isn’t. Line counts are however good for the soul if you are very small development team and can act as an indication of project size and complexity. What can be a good metric, however, is a version on version comparison of line count.

So, Regatta Manager Suite v2.0 is approximately 70,000 lines of code, 11,000 of those are Jenny’s with the Weather Maker, Race Administrator and Rounding Actuals tools. The remaining 60,000 lines making up the core assemblies and the Course Setter. I’d not actually done a line count last year but had guessed (very wrongly) that it was around 30,000 lines. That code was actually 110,000 lines of code. 65,000 of those were in the Course Setter.

Using WPF reduced the line count for the Course Setter by half. The rest of the reduction in code is accounted for by a huge amount of refactoring of the core and clients; I moved from the data application block to using ADO.NET DataSets, and cleaned up a whole host of repeated, bloated and frankly crap code written either during the early hours of the morning or under huge pressure and always with a caffeine saturated blood stream.

I’m always looking for ways to promote WPF and the rest of the .NET Framework v3.0 to other developers and here is another one. It can seriously reduce the amount of code you have to manage on your user interface.

All I have to do now is port all my thrown together XAML from Beta 2 to RC1/RTM.

Lucky me.

It’s over!

This is a repost

It’s all over (until next year?), and I am back at home in Newbury and have my email back up and running. I am still in need of a great amount of sleep which I hope I can catch up on before Monday.

Anyway, ‘what happened?’ you are all asking.  Well for starters here is a screenshot of the final application with live data showing from last week for you all to gawp at.

It looks pretty funky doesn’t it, well other than the blue gel effect anyway.  As far as how it worked other than a few user errors we had a pretty faultless week, we had to put a bit more validation in to the Weather Maker so that it doesn’t allow you to put the bearing and wind speed in the wrong way around; because the boat speed calculations interpolate linearly past the maximum polar ring (25kts) putting in 110knots and 18 instead of the other way around results in about 90kts of boat speed, so whilst not stopping you doing it in future, it now asks you if you’re sure.

There were also a couple of issues with the predictions for class 0, mostly because the IRC handicap rating doesn’t allow for the type of boat and despite their size ABN Amro, Maximus and Full Pelt sail like sports boats in the right conditions, whereas the rest of the IRC 0 fleet are displacement boats.

The graph on the right represents the X-332 class, which is a displacement boat, (the different arcs being different wind speeds (2,4, and 6kts)) and the one on the left the J-109 class, a sportsboat, (the first arc being 6kts wind speed). As you can see there is a marked difference between the two from 90 onwards, which represents how the boats behave as they get further away from the wind.  Sportsboats take off as they start to reach, whilst displacement boats are at their most efficient running before the wind. Now this is fine when you have two classes which each fit one of these diagrams, but when you have a class which contains both it becomes difficult to predict when the class will get home. On top of that ABN Amro has a canting keel, meaning she can sail in much higher winds with the same sail area without the corresponding increase in leeway. Amazingly however, discounting class 0 and the multihulls (again another really difficult class to predict for) we were pretty much spot on with our estimates. I haven’t checked all of the data yet, but I know we had at least 2 predictions that differed from the actuals by less than 5 seconds. Over 2 hours and 10-20 miles that ain’t half bad.

Linz has insisted that I immortalise the following story on my blog, and whilst equal parts name dropping and total embarrassment I have given in. Throughout the week we must have had 20 or so people ranging from media to friends of staff, from the Skandia Geelong week organisers to the small time Waymouth Regatta people come in and look at the Regatta Manager, sometimes I was there, others not. Needless to say by the end of the week I pretty much had the spiel down to a concise 5-10 min talk and was starting to relax whilst doing them. So much so that when a member of staff came in with what appeared to be his family I merrily went on about how wonderful it all was and everything was good. It was only after they left and Linz came over and said “You do realise that was David Gower don’t you?” that I started to feel like a prat.

Microsoft PR Event

I alluded in an earlier post to a PR event that Microsoft organised, they sent a film crew along to video the whole Regatta Manager Suite working, paying special attention to the Course Setter which makes use of the Windows Presentation Foundation aspect of the .Net Framework version 3.0. It was a fantastic 3 days actually, we had good wind, and it was the Royal Yacht Squadron’s triumvirate days and everyone went out of the way to accommodate the film crew. A special thanks to John Grandy the RYS Principle Race Officer, and to all the course setters on those days, as well as Chris Tibbs and Richard Saloman and his team for the intrusion on their time.

In terms of where and when the final product will be shown, I am not quite sure yet, but with the imminent release of Windows Vista hopefully it will feature along with that.

And Finally…

A lot of people have expressed an interest in how the Regatta Manager works, and whilst I am not about to reveal trade secrets I am planning on putting together a post explaining some of the concepts behind how we get such good predictions given the large variables we have to deal with.