From ae0195ab312388deb8466816375addc155eadad9 Mon Sep 17 00:00:00 2001 From: James McKenzie Date: Sat, 18 Feb 2023 18:44:57 +0000 Subject: add code for fetching epheredies and ublox assit data --- metotime/decode.pl | 47 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 12 deletions(-) (limited to 'metotime') diff --git a/metotime/decode.pl b/metotime/decode.pl index 9962c75..f2e4fd0 100755 --- a/metotime/decode.pl +++ b/metotime/decode.pl @@ -674,8 +674,15 @@ my @cycle_4_lut = ( my @cycle_2_lut = ( "Forecast day 1", "Forecast day 2", ); -sub decode($$$) { - my ( $dt, $mins_since_midnight, $bits ) = @_; +sub match($$) +{ +my ($a,$re)=@_; +return 1 if ($a =~/\Q$re/); +return 0; +} + +sub decode($$$$$) { + my ( $dt, $mins_since_midnight, $bits, $string, $where ) = @_; $mins_since_midnight = int( ( $mins_since_midnight - 1 ) / 3 ); @@ -683,30 +690,46 @@ sub decode($$$) { my $region = $mins_since_midnight % 60; my $day = int( $cycle / 2 ); + my $region_str=$location_lut[$region]; + my $w = decode_bits( $bits, $cycle % 2 ); if ( $cycle < 7 ) { - print "region: ", $location_lut[$region], ", cycle: ", + + if (match($region_str,$where)) { + print $string,"\n"; + print "region: ", $region_str, ", cycle: ", $cycle_4_lut[$cycle], ", when: ", time_to_string( $dt, $day ), "\n"; print_prognosis($w); print_rest($w); +} } else { - print "region: ", $location_lut[$region], ", cycle: ", + my $sub_region = $region % 30; + $sub_region += 60; + my $sub_region_str = $location_lut[$sub_region]; + + if (match($region_str,$where) or match($sub_region_str,$where)) { + print $string,"\n"; + } + + if (match($region_str,$where)) { + print "region: ", $region_str, ", cycle: ", $cycle_4_lut[$cycle], ", when: ", time_to_string( $dt, $day ), "\n"; print_rest($w); + } - my $sub_region = $region % 30; + if (match($sub_region_str,$where)) { my $sub_cycle = int( $region / 30 ); my $sub_day = 1 + $sub_cycle; - $sub_region += 60; - print "region: ", $location_lut[$sub_region], ", cycle: ", + print "region: ", $sub_region_str, ", cycle: ", $cycle_2_lut[$sub_cycle], ", when: ", time_to_string( $dt, $sub_day ), "\n"; print_prognosis($w); + } } @@ -717,7 +740,7 @@ sub decode($$$) { # Step 1, fetch the squished up data for the last 24 hours from the clock # and reconstruct the whole data stream -my $bin = get("http://tock/meteotime.dat"); +my $bin = get("http://clock2k.hamachi.james.internal/meteotime.dat"); my $bs = unpack( 'b*', $bin ); my $d = []; @@ -775,7 +798,7 @@ for ( my $i = 0 ; $i < ( $sl - 2 ) ; ++$i ) { unless ( defined $plain ) { my $msg = sprintf( "Bad data at %02d:%02d", $hour, $min ); - print STDERR "BAD DATA $msg\n"; +# print STDERR "BAD DATA $msg\n"; next; } next unless defined $plain; @@ -786,9 +809,9 @@ for ( my $i = 0 ; $i < ( $sl - 2 ) ; ++$i ) { day => $day ); - printf "%04d-%02d-%02d %02d:%02d bits: %s\n", $year, $month, $day, - $hour, $min, b4($plain); + my $bits= sprintf("%04d-%02d-%02d %02d:%02d bits: %s", $year, $month, $day, + $hour, $min, b4($plain)); - decode( $dt, $mins_since_midnight, $plain ); + decode( $dt, $mins_since_midnight, $plain, $bits, $ARGV[0] ); } -- cgit v1.2.3