A Little More Software

I couldn’t resist.  I just had to do some more work on the Web site.  Actually, there was a glaring bug I felt compelled to address.  Instead of playing nice and asking the weather station to supply the weather stats and logs, I was copying them directly from the directory where the weather station software stores them.  I did that for expediency, but it is the wrong way to do things.  The bug was that sometimes the files were copied while the weather station software was in the process of writing them.  This resulted in incomplete files being transferred occasionally.  The correct way was to open a TCP/IP connection to the weather station and ask for the data.  That way the station software could control concurrent access to the data.  Another benefit is that the data returned is in XML format.  One of the log files was being transferred as a binary file.  Having it as XML makes it much easier to parse in PHP.

I wrote a small Java application to connect to the weather station and retrieve the data.  Then I transfer that data to the Web site so that the PHP scripts can parse, format, and display it.  I also made sure that the FTP script copies the files using new names, then deletes and renames the file once they have been transferred successfully.

Next I completed the display of the weather station history information.  That was one of the largest outstanding items left on the Web site to do list.  Not very difficult to program, now that I have the data in XML format.  I also made a few modifications to the pages that use data not generated by the weather station.  I had been using wget in a script running from cron to retrieve that data on a periodic basis.  I modified the PHP scripts that parse that data to retrieve the data on demand and store it locally.  Once the data becomes stale, they retrieve a new copy.  That keeps me from needing the cron script at all, and also prevents the script from retrieving the data too often.

Finally, I created common files for the header, footer, and navigation.  This is something I’ve wanted to do for some time now.  That helps to ensure consistency across all the pages, and makes maintenance a lot easier, as I only need to make changes in one place rather than on each page.  This fix was long overdue, and the reason I didn’t start out this way was that straight HTML doesn’t provide a good mechanism for doing this, and the template I started with didn’t split out these pieces.  Hopefully these changes will make my life easier.  I still need to rewrite some of my astronomy calculations from Java to PHP.  But I really need to get the hardware finished.