File: make_cbr.pm

package info (click to toggle)
xtlf 0.0%2B1.03beta-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 1,140 kB
  • ctags: 233
  • sloc: perl: 6,072; sh: 160; makefile: 42
file content (185 lines) | stat: -rw-r--r-- 5,622 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
#! /usr/bin/perl -w


# Ham Radio log convert module logconvert.pm by PA0R.

# This program is published under the GPL license.
#   Copyright (C) 2005, 2006
#       Rein Couperus PA0R (rein@couperus.com)
# 
# *    logconvert.pm is free software; you can redistribute it and/or modify
# *    it under the terms of the GNU General Public License as published by
# *    the Free Software Foundation; either version 2 of the License, or
# *    (at your option) any later version.
# *
# *    logconvert.pm is distributed in the hope that it will be useful,
# *    but WITHOUT ANY WARRANTY; without even the implied warranty of
# *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# *    GNU General Public License for more details.
# *
# *    You should have received a copy of the GNU General Public License
# *    along with this program; if not, write to the Free Software
# *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

# Date: 05-04-06



#$exchangetype = "serial", "standardexchange";
#$standardexchange = "";

############################################################################
sub make_cbr {
############################################################################
my ($inputfile, $outputfile, $exchangetype, $standardexchange) = @_;

my ($Band, $Mode, $day, $month, $cntr, $cmpmonth, $year, $hour, $minutes, $number, $call,
	$logline, $rstsend, $rstrcvd, $exchange, $frequency	);
	
	open (IN, "<", $inputfile) or die "Cannot open log file $!";
	my @log = <IN>;
	close (IN);

	makesummary($outputfile);

	open (OUT, ">>", $outputfile) or die "Cannot open cabrillo file $!";

	@months = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
	$cntr = 0;

	foreach $logline (@log) {
		$Band = substr($logline, 0, 3);
		$Band =~ s/\s*//;
		$Mode = substr($logline, 3, 3);
		$Mode =~ s/\s*$//;
		if ($Mode eq "DIG") {
			$Mode = "RY";
		} elsif ($Mode eq "SSB") {
			$Mode = "PH";
		} else {
			$Mode = "CW";
		}
		$day = substr($logline, 7, 2);
		$month = substr($logline, 10, 3);
		$cntr = 0;
		foreach $cmpmonth (@months) {
			$cntr++;
			if ($month eq $cmpmonth) {
				last;
			} 
		}
		$month = sprintf ("0%d",$cntr);
		$month = substr($month, -2, 2);
		$year = "20" . substr($logline, 14, 2);
		$hour = substr ($logline, 17, 2);
		$minutes = substr($logline, 20, 2);
		$number = substr($logline, 23, 4);
		$call = substr($logline, 29, 13);
#		$call =~ s/\s*$//;
		$rstsend = substr($logline, 44, 3);
#		$rstsend =~ s/\s*$//;
		$rstrcvd = substr($logline, 49, 3);
#		$rstrcvd =~ s/\s*$//;
		$exchange = substr($logline, 54, 6);
#		$exchange =~ s/\s*$//;
		$frequency = substr($logline, 84, 7);
		$frequency = int ($frequency);
		chomp $frequency;
		$pcall = $Mycall . "             ";
		$pcall = substr($pcall, 0, 13);

		$pexchange = $standardexchange . "      ";
 		$pexchange =~ s/\#/$number/g; 
		$pexchange = substr($pexchange, 0, 6);
		
#                              --------info sent------- -------info rcvd--------
#QSO: freq  mo date       time call          rst exch   call          rst exch   t
#QSO: ***** ** yyyy-mm-dd nnnn ************* nnn ****** ************* nnn ****** n
#QSO:  3799 PH 1999-03-06 0711 HC8N          59  700    W1AW          59  CT     0
#000000000111111111122222222223333333333444444444455555555556666666666777777777788
#123456789012345678901234567890123456789012345678901234567890123456789012345678901

	my $outline = sprintf ("QSO: %5s %s %s-%s-%s %s%s %13s %3s %6s %13s %3s %6s",$frequency, $Mode, $year, $month, $day, $hour, $minutes, $pcall, $rstsend,$pexchange, $call,  $rstrcvd, $exchange);		
		print OUT "$outline\n";
		
	}
	print OUT "END-OF-LOG:\n";

	close (OUT);

}

#######################################
sub makesummary {
#######################################
	my $outputfile = shift @_;
	
	my @messages = ();
	eval {
		open ($fh, "$ENV{HOME}/.xtlf/summarydata") or die "Cannot find messages\n";
		while (<$fh>) {
			if (/=(.*)/) {
				push @messages, $1;
			}
		}
		close ($fh);
	};
	if ($@) {
		print $@;
	}

open ($fh, ">", $outputfile) or die "cannot open output file $outputfile: $!";
	print $fh "START-OF-LOG: 2.0\n";
	print $fh "ARRL-SECTION: " . $messages[1] ."\n";
	print $fh "CALLSIGN: " . $messages[0] ."\n";
	print $fh "CONTEST: " . $messages[7] ."\n";
	print $fh "CATEGORY: ";
	if ($messages[2]) { print $fh $messages[2] . " ";}
	if ($messages[3]) { print $fh $messages[3] . " ";}
	if ($messages[4]) { print $fh $messages[4] . " ";}
	if ($messages[5]) { print $fh $messages[5] . " ";}
	print $fh "\n";
	print $fh "CATEGORY-ASSISTED:" . $messages[6] ."\n";
	if ($messages[9]) { 
		print $fh "CATEGORY-OVERLAY: " . $messages[9] . "\n";
	}
	if ($messages[8]) { 
		print $fh "OPERATORS: " . $messages[8] . "\n";
	}
	print $fh "CLAIMED-SCORE: " . $totalscore . "\n";
	if ($messages[19]) { 
		print $fh "CLUB: " . $messages[19] . "\n";
	}
	print $fh "CREATED-BY: " . "Xtlf-1.0.0" ."\n";
	if ($messages[16]) { 
		print $fh "CATEGORY-DXPEDITION: " . $messages[16] . "\n";
	}
	if ($messages[17]) { 
		print $fh "CATEGORY-TIME: " . $messages[17] . "\n";
	}
	if ($messages[18]) { 
		print $fh "IOTA-ISLAND-NAME: " . $messages[18] . "\n";
	}
	if ($messages[10]) { 
		print $fh "NAME: " . $messages[10] . "\n";
	}
	if ($messages[11]) { 
		print $fh "ADDRESS: " . $messages[11] . "\n";
	}
	if ($messages[12]) { 
		print $fh "ADDRESS: " . $messages[12] . "\n";
	}
	if ($messages[13]) { 
		print $fh "ADDRESS: " . $messages[13] . "\n";
	}
	if ($messages[14]) { 
		print $fh "ADDRESS: " . $messages[14] . "\n";
	}
	if ($messages[15]) { 
		print $fh "SOAPBOX: " . $messages[15] . "\n";
	}

close ($fh);

}
1;