PDA

View Full Version : New weather plugin alpha



CodeMonkey
2004-04-10, 10:54 PM
It isn't complete yet but I figured I'd let you all see what it looks like so far. *Only the current conditions and radar image work right now. *I will be adding the other 3 buttons today or tomorrow.

The source is not included yet. *But it will be when the plugin is released. *It is based heavily on the supplied weather plugin C# example.

WeatherPluginAlpha.zip (http://home.rochester.rr.com/woatman/WeatherPluginAlpha.zip)

Right now when you click on the 'current' button with the mouse, it is not highlighted. *That's the only bug I know of so let me know of any others.

sub
2004-04-10, 11:12 PM
Well done. Thats a good start. Seems to work well here.

I see what you mean about the selection state of the current button.

Also, the top line says "Weather for Wellington, , New Zeala" here. You might want to make bounding box for this text slightly larger. On my screen it looks like it still has about 100 or so pixel to the edge of the box.

You probably want to reduce the spacing between the buttons also.

There was a line that did this in the original sample:
Graphics.FromImage(compositeScreenImage).FillRecta ngle(new SolidBrush(Color.Black), 233, 168, 364, 244);
You should change these dimension to match the new image size because I can see a slight darker small rectangle in the middle of the radar map.

I hope these suggestions help.

sub
2004-04-10, 11:14 PM
We need to find someone artistic (any takers?) to draw us images that we can show to represent the current outlook - windy/sunny/rain/snow etc. That would look cool.

CodeMonkey
2004-04-11, 12:07 AM
Do we want some sort of standard on how far apart the buttons are? For example, the code in weather is:

g.DrawImage(image, 10, 80+(i*(image.Height+10)));

clickableRegions.Add(new Rectangle(10, 80+(i*(image.Height+10)), image.Width, image.Height), button);

What is it in your main menu code?

sub
2004-04-11, 12:38 AM
If you take out the +10 it should be about right as there is a gap at the bottom of the button images. The main menu is done slightly differently.

CodeMonkey
2004-04-11, 12:47 AM
OK, all of subs suggestions are in (thanks!). *Have another go http://gbpvr.com/iB_html/non-cgi/emoticons/smile.gif

Latest Weather Plugin Alpha (http://home.rochester.rr.com/woatman/WeatherPluginAlpha.zip)

CodeMonkey
2004-04-11, 01:33 AM
I'm changing the current conditions to display the current temp and condition (cloudy etc) in a larger font, and displaying a graphic for the condition. Graphics are currently stolen from mythtv until we get our own. I should have that tonight then call it quits for today http://gbpvr.com/iB_html/non-cgi/emoticons/smile.gif

CodeMonkey
2004-04-11, 02:19 AM
Final one for tonight, I promise http://gbpvr.com/iB_html/non-cgi/emoticons/smile.gif

This one has the temp/outlook and icon in current conditions.

It only displays the icon for 'partly cloudy' due to a brain cramp on my part, please read my next post and help http://gbpvr.com/iB_html/non-cgi/emoticons/smile.gif

Another weather alpha (http://home.rochester.rr.com/woatman/WeatherPluginAlpha.zip)

sub
2004-04-11, 02:32 AM
I've tried to download this latest version a few times - all have said corrupt archive. Can you try zipping it up again?

sub
2004-04-11, 02:36 AM
dont worry...got it.

CodeMonkey
2004-04-11, 02:38 AM
OK, having a problem with the weather icon. *Trying to follow what myth weather does. *They have a weathertypes.dat file that contains the icon file name for what is in the swCIcon part of the msnbc weather page. *As an example, Go Here (http://www.msnbc.com/m/chnk/d/weather_d_src.asp?acid=14472).

Right now, swCIcon shows 28, and swConText = Mostly Cloudy.

However, in weathertypes.dat the icon for a swCIcon of 28 is thunshowers.png.

What the heck am I missing?? *And on this note I'm stepping away from the monitor for the evening http://gbpvr.com/iB_html/non-cgi/emoticons/smile.gif

sub
2004-04-11, 02:48 AM
Wow. That is looking really good.

CodeMonkey
2004-04-11, 03:00 AM
OK so I lied about stepping away from the PC ;)

Thanks. It should be useable by everyone now. All the data from the default plugin is there, and even a bit more now.

This darn icon problem is bugging me though!

sub
2004-04-11, 03:33 AM
I'm not quite sure what they were doing in Mythtv, its a little hard to follow. I wonder if you should use a hashtable keyed by swConText. For example,

* Hashtable weatherIcons = new Hashtable();
* weatherIcons["sunny"] = Image.fromFile(directory + "\\sunny.png");
* weatherIcons["partly cloudy"] = Image.fromFile(directory + "\\pcloudy.png");
* ...etc

Then later:
string swConText = ...
* Image currentWeatherIcon = (Image)weatherIcons[swConText.ToLower()];

CodeMonkey
2004-04-11, 03:44 AM
Yeah I was heading that way myself. Thanks. Should have that tomorrow and maybe the rest as well http://gbpvr.com/iB_html/non-cgi/emoticons/smile.gif

bitter_old_man
2004-04-11, 04:12 AM
This looks great!

CodeMonkey
2004-04-11, 05:32 AM
Thanks bitter old man http://gbpvr.com/iB_html/non-cgi/emoticons/smile.gif

Another question sub. *I don't see these weather icons being skin specific do you? *And if not, where in the directory structure should I put them. *In a 'weather' subdir off of the plugin dir?

CodeMonkey
2004-04-11, 02:40 PM
Minor cosmetic fix uploaded today for the benefit of our non-USA friends. No more 'Wellington, , New Zealand' in the title for example http://gbpvr.com/iB_html/non-cgi/emoticons/smile.gif

WeatherAlpha (http://home.rochester.rr.com/woatman/WeatherPluginAlpha.zip)

bitter_old_man
2004-04-11, 04:28 PM
I wish MSNBC updated the conditions more often. Right now they are over an hour behind the National Weather Service and the current temperature is 5 degrees higher than MSNBC reports. I guess I'll find out it's raining an hour after it starts. http://gbpvr.com/iB_html/non-cgi/emoticons/biggrin.gif

Keep up the good work, CodeMonkey.

Barry

CodeMonkey
2004-04-11, 04:34 PM
Quote[/b] (bitter_old_man @ April 11 2004,10:28)]I wish MSNBC updated the conditions more often. Right now they are over an hour behind the National Weather Service and the current temperature is 5 degrees higher than MSNBC reports. I guess I'll find out it's raining an hour after it starts. http://gbpvr.com/iB_html/non-cgi/emoticons/biggrin.gif

Keep up the good work, CodeMonkey.

Barry
Go to the MSNBC site then send them a comment about updating more frequently. If enough people complain they might increase the frequency.

sub
2004-04-11, 06:45 PM
Cheers for the last update codemonkey. It just makes it that little bit nicer.

Are you planning for some more additions?

CodeMonkey
2004-04-11, 07:09 PM
Yes. I'm doing the weather icons now (there are a LOT of text possibilities to type into the hashtable). Then after that I'll be doing the forecasts (today, tomorrow, and week).

Should end up being pretty good by the time I'm done!

sub
2004-04-11, 07:12 PM
Excellent. Cant wait.

CodeMonkey
2004-04-11, 10:02 PM
Another update. Weather icons should be working now.

If you see a 'unknown' icon show up, make note of what the text under the temperature (cloudy etc.) says and post it here.

WeatherPlugin Alpha (http://home.rochester.rr.com/woatman/WeatherPluginAlpha.zip)

sub
2004-04-11, 10:16 PM
Its partly cloudy here today, so I had to try another area code. Seems to be working just fine.

One very minor cosmetic thing, the white rectangle that is drawn around the radar map is slightly smaller than the image. The bottom line of the rectangle is obscured.

CodeMonkey
2004-04-11, 11:22 PM
Sure was, try it now http://gbpvr.com/iB_html/non-cgi/emoticons/smile.gif
Update: The selected button problem when you click with a mouse is fixed now too.

Weather Plugin Alpha (http://home.rochester.rr.com/woatman/WeatherPluginAlpha.zip)

bs007
2004-04-12, 11:14 AM
Nice plugin! However when I want to set it to show degrees in Celsius I get an error msg. (SystemsNullReferenceException).

CodeMonkey
2004-04-13, 02:36 AM
Quote[/b] (bs007 @ April 12 2004,05:14)]Nice plugin! However when I want to set it to show degrees in Celsius I get an error msg. (SystemsNullReferenceException).
I just tried celsius and it was fine. What was your area code and what was the weather condition that showed when you had degrees F (cloudy, sunny etc.)?

2004-04-13, 04:02 AM
Quote[/b] ]I wish MSNBC updated the conditions more often. Right now they are over an hour behind the National Weather Service

They are 6 hours behind here in Australia. Temp is shown as 16C when it is currently 25C!

sub
2004-04-13, 04:21 AM
lol. New Zealand wasn't that out of date, but I wish it was 25C here.

sub
2004-04-13, 04:46 AM
Maybe CodeMonkey can put in some hooks for getting the weather information from other websites for certain area codes. I wouldnt expect him to implement support for other countries himself, but rather use the current approach (msnbc.com) as the default, and if others would like to provide more update info (eg Australia) then they could implement a function that will retrieve the information from a more upto date site.

CodeMonkey, if you do decide to do this I wouldnt worry about implementing anything too flashy:

if (areaCode.StartsWith("AU"))
{
GetAustralianWeatherInformation();
}
// add other else if specific countries here...
else
{
GetDefaultWeatherInformation();
}

CodeMonkey
2004-04-13, 10:50 AM
Sure I can add that in. At least the hook. When I release the source people can add those as they see fit (and send them to me and I will release it) or if I have time I can add specific ones for non-programmers.

I'd have to add functions for the forecasts too. And if the other weather sources don't give as much forecast data put up some kind of 'no info available' screen.

bs007
2004-04-13, 05:28 PM
Quote[/b] (CodeMonkey @ April 13 2004,03:36)]I just tried celsius and it was fine. *What was your area code and what was the weather condition that showed when you had degrees F (cloudy, sunny etc.)?

My area code is NLXX002. I just have tried again and the conditions are: 54F, partly cloudy.

bs007
2004-04-13, 06:44 PM
The timezone of the weather report is EST. Is it possible to convert that to the timezone the machine is in? (In my case CE(S)T).

bitter_old_man
2004-04-13, 06:52 PM
Quote[/b] ]They are 6 hours behind here in Australia. Temp is shown as 16C when it is currently 25C!
And I thought my 5 degrees F difference was bad! http://gbpvr.com/iB_html/non-cgi/emoticons/biggrin.gif

Barry

CodeMonkey
2004-04-13, 07:32 PM
Quote[/b] (bs007 @ April 13 2004,11:28)]
Quote[/b] (CodeMonkey @ April 13 2004,03:36)]I just tried celsius and it was fine. *What was your area code and what was the weather condition that showed when you had degrees F (cloudy, sunny etc.)?

