From f6bbd479a1c5ebc8a82ecd9ac52ec44d229e342b Mon Sep 17 00:00:00 2001 From: aa1vs Date: Sun, 4 Sep 2011 23:14:07 +0000 Subject: [PATCH] Cleanup comments and code with satellite status updates. git-svn-id: https://gpredict.svn.sourceforge.net/svnroot/gpredict/trunk@894 ab6734ba-2843-0410-b83b-99c217ef6c0f --- ChangeLog | 7 +++++++ src/tle-update.c | 35 ++++++++++++++++++++--------------- 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8bfcc2a..c034d04 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2011-09-04 Charles Suprin + + * ChangeLog + * src/tle-update.c + Cleanup comments and code with satellite status updates. + + 2011-09-01 Charles Suprin * ChangeLog diff --git a/src/tle-update.c b/src/tle-update.c index c6ed60e..2f4048a 100644 --- a/src/tle-update.c +++ b/src/tle-update.c @@ -889,9 +889,11 @@ static gint read_fresh_tle (const gchar *dir, const gchar *fnam, GHashTable *dat /* add data to hash table */ key = g_try_new0 (guint, 1); *key = catnr; - + + ntle = g_hash_table_lookup (data, key); + /* check if satellite already in hash table */ - if (g_hash_table_lookup (data, key) == NULL) { + if ( ntle == NULL) { /* create new_tle structure */ ntle = g_try_new (new_tle_t, 1); @@ -908,23 +910,26 @@ static gint read_fresh_tle (const gchar *dir, const gchar *fnam, GHashTable *dat retcode++; } else { - /* if the satellite in the hash is older than - the one just loaded, copy the values over. */ - ntle = g_hash_table_lookup (data, key); + /* satellite is already in hash */ + /* apply various merge routines */ if (ntle->epoch == tle.epoch) { - if (ntle->status!=tle.status) { - if (tle.status != OP_STAT_UNKNOWN) { - if (ntle->status!= OP_STAT_UNKNOWN) { - sat_log_log (SAT_LOG_LEVEL_ERROR, - _("%s:%s: Two different statuses for the same satellite at the same time."), - __FILE__, __FUNCTION__); - - } - ntle->status = tle.status; + /* if satellite epoch has the same time, merge status as appropriate */ + if ( (ntle->status != tle.status) && ( ntle->status != OP_STAT_UNKNOWN )) { + /* update status */ + ntle->status = tle.status; + if ( tle.status != OP_STAT_UNKNOWN ) { + /* log if there is something funny about the data coming in */ + sat_log_log (SAT_LOG_LEVEL_WARN, + _("%s:%s: Two different statuses for %s:%d at the same time."), + __FILE__, __FUNCTION__, ntle->satname,ntle->catnum); + } } } - else if (ntle->epoch epoch < tle.epoch ) { + /* if the satellite in the hash is older than + the one just loaded, copy the values over. */ + ntle->catnum = catnr; ntle->epoch = tle.epoch; ntle->status = tle.status;