PDA

View Full Version : Weather icons - sometimes displayed, sometimes not...



sapnho
May 14th, 2005, 02:12 AM
I am losing my last hair over this problem (and there isn't much left to start with... :wink: )

I am using Dan's weather with Marcel's weather icons (copied and pasted together in my own ccf-thanks guys!). I have the current weather on the Home panel and a full weather page on another one. This is how is looks like when it works:

http://www.wiki-knowledge.com/foren/weath1.gif

However, it doesn't work very often. Almost always it looks like this:

http://www.wiki-knowledge.com/foren/weath2.gif

My first thought was, this is a LUA issue, so here are the relevant LUA pieces:

Start of .lua file:

currentweatherimg = -1;
currentweatherimgam = -1;
currentweatherimgpm = -1;

Somewhere in the middle:

weatherimgdata = {};
weathertoday = "";
weatherimgdataloaded = 0;


function getweatherpic(offset,name)

local fh = io.open(NetRemote.GetVariable("NR.InstallDir").."\\weather\\"..name,"rb")
if (fh) then
weatherimgdata[tonumber(offset)] = fh:read("*all");
fh:close()
end

local fh = io.open(NetRemote.GetVariable("NR.InstallDir").."\\weather\\large\\L"..name,"rb")
if (fh) then
weatherimgdata["L"..tonumber(offset)] = fh:read("*all");
fh:close()
end

end

function setweatherimg()

if (weatherimgdataloaded~= 0) then
local newweatherimg = tonumber(NetRemote.GetVariable("cc.icon")) or 48;
if (currentweatherimg ~= newweatherimg) then
if (newweatherimg >= 0 and newweatherimg <= 48) then
NetRemote.SetImageVariable("Weather.today","image/png",weatherimgdata["L"..newweatherimg]);
else
newweatherimg = 48
NetRemote.SetImageVariable("Weather.today","image/png",weatherimgdata["L"..newweatherimg]);
end
end
end
end;

function setweatherforecastimg(forecastday)
if (weatherimgdataloaded~=0) then
local newweatherimgam = tonumber(NetRemote.GetVariable("Weather.Day"..forecastday.."am")) or 48;
local newweatherimgpm = tonumber(NetRemote.GetVariable("Weather.Day"..forecastday.."pm")) or 48;
if (currentweatherimgam ~= newweatherimgam) then
if (newweatherimgam >= 1and newweatherimgam <= 48) then
NetRemote.SetImageVariable("Weather.day"..forecastday.."ampic","image/png",weatherimgdata[newweatherimgam]);
else
newweatherimgam = 48
NetRemote.SetImageVariable("Weather.day"..forecastday.."ampic","image/png",weatherimgdata[newweatherimgam]);
end
end

if (currentweatherimgam ~= newweatherimgam) or (currentweatherimgpm ~= newweatherimgpm) then
if (newweatherimgpm >= 1and newweatherimgpm <= 48) then
NetRemote.SetImageVariable("Weather.day"..forecastday.."pmpic","image/png",weatherimgdata[newweatherimgpm]);
else
newweatherimgpm = 48
NetRemote.SetImageVariable("Weather.day"..forecastday.."pmpic","image/png",weatherimgdata[newweatherimgpm]);
end
end
end
end


OnCCF Part:

function OnCCFLoad()

NetRemote.ExecuteAction(-1014,1,9,"weatherrefresh");--part of timer function to check weather status every 30mins
NetRemote.ExecuteAction(-1014,1,8,"weatherrefresh;1800000;1800000;0;1");--part of timer function to check weather status every 30mins

for i = 0, 48, 1 do getweatherpic(i, i..".png") end;

weatherimgdataloaded = 1;

setweatherimg();

end;

On Panel Load

function OnPanelLoad()

local pn = NetRemote.GetVariable("NR.PanelName");
local dn = NetRemote.GetVariable("NR.DeviceName");

if (pn=="Home") then
NetRemote.ExecuteAction(-1,0,1,"nr.stopperformance");
NetRemote.ExecuteAction(-1,0,1,"NR.Checkweather");
NetRemote.ExecuteAction(-1,0,1,"nr.weatherradar");
NetRemote.SetVariable('UPAVL',0); --JRMC Up a GAC level button
NetRemote.ExecuteAction(-1014,1,8,"seticononstart;5000;0;0;1");
news_refresh();
end;

end;

And finally:

function OnVariableChange(varname,varvalue)

if (varname=="weatherrefresh") then --part of timer function to check weather status every 30mins
NetRemote.SetVariable('weatherrefresh', '0');
NetRemote.ExecuteAction(-1,0,1,"NR.Checkweather");
NetRemote.ExecuteAction(-1,0,1,"nr.weatherradar");--called to check current radar image
elseif (varname=="MP.Track") or (varname == "MP.Artist") or (varname == "MP.LinkActive") or (varname =="MP.PlayState") then --part of function for JRMC display status
local MPStatus = ""
if (NetRemote.GetVariable("MP.Track") == "" and NetRemote.GetVariable("MP.Artist") == "") or tonumber(NetRemote.GetVariable("MP.PlayState")) == 0 then
MPStatus = "";
NetRemote.SetVariable("MP.Status", MPStatus);
else
MPStatus = "Playing Now :- "..NetRemote.GetVariable("MP.Track")..", "..NetRemote.GetVariable("MP.Artist").." - "..NetRemote.GetVariable("MP.Album");
NetRemote.SetVariable("MP.Status", MPStatus);
end;
elseif (varname=="seticononstart") then --sets the weather icon in the status section on start up after a small delay
setweatherimg();
end;


I left out the bits which I believe are not weather relevant. What am I forgetting?

Please save my (last) hair and help! Thanks!

danward79
May 14th, 2005, 03:29 AM
Hi,

Are you calling the function "setweatherimg" in the button you use to go to the weather page?

sapnho
May 14th, 2005, 03:59 AM
Hmmm, we may be getting there...but no quite yet! My setup is that I control through a PPC another computer and its display (this computer has no keyboard and just serves for showing things!).

This is how my button looks like:

http://www.wiki-knowledge.com/foren/weath3.gif

Now, I also tried putting a button on the ccf which has the actual weather display (the computer without keyboard) and through VNC remote - it works. However, the same button on my PPC does not give the same result: The panel comes up without the small icons again. Do I have to add a client in my LUA file just like when making another computer jump to a panel?

sapnho
May 14th, 2005, 04:53 AM
I don't think my last post was really clear. The PPC actually controls the display of a PC. So the weather application is not on the PPC but on the PC. This is what what makes it so tricky I guess. :cry:

danward79
May 14th, 2005, 10:10 AM
Yeah, it looks like that may be you problem. Do you have a girder plugin setup to point to you girder from the pc nr?

sapnho
May 14th, 2005, 08:44 PM
Do you have a girder plugin setup to point to you girder from the pc nr?

What exactly do you mean?

danward79
May 15th, 2005, 01:03 AM
Sorry! That was a terrible sentence!

What I meant was do you have a instance of the girder plugin (in NR) on your display machine to point at girder on the machine supplying the weather info?

sapnho
May 15th, 2005, 01:25 AM
Yes, exactly. The NR/girder application is on the "display only PC" , and the PPC only has NR and points to the PC both in terms of girder and host.

danward79
May 15th, 2005, 02:16 AM
so you are going to need a girder instance on the display pc nr to girder on the display pc

sapnho
May 15th, 2005, 03:08 AM
so you are going to need a girder instance on the display pc nr to girder on the display pc

Yes, that's what I have (I believe :roll: ).

Rob recommended to
do that you'd have to have Girder set a variable in the second NR. That copy of NR would need to watch the variable - either using OnVariableChange or my RegisterVariableWatch() function and then call the required function.

Although I understand the logic of this command chain, I am uncertain how to put this together. I believe the sequence looks like this:

1) Add a command in the ccf's main lua on the display PC in the section on variable change
function OnVariableChange(varname,varvalue)