My area code is NLXX002. I just have tried again and the conditions are: 54F, partly cloudy.
Are you sure about that area code? I don't get valid data for it.

I will look into converting the 'as of' date on the current page once the other stuff is done.

sisuomin
2004-04-13, 07:54 PM
I get an error: input string was not in a correct format

I'm trying to use area code: FIXX0031

BTW. I got the same error with the default area. Is this related to my regional settings?

sub
2004-04-13, 08:06 PM
sisuomin, you dont have a firewall or similar that could be blocking the access out to msnbc.com website?

CodeMonkey
2004-04-13, 08:24 PM
Quote[/b] (sisuomin @ April 13 2004,13:54)]I get an error: input string was not in a correct format

I'm trying to use area code: FIXX0031

BTW. I got the same error with the default area. Is this related to my regional settings?
I get valid data for this one. Tampere/Pirkkala

I think sub is right, do you have something blocking msnbc?

bs007
2004-04-13, 08:43 PM
Quote[/b] (CodeMonkey @ April 13 2004,20:32)]My area code is NLXX002. I just have tried again and the conditions are: 54F, partly cloudy.
Are you sure about that area code? *I don't get valid data for it.

I will look into converting the 'as of' date on the current page once the other stuff is done.[/QUOTE]
I am sorry, I missed a zero. It must be NLXX0002.

