void MindLocalCircuitConnectionDef::createFromXml( Xml xml ) {
	// attributes are properties
	typeName = xml.getAttribute( "type" );

	primary = xml.getBooleanAttribute( "primary" , false );
	srcRegion = xml.getAttribute( "src" );
	dstRegion = xml.getAttribute( "dst" );

	Object::setInstance( srcRegion + "-" + dstRegion );
}
void MindTarget::addSensor( String p_id , MindSensor *sensor ) {
	Xml configSensors = config.getChildNode( "sensors" );
	Xml xconfig = configSensors.findChildByPathAttr( "sensor" , "id" , p_id );

	bool offline = true;
	if( xconfig.exists() && xconfig.getBooleanAttribute( "run" , true ) ) {
		sensor -> configureSensor( xconfig );
		offline = false;
	}

	sensor -> setSensorId( p_id );
	sensorArea -> addSensor( sensor , offline );
}
void MindTarget::addEffector( String p_id , MindEffector *effector ) {
	Xml configEffectors = config.getChildNode( "effectors" );
	Xml xconfig = configEffectors.findChildByPathAttr( "effector" , "id" , p_id );

	ASSERTMSG( xconfig.exists() , "addEffector: unknown target id=" + p_id );

	bool offline = true;
	if( xconfig.getBooleanAttribute( "run" , true ) ) {
		effector -> configureEffector( xconfig );
		offline = false;
	}

	effector -> setEffectorId( p_id );
	effectorArea -> addEffector( effector , offline );
}
void MindCircuitDef::createFromXml( Xml xml ) {
	// attributes are properties
	id = xml.getAttribute( "id" );
	name = xml.getAttribute( "name" );
	Object::setInstance( name );

	enabled = xml.getBooleanAttribute( "enabled" , true );
	if( !enabled )
		return;

	// read connections
	for( Xml xmlChild = xml.getFirstChild( "connection" ); xmlChild.exists(); xmlChild = xmlChild.getNextChild( "connection" ) ) {
		// construct MindArea from attributes
		MindCircuitConnectionDef *connection = new MindCircuitConnectionDef( this );
		connection -> createFromXml( xmlChild );
		connections.add( connection );
	}
}
Example #5
0
void AIKnowledgeImpl::addKnowledgeController( Xml configControllers , KnowledgeController *controller )
{
	String name = controller -> getName();

	// find configuration
	Xml config = configControllers.getChildNamedNode( "controller" , name );
	ASSERTMSG( config.exists() , "Configuration not found for knowledge controller=" + name );

	if( !config.getBooleanAttribute( "run" ) ) {
		// do not use this controller
		delete controller;
		logger.logInfo( "addKnowledgeController: knowledge controller ignored as not configured to run - name=" + name );
		return;
	}

	// add controller
	controllers.add( name , controller );
	controller -> createController( config );
	logger.logInfo( "addKnowledgeController: knowledge controller created - name=" + name );
}
void MindAreaDef::createFromXml( Xml xml ) {
	// attributes are properties
	areaId = xml.getAttribute( "id" );
	areaType = xml.getAttribute( "type" );
	areaName = xml.getAttribute( "name" );
	areaFunction = xml.getAttribute( "function" );
	Object::setInstance( areaId );

	enabled = xml.getBooleanAttribute( "enabled" , true );
	if( !enabled )
		return;

	// read regions
	for( Xml xmlChild = xml.getFirstChild( "region" ); xmlChild.exists(); xmlChild = xmlChild.getNextChild( "region" ) ) {
		// construct MindArea from attributes
		MindRegionDef *region = new MindRegionDef( this );
		region -> createFromXml( xmlChild );
		regions.add( region );
		regionMap.add( region -> getId() , region );
	}
}
void TargetCircuitConnectionDef::defineCircuitConnectorDef( TargetRegionConnectorDef *p_regionConnection , Xml xml ) {
	regionConnection = p_regionConnection;
	TargetCircuitDef *circuitInfoTarget = ( TargetCircuitDef * )MindCircuitConnectionDef::circuitDef;

	// check direction
	if( regionConnection -> getType().equals( "target" ) ) {
		MindCircuitConnectionDef::srcRegion = regionConnection -> getRegion();
		MindCircuitConnectionDef::dstRegion = circuitInfoTarget -> getActuatorId();
	}
	else {
		MindCircuitConnectionDef::srcRegion = circuitInfoTarget -> getActuatorId();
		MindCircuitConnectionDef::dstRegion = regionConnection -> getRegion();
	}

	// create unique connection type
	connectionTypeDef = new TargetConnectionTypeDef();
	connectionTypeDef -> defineConnectionTypeDef( circuitInfoTarget , regionConnection , xml );

	MindCircuitConnectionDef::typeName = connectionTypeDef -> getName();
	Object::setInstance( MindCircuitConnectionDef::typeName );
	MindCircuitConnectionDef::type = connectionTypeDef;
	MindCircuitConnectionDef::primary = xml.getBooleanAttribute( "primary" , false );
}
Example #8
0
void Sensors::addSensor( Xml configSensors , Sensor *att )
{
	String name = att -> getName();
	Xml config = configSensors.getChildNamedNode( "sensor" , name );

	if( config.exists() && config.getBooleanAttribute( "run" ) ) {
		sensors.add( name , att );
		logger.logInfo( "addSensor: sensor added - name=" + name );
	}
	else {
		sensorsOffline.add( name , att );
		logger.logInfo( "addSensor: sensor is not configured to run - name=" + name );
	}

	// generate cortex dimentions - square-like
	BrainLocation cortexLocation;
	int inputsDim1 , inputsDim2;
	int nInputs = att -> getNInputs( inputsDim1 , inputsDim2 );
	int outputsDim1 , outputsDim2;
	int nOutputs = att -> getNOutputs( outputsDim1 , outputsDim2 );

	// two layers: upper - control, lower - sensor data
	int dz = 2;

	// make cortex location
	int dx = max( inputsDim1 , outputsDim1 );
	int dy = max( inputsDim2 , outputsDim2 );

	cortexLocation.setDimensions( dx , dy , dz );
	cortexLocation.setOrientationZ( true );
	BrainLocation areaLocation = MindArea::getLocation();
	areaLocation.placeLocation( coverLocation , cortexLocation );

	// add to brain
	AIBrain brain;
	brain.createSensorCortex( this , cortexLocation , att );
}