static int _setAISSta (unsigned int mmsi, int status, int turn) { /* from doc in 'gpsd' "0 - Under way using engine", "1 - At anchor", "2 - Not under command", "3 - Restricted manoeuverability", "4 - Constrained by her draught", "5 - Moored", "6 - Aground", "7 - Engaged in Fishing", "8 - Under way sailing", "9 - Reserved for future amendment of Navigational Status for HSC", "10 - Reserved for future amendment of Navigational Status for WIG", "11 - Reserved for future use", "12 - Reserved for future use", "13 - Reserved for future use", "14 - Reserved for future use", "15 - Not defined (default)" */ _ais_t *ais = _getAIS(mmsi); if (NULL == ais) return FALSE; if ((status!=ais->status) || (turn!=ais->turn)) { if (1==status || 5==status || 6==status) { int vestat = 2; // AIS sleeping #ifdef S52_USE_SOCK _encodeNsend("S52_setVESSELstate", "%lu,%i,%i,%i", ais->vesselH, 0, vestat, turn); #else S52_setVESSELstate(ais->vesselH, 0, vestat, turn); // AIS sleeping #endif } else { // AIS active int vestat = 1; // normal //int vestat = 3; // red, close quarters #ifdef S52_USE_SOCK _encodeNsend("S52_setVESSELstate", "%lu,%i,%i,%i", ais->vesselH, 0, vestat, turn); #else S52_setVESSELstate(ais->vesselH, 0, vestat, turn); // AIS active #endif } ais->status = status; ais->turn = turn; } #ifdef S52_USE_DBUS // need to send the status every time because AIS-monitor.js // can be restarted wild libS52 is running hence status is not updated (ie no change) _signal_setVESSELstate(_dbus, ais->vesselH, 0, status, turn); #endif return TRUE; }
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; }