Ejemplo n.º 1
0
static int      _s52_updTimeTag (s52engine *engine)
{
    (void)engine;


    // fake one AIS
    if (NULL != _vessel_ais) {
        gchar         str[80];
        GTimeVal      now;
        static double hdg = 0.0;

        hdg = (hdg >= 359.0) ? 0.0 : hdg+1;  // fake rotating hdg

        g_get_current_time(&now);
        g_sprintf(str, "%s %lis", VESSELLABEL, now.tv_sec);
        S52_setVESSELlabel(_vessel_ais, str);
        S52_pushPosition(_vessel_ais, engine->state.cLat - 0.01, engine->state.cLon + 0.01, hdg);
        S52_setVector(_vessel_ais, 1, hdg, 16.0);   // ground

#ifdef S52_USE_AFGLOW
        // stay at the same place but fill internal S52 buffer - in the search for possible leak
        S52_pushPosition(_vessel_ais_afglow, engine->state.cLat, engine->state.cLon, 0.0);
#endif
    }


    return TRUE;
}
Ejemplo n.º 2
0
static int           _setAISLab (unsigned int mmsi, const char *name)
// update AIS label
{
    // debug
    //if (316006302 == mmsi)
    //    g_print("s52ais:_setAISLab(): mmsi:%i name:[%s]\n", mmsi, name);

    _ais_t *ais = _getAIS(mmsi);
    if (NULL == ais)
        return FALSE;

    if (NULL != name) {
        g_snprintf(ais->name, AIS_SHIPNAME_MAXLEN+1, "%s", name);

#ifdef S52_USE_SOCK
        _encodeNsend("S52_setVESSELlabel", "%lu,\"%s\"", ais->vesselH, name);
#else
        S52_setVESSELlabel(ais->vesselH, name);
#endif

#ifdef S52_USE_DBUS
        _signal_setVESSELlabel(_dbus, ais->vesselH, ais->name);
#endif
    }

    g_get_current_time(&ais->lastUpdate);

    return TRUE;
}
Ejemplo n.º 3
0
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;
}
Ejemplo n.º 4
0
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;
}
Ejemplo n.º 5
0
static int      _s52_setupVESSEL(s52droid_state_t *state)
{
    // ARPA
    //_vessel_arpa = S52_newVESSEL(1, dummy, "ARPA label");
    //_vessel_arpa = S52_newVESSEL(1, "ARPA label");
    //S52_pushPosition(_vessel_arpa, _engine.state.cLat + 0.01, _engine.state.cLon - 0.02, 045.0);
    //S52_setVector(_vessel_arpa, 2, 060.0, 3.0);   // water

    // AIS active
    _vessel_ais = S52_newVESSEL(2, NULL);
    S52_setDimension(_vessel_ais, 100.0, 100.0, 15.0, 15.0);
    //S52_pushPosition(_vessel_ais, _engine.state.cLat - 0.02, _engine.state.cLon + 0.02, 045.0);
    //S52_pushPosition(_vessel_ais, state->cLat - 0.04, state->cLon + 0.04, 045.0);
    S52_pushPosition(_vessel_ais, state->cLat - 0.01, state->cLon + 0.01, 045.0);
    S52_setVector(_vessel_ais, 1, 060.0, 16.0);   // ground

    // (re) set label
    S52_setVESSELlabel(_vessel_ais, VESSELLABEL);
    int vesselSelect = 0;  // OFF
    int vestat       = 1;
    int vesselTurn   = VESSELTURN_UNDEFINED;
    S52_setVESSELstate(_vessel_ais, vesselSelect, vestat, vesselTurn);

    // AIS sleeping
    //_vessel_ais = S52_newVESSEL(2, 2, "MV Non Such - sleeping"););
    //S52_pushPosition(_vessel_ais, _engine.state.cLat - 0.02, _engine.state.cLon + 0.02, 045.0);

    // VTS (this will not draw anything!)
    //_vessel_vts = S52_newVESSEL(3, dummy);

#ifdef S52_USE_AFGLOW
    // afterglow
    _vessel_ais_afglow = S52_newMarObj("afgves", S52_LINES, MAX_AFGLOW_PT, NULL, NULL);
#endif

    return TRUE;
}