Client Project - ConnectWise Mobile
A couple of years ago, I was contacted through a current client that they had a "Fun Project" to work on, normally when I here this I go running for the hills! This one was different, ever since my early days as an embedded systems programmer, I had a passion for mobile devices. I've always played around with these technologies since early Windows CE devices but as in this post until the last couple of years the hardware and development platforms just weren't out there to realistcally do anything but non-trivial apps without a very significant development effort. The application was for a company that has a professional services automation tool and is called:

Once I completed the initial requirements gathering and design, this application started out life as a Compact Frameworks 1.0 application on Windows PPC 2003 using SQL Server CE. It currently runs on the Compact Frameworks 2.0 on Windows Mobile 5.0 and I will be attending MEDC 2007 to learn about any changes required or new capabilities offered in new framework to be offered later this year. Along the way I converted CFNunit to work with the Compact Frameworks 2.0 and add a little more functionality on the PC for running these tests. I also learned a ton about what it takes to make a PPC CF application work without a stylus, this doesn't really come that way out-of-the box. Finally we also have a desktop version of this app using the same Business Objects and Control Library.

This site discusses the features of this application much better than I could do here so check it out!
-ec
It's not a destination, it's the journey
While trying to implement a Project Delivery Optimization initiative, it's not the destination it's the journey. Where you want to get to has a lot to do with where you are. As you set off on the road to "make-things-better" when delivering software you need to look for the right steps to make increment improvements today without limiting your options in the future. The processes and tool you need to take you to the next level will serve as a set of building blocks for the level after that. There is nothing wrong with incremental gains, however as you decide on a process, tool or technology, you should have an understanding of what their limits are what can be done when you hit those limits. For any non-trivial development organization as you achieve your goals, one of the biggest changes you will make will be to the culture of the organization. As you make these changes, you will establish momentum. If a certain process you start has limits that will only take you so far, you don't want to lose all that momentum.

Let's say you establish a project specific initiative, you see progress beyond what you expect. The tools and processes you come up with work like clockwork on that initiative. You want to repeat that on another project so you implement that initiative on the next project. Now you have a couple/few projects working like a well oiled machine. You decide to implement that for the other 12 projects in your area. You do this, however you see that things are starting to slip and you aren't seeing the improvements in efficiencies you expect. What happened? Maybe the initiative you implemented works well at the tactical project level but not at the strategic organizational level. The way this initiative/tools work doesn't take into account any additional commitments beyond the project level and there is no way to change that. You've made gains but now you are at a dead end and changing course could mean starting from scratch. If you start out with the strategic end in mind and keep that in mind while making tactical maneuvers your journey toward the utopia of project delivery execution will be much smoother!

Have you ever made any decisions that where absolutely the right decision at the time, however as time went on you find that the investment you made in that decision limited any possibility for future growth without significant pain?
-ec
Microsoft Robotics Studio Communications Protocol
Ah – the weekend, time to do a little coding for fun! One of my on-going projects it to build out the functionality of my latest robot NiVek I. Although the robot itself has a little computer it doesn’t have much of a user interface, that is provided via a PC. Therefore for the PC to configure and display the telemetry from the robot a communications channel needs to be established.

There is a cool little card that you can get at Parallax called the Embedded Blue transceiver, this little devices takes TTL (+5v) level signals from a microcontroller and allows for serial communications with another BlueTooth device (such as a computer). So I can hookup a couple lines on my Javelin Stamp chip to the Embedded Blue device, then establish a BlueTooth connection and it’s just like having a two way serial cable between my computer and the robot, very nice!

