#! perl # # use Win32::SerialPort 0.19; use Geo::WeatherNWS; use Geo::WeatherNOAA; use Astro::Sunrise; use LWP::Simple; use URI::URL; # ($sunrise, $sunset) = sunrise(YYYY,MM,DD,longitude,latitude,Time Zone,DST); ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); my $yr = $year + 1900; my $mnth = $mon + 1; ($sunrise, $sunset) = sunrise( $yr, $mnth, $mday, -93, 45.1, -6, $isdst ); my $content = get("http://www.menet.umn.edu/pressure"); die "Couldn't get it!" unless defined $content; my ($press) = ($content =~ /.(\d\d\d\.\d\d)/); print "Got Menet pressure\n"; # Pressure data locations my $pressurefile="W:/pressure/pressure"; my $pressuredata="W:/pressure/pressuredata"; use constant ADJUST => 1; # gets temps from the qk145 kit via win32-serialport my $line=0; my $iter=0; my $num=4000; my $ele = 0; my $cfgfile = "qk145.cfg"; ## my $tempdata="z:/dir/tpdt"; ($wdy, $mn, $dy, $tm, $yr) = split(' ',localtime()); my $time=localtime; my $t= ($wdy); #to clear feedback ## $PortObj = tie (*FH, 'Win32::SerialPort', $cfgfile) || die "Can't tie: $^E\n"; sleep 1; do { ############################################################################## while () { s/^\s+//; # Better than chomp because of funky s/\s+$//; # \n\r output next unless /^\d/; # Skip non-temps (e.g. status line) my ($line, $temp) = split; # Temp lines look like "1 0081.95" next unless $temp; # There weren't two fields (?) @tmp[$ele,$ele+1] = ($line,$temp) } $iter++; $ele=@tmp; } while ($iter < $num); # #print ("@tmp\n"); undef $PortObj; open(TEMPDATA,">>$tempdata") || die "tempdata: $! \n"; print TEMPDATA ("$dy-$mn-$yr $tm\t"); print TEMPDATA "\t@tmp\t"; print TEMPDATA "\n"; close TEMPDATA; print "Got local temps\n"; #wrote temps to a file my ($pressure)=$press; my ($presskpa)= $press/10; # open the pressure file and the pressure data record open(PRESSURE,">$pressurefile.tmp") || die "pressurefile.tmp: $! \n"; open(PRESSUREDATA,">>$pressuredata") || die "pressure: $! \n"; #write the pressure, padding out to at least 10 characters print PRESSURE "$pressure \n"; close PRESSURE; rename "$pressurefile.tmp","$pressurefile"; unlink "$pressurefile.tmp"; #append to the pressure data record if it's a real reading ($wdy, $mn, $dy, $tm, $yr) = split(' ',localtime()); my $time=localtime; # sleep a few so you don't run into the pressureget script sleep 4; # Configuration variables my $htmlfile="z:/dir/index.html"; my $htmlheader="z:/dir/hdr.html"; my $htmlfooter="z:/dir/ftr.html"; $pressurefile="z:/dir/file1"; my $storagefile="z:/pressure/file2"; # Open html files and the current pressure open(HEADER,"<$htmlheader"); open(FOOTER,"<$htmlfooter"); open(HTML,">$htmlfile.tmp"); open(PRESSURE,"$pressurefile"); # Write header to html while(
) { print HTML; } # Write the current pressure to the file $pressure=; $currenttime=scalar localtime; chomp $pressure; $correctedpressure=($pressure/3.3863886)/exp(-219.46/7000); my $cityb = 'Minneapolis'; my $state = 'MN'; ($date,$warnings,$forecast,$coverage) = process_city_zone($cityb,$state,'','get'); my $max_items = 4; my $cols = (keys %$forecast); $cols = $max_items; my $Report=Geo::WeatherNWS::new(); $Report->getreport('kmsp'); # For Minneapolis, MN if ($Report->{error}) { print "NWS $Report->{errortext}\n"; } #write some of the weather data to a file for plotting print PRESSUREDATA "$dy-$mn-$yr $tm\t$presskpa\t"; print PRESSUREDATA "$Report->{temperature_f}\t$Report->{dewpoint_f}\t$Report->{pressure_inhg}"; print PRESSUREDATA "\t@tmp[1]\t@tmp[3]\n"; close PRESSUREDATA; print "Got NWS Report\n"; print HTML '
'; print HTML '
Current Conditions


'; print HTML "At $currenttime the "; print HTML "Current Weather Conditions at Minneapolis St Paul Intl Airport are:
\n"; print HTML 'Temperature: '; print HTML $Report->{temperature_f} ; print HTML ''; print HTML " degrees F\n
"; print HTML "Dew Point: "; print HTML $Report->{dewpoint_f}; # Dewpoint (degrees f) print HTML " degrees F\n
"; print HTML "Barometric Pressure: "; print HTML $Report->{pressure_inhg}; print HTML " inHg\n
"; # If it isnt raining, etc - just print cloud cover if ($Report->{conditionstext}) { print HTML "Conditions: $Report->{conditionstext}\n"; } else { print HTML "Current Conditions: $Report->{cloudcover}\n"; } print HTML '
'; print HTML 'Here is the current view looking northwest from the ME building at the University of Minnesota.
'; print HTML ''; print HTML 'Weather Cam
'; print HTML '
The Local Forecast


'; #print forecast cell foreach my $key ( (keys %$forecast)[0..($cols - 1)] ) { print HTML "$key: $forecast->{$key}\n
"; } print "Got NOAA forecast\n"; print HTML "The sun will rise today at $sunrise\n
"; print HTML "and will set at $sunset\n
"; print HTML '
'; my $tempf = ( @tmp[3] * 9 / 5 ) + 32; print HTML "
The current temperature outside the 4th floor"; printf HTML " of the ME Building is %2.2f\n", @tmp[3]; printf HTML " deg C, or %2.2f\n", $tempf; print HTML " def F.
"; printf HTML "The current pressure in ME155 is %2.2f\n", $presskpa; print HTML " kPa.
"; # Add footer to html while(