sub
2004-04-13, 08:55 PM
I just tried NLXX0002 here and seem to work fine.

bs007
2004-04-13, 09:51 PM
Also in Celsius?

sub
2004-04-13, 09:55 PM
Yes. Do you have a firewall that could be stopping the weather plugin from getting to the www.msnbc.com website?

bs007
2004-04-13, 10:09 PM
Yes I have a firewall - IPCOP 1.3 - but I never have any problems like this with it. But I don't know how the plugin is getting the weather details. If it uses a usual protocol and a standard or a high portnumber the firewall can't be blocking it. I have just tried to change the area code in the weather plugin but I can't anymore. So the problem resides in the plugin itself, gbpvr or another software problem in my PVR-pc. The error I get is in a window called 'Disk Space sample configuration form'. ??? Disk space can't be the issue here.
Did I already say your help is highly appreciated?

sub
2004-04-13, 10:13 PM
lol. The Weather plugin started out as a diskspace plugin. CodeMonkey you'll need to change the title of the configuration form.

It gets the weather information using a standard http request (TCPIP port 80), so its probably not the problem. Its was just a suggestion of something to check.

sub
2004-04-13, 10:20 PM
I had though it was in the main GB-PVR software, but your description above sounds like it is in the config app. Can describe exactly what happens?

