{"id":166,"date":"2011-10-08T20:15:32","date_gmt":"2011-10-09T00:15:32","guid":{"rendered":"http:\/\/www.cloppermillweather.org\/blog\/?p=166"},"modified":"2011-10-09T09:02:54","modified_gmt":"2011-10-09T13:02:54","slug":"a-little-more-software","status":"publish","type":"post","link":"https:\/\/www.cloppermillweather.org\/blog\/2011\/10\/08\/a-little-more-software\/","title":{"rendered":"A Little More Software"},"content":{"rendered":"<p>I couldn&#8217;t resist.\u00a0 I just had to do some more work on the Web site.\u00a0 Actually, there was a glaring bug I felt compelled to address.\u00a0 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.\u00a0 I did that for expediency, but it is the wrong way to do things.\u00a0 The bug was that sometimes the files were copied while the weather station software was in the process of writing them.\u00a0 This resulted in incomplete files being transferred occasionally.\u00a0 The correct way was to open a TCP\/IP connection to the weather station and ask for the data.\u00a0 That way the station software could control concurrent access to the data.\u00a0 Another benefit is that the data returned is in XML format.\u00a0 One of the log files was being transferred as a binary file.\u00a0 Having it as XML makes it much easier to parse in PHP.<\/p>\n<p>I wrote a small Java application to connect to the weather station and retrieve the data.\u00a0 Then I transfer that data to the Web site so that the PHP scripts can parse, format, and display it.\u00a0 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.<\/p>\n<p>Next I completed the display of the weather station history information.\u00a0 That was one of the largest outstanding items left on the Web site to do list.\u00a0 Not very difficult to program, now that I have the data in XML format.\u00a0 I also made a few modifications to the pages that use data not generated by the weather station.\u00a0 I had been using wget in a script running from cron to retrieve that data on a periodic basis.\u00a0 I modified the PHP scripts that parse that data to retrieve the data on demand and store it locally.\u00a0 Once the data becomes stale, they retrieve a new copy.\u00a0 That keeps me from needing the cron script at all, and also prevents the script from retrieving the data too often.<\/p>\n<p>Finally, I created common files for the header, footer, and navigation.\u00a0 This is something I&#8217;ve wanted to do for some time now.\u00a0 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.\u00a0 This fix was long overdue, and the reason I didn&#8217;t start out this way was that straight HTML doesn&#8217;t provide a good mechanism for doing this, and the template I started with didn&#8217;t split out these pieces.\u00a0 Hopefully these changes will make my life easier.\u00a0 I still need to rewrite some of my astronomy calculations from Java to PHP.\u00a0 But I really need to get the hardware finished.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I couldn&#8217;t resist.\u00a0 I just had to do some more work on the Web site.\u00a0 Actually, there was a glaring bug I felt compelled to address.\u00a0 Instead of playing nice and asking the weather station to supply the weather stats &hellip; <a href=\"https:\/\/www.cloppermillweather.org\/blog\/2011\/10\/08\/a-little-more-software\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-166","post","type-post","status-publish","format-standard","hentry","category-weather"],"_links":{"self":[{"href":"https:\/\/www.cloppermillweather.org\/blog\/wp-json\/wp\/v2\/posts\/166","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.cloppermillweather.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cloppermillweather.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cloppermillweather.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cloppermillweather.org\/blog\/wp-json\/wp\/v2\/comments?post=166"}],"version-history":[{"count":0,"href":"https:\/\/www.cloppermillweather.org\/blog\/wp-json\/wp\/v2\/posts\/166\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.cloppermillweather.org\/blog\/wp-json\/wp\/v2\/media?parent=166"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cloppermillweather.org\/blog\/wp-json\/wp\/v2\/categories?post=166"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cloppermillweather.org\/blog\/wp-json\/wp\/v2\/tags?post=166"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}