Ejemplo n.º 1
0
int setup_router()
{
    const char *host = "localhost";
    router = mapper_router_new(source, host, destination->admin->port.value, 
                               mdev_name(destination));
    mdev_add_router(source, router);
    printf("Router to %s:%d added.\n", host, port);

    char signame_in[1024];
    if (!msig_full_name(recvsig, signame_in, 1024)) {
        printf("Could not get destination signal name.\n");
        return 1;
    }

    char signame_out[1024];
    if (!msig_full_name(sendsig, signame_out, 1024)) {
        printf("Could not get source signal name.\n");
        return 1;
    }

    printf("Mapping signal %s -> %s\n", signame_out, signame_in);
    mapper_connection c = mapper_router_add_connection(router, sendsig,
                                                       recvsig->props.name,
                                                       'f', 3);
    const char *expr = "y=x*10";
    mapper_connection_set_expression(c, sendsig, expr);

    return 0;
}
Ejemplo n.º 2
0
int setup_router()
{
    const char *host = "localhost";
    router = mapper_router_new(source, host, destination->props.port,
                               mdev_name(destination), 0);
    mdev_add_router(source, router);
    printf("Router to %s:%d added.\n", host, destination->props.port);

    char signame_in[1024];
    if (!msig_full_name(recvsig, signame_in, 1024)) {
        printf("Could not get destination signal name.\n");
        return 1;
    }

    char signame_out[1024];
    if (!msig_full_name(sendsig, signame_out, 1024)) {
        printf("Could not get source signal name.\n");
        return 1;
    }

    printf("Connecting signal %s -> %s\n", signame_out, signame_in);
    mapper_connection c = mapper_router_add_connection(router, sendsig,
                                                       recvsig->props.name,
                                                       'f', 1);
    mapper_connection_range_t range;
    range.src_min = 0;
    range.src_max = 1;
    range.dest_min = -10;
    range.dest_max = 10;
    range.known = CONNECTION_RANGE_KNOWN;
    
    mapper_connection_set_linear_range(c, &range);

    return 0;
}