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!
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!