static int _s52_setupOWNSHP(s52droid_state_t *state) { _ownshp = S52_newOWNSHP(OWNSHPLABEL); //_ownshp = S52_setDimension(_ownshp, 150.0, 50.0, 0.0, 30.0); //_ownshp = S52_setDimension(_ownshp, 150.0, 50.0, 15.0, 15.0); //_ownshp = S52_setDimension(_ownshp, 100.0, 100.0, 0.0, 15.0); //_ownshp = S52_setDimension(_ownshp, 100.0, 0.0, 15.0, 0.0); _ownshp = S52_setDimension(_ownshp, 0.0, 100.0, 15.0, 0.0); //_ownshp = S52_setDimension(_ownshp, 1000.0, 50.0, 15.0, 15.0); S52_pushPosition(_ownshp, state->cLat - 0.02, state->cLon - 0.01, 180.0 + 045.0); S52_setVector(_ownshp, 0, 220.0, 6.0); // ownship use S52_MAR_VECSTB return TRUE; }
static _ais_t *_getAIS (unsigned int mmsi) { // return this _ais_t *ais = NULL; // check that gps_done() haven't flush this if (NULL == _ais_list) { g_print("s52ais:_getAIS() no AIS list\n"); return NULL; } unsigned int i = 0; for (i=0; i<_ais_list->len; ++i) { ais = &g_array_index(_ais_list, _ais_t, i); if (mmsi == ais->mmsi) { return ais; } } { // NEW AIS (not found hence new) _ais_t newais; __builtin_bzero(&newais, sizeof(_ais_t)); newais.mmsi = mmsi; newais.status = -1; // 0 indicate that status form report is needed //newais.name[AIS_SHIPNAME_MAXLEN + 1] = '\0'; newais.name[0] = '\0'; g_get_current_time(&newais.lastUpdate); newais.course = -1.0; newais.speed = 0.0; // create an active symbol, put mmsi since status is not known yet g_sprintf(newais.name, "%i", mmsi); #ifdef S52_USE_SOCK // debug: make ferry acte as ownshp if (OWNSHIP == mmsi) { gchar *resp = _encodeNsend("S52_newOWNSHP", "\"%s\"", newais.name); if (NULL != resp) { sscanf(resp, "[ %lu", (long unsigned int *) &newais.vesselH); } g_print("s52ais:_getAIS(): new ownshpH:%lu\n", (long unsigned int) newais.vesselH); } else { gchar *resp = _encodeNsend("S52_newVESSEL", "%i,\"%s\"", 2, newais.name); if (NULL != resp) { sscanf(resp, "[ %lu", (long unsigned int *) &newais.vesselH); } g_print("s52ais:_getAIS(): new vesselH:%lu\n", (long unsigned int) newais.vesselH); } #else // S52_USE_SOCK // debug: make ferry acte as ownshp if (OWNSHIP == mmsi) { newais.vesselH = S52_newOWNSHP(newais.name); } else { //int vesrce = 1; // ARPA int vesrce = 2; // AIS //int vesrce = 3; // VTS newais.vesselH = S52_newVESSEL(vesrce, newais.name); } #endif // S52_USE_SOCK // new AIS failed if (NULL == newais.vesselH) { g_print("s52ais:_getAIS(): new vesselH fail\n"); return NULL; } #ifdef S52_USE_AFGLOW #ifdef S52_USE_SOCK // debug: make ferry acte as ownshp if (OWNSHIP == mmsi) { gchar *resp = _encodeNsend("S52_newMarObj", "\"%s\",%i,%i", "afgshp", S52_LINES, MAX_AFGLOW_PT); if (NULL != resp) { sscanf(resp, "[ %lu", (long unsigned int *) &newais.afglowH); } g_print("s52ais:_getAIS(): new afglowH:%lu\n", (long unsigned int) newais.afglowH); } else { gchar *resp = _encodeNsend("S52_newMarObj", "\"%s\",%i,%i", "afgves", S52_LINES, MAX_AFGLOW_PT); if (NULL != resp) { sscanf(resp, "[ %lu", (long unsigned int *) &newais.afglowH); } g_print("s52ais:_getAIS(): new afglowH:%lu\n", (long unsigned int) newais.afglowH); } #else // S52_USE_SOCK // debug: make ferry acte as ownshp if (OWNSHIP == mmsi) newais.afglowH = S52_newMarObj("afgshp", S52_LINES, MAX_AFGLOW_PT, NULL, NULL); else newais.afglowH = S52_newMarObj("afgves", S52_LINES, MAX_AFGLOW_PT, NULL, NULL); #endif // S52_USE_SOCK if (NULL == newais.afglowH) { g_print("s52ais:_getAIS(): new afglowH fail\n"); return NULL; } #endif // save S52obj handle after registered in libS52 g_array_append_val(_ais_list, newais); ais = &g_array_index(_ais_list, _ais_t, _ais_list->len - 1); #ifdef S52_USE_DBUS _signal_newVESSEL(_dbus, newais.vesselH, newais.name); #endif } return ais; }