if (varname=="callweather") then
callweather==0 --is this the right command to reset the var to 0?
setweatherimg() --this is what the button usually does
setweatherforecastimg(1) --this is what the button usually does
setweatherforecastimg(2) --this is what the button usually does
setweatherforecastimg(3) --this is what the button usually does
setweatherforecastimg(4) --this is what the button usually does
JumpDevice('Weather','Wetter') --is this the right command to jump to a panel within NR?
end;

2) Attach a command on the PPC which triggers an event in girder
--no problem here

3) Create a command in girder which
a) triggers nr.forecast--no problem
b) changes the value of callweather to 1--I guess a very short LUA script but I have no idea how to make girder change a variable in the NetRemote space - please help!

Is my thinking more or less correct?

Rob H
May 15th, 2005, 04:50 AM
I've corrected your code :-



function OnVariableChange&#40;varname,varvalue&#41;
if &#40;varname=="callweather"&#41; and &#40;varvalue == 1&#41; then -- important to check the value or the next line might call this function again
callweather=0 --is this the right command to reset the var to 0? No it wasn't
setweatherimg&#40;&#41;
setweatherforecastimg&#40;1&#41;
setweatherforecastimg&#40;2&#41;
setweatherforecastimg&#40;3&#41;
setweatherforecastimg&#40;4&#41;
NetRemote.GoDevice&#40;'Weather','Wetter'&#41;
end;




3) Create a command in girder which
a) triggers nr.forecast--no problem
b) changes the value of callweather to 1--I guess a very short LUA script but I have no idea how to make girder change a variable in the NetRemote space - please help!

