Ejemplo n.º 1
0
// ----------------------------------------------------------------------------
//
FixtureDefinition* DefinitionReader::read( TiXmlElement* self, FixtureDefinition* fixture )
{
    fixture = new FixtureDefinition();

    try {
        fixture->m_fuid = (FUID)read_dword_attribute( self, "fuid" );
        fixture->m_type = fixture->convertTextToFixtureType( read_text_attribute( self, "type" ) );
        fixture->m_manufacturer = read_text_element( self, "manufacturer" );
        fixture->m_model = read_text_element( self, "model" );

        // Add channel list(s)
        std::vector<Channel *> channels = 
            read_xml_list<Channel>( self->FirstChildElement( "channels" ), "channel" );

        for ( std::vector<Channel *>::iterator it=channels.begin(); it != channels.end(); ++it ) {
            fixture->m_channels.push_back( *(*it) );
            delete (*it);
        }

        if ( fixture->m_fuid == 0 ) {                           // Generate FUID with a (hopefully) unique hash
            fixture->m_fuid = fixture->generateFUID( );
        }

        fixture->chooseCapabilities();
    }
    catch ( ... ) {
        delete fixture;
        throw;
    }

    return fixture;
}
Ejemplo n.º 2
0
// ----------------------------------------------------------------------------
//
Scene* VenueReader::read( TiXmlElement* self, Scene* scene )
{
    scene = new Scene();

    readDObject( self, scene, "scene_number" );

    scene->m_bpm_rating = (BPMRating)read_int_attribute( self, "bpm_rating", BPMRating::BPM_NO_RATING);

    std::vector<SceneActor *> actors = 
        read_xml_list<SceneActor>( self->FirstChildElement( "actors" ), "actor" );

    for ( std::vector<SceneActor *>::iterator it=actors.begin(); it != actors.end(); ++it ) {
        scene->addActor( *(*it) );
        delete (*it);
    }

    TiXmlElement* acts = self->FirstChildElement( "acts" );
    if ( acts ) {
        TiXmlElement* element = acts->FirstChildElement( "act" );
        while ( element ) {
            scene->m_acts.insert( read_unsigned_attribute( element, "number" ) ) ;
            element = element->NextSiblingElement();
        }
    }

    TiXmlElement* container = self->FirstChildElement( "animations" );
    if ( container ) {
        TiXmlElement* element = container->FirstChildElement( "animation" );
        while ( element ) {
            const char* class_name = read_text_attribute( element, "class" );
            AbstractAnimation* animation = NULL;

            if ( !strcmp( class_name, SceneSequence::className ) )
                animation = read( element, (SceneSequence*)NULL );
            else if ( !strcmp( class_name, SceneSoundLevel::className ) )
                animation = read( element, (SceneSoundLevel*)NULL );
            else if ( !strcmp( class_name, SceneChannelAnimator::className ) )
                animation = read( element, (SceneChannelAnimator*)NULL );
            else if ( !strcmp( class_name, ScenePatternDimmer::className ) )
                animation = read( element, (ScenePatternDimmer*)NULL );
            else if ( !strcmp( class_name, SceneColorFader::className ) )
                animation = read( element, (SceneColorFader*)NULL );
            else if ( !strcmp( class_name, SceneMovementAnimator::className ) )
                animation = read( element, (SceneMovementAnimator*)NULL );
            else if ( !strcmp( class_name, SceneStrobeAnimator::className ) )
                animation = read( element, (SceneStrobeAnimator*)NULL );
            else if ( !strcmp( class_name, ScenePixelAnimator::className ) )
                animation = read( element, (ScenePixelAnimator*)NULL );
            else if ( !strcmp( class_name, SceneChannelFilter::className ) )
                animation = read( element, (SceneChannelFilter*)NULL );
            else
                STUDIO_ASSERT( false, "Unknown animation class '%s'", class_name );

            scene->addAnimation( animation );

            element = element->NextSiblingElement();
        }
    }

    return scene;
}
Ejemplo n.º 3
0
// ----------------------------------------------------------------------------
//
Channel* DefinitionReader::read( TiXmlElement* self, Channel* channel )
{
    channel = new Channel();

    try {
        channel->m_channel_offset = (channel_t)read_dword_attribute( self, "index" );
        channel->m_type = Channel::convertTextToChannelType( read_text_attribute( self, "type" ) );
        channel->m_name = read_text_element( self, "name" );
        channel->m_is_color = read_bool_attribute( self, "color" );
        channel->m_can_blackout = read_bool_attribute( self, "blackout" );
        channel->m_can_whiteout = read_bool_attribute( self, "whiteout", true );
        channel->m_default_value = (BYTE)read_int_attribute( self, "value" );
        channel->m_home_value = (BYTE)read_int_attribute( self, "home_value" );
        channel->m_pixel_index = (BYTE)read_int_attribute( self, "pixel" );
        channel->m_head_number = (BYTE)read_int_attribute( self, "head" );

        // If head number is not set on tilt or pan, default to 1
        if ( channel->m_head_number == 0 && 
             (channel->m_type == CHNLT_TILT
              || channel->m_type == CHNLT_PAN
              || channel->m_type == CHNLT_PAN_FINE
              || channel->m_type == CHNLT_TILT_FINE) )
            channel->m_head_number = 1;

        STUDIO_ASSERT( channel->m_channel_offset > 0, "Channel '%s' index < 1", channel->m_name );

        channel->m_channel_offset--;        // Adjust offset for internal zero based

        TiXmlElement *dimmer = self->FirstChildElement( "dimmer" );
        if ( dimmer ) {
            channel->m_is_dimmer = true;
            channel->m_lowest_intensity = (BYTE)read_int_attribute( dimmer, "lowest_intensity", 0 );
            channel->m_highest_intensity = (BYTE)read_int_attribute( dimmer, "highest_intensity", 255 );
        }
        else {
            channel->m_is_dimmer = ( channel->m_type == CHNLT_DIMMER );     // Implies this is the default 0-255 dimmer channel type
            channel->m_lowest_intensity = 0;
            channel->m_highest_intensity = 255;
        }

        // Add channel ranges
        std::vector<ChannelValueRange *> ranges = 
            read_xml_list<ChannelValueRange>( self->FirstChildElement( "ranges" ), "range" );

        for ( std::vector<ChannelValueRange *>::iterator it=ranges.begin(); it != ranges.end(); ++it ) {
            STUDIO_ASSERT( (*it)->getEnd() >= (*it)->getStart(), "Channel '%s' range %s invalid", channel->m_name, (*it)->getName() );
            STUDIO_ASSERT( channel->getRange( (*it)->getEnd() ) == NULL, "Channel '%s' range %s overlaps", channel->m_name, (*it)->getName() );
            STUDIO_ASSERT( channel->getRange( (*it)->getStart() ) == NULL, "Channel '%s' range %s overlaps", channel->m_name, (*it)->getName() );
            channel->m_ranges.push_back( *(*it) );
            delete (*it);
        }

        // Add angles
        std::vector<ChannelAngle *> angles = 
            read_xml_list<ChannelAngle>( self->FirstChildElement( "angles" ), "angle" );

        for ( std::vector<ChannelAngle *>::iterator it=angles.begin(); it != angles.end(); ++it ) {
            channel->m_angles[ (*it)->getAngle() ] = *(*it);
            delete (*it);
        }

        channel->generateAngleTable();
    }
    catch( ... ) {
        delete channel;
        throw;
    }

    return channel;
}