Sandaysoft

Support forum for Cumulus weather station software
It is currently Wed May 22, 2013 7:26 pm
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  [ 32 posts ]  Go to page 1, 2, 3  Next
Author Message
 Post subject: Cumulus realtime.txt file reader
PostPosted: Mon Jan 10, 2011 12:23 pm 
Offline
User avatar

Joined: Sat Dec 04, 2010 10:11 am
Posts: 94
Location: Lemmer
Weather Station: ws4000
Operating System: win7
Because I want to use the information from realtime.txt in my website script, I made this tiny script to read the realtime.txt file and put the info from that file in variables.

Usage of the script:

include the view-realtime.php in your script. Now you can use the strings to print the info on your website

for testing the script, point your browser to:
http://linktoyoursite/view-realtime.php?action=view


For more instructions, read the comments in the script.

Have fun with it!

Theo


EDIT: Filecheck added to the script.
EDIT: Made a change to the filecheck. (Thanks to Steve for the tip!)

EDIT: Made another usefull script for using with the view-realtime.php script.

EDIT: Update of the script. now without errors

This script shows a table with all the strings that are used by the view-realtime-helper.php script

Unpack the .rar with winrar and put the realtime-helper.php script in the same directory as the view-realtime.php file.

Point your browser to:

http://www.linktoyoursite/realtime-helper.php

EDIT: To show what nice things you can do with the view-realtime.php script I have made a webpage.

DEMO: http://www.weerstation-lemmer.nl/cumulus/weatherconsole.php

This is a weatherconsole with "live"updates. Page refreshes every 15 seconds. (Could be more or less if you want)


Have fun with it!


You do not have the required permissions to view the files attached to this post.

_________________
Sincerely, Theo
Image
http://www.weerstation-lemmer.nl


Last edited by phtvs on Tue Jan 11, 2011 6:32 pm, edited 13 times in total.

Top
 Profile  
 
 Post subject: Re: Cumulus realtime.txt file reader
PostPosted: Mon Jan 10, 2011 12:39 pm 
Offline
User avatar

Joined: Sat Jul 31, 2010 10:34 pm
Posts: 1039
Location: Anglesey, North Wales, UK
Weather Station: Fine Offset
Operating System: Windows XP
have uploaded it to my website


to my root weather folder, my realtime.txt file is here


http://www.h-i-r.org.uk/weather/realtime.txt

I have changed the location in your script, to this below, but get a blank page?


Code:
$file_clientraw = file_get_contents("weather/realtime.txt"); // change this line if realtime.txt is at another location
$data_clientraw = explode(" ", $file_clientraw);




http://h-i-r.org.uk/weather/view-realtime.php

_________________
Rob,
Dyffryn History on WU Dyffryn on Twitter Dyffryn on WOW
Image


Top
 Profile  
 
 Post subject: Re: Cumulus realtime.txt file reader
PostPosted: Mon Jan 10, 2011 12:46 pm 
Offline
User avatar

Joined: Sat Dec 04, 2010 10:11 am
Posts: 94
Location: Lemmer
Weather Station: ws4000
Operating System: win7
I think you need to add this: ../ before: weather/realtime.txt

So that line must be:

../weather/realtime.txt

If that wont work you can also use this line:

http://www.h-i-r.org.uk/weather/realtime.txt


EDIT:
To test the script use your browser to go to the script like this:

http://h-i-r.org.uk/weather/view-realti ... ction=view

_________________
Sincerely, Theo
Image
http://www.weerstation-lemmer.nl


Last edited by phtvs on Mon Jan 10, 2011 12:50 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Cumulus realtime.txt file reader
PostPosted: Mon Jan 10, 2011 12:49 pm 
Offline
Site Admin
User avatar

Joined: Mon Jun 02, 2008 6:49 pm
Posts: 17567
Location: Sanday, Orkney
Weather Station: Davis VP2
Operating System: Windows Home Server 2011
The PHP file is already in the 'weather' directory, so presumably this would work:

$file_clientraw = file_get_contents("realtime.txt");

_________________
Steve
Sanday Weather
----------------------------------------------------------------------------------------------------------------------------------
Like Cumulus and want to support it? Please donate! Image


Top
 Profile  
 
 Post subject: Re: Cumulus realtime.txt file reader
PostPosted: Mon Jan 10, 2011 12:52 pm 
Offline
User avatar

Joined: Sat Dec 04, 2010 10:11 am
Posts: 94
Location: Lemmer
Weather Station: ws4000
Operating System: win7
steve wrote:
The PHP file is already in the 'weather' directory, so presumably this would work:

$file_clientraw = file_get_contents("realtime.txt");



Of course...

Thanks for helping, Steve!

_________________
Sincerely, Theo
Image
http://www.weerstation-lemmer.nl


Top
 Profile  
 
 Post subject: Re: Cumulus realtime.txt file reader
PostPosted: Mon Jan 10, 2011 12:54 pm 
Offline
User avatar

Joined: Sat Jul 31, 2010 10:34 pm
Posts: 1039
Location: Anglesey, North Wales, UK
Weather Station: Fine Offset
Operating System: Windows XP
tried both, no luck, strange this is, when you look at the page source for the .php page, it has no coding?

_________________
Rob,
Dyffryn History on WU Dyffryn on Twitter Dyffryn on WOW
Image


Top
 Profile  
 
 Post subject: Re: Cumulus realtime.txt file reader
PostPosted: Mon Jan 10, 2011 12:59 pm 
Offline
Site Admin
User avatar

Joined: Mon Jun 02, 2008 6:49 pm
Posts: 17567
Location: Sanday, Orkney
Weather Station: Davis VP2
Operating System: Windows Home Server 2011
Looks fine from here: http://h-i-r.org.uk/weather/view-realtime.php?action=view

