static int _updateTimeTag(void) // then update time tag of AIS { if (NULL == _ais_list) return FALSE; /* { // check global time - update time tag of all AIS each sec // FIXME: should be 0.5 sec GTimeVal now; g_get_current_time(&now); if ((now.tv_sec-_timeTick.tv_sec) < 1) return FALSE; g_get_current_time(&_timeTick); } */ // keep removing old AIS while (TRUE == _removeOldAIS()) _dumpAIS(); GTimeVal now; g_get_current_time(&now); for (guint i=0; i<_ais_list->len; ++i) { gchar str[127+1] = {'\0'}; _ais_t *ais = &g_array_index(_ais_list, _ais_t, i); if (-1.0 != ais->course) { #ifdef S52_USE_SOCK g_snprintf(str, 127, "%s %lis%s%03.f deg / %3.1f kt", ais->name, (now.tv_sec - ais->lastUpdate.tv_sec), NL, ais->course, ais->speed); #else g_snprintf(str, 127, "%s %lis%c%03.f deg / %3.1f kt", ais->name, (now.tv_sec - ais->lastUpdate.tv_sec), (int)NL, ais->course, ais->speed); #endif } else { g_snprintf(str, 127, "%s %lis", ais->name, now.tv_sec - ais->lastUpdate.tv_sec); } #ifdef S52_USE_SOCK _encodeNsend("S52_setVESSELlabel", "%lu,\"%s\"", ais->vesselH, str); #else if (FALSE == S52_setVESSELlabel(ais->vesselH, str)) { g_print("s52ais:_updateTimeTag(): FAIL setVESSELlabel = %s\n", str); _setAISDel(ais); g_array_remove_index_fast(_ais_list, i); //g_assert(0); } #endif } return TRUE; }
static int _updateTimeTag(void) // then update time tag of AIS { if (NULL == _ais_list) return FALSE; // keep removing old AIS while (TRUE == _removeOldAIS()) _dumpAIS(); GTimeVal now; g_get_current_time(&now); for (guint i=0; i<_ais_list->len; ++i) { gchar str[128] = {'\0'}; _ais_t *ais = &g_array_index(_ais_list, _ais_t, i); if (-1.0 != ais->course) { #ifdef S52_USE_SOCK g_snprintf(str, 128, "%s %lis%s%03.f deg / %3.1f kt", ais->name, (now.tv_sec - ais->lastUpdate.tv_sec), NL, ais->course, ais->speed); #else g_snprintf(str, 128, "%s %lis%c%03.f deg / %3.1f kt", ais->name, (now.tv_sec - ais->lastUpdate.tv_sec), (int)NL, ais->course, ais->speed); #endif } else { g_snprintf(str, 128, "%s %lis", ais->name, now.tv_sec - ais->lastUpdate.tv_sec); } #ifdef S52_USE_SOCK _encodeNsend("S52_setVESSELlabel", "%lu,\"%s\"", ais->vesselH, str); #else //Note: can't use _setAISLab() as it update timetag - long str if (FALSE == S52_setVESSELlabel(ais->vesselH, str)) { ais->lost = TRUE; } #endif } return TRUE; }