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); }
void RTSPropertiesViewImpl::showConnection(PortService_var port, string id, QTreeWidgetItem* item)//ComponentProfile_var cprofile, string port, string id, QTreeWidgetItem* item) { item->setText(0, _("Connector Profile")); item->setIcon(0, QIcon(":/RTSystemEditor/icons/IconConnector.png")); if(CORBA::is_nil(port) || port->_non_existent()) return; PortProfile_var portprofile = port->get_port_profile(); ConnectorProfileList connections = portprofile->connector_profiles; for(CORBA::ULong i = 0; i < connections.length(); i++){ ConnectorProfile connector = connections[i]; if(id == string(connector.connector_id)){ PortServiceList& connectedPorts = connector.ports; QTreeWidgetItem* conPropChild = new QTreeWidgetItem; conPropChild->setText(0, _("Connector ID")); conPropChild->setText(1, QString(connector.connector_id)); item->addChild(conPropChild); //conPropChild = new RTSTreeItem(RTSTreeItem::RTS_ITEM_NAME_TYPE); conPropChild = new QTreeWidgetItem; conPropChild->setText(0, _("Name")); conPropChild->setText(1, QString(connector.name)); // keep the values of connection. //this->connItem->name = string(connector.name); item->addChild(conPropChild); coil::Properties cproperties = NVUtil::toProperties(connector.properties); vector<string> names = cproperties.propertyNames(); for (vector<string>::iterator iter = names.begin(); iter != names.end(); iter++) { // view the attribute of rtc-connection. string name = (*iter).c_str(); //QTreeWidgetItem* connPropChild = judgementType(name); conPropChild = new QTreeWidgetItem; conPropChild->setText(0, QString(name.c_str())); conPropChild->setText(1, QString((cproperties[*iter]).c_str())); item->addChild(conPropChild); } // Show the port informations. CORBA::ULong pslen(connectedPorts.length()); for (CORBA::ULong k = 0; k < pslen; k++) { PortService_var pservice = connectedPorts[k]; PortProfile* pprofile = pservice->get_port_profile(); showPortConcrete(pprofile, item); } } } }
bool RTSCompExt::connectionCheckSub(RTSPortExt* rtsPort) { bool updated = false; if (isObjectAlive(rtsPort->port) == false) return updated; /** The get_port_profile() function should not be used here because it takes much time when the port has large data and its owner RTC is in a remote host. The get_connector_profiles() function does not seem to cause such a problem. */ ConnectorProfileList_var connectorProfiles = rtsPort->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_var connectedPortRef = connectedPorts[j]; if(CORBA::is_nil(connectedPortRef)){ continue; } PortProfile_var connectedPortProfile; try { connectedPortProfile = connectedPortRef->get_port_profile(); } catch (CORBA::SystemException& ex) { MessageView::instance()->putln( MessageView::WARNING, format(_("CORBA %1% (%2%), %3% in RTSComp::connectionCheckSub()")) % ex._name() % ex._rep_id() % ex.NP_minorString()); continue; } string portName = string(connectedPortProfile->name); vector<string> target; RTCCommonUtil::splitPortName(portName, target); if (target[0] == name) continue; string rtcPath; if(!getComponentPath(connectedPortRef, rtcPath)){ continue; } RTSCompExt* targetRTC = rts_->impl->nameToRTSComp("/" + rtcPath); if(!targetRTC){ continue; } //DDEBUG("targetRTC Found"); RTSPortExt* targetPort = targetRTC->nameToRTSPort(portName); if (targetPort) { auto itr = rts_->impl->rtsConnections.find(RTSystemExtItem::RTSPortPair(rtsPort, targetPort)); if (itr != rts_->impl->rtsConnections.end()) { continue; } RTSConnectionExtPtr rtsConnection = new RTSConnectionExt( string(connectorProfile.connector_id), string(connectorProfile.name), name, rtsPort->name, target[0], portName); coil::Properties properties = NVUtil::toProperties(connectorProfile.properties); vector<NamedValueExtPtr> propList; NamedValueExtPtr dataType(new NamedValueExt("dataport.dataflow_type", properties["dataport.dataflow_type"])); propList.push_back(dataType); NamedValueExtPtr subscription(new NamedValueExt("dataport.subscription_type", properties["dataport.subscription_type"])); rtsConnection->propList = propList; rtsConnection->srcRTC = this; rtsConnection->sourcePort = nameToRTSPort(rtsConnection->sourcePortName); rtsConnection->targetRTC = targetRTC; rtsConnection->targetPort = targetRTC->nameToRTSPort(rtsConnection->targetPortName); rtsConnection->isAlive_ = true; rts_->impl->rtsConnections[RTSystemExtItem::RTSPortPair(rtsPort, targetPort)] = rtsConnection; rts_->suggestFileUpdate(); updated = true; } } } return updated; }