How do you reproduce the error? Are you simple selecting the Celsius check box then hitting the OK button? Can you reproduce the error then email me the config.exe.log?

bs007
2004-04-13, 10:54 PM
It is in your mailbox. Indeed I was simply clicking on the Celsius check box then hitting the OK button.

CodeMonkey
2004-04-14, 12:58 AM
Oh, good catch sub. I thought it was when trying to get the weather too http://gbpvr.com/iB_html/non-cgi/emoticons/smile.gif

CodeMonkey
2004-04-14, 01:12 AM
Weird. I just tried NLXX0002 and it showed the 'unknown' weather icon. So I checked what is coming out of msnbc and saw

this.swConText = "";

No weather context, how strange. But at least it didn't crash because of it ;)

CodeMonkey
2004-04-14, 01:27 AM
I just emailed a new version to sub. Nothing but the title bar change in the config dialog.

I'm working on the forecast stuff but it's a bit strange, and I just started a new job so it might take a couple more days for that.

Then I have to think about what to do next. http://gbpvr.com/iB_html/non-cgi/emoticons/smile.gif

bs007
2004-04-14, 03:24 PM
Sub suggested to me to delete a part of the config.xml and that solved my 'Celsius' problem. I had probably messed up my config.xml when installing the new weather app. So I'm pretty sure the error was only in my configuration and not in gb-pvr or the new weather plugin.
Good luck with your new job, CodeMonkey!

sisuomin
2004-04-14, 09:41 PM
Quote[/b] (sub @ April 13 2004,19:06)]sisuomin, you dont have a firewall or similar that could be blocking the access out to msnbc.com website?
My problem is somehow related to regional settings. If I set locale to Finnish (control panel -> regional options) I get an error. With English it works ok.

CodeMonkey
2004-04-14, 11:32 PM
Quote[/b] (sisuomin @ April 14 2004,15:41)]My problem is somehow related to regional settings. If I set locale to Finnish (control panel -> regional options) I get an error. With English it works ok.
When you say 'I get an error' is that when you press the weather button in the weather plugin or when trying to set it in the config dialog?