use


NetRemote.ClientSendLabel&#40;ipAddress, 'callweather', 1&#41;

sapnho
May 15th, 2005, 05:53 AM
Thanks Rob. It works from the logic point of view, but unfortunately I still don't get my little weather icons this way. I really can't figure out what I am missing. Dan, is there anything else that your weather app requires?

sapnho
May 15th, 2005, 07:15 AM
Well, it still doesn't work and it starts to ruin my Sunday... :wink:

I believe that I have exactly replicated in LUA what is in the button and all the calls for weather (see above) and yet the button (on the display PC) works but not the the button the PPC.



if (varname=="callweather") and (varvalue == 1) then

callweather = 0

NetRemote.ExecuteAction(-1,0,1,"nr.forecast");

setweatherimg();
setweatherforecastimg(1);
setweatherforecastimg(2);
setweatherforecastimg(3);
setweatherforecastimg(4);
NetRemote.GoDevice('Weather','Wetter');
end;

I checked if girder changes the variable name and by showing the value in a separate frame. Could it be that the on variable change doesn't work as advertised? I have the weather functions in a separate lua but it works for the button, so it should work here as well. Any thoughts?

Rob H
May 15th, 2005, 08:27 AM
My fault - I'm an idiot!

instead of varvalue == 1 try varvalue == "1"

Probably the most common mistake - did the same thing yesterday!

sapnho
May 15th, 2005, 08:45 AM
Well, that is certainly good news! However, now I have taken apart my complete lua file to have one per panel and I have to clean up my master file now. So it will probably take a bit to try it out but thanks already!

sapnho
May 16th, 2005, 11:00 AM
Somehow the variable stays at 1 despite the change back to 0. I even initialised it to 0 at CCF loading....wait: could it be that I have to put the 0 also in quotes, like callweather ="0" ??

Anyway, I ended up using another trick for Marcel's Dilbert which also requires the call of a function before going to the panel. I used the onpanelchange and just called it in there. Works like a charm! I'll try the same thing with weather when I have cleaned up my LUA.

Thanks guys! Another one done! :P

sapnho
May 16th, 2005, 12:00 PM
Hurrah! The weather works as well. What I ended up doing was to put the function calls in the on-panel-change section and it works!

Now off to the last challenge for today: the worldclock... 8)

Rob H
May 16th, 2005, 12:12 PM
Ah, another thing I missed. You need to use

NetRemote.SetVariable&#40;'callweather', 0&#41;

beags
January 9th, 2006, 06:44 PM
Hi I am using the today weather image on my front screen.
The problem I am having is that when NetRemote first launches the image is not present, I have to select where the image is which goes to the today panel. when I go back to the front screen the today weather image is there, until I close NetRemote, then when I relaunch the image has disappeared.
Is there a way to have the image load on the front screen when I launch NetRemote.

Kind Regards
Des

danward79
January 9th, 2006, 09:07 PM
You could make a call from OnCCFLoad()

beags
January 9th, 2006, 09:48 PM
Thanks Dan
I already have this, but it doesnt work
function OnCCFLoad()
OnGirderReady(function ()
NetRemote.ExecuteAction((GirderWeatherInstance or -1),0,1,"NR.Checkweather");
-- setweatherimg ("ppc");
end, (GirderWeatherInstance or -1));
RegisterPanelWatch("Weather", '*', function ()
NetRemote.ExecuteAction((GirderWeatherInstance or -1),0,1,"NR.Checkweather");
weatherdays();
setweatherimg ("ppc");
end);
end;

Kind Regards
Des

beags
January 11th, 2006, 09:02 PM
Any ideas.
Its driving me crazy.

Kind Regards
Des

danward79
January 11th, 2006, 09:08 PM
Out of interest, you could possibly try adding a second call to check weather at the end of ccfload, if that works it may be a clue.

beags
January 12th, 2006, 02:18 PM
:( Dan nothing seems to work.
Have you been able to do this with you CCF?

Kind Regards
Des

danward79
January 12th, 2006, 08:59 PM
In my ccf the weather is on a seperate page and seems to work fine.

beags
January 16th, 2006, 05:18 PM
Dan
Thanks for your help.
Its no big deal, I will keep the weather on a seperate panel as well

Kind regards
Des

emery
December 2nd, 2006, 08:17 PM
Folks, this is the exact look that I am trying to achieve, but as a Lua idiot, have been failing miserably. Basically trying to use Girder 4.0 to import this to NR 2.0 and also use the weather info from the default site. Cutting and pasting are not working at this point, so have deleted all my weather pages and looking for a starting point.

PS. I saw Dans last post on "weather.com" but have not been able to figure out how to incorporate this to function as a Girder 4.0 event into NR 2.0.
Could be because of the Lau moron I am at this point. Trying to learn too many things at one time.

Any help will be most appreciated.