예제 #1
0
bool RTSConnectionExt::connect()
{
    DDEBUG("RTSConnection::connect");

    if (!sourcePort || !targetPort) {
        return false;
    }

    if (!sourcePort->port || !targetPort->port ||
       CORBA::is_nil(sourcePort->port) || sourcePort->port->_non_existent() ||
       CORBA::is_nil(targetPort->port) || targetPort->port->_non_existent()) {
        DDEBUG("RTSConnection::connect False");
        return false;
    }

    if (sourcePort->isConnectedWith(targetPort)) {
        return false;
    }

    ConnectorProfile cprof;
    cprof.connector_id = CORBA::string_dup(id.c_str());
    cprof.name = CORBA::string_dup(name.c_str());
    cprof.ports.length(2);
    cprof.ports[0] = PortService::_duplicate(sourcePort->port);
    cprof.ports[1] = PortService::_duplicate(targetPort->port);

    for (int index = 0; index < propList.size(); index++) {
        NamedValueExtPtr param = propList[index];
        CORBA_SeqUtil::push_back(
            cprof.properties, NVUtil::newNV(param->name_.c_str(), param->value_.c_str()));
    }

    RTC::ReturnCode_t result = sourcePort->port->connect(cprof);
    if (result == RTC::RTC_OK) {
        PortProfile_var portprofile = sourcePort->port->get_port_profile();
        ConnectorProfileList connections = portprofile->connector_profiles;
        for (CORBA::ULong i = 0; i < connections.length(); i++) {
            ConnectorProfile& connector = connections[i];
            PortServiceList& connectedPorts = connector.ports;
            for (CORBA::ULong j = 0; j < connectedPorts.length(); ++j) {
                PortService_ptr connectedPortRef = connectedPorts[j];
                if (connectedPortRef->_is_equivalent(targetPort->port)) {
                    id = string(connector.connector_id);
                    isAlive_ = true;
                    DDEBUG("RTSConnection::connect End");
                    return true;
                }
            }
        }
        return false;
    }

    DDEBUG("connect Error");
    return false;
}
RTC::ReturnCode_t ImageViewer::onActivated(RTC::UniqueId ec_id)
{
  PortServiceList* portlist;
  
  portlist = this->get_ports();
  connection_check = new bool [portlist->length()];
  for(unsigned int i=0; i<portlist->length(); ++i)
  {
	PortService_ptr port;
	port = (*portlist)[i];
	if(port->get_port_profile()->connector_profiles.length()!=0)
	  connection_check[i]=true;
	else
      connection_check[i]=false;
  }

  //サービスポート接続状態のチェック
  if(connection_check[1])
  {
      //連続画像取得モードに設定
	  if(m_capture_frame_num == 0)
	  {
		std::cout << "start continuous image streaming." << std::endl;
		RTC_INFO(("Send command of \"start continuous\" via CameraCaptureService."));
		m_CameraCaptureService->start_continuous();
	  }
	  //1shotキャプチャモードに設定
	  else if(m_capture_frame_num == 1)
	  {
		std::cout << "take one frame." << std::endl;
		RTC_INFO(("Send command of \"take one frame\" via CameraCaptureService."));
		m_CameraCaptureService->take_one_frame();
	  }
	  //指定枚数キャプチャモードに設定
	  else if(m_capture_frame_num > 1)
	  {
		std::cout << "take multi frames (" << m_capture_frame_num << " frames)." << std::endl;
		RTC_INFO(("Send command of \"take multi frames\" via CameraCaptureService."));
		m_CameraCaptureService->take_multi_frames(m_capture_frame_num);
	  }
	  else
	  {
		std::cerr << "Please set capture_frame_num to more than 0" << std::endl;
		RTC_ERROR(("Configuration Param <frames_num> should be over 0. [%d]",m_capture_frame_num));
		return RTC::RTC_ERROR;
	  }
  }


  std::cout << "Start image view" << std::endl;
  std::cout << "If you want to take a 1 shot image as image file, please push s on Captured Image Window!" << std::endl;

  return RTC::RTC_OK;
}
예제 #3
0
void portConnect(PortService_ptr p1, PortService_var p2)
{
	string subs_type = "flush";
	string period = "";

	p1->disconnect_all();
	p2->disconnect_all();

	string ConnectName = "_";
	ConnectName += p1->get_port_profile()->name;
	ConnectName += "_";
	ConnectName += p2->get_port_profile()->name;

	string ConnectIDName = "_id_";
	ConnectIDName += p1->get_port_profile()->name;
	ConnectIDName += "_";
	ConnectIDName += p2->get_port_profile()->name;


/*
http://www17.atpages.jp/~aitech/wiki/?OpenRTM%2FControl%2Fconnect
のソースコード70〜78行目
*/

	RTC::ConnectorProfile prof;
	prof.connector_id = ConnectIDName.c_str();
	prof.name = CORBA::string_dup(ConnectName.c_str());
	prof.ports.length(2);
	prof.ports[0] = p1;
	prof.ports[1] = p2;


    CORBA_SeqUtil::push_back(prof.properties,NVUtil::newNV("dataport.interface_type", "corba_cdr"));
    CORBA_SeqUtil::push_back(prof.properties,NVUtil::newNV("dataport.dataflow_type","push"));
    if(subs_type=="flush")
        CORBA_SeqUtil::push_back(prof.properties,NVUtil::newNV("dataport.subscription_type","flush"));
    else if(subs_type=="new")
        CORBA_SeqUtil::push_back(prof.properties,NVUtil::newNV("dataport.subscription_type","new"));
    else if(subs_type=="periodic"){
        CORBA_SeqUtil::push_back(prof.properties,NVUtil::newNV("dataport.subscription_type","periodic"));
        CORBA_SeqUtil::push_back(prof.properties,NVUtil::newNV("dataport.push_rate",period.c_str()));
    }

/*ここまで*/

    RTC::ReturnCode_t ret;



    ret = p1->connect(prof);

}
예제 #4
0
void MyModuleInit(RTC::Manager* manager)
{
    RGB2GrayInit(manager);
    RTC::RtcBase* comp;

    // Create a component
    comp = manager->createComponent("RGB2Gray");


    // Example
    // The following procedure is examples how handle RT-Components.
    // These should not be in this function.

    // Get the component's object reference
    RTC::RTObject_var rtobj;
    rtobj = RTC::RTObject::_narrow(manager->getPOA()->servant_to_reference(comp));

    // Get the port list of the component
    PortServiceList* portlist;
    portlist = rtobj->get_ports();

    // getting port profiles
    std::cout << "Number of Ports: ";
    std::cout << portlist->length() << std::endl << std::endl;
    for (CORBA::ULong i(0), n(portlist->length()); i < n; ++i)
    {
        PortService_ptr port;
        port = (*portlist)[i];
        std::cout << "Port" << i << " (name): ";
        std::cout << port->get_port_profile()->name << std::endl;

        RTC::PortInterfaceProfileList iflist;
        iflist = port->get_port_profile()->interfaces;
        std::cout << "---interfaces---" << std::endl;
        for (CORBA::ULong i(0), n(iflist.length()); i < n; ++i)
        {
            std::cout << "I/F name: ";
            std::cout << iflist[i].instance_name << std::endl;
            std::cout << "I/F type: ";
            std::cout << iflist[i].type_name << std::endl;
            const char* pol;
            pol = iflist[i].polarity == 0 ? "PROVIDED" : "REQUIRED";
            std::cout << "Polarity: " << pol << std::endl;
        }
        std::cout << "---properties---" << std::endl;
        NVUtil::dump(port->get_port_profile()->properties);
        std::cout << "----------------" << std::endl << std::endl;
    }

    return;
}
예제 #5
0
void portConnect(PortService_ptr p1, PortService_var p2)
{
	string subs_type = "new";
	string period = "";

	coil::UUID_Generator *m_uuid = new coil::UUID_Generator();
	coil::UUID* m_generateUUID = m_uuid->generateUUID(0, 0);
	
	std::string m_uuidstr = m_generateUUID->to_string();

	

	//p1->disconnect_all();
	//p2->disconnect_all();

	string ConnectName = m_uuidstr;
	
	

	string ConnectIDName = "_id_" + m_uuidstr;
	


/*
http://www17.atpages.jp/~aitech/wiki/?OpenRTM%2FControl%2Fconnect
のソースコード70〜78行目
*/

	RTC::ConnectorProfile prof;
	prof.connector_id = ConnectIDName.c_str();
	prof.name = CORBA::string_dup(ConnectName.c_str());
	prof.ports.length(2);
	prof.ports[0] = p1;
	prof.ports[1] = p2;


    CORBA_SeqUtil::push_back(prof.properties,NVUtil::newNV("dataport.interface_type", "corba_cdr"));
    CORBA_SeqUtil::push_back(prof.properties,NVUtil::newNV("dataport.dataflow_type","push"));
    if(subs_type=="flush")
        CORBA_SeqUtil::push_back(prof.properties,NVUtil::newNV("dataport.subscription_type","flush"));
    else if(subs_type=="new")
        CORBA_SeqUtil::push_back(prof.properties,NVUtil::newNV("dataport.subscription_type","new"));
    else if(subs_type=="periodic"){
        CORBA_SeqUtil::push_back(prof.properties,NVUtil::newNV("dataport.subscription_type","periodic"));
        CORBA_SeqUtil::push_back(prof.properties,NVUtil::newNV("dataport.push_rate",period.c_str()));
    }

/*ここまで*/

    RTC::ReturnCode_t ret;



    ret = p1->connect(prof);


	delete m_uuid;
	delete m_generateUUID;
}
예제 #6
0
bool RTSPortExt::isConnectedWith(RTSPortExt* target)
{
    if (!port || !target->port ||
       CORBA::is_nil(port) || port->_non_existent() ||
       CORBA::is_nil(target->port) || target->port->_non_existent()) {
        return false;
    }

    ConnectorProfileList_var connectorProfiles = port->get_connector_profiles();

    for (CORBA::ULong i = 0; i < connectorProfiles->length(); ++i) {
        ConnectorProfile& connectorProfile = connectorProfiles[i];
        PortServiceList& connectedPorts = connectorProfile.ports;
        for (CORBA::ULong j = 0; j < connectedPorts.length(); ++j) {
            PortService_ptr connectedPortRef = connectedPorts[j];
            if (connectedPortRef->_is_equivalent(target->port)) {
                return true;
            }
        }
    }

    return false;
}