Merged master 8748
This commit is contained in:
@@ -1,55 +0,0 @@
|
||||
subroutine genft8(msg,msgsent,msgbits,itone)
|
||||
|
||||
! Encode an FT8 message, producing array itone().
|
||||
|
||||
use crc
|
||||
use packjt
|
||||
include 'ft8_params.f90'
|
||||
character*22 msg,msgsent
|
||||
character*87 cbits
|
||||
! logical checksumok
|
||||
integer*4 i4Msg6BitWords(12) !72-bit message as 6-bit words
|
||||
integer*1 msgbits(KK),codeword(3*ND)
|
||||
integer*1, target:: i1Msg8BitBytes(11)
|
||||
integer itone(NN)
|
||||
integer icos7(0:6)
|
||||
data icos7/2,5,6,0,4,1,3/ !Costas 7x7 tone pattern
|
||||
|
||||
call packmsg(msg,i4Msg6BitWords,itype) !Pack into 12 6-bit bytes
|
||||
call unpackmsg(i4Msg6BitWords,msgsent) !Unpack to get msgsent
|
||||
i3bit=0 !### temporary ###
|
||||
write(cbits,1000) i4Msg6BitWords,32*i3bit
|
||||
1000 format(12b6.6,b8.8)
|
||||
read(cbits,1001) i1Msg8BitBytes(1:10)
|
||||
1001 format(10b8)
|
||||
i1Msg8BitBytes(10)=iand(i1Msg8BitBytes(10),128+64+32)
|
||||
i1Msg8BitBytes(11)=0
|
||||
icrc12=crc12(c_loc(i1Msg8BitBytes),11)
|
||||
|
||||
! For reference, here's how to check the CRC
|
||||
! i1Msg8BitBytes(10)=icrc12/256
|
||||
! i1Msg8BitBytes(11)=iand (icrc12,255)
|
||||
! checksumok = crc12_check(c_loc (i1Msg8BitBytes), 11)
|
||||
! if( checksumok ) write(*,*) 'Good checksum'
|
||||
|
||||
write(cbits,1003) i4Msg6BitWords,i3bit,icrc12
|
||||
1003 format(12b6.6,b3.3,b12.12)
|
||||
read(cbits,1004) msgbits
|
||||
1004 format(87i1)
|
||||
|
||||
call encode174(msgbits,codeword) !Encode the test message
|
||||
|
||||
! Message structure: S7 D29 S7 D29 S7
|
||||
itone(1:7)=icos7
|
||||
itone(36+1:36+7)=icos7
|
||||
itone(NN-6:NN)=icos7
|
||||
k=7
|
||||
do j=1,ND
|
||||
i=3*j -2
|
||||
k=k+1
|
||||
if(j.eq.30) k=k+7
|
||||
itone(k)=codeword(i)*4 + codeword(i+1)*2 + codeword(i+2)
|
||||
enddo
|
||||
|
||||
return
|
||||
end subroutine genft8
|
||||
@@ -0,0 +1,89 @@
|
||||
program contest72
|
||||
|
||||
use packjt
|
||||
integer dat(12)
|
||||
logical text,bcontest,ok
|
||||
character*22 msg,msg0,msg1
|
||||
character*72 ct1,ct2
|
||||
character*12 callsign1,callsign2
|
||||
character*1 c0
|
||||
character*42 c
|
||||
character*6 mygrid
|
||||
data c/'0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ +-./?'/
|
||||
data bcontest/.true./
|
||||
data mygrid/"EM48 "/
|
||||
|
||||
! itype Message Type
|
||||
!--------------------
|
||||
! 1 Standardd message
|
||||
! 2 Type 1 prefix
|
||||
! 3 Type 1 suffix
|
||||
! 4 Type 2 prefix
|
||||
! 5 Type 2 suffix
|
||||
! 6 Free text
|
||||
! -1 Does not decode correctly
|
||||
|
||||
nargs=iargc()
|
||||
if(nargs.eq.0) open(10,file='contest_msgs.txt',status='old')
|
||||
|
||||
nn=0
|
||||
do imsg=1,9999
|
||||
if(nargs.eq.1) then
|
||||
if(imsg.gt.1) exit
|
||||
call getarg(1,msg0)
|
||||
else
|
||||
read(10,1001,end=999) msg0
|
||||
1001 format(a22)
|
||||
endif
|
||||
msg=msg0
|
||||
call packmsg(msg,dat,itype,bcontest)
|
||||
call unpackmsg(dat,msg1,bcontest,mygrid)
|
||||
ok=msg1.eq.msg0
|
||||
if(msg0.eq.' ') then
|
||||
write(*,1002)
|
||||
else
|
||||
if(jt_c2(1:1).eq.'W') msg0=' '//msg0(1:20)
|
||||
nn=nn+1
|
||||
write(*,1002) nn,msg0,ok,jt_itype,jt_nc1,jt_nc2,jt_ng,jt_k1,jt_k2
|
||||
1002 format(i1,'. ',a22,L2,i2,2i10,i6,2i8)
|
||||
if(index(msg1,' 73 ').gt.4) nn=0
|
||||
endif
|
||||
if(.not.ok) print*,msg0,msg1
|
||||
if(itype.lt.0 .or. itype.eq.6) cycle
|
||||
|
||||
if(msg(1:3).eq.'CQ ') then
|
||||
m=2
|
||||
write(ct1,1010) dat
|
||||
1010 format(12b6.6)
|
||||
! write(*,1014) ct1
|
||||
!1014 format(a72)
|
||||
cycle
|
||||
endif
|
||||
|
||||
i1=index(msg,'<')
|
||||
if(i1.eq.1) then
|
||||
m=0
|
||||
cycle
|
||||
endif
|
||||
|
||||
if(i.ge.5) then
|
||||
m=3
|
||||
cycle
|
||||
endif
|
||||
|
||||
if(msg(1:6).eq.'73 CQ ') then
|
||||
m=4
|
||||
cycle
|
||||
endif
|
||||
|
||||
call packmsg(msg,dat,itype,.false.)
|
||||
write(ct1,1010) dat
|
||||
call packtext(msg,nc1,nc2,ng,.false.,'')
|
||||
! write(ct2,1012) nc1,nc2,ng+32768
|
||||
!1012 format(2b28.28,b16.16)
|
||||
! write(*,1014) ct1
|
||||
! write(*,1014) ct2
|
||||
! write(*,1014)
|
||||
enddo
|
||||
|
||||
999 end program contest72
|
||||
@@ -1,145 +0,0 @@
|
||||
/*
|
||||
#Sov Mil Order of Malta: 15: 28: EU: 41.90: -12.43: -1.0: 1A:
|
||||
#1A;
|
||||
#Spratly Islands: 26: 50: AS: 9.88: -114.23: -8.0: 1S:
|
||||
#1S,9M0,BV9S;
|
||||
#Monaco: 14: 27: EU: 43.73: -7.40: -1.0: 3A:
|
||||
#3A;
|
||||
#Heard Island: 39: 68: AF: -53.08: -73.50: -5.0: VK0H:
|
||||
#=VK0IR;
|
||||
#Macquarie Island: 30: 60: OC: -54.60: -158.88: -10.0: VK0M:
|
||||
#=VK0KEV;
|
||||
#Cocos-Keeling: 29: 54: OC: -12.15: -96.82: -6.5: VK9C:
|
||||
#AX9C,AX9Y,VH9C,VH9Y,VI9C,VI9Y,VJ9C,VJ9Y,VK9C,VK9Y,VL9C,VL9Y,VM9C,VM9Y,
|
||||
#VN9C,VN9Y,VZ9C,VZ9Y,=VK9AA;
|
||||
*/
|
||||
|
||||
|
||||
#include "countrydat.h"
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
|
||||
|
||||
void CountryDat::init(const QString filename)
|
||||
{
|
||||
_filename = filename;
|
||||
_data.clear();
|
||||
}
|
||||
|
||||
QString CountryDat::_extractName(const QString line) const
|
||||
{
|
||||
int s1 = line.indexOf(':');
|
||||
if (s1>=0)
|
||||
{
|
||||
QString name = line.mid(0,s1);
|
||||
return name;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
void CountryDat::_removeBrackets(QString &line, const QString a, const QString b) const
|
||||
{
|
||||
int s1 = line.indexOf(a);
|
||||
while (s1 >= 0)
|
||||
{
|
||||
int s2 = line.indexOf(b);
|
||||
line = line.mid(0,s1) + line.mid(s2+1,-1);
|
||||
s1 = line.indexOf(a);
|
||||
}
|
||||
}
|
||||
|
||||
QStringList CountryDat::_extractPrefix(QString &line, bool &more) const
|
||||
{
|
||||
line = line.remove(" \n");
|
||||
line = line.replace("=","");
|
||||
line = line.replace(" ","");
|
||||
|
||||
_removeBrackets(line,"(",")");
|
||||
_removeBrackets(line,"[","]");
|
||||
_removeBrackets(line,"<",">");
|
||||
_removeBrackets(line,"~","~");
|
||||
|
||||
int s1 = line.indexOf(';');
|
||||
more = true;
|
||||
if (s1 >= 0)
|
||||
{
|
||||
line = line.mid(0,s1);
|
||||
more = false;
|
||||
}
|
||||
|
||||
QStringList r = line.split(',');
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
void CountryDat::load()
|
||||
{
|
||||
_data.clear();
|
||||
_countryNames.clear(); //used by countriesWorked
|
||||
|
||||
QFile inputFile(_filename);
|
||||
if (inputFile.open(QIODevice::ReadOnly))
|
||||
{
|
||||
QTextStream in(&inputFile);
|
||||
while ( !in.atEnd() )
|
||||
{
|
||||
QString line1 = in.readLine();
|
||||
if ( !in.atEnd() )
|
||||
{
|
||||
QString line2 = in.readLine();
|
||||
|
||||
QString name = _extractName(line1);
|
||||
if (name.length()>0)
|
||||
{
|
||||
_countryNames << name;
|
||||
bool more = true;
|
||||
QStringList prefixs;
|
||||
while (more)
|
||||
{
|
||||
QStringList p = _extractPrefix(line2,more);
|
||||
prefixs += p;
|
||||
if (more)
|
||||
line2 = in.readLine();
|
||||
}
|
||||
|
||||
QString p;
|
||||
foreach(p,prefixs)
|
||||
{
|
||||
if (p.length() > 0)
|
||||
_data.insert(p,name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
inputFile.close();
|
||||
}
|
||||
}
|
||||
|
||||
// return country name else ""
|
||||
QString CountryDat::find(QString prefix) const
|
||||
{
|
||||
prefix = prefix.toUpper ();
|
||||
auto pf = prefix;
|
||||
while (pf.size () >= 1)
|
||||
{
|
||||
if (_data.contains (pf))
|
||||
{
|
||||
QString country {_data.value (pf)};
|
||||
|
||||
//
|
||||
// deal with special rules that cty.dat does not cope with
|
||||
//
|
||||
|
||||
// KG4 2x1 and 2x3 calls that map to Gitmo are mainland US not Gitmo
|
||||
if (prefix.startsWith ("KG4") && prefix.size () != 5)
|
||||
{
|
||||
country.replace ("Guantanamo Bay", "United States");
|
||||
}
|
||||
|
||||
return country;
|
||||
}
|
||||
pf = pf.left (pf.size () - 1);
|
||||
}
|
||||
return QString {};
|
||||
}
|
||||
Reference in New Issue
Block a user