1 /*
2  * Tlf - contest logging program for amateur radio operators
3  * Copyright (C) 2011, 2015 Thomas Beierlein <tb@forth-ev.de>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  */
19 
20 
21 #ifndef _BANDMAP_H
22 #define _BANDMAP_H
23 
24 #include <hamlib/rig.h>
25 #include "tlf.h"
26 
27 typedef struct {
28     char 	*call;
29     int 	freq;	/* freq in Hz */
30     char 	mode;
31     short 	band;
32     char	node;
33     unsigned int timeout;/* time (in seconds) left in bandmap */
34     char 	dupe;	/* only used internal in bm_show() */
35     int 	cqzone;	/* CQ zone */
36     int 	ctynr;	/* Country nr */
37     char 	*pfx; /* prefix */
38 } spot;
39 
40 #define SPOT_NEW	(bm_config.livetime)
41 #define SPOT_NORMAL	(SPOT_NEW * 95) / 100
42 #define SPOT_OLD	(SPOT_NEW * 2)  / 3
43 
44 typedef struct {
45     short allband;
46     short allmode;
47     short showdupes;
48     short skipdupes;
49     short livetime;
50     short onlymults;
51 } bm_config_t;
52 
53 extern bm_config_t bm_config;
54 
55 enum {
56     CB_DUPE = 8,
57     CB_OLD,
58     CB_NORMAL,
59     CB_NEW,
60     CB_MULTI
61 };
62 
63 /*
64  * write bandmap spots to a file
65  */
66 void bmdata_write_file();
67 
68 void bm_init();
69 
70 void bm_add(char *s);
71 
72 void bm_menu();
73 
74 /** add a new spot to bandmap data
75  * \param call  	the call to add
76  * \param freq	 	on which frequency heard
77  * \param reason	- new cluster spot
78  * 			- local announcement (Ctrl-A)
79  * 			- own cluster announcement (Ctrl-B)
80  * 			- just worked in S&P
81  */
82 void bandmap_addspot(char *call, freq_t freq, char node);
83 /*
84  * - if call already on that band and mode replace old entry with new one and
85  *   set age to 0 otherwise add it to collection
86  * - if other call on same frequency (with some tolerance) replace it and set
87  *   age to 0
88  * - round all frequencies from cluster to 100 Hz, remember all other exactly
89  *   but display only rounded to 100 Hz - sort exact
90  */
91 
92 void bandmap_age();
93 /*
94  * - go through all entries
95  *   + decrement timeout
96  *   + set state to new, normal, aged or dead
97  *   + if dead -> drop it from collection
98  */
99 
100 void bandmap_show();
101 /*
102  * display depending on filter state
103  * - all bands on/off
104  * - all mode  on/off
105  * - dupes     on/off
106  *
107  * If more entries to show than place in window, show around current frequency
108  *
109  * mark entries according to age, source and worked state. Mark new multis
110  * - new 	brigth blue
111  * - normal	blue
112  * - aged	black
113  * - worked	small caps
114  * - new multi	underlined
115  * - self announced stations
116  *   		small preceeding letter for repoting station
117  *
118  * maybe show own frequency as dashline in other color
119  * (maybee green highlighted)
120  * - highligth actual spot if near its frequency
121  *
122  * Allow selection of one of the spots (switches to S&P)
123  * - Ctrl-G as known
124  * - '.' and cursor plus 'Enter'
125  *
126  * '.' goes into map, shows help line above and supports
127  * - cursormovement
128  * - 'ESC' leaves mode
129  * - 'Enter' selects spot
130  * - 'B', 'D', 'M' switches filtering for band, dupes and mode on or off.
131  */
132 
133 spot *bandmap_lookup(char *partialcall);
134 
135 spot *bandmap_next(unsigned int upwards, freq_t freq);
136 
137 void get_spot_on_qrg(char *dest, freq_t freq);
138 
139 #endif
140