Ejemplo n.º 1
0
void Node::close()
{
    // deallocate memory
    artnet_stop(artnetNode);
    artnet_destroy(artnetNode);
    didSetup = false;
    unis.clear();
};
Ejemplo n.º 2
0
void ofxArtnet::setup(const char* interfaceIP, int port_addr, int verbose)
{
    printf("ofxArtnet::setup\n");
    verbose = 1;
    nodes_found = 0;
    
    // create new artnet node, and set config values
    
    if ( (node = artnet_new(interfaceIP, verbose)) == NULL)
    {
        if ( verbose ) printf("cannot create node: %s\n", artnet_strerror() );
        goto error_destroy;
    }
    artnet_set_short_name(node, SHORT_NAME.c_str());
    artnet_set_long_name(node, LONG_NAME.c_str());
    artnet_set_node_type(node, ARTNET_RAW);
    
    artnet_set_port_type(node, 0, ARTNET_ENABLE_INPUT, ARTNET_PORT_DMX);
    artnet_set_port_addr(node, 0, ARTNET_INPUT_PORT, port_addr);
    artnet_set_handler(node, ARTNET_REPLY_HANDLER, ofxArtnet::reply_handler, NULL);
    
    if (artnet_start(node) != ARTNET_EOK) {
        if ( verbose ) printf("Failed to start: %s\n", artnet_strerror() );
        goto error_destroy;
    }
    
    sd = artnet_get_sd(node);
    
    find_timeout = ofGetElapsedTimeMillis();
    status = NODES_FINDING;
    if (artnet_send_poll(node, NULL, ARTNET_TTM_DEFAULT) != ARTNET_EOK) {
        printf("send poll failed: %s\n", artnet_strerror() );
        goto error_destroy;
    }
    printf("starting thread\n");
    startThread(true);
    return;
    
    error_destroy :
    artnet_destroy(node);
    
    //    free(ops.ip_addr);
    //    exit(1);
}