Пример #1
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;
}
Пример #2
0
RTSPortExt::RTSPortExt(const string& name_, PortService_var port_, RTSCompExt* parent)
    : rtsComp(parent), isConnected_(false)
{
    isInPort = true;
    name = name_;
    port = port_;
    //
    if (port) {
        RTC::PortProfile_var profile = port->get_port_profile();
        RTC::PortInterfaceProfileList interfaceList = profile->interfaces;
        for (CORBA::ULong index = 0; index < interfaceList.length(); ++index) {
            RTC::PortInterfaceProfile ifProfile = interfaceList[index];
            PortInterfaceExtPtr portIf(new PortInterfaceExt());
            if (parent) {
                portIf->rtc_name = parent->name;
            }
            const char* port_name;
            portIf->port_name = string((const char*)profile->name);
            if (ifProfile.polarity == PortInterfacePolarity::REQUIRED) {
                portIf->if_polarity = "required";
            } else {
                portIf->if_polarity = "provided";
            }
            const char* if_iname;
            const char* if_tname;
            if_iname = (const char*)ifProfile.instance_name;
            if_tname = (const char*)ifProfile.type_name;
            DDEBUG_V("name: %s, IF name: %s, instance_name: %s, type_name: %s", name_.c_str(), portIf->port_name.c_str(), if_iname, if_tname);
            portIf->if_tname = if_tname;
            portIf->if_iname = if_iname;
            interList.push_back(portIf);

            isConnected_ = isConnected();
        }
    }
}
Пример #3
0
void RTSPropertiesViewImpl::showPortConcrete(PortProfile* portprofile, QTreeWidgetItem* item)
{
    coil::Properties pproperties = NVUtil::toProperties(portprofile->properties);

    string portName = string(portprofile->name);
    RTCCommonUtil::splitPortName(portName);
    string portType = pproperties["port.port_type"];

    QTreeWidgetItem* port = new QTreeWidgetItem;
    if (boost::iequals(portType, "CorbaPort")) {
        port->setText(0, QString("ServicePort"));
        port->setIcon(0, QIcon(":/RTSystemEditor/icons/IconServicePort.png"));
    } else {
        port->setText(0, QString(portType.substr(4).c_str()));
        port->setIcon(0, QIcon(boost::iequals(portType, "DataOutPort") ?
                ":/RTSystemEditor/icons/IconOutPort.png" :
                ":/RTSystemEditor/icons/IconInPort.png"));
    }
    item->addChild(port);

    QTreeWidgetItem* portChild = new QTreeWidgetItem;
    portChild->setText(0, _("Name"));
    portChild->setText(1, QString(portName.c_str()));
    port->addChild(portChild);

    if (boost::iequals(portType, "CorbaPort")) {
        RTC::PortInterfaceProfileList iflist = portprofile->interfaces;
        for (CORBA::ULong i = 0; i < iflist.length(); i++) {
            QTreeWidgetItem* ifport = new QTreeWidgetItem;
            ifport->setText(0, QString("PortInterfaceProfile"));
            ifport->setIcon(0, QIcon(":/RTSystemEditor/icons/IconPIP.png"));
            port->addChild(ifport);

            QTreeWidgetItem* ifportc = new QTreeWidgetItem;
            ifportc->setText(0, QString("Interface Name"));
            ifportc->setText(1, QString(iflist[i].instance_name));
            ifport->addChild(ifportc);

            ifportc = new QTreeWidgetItem;
            ifportc->setText(0, QString("Type Name"));
            ifportc->setText(1, QString(iflist[i].type_name));
            ifport->addChild(ifportc);

            ifportc = new QTreeWidgetItem;
            ifportc->setText(0, QString("Port Interface Polarity"));
            ifportc->setText(1, QString((iflist[i].polarity == 0 ? "PROVIDED" : "REQUIRED")));
            ifport->addChild(ifportc);
        }
    }

    // Get the port properties.
    QTreeWidgetItem* portProp = new QTreeWidgetItem;
    portProp->setText(0, _("Properties"));
    port->addChild(portProp);

    vector<string> portNames = pproperties.propertyNames();
    for (vector<string>::iterator iter = portNames.begin(); iter != portNames.end(); iter++) {
        QTreeWidgetItem* portPropChild = new QTreeWidgetItem;
        portPropChild->setText(0, QString((*iter).c_str()));
        portPropChild->setText(1, QString((pproperties[*iter]).c_str()));
        portProp->addChild(portPropChild);
    }
}