home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.ee.pdx.edu
/
2014.02.ftp.ee.pdx.edu.tar
/
ftp.ee.pdx.edu
/
oss
/
cvs-2004
/
OpenHamLog
/
src
/
LogItem.java,v
< prev
next >
Wrap
Text File
|
2003-08-12
|
17KB
|
860 lines
head 1.12;
access;
symbols;
locks; strict;
comment @# @;
1.12
date 2003.08.12.03.44.36; author htodd; state Exp;
branches;
next 1.11;
1.11
date 2003.08.04.19.35.01; author htodd; state Exp;
branches;
next 1.10;
1.10
date 2003.08.04.05.46.55; author htodd; state Exp;
branches;
next 1.9;
1.9
date 2003.08.03.22.59.00; author htodd; state Exp;
branches;
next 1.8;
1.8
date 2003.08.03.00.00.49; author htodd; state Exp;
branches;
next 1.7;
1.7
date 2003.07.30.19.44.40; author htodd; state Exp;
branches;
next 1.6;
1.6
date 2003.07.29.00.03.34; author htodd; state Exp;
branches;
next 1.5;
1.5
date 2003.07.28.19.50.04; author htodd; state Exp;
branches;
next 1.4;
1.4
date 2003.07.23.21.37.33; author htodd; state Exp;
branches;
next 1.3;
1.3
date 2003.07.21.22.06.51; author htodd; state Exp;
branches;
next 1.2;
1.2
date 2003.07.17.04.38.48; author htodd; state Exp;
branches;
next 1.1;
1.1
date 2003.07.17.02.38.48; author htodd; state Exp;
branches;
next ;
desc
@@
1.12
log
@Kinda works as a filter.
@
text
@/* file name : LogItem.java
* authors : Hisashi T Fujinaka
* created : Wed Jul 16 12:08:33 2003
*
* Copyright (c) 2003 Hisashi T Fujinaka
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*
$log$
*
*/
import java.io.*;
import java.util.*;
/**
* LogItem
*
* @@author Hisashi T Fujinaka
* @@version 0.1
*/
public class LogItem {
int band;
String call;
String county;
String comment;
int cq_zone;
int dxcc_adif; //dxcc country number
int dxcc_arrl; //dxcc country number
int dxcc_accept;
int dxcc_submit;
float freq;
String gridsquare;
String iota;
String mode;
String name;
boolean qsl_rcvd;
boolean qsl_sent;
String QSL_VIA;
int QSLRDATE;
int QSLSDATE;
int QSO_DATE;
String QTH;
String RST_RCVD;
String RST_SENT;
String STATE;
int time_on;
float TX_PWR;
/**
* addBand
*
* @@param inband, an int defining a ham band
* @@return whether it's a ham band
*/
boolean addBand(int inband) {
if (bandCheck(inband)) {
band = inband;
return true;
}
inband = 0;
return false;
}
/**
* add a call (no checking yet)
*
* @@param incall String of call to insert
* @@return
*/
boolean addCall(String incall) {
call = incall;
return true;
}
/**
* add a US County (no checking yet)
*
* @@param incounty
* @@return
*/
boolean addCounty(String incounty) {
county = incounty;
return true;
}
/**
* add a comment (no checking)
*
* @@param incomment
*/
void addComment(String incomment) {
comment = incomment;
}
/**
*
*
* @@param incq_zone
* @@return
*/
boolean addCQZone(int incq_zone) {
cq_zone = incq_zone;
return true;
}
boolean addDXCC_adif(int indxcc_adif) {
dxcc_adif = indxcc_adif;
dxcc_arrl = adif2arrl(indxcc_adif);
if (dxcc_arrl == 0) {
dxcc_adif = 0;
return false;
}
return true;
}
boolean addDXCC_arrl(int indxcc_arrl) {
dxcc_arrl = indxcc_arrl;
dxcc_adif = arrl2dxcc(indxcc_arrl);
if (dxcc_adif == 0) {
dxcc_adif = 0;
return false;
}
return true;
}
boolean addDXCCAccept(int indxcc_accept) {
if (dateCheck(indxcc_accept) && (indxcc_accept > dxcc_submit)) {
dxcc_accept = indxcc_accept;
return true;
}
return false;
}
boolean addDXCCSubmit (int indxcc_submit) {
if (dateCheck(indxcc_submit) && (dxcc_accept > indxcc_submit)) {
dxcc_submit = indxcc_submit;
return true;
}
return false;
}
boolean addFreq(float infreq) {
int check_band = whichBand(infreq);
if (band != 0 && band != check_band)
return false;
freq = infreq;
return true;
}
boolean addGridSquare(String ingridsquare) {
gridsquare = ingridsquare;
return true;
}
boolean addIOTA(String iniota) {
iota = iniota;
return true;
}
boolean addMode(String inmode) {
if (band != 0 && bandCheck(band, inmode)) {
mode = inmode;
return true;
} else if (band == 0) {
mode = inmode;
}
mode = inmode;
return false;
}
void addName(String inname) {
name = inname;
}
void addQSLRcvd() {
qsl_rcvd = true;
}
void addQSLSent() {
qsl_sent = true;
}
void addQSLVia(String inQSL_VIA) {
QSL_VIA = inQSL_VIA;
}
boolean addQSLRDate(int inQSLRDATE) {
if (dateCheck(inQSLRDATE)) {
QSLRDATE = inQSLRDATE;
return true;
}
return false;
}
boolean addQSLSDate(int inQSLSDATE) {
if (dateCheck(inQSLSDATE)) {
QSLSDATE = inQSLSDATE;
return true;
}
return false;
}
boolean addQSODate(int inQSO_DATE) {
if (dateCheck(inQSO_DATE)) {
QSO_DATE = inQSO_DATE;
return true;
}
return false;
}
void addQTH(String inQTH) {
QTH = inQTH;
}
void addRST_RCVD(String inRST_RCVD) {
RST_RCVD = inRST_RCVD;
}
void addRST_SENT(String inRST_SENT) {
RST_SENT = inRST_SENT;
}
boolean addState(String inSTATE) {
if (stateCheck(inSTATE)) {
STATE = inSTATE;
return true;
}
return false;
}
void addTime_On(int intime_on) {
time_on = intime_on;
}
void addTX_PWR(float inTX_PWR) {
TX_PWR = inTX_PWR;
}
/**
* should check for valid state - not implemented yet
*
* @@param checkState
* @@return
*/
boolean stateCheck(String checkState) {
// needs to be fixed
return true;
}
boolean dateCheck(int checkDate) {
// needs to be fixed
return true;
}
int arrl2dxcc(int indxcc_arrl) {
if (((indxcc_arrl > 0) && (indxcc_arrl < 511)) ||
(indxcc_arrl == 512)) {
return indxcc_arrl;
} else if (indxcc_arrl == 511) {
return 513;
} else if (indxcc_arrl == 513) {
return 511;
}
return 0;
}
int adif2arrl(int indxcc_adif) {
//things are symmetric for now
return arrl2dxcc(indxcc_adif);
}
// band checks for US Region 2
// return the band for a freq
int whichBand(float freq) {
if (freq >= 1.8 && freq <= 2.0)
return 160;
if (freq >= 3.5 && freq <= 4.0)
return 80;
if (freq == 5.3305 ||
freq == 5.3465 ||
freq == 5.3665 ||
freq == 5.3715 ||
freq == 5.4035)
return 60;
if (freq >= 7.0 && freq <= 7.3)
return 40;
if (freq >= 10.1 && freq <= 10.15)
return 30;
if (freq >= 14.0 && freq <= 14.35)
return 20;
if (freq >= 18.068 && freq <= 18.168)
return 17;
if (freq >= 21.0 && freq <= 21.45)
return 15;
if (freq >= 24.89 && freq <= 24.99)
return 12;
if (freq >= 28.0 && freq <= 29.7)
return 10;
if (freq >= 50.0 && freq <=54.0)
return 6;
return 0;
}
// check to see if freq is in the voice subband
boolean voiceCheck(float freq) {
if ((freq >= 1.8 && freq <= 2.0) ||
(freq >= 3.75 && freq <= 4.0) ||
(freq == 5.3305 ||
freq == 5.3465 ||
freq == 5.3665 ||
freq == 5.3715 ||
freq == 5.4035) ||
(freq >= 7.15 && freq <= 7.3) ||
(freq >= 14.15 && freq <= 14.35) ||
(freq >= 18.110 && freq <= 18.168) ||
(freq >= 21.2 && freq <= 21.45) ||
(freq >= 24.93 && freq <= 24.99) ||
(freq >= 28.3 && freq <= 29.7) ||
(freq >= 50.1 && freq <=54.0))
return true;
return false;
}
// the freq check
boolean bandCheck(float freq) {
if ((freq >= 1.8 && freq <= 2.0) ||
(freq >= 3.5 && freq <= 4.0) ||
freq == 5.3305 ||
freq == 5.3465 ||
freq == 5.3665 ||
freq == 5.3715 ||
freq == 5.4035 ||
(freq >= 7.0 && freq <= 7.3) ||
(freq >= 10.1 && freq <= 10.15) ||
(freq >= 14.0 && freq <= 14.35) ||
(freq >= 18.068 && freq <= 18.168) ||
(freq >= 21.0 && freq <= 21.45) ||
(freq >= 24.89 && freq <= 24.99) ||
(freq >= 28.0 && freq <= 29.7) ||
(freq >= 50.0 && freq <=54.0)) {
return true;
}
return false;
}
// the band check
boolean bandCheck(int band) {
if (band == 160 ||
band == 80 ||
band == 60 ||
band == 40 ||
band == 30 ||
band == 20 ||
band == 17 ||
band == 15 ||
band == 12 ||
band == 10 ||
band == 6) {
return true;
}
return false;
}
// check that band and freq match
boolean bandCheck(float freq, int band) {
int bandCheck = whichBand(freq);
if (band == bandCheck)
return true;
return false;
}
// see if in voice subband
//
boolean bandCheck(float freq, int band, String mode) {
// if it's CW, it's OK, except for 60M
if (mode == "CW" && band != 60) {
return (bandCheck(freq, band));
}
// if it's RTTY, it's OK except for some of 6M and 60M
if ((mode == "RTTY" || mode == "PSK31") && (band != 60)) {
if (band == 6 && freq >= 50.1 && freq <= 54.0)
return true;
return (bandCheck(freq, band));
}
return voiceCheck(freq);
}
boolean bandCheck(float freq, String mode) {
int check_band = whichBand(freq);
// if it's CW, it's OK, except for 60M
if (mode == "CW" && check_band != 60) {
return (bandCheck(freq, check_band));
}
// if it's RTTY, it's OK except for some of 6M and 60M
if ((mode == "RTTY" || mode == "PSK31") && (check_band != 60)) {
if (check_band == 6 && freq >= 50.1 && freq <= 54.0)
return true;
return (bandCheck(freq, check_band));
}
return voiceCheck(freq);
}
String convDate(int compressedDate) {
int year_int = compressedDate/10000;
int month_int = (compressedDate/100)%100 - 1;
int day_int = (compressedDate)%100;
GregorianCalendar cal = new GregorianCalendar();
int this_year = cal.get(GregorianCalendar.YEAR);
String month_s[] = {
"Jan", "Feb", "Mar",
"Apr", "May", "Jun",
"Jul", "Aug", "Sep",
"Oct", "Nov", "Dec"
};
int month_l[] = {
31,28,31,30,
31,30,31,31,
30,31,30,31
};
// year check, arbitrarily start when dxcc awards start.
//
// XXX
//
if ((year_int < 1945) || (year_int > this_year)) {
System.out.println("ERROR: year calculated wrong " + year_int);
return null;
}
if ((month_int < 0) || (month_int > 11)) {
System.out.println("ERROR: month calculated wrong " + month_int);
return null;
}
if ((month_int == 1) && (year_int%4 == 0) && (year_int%100 != 0) &&
(day_int > 29)) {
// leap year date check
System.out.println("ERROR: day calculated wrong: ");
return null;
} else if (day_int > month_l[month_int]) {
// regular year check
System.out.println("ERROR: day calculated wrong");
return null;
}
Integer yearI = new Integer(year_int);
Integer dayI = new Integer(day_int);
String converted = yearI.toString() +
month_s[month_int] + dayI.toString();
return converted;
}
String printLabel() {
// perform some checks
if (call == null ||
QSO_DATE == 0 ||
time_on == 0 ||
band == 0 ||
mode == null) {
return null;
}
String qsoDt = convDate(QSO_DATE);
String labelText = new String(call + "\\\\\nDate&UTC&Band&RS(T)&2x\\\\\n");
labelText = labelText + qsoDt + "&" + time_on + "&" + band + "&" +
RST_SENT + "&" + mode;
return labelText;
}
}
@
1.11
log
@Now it writes to a file.
@
text
@d488 3
a490 3
String labelText = new String(call + "\nDate\tUTC\tBand\tRS(T)\t2x\n");
labelText = labelText + qsoDt + "\t" + time_on + "\t" + band + "\t" +
RST_SENT + "\t" + mode;
@
1.10
log
@Sorta works now!
@
text
@d478 1
a478 1
void printLabel() {
d480 7
a486 7
// if (call == null ||
// QSO_DATE == 0 ||
// time_on == 0 ||
// band == 0 ||
// mode == null) {
// return;
// }
d488 3
d492 1
a492 6
System.out.println(call);
System.out.println("Date\tUTC\tBand\tRS(T)\t2x");
System.out.println(qsoDt + "\t" + time_on + "\t" + band + "\t" +
RST_SENT + "\t" + mode);
return;
@
1.9
log
@Need to fix RST.
@
text
@d181 4
a184 1
}
d487 1
a487 1
String qsoS = convDate(QSO_DATE);
d491 2
a492 1
System.out.println(qsoS + "\t" + time_on + "\t" + band + "\t" + mode);
@
1.8
log
@Some Saturday work.
@
text
@a427 5
System.out.println("compressedDate: " + compressedDate);
System.out.println("year: " + year_int);
System.out.println("month: " + month_int);
System.out.println("day: " + day_int);
d486 2
a487 1
System.out.println(call + "Date\tUTC\tBand\tRS(T)\t2x");
@
1.7
log
@7/30/2003 class
@
text
@d426 1
a426 1
int this_year = cal.get(GregorianCalendar.YEAR) - 1900;
@
1.6
log
@Time for debugging.
@
text
@d428 5
d447 3
a449 3
//
// XXX
//
d451 1
a451 1
System.out.println("ERROR: year calculated wrong");
d456 1
a456 1
System.out.println("ERROR: month calculated wrong");
d463 1
a463 1
System.out.println("ERROR: day calculated wrong");
d482 7
a488 7
if (call == null ||
QSO_DATE == 0 ||
time_on == 0 ||
band == 0 ||
mode == null) {
return;
}
@
1.5
log
@Started added QSL adding.
@
text
@d25 1
a25 1
* $log$
d39 26
a64 26
private int band;
private String call;
private String county;
private String comment;
private int cq_zone;
private int dxcc_adif; //dxcc country number
private int dxcc_arrl; //dxcc country number
private int dxcc_accept;
private int dxcc_submit;
private float freq;
private String gridsquare;
private String iota;
private String mode;
private String name;
private boolean qsl_rcvd;
private boolean qsl_sent;
private String QSL_VIA;
private int QSLRDATE;
private int QSLSDATE;
private int QSO_DATE;
private String QTH;
private String RST_RCVD;
private String RST_SENT;
private String STATE;
private int time_on;
private float TX_PWR;
d419 57
a475 1
void printLabel() {
d477 8
a484 2
if (call == null ||
call
d486 2
d489 1
d491 1
@
1.4
log
@Wed Jul 23
@
text
@d201 1
a201 1
boolean addQSLRdate(int inQSLRDATE) {
d418 5
@
1.3
log
@Monday July 21.
@
text
@d73 1
a73 1
if (checkBand(inband)) {
d125 1
a125 1
dxcc_arrl = adif2dxcc(indxcc_adif);
d143 125
a267 19
private int dxcc_accept;
private int dxcc_submit;
private float freq;
private String gridsquare;
private String iota;
private String mode;
private String name;
private boolean qsl_rcvd;
private boolean qsl_sent;
private String QSL_VIA;
private int QSLRDATE;
private int QSLSDATE;
private int QSO_DATE;
private String QTH;
private String RST_RCVD;
private String RST_SENT;
private String STATE;
private int time_on;
private float TX_PWR;
a285 1
d340 1
a340 1
boolean checkBand(float freq) {
d362 1
a362 1
boolean checkBand(int band) {
d380 3
a382 3
boolean checkBand(float freq, int band) {
int checkBand = whichBand(freq);
if (band == checkBand)
d390 1
a390 1
boolean checkBand(float freq, int band, String mode) {
d393 1
a393 1
return (checkBand(freq, band));
d399 16
a414 1
return (checkBand(freq, band));
@
1.2
log
@Make LogItem compile for now.
@
text
@d66 6
d80 100
@
1.1
log
@New file LogItem.java
@
text
@d46 2
a47 2
private MinDate dxcc_accept;
private MinDate dxcc_submit;
d56 3
a58 3
private MinDate QSLRDATE;
private MinDate QSLSDATE;
private MinDate QSO_DATE;
d109 1
a109 1
bool voiceCheck(float freq) {
d129 1
a129 1
boolean bandCheck(float freq) {
d151 1
a151 1
boolean bandCheck(int band) {
d169 1
a169 1
boolean bandCheck(float freq, int band) {
d179 1
a179 1
boolean bandCheck(float freq, int band, String mode) {
d182 1
a182 1
return (bandCheck(freq, band));
d188 1
a188 1
return (bandCheck(freq, band));
@