Exemple #1
0
/*! Creation of a local source. */
int setup_source()
{
    source = mdev_new("testsend", port, 0);
    if (!source)
        goto error;
    printf("source created.\n");

    float mn=0, mx=10;

    sendsig_1 = mdev_add_output(source, "/outsig_1", 1, 'f', "Hz", &mn, &mx);
    sendsig_2 = mdev_add_output(source, "/outsig_2", 1, 'f', "mm", &mn, &mx);
    sendsig_3 = mdev_add_output(source, "/outsig_3", 3, 'f', 0, &mn, &mx);
    sendsig_4 = mdev_add_output(source, "/outsig_4", 1, 'f', 0, &mn, &mx);

    printf("Output signal /outsig registered.\n");

    // Make sure we can add and remove outputs without crashing.
    mdev_remove_output(source, mdev_add_output(source, "/outsig_5", 1,
                                               'f', 0, &mn, &mx));

    printf("Number of outputs: %d\n", mdev_num_outputs(source));

    return 0;

  error:
    return 1;
}
Exemple #2
0
int setup_sources() {

	char str[20];
	int number;

	for ( int i=0; i<num_sources; i++ ) {
		
		source_device_list[i] = mdev_new("source", port, 0);
		number = num_signals[i+num_dests];

		for ( int j=0; j<number; j++ ) {

			sprintf( str, "/outsig%d", j );
            float mn=0, mx=1;
			mdev_add_output(source_device_list[i], str, 1, 'f',
                            0, &mn, &mx);

		}

		if ( !source_device_list[i] ) {

			goto error;

		}

	}

    return 0;

  error:
    return 1;

}
Exemple #3
0
/*! Creation of a local source. */
int setup_source()
{
    char sig_name[20];
    source = mdev_new("testsend", port, 0);
    if (!source)
        goto error;
    printf("source created.\n");

    float mn=0, mx=10;

    for (int i = 0; i < 4; i++) {
        snprintf(sig_name, 20, "%s%i", "/outsig_", i);
        sendsig[i] = mdev_add_output(source, sig_name, 1, 'f', 0, &mn, &mx);
    }
    
    for (int i = 0; i < 4; i++) {
        snprintf(sig_name, 20, "%s%i", "/dummysig_", i);
        dummysig[i] = mdev_add_hidden_input(source, sig_name, 1,
                                            'f', 0, 0, 0, query_response_handler,
                                            sendsig[i]);
    }

    printf("Output signals registered.\n");
    printf("Number of outputs: %d\n", mdev_num_outputs(source));

    return 0;

  error:
    return 1;
}
Exemple #4
0
int setup_source()
{
    source = mdev_new("testsend", port, 0);
    if (!source)
        goto error;
    printf("source created.\n");

    float mn=0, mx=1;
    sendsig = mdev_add_output(source, "/outsig", 3, 'f', 0, &mn, &mx);

    printf("Output signal /outsig registered.\n");
    printf("Number of outputs: %d\n", mdev_num_outputs(source));
    return 0;

  error:
    return 1;
}
Exemple #5
0
/*! Creation of a local source. */
int setup_source()
{
    source = mdev_new("testselect-send", 0, 0);
    if (!source)
        goto error;
    eprintf("source created.\n");

    float mn=0, mx=10;

    sendsig = mdev_add_output(source, "/outsig", 1, 'f', "Hz", &mn, &mx);

    eprintf("Output signal /outsig registered.\n");

    return 0;

  error:
    return 1;
}
Exemple #6
0
/*! Creation of a local source. */
int setup_source()
{
    source = mdev_new("testquery-send", 0, 0);
    if (!source)
        goto error;
    printf("source created.\n");

    float mn=0, mx=10;

    sendsig = mdev_add_output(source, "/outsig", 1, 'i', 0, &mn, &mx);
    msig_set_callback(sendsig, insig_handler, 0);

    printf("Output signals registered.\n");
    printf("Number of outputs: %d\n", mdev_num_outputs(source));

    return 0;

  error:
    return 1;
}
Exemple #7
0
/*! Creation of a local source. */
int setup_source()
{
    source = mdev_new("testSpeedSend", 0, 0);
    if (!source)
        goto error;
    printf("source created.\n");

    sendsig = mdev_add_output(source, "/outsig", 1, 'f', 0, 0, 0);
    if (!sendsig)
        goto error;
    msig_reserve_instances(sendsig, 9);

    printf("Output signal registered.\n");
    printf("Number of outputs: %d\n", mdev_num_outputs(source));

    return 0;

  error:
    return 1;
}
Exemple #8
0
struct _agentInfo *agentInit()
{
    obs[0] = obs[1] = 0;
    id = 0;

    struct _agentInfo *info = &agentInfo;
    memset(info, 0, sizeof(struct _agentInfo));

    info->influence_device_name = strdup("/influence.1");
    info->xagora_device_name = strdup("/XAgora_receiver.1");

    info->admin = mapper_admin_new(0, 0, 0);

    // add device
    info->dev = mdev_new("agent", 9000 + id, info->admin);
    while (!mdev_ready(info->dev)) {
        mdev_poll(info->dev, 100);
    }
    printf("ordinal: %d\n", mdev_ordinal(info->dev));
    fflush(stdout);

    // add monitor and monitor callbacks
    info->mon = mapper_monitor_new(info->admin, 0);
    info->db  = mapper_monitor_get_db(info->mon);
    mapper_db_add_device_callback(info->db, dev_db_callback, info);
    mapper_db_add_link_callback(info->db, link_db_callback, info);

    // add signals
    float mn=-1, mx=1;
    mdev_add_input(info->dev, "observation", 2, 'f', "norm", &mn, &mx,
                   signal_handler, 0);
    int imn=0, imx=WIDTH;
    info->sig_pos = mdev_add_output(info->dev, "position", 2, 'i', 0, &imn, &imx);
    info->sig_gain = mdev_add_output(info->dev, "gain", 1, 'f',
                               "normalized", &mn, &mx);
    mx = 0.9;
    info->sig_fade = mdev_add_output(info->dev, "fade", 1, 'f', "normalized", &mn, &mx);
    mn = -1.5;
    mx = 1.5;
    info->sig_spin = mdev_add_output(info->dev, "spin", 1, 'f', "radians", &mn, &mx);
    mn = -3.1415926;
    mx = 3.1315926;
    info->sig_dir = mdev_add_output(info->dev, "direction", 1, 'f', "radians", &mn, &mx);
    mn = -1;
    info->sig_flow = mdev_add_output(info->dev, "flow", 1, 'f', "noramlized", &mn, &mx);

    return info;
}