1 /*
2  * gsat - a realtime satellite tracking graphical frontend to predict
3  *
4  * Copyright (C) 2001 by Xavier Crehueras, EB3CZS
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19  *
20  * Look at the README for more information on the program.
21  */
22 
23 /* Global definitions */
24 
25 #define GSATVERSION "1.1.0"
26 #define WINTITLE(VERS)  "gsat #VERS: Real-Time Satellite Tracking Display"
27 
28 #ifndef GSATLIBDIR
29 #define GSATLIBDIR "/usr/local/lib/gsat"
30 #endif
31 
32 #define MAXPLUGINS 20
33 #define DEFAULTPLUGINSDIR GSATLIBDIR"/plugins/"
34 
35 /* Buffer size for network reads */
36 #define NETBUFSIZE 1024
37 
38 /* Network timeout */
39 #define NETTIMEOUT 10
40 
41 /* Network maximum number of timeouts */
42 #define MAXTIMEOUTS 3
43 
44 /* Size of world map */
45 #define MAPSIZEX 700
46 #define MAPSIZEY 350
47 
48 /* Maximum number of dots for drawing orbits */
49 #define MAXDOTS 2800
50 
51 /* Size of az/el graphic */
52 #define AZELSIZEX 250
53 #define AZELSIZEY 250
54 
55 /* Maximum number of dots for drawing az/el graphic */
56 #define AZELMAXDOTS AZELSIZEX*2
57 
58 int errno;
59 
60 /* Network parameters */
61 char *predicthost;
62 char *predictport;
63 int netsocket;
64 
65 /* Main Widgets */
66 GtkWidget * mainwindow;
67 GtkWidget * dialog_connect;
68 GtkWidget * dialog_preferences;
69 GtkWidget * dialog_azel_graph;
70 GtkWidget * dialog_dbedit;
71 GtkWidget * dialog_about;
72 
73 /* Main control parameters */
74 int connected;
75 int timeUTC;
76 int drawgrid;
77 int satfootprint;
78 int qthfootprint;
79 int drawtrack;
80 int autofreq;
81 int azelgraph;
82 int enableupdoppler;
83 int enabledowndoppler;
84 char predictversion[10];
85 GList *satlist;
86 char statusmsg[256];
87 float lastel;
88 gint selectedrow;
89 GList *modelist;
90 GList *uplinklist;
91 GList *downlinklist;
92 GList *beaconlist;
93 
94 /* Graphics parameters */
95 GdkPixmap *drawmap;
96 GdkPixmap *sourcemap;
97 GdkPoint dots[MAXDOTS];
98 gint ndots;
99 GdkFont *drawfont;
100 GdkColor yellowclr, redclr, purpleclr, cyanclr, blueclr;
101 GdkGC *yellow_gc, *red_gc, *purple_gc, *cyan_gc, *blue_gc;
102 GdkPixmap *drawazel;
103 GdkPixmap *sourceazel;
104 GdkPoint azeldots[AZELMAXDOTS];
105 gint nazeldots;
106 
107 /* Program flags */
108 int doprediction;
109 int newsat;
110 
111 /* Plugin interface functions */
112 char * (*plugin_info_uplink)( void );
113 int (*plugin_open_rig_uplink)( char * config );
114 void (*plugin_close_rig_uplink)( void );
115 void (*plugin_set_uplink_frequency)( double frequency );
116 char * (*plugin_info_downlink)( void );
117 int (*plugin_open_rig_downlink)( char * config );
118 void (*plugin_close_rig_downlink)( void );
119 void (*plugin_set_downlink_frequency)( double frequency );
120 char * (*plugin_info_beacon)( void );
121 int (*plugin_open_rig_beacon)( char * config );
122 void (*plugin_close_rig_beacon)( void );
123 void (*plugin_set_beacon_frequency)( double frequency );
124 char * (*plugin_info_rotor)( void );
125 int (*plugin_open_rotor)( char * config );
126 void (*plugin_close_rotor)( void );
127 void (*plugin_set_rotor)( double azimuth, double elevation );
128 
129 /* Plugin control parameters */
130 int uppluginenable;
131 int enableupdoppler;
132 char * uppluginconfig;
133 void * upplugin_handle;
134 
135 int downpluginenable;
136 int enabledowndoppler;
137 char * downpluginconfig;
138 void * downplugin_handle;
139 
140 int beaconpluginenable;
141 int enablebeacondoppler;
142 char * beaconpluginconfig;
143 void * beaconplugin_handle;
144 
145 int rotorpluginenable;
146 int enablerotor;
147 char * rotorpluginconfig;
148 void * rotorplugin_handle;
149 
150 GList *pluginlist;
151 char pluginfiles[MAXPLUGINS][30];
152 char plugindescriptions[MAXPLUGINS][30];
153 char pluginsdir[256];
154 
155 GList *rotorpluginlist;
156 char rotorpluginfiles[MAXPLUGINS][30];
157 char rotorplugindescriptions[MAXPLUGINS][30];
158 
159 /* Preferences */
160 char prefs_grid[1];
161 char prefs_utctime[1];
162 char prefs_satfootprint[1];
163 char prefs_qthfootprint[1];
164 char prefs_track[1];
165 char prefs_autofreq[1];
166 char prefs_aos_command[1024];
167 char prefs_los_command[1024];
168 char prefs_up_plugin[256];
169 char prefs_up_plugin_config[256];
170 char prefs_down_plugin[256];
171 char prefs_down_plugin_config[256];
172 char prefs_beacon_plugin[256];
173 char prefs_beacon_plugin_config[256];
174 char prefs_rotor_plugin[256];
175 char prefs_rotor_plugin_config[256];
176