Bringing Joy to the World

December 23, 2009 by jonnyboats

Here is a video of people enjoying the HBO Shop Interactive Snow Window in New York City. In particular I enjoyed watching the little girl to whom this display obviously brought so much joy.

hbo_013

Having lived in Manhattan for ten years, I remember well the display windows in the stores as well as the extra effort that went into them during the holidays. One need only consider the Macy’s Thanks-giving day parade to realize that merchants in NYC regularly exceed their counter-parts in other places in terms of the efforts they will undertake.

Quoting from the Sosolimited website: “We built a snow blowing machine that senses people walking by on the sidewalk and launches snow into the air in response. The installation was developed with the openFrameworks programming API and the physical hardware was controlled using an Arduino. An IR sensor array detects how close pedestrians and window-gazers are, and using mechanical relays, switches on and off fans under the snow in response. A Large LED wall behind the snow is also reactive to street traffic as well. A sliced winter forest scene changes color and moves in response to street traffic.”

I too use Arduino computers, which are open source and available for approximately $30. All the software for them, compilers etc., is open source and free. I use my Microsoft Windows computer to compile programs for the Arduino and then download and run the program on the Arduino. It’s an ideal combination, the power, speed and ease of use of Windows combined with ultra low cost deployment.

While I have used multi-million dollar computers to solve sophisticated financial calculations using integer programming, I have never had a child dance and enjoy any program I have ever written. My hat is off to the people at Sosolimited and HBO; they have used a $30 computer to bring the true joy of the holidays to untold children and adults this holiday season.

Wouldn’t it be great if all of us who work with computers could dedicate ourselves to using them to bring a little bit of joy to the world in the coming year?

Choose Microsoft for iPhone development

December 9, 2009 by jonnyboats

About now you’re probably thinking, “What happened JonnyBoats, the boom on your sailboat hit you in the head?” Everybody knows the way to develop for the iPhone is with Objective-C form Apple. Well hang in there with me….

Having dealt with lots of people at Microsoft for over 20 years, I can assure you that once you get to know them the company is really lots of different groups with different agendas and goals. Those who portray Microsoft as the “evil empire” with all employees goose stepping to the same music has simply not taken the time to get to know those on the main campus.

One of the podcasts I try to listen to is StackOverflow, they are published weekly and last for over an hour, so I often fall behind. I was listening to Podcast # 61 with Miguel de Icaza of the Mono project. If you have the time, I encourage you to listen to the podcast.

In the podcast Miguel mentions dealing with Bob Muglia of Microsoft concerning licensing and the mono project and how accommodating and supportive he is to open source.

I first dealt with Bob back in 1988 when he joined Microsoft (see this news item). I had a small firm, Canaan Analytics, and we were developing a Windows based system used by an internally managed pension fund that used it to manage several billion dollars of US stocks. Bob always went above and beyond to help us, and I can assure you that we could never have done what we did without a lot of help from many, many people at Microsoft.

Allow me to give you a quick example of one of the many things he did to help us. We were using second class broadcast mailslots to deliver real-time stock quotes through the LAN. Bob knew this, and that we were virtually the only firm using them in this way. Bob gave me a call to tell me Microsoft would like to change their implantation under Windows NT and wanted to know how this would affect us.