Now that we have our serial link we need a nice general purpose (and simple) protocol to exchange data. In a past life I worked on a lot of embedded systems that needed to talk to the outside world. This is very similar to what I wanted to do with my robot. Here’s what I came up with.
<STX> - Start of Transmission Character (0x03)
<LEN_MSB> - Most Significant Byte of the size of the data packet.
<LEN_LSB> - Least Significant Byte of the size of the data packet
<DEVICE_TYPE> - Single byte that identifies the device (Enum type in C#)
<DEVICE_ID> - Since there may be many of these devices, we have a simple numeric id
<DEVICE_ACTION> - An additional byte that describes the action (Also an Enum type in C#)
<PAYLOAD> - An additional set of bytes that represent any data to be passed.
<CHECK_SUM> - A single byte check sum to validation the message
<ETX> - End of Transmission character (0x04)
Once we’ve defined this protocol, two chunks of code need to be written on each device that will be “talking”. We need some simple methods to build up the packets. We also need a simple state machine that will look at the bytes coming in on the serial port and build up these packets.
On the PC side, a simple state machine was built that progresses through each of the bytes from the serial port, once the ETX is received, an event is fired to pass the message to host that decides how to handle the message. Creating the new packets to send is even easier, it’s just simply a static method that takes the DeviceType Enum, DeviceId, DeviceAction Enum and Payload and constructs a byte array. Once complete that byte array is then dropped into a queue to be sent out on the serial port.
For my Java robot, our options are fairly limited, the Javelin is a cool little chip however the Java Interpreter is not very complete, no Garbage Collection and no real multi-tasking. So here I did kind-of a round-robin type of thing where I have a main program loop, then I established the different services such as checking the sensors, checking the in buffer, performing actions etc.. One of those tasks was to check the serial port in buffer for new characters, if new characters are available, they are parsed via a state machine, once a message is complete it's dropped into a queue. Then when the main loop checks the queue it pulls out the message, and based upon the DeviceType, it just hands the message off to the Java class that handle that device in a nice clean Handle Method. Sending out a message isn't all that clean but since the Serial UART built into the Javelin chip works in the background it may not be that bad. Basically each device calls a method on the Communications interface within the program to just dump the bytes into the output buffer that follows the protocol defined above.
If anyone is interested in getting a copy of this code, just drop me an email.
-ec
Exploring SharePoint 2007 with PowerShell
The more I work with SP2007, the more I get pumped about the technology. Although there is a lot you can do right out-of-the-box, the programming model behind this really allows it to be a great framework for any development platform.
To get started programming, you probably want to get an idea of how the Object Model works, a real simple way to do this is with PowerShell. I have an SP2007 dev server I setup that I installed PowerShell & PowerShell IDE on. Once you do that, just get a hold of the SP2007 SDK documentation, this will give you an idea of the structure of the Object Model then start playing! The following screen shot should be enough to get you going:

Obviously this same concept would work to exercise any object model!
Enjoy!
- ec
Developer Efficiency
At the very essence of what we do as technical developer folk is take the needs of our business stake holders and turn those into 1's and 0's (and maybe in our lifetime we might figure out how to get 2 ) that business stake holder can run as software on our computers. Any thing else is pure rubbish!
So what are the attributes of an efficient coder?
Technical Aptitude
This is a baseline of becoming an efficient coder, when it's all said and done you must have a certain level of Technical Aptitude, that's not to say you need to be a "Rocket Scientist" however you should have certain skill such as problem solving, a general nature to ask "hmmm...I wonder how that actually works?" or "boy that sure is some cool technology, I wonder if I could build that?". I think this is something you either have or you don't. Not having it is not a bad thing it just means this type of work may not be a good fit. I know any time I try to do something creative with any sort of graphics problem, I can spend 3-4 hours on trying new things and in the end it probably looks worse that when I started. This isn't a bad thing, but the sooner you can recognize your weaknesses, the sooner you can find other people around that complement your strengths that make up for those weaknesses.
Memory
As a developer there are just too many different technologies that could be implemented to solve a problem, too many Languages and API's to learn, too many object models, too many command prompt arguments and keywords, you get the idea. The more of these you can stash away and bring to the fore-front when necessary the quicker you can continue developing and not doing discovery.
Perceptiveness
Being able to read between the lines and think to a long term strategy is important when developing your solutions. I see Software Development as chess match. At any given time you are presented with a certain set of facts or knowledge, each time you sit down to design/code the moves you make have a major impact in how the pieces get moved and sets you up for your next designing/coding session. I've just seen too many software efforts take the fundamentally wrong approach early on, and those projects never really recover. Although an extreme example, let's say you wanted to write a simple contact manager, do you think you would start writing this in Assembler? How about some sort of auditing function where a copy of all items was made into a database every 15 minutes, then a process was run to detect and report on changes, this was a real world scenario where a developer worked on getting this process working for about four weeks, and never did...the efficient coder made the correct chess moves and had implemented in an afternoon. I see this is a very common problem in software development. Do you start coding before you have a true understanding of the problem you are trying to solve?
Attention to Detail
This is a really hard one for me, coming up with creative solutions and looking at the big picture sometimes blurs some of the details. What's interesting is that when I'm doing low-level programming such as embedded systems development, my eye for detail is very sharp...go figure...to be a efficient coder means developing system with little or no bugs. The challenge here is that if you pay too much attention to the details, you may loose site of the big picture. Coding something that implements the fundamentally wrong solution even if perfect and bug free is worth little to no value. I think this is one of the bigger areas where we can use technologies, tool and processes to improve our efficiency. After all computers aren't very good at creativity however they are extremely good at the details.
Experience Level
I think by far the biggest impact on this ratio is the experience of the person doing the development. This experience is not just in the actual programming languages such as Java, C, C++, or the Software Development Life Cycle/methodologies, but to an even greater extent programming a wide variety of business processes. Just as with software, certain things can be "abstracted" the same is true with business processes. This experience also helps facilitate the conversations with the business stake holders, the more you understand about business in general, the more time you can more quickly get to the specifics of what makes this problem unique.
Experience only comes with time. You can do certain things that may not seem that important, but really are. There is no substitute for spending time with the business stake holders even is you just sit in the room and not contribute anything. That is not to say they should have a direct line or to influence your day-to-day scheduling. But as a manager early on, I used any possible opportunity to get the developers in a room with the stake holder. When doing embedded systems work it was always a good reminder going to the field and realizing that in the real world when my software is working it's not just a little LED that comes on at the right time but it's actually a 20 ton rock crusher that would be very bad if it came on at the wrong time. It puts everything you do in a different perspective. How often do you have actual conversations with your business stake holders?
Passion
What really differentiates you as an "efficient coder"? Do you really just plain and simple love what you do? Or are you just coding to pick up a paycheck? Life is just too short to spend the majority of it working in a job just to pickup a paycheck. If at a certain extent you have qualities mentioned above and your are passionate about taking the needs of the business stake holders and turning them into the 1's and 0's in exactly the right order as efficiently as possible (what ever that means on your particular effort) the chances of you being an "efficient coder" are pretty good!
Are you an "efficient coder"?
- ec
Mobile Device Ramblings
Since my days of writing code for embedded systems in the early 90’s I’ve always had a soft spot for mobile devices. My first experience writing code for mobile devices was a floating point library I created for the Palm OS for a time tracking application, this was a small C library, nice concept but I just don’t think it reached the fullest potential, next was in 1998 with my first HPC or Handheld PC running some early version of Windows CE, with a fold out keyboard and a of low resolution LCD black and gray display. At the time we used embedded VB to write applications; it was fairly painful to write anything but the smallest applications, these devices never really took off. Next was a collection of “smart-phones” with PDA like functionality, some had development kits but again these were very painful and you really couldn’t do too much other than manage lists and appointments. Then around 2001 the world was changing for mobile devices with a new technology called WAP or wireless application protocol, the idea here was really cool, define your application in a set of XML documents using the WAP standard and it would run on any device that supported a WAP browser. Well I learned the technology, built a few proof of concepts systems, but in the end this technology just didn’t turn into anything real. An interesting side note on this is that although WAP seemed and still seems like a great idea, most phone or mobile device that people do “web-stuff” these days really have a full feature browser built in so all the experience learning WAP probably provides less than significant value today.
Fast forward to 2003, hardware is really coming of age and cellular technology is starting to provide solutions for wireless wide area networks that are usable. These are built into phone and cards that fit in your computer that act as modems as well as a new hybrid technology called the “Smart Phones” that not only provide voice service, but a platform for developing non-trivial applications. So now we have devices that have decent computing power as well as some sort of connectivity. With PDA’s up to this point some sort of external connectivity was required to synchronize data, now we have a device that can not only access web sites via built on browser functionality, but when networks are available they can synchronize data with the server to keep their data fresh. I’m not really so much a Microsoft Bigot, but that is where the majority of my experience is so I can speak to that. With the release of Windows Pocket PC 2003 and Pocket PC 2003 Second Edition and the Compact Framework we started to have a good platform where it made sense to develop business applications on a mobile application (this was possible before, but using tools like eVC++ and Embedded visual basic, the eVC++ probably really good at creating small, yet industrial strength PPC apps and Embedded VB…well lets just not talk about it…)
So although the Compact Frameworks application was definitely a 1.0 release it did provide the basis to build real applications, in addition if you needed a non-trivial data store, SQL Server CE was an excellent solution, although it’s footprint was small in relative terms, it wasn’t really all that small and with limited amount of RAM on the device it wasn’t always the best solution. With the release of the .NET framework 2.0 came the Compact Frameworks 2.0 and around that time Windows Mobile 5.0. The compact framework 2.0 was much “tighter” than the 1.0 release but to develop a real world class application you still needed to get down and dirty and do a lot of tricks to get it to do the things you want. I’m confident with the next major release, this will become a fairly mature product at the same time the mobile operating systems based upon Windows CE. In addition each year the devices provide more capability in terms of built in RAM, display resolution and processing speed. Finally bandwidth provided by mobile carrier is increasing with each year so it looks like these devices are coming of age where it makes sense to seriously start putting business application onto these devices…
Saying that…
Let’s discuss a little bit about what type of application is a good candidate to build on a mobile device and what type isn’t....
What is a good candidate for a Pocket PC application? A good candidate for an application is one for users that have a really busy schedule that require work to be performed at many different locations. As good as a user interface is on a mobile device, the capabilities that are on a more robust set of hardware such as a laptop just aren’t present. In addition the information that can be conveyed to the user is also fairly limiting. Leaving out the obvious solution of calendaring/scheduling an excellent application for a mobile device is email. With this type of application you really don’t have to perform many steps, lookup significant data, you just really want to exchange a little bit of information back and forth as efficiently and quickly as possible, you want to do it efficiently in that you don’t spend 2 minutes or even 15 seconds using the application, you want to do it quickly in that if you get an email, you would like to respond within a short amount of time (like 5 minutes). Yes this could be done with a phone call, but if you are in the middle of a task, you may need to spend an extra 2 minutes completing it before you want the interruption of doing your end of the communications, by that time the original person has moved on and you may be interrupting them. I guess you would almost call this a vehicle for asynchronous communications. So now let’s think in terms of a busy remote worker with many tasks to be performed at multiple locations. What can we do to empower these types of worker with the information they need and the capability to provide real time feedback to some sort of coordinator? Well it depends, if the system would need something like...where they need to be and when they need to be there and their schedule doesn’t change that much, I guess they could just print out their schedule in the morning (or synchronize with a server in the morning) and that would be adequate. There are two or three areas where building an application may make sense:
- They need more than just the schedule, this could be any detailed instructions of what they need to do, any past work that has already been performed, contact information etc...
- When they perform the work (drop off a package, pick up a vehicle or similar, some central coordinator needs to know about it. 3)
- Once they begin their day, their schedule may need to be flexible.
So now revisiting the idea of an asynchronous vehicle for communications we can start thinking in terms of good candidates for mobile applications…well not yet, the other thing we need to think about is the capability of the device for interacting with users (at least until we can take voice interactions to the next level). Right now a 2x3” screen with a stylus just isn’t the right answer for all but a certain class of applications. I recently developed an application for a IT dispatching system that this is a great fit, but for someone like me that needs to have multiple and sophisticated "conversations" with technology it just isn’t all that efficient. So the answer for determining the right cutoff for a mobile application might be the volume, length and the sophistication of the conversation between the user and the application. So for a delivery driver where they could do a lookup of on a map, get directions, drop the package off, possibly get a signature, send that information about the coordinator, we have many small non-sophisticated conversations with a device. For a developer fixing bugs, let’s say they fix 5-6 bugs a day, their conversation may be extensive if they enter notes but the key factor here is once they open their device get to where they need it is probably quicker to just do this on their desktop. In addition the developer probably will enter some notes, until we come up with a reliable voice solution this will never be perceived as simple on a device.
-ec
Custom WebParts in SharePoint 2007
Creating a custom WebPart in SharePoint 2007 isn't all that terribly difficult, just a few basic steps that may not be completely obvious...in addition if you want to deploy your WebPart on SP 2007 it may contain some additional resources such as gif's or java scripts. Wouldn't it be nice if you could just deploy one assembly with everything you need? Well that's possible so let's do that as well...
- To start out, just create a new VS.NET 2005 class library project and add a reference to "System.Web".
- Go ahead and setup a reasonable sounding Assembly Name and Default NameSpace, these will be important when registering your component with Share Point 2007.
- While your are changing your project settings, find the Signing Tab and make sure "Sign the assembly" is checked. You will then need to go ahead and create a new KeyFile. So far straight forward right?
- Now let's add our web part, to do this simply add an class to your project.
- The code in your web part should look something like Not a example of good coding but that isn't the point
:
using System; using System.Runtime.InteropServices; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Serialization; using System.Reflection; using System.Data; using System.Data.SqlClient; using System.ComponentModel;
namespace SoftwareLogistics.SharePointTest {
[ Guid("72a24b71-f3a9-4fee-9272-4f3c27c87559")] public class SampleSP2007Part : System.Web.UI.WebControls.WebParts.WebPart { System.Web.UI.WebControls.DataGrid grdTime;
protected override void CreateChildControls() { Image img = new Image(); img.ImageUrl = Page.ClientScript.GetWebResourceUrl(this.GetType(), "SoftwareLogistics.SharePointTest.Images.Target.gif");
grdTime = new System.Web.UI.WebControls.DataGrid(); string dsn = "server=??????;database=??????;user id=????;password=?????";
SqlDataAdapter da = new SqlDataAdapter("select top 5 * from usv_time_tracking order by start_date desc", new SqlConnection(dsn)); DataTable tblTime = new DataTable("My Time");
da.Fill(tblTime); grdTime.DataSource = tblTime; grdTime.DataBind();
Controls.Add(img); Controls.Add(new LiteralControl("<br/>")); Controls.Add(grdTime);
base.CreateChildControls(); }
protected override void Render(HtmlTextWriter writer) { writer.Write("<h4>Hello World!</h4>"); base.Render(writer); } } }
Before installing this to SharePoint 2007, let's complete this section by talking about what we need to do to embed the resources with the assembly.
- Create an Image directory within your project and copy the Image there:
- You can see that the name including the NameSpace is "SoftwareLogistics.SharePointTest.Images.Target.gif" (Case is important here)
- Once you copied the image there you need to make sure you click on "Properties" and then set the Build Action to "Embedded Resource" for Target.gif, very important to do this...
- Now open up your "AssemblyInfo.cs" file that is in the Properties folder of your project. Add a line to it similar to
[assembly: WebResource("SoftwareLogistics.SharePointTest.Images.Target.gif","image/gif")
-
You will also need to add using System.Web.UI; to the top of your AssemblyInfo.cs.
-
Finally in the code you can set the url of the image as: img.ImageUrl = Page.ClientScript.GetWebResourceUrl(this.GetType(), "SoftwareLogistics.SharePointTest.Images.Target.gif");
Now your assembly is ready to go all you need to do is turn that into and assembly and your are ready to incorporate it into your SharePoint 2007 site, you can even us this as a WebPart or even a standard Server Control on any ASP.NET 2.0 site.
To install the the component on the SharePoint2007 server you need to do the next couple of steps...
- First we need to get our component into the GAC so just drag it into the file pane for Windows\Assembly, you can see the my file here:
- Make a note of the Public Key Token, you will need that to register your part with SharePoint, you can also right mouse click on the assembly click on Properties and copy the Pulbic Key Token from there.
- The final step to make it appear as a "potential" web part within SharePoint is to register the component in the Web.Config file. So find Web.Config for the SharePoint instance you want this work with and open it in your favorite XML editor.
- Find the section labeled "SafeControls" and add the following line (you can always just copy one of the existing lines and fill in your information.
<SafeControl Assembly="SoftwareLogistics.SharePointTest, Version=1.1.0.0, Culture=neutral, PublicKeyToken=8220d66cd77f3b8d" Namespace="SoftwareLogistics.SharePointTest" TypeName="*" Safe="True" />
At this point SharePoint knows about your WebPart, but you'll need to make it part of the Gallery so open up your SharePoint site and do these final steps
- Click on "Site Actions" and then "Site Settings"
- Within the "Galleries" section click on "Web Parts"
- Click on New, if all went well you should see the part you created within the list, if you don't see it there, go ahead and reset IIS.
- Put a check mark next to your new web part and then click the "Populate Gallery" button.
At this point your web part is ready to be included just like any other WebPart.
Happy Coding!
- ec
SharePoint 2007 - It's finally all coming together!
I remember in the very early days of .NET they had a cool demo of how to build a portal in ASP.NET, this was called "I Buy Spy" from what I understood went on to be DOTNETNUKE, I was excited about the concept of configurable content within the portal, it had all the right concepts, adding tabs, little widgets you could configure etc... These were really just Web Controls (ASCX) or Server Controls (compiled DLL's). My third version of "The Chaos Filter" used this concept extensively.
Then with ASP.NET 2.0, they introduced the concept of WebParts, this was nice however you had to build up a set of scaffolding and use the provider model to use these within your site (at least as pure web parts). Not terribly difficult but it limited your deployed options. At the time SharePoint 2003 had something called "WebParts" as well, extremely similar in both appearance and function, however these "WebParts" were not the same thing as those created with ASP.NET 2.0. Very disappointing (and confusing), SharePoint 2003 web parts actually came out first, and I assume that Microsoft kept the name since it seems to fit this concept so well and the intent with ASP.NET 2.0 web parts was that they would work with SharePoint 2007.
Version 3.0 of the product really defined and flushed out the data model and workflow engine however, I just wasn't very happy with the presentation layer in ASP.NET 1.1 using the ASCX's and custom controls. With the introduction of the ASP.NET 2.0 I started on version 4.0 of "The Chaos Filter", this time I focused on an architecture that was built from the ground-up to use web parts and leverage the existing data model and workflow concepts that make the Chaos Filter unique. This architecture relied heavily on code generation from a product called CodeSmith, templates where created to not only create a simple DAL that mapped to tables in the database, but it also created two web parts (master/detail) for each tables. This obviously doesn't mean that you can generate 100% of the application, however it does mean that it can very rapidly give you web parts that work out-of-the box that you can customize. Anytime I hear "You can build your hole site in just three lines of code" my spider senses tell me to watch out! This solution is really intended to put in place the framework and plumbing that you can open up in your development environment and make it do something useful.
So here we are, SharePoint 2007 was released last November, what does this give us that we really didn't have before? We now have the ability to easily create little "chunks" of functionality in the form of "WebParts" that can be wired up to create applications. So with the data model defined in V3.0 of my product, the architecture to include code generation defined in V4.0 of my product, and a mature framework in SharePoint 2007, it's time to start figuring out how to package these concepts into something that will provide value.
-ec
NiVek 1
Over the weekend I finally had a few hours to get all the basic functionality working on my latest robot "NiVek I"

I'll be doing some additional posts along with some source code, but below are some of the cool features
Hardware
- Traxster Chassis and Turret from Robotics Connection
- Main Board and Turret boards I designed and had manufactured by PCB Express based upon the Parallax Javelin Stamp a PIC processor with additional RAM/ROM that has a built in Java Interpreter
- Bluetooth Communications via Embedded Blue transceiver
- I2C bus driven by the Javelin Stamp
- GPIO14 General Purpose IO A/D & D/A on the I2C bus
- SD20 20 port Servo Control on the I2C bus
- 3 Sharp GP2D120 IR Sensors mounted on the turret
- 2 Ultrasonic sensors one mounted on the turret and another mounted on a servo to allow panning at the rear of the robot
- Speech via Daventech SP03 Text to Speech Synthesizer on the I2C bus
- CMPS03 Daventech Compass
- Optical Wheel Encoders
- MotorMindB DC Motor Speed Controller
- 2 laser pointers mounted on the turret for range detection (this will be a great post once I work out the details)
- GrandTec Wireless Web Cam mounted on the turret
- 2 x MC24LC256 256K I2C Serial CMOS EEPROM
Software
- Software on robot written in Java
- Simple <STX><ETX> communications protocol with Device Type, Device ID, Device Action and Payload along with a Check Sum communicating from the robot to a C# application via BlueTooth
- Although the first version of the controller application is a C# Win Forms application the Communications Library is setup to create Microsoft Robotics Studio Services (when time permits)
- The following features are controlled via the existing console
- Motion Detection Algorithm on Web Cam Input
- Drawing heading on web cam input
- White half moon displays ranges from three IR Sensors on turret
- Turret Pan & Tilt controlled via sliders
- RGB Display used for turning laser detection algorithm (range finding)
- Motor Controls via slider
- Speech Control

There just aren't enough hours in the day to do all this fun stuff!
- ec
Backup Strategy with PowerShell and ntbackup
About once a year, I spend about a day going doing preventative maintenance on my development servers. Today is that day. I've had basic backups being done via a scheduled task an NTBACKUP, these seem to work, but luckily I've never needed them. What I didn't like was that although my SQL Server backups send me emails I look for each morning, my file backups didn't. I did a little research on some programs out there, anything that I would trust for this kind of stuff seemed rather expensive so I decided that I could take this opportunity to learn Windows PowerShell and create my own little backup strategy...disclaimer, although this process seems solid, in no-way-shape-or-form will Software Logistics be liable if you attempt to mimic this process and for some reason you may loose data. If you continue on reading, we'll just assume that you'll accept this disclaimer and won't try to take my house if something goes wrong!
Here's my setup...
- I have a Windows 2003 R2 Server acting as my Virtual Machine Host, off of this machine I have a decent 200GB USB 2.0 Hard Drive.
- Download Windows PowerShell 1.0
- I've downloaded the program that helped write my scripts PowerShell IDE there might be something a little better, but this seems to work.
- I already had the backups setup on my SQL & Exchange servers, so on those boxes I created a network share called \Backups.
- Now on my USB Hard Drive I created two directories:
- In the J:\BackupJobs directory I created my Power Shell File J:\BackupJobs\ProcessBackups.ps1
- Then I started to create my script...this really isn't intended as a PowerShell tutorial, but you should be able to get enough out of this to complete your scripts, but basically it does the following:
- Create a new Time & Date Stamp directory like J:\Backup\01272007, this will be stored into a variable called "$BackupPath"
- Create a variable called "$Body" that will be used to hold the log file for all activities, this will be written to disk with the script
- $body | Out-File -FilePath $logFile
- Create a Variable that holds the individual file name like
- $UserBackupFileName = $BackupPath + "\UserData.bkf"
- Now start my backup process
- ntbackup backup "\\sl1\users /J "User Data Backup Job" /f $UserBackupFileName | out-null
- The piping (|) into the out-null will make sure that the process (ntbackup) completes before moving on to the next step.
- Once this completes, I write an entry into the log file with the files names and Paths as well as the completion time.
- I then just complete steps 3-6 for the rest of the directories to be backed up.
- After everything is backed up, I want to do a little cleanup, here's the process there:
- Create a new variable called $OldBackup based upon the current date $OldBackup = Get-Date
- Add -5 days to that via $OldBackup = $OldBackup.AddDays(-5)
- Now create the Path $OldBackupPath = "J:\Backups\" + $OldBackup.ToString("MMddyyyy")
- Now we just make sure it exists if([System.IO.Directory]::Exists($OldBackupPath))
- And if so just blow it away! [System.IO.Directory]::Delete($OldBackupPath,$TRUE)
- Once I do all of this I just send my self an email with log data, something like:
-
$mailServer = New-Object "System.Net.Mail.SmtpClient" $mailServer.Host = "MyMail.Server.Com" $mailServer.Port = 25 $msg = New-Object "System.Net.Mail.MailMessage" $msg.To.Add("BackupAdmin@MyCompany.com") $msg.From = "Backup.Service@MyCompany.net" $msg.Subject = "Backup Completed" $msg.Body = $body $mailServer.Send($msg)
And now my backup is completed!
This was really my first in-depth powershell experience and it wasn't too painful, I'm sure there is plenty of room for optimization but hey it's Saturday and this seems to work!
-ec
Does this only happen to me?
I've been cruising along on all eight cylinders, making sure and steady progress on a chunk of code. I get to the point where I think I've got all the problems solved and want to integrate a bunch of things together and whammo - I get a flat tire...something stupid like my VPN drops, a real slooooowww connection speed where it's painful to do anything or maybe a reference to some library "just" disappears, or my favorite something like "Internal Compiler Error please start Visual Studio". Just as I was ready to pull all the "stuff" together on a project I'm working on today that "flat tire" was all of a sudden my clip board in Vista stopped working...very odd...very frustrating...real momentum killer...
-ec
Filtering a SQL Server Table by content of XML
One of my applications parses custom forms from a web site that are defined by an end user, it then stores the actual content of the form as an XML document in a SQL 2005 database. I recently had the need to write some queries to identify specific records in this table based upon content entered on the form. To do this I needed a "where" clause that would filter the the records based upon the content of the XML. The following solution seems to do the trick:
select FormId from MyForms where FormType = 'MyNewForm' and FormXml.value('if( /root/Field1=200 eq true() ) then 1 else 0 ', 'bit') = 1 and FormXml.value('if( /root/Field2=300 eq true() ) then 1 else 0 ', 'bit') = 1 and FormXml.value('if( /root/Field3=500 eq true() ) then 1 else 0 ', 'bit') = 1
Since our filter arguments (200,300,500) are really passed into and built as part of the string we really can't use a parameterized query, but I think that is probably OK. Since the initial output of the XQuery is XML, we need to convert that to a "bit" field that we can then use to complete our Where Clause
-ec
|