Пример #1
0
int recmonitor_start()
{
    mon = mapper_monitor_new(0, 0);
    if (mon) {
        db = mapper_monitor_get_db(mon);
        mapper_db_add_device_callback(db, device_callback, 0);
        mapper_db_add_signal_callback(db, signal_callback, 0);
        return 0;
    }
    return 1;
}
Пример #2
0
/*! Creation of a local dummy device. */
int setup_monitor()
{
    mon = mapper_monitor_new(0, SUB_DEVICE_ALL);
    if (!mon)
        goto error;
    printf("Monitor created.\n");

    db = mapper_monitor_get_db(mon);

    return 0;

  error:
    return 1;
}
Пример #3
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;
}