/* Source code made by iri This code is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. You can do what you want with it */ typeof Weather = ObjScienceWeatherMetar;; // few functions are in the Syspack library fun buildWeather (l)= if l == nil then "" else strcat (sprintf "%s %d" hd l) buildWeather tl l;; fun cbMetarReceived (obj, user_parameter, metar, state)= _fooS "METAR RECEIVED !"; _fooS metar; _fooId state; _scienceWeatherMetarDatasSet Weather metar; _fooId _scienceWeatherMetarPressure Weather; 0;; fun main ()= _showconsole; /* let _scienceWeatherDecodeMetar "2012/02/19 06:00\nAYMH 190600Z 18008KT 9999 BKN035 23/16 Q1017" FROM_NOAA -> [type icao day hour min windir windspeed windgust windunit windvariationfrom windvariationto visibility currentweather nebulolow nebulomed nebulohigh temperature dewpoint presure recentweather] in*/ /* _fooS sprintf "type : %s\ncode station : %s\nday : %s\ntime : %s:%s\nwind direction : %s\nwind speed : %s\nwind gust : %s\nwind unit : %s\nvariation wind direction : %s - %s\nvisibility : %s\ncurrent weather : %s\nnebulosity : %s - %s - %s\ntemperature : %s\ndewpoint : %s\npresure : %s\nrecent weather : %s" _scienceWeatherDecodeMetar "AYMH 190600Z 18008KT 9999 BKN035 23/16 Q1017" nil; 0;;*/ /* let _scienceWeatherDecodeMetarLight "2012/02/19 15:30\nLFML 191530Z 32024KT CAVOK 13/M00 Q1017 NOSIG" FROM_NOAA -> datas in _fooS sprintf "data : %sth current\ntime : %s\nwind direction : %s °\nwind speed : %d %s\ncurrent weather : %s\npresure : %d hPa\ntemperature : %d °C\nRelative humidity : %d %" datas; 0;;*/ set Weather = _scienceWeatherMetarNew _channel; if Weather == nil then ( _fooS "Unable to create the Scol object !"; 1 ) else // let _scienceWeatherMetarUrlSet Weather "ftp://tgftp.nws.noaa.gov/data/observations/metar/stations/" ".txt" -> _ in let _scienceWeatherMetarDatasSetFromUrl Weather "LFML" FROM_NOAA @cbMetarReceived 0 -> w in if w == nil then ( _fooS "Unable to get the datas from internet !"; 2 ) else ( _fooS "Downloading, please wait ... !"; 0 );; /* let _scienceWeatherMetarTemperature Weather -> [curTemperature curDewpoint] in let _scienceWeatherMetarWeather Weather -> [weathers nebulosity] in ( _fooS "In direct live from Marseille, France !"; _fooS sprintf "The %dth, %d:%d" _scienceWeatherMetarDate Weather; _fooS sprintf "The current weather : %s" [buildWeather weathers]; _fooS sprintf "the temperature is %d °C and the humidity is %d %."[curTemperature _scienceWeatherMetarHumidity Weather]; _fooS sprintf "With this temperature, the windchill is %f." [_scienceWeatherMetarWindchill Weather]; _fooS sprintf "With the nebulosity at %s at low level, %s at medium level and %s at high level," nebulosity; _fooS sprintf "the visibility is %d meters." [_scienceWeatherMetarVisibility Weather]; 0 );;*/ fun displayEasyWeather (l)= if l == nil then 0 else ( _fooS sprintf "weather = %s intensity = %d" hd l; displayEasyWeather tl l );; fun main2 ()= _showconsole; set Weather = _scienceWeatherMetarNew _channel; /* printf "avant : prefix = %s sufix = %s\n" _scienceWeatherMetarUrlGet Weather 0; _scienceWeatherMetarUrlSet Weather "toto" "ahahah"; printf "apres : prefix = %s sufix = %s\n" _scienceWeatherMetarUrlGet Weather 0; */ /* _scienceWeatherMetarDatasSet Weather "LFML 231330Z 16013KT CAVOK 34/11 Q1015 NOSIG"; _fooS _scienceWeatherMetarDatasGet Weather; printf "date de l'observation : le %d a %d h et %d mn\n" _scienceWeatherMetarDate Weather 0; printf "la pression est de : %d\n" [_scienceWeatherMetarPressure Weather] 0; printf "la temperature est de : %d et le point de rosee de : %d\n" _scienceWeatherMetarTemperature Weather 0;*/ _scienceWeatherMetarDatasSetFromUrl Weather "LFML" 1 nil nil; _fooS _scienceWeatherMetarDatasGet Weather; _fooId _scienceWeatherMetarPressure Weather; let _scienceWeatherMetarWeather Weather -> [l t] in ( displayEasyWeather l; _fooS sprintf "low = %s medium = %s high = %s" t; ); _fooSList _scienceWeatherMetarRecentWeather Weather; _fooS sprintf "t = %d td = %d" _scienceWeatherMetarTemperature Weather; _fooS sprintf "Wind dir = %d speed = %d gust = %d" _scienceWeatherMetarWind Weather; _fooS sprintf "Visibility : %d" [_scienceWeatherMetarVisibility Weather]; _fooF _scienceWeatherMetarWindchill Weather; _fooS sprintf "Windchill : %f" [_scienceWeatherMetarWindchill Weather]; // getMetar "LFML"; 0;;