Beispiel #1
0
int main( int argc, const char* argv[] )
{
#ifdef XI_NOB_ENABLED
    XI_UNUSED( argc );
    XI_UNUSED( argv );
#else
    if( argc < REQUIRED_ARGS )
    {
        print_usage();
        exit( 0 );
    }

    // create the xi library context
    xi_context_t* xi_context
        = xi_create_context(
                  XI_HTTP, argv[ 1 ]
                , atoi( argv[ 2 ] ) );

    // check if everything works
    if( xi_context == 0 )
    {
        return -1;
    }

    // create feed
    xi_feed_t f;
    memset( &f, 0, sizeof( xi_feed_t ) );

    xi_feed_get_all( xi_context, &f );

    printf( "\n" );

    for( size_t i = 0; i < f.datastream_count; ++i )
    {
        xi_datastream_t* d = &f.datastreams[ i ];
        printf( "datasream_id: %s ", d->datastream_id );

        for( size_t j = 0; j < d->datapoint_count; ++j )
        {
            xi_datapoint_t* p = &d->datapoints[ j ];
            print_datapoint( p );
        }
    }

    // destroy the context cause we don't need it anymore
    xi_delete_context( xi_context );
#endif
    return 0;
}
Beispiel #2
0
void print_dataset(Dataset* dataset){
    printf("Dimensionality of data: %ld\nDataset size: %ld\n", dataset->dimensionality, dataset->size);
    for (size_t i = 0; i < dataset->size; i++) {
        print_datapoint(dataset->points[i]);
    }
}
Beispiel #3
0
int main( int argc, const char* argv[] )
{

    if( argc < REQUIRED_ARGS )
    {
        print_usage();
        exit( 0 );
    }

    // create the xi library context
    xi_context_t* xi_context
        = xi_create_context(
                  XI_HTTP, argv[ 1 ]
                , atoi( argv[ 2 ] ) );

    // check if everything works
    if( xi_context == 0 )
    {
        return -1;
    }

    // remember the count for pairs
    size_t datapoints_count = argc - REQUIRED_ARGS;

    // create feed
    xi_feed_t f;
    memset( &f, 0, sizeof( xi_feed_t ) );

    // set datastream count
    f.feed_id           = atoi( argv[ 2 ] );
    f.datastream_count  = datapoints_count;

    // for each
    for( size_t i = 0; i < datapoints_count; i++ )
    {
        // get the datastream pointer
        xi_datastream_t* d = &f.datastreams[ i ];

        // set the datastream id
        int size = sizeof( d->datastream_id );
        int s = xi_str_copy_untiln( d->datastream_id, size
            , argv[ REQUIRED_ARGS + i ], '\0' );

        if( s >= size )
        {
            perror( "datastream name too long " );
        }
    }

    xi_feed_get( xi_context, &f );

    for( size_t i = 0; i < f.datastream_count; ++i )
    {
        xi_datastream_t* d = &f.datastreams[ i ];
        printf( "datasream_id: %s ", d->datastream_id );

        for( size_t j = 0; j < d->datapoint_count; ++j )
        {
            xi_datapoint_t* p = &d->datapoints[ j ];
            print_datapoint( p );
        }
    }

    // destroy the context cause we don't need it anymore
    xi_delete_context( xi_context );

    return 0;
}