Clicky

ChrisEllsworth.com

The online home of Christopher Chess Ellsworth
Welcome to ChrisEllsworth.com Sign in | Join | Help
in Search

Chris's Development Blog

Tutorials and thoughts on software development.

  • Creating Custom Search Providers for the Browser

    Search ProvidersOne of my favorite time saving features in most current web browsers, besides tabbed browsing, is the ability to search the web from any web page. Just type your search query in the search bar at the top of the browser and hit enter. Most people know that you can search Live.com, Google, Lycos, or whatever your favorite search engine is. What many people do not know is that you can configure your browser to search using any search engine, or configure your web site to allow other people to search using your own site's search engine.

    Creating custom search providers first drew my attention a few years ago while I was working as an embedded systems engineer.  I constantly found myself searching Mouser, Digi-Key, Grainger, and Jameco by part numbers and keywords.  If you poke around the IE7 search applet, you will find a link to a page for adding common search engines (by clicking on Find More Providers...).  This page also allows you to create custom search providers by filling out a form.  You can also create a simple web page that will do this for you.

    I wanted a quick way to paste a part number into a search box and go directly to the search results, without having to navigate my favorites and find the search engine on some web site.  With this goal in mind, I set out to create a web page that would allow the user to automatically add search providers for a bunch of web sites all at once.

    This is a two step process:

    1. Create Open Search descriptions in a separate XML file for each search engine that you want to add.
    2. Make a web page that links to each of these search descriptions.

    The rest of this blog post will walk through these steps for creating a Digi-Key search provider.

    1. Creating the Open Search Description

    Create an XML file locally or on your web server that contains a search description like the following, where the template attribute of the URL element contains the search string used on your target web site and has {searchTerms} in the place of the search query.

    <?xml version="1.0" encoding="UTF-8"?>
    <OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
      <ShortName>Digi-Key</ShortName>
      <Description>Search Digi-Key Part # / Keywords.</Description>
      <URL type="text/html
               template="http://search.digikey.com/scripts/DkSearch/dksus.dll?keywords={searchTerms}"/>
    </OpenSearchDescription>

    2. Adding Links to the Search Descriptions

    In the head element of your web page, add link elements for each search provider you wish to include.

    <link title="Digi-Key
             rel="search"
             type="application/opensearchdescription+xml"
             href="http://www.chrisellsworth.com/SearchProviders/digikey-search.xml">

    Viewing the Web Page

    SearchProvider_2_cropped

    When you open a web page containing search link elements, the browser automatically detects them and allows you to search using them or to permanently add them to the search bar.  This technique allows you to create a "search provider install" page to quickly install all of your favorite search engines, or to add a custom search provider when people visit your web site (as I do on all of my pages on ChrisEllsworth.com).

    You can view the example page I created in this tutorial here.  The XML file containing the search descriptor for Digi-Key may be found here.

     

    Important Notes

    One common mistake people make is in the the URL encoding for the Open Search Description.  If the URL contains any '&' characters, then they must be replaced with &amp;.  The same rules need to be applied for white space (%20).  Basically, you need to follow the standard URL encoding rules.  The other caveat I want to mention is that, in my testing, IE7 only seemed to list the first 3 search link entries on a page, although Firefox listed them all.

    I hope you find this helpful.  Please post any questions in the comments below, or email them directly to me by clicking on the "email me" link in the menu bar at the right.

  • Research Awards

    I usually do not write about non-technical issues in my blog, but I was honored to receive awards from both the graduate school and the Appalachian State University chapter of Sigma Xi for my thesis research and thought this presented a good opportunity to post some photos and thank the people involved.

    Receiving the Appalachian State University 2007-2008 Outstanding Thesis - Science and Technology Award. Left to right: Dr. James Wilkes (CS department chair), Dr. Jay Fenwick (CS graduate studies chair), Chris Ellsworth (me), and Dr. Barry Kurtz (my thesis chair).

    Receiving the Sigma Xi Appalachian State University 2007-2008 Graduate Student Research Award. Above left, with Dr. Dale Wheeler from the ASU chapter of Sigma Xi; right, with my thesis advisor, Dr. Barry Kurtz.

    I would like to thank Dr. Barry Kurtz, my thesis advisor, for his support and friendship during my time at ASU. I would also like to thank the other members of my thesis committee, Dr. Rahman Tashakkori and Professor Frank Barry, for their guidance. In addition, I would like thank all of the faculty and staff at Appalachian State University for providing a nurturing research environment.

    Financial support for this research was provided by Dr. Barry Kurtz on behalf of the Lowe's Distinguished Professor endowment.

  • Master’s Thesis

    After years of hard work, I have completed my Master's research and thesis in Evolutionary Robotics. This body of work spanned the disciplines of electrical engineering, software engineering, and some mechanical engineering (I designed several custom parts that were manufactured in our machine shop). Using these skills, I applied the scientific method to perform an extensive series of experiments and analysis of the resulting data. This research is formally presented in my thesis "Simulation-Based Evolution of Neural Controllers for Embodied Autonomous Agents", and received the Appalachian State University 2007-2008 Outstanding Thesis - Science and Technology Award and the Sigma Xi Appalachian State University 2007-2008 Graduate Student Research Award.

    Anyone interested in the specific details of the research may read my thesis by downloading it from the publications folder in the downloads section of my website (PDF link). The document covers the robotic systems developed, the evolutionary strategies employed, and the experiments, results, and analysis that were conducted.

  • Engineering Principles

    Recently I have been working on my curriculum vitae and decided to add a section regarding my engineering principles.  I was thinking about what was important to me when it comes to system design and implementation and an analogy came to mind.

    The hole may initially look square, but after going through the process of making the peg it may become clear that the hole is in fact round.  In this case, it is often better to make a new round peg than it is to try and make the square one fit (which may not always be possible, or worse, is possible if done with a crowbar and duct tape).  In other words, it is important to be able to free yourself from the burden of existing design/implementation and start from scratch, armed with the knowledge attained during the previous effort.  This is something that many engineers are unable to do: let go of their cherished work and begin anew.

  • Word 2007 Citations - ISO Numerical Format

    I have been using Word 2007 since it was in beta and really like all the new features. As someone who typically writes technical papers, the new features that have had the biggest impact on me are the table of contents and citation/bibliography generation tools. They are seamlessly integrated with the interface and save a great deal of time over doing things the manual way.

    I use the ISO 690 numerical style for citations and am used to the standard notation of using brackets to enclose numerical references to the bibliography. The one thing I have not liked about Word 2007 since the beginning was that it uses parenthesis instead of brackets. I am not sure what the official standard is, but all of the scientific publications I read always use brackets.

    For some time now I knew that there had to be a simple way to change this, and that it must be related to the ISO690Nmerical.xsl XSLT stylesheet located in the office 12 program files directory. I am a confident XSLT developer, but I did not want to take the time to go through the 7000+ line stylesheet. Fortunately, the forums at Channel 9 contain a thread regarding this very issue and someone was kind enough to list the line numbers that need to be changed.

    Here is a link to the channel 9 forum post describing the changes required:

    http://channel9.msdn.com/ShowPost.aspx?PostID=245923

    I have uploaded a version of the stylesheet that already has the changes made. It may be downloaded here. I have also uploaded the original version in case you need to go back. Save it to your \Program Files\Microsoft Office\Office12\Bibliography\Style directory and you are ready to rock and roll. If you are using Vista, then you may have to delete the old version first and then copy the new one in to have the changes take effect. This has to do with the file system protection in Vista.

    I hope this helps. Feel free to leave comments if you have any questions.

  • Nice Programming Font (Inconsolata)

    I recently stumbled across a new programming font called Inconsolata over at Scott Hanselman's blog.  I typically use Microsoft's Consolas font in all of my development tools, but I think I am going to try Inconsolata for a while and see how I like it.  While the font is still in development, my first impression leads me to believe that it is going to be a significant improvement over the already great Consolas.

  • Vista RC2 and SQL Server Express 2005

    Like many other people I know and read about, I switched my primary production system over to Windows Vista starting with the release of Beta 2.  I spend most of my time in Visual Studio 2005, Office 2007, and a few miscellaneous CAD tools for embedded systems development.  Since the release of Beta 2 I have had very few stability problems and most of my software has worked without issue (with the exception of Camtasia, which I think is a TechSmith problem).

    When I was getting ready to update from RC1 to RC2 I was assaulted with a horrific message, "SQL Server 2005 is not compatible with RC2".  I use SQL Server Express 2005 almost on a daily basis and depend on it for many of my development projects.  The update looked like it could continue and would not uninstall SQL Server Express 2005, so I decided to give it a try and hope for the best.

    During the update I decided to do some reading in the development blogs and found that people were having problems getting RC2 to even allow them to install SQL Server Express 2005.  I did find some people who were able to use it once it was installed though.

    After the update and some more reading I was able to solve the problem and have been using it reliably ever since.  First, the SQL Server service still starts and runs with no errors in the event log.  It seems the trick is to be sure that any application that needs to connect to a database is running as an administrator.  This includes Visual Studio 2005 and SQL Server Management Studio.  For development purposes this is not a problem and has worked great in my environment.  Obviously you would not want to deploy a system with this constraint, but there is probably some subtle permission that needs to be assigned in order to solve the problem, and running as an administrator fills that need.

    My opinion is that MS probably is not supporting SQL Server 2005 on RC2 because of the inherent security issues related to requiring all connecting applications to be running with elevated rights.  I would have made the same decision.  However, in a development environment where the user knows what they are doing, the security issues are almost nonexistent.

    Microsoft has some documentation on their SQL Server web site, while not specific to RC2 it is helpful for troubleshooting.

    On a final note, I would like to say that it is my opinion that Vista is the best operating system to date.  The Aero Glass and other UI enhancements are just fluff, the real achievement is the underlying kernel and all of the new subsystems (UAC, file system, indexing, networking, etc.).  This is an OS that is a decade ahead of anything else currently available.  Good job Microsoft developers!

  • Java Concurrency API Example

    Download the example code.

    I was asked to put together some teaching materials for a Data Structures class as the second part of their introduction to threading.  I decided to go ahead and jump right in to the Java Concurrency API and needed a simple example to illustrate the concepts.  I adapted this from an example in their textbook (not sure about the authors name), although no code actually remains from the author.  It is a problem domain that they where already familiar with, animated sorting algorithms.

    The idea is that there is a set of data that needs to be sorted.  A user interface displays this data while it is being sorted by some sorting algorithm running in a separate thread (i.e. two threads running concurrently with shared data).  This raises the question of data protection and synchronization.  This also provides a way to illustrate the benefit of separating presentation logic from application logic.  Here is what the application looks like (sorting data on the left, sort completed on the right):

     

     

    At the core of the example are the classes SortAlgo and SortDisplay, which are intended to share a common instance of the Data.  In order to have the ability to compare sorting techniques, the sorting algorithm's Call() method times how long it takes to sort the data and returns the sort time once sorting has completed.  The SortDisplay's Run() method continuously updates (redraws) the data display until the SortCompleted(Long sortTime) method is invoked, at which point the Run() method terminates and the display is updated to include the sort time.

     

     

    The Callable<T> and Runnable interfaces are used to indicate that a class has some task(s) that needs to be performed in a separate thread.  Runnable,  around since the early days of Java, states that the implementing class must define a method with the signature public void run().  This method commonly has some time consuming task to perform and then returns or runs continuously, waiting for data to become available, processing it, and then waiting for then next set of data to arrive.  Either way, the run() method typically only modifies data related to the class for which it is defined.

    Callable<T>, on the other hand, is intended for time consuming tasks that return a result.  The sorting algorithm is a perfect example of this kind of task.  It sorts the data (time consuming) and then returns the time it took to sort.  Lets look at what happens if we execute the following code:

     

    SortAlgo sortAlgo = new SortAlgo(data);
    Long time = sortAlgo.call();
    System.out.println("Sort Completed: "+time);

     

    Once we call the sortAlgo.call() method, we are stuck waiting until the sorting completes before we can do anything else.  Because we are implementing the Callable<T> interface, we can rewrite this using the Concurrency API to allow us to do other work while we are waiting for the sorting to complete.  

     
    ExecutorService taskExecutor = Executors.newCachedThreadPool();
    CompletionService<Long> taskCompletionService = 
        new ExecutorCompletionService<Long>(taskExecutor);
    
    SortAlgo sortAlgo = new SortAlgo(data);
    Future<Long> sortAlgoFuture = taskCompletionService.submit(sortAlgo); 
    
    while(!sortAlgoFuture.isDone()) {
        // Do some work...
        System.out.println("Working on something...");
    }
    
    // Sorting is now complete, so lets get the result
    Long time = sortAlgoFuture.get();
    System.out.println("Sort Completed: "+time);

     

    This time, we are never stuck waiting for the task to complete.  That is we can be doing something useful at all times until the data is sorted, at which point we can immediately get the result (the sort time) and move on.  A common use of this kind of API is to maintain a collection of tasks that are being performed and remove them one-by-one as they are completed.

    Download the code and examine the interactions between the SortAlgo and SortDisplay classes.  Thread synchronization (data protection) is attained through the use of the Lock class.  The students in our Data Structures course where assigned the task of taking this code and extending it to handle multiple sorting algorithms (think inheritance and abstract classes) and to be able to dynamically wire up multiple data, sorting algorithms, and sort displays from a GUI.  This is a good exercise if you wish to gain a better understanding of the Java Concurrency API.  Also, examine the short FutureCallback<T> class in the example archive, which combines reflection and the concurrency API to produce a very handy utility class.

  • Implementing a Presentation Layer Using ASP .NET 2.0 And Visual Studio 2005 (Screencast)

    This screencast walks through the use of Visual Studio 2005 and ASP .NET 2.0 to implement a presentation layer. Web services are consumed from a Business Layer.

    <a href="http://www.cs.appstate.edu/~cce/feeds/content/DotNetPresentationLayer/DotNetPresentationLayer.wmv"><img src="/apps/cs/Themes/default/images/video.gif" border = "0" width="640" height="480"></a><br /><a href = "http://www.cs.appstate.edu/~cce/feeds/content/DotNetPresentationLayer/DotNetPresentationLayer.wmv">View Video</a><br />Format: wmv<br />Duration: 01:15:57

  • Implementing a Business Layer Using .NET 2.0 And Visual Studio 2005 (Screencast)

    This screencast walks through the use of Visual Studio 2005 to implement a business layer. Web services are consumed from the Data Layer, business logic is implemented, and services are then exposed for consumption by the Presentation Layer.

    <a href="http://www.cs.appstate.edu/~cce/feeds/content/DotNetBusinessLayer.wmv"><img src="/apps/cs/Themes/default/images/video.gif" border = "0" width="640" height="480"></a><br /><a href = "http://www.cs.appstate.edu/~cce/feeds/content/DotNetBusinessLayer.wmv">View Video</a><br />Format: wmv<br />Duration: 55:05

  • Implementing a Data Layer using .NET 2.0 and Visual Studio 2005 (Screencast)

    This screencast walks through the use of Visual Studio 2005 and SQL Server Express 2005 to create a data access layer.

    <a href="http://www.cs.appstate.edu/~cce/feeds/content/DotNetDataLayer.wmv"><img src="/Web/Themes/default/images/video.gif" border = "0" width="640" height="480"></a><br /><a href = "http://www.cs.appstate.edu/~cce/feeds/content/DotNetDataLayer.wmv">View Video</a><br />Format: wmv<br />Duration: 1:21:30

  • The Stamp Controller Interface Board and the BS2e

    I was recently working a project that was based on Parallax's industrial Stamp Controller Interface Board and the BASIC Stamp 2.  We needed to upgrade the system to use the more robust BS2e microcontroller and were told by Parallax support that this was no problem.  We received the new parts and began testing the setup only to find that the line drivers where not supplying enough voltage on logic high (only 1.5v) to trigger the BS2e's input pins (when it had worked fine with the BS2).  After talking numerous times with Parallax support we came to the conclusion that there needed to be a pull-up resistor soldered to the boards prototype area.  A 5.6k-Ohm resistor between each input pin and +5v seemed to do the trick.  While this worked, I was not very happy with the solution.  The problem stems from the fact that the BS2 is based on the PIC microcontroller and the BS2e on Ubicom's SX chip.  When I asked if they where going to update the board design to resolve this issue, tech support said that they where not because the person who originally designed the board is no longer at Parallax.

    Parallax has a great line of very professional products, and I was surprised by this undocumented incompatibility between the BS2e and the Stamp CI board.  While most people would argue that soldering a few pull-up resistors on a board is no big deal, it is really something that should have been included in the PCB design.  In a production environment, it is a time consuming step that increases the overall cost of a system and adds one more possible failure point.

    I would like to add that I have a high regard for Parallax products, but this issue has forced me to have second thoughts regarding my decision to design a production system based on their products.  In the future, I will probably go with a more traditional approach such as the Motorola line of microcontrollers.

  • Software Flow Control on the BASIC Stamp 2

    Most BASIC Stamp carrier boards include a DB-9 connector for programming the microcontroller and for performing simple debugging.  Unfortunately, only three pins are actually connected to the DB-9: TX, RX, and ATN (for programming).  This severely rules out any possibility for hardware flow control.  Last year I needed to communicate with a device that was much faster than the little BS2 microcontroller, and implementing some kind of flow control was the only way to keep from losing bytes.  After a decent amount of reading about flow control and RS-232, I came up with the following solution.

    I enabled XON/XOFF software flow control on the fast device, and then manually sent the XON and XOFF bytes from the BS2 when I was ready to read bytes.

     

    SoftwareFlowControlExample.bs2

    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    '
    ' Software Flow Control Example Snippit
    '
    ' This example lays out the basic framework for implementing software
    ' flow control on the basic stamp.
    '
    ' Author: Christopher Chess Ellsworth
    '
    SerialInPin      CON    16
    SerialOutPin     CON    16
    
    T2400            CON    396
    T19K2            CON    32
    T38K4            CON    6
    Inverted         CON    $4000
    Baud             CON    T2400 + Inverted
    
    'Timeout for reading from the serial port
    SerialInTimeout  VAR    Word
    SerialInTimeout = 1000
    
    command          VAR    Byte
    
    Init:
      'Tell the host that we are not ready to recieve data
      GOSUB X_OFF
    
    Main:
      GOSUB Read_Message
      'Do something if command is not 0
      'SELECT command
      'ENDSELECT
      GOTO Main
    
    'Read a message from the server machine.
    Read_Message:
      GOSUB X_ON
      SERIN SerialInPin, Baud, SerialInTimeout, Read_Message_Time_Out, [command]
      GOSUB X_OFF
      RETURN
    'END Read_Message
    
    'If no message can be read from the serial port.
    Read_Message_Time_Out:
      GOSUB X_OFF
      command = 0
      RETURN
    'END Read_Message_Time_Out
    
    'Send software flow control bytes
    X_ON:
      SEROUT SerialOutPin, Baud, [17]
      RETURN
    
    X_OFF:
      SEROUT SerialOutPin, Baud, [19]
      RETURN
    

    The solution worked for me, although it was a fairly unique chain of devices I was talking to.  Please let me know if anyone has any thoughts on this technique.

  • Introduction to XML Web Services (Video Podcast)

    This introduction to XML Web Services examines the standards which make up the Web Service specification, how Web Services enable the Service Oriented Architecture, and walks through the development of a simple Web Service using Java and the Eclipse IDE.
  • Consuming Web Services in C++ and Visual Studio 2003

    This tutorial walks through the process of consuming an XML Web Service using Visual Studio 2003 and C++.

    Download the source code for the example.

    <a href="http://www.cs.appstate.edu/~cce/feeds/content/Consuming_CPP.wmv"><img src="/apps/cs/Themes/ccetheme/images/video.gif" border = "0" width="640" height="480"></a><br /><a href = "http://www.cs.appstate.edu/~cce/feeds/content/Consuming_CPP.wmv">View Video</a><br />Format: wmv<br />Duration: --:--

More Posts Next page »

Locations of Visitors

Locations of visitors to this page
©2007 Christopher Chess Ellsworth