Back to the present, take a look at these show notes excerpted from the StackOverflow podcast:

  • Mono runs on the iPhone, through the Unity game engine! This was challenging for the Mono team to develop, because interpreters and runtimes are explicitly disallowed in terms of the iPhone SDK. Mono had to be converted from a JIT to a static compiler.
  • Per Miguel, programmers wanted Mono because Objective-C is fairly primitive in memory management and requires a lot of repetition and boilerplate. With Mono “this is all taken care for you”, as a higher level language.
  • Due to concerns within the free software community, Microsoft made a legally binding promise that it will not enforce patents against Mono — for the core framework.

    For all the details you really do need to listen to the podcast; but here is my take:

    1. Apple provides a limited, outdated development environment for the iPhone.
    2. Apple restricts through legal contracts what developers can do on the iPhone, forbidding some of the most popular tools which are capable of running on the iPhone.
    3. Microsoft provides a great development environment with Visual Studio and .NET. The compilers are included for free with Windows and the Express version of Visual Studio is also free.
    4. Because of the open source Mono project and the Unity framework, applications can be developed in Visual Studio and deployed on the iPhone.

    So in conclusion Microsoft provides free and low cost versions of Visual Studio that permits one to develop applications that run on Windows, Unix, Mac, Windows Mobile and the iPhone. If you develop on a Mac, what tools does Apple give you to develop applications to deploy on Windows?

  • Software development choices

    August 2, 2009 by jonnyboats

    Anyone in the computer field is constantly called upon to make a dizzying array of choices. For a developer, a computer is hardly a set it and forget it device!

    All users must make choices like do I buy a Mac or a PC? If I get a PC, do I get a netbook with Windows XP, a laptop with Windows Vista or wait for Windows 7? No sooner than I get the computer it seems like I am faced with the question: “Is it time to upgrade?”

    For a developer things can be even more frenetic. By way of example, hardly a week goes by without some sort of security patch or service pack for one of the myriad of tools. Silverlight, Visual Studio, Azure etc, the list seems endless! Worse still, tools for developers can easily cost thousands of dollars.

    On a longer term and more strategic level one is forced to commit to platforms and development environments which take years to master and which unfortunately may not be around that long. Perhaps you learned the PASCAL language in college? Well there really aren’t many jobs for PASCAL developers, especially compared to web developers or iPhone developers. Did the iPhone even exist when you were in college?

    My first job after college in 1974 was as a COBOL programmer on IBM mainframes, technology which I concentrated on until the 1980s when I switched my focus to PCs. In the fall of 1987 I became a big fan of Microsoft Windows and have been doing development on Microsoft platforms with Microsoft tools ever since. In case you were wondering, I am a big Microsoft fan!

    Two websites I am currently developing use vastly different toolsets. One, http://NewsPeeps.com, uses Microsoft Model View Controller (MVC) and utilizes open source; specifically KiGG. The other, http://www.ehswidges.com, uses Microsoft’s Silverlight built with Expression Design 3’s SketchFlow tool.

    The first, MVC, has a rather steep learning curve. Once one becomes proficient, one can do amazing things. One could characterize MVC as a tool for professionals. SketchFlow on the other hand can be can be understood in less than an hour and once could then build an extremely good looking website in far less than a day. That’s right, someone who is familiar with computers could learn SketchFlow and produce a quite acceptable website in less than a day! Watch this video to see what I mean.

    This reminds me of Windows development in the early 1990s. If one wanted to produce a Windows application prior to 1991 one programmed in C with the Windows SDK. In fact learning the Windows SDK took longer than learning C! Then in 1991 Microsoft Introduced Visual Basic and the barrier to entry as a Windows programmer was reduced by orders of magnitude. Commercial products like Microsoft Office continued to be written in C while the vast majority of corporate developers and hobbyists adopted VB. The number of Windows applications, particularly specialty products and  in-house applications skyrocketed.

    The lesson here is that Companies like Microsoft that make it easy for people to develop software will be far more successful in the long run than those that don’t. How easy does Microsoft make it? If you are a student, check out DreamSpark. A starving entrepreneur looking to produce his (or her) first software product, check out BizSpark. Someone else wanting a free version of Visual Basic .NET, then download VB.NET for free.

    In my next post I will discuss why this may be the game changing strategy that could permit Microsoft to dominate the mobile phone market.

    Mind mapping with SketchFlow

    July 19, 2009 by jonnyboats

    Recently Microsoft released version 3 of Expression Blend, a tool used primarily to create websites and programs that run on Microsoft Windows. The technology used by Blend for these websites is Silverlight which permits the development of stunning graphics, similar to Flash but much easier in  my opinion.

    Last week I had the opportunity to work on one of these Silverlight 3 websites using SketchFlow. If you are curious you can see the website, ehs Widgets.

    As is often the case, one may find new uses for a tool other than what its creators intended. Today I needed to collaborate with a colleague in another state using a mind map. Mind maps are great tools for brainstorming and if you are not familiar with them you may want to either Google them or read about them at Wikipedia. Not wanting to purchase an additional program just to do mind maps, it occurred to me that SketchFlow could easily be used as a mind mapping tool with the added benefit that the completed map can easily be output as a Microsoft Word document; or even a website if one so desires!

    Displaying GPS data in WPF

    June 5, 2009 by jonnyboats

    One of the great things about Windows Presentation Foundation (WPF) is that it uses Extensible Application Markup Language (XAML). XAML is an XML based language that graphic artists can easily create using Microsoft Expression Blend. A programmer can then write the program logic in any .NET language such as C# or Visual Basic.

    A big advantage to this separation beyond separation of tasks during initial development is that a non-programmer can change what the application looks like without knowing a programming language; only the XAML needs to be modified.

    I built a simple test application in WPF using Visual Studio 2008 that reads data from a GPS and displays the position in latitude and longitude. Also displayed is the date and time which is updated from a timer. A screen shot of the application appears below:

    image

    This solution is rather simple and its structure is shown below. The two items of interest are Window1.xaml and NMEAParse.cs As an aside, Window1.xaml.cs is just as generated by Visual Studio, it contains no additional code.

    image

    Here is Window1.xaml:
    ___________________________________________________________

    <Window x:Class="NMEATest.Window1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:NMEATest="clr-namespace:NMEATest"
        Title="Window1" Height="300" Width="300">
        <Grid>
            <StackPanel Orientation="Vertical">
                <TextBox Height="34" Width="Auto" Text="{Binding Mode=OneWay, Path=FormattedDateTime}"
                         TextWrapping="Wrap" x:Name="DispValue"  Foreground="#FFE61919" FontSize="18">
                    <TextBox.DataContext>
                        <NMEATest:UpdatingDtTm/>
                    </TextBox.DataContext>
                </TextBox>

                <TextBox x:Name="lat"  Text="{Binding Mode=OneWay, Path=GPSPosition}">
                    <TextBox.DataContext>
                        <NMEATest:UpdateGPS/>
                    </TextBox.DataContext>
                </TextBox>
            </StackPanel>
        </Grid>
    </Window>

    ________________________________________________________

    This interface is rather simple, consisting primarily of two text boxes, one for the date-time and the other for the position. The key to getting the data into these textboxes is data binding. In this case the binding mode is set to OneWay since we are only displaying data, not updating it. The Path specifies the variable name being referenced (FormattedDateTime & GPSPosition) while the DataContext specifies the namespace and class name (NMEATest:UpdatingDtTm & NMEATest:UpdateGPS).

    Below is NMEAParse.cs, the C# code that provides the data that is displayed in the XAML. Since this code is in a different class, it will run on a separate thread and thus the user interface will remain responsive even if the c# code is heavily loaded.

    The key to implementing the data binding is to implement the

    INotifyPropertyChanged interface, providing a PropertyChangedEventHandler and then calling PropertyChanged when there is new data to be displayed.
    ________________________________________________________

    using System;
    using System.IO.Ports;
    using System.ComponentModel;
    using System.Windows.Threading;

    namespace NMEATest
    {
        public class UpdateGPS : INotifyPropertyChanged
        {
                private string _GPSPosition = "lost";
                private bool bPortOpen = false;
                private SerialPort port;
                private string serBuff = "";

                #region INotifyPropertyChanged Members
                public event PropertyChangedEventHandler PropertyChanged;
                #endregion

                public string GPSPosition
                {
                    get { return _GPSPosition; }
                }

                public UpdateGPS()
                {
                    port = new SerialPort("COM5", 4800);
                    port.DataReceived += new SerialDataReceivedEventHandler(sp_DataReceived);
                    port.Open();
                    bPortOpen = true;
                    //port.Close();
                }
                void sp_DataReceived(object sender, SerialDataReceivedEventArgs e)
                {
                    bool newData = false;
                    serBuff = serBuff + port.ReadExisting();
                    while (serBuff.Contains("\r\n"))
                    {
                        int i = serBuff.IndexOf("\r\n");
                        string line = serBuff.Substring(0,i);
                        if (‘$’ == line[0])
                        {
                            string[] tok = line.Split(‘,’);
                            switch (tok[0])
                            {
                                case "$GPAPB":      // Auto Pilot B sentence
                                    break;
                                case "$GPBOD":      // Bearing Origin to Destination
                                    break;
                                case "$GPBWC":      // Bearing using Great Circle route
                                    break;
                                case "$GPGGA":      //  Fix information
                                    if (tok[1].Length > 0)
                                    {
                                        _GPSPosition =
                                            tok[2].Substring(0,2) + " " + tok[2].Substring(2, tok[2].Length-2) + " " +tok[3] +
                                             " – " +
                                            tok[4].Substring(0,3) + " " + tok[4].Substring(3, tok[4].Length-3) +
                                            " " + tok[5];
                                    }
                                    else
                                    {
                                        _GPSPosition = line;
                                    }
                                    newData = true;
                                    break;
                                case "$GPGLL":      // Lat/Lon data
                                    break;
                                case "$GPGSA":      //  Overall Satellite data
                                    break;
                                case "$GPGSV":      // Detailed Satellite data
                                    //_GPSPosition = line;
                                    //newData = true;
                                    break;
                                case "$GPRMB":      // recommended navigation data for gps
                                    break;
                                case "$GPRMC":      // recommended minimum data for gps
                                    break;
                                case "$GPRTE":      // route message
                                    break;
                                case "$GPVTG":      // Vector track an Speed over the Ground
                                    break;
                                case "$GPXTE":      // measured cross track error
                                    break;
                                case "$PGRME":     
                                    break;
                                case "$PGRMM":
                                    break;
                                case "$PGRMZ":
                                    break;
                                default:
                                    //string un = line;
                                    //Console.WriteLine(un);
                                    break;
                            }
                        }
                        serBuff = serBuff.Substring(i+2);
                    }

                    //_GPSPosition = serBuff;
                    if (newData)
                    {
                        if (PropertyChanged != null)
                        {
                            PropertyChanged(this, new PropertyChangedEventArgs("GPSPosition"));
                        }
                    }
                }
       }

            public class UpdatingDtTm : INotifyPropertyChanged
            {
                private string _someText = "Foo";
                private DispatcherTimer tmr = new DispatcherTimer();

                #region INotifyPropertyChanged Members
                public event PropertyChangedEventHandler PropertyChanged;
                #endregion

                public string FormattedDateTime
                {
                    get { return _someText; }
                }

                public UpdatingDtTm()
                {
                    tmr.Interval = TimeSpan.FromMilliseconds(10);
                    tmr.Tick += new EventHandler(tmr_Tick);
                    tmr.Start();
                }

                void tmr_Tick(object sender, EventArgs e)
                {
                    _someText = DateTime.Now.ToString();
                    if (PropertyChanged != null)
                        PropertyChanged(this, new PropertyChangedEventArgs("FormattedDateTime"));
                }
            }
    }

    _________________________________________________________________

    If you are not familiar with WPF development, you may be surprised if you open this project in Visual Studio. The design interface will update the data in real-time in design mode; even before you run the program! This is to be expected.

    One other thing, I used a Microsoft GPS puck on a USB port for testing. This is the one that ships with some versions of Streets & Trips. On my computer it installed on Comm port 5 and runs on 4800 baud. If your GPS uses a different port or speed, you will need to change the line that opens the serial port. If you don’t have a GPS don’t worry, the date and time will still update.

    stack overflow

    June 2, 2009 by jonnyboats

    It has been many years since I started programming computers and a lot has changed in that time. On the one hand all this new technology and changes leads to lots of questions, while on the other we have lots of new ways to get answers. For a long time now it has been common to simply Google the internet for answers.

    Now there is a great new resource for programmers; stack overflow. It is for one thing only, to ask questions and get answers about programming. This site is so good that one can ask a question and get multiple answers in literally minutes.

    The story behind stack overflow is fascinating. For the details watch this video.

    Microsoft Robotics Studio

    April 8, 2009 by jonnyboats

    As part of my work for TTA Marine, I have been doing lots of work to interface sensors and other marine electronic devices to computers running Microsoft Windows. Jeff Barnes of Microsoft suggested I take a look at Microsoft’s Robotics Studio, pointing out that its CCR/DSS component is good for applications far beyond robots.

    For hard core programmers looking for an example of the kinds of things the CCR/DSS is good for, I suggest you take a look at Igor Moochnick’s PowerPoint presentation Concurrency and Coordination Runtime (CCR): No More Asynchronous Spaghetti. Igor wrote a web crawler (think Google search engine) using the product and has the source code for this and his other examples available for download. Get the presentation and sample code at http://igor.moochnick.googlepages.com/ccrpresentation1.

    Getting back to Jeff Barnes, I want to extend a big thank you to him for turning me onto this technology! While it is definitely not an easy learning curve, it holds lots of promise. Jeff has done an excellent presentation titled “Silver GPS – Overview of an end-to-end Mobile GPS tracking application using the .NET Compact Framework, WCF, LINQ, Silverlight, and Virtual Earth” once again full source code is included. While Jeff does not use code from the Robotics Studio for this presentation, he has for several others.