sisuomin
2004-04-15, 07:05 PM
Error appears when weather button is pressed. Configuration works ok.

CodeMonkey
2004-04-16, 02:52 AM
Sub maybe you can have a look. *I added the log command here in DownloadWeatherInformation:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">
System.Uri uri = new System.Uri&#40;weatherURL&#41;;
WebRequest request = WebRequest.Create&#40;uri&#41;;
WebResponse response = request.GetResponse&#40;&#41;;
StreamReader streamReader = new StreamReader&#40;response.GetResponseStream&#40;&#41;&#41;;

string weatherSummaryText = streamReader.ReadToEnd&#40;&#41;;

Logger.Verbose&#40;weatherSummaryText&#41;;

// parse information out of summary text
[/QUOTE]

When the US locale is selected here is that part of the log:

4/15/2004 8:22:05 PM.777 VERBOSE [2] Rendering HomeMenu
4/15/2004 8:22:06 PM.618 VERBOSE [2]
function makeWeatherObj() {

this.swCity = &quot;Honeoye Falls&quot;;
this.swSubDiv = &quot;NY&quot;;
this.swCountry = &quot;USA&quot;;
this.swRegion = &quot;United States&quot;;
this.swTemp = &quot;50&quot;;
this.swTempCel = Math.round((5/9)*(this.swTemp-32));
this.swCIcon = &quot;30&quot;;
this.swWindS = &quot;6&quot;;
this.swWindD = &quot;NNW&quot;;
this.swBaro = &quot;30.23&quot;;
this.swHumid = &quot;29&quot;;
this.swReal = &quot;50&quot;;
this.swUV = &quot;0&quot;;
this.swVis = &quot;10.00&quot;;
this.swLastUp = &quot;04/15/2004 17:54:00&quot;;
this.swConText = &quot;Partly Cloudy&quot;;
this.swFore = &quot;6&#124;7&#124;1&#124;2&#124;3&#124;04/16/2004&#124;04/17/2004&#124;04/18/2004&#124;04/19/2004&#124;04/20/2004&#124;34&#124;37&#124;30&#124;28&#124;30&#124;22&#124;27&#124;26&#124;3&#124;26&#124;63&#124;69&#124;74&#124;75&#124;57&#124;2 0&#124;30&#124;20&#124;30&#124;20&#124;29&#124;26&#124;29&#124;11&#124;29&#124;4&#124;1&#124;4&#124;14&#124;4&#124;48&#124;54&#124;57&#124;4 4&#124;34&#124;&quot;;

this.swAcid = &quot;14472&quot;;
}
4/15/2004 8:22:11 PM.635 VERBOSE [2] Rendering HomeMenu
4/15/2004 8:22:13 PM.548 VERBOSE [2] Rendering HomeMenu

and when I select the Finnish locale:

