/** * This example sets the interface up in the Constructor * of the component. */ HelloWorld(std::string name) : TaskContext(name), // Name, description, value property("the_property", "the_property Description", "Hello World"), // Name, value attribute("the_attribute", "Hello World"), // Name, value constant("the_constant", "Hello World"), // Name, initial value dataport("the_data_port","World"), // Name, buffer size, initial value bufferport("the_buffer_port",13, "World"), // Name, function pointer, object method("the_method", &HelloWorld::mymethod, this), // Name, command function pointer, completion condition function pointer, object command("the_command", &HelloWorld::mycommand, &HelloWorld::mycomplete, this), // Name event("the_event"), // Create the activity which runs the task's engine: // 0: Priority // 0.01: Period (100Hz) // engine(): is being executed. act(0, 0.01, this->engine() ) { // Set log level more verbose than default, // such that we can see output : if ( log().getLogLevel() < Logger::Info ) { log().setLogLevel( Logger::Info ); log(Info) << "HelloWorld manually raises LogLevel to 'Info' (5). See also file 'orocos.log'."<<endlog(); } // Check if all initialisation was ok: assert( property.ready() ); assert( attribute.ready() ); assert( constant.ready() ); assert( method.ready() ); assert( command.ready() ); assert( event.ready() ); // Now add it to the interface: this->properties()->addProperty(&property); this->attributes()->addAttribute(&attribute); this->attributes()->addConstant(&constant); this->ports()->addPort(&dataport); this->ports()->addPort(&bufferport); this->methods()->addMethod(&method, "'the_method' Description"); this->commands()->addCommand(&command, "'the_command' Description", "the_arg", "Use 'World' as argument to make the command succeed."); this->events()->addEvent(&event, "'the_event' Description", "the_data", "The data of this event."); // Adding an asynchronous callback: h = this->events()->setupConnection("the_event").callback(this, &HelloWorld::mycallback, this->engine()->events() ).handle(); h.connect(); log(Info) << "**** Starting the 'Hello' component ****" <<endlog(); // Start the component's activity: this->start(); }