Attachment:
Mozilla Firefox_2011-01-10_12-57-44.png


You do not have the required permissions to view the files attached to this post.

_________________
Steve
Sanday Weather
----------------------------------------------------------------------------------------------------------------------------------
Like Cumulus and want to support it? Please donate! Image


Top
 Profile  
 
 Post subject: Re: Cumulus realtime.txt file reader
PostPosted: Mon Jan 10, 2011 12:59 pm 
Offline
User avatar

Joined: Sat Dec 04, 2010 10:11 am
Posts: 94
Location: Lemmer
Weather Station: ws4000
Operating System: win7
robynfali wrote:
tried both, no luck, strange this is, when you look at the page source for the .php page, it has no coding?



Seems to me that it works perfect...

Follow this link:

http://h-i-r.org.uk/weather/view-realtime.php?action=view

_________________
Sincerely, Theo
Image
http://www.weerstation-lemmer.nl


Top
 Profile  
 
 Post subject: Re: Cumulus realtime.txt file reader
PostPosted: Mon Jan 10, 2011 2:44 pm 
Online

Joined: Mon Aug 10, 2009 10:16 pm
Posts: 1793
Location: World...
Weather Station: No weather station
Operating System: No operating system
robynfali wrote:
tried both, no luck, strange this is, when you look at the page source for the .php page, it has no coding?
Rob, if you try to look at a PHP script through your browser, you should/would see nothing of the code of the script ... because the script itself is not sent to your browser but processed by your Web server and only the results are sent to your browser... ;)


Top
 Profile  
 
 Post subject: Re: Cumulus realtime.txt file reader
PostPosted: Mon Jan 10, 2011 2:45 pm 
Offline
User avatar

Joined: Sat Jul 31, 2010 10:34 pm
Posts: 1039
Location: Anglesey, North Wales, UK
Weather Station: Fine Offset
Operating System: Windows XP
didnt realise you needed the
Quote:
?action=view
bit after, sorry

_________________
Rob,
Dyffryn History on WU Dyffryn on Twitter Dyffryn on WOW
Image


Top
 Profile  
 
 Post subject: Re: Cumulus realtime.txt file reader
PostPosted: Mon Jan 10, 2011 2:49 pm 
Online

Joined: Mon Aug 10, 2009 10:16 pm
Posts: 1793
Location: World...
Weather Station: No weather station
Operating System: No operating system
Theo, I have quickly looked at the code of your 'view-realtime.php' script... Once I tried it, I will probably come up with some suggestions, one of them being a check for the presence of the 'realtime.txt' before trying to read the file... ;)


Top
 Profile  
 
 Post subject: Re: Cumulus realtime.txt file reader
PostPosted: Mon Jan 10, 2011 3:41 pm 
Offline
User avatar

Joined: Sat Dec 04, 2010 10:11 am
Posts: 94
Location: Lemmer
Weather Station: ws4000
Operating System: win7
gemini06720 wrote:
Theo, I have quickly looked at the code of your 'view-realtime.php' script... Once I tried it, I will probably come up with some suggestions, one of them being a check for the presence of the 'realtime.txt' before trying to read the file... ;)



Good idea. I was working on that part but got stuck..
Im just a beginner at php scripting ;-)

Sugestions are always welcome!!

So feel free to make the script better!

_________________
Sincerely, Theo
Image
http://www.weerstation-lemmer.nl


Top
 Profile  
 
 Post subject: Re: Cumulus realtime.txt file reader
PostPosted: Mon Jan 10, 2011 5:52 pm 
Offline
User avatar

Joined: Sat Dec 04, 2010 10:11 am
Posts: 94
Location: Lemmer
Weather Station: ws4000
Operating System: win7
Finaly got the filecheck function working...

The script checks if realtime.txt is there, if not then it displays a warning and exits from the script.

Done it the easy way, so if someone can do it better, please do!!


You do not have the required permissions to view the files attached to this post.

_________________
Sincerely, Theo
Image
http://www.weerstation-lemmer.nl


Top
 Profile  
 
 Post subject: Re: Cumulus realtime.txt file reader
PostPosted: Mon Jan 10, 2011 6:07 pm 
Offline
Site Admin
User avatar

Joined: Mon Jun 02, 2008 6:49 pm
Posts: 17567
Location: Sanday, Orkney
Weather Station: Davis VP2
Operating System: Windows Home Server 2011
Just a minor comment, if I may:

Code:
$filename = "realtime.txt";
if (file_exists($filename)) {
//
// edit these lines when needed
//
$file_clientraw = file_get_contents("realtime.txt"); // change this line if realtime.txt is at another location


You have the realtime.txt file in twice; better to just have it once at the beginning, for the user to configure, and then use the same variable again later:

Code:
$filename = "realtime.txt";  // change this line if realtime.txt is at another location

if (file_exists($filename)) {
$file_clientraw = file_get_contents($filename);

_________________
Steve
Sanday Weather
----------------------------------------------------------------------------------------------------------------------------------
Like Cumulus and want to support it? Please donate! Image


Top
 Profile  
 
 Post subject: Re: Cumulus realtime.txt file reader
PostPosted: Mon Jan 10, 2011 6:19 pm 
Offline
User avatar

Joined: Sat Dec 04, 2010 10:11 am
Posts: 94
Location: Lemmer
Weather Station: ws4000
Operating System: win7
So true, Steve...

Thanks for the tip. I change that and post a new rar file with the correct php file in my first post.

EDIT: updated my first post with new rar file.

_________________
Sincerely, Theo
Image
http://www.weerstation-lemmer.nl


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 32 posts ]  Go to page 1, 2, 3  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 0 guests


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