Sandaysoft

Support forum for Cumulus weather station software
It is currently Sun May 19, 2013 1:38 am
Please click here before posting. Help me to help you!
Useful Links: Cumulus FAQ • Enhancement requests • Wiki (documentation)
Please put your approximate location into your profile
Add your web site to the Cumulus user map
Vantage Pro2 users with firmware 3.00 should upgrade to fw 3.12 and Cumulus 1.9.4

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Saratoga AJAX/PHP Cumulus template updated (CU-defs.php)
PostPosted: Sun Mar 25, 2012 1:48 am 
Offline
User avatar

Joined: Wed May 06, 2009 5:02 am
Posts: 423
Location: Saratoga, CA, USA
Weather Station: Davis Vantage Pro Plus
Operating System: Windows XP SP3
I've added some code to the CU-defs.php, and a new setting in Settings-weather.php ($SITE['overrideRain']) to control display of current conditions when using a METAR as the source ($SITE['conditionsMETAR']).

The overrideRain setting allows your local station rain to override the METAR rain indication (if any) with icon/text as follows:

"Moderate Drizzle" when rain rate is = 0.0 per hour and <#LastRainTipISO> is < 30 minutes ago.
"Light Rain" when rain rate is > 0.0 and < 2.5 mm (0.098 in) per hour
"Moderate Rain" when rain rate is >= 2.5 mm (0.098 in) and < 7.6 mm (0.30 in) per hour
"Heavy Rain" when rain rate is >= 7.6 mm (0.30 in) per hour and < 50 mm (2.0 in) per hour
"Violent Rain" when rain rate is >= 50 mm (2.0 in) per hour

If $SITE['overrideRain'] setting is ommitted from Settings-weather.php, the default will be assumed as 'true' to enable the function.

If enabled, the rain words from the METAR will be removed, and the above words used based on the current rain rate.

We finally had enough rain around here to test out the additions :)

Use the updates page (24-Mar-2012) to get the changed *-defs files (and also support for WeatherCat software that was released today).

Best regards,
Ken


Top
 Profile  
 
 Post subject: Re: Saratoga AJAX/PHP Cumulus template updated (CU-defs.php)
PostPosted: Tue Mar 27, 2012 1:27 pm 
Offline
User avatar

Joined: Mon Dec 20, 2010 12:12 pm
Posts: 446
Location: Palmerston, NT, Australia
Weather Station: WS-1081 with rain gauge mod
Operating System: Windows 7 & 1.9.3 b1059
Well done :). I guess it's easy enough to chance to your local conditions, as 40% of my rain would be heavy, and 50% violent ;) . Had thought about doing a gauge for rain rate, as for most people that are not into it like we are, would not understand how heavy it's raining if the rainrate was 70+mm/hr calculated over 5 mins. They would be like " :? ????". You need a big sign saying "Raining Cat's and Dogs Man!".

_________________
Michael, Palmerston, NT Australia www.Palmerston-WeatherImageNo image? I'm offline!
ImageImageImage


Top
 Profile  
 
 Post subject: Re: Saratoga AJAX/PHP Cumulus template updated (CU-defs.php)
PostPosted: Tue Mar 27, 2012 11:20 pm 
Offline
User avatar

Joined: Wed Oct 21, 2009 11:19 am
Posts: 280
Location: Bayswater, Australia
Weather Station: La Crosse WS-2355
Operating System: Windoze 7
Mick,
I use this php function to show a "local lingo" description of rain rate. It can easily be extended for your bucket-sized rain-drops...

Code:
/**
* showLastRain()
* Returns the date & time of last rain.
*/
function showLastRain($lastrain, $rrate) {
   $raindate=substr($lastrain,8,2)."/".substr($lastrain,5,2)."/".substr($lastrain,0,4);
   $raintime=substr($lastrain,11,5);
   $lastraindays=dateDiff($lastrain, date("y-m-d h:m"));

   switch ($lastraindays)
   {
   case 0:
      if ($rrate>15) $lastmsg='The ark plans are drawn up, now to start building...';
      elseif ($rrate>10) $lastmsg='It is time to think about building an ark!';
      elseif ($rrate>7.6) $lastmsg='It is raining cats and dogs here!';
      elseif ($rrate>2.5) $lastmsg='It is raining moderately';
      elseif ($rrate>0) $lastmsg='It is raining lightly';
      else $lastmsg='Last Recorded Rain - '.$raintime.' today';
      break;
   case 1:
      $lastmsg='Last Recorded Rain - '.$raintime.' yesterday';
      break;
   default:
      if ($raindate>"00/00/0000")
         $lastmsg='No rain detected for '.$lastraindays.' days ('.$raindate.' '.$raintime.')';
      else $lastmsg='No rain detected since new install';
   }
   return ($lastmsg);
}   // end of showLastRain()

/**
* dateDiff()
* Find the difference in days between two calendar dates.
* Source:  http://php.net/manual/en/function.date.php
*
* @param Date $startDate
* @param Date $endDate
* @return Int
*/
function dateDiff($startDate, $endDate) {
// Parse dates for conversion
    $startArry=date_parse($startDate);
    $endArry=date_parse($endDate);

    // Convert dates to Julian Days
    $start_date=gregoriantojd($startArry["month"], $startArry["day"], $startArry["year"]);
    $end_date=gregoriantojd($endArry["month"], $endArry["day"], $endArry["year"]);

    // Return difference
    return round(($end_date - $start_date), 0);
}   // end of dateDiff()


_________________
Graeme.
http://weather.gktnet.com/cumulus/index.htm
Image


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Protected by Anti-Spam ACP Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group