static int _setAISVec (unsigned int mmsi, double course, double speed) { _ais_t *ais = _getAIS(mmsi); if (NULL == ais) return FALSE; int vecstb = 1; // overground // ground vector (since AIS transmit the GPS) ais->course = course; ais->speed = speed; #ifdef S52_USE_SOCK _encodeNsend("S52_setVector", "%lu,%i,%lf,%lf", ais->vesselH, vecstb, course, speed); #else // FIXME: test ship's head up setView() S52_setVector(ais->vesselH, vecstb, course, speed); #endif #ifdef S52_USE_DBUS _signal_setVector(_dbus, ais->vesselH, 1, course, speed); #endif g_get_current_time(&ais->lastUpdate); return TRUE; }
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; }
static int _setAISPos (unsigned int mmsi, double lat, double lon, double heading) { _ais_t *ais = _getAIS(mmsi); if (NULL == ais) return FALSE; #ifdef S52_USE_SOCK _encodeNsend("S52_pushPosition", "%lu,%lf,%lf,%lf", (long unsigned int *)ais->vesselH, lat, lon, heading); #else S52_pushPosition(ais->vesselH, lat, lon, heading); #endif #ifdef S52_USE_AFGLOW #ifdef S52_USE_SOCK _encodeNsend("S52_pushPosition", "%lu,%lf,%lf,%lf", (long unsigned int *)ais->afglowH, lat, lon, heading); #else S52_pushPosition(ais->afglowH, lat, lon, 0.0); #endif #endif #ifdef S52_USE_DBUS _signal_setPosition (_dbus, ais->vesselH, lat, lon, heading); _signal_setVESSELlabel(_dbus, ais->vesselH, ais->name); #endif g_get_current_time(&ais->lastUpdate); return TRUE; }
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 _setAISDim (unsigned int mmsi, double a, double b, double c, double d) { _ais_t *ais = _getAIS(mmsi); if (NULL == ais) return FALSE; #ifdef S52_USE_SOCK _encodeNsend("S52_setDimension", "%lu,%lf,%lf,%lf,%lf", ais->vesselH, a, b, c, d); #else S52_setDimension(ais->vesselH, a, b, c, d); #endif g_get_current_time(&ais->lastUpdate); return TRUE; }
static int _setAISInfo(unsigned int mmsi, unsigned int imo, char *callsign, unsigned int shiptype, unsigned int month, unsigned int day, unsigned int hour, unsigned int minute, unsigned int draught, char *destination) { _ais_t *ais = _getAIS(mmsi); if (NULL == ais) return FALSE; #ifdef S52_USE_DBUS _signal_setAISInfo(_dbus, ais->vesselH, mmsi, imo, callsign, shiptype, month, day, hour, minute, draught, destination); #endif return TRUE; }
static int _setAISLab (unsigned int mmsi, const char *name) // update AIS label { _ais_t *ais = _getAIS(mmsi); if (NULL == ais) return FALSE; if (NULL != name) { g_snprintf(ais->name, AIS_SHIPNAME_MAXLEN, "%s", name); #ifdef S52_USE_DBUS _signal_setVESSELlabel(_dbus, ais->vesselH, ais->name); #endif } g_get_current_time(&ais->lastUpdate); return TRUE; }