mirror of
https://github.com/csete/gpredict
synced 2026-08-13 17:39:46 -04:00
Store frequencies as int64 instead of double.
Also add some sanity checks to ensure that we can handle various scenarios where either limit of up- or downlink is not specified, see issue #35. The calculations in rig-ctrl are stil ldone using double.
This commit is contained in:
parent
075976134d
commit
bf66478da8
3 changed files with 55 additions and 34 deletions
|
|
@ -1018,10 +1018,10 @@ static void trsp_tune_cb(GtkButton * button, gpointer data)
|
|||
return;
|
||||
|
||||
/* tune downlink */
|
||||
if ((ctrl->trsp->downlow > 0.0) && (ctrl->trsp->downhigh > 0.0))
|
||||
if ((ctrl->trsp->downlow > 0) && (ctrl->trsp->downhigh > 0))
|
||||
{
|
||||
freq = ctrl->trsp->downlow +
|
||||
fabs(ctrl->trsp->downhigh - ctrl->trsp->downlow) / 2;
|
||||
abs(ctrl->trsp->downhigh - ctrl->trsp->downlow) / 2;
|
||||
gtk_freq_knob_set_value(GTK_FREQ_KNOB(ctrl->SatFreqDown), freq);
|
||||
|
||||
/* invalidate RIG<->GPREDICT sync */
|
||||
|
|
@ -1029,10 +1029,10 @@ static void trsp_tune_cb(GtkButton * button, gpointer data)
|
|||
}
|
||||
|
||||
/* tune uplink */
|
||||
if ((ctrl->trsp->uplow > 0.0) && (ctrl->trsp->uphigh > 0.0))
|
||||
if ((ctrl->trsp->uplow > 0) && (ctrl->trsp->uphigh > 0))
|
||||
{
|
||||
freq = ctrl->trsp->uplow +
|
||||
fabs(ctrl->trsp->uphigh - ctrl->trsp->uplow) / 2;
|
||||
abs(ctrl->trsp->uphigh - ctrl->trsp->uplow) / 2;
|
||||
gtk_freq_knob_set_value(GTK_FREQ_KNOB(ctrl->SatFreqUp), freq);
|
||||
|
||||
/* invalidate RIG<->GPREDICT sync */
|
||||
|
|
@ -2796,7 +2796,7 @@ static void track_downlink(GtkRigCtrl * ctrl)
|
|||
return;
|
||||
|
||||
/* ensure that we have a useable transponder config */
|
||||
if ((ctrl->trsp->downlow > 0.0) && (ctrl->trsp->uplow > 0.0))
|
||||
if ((ctrl->trsp->downlow > 0) && (ctrl->trsp->uplow > 0))
|
||||
{
|
||||
down = gtk_freq_knob_get_value(GTK_FREQ_KNOB(ctrl->SatFreqDown));
|
||||
delta = down - ctrl->trsp->downlow;
|
||||
|
|
@ -2830,7 +2830,7 @@ static void track_uplink(GtkRigCtrl * ctrl)
|
|||
return;
|
||||
|
||||
/* ensure that we have a useable transponder config */
|
||||
if ((ctrl->trsp->downlow > 0.0) && (ctrl->trsp->uplow > 0.0))
|
||||
if ((ctrl->trsp->downlow > 0) && (ctrl->trsp->uplow > 0))
|
||||
{
|
||||
up = gtk_freq_knob_get_value(GTK_FREQ_KNOB(ctrl->SatFreqUp));
|
||||
delta = up - ctrl->trsp->uplow;
|
||||
|
|
|
|||
|
|
@ -41,6 +41,29 @@
|
|||
#define KEY_MODE "MODE"
|
||||
#define KEY_BAUD "BAUD"
|
||||
|
||||
static void check_trsp_freq(trsp_t * trsp)
|
||||
{
|
||||
/* ensure we don't have any negative frequencies */
|
||||
if (trsp->downlow < 0)
|
||||
trsp->downlow = 0;
|
||||
if (trsp->downhigh < 0)
|
||||
trsp->downhigh = 0;
|
||||
if (trsp->uplow < 0)
|
||||
trsp->uplow = 0;
|
||||
if (trsp->uphigh < 0)
|
||||
trsp->uphigh = 0;
|
||||
|
||||
if (trsp->downlow == 0 && trsp->downhigh > 0)
|
||||
trsp->downlow = trsp->downhigh;
|
||||
else if (trsp->downhigh == 0 && trsp->downlow > 0)
|
||||
trsp->downhigh = trsp->downlow;
|
||||
|
||||
if (trsp->uplow == 0 && trsp->uphigh > 0)
|
||||
trsp->uplow = trsp->uphigh;
|
||||
else if (trsp->uphigh == 0 && trsp->uplow > 0)
|
||||
trsp->uphigh = trsp->uplow;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read transponder data file.
|
||||
*
|
||||
|
|
@ -102,46 +125,44 @@ GSList *read_transponders(guint catnum)
|
|||
/* read transponder data */
|
||||
trsp->name = g_strdup(groups[i]);
|
||||
|
||||
trsp->uplow = g_key_file_get_double(cfg, groups[i], KEY_UP_LOW,
|
||||
&error);
|
||||
trsp->uplow = g_key_file_get_int64(cfg, groups[i], KEY_UP_LOW, &error);
|
||||
if (error != NULL)
|
||||
{
|
||||
sat_log_log(SAT_LOG_LEVEL_INFO, INFO_MSG, __func__, KEY_UP_LOW,
|
||||
name, groups[i]);
|
||||
g_clear_error(&error);
|
||||
trsp->uplow = 0.0;
|
||||
}
|
||||
|
||||
trsp->uphigh = g_key_file_get_double(cfg, groups[i], KEY_UP_HIGH,
|
||||
&error);
|
||||
trsp->uphigh = g_key_file_get_int64(cfg, groups[i], KEY_UP_HIGH,
|
||||
&error);
|
||||
if (error != NULL)
|
||||
{
|
||||
sat_log_log(SAT_LOG_LEVEL_INFO, INFO_MSG, __func__, KEY_UP_HIGH,
|
||||
name, groups[i]);
|
||||
g_clear_error(&error);
|
||||
trsp->uphigh = trsp->uplow;
|
||||
}
|
||||
|
||||
trsp->downlow = g_key_file_get_double(cfg, groups[i],
|
||||
KEY_DOWN_LOW, &error);
|
||||
trsp->downlow = g_key_file_get_int64(cfg, groups[i], KEY_DOWN_LOW,
|
||||
&error);
|
||||
if (error != NULL)
|
||||
{
|
||||
sat_log_log(SAT_LOG_LEVEL_INFO, INFO_MSG, __func__, KEY_DOWN_LOW,
|
||||
name, groups[i]);
|
||||
g_clear_error(&error);
|
||||
trsp->downlow = 0.0;
|
||||
}
|
||||
|
||||
trsp->downhigh = g_key_file_get_double(cfg, groups[i], KEY_DOWN_HIGH,
|
||||
&error);
|
||||
trsp->downhigh = g_key_file_get_int64(cfg, groups[i], KEY_DOWN_HIGH,
|
||||
&error);
|
||||
if (error != NULL)
|
||||
{
|
||||
sat_log_log(SAT_LOG_LEVEL_INFO, INFO_MSG, __func__, KEY_DOWN_HIGH,
|
||||
name, groups[i]);
|
||||
g_clear_error(&error);
|
||||
trsp->downhigh = trsp->downlow;
|
||||
}
|
||||
|
||||
/* check data to ensure consistency */
|
||||
check_trsp_freq(trsp);
|
||||
|
||||
trsp->invert = g_key_file_get_boolean(cfg, groups[i],
|
||||
KEY_INVERT, &error);
|
||||
if (error != NULL)
|
||||
|
|
@ -215,18 +236,18 @@ void write_transponders(guint catnum, GSList * trsp_list)
|
|||
continue;
|
||||
}
|
||||
|
||||
if (trsp->uplow > 0.0)
|
||||
g_key_file_set_double(trsp_data, trsp->name, KEY_UP_LOW,
|
||||
trsp->uplow);
|
||||
if (trsp->uphigh > 0.0)
|
||||
g_key_file_set_double(trsp_data, trsp->name, KEY_UP_HIGH,
|
||||
trsp->uphigh);
|
||||
if (trsp->downlow > 0.0)
|
||||
g_key_file_set_double(trsp_data, trsp->name, KEY_DOWN_LOW,
|
||||
trsp->downlow);
|
||||
if (trsp->downhigh > 0.0)
|
||||
g_key_file_set_double(trsp_data, trsp->name, KEY_DOWN_HIGH,
|
||||
trsp->downhigh);
|
||||
if (trsp->uplow > 0)
|
||||
g_key_file_set_int64(trsp_data, trsp->name, KEY_UP_LOW,
|
||||
trsp->uplow);
|
||||
if (trsp->uphigh > 0)
|
||||
g_key_file_set_int64(trsp_data, trsp->name, KEY_UP_HIGH,
|
||||
trsp->uphigh);
|
||||
if (trsp->downlow > 0)
|
||||
g_key_file_set_int64(trsp_data, trsp->name, KEY_DOWN_LOW,
|
||||
trsp->downlow);
|
||||
if (trsp->downhigh > 0)
|
||||
g_key_file_set_int64(trsp_data, trsp->name, KEY_DOWN_HIGH,
|
||||
trsp->downhigh);
|
||||
if (trsp->baud > 0.0)
|
||||
g_key_file_set_double(trsp_data, trsp->name, KEY_BAUD, trsp->baud);
|
||||
if (trsp->invert)
|
||||
|
|
|
|||
|
|
@ -32,10 +32,10 @@
|
|||
/* NOTE For beacons uplow=uphigh=0 and downlow=downhigh */
|
||||
typedef struct {
|
||||
gchar *name; /*!< The name of the transponder (same as config group) */
|
||||
gdouble uplow; /*!< Lower limit of uplink. */
|
||||
gdouble uphigh; /*!< Upper limit of uplink. */
|
||||
gdouble downlow; /*!< Lower limit of downlink. */
|
||||
gdouble downhigh; /*!< Upper limit of donlink. */
|
||||
gint64 uplow; /*!< Lower limit of uplink. */
|
||||
gint64 uphigh; /*!< Upper limit of uplink. */
|
||||
gint64 downlow; /*!< Lower limit of downlink. */
|
||||
gint64 downhigh; /*!< Upper limit of donlink. */
|
||||
gdouble baud; /*!< Baud rate > */
|
||||
gboolean invert; /*!< Flag indicating whether transponder is inverting. */
|
||||
gchar *mode; /*!< Mode descriptor. */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue