Exemple #1
0
/* ----------------------------------------------------------------------- */
int __stdcall parse_seaway1_1( sixbit *state, seaway1_1 *result )
{
    int length;
    int i;
    int j;
    
    if( !state )
        return 1;
    if( !result )
        return 1;

	length = sixbit_length(state);
    if( (length < 0) || (length > 1008) )
        return 2;

    /* Clear out the structure first */
    memset( result, 0, sizeof( seaway1_1 ) );

    for( i=0; i<4; i++ )
    {
        if( get_timetag( state, &result->report[i].utc_time ) )
			return 3;

        /* Get the Callsign, convert to ASCII */
        j = 0;
        while( j != 7 )
        {
            result->report[i].station_id[j] = ais2ascii( (char) get_6bit( state, 6 ));
            j++;
        }
        result->report[i].station_id[j] = 0;

        result->report[i].longitude = (long) get_6bit( state, 25 );
        result->report[i].latitude  = (long) get_6bit( state, 24 );
        result->report[i].speed     = (int) get_6bit( state, 10 );
        result->report[i].gust      = (int) get_6bit( state, 10 );
        result->report[i].direction = (int) get_6bit( state, 9 );
        result->report[i].pressure  = (int) get_6bit( state, 14 );
        result->report[i].air_temp  = (int) get_6bit( state, 10 );
        result->report[i].dew_point = (int) get_6bit( state, 10 );
        result->report[i].visibility= (unsigned char) get_6bit( state, 8 );
        result->report[i].water_temp= (int) get_6bit( state, 10 );
        
    	/* Convert the position to signed value */
		result->report[i].longitude *= 10;
		result->report[i].latitude *= 10;
    	conv_pos( &result->report[i].latitude, &result->report[i].longitude);

		/* Convert the air_temp, dew_point and water_temp to a signed value */
		conv_sign( 0x0200, &result->report[i].air_temp);
		conv_sign( 0x0200, &result->report[i].dew_point);
		conv_sign( 0x0200, &result->report[i].water_temp);

        /* Is there enough data for another? */
        if( sixbit_length(state) < 192)
            break;
    }
    return 0;
}
Exemple #2
0
foreign_t send_timestamped(term_t addr, term_t msg, term_t args, term_t secs, term_t frac) {
	lo_address 	a;
	lo_timetag  ts;
	char			*m;

	return get_addr(addr,&a) &&
			get_timetag(secs,frac,&ts) &&
			get_msg(msg, &m) &&
			send_msg_timestamped(a,&ts,m,args);
}
Exemple #3
0
/* ----------------------------------------------------------------------- */
int __stdcall parse_seaway1_3( sixbit *state, seaway1_3 *result )
{
    int length;
    int i;
    int j;
    
    if( !state )
        return 1;
    if( !result )
        return 1;

	length = sixbit_length(state);
    if( (length < 0) || (length > 1008) )
        return 2;

    /* Clear out the structure first */
    memset( result, 0, sizeof( seaway1_3 ) );

    for( i=0; i<6; i++ )
    {
        if( get_timetag( state, &result->report[i].utc_time ) )
			return 3;

        /* Get the Callsign, convert to ASCII */
        j = 0;
        while( j != 7 )
        {
            result->report[i].station_id[j] = ais2ascii( (char) get_6bit( state, 6 ));
            j++;
        }
        result->report[i].station_id[j] = 0;

        result->report[i].longitude = (long) get_6bit( state, 25 );
        result->report[i].latitude  = (long) get_6bit( state, 24 );
        result->report[i].type      = (char) get_6bit( state, 1 );
        result->report[i].level     = (unsigned int) get_6bit( state, 16 );
        result->report[i].datum     = (char) get_6bit( state, 2 );
        result->report[i].spare     = (int)  get_6bit( state, 14 );

    	/* Convert the position to signed value */
		result->report[i].longitude *= 10;
		result->report[i].latitude *= 10;
    	conv_pos( &result->report[i].latitude, &result->report[i].longitude);

		/* Convert level to a signed integer */
		conv_sign( 0x8000, &result->report[i].level );

        /* Is there enough data for another? */
        if( sixbit_length(state) < 144)
            break;
    }
    return 0;
}
Exemple #4
0
/* ----------------------------------------------------------------------- */
int __stdcall parse_pawss1_5( sixbit *state, pawss1_5 *result )
{
    int length;
    int i;
    int j;
    
    if( !state )
        return 1;
    if( !result )
        return 1;

	length = sixbit_length(state);
    if( (length < 0) || (length > 1008) )
        return 2;

    /* Clear out the structure first */
    memset( result, 0, sizeof( pawss1_5 ) );

    for( i=0; i<6; i++ )
    {
        if( get_timetag( state, &result->report[i].utc_time ) )
			return 3;

        /* Get the Callsign, convert to ASCII */
        j = 0;
        while( j != 7 )
        {
            result->report[i].station_id[j] = ais2ascii( (char) get_6bit( state, 6 ));
            j++;
        }
        result->report[i].station_id[j] = 0;

        result->report[i].longitude = (long) get_6bit( state, 25 );
        result->report[i].latitude  = (long) get_6bit( state, 24 );
        result->report[i].salinity  = (int) get_6bit( state, 10 );
        result->report[i].water_temp= (int) get_6bit( state, 10 );
        result->report[i].spare     = (unsigned int) get_6bit( state, 13 );

    	/* Convert the position to signed value */
		result->report[i].longitude *= 10;
		result->report[i].latitude *= 10;
    	conv_pos( &result->report[i].latitude, &result->report[i].longitude);

		/* Convert water temp to signed value */
		conv_sign( 0x0200, &result->report[i].water_temp);

        /* Is there enough data for another? */
        if( sixbit_length(state) < 144)
            break;
    }
    return 0;
}
Exemple #5
0
/* ----------------------------------------------------------------------- */
int __stdcall parse_pawss2_3( sixbit *state, pawss2_3 *result )
{
    int length;
    int i;
    int j;
    
    if( !state )
        return 1;
    if( !result )
        return 1;

	length = sixbit_length(state);
    if( (length < 0) || (length > 1008) )
        return 2;

    /* Clear out the structure first */
    memset( result, 0, sizeof( pawss2_3 ) );

    if( get_timetag( state, &result->utc_time ) )
		return 3;

    /* Get the Direction, convert to ASCII */
    j = 0;
    while( j != 16 )
    {
        result->direction[j] = ais2ascii( (char) get_6bit( state, 6 ));
        j++;
    }
    result->direction[j] = 0;

    result->longitude = (long) get_6bit( state, 25 );
    result->latitude  = (long) get_6bit( state, 24 );
    result->spare2 = (char)  get_6bit( state, 3 );

   	/* Convert the position to signed value */
	result->longitude *= 10;
	result->latitude *= 10;
   	conv_pos( &result->latitude, &result->longitude);

    for( i=0; i<4; i++ )
    {
        result->report[i].order  = (char) get_6bit( state, 5 );
        
        /* Get the Vessel Name, convert to ASCII */
        j = 0;
        while( j != 15 )
        {
            result->report[i].vessel_name[j] = ais2ascii( (char) get_6bit( state, 6 ));
            j++;
        }
        result->report[i].vessel_name[j] = 0;

        /* Get the Vessel Name, convert to ASCII */
        j = 0;
        while( j != 13 )
        {
            result->report[i].position_name[j] = ais2ascii( (char) get_6bit( state, 6 ));
            j++;
        }
        result->report[i].position_name[j] = 0;
        
        result->report[i].time_hh = (char) get_6bit( state, 5 );
        result->report[i].time_mm = (char) get_6bit( state, 6 );
        result->report[i].spare   = (char) get_6bit( state, 6 );

        /* Is there enough data for another? */
        if( sixbit_length(state) < 184)
            break;
    }
    return 0;
}
Exemple #6
0
/* ----------------------------------------------------------------------- */
int __stdcall parse_seaway2_2( sixbit *state, seaway2_2 *result )
{
    int length;
    int j;
    
    if( !state )
        return 1;
    if( !result )
        return 1;

	length = sixbit_length(state);
    if( (length < 0) || (length > 1008) )
        return 2;

    /* Clear out the structure first */
    memset( result, 0, sizeof( seaway2_2 ) );

    if( get_timetag( state, &result->utc_time ) )
		return 3;

    /* Get the vessel name, convert to ASCII */
    j = 0;
    while( j != 15 )
    {
        result->name[j] = ais2ascii( (char) get_6bit( state, 6 ));
        j++;
    }
    result->name[j] = 0;

    /* Get the Last Location, convert to ASCII */
    j = 0;
    while( j != 7 )
    {
        result->last_location[j] = ais2ascii( (char) get_6bit( state, 6 ));
        j++;
    }
    result->last_location[j] = 0;

    if( get_timetag( state, &result->last_ata ) )
		return 3;

    /* Get the First Lock, convert to ASCII */
    j = 0;
    while( j != 7 )
    {
        result->first_lock[j] = ais2ascii( (char) get_6bit( state, 6 ));
        j++;
    }
    result->first_lock[j] = 0;

    if( get_timetag( state, &result->first_eta ) )
		return 3;

    /* Get the Second Lock, convert to ASCII */
    j = 0;
    while( j != 7 )
    {
        result->second_lock[j] = ais2ascii( (char) get_6bit( state, 6 ));
        j++;
    }
    result->second_lock[j] = 0;

    if( get_timetag( state, &result->second_eta ) )
		return 3;

    /* Get the Delay, convert to ASCII */
    j = 0;
    while( j != 7 )
    {
        result->delay[j] = ais2ascii( (char) get_6bit( state, 6 ));
        j++;
    }
    result->delay[j] = 0;

    result->spare2 = (int) get_6bit( state, 4 );

    return 0;
}
Exemple #7
0
/* ----------------------------------------------------------------------- */
int __stdcall parse_seaway2_1( sixbit *state, seaway2_1 *result )
{
    int length;
    int i;
    int j;
    
    if( !state )
        return 1;
    if( !result )
        return 1;

	length = sixbit_length(state);
    if( (length < 0) || (length > 1008) )
        return 2;

    /* Clear out the structure first */
    memset( result, 0, sizeof( seaway2_1 ) );

    if( get_timetag( state, &result->utc_time ) )
		return 3;

    /* Get the Callsign, convert to ASCII */
    j = 0;
    while( j != 7 )
    {
        result->lock_id[j] = ais2ascii( (char) get_6bit( state, 6 ));
        j++;
    }
    result->lock_id[j] = 0;

    result->longitude = (long) get_6bit( state, 25 );
    result->latitude  = (long) get_6bit( state, 24 );
    result->spare2    = (int) get_6bit( state, 9 );

   	/* Convert the position to signed value */
	result->longitude *= 10;
	result->latitude *= 10;
   	conv_pos( &result->latitude, &result->longitude);

    for( i=0; i<6; i++ )
    {
        /* Get the Callsign, convert to ASCII */
        j = 0;
        while( j != 15 )
        {
            result->schedule[i].name[j] = ais2ascii( (char) get_6bit( state, 6 ));
            j++;
        }
        result->schedule[i].name[j] = 0;

        result->schedule[i].direction = (char) get_6bit( state, 1 );
		if ( get_timetag( state, &result->schedule[i].eta ) )
			return 4;
        result->schedule[i].spare     = (int)  get_6bit( state, 9 );

        /* Is there enough data for another? */
        if( sixbit_length(state) < 120)
            break;
    }
    return 0;
}