Ejemplo n.º 1
0
 ServerData(Config *config) : config_(config) {
     config_->startup();
     getPorts("/xscript/alternate-port", 8080, alternate_ports_);
     getPorts("/xscript/noxslt-port", 8079, noxslt_ports_);
     
     char buf[256];
     int res = ::gethostname(buf, sizeof(buf));
     if (0 == res) {
         hostname_.assign(buf);
     }
 }
Ejemplo n.º 2
0
char portsStateChanged(){
	unsigned int cur_state = getPorts();
	if (cur_state != g_ports_state){
		g_ports_state = cur_state;
		return TRUE;
	}
	return FALSE;
}
Ejemplo n.º 3
0
QStringList ModItemsTree::getPorts(ModItem* parent,ModItem::NameFormat format)
{
    QList<ModItem*> _ports = getPorts(parent);

    QStringList _portsNames;
    for(int i=0; i<_ports.size(); i++)
        _portsNames.push_back(_ports.at(i)->name(format));

    return _portsNames;
}
Ejemplo n.º 4
0
void CompositionTest::delete_selfInstance_port_removes_dependant_connections()
{
  Component *comp1 = ComponentFactory::produce("comp1", {"in"}, {"out"});
  Composition *composition = new Composition(new CompositionInstance(comp1));
  comp1->setImplementation(composition);

  const auto inst = composition->getSelfInstance();
  auto portIn = inst->getPorts()[0];
  auto portOut = inst->getPorts()[1];
  auto connection = ConnectionFactory::produce(portIn, portOut);
  composition->getConnections().add(connection);

  ComponentPort *port = comp1->getPorts()[0];
  CPPUNIT_ASSERT_EQUAL(size_t(1), composition->getConnections().size());
  comp1->getPorts().remove(port);
  CPPUNIT_ASSERT_EQUAL(size_t(0), composition->getConnections().size());

  ComponentFactory::dispose(comp1);
}
Ejemplo n.º 5
0
Port* Processor::getPort(const std::string& name) const {
    const std::vector<Port*> ports = getPorts();

    for (size_t i=0; i < ports.size(); i++) {
        if (ports[i]->getID() == name)
            return ports[i];
    }

    return 0;
}
Ejemplo n.º 6
0
void SerialWatch::watchPorts()
{
    newPorts = getPorts();
    /* First watch should emit signal always */
    if ((oldPorts != newPorts) || (firstWatch == true)) {
//        qDebug() << "Serial ports changed from: " << oldPorts << " to: " << newPorts;
        mutex.lock();
        oldPorts = newPorts;
        emit(changed(newPorts));
        mutex.unlock();
        firstWatch = false;
    }
}
Ejemplo n.º 7
0
void Processor::initialize() throw (tgt::Exception) {
    if(description_ == "")
        setDescriptions();

    if (!VoreenApplication::app()) {
        LERROR("VoreenApplication not instantiated");
        throw VoreenException("VoreenApplication not instantiated");
    }

    if (isInitialized()) {
        LWARNING("initialize(): '" << getID() << "' already initialized");
        return;
    }

    bool glMode = VoreenApplication::app() && VoreenApplication::app()->isInitializedGL();
    if (!glMode)
        LDEBUG("initialize() not in OpenGL mode");

    // create and initialize processor widget
    processorWidget_ = VoreenApplication::app()->createProcessorWidget(this);
    if (processorWidget_) {
        processorWidget_->initialize();
        if (glMode)
            LGL_ERROR;
        // inform the observers about the new widget
        std::vector<ProcessorObserver*> observers = Observable<ProcessorObserver>::getObservers();
        for (size_t i = 0; i < observers.size(); ++i)
            observers[i]->processorWidgetCreated(this);
    }


    // initialize ports
    const std::vector<Port*>& ports = getPorts();
    for (size_t i=0; i < ports.size(); ++i) {
        if (!ports[i]->isInitialized())
            ports[i]->initialize();
        if (glMode)
            LGL_ERROR;
    }

    // initialize properties
    const std::vector<Property*>& properties = getProperties();
    for (size_t i=0; i < properties.size(); ++i) {
        properties[i]->initialize();
        if (glMode)
            LGL_ERROR;
    }
}
void QextSerialEnumerator::setUpNotifications( )
{
    #ifdef QT_GUI_LIB
    if(notificationWidget)
        return;
    notificationWidget = new QextSerialRegistrationWidget(this);

    DEV_BROADCAST_DEVICEINTERFACE dbh;
    ZeroMemory(&dbh, sizeof(dbh));
    dbh.dbcc_size = sizeof(dbh);
    dbh.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE;
    CopyMemory(&dbh.dbcc_classguid, &GUID_DEVCLASS_PORTS, sizeof(GUID));
    if( RegisterDeviceNotification( notificationWidget->winId( ), &dbh, DEVICE_NOTIFY_WINDOW_HANDLE ) == NULL)
        qWarning() << "RegisterDeviceNotification failed:" << GetLastError();
    // setting up notifications doesn't tell us about devices already connected
    // so get those manually
    foreach( QextPortInfo port, getPorts() )
      emit deviceDiscovered( port );
    #else
    qWarning("QextSerialEnumerator: GUI not enabled - can't register for device notifications.");
    #endif // QT_GUI_LIB
}
Ejemplo n.º 9
0
void Processor::deinitialize() throw (tgt::Exception) {
    if (!isInitialized()) {
        LWARNING("deinitialize(): '" << getID() << "' (" << getClassName() << ") not initialized");
        return;
    }

    bool glMode = VoreenApplication::app() && VoreenApplication::app()->isInitializedGL();
    if (!glMode)
        LDEBUG("deinitialize() not in OpenGL mode");

    if (glMode)
        LGL_ERROR;

    // deinitialize ports
    const std::vector<Port*>& ports = getPorts();
    for (size_t i=0; i < ports.size(); ++i)
        ports[i]->deinitialize();
    if (glMode)
        LGL_ERROR;

    // deinitialize properties
    const std::vector<Property*>& properties = getProperties();
    for (size_t i=0; i < properties.size(); ++i)
        properties[i]->deinitialize();
    if (glMode)
        LGL_ERROR;

    // delete processor widget
    delete processorWidget_;
    processorWidget_ = 0;

    // notify observers about the deleted widget
    std::vector<ProcessorObserver*> observers = Observable<ProcessorObserver>::getObservers();
    for (size_t i = 0; i < observers.size(); ++i)
        observers[i]->processorWidgetDeleted(this);
}
Ejemplo n.º 10
0
bool CGPSgeneric::findPort(CGPSport *portinfo,CString *portname, CString *devicename, CString *deviceid)
{
    CGPSportList wholeList,shortList;
    unsigned int ll,ii;

    // No port destination object ... err ... no
    if (portinfo==NULL)
        return false;

    // No info, no dice
    if (portname==NULL && devicename==NULL && deviceid==NULL)
        return false;

    wholeList=getPorts();

    for (ll=0; ll<4; ll++) {

        // no point looking if there are no devices to be found
        if (wholeList.size() == 0)
            return false;

        // no point looking any further if there is just one match
        if (wholeList.size() == 1u) {
            *portinfo=wholeList.front();
            return true;
        }

        switch (ll) {
        case 0:
            // See if we know any device by name
            if (devicename!=NULL) {
                for (ii=0; ii<wholeList.size(); ii++) {
                    if (wholeList[ii].getDeviceName() == *devicename) {
                        shortList.push_back(wholeList[ii]);
                    }
                }
                if (shortList.size() > 0)
                {
                    wholeList=shortList;
                    shortList.clear();
                }
            }
            break;
        case 1:
            // See if we know any device by ID
            if (deviceid!=NULL) {
                for (ii=0; ii<wholeList.size(); ii++) {
                    if (wholeList[ii].getDeviceID() == *deviceid) {
                        shortList.push_back(wholeList[ii]);
                    }
                }
                if (shortList.size() > 0)
                {
                    wholeList=shortList;
                    shortList.clear();
                }
            }
            break;
        case 2:
            // See if we know any device by port
            if (portname!=NULL) {
                for (ii=0; ii<wholeList.size(); ii++) {
                    if (wholeList[ii].getPortName() == *portname) {
                        shortList.push_back(wholeList[ii]);
                    }
                }
                if (shortList.size() > 0)
                {
                    wholeList=shortList;
                    shortList.clear();
                }
            }
            break;
        case 3:
        // empty loop to do simple returns
        default:
            // WTF?
            break;
        }
    }

    // If we haven't returned yet, it means we have devices but don't have any matches, so pick a random
    // device. At a guess the ports should be ordered NMEA, Ser, USB, so pick from the back
    *portinfo=wholeList.back();

    return true;


}