Saturday, September 5, 2009

Ringing the Bells

Recently we found our selves with a few classrooms that were not connected to the main bell system.  A classroom full of kids watching the clock like a hawk isn't the best thing in the world.  The few precious minutes of class time that is available doesn't need to be wasted clock watching, so they came to us in technology and asked if we could come up with a solution (cheaply).  My knee-jerk reaction was, "Get them all alarm clocks."  After that passed and I thought about it for a minute, an alarm clock didn't sound like a bad idea.  Why not turn the computers in the classrooms into alarm clocks.  They're old and slow, but they do keep time and will play sound.


We (in technology) tried to come up with an idea of exactly what we needed.  Then we set out across the internet looking for the solution.  We needed something that was cheap (free would be best), easy to use, allowed setting multiple alarms, and wrote the alarm settings to some kind of configuration file that we could easily push to the computers.  We found a lot of programs, some of the teachers even pitched in with suggestions, but we couldn't find anything that was a good fit.


Then the old reliable "Scheduled Tasks" came to the rescue.  It was free (comes with Windows), could be easily programmed with a batch file, could run as many alarms as we wanted, and the batch file was an easy way to set the schedule.  For any of you that don't know.  There's a way to set scheduled tasks through the command line, just run "SCHTASKS".  The built help is great and it takes just a few minutes to figure out what it takes to make the bell ring.  Well, it took just a few minutes to figure out that scheduled tasks doesn't include anything to make a sound.  That's ok, we're on a Windows box and we still have the trusty "Sound Recorder" program.  Now we've got the solution, Scheduled Tasks to watch the clock, Sound Recorder to play the sound, and a single batch file to set it all up.


The batch file we used is pretty simple.  Each bell ring gets created by a single command and we just copy that command over and over adjusting the times until we've got all the bell rings covered.  The command looks something like this:

SCHTASKS /create /tn BELL_8_00 /tr "sndrec.exe /play C:\Windows\Media\ding.wav /close" /D MON, TUE, WED, THU, FRI /ST 08:00


That command creates a schedule task that's named BELL_8_00, runs at 8:00AM, silently launches Sound Recorder, plays, ding.wav, automatically closes and runs Monday thru Friday.  Just rinse and repeat with the times for each bell ring that you need.  You can pick any wav file that you know is on the computers.  The key to making it play and close cleanly is the "/play" and "/close" switches on the sndrec.exe file.  


When it comes time to clean this up, it's much simpler command:


SCHTASKS /delete /tn BELL_8_00 /f


The /f forces the command to run, no prompts, no warning, it just deletes the tasks.  Rinse and repeat for each time.


This isn't a perfect solution, there are some draw backs, but it fit our requirements for the time. One problem is that it only allows for on schedule, unless you setup multiple batch files and make sure the teachers get the right ones.  It also doesn't account for activity schedules that occur at random times (like pep rallys or school plays).  And unless the teacher knows about configuring schedule tasks it doesn't give him/her many configuration options.  One solution might be to make a pretty wrapper with AutoIT or VBScript/HTA to allow for customization.  


Another idea that I had is a small program that watches for bell ringing commands from another computer so you can change and adjust the schedules in one spot.  That way each PC is sitting on the network ready to ring at any minute.  I was thinking a small stripped down XMPP client for each PC and a bigger XMPP bot that does the ringing and gets his ring schedule from a GUI that's configured by someone in the office.  That's going to be a project for my spare time.

No comments:

Post a Comment