15.4.2004 20:06:11.575 VERBOSE [2] Rendering HomeMenu
15.4.2004 20:06:12.676 VERBOSE [2] Rendering HomeMenu
15.4.2004 20:06:13.508 VERBOSE [2]
function makeWeatherObj() {

this.swCity = &quot;Honeoye Falls&quot;;
this.swSubDiv = &quot;NY&quot;;
this.swCountry = &quot;USA&quot;;
this.swRegion = &quot;United States&quot;;
this.swTemp = &quot;50&quot;;
this.swTempCel = Math.round((5/9)*(this.swTemp-32));
this.swCIcon = &quot;30&quot;;
this.swWindS = &quot;6&quot;;
this.swWindD = &quot;NNW&quot;;
this.swBaro = &quot;30.23&quot;;
this.swHumid = &quot;29&quot;;
this.swReal = &quot;50&quot;;
this.swUV = &quot;0&quot;;
this.swVis = &quot;10.00&quot;;
this.swLastUp = &quot;04/15/2004 17:54:00&quot;;
this.swConText = &quot;Partly Cloudy&quot;;
this.swFore = &quot;6&#124;7&#124;1&#124;2&#124;3&#124;04/16/2004&#124;04/17/2004&#124;04/18/2004&#124;04/19/2004&#124;04/20/2004&#124;34&#124;37&#124;30&#124;28&#124;30&#124;22&#124;27&#124;26&#124;3&#124;26&#124;63&#124;69&#124;74&#124;75&#124;57&#124;2 0&#124;30&#124;20&#124;30&#124;20&#124;29&#124;26&#124;29&#124;11&#124;29&#124;4&#124;1&#124;4&#124;14&#124;4&#124;48&#124;54&#124;57&#124;4 4&#124;34&#124;&quot;;

this.swAcid = &quot;14472&quot;;
}
15.4.2004 20:06:14.219 ERROR [2] Error: msg=0x202 (WM_LBUTTONUP) hwnd=0x80336 wparam=0x0 lparam=0x15100b5 result=0x0 * : *Input string was not in a correct format. * : * * at System.Number.ParseSingle(String s, NumberStyles style, NumberFormatInfo info)
* at System.Single.Parse(String s, NumberStyles style, IFormatProvider provider)
* at WeatherPlugin.WeatherTask.CurrentConditions()
* at WeatherPlugin.WeatherTask.render(Boolean&amp; requiresMoreRendering)
* at ac.f(Object A_0, EventArgs A_1)
* at System.Windows.Forms.Control.OnClick(EventArgs e)
* at System.Windows.Forms.Control.WmMouseUp(Message&amp; m, MouseButtons button, Int32 clicks)
* at System.Windows.Forms.Control.WndProc(Message&amp; m)
* at System.Windows.Forms.ScrollableControl.WndProc(Mes sage&amp; m)
* at System.Windows.Forms.ContainerControl.WndProc(Mess age&amp; m)
* at System.Windows.Forms.Form.WndProc(Message&amp; m)
* at ac.a(Message&amp; A_0)
15.4.2004 20:06:14.219 VERBOSE [2] Rendering HomeMenu
15.4.2004 20:06:16.702 VERBOSE [2] Rendering HomeMenu
15.4.2004 20:06:17.944 VERBOSE [2] Rendering HomeMenu
15.4.2004 20:06:18.154 VERBOSE [2] SourceConfigurationContainer.LoadAll()
15.4.2004 20:06:18.174 VERBOSE [2] Loading DirectRecordingSource Configuration : 1
15.4.2004 20:06:18.194 VERBOSE [2] Loading XMLTV Configuration : 1
15.4.2004 20:06:18.234 VERBOSE [2] About to connect to remote recording service
15.4.2004 20:06:18.274 VERBOSE [2] getValue() loading new key/value into cache: /settings/AutoCreateFolders
15.4.2004 20:06:18.274 VERBOSE [2] getValue: /settings/AutoCreateFolders : true

Does this failure make any sense to you? *That error message is not generated by the weather plugin.

sub
2004-04-16, 02:57 AM
Can you email the code for the WeatherTask.CurrentConditions() function? Send it to me at support@devnz.com

sub
2004-04-16, 03:03 AM
I suspect its a problem parsing one of the numeric fields that contain a decimal point.

sisuomin, does the Finnish locale use comma&#39;s instead of decimal points?

CodeMonkey
2004-04-16, 03:27 AM
I believe it does, sub. * You have mail.

It makes sense too. Your example, which runs fine in the finnish locale, doesn&#39;t parse any real numbers.

sub
2004-04-16, 03:45 AM
The microsoft online-help indicates that the float and double.parse() methods parse a culture-specific decimal point symbol, so this likely to be the problem.

Use the form of Double.Parse which takes an IFormatProvider, and give
it CultureInfo.InvariantCulture, eg:

double d = Double.Parse (myString, CultureInfo.InvariantCulture);

CodeMonkey
2004-04-16, 10:45 AM
Yup, that fixed it. Thanks sub.

It will be in the next weather release.