Page 1 of 2
Gauges page updating - a problem
Posted: Tue 04 May 2010 6:01 pm
by mcrossley
If you have been following the other thread on redesigning some of the gauges, the this is a follow-on...
I have now amended my gauges page so that the gauges update every minute from my realtime.txt file without refreshing the whole page.
The problem is in the boxover code. The boxovers appear correctly after the initial page load (which uses Cumulus supplied data embedded in the HTML as normal), and after the first gauge update from realtime.txt. However subsequent updates make the boxovers then appear with the source code rather than rendered HTML.
Anyone any ideas what is going wrong?
The page is here:
http://weather.wilmslowastro.com/gauges.htm
Thanks
Re: Gauges page updating - a problem
Posted: Wed 05 May 2010 4:06 am
by beteljuice
... I have now amended my gauges page so that the gauges update every minute from my realtime.txt file without refreshing the whole page...
How are you doing that ?
... don't forget boxover.js has already been 'initialsed' after dashboard.js
Re: Gauges page updating - a problem
Posted: Wed 05 May 2010 6:52 am
by mcrossley
I just have a 'setInterval' in dashboard.js that fetches the realtime.txt file from my website, updates the data arrays from the realtime data,then redraws the gauges.
As I do not refresh the whole page then boxover,js isn't reloaded each time - ah! is there some code in boxover that has to be run each time before the boxovers are created? The code is really badly formatted for human reading - I'll have a look into that tonight...
I now have Cumulus creating an extra 'wind data' file every 15 mins, so I can eventually incorporate that to update the wind rose diagram too.
Re: Gauges page updating - a problem
Posted: Wed 05 May 2010 7:24 am
by captzero
Mark,
Good job with the gauges. I'm following your progress with interest.
Cheers
Re: Gauges page updating - a problem
Posted: Wed 05 May 2010 8:23 am
by steve
mcrossley wrote:ah! is there some code in boxover that has to be run each time before the boxovers are created? The code is really badly formatted for human reading - I'll have a look into that tonight...
boxover.js appears to be no longer supported, even the domain which is referenced has gone. You might do better to look for an alternative.
By the way, when I have your gauges page open in Firefox, every time it updates, FF goes completely unresponsive for a few seconds. It doesn't seem to have the same effect in IE8.
Re: Gauges page updating - a problem
Posted: Wed 05 May 2010 10:35 am
by gemini06720
steve wrote:...By the way, when I have your gauges page open in Firefox, every time it updates, FF goes completely unresponsive for a few seconds. It doesn't seem to have the same effect in IE8.
Indeed, for a second or two, I thought my Firefox had crashed...
I loaded your page into the 4 browsers nstalled on my computer, Firefox, Google Chrome, Internet Explorer and Opera.
Firefox was the only one 'freezing' during the 'dashboard' refresh.
Chrome and Opera seemed to update properly - I used the 'Instrument view of current data at...' time to confirm the regular update.
Internet Explorer might have updated except the time has not changed - the clock it is now 10 minutes behind the clock on the other browsers.
There is something 'not right' with your 'dashboard' updating - it should refresh in all browsers without causing any momentary freeze.
As for the boxover-produced text - after the first refresh, the HTML source code is being displayed... I use boxover in my newer Cumulus page (which is also updated through the use of AJAX/JavaScript) and the boxover-produced text is still displaying properly after an update...
I do not think the problem is with the boxover script but rather with the dashboard script...
Re: Gauges page updating - a problem
Posted: Wed 05 May 2010 10:45 am
by mcrossley
Thanks Ray, I had been using IE8 and Chrome to test it. Strange how Firefox is affected this way, all the code is doing is a standard asynchronous fetch of the realtime text file using an XMLHttpRequest then repainting the gauges using pretty unmodified 'gauge page' code. Unless it is the repainting of the graphics that causes the problem? Do you see the same freeze when loading the Cumulus as-supplied gauges page?
Re: Gauges page updating - a problem
Posted: Wed 05 May 2010 11:11 am
by gemini06720
mcrossley wrote:Do you see the same freeze when loading the Cumulus as-supplied gauges page?
Nope!
Even with the modified 'dashboard' and 'boxover' files (I recently uploaded) and the 'old-redesigned' gauges (the barometer and the wind rose gauges you have released a week or so ago) I do not have any problem displaying them with any of the browsers. But, then, I do not auto-refresh the 'dashboard' script.
I have had a little situation with the 'boxover' script and Opera where the HTML code was displayed rather than the text the HTML is suppose to display ... a page refresh usually corrects the situation.
But this is not the situation with you page - after the first 'dashboard' refresh, all the browsers display the HTML code...
Re: Gauges page updating - a problem
Posted: Wed 05 May 2010 11:44 am
by beteljuice
I'm pretty sure your problem is related to the way the zorn graphics are generated.
ie. It creates a parent div with children.
When your loop goes around the 'old' div (and any zorn data array) still exist with the same IDs - I'm surprised you are getting your images to update at all !
Also, zorn recommends that when updating data / graphic - run TWO parent divs (per item), and toggle 'display' properties AFTER latest drawing has been completed, this technique is used when animating.
Sometimes it may be easier just to 'empty' the parent div - but other times you will have use the zorn command to delete graphic 'array'.
... rough example of both techniques here:
http://www.beteljuice.com/betel_cumulus/wind2.html
View source for a very messy commented out and some incomplete decisions code
Your (and others) ajax problem maybe related to something I found when I created the betejuice AJAX, not all (new) browsers handle onload and css the same way, I have noticed this recently on other AJAX weather sites using different softwares but based roughly on the same code.
Basically on the initial grab, you ARE reading your data file, but css hasn't caught up yet, so the divs you want to 'edit' haven't been named yet as far as the browser / javascript are concerned, so nothing 'apparently' happens until the next grab in the loop.
NB: I am laying down zorn 'needles' and the background picture is NOT changed (although scale and text maybe

)
Re: Gauges page updating - a problem
Posted: Wed 05 May 2010 12:50 pm
by mcrossley
I think I may have fixed the freezing in Firefox - I was recreating the XMLHttpRequest object afresh each time I used it, it seems that Firefox freezes whilst this takes place, so I have changed the code to re-use the same request objects each time. The problem then became that it just kept re-using the same copy of realtime.txt from the local browser cache! So I have added a cache defeat to the realtime.txt and the wind_data.txt that is now also updated (every 15 mins).
Now to look at the boxover problem - when I've fixed the washing machine!
Re: Gauges page updating - a problem
Posted: Wed 05 May 2010 1:11 pm
by mcrossley
beteljuice wrote:I'm pretty sure your problem is related to the way the zorn graphics are generated.
ie. It creates a parent div with children.
When your loop goes around the 'old' div (and any zorn data array) still exist with the same IDs - I'm surprised you are getting your images to update at all !
Also, zorn recommends that when updating data / graphic - run TWO parent divs (per item), and toggle 'display' properties AFTER latest drawing has been completed, this technique is used when animating.
Sometimes it may be easier just to 'empty' the parent div - but other times you will have use the zorn command to delete graphic 'array'.
Great, thanks for the info - I'll study this tonight, I didn't know you could animate either! Something else to look into.
Edit: I just had a v. quick look at the wz_jsgraphics code - it seems that when you declare a "new jsGraphics("xyz")" it clears out any existing child div that the previous graphics created. That explains why my code is working. But if I want to animate then I'll have to change the graphics to be persistant.
Re: Gauges page updating - a problem
Posted: Wed 05 May 2010 5:03 pm
by mcrossley
I found a later 'patched' version of the boxover script - and this now seems to be working fine. So I think what I have done so far is all fixed now. Thanks for the pointers, and I will looking into animating the windspeed gauge using some tips from Beteljuice
I plan on replacing the wind direction gauge next, that will only leave the wind distribution being generated by Cumulus - I can then make the whole page 'static' and not have Cumulus process it al all.
Re: Gauges page updating - a problem
Posted: Fri 07 May 2010 9:29 am
by mcrossley
Well the washing machine still isn't fixed (parts in the post) but my
gauges web page is now fully realtime (well almost, the Wind Distribution is still a Cumulus graphic).
I adapted the cumuluswebtag php template to javascript format and import that for all the values that are required. I still want to animate the wind indicators for smooth transitions, but the rest change so slowly no animation is required.
I have had to change the URL as there does not seem to be anyway of stopping Cumullus FTPing the standard gauges.htm - I deleted the template from the Cumulus web folder, but it then just FTPs a zero length file

Re: Gauges page updating - a problem
Posted: Fri 07 May 2010 9:50 am
by steve
mcrossley wrote:I have had to change the URL as there does not seem to be anyway of stopping Cumullus FTPing the standard gauges.htm - I deleted the template from the Cumulus web folder, but it then just FTPs a zero length file

It's 'all or none' with the standard pages. The only way to stop just the gauges.htm file being uploaded is to untick 'include standard files' on the files tab and list all of the others separately.
Re: Gauges page updating - a problem
Posted: Fri 07 May 2010 4:40 pm
by mcrossley
Thanks Steve, I thought I'd run out slots on file transfer page, but I'm OK.
I have now created an animated version of the gauges page - well the Wind Speed and Wind Direction are animated anyway.
It seems to work OK in Firefox and Chrome, but my copy of IE8 seems to struggle a bit to keep up so I don't know if this is a keeper
http://weather.wilmslowastro.com/gauges_ani.htm
Edit: I removed the compass and added pointers to the wind rose instead. With the simpler page I think it is a goer, now on my main url...
http://weather.wilmslowaastro.com/gauges.htm
Oh, and I managed to mess up the boxover on the animated gauges too - need to look at that...