#!perl use strict; use warnings; # Compile into EXE: # pp -o spotcollector2pskr.exe spotcollector2pskr.pl # pp -o spotcollector2pskr.exe -M DBIx::ContextualFetch -M Class::DBI::SQL::Transformer::Quotify spotcollector2pskr.pl use Data::Dumper; use lib '.'; use SCSpots; use PSKR; use Win32::TieRegistry( Delimiter => '/', ArrayValues => 0, ); print qq{ SpotCollector Local Spots To PSKReporter Bridge KJ4IZW v${PSKR::VERSION} http://dwestbrook.net/projects/ham/spotcollector2pskr/ }; my $dxlab = $Registry->{'CUser/Software/VB and VBA Program Settings/'}; if( ! $dxlab->{'SpotCollector'}->{'General//LookupGrid'} ){ print q{ERROR: Please enable the option: SpotCollector -> Config -> General -> "Lookup missing location info" }; } if( ! $dxlab->{'SpotCollector'}->{'QTH//LatDeg'} ){ # and LatMin, LonDeg, LonMin print q{ERROR: Please set the Latitude and Longitude in the section: SpotCollector -> Config -> General -> "Operator location" }; } if( ! $dxlab->{'WinWarbler'}->{'BroadbandDecode//AutoSpot'}, ){ print q{WARNING: Please enable the option: WinWarbler->Config->Broadband Decode->"create local spots in SpotCollector" }; } if( ! $dxlab->{'WinWarbler'}->{'Display//LocalSpotOnAcquisition'}, ){ print q{WARNING: Please enable the option: WinWarbler -> Config -> Log-> "local spot on callsign acquisition" }; } SCSpots->disconnect; my %seen; while(1){ my @t = gmtime(time - 70); my $lastTime = sprintf '%04d-%02d-%02d %02d:%02d:%02d', $t[5]+1900, $t[4]+1, $t[3], @t[2,1,0]; print "$lastTime\n"; SCSpots->connect; my @x = SCSpots->search_where( Network => 'local', mode => { '<>', ['JT65','JT65A'] }, # not working for some reason mode => \q{ NOT IN ('JT65','JT65A') }, LastTime => { '>=', $lastTime }, # this field is indexed SpotTime => { '>=', $lastTime }, # necessary? ); @x = grep { ! $seen{$_->index}++ } @x; printf "%s %s -- %s %s %s %s\n", $_->source, $_->origingrid, $_->spottime, $_->mode, $_->callsign, $_->dxgrid for @x; #exit; if( scalar @x ){ my $pskr = PSKR->new; my $mycall = $x[0]->source; my $mygrid = $x[0]->origingrid; my $n = $pskr->send_spots($mycall, $mygrid, \@x); printf "$n spots submitted\n"; } SCSpots->disconnect; #last; #debug sleep 60; }