Пример #1
0
void MainWidget::connectSignals()
{
    connect(configForm, SIGNAL(finished(int)), this, SLOT(dialogResult(int)));
    connect(managerForm, SIGNAL(stopped()), qApp, SLOT(quit()));
    connect(managerForm, SIGNAL(deviceConnected(QString)), this, SIGNAL(deviceConnected(QString)));
    connect(managerForm, SIGNAL(deviceDisconnected()), this, SIGNAL(deviceDisconnected()));
    connect(managerForm, SIGNAL(messageSent(QString)), this, SIGNAL(messageReceived(QString)));
    connect(managerForm, SIGNAL(updated(int)), this, SIGNAL(databaseUpdated(int)));
}
Пример #2
0
void TCPCom::connect(bool connect) {
  try {
    if (connect) {
      mDevice.getConnection().open();
      emit deviceConnected(true);
    }
    else {
      mDevice.getConnection().close();
      emit deviceConnected(false);
    }
  }
  catch (SystemException& e) {
    emit comException(e.what());
  }
}
Пример #3
0
void CmaClient::processNewConnection(vita_device_t *device)
{
    QMutexLocker locker(&mutex);
    in_progress = true;
    broadcast.setUnavailable();

    qDebug("Vita connected: id %s", VitaMTP_Get_Identification(device));
    DeviceCapability vita_info;

    if(!vita_info.exchangeInfo(device)) {
        qCritical("Error while exchanging info with the vita");
    } else {
        // Conection successful, inform the user
        emit deviceConnected(QString(tr("Connected to ")) + vita_info.getOnlineId());
        enterEventLoop(device);
    }

    VitaMTP_SendHostStatus(device, VITA_HOST_STATUS_EndConnection);
    qDebug("Releasing device...");
    VitaMTP_Release_Device(device);

    emit deviceDisconnected();

    broadcast.setAvailable();
    in_progress = false;
    sema.release();
}
Пример #4
0
/**
*   Method called when the user clicks the "Connect" button
*/
bool ConnectionManager::connectDevice(DevListItem device)
{
    DevListItem connection_device = findDevice(m_availableDevList->itemData(m_availableDevList->currentIndex(),Qt::ToolTipRole).toString());
    if (!connection_device.connection)
        return false;

    QIODevice *io_dev = connection_device.connection->openDevice(connection_device.device.name);
    if (!io_dev)
        return false;

    io_dev->open(QIODevice::ReadWrite);

    // check if opening the device worked
    if (!io_dev->isOpen()) {
        return false;
    }

    // we appear to have connected to the device OK
    // remember the connection/device details
    m_connectionDevice = connection_device;
    m_ioDev = io_dev;

    connect(m_connectionDevice.connection, SIGNAL(destroyed(QObject *)), this, SLOT(onConnectionDestroyed(QObject *)), Qt::QueuedConnection);

    // signal interested plugins that we connected to the device
    emit deviceConnected(io_dev);
    m_connectBtn->setText("Disconnect");
    m_availableDevList->setEnabled(false);

    // tell the monitorwidget we're conneced
    m_monitorWidget->connect();

    return true;
}
Пример #5
0
OniStatus PlayerDriver::tryDevice(const char* strUri)
{
	static XnPlayerInputStreamInterface inputInterface = 
	{
		FileOpen,
		FileRead,
		NULL,
		NULL,
		FileClose,
		NULL,
		NULL,
	};

	// Store the file path.
	m_filePath = strUri;

	XnStatus rc = PlayerNode::ValidateStream(this, &inputInterface);
	if (rc == XN_STATUS_OK)
	{
		OniDeviceInfo* pInfo = XN_NEW(OniDeviceInfo);
		xnOSMemSet(pInfo, 0, sizeof(*pInfo));
		xnOSStrCopy(pInfo->uri,    strUri,               ONI_MAX_STR);
		xnOSStrCopy(pInfo->vendor, kVendorString.Data(), ONI_MAX_STR);
		xnOSStrCopy(pInfo->name,   kDeviceName.Data(),   ONI_MAX_STR);
		deviceConnected(pInfo);
		return ONI_STATUS_OK;
	}

	return DriverBase::tryDevice(strUri);
}
	virtual OniStatus initialize(
		oni::driver::DeviceConnectedCallback connectedCallback,
		oni::driver::DeviceDisconnectedCallback disconnectedCallback,
		oni::driver::DeviceStateChangedCallback deviceStateChangedCallback,
		void* pCookie)
	{
		oni::driver::DriverBase::initialize(connectedCallback, disconnectedCallback, deviceStateChangedCallback, pCookie);

        // Open Kinect v2
        auto hr = ::GetDefaultKinectSensor( &kinect_ );
        if ( FAILED( hr ) ) {
			return ONI_STATUS_NO_DEVICE;
        }
        
        hr = kinect_->Open();
        if (FAILED(hr)) {
            std::cerr << "IKinectSensor::Open() failed." << std::endl;
			return ONI_STATUS_ERROR;
        }

		// Create device info
		OniDeviceInfo* pInfo = XN_NEW(OniDeviceInfo);
		xnOSStrCopy(pInfo->vendor, "Microsoft", ONI_MAX_STR);
		xnOSStrCopy(pInfo->name, "Kinect V2 Developer Preview", ONI_MAX_STR);
		xnOSStrCopy(pInfo->uri, "Kinect V2", ONI_MAX_STR);

		// internal connect device
		deviceConnected(pInfo);
		deviceStateChanged(pInfo, 0);

		return ONI_STATUS_OK;
	}
Пример #7
0
void LeapMotionPlugin::pluginUpdate(float deltaTime, const controller::InputCalibrationData& inputCalibrationData) {
    if (!_enabled) {
        return;
    }

    const auto frame = _controller.frame();
    const auto frameID = frame.id();
    if (_lastFrameID >= frameID) {
        // Leap Motion not connected or duplicate frame.
        return;
    }

    if (!_hasLeapMotionBeenConnected) {
        emit deviceConnected(getName());
        _hasLeapMotionBeenConnected = true;
    }

    processFrame(frame);  // Updates _joints.

    auto joints = _joints;

    auto userInputMapper = DependencyManager::get<controller::UserInputMapper>();
    userInputMapper->withLock([&, this]() {
        _inputDevice->update(deltaTime, inputCalibrationData, joints, _prevJoints);
    });

    _prevJoints = joints;

    _lastFrameID = frameID;
}
Пример #8
0
BtLocalDevice::BtLocalDevice(QObject *parent) :
    QObject(parent), securityFlags(QBluetooth::NoSecurity)
{
    localDevice = new QBluetoothLocalDevice(this);
    connect(localDevice, SIGNAL(error(QBluetoothLocalDevice::Error)),
            this, SIGNAL(error(QBluetoothLocalDevice::Error)));
    connect(localDevice, SIGNAL(hostModeStateChanged(QBluetoothLocalDevice::HostMode)),
            this, SIGNAL(hostModeStateChanged()));
    connect(localDevice, SIGNAL(pairingFinished(QBluetoothAddress,QBluetoothLocalDevice::Pairing)),
            this, SLOT(pairingFinished(QBluetoothAddress,QBluetoothLocalDevice::Pairing)));
    connect(localDevice, SIGNAL(deviceConnected(QBluetoothAddress)),
            this, SLOT(connected(QBluetoothAddress)));
    connect(localDevice, SIGNAL(deviceDisconnected(QBluetoothAddress)),
            this, SLOT(disconnected(QBluetoothAddress)));
    connect(localDevice, SIGNAL(pairingDisplayConfirmation(QBluetoothAddress,QString)),
            this, SLOT(pairingDisplayConfirmation(QBluetoothAddress,QString)));

    if (localDevice->isValid()) {
        deviceAgent = new QBluetoothDeviceDiscoveryAgent(this);
        connect(deviceAgent, SIGNAL(deviceDiscovered(QBluetoothDeviceInfo)),
                this, SLOT(deviceDiscovered(QBluetoothDeviceInfo)));
        connect(deviceAgent, SIGNAL(finished()),
                this, SLOT(discoveryFinished()));
        connect(deviceAgent, SIGNAL(error(QBluetoothDeviceDiscoveryAgent::Error)),
                this, SLOT(discoveryError(QBluetoothDeviceDiscoveryAgent::Error)));
        connect(deviceAgent, SIGNAL(canceled()),
                this, SLOT(discoveryCanceled()));

        serviceAgent = new QBluetoothServiceDiscoveryAgent(this);
        connect(serviceAgent, SIGNAL(serviceDiscovered(QBluetoothServiceInfo)),
                this, SLOT(serviceDiscovered(QBluetoothServiceInfo)));
        connect(serviceAgent, SIGNAL(finished()),
                this, SLOT(serviceDiscoveryFinished()));
        connect(serviceAgent, SIGNAL(canceled()),
                this, SLOT(serviceDiscoveryCanceled()));
        connect(serviceAgent, SIGNAL(error(QBluetoothServiceDiscoveryAgent::Error)),
                this, SLOT(serviceDiscoveryError(QBluetoothServiceDiscoveryAgent::Error)));

        socket = new QBluetoothSocket(SOCKET_PROTOCOL, this);
        connect(socket, SIGNAL(stateChanged(QBluetoothSocket::SocketState)),
                this, SLOT(socketStateChanged(QBluetoothSocket::SocketState)));
        connect(socket, SIGNAL(error(QBluetoothSocket::SocketError)),
                this, SLOT(socketError(QBluetoothSocket::SocketError)));
        connect(socket, SIGNAL(connected()), this, SLOT(socketConnected()));
        connect(socket, SIGNAL(disconnected()), this, SLOT(socketDisconnected()));
        connect(socket, SIGNAL(readyRead()), this, SLOT(readData()));
        setSecFlags(socket->preferredSecurityFlags());

        server = new QBluetoothServer(SOCKET_PROTOCOL, this);
        connect(server, SIGNAL(newConnection()), this, SLOT(serverNewConnection()));
        connect(server, SIGNAL(error(QBluetoothServer::Error)),
                this, SLOT(serverError(QBluetoothServer::Error)));
    } else {
        deviceAgent = 0;
        serviceAgent = 0;
        socket = 0;
        server = 0;
    }
}
void ControllerWrapper::connectController()
{
#ifdef Q_OS_SYMBIAN
    //d_ptr->connectController();
    d_ptr->findAndConnect();
#elif defined(_SIMULATOR_STUB)
    emit deviceConnected(0);
#endif
}
Пример #10
0
void USBHALHost::UsbIrqhandler() {
    if( LPC_USB->HcInterruptStatus & LPC_USB->HcInterruptEnable ) //Is there something to actually process?
    {
        
        uint32_t int_status = LPC_USB->HcInterruptStatus & LPC_USB->HcInterruptEnable;

        // Root hub status change interrupt
        if (int_status & OR_INTR_STATUS_RHSC) { 
            if (LPC_USB->HcRhPortStatus1 & OR_RH_PORT_CSC) {
                if (LPC_USB->HcRhStatus & OR_RH_STATUS_DRWE) {
                    // When DRWE is on, Connect Status Change
                    // means a remote wakeup event.
                } else {

                    //Root device connected
                    if (LPC_USB->HcRhPortStatus1 & OR_RH_PORT_CCS) { 
                        
                        // wait 150ms to avoid bounce
                        wait_ms(150);
                        
                        //Hub 0 (root hub), Port 1 (count starts at 1), Low or High speed
                        deviceConnected(0, 1, LPC_USB->HcRhPortStatus1 & OR_RH_PORT_LSDA); 
                    } 
                    
                    //Root device disconnected
                    else { 
                        
                        if (!(int_status & OR_INTR_STATUS_WDH)) {
                            usb_hcca->DoneHead = 0;
                        }
                        
                        // wait 200ms to avoid bounce
                        wait_ms(200);
                        
                        deviceDisconnected(0, 1, NULL, usb_hcca->DoneHead & 0xFFFFFFFE);
                        
                        if (int_status & OR_INTR_STATUS_WDH) {
                            usb_hcca->DoneHead = 0;
                            LPC_USB->HcInterruptStatus = OR_INTR_STATUS_WDH;
                        }
                    }
                }
                LPC_USB->HcRhPortStatus1 = OR_RH_PORT_CSC;
            }
            if (LPC_USB->HcRhPortStatus1 & OR_RH_PORT_PRSC) {
                LPC_USB->HcRhPortStatus1 = OR_RH_PORT_PRSC;
            }
            LPC_USB->HcInterruptStatus = OR_INTR_STATUS_RHSC;
        }

        // Writeback Done Head interrupt
        if (int_status & OR_INTR_STATUS_WDH) {
            transferCompleted(usb_hcca->DoneHead & 0xFFFFFFFE);
            LPC_USB->HcInterruptStatus = OR_INTR_STATUS_WDH;
        }
    }
}
Пример #11
0
void EkosManager::processLocalDevice(ISD::GDInterface *devInterface)
{
    DriverInfo *di = devInterface->getDriverInfo();

            switch (di->getType())
            {
               case KSTARS_TELESCOPE:
                scope = devInterface;
                break;


               case KSTARS_CCD:
                if (guider_di == di)
                {
                    guider = devInterface;
                    guiderName = devInterface->getDeviceName();
                }
                else
                    ccd = devInterface;
                break;

            case KSTARS_FOCUSER:
                focuser = devInterface;
                break;

             case KSTARS_FILTER:
                if (filter_di == di)
                    filter = devInterface;
                if (useFilterFromCCD)
                    ccd = devInterface;
                break;

             case KSTARS_AUXILIARY:
                if (aux_di == di)
                    aux = devInterface;
                    break;

              default:
                return;
                break;
            }

     nDevices--;

    connect(devInterface, SIGNAL(Connected()), this, SLOT(deviceConnected()));
    connect(devInterface, SIGNAL(Disconnected()), this, SLOT(deviceDisconnected()));
    connect(devInterface, SIGNAL(propertyDefined(INDI::Property*)), this, SLOT(processNewProperty(INDI::Property*)));

    if (nDevices == 0)
    {
        connectB->setEnabled(true);
        disconnectB->setEnabled(false);
        controlPanelB->setEnabled(true);
    }

}
Пример #12
0
 inline bool _insertToken(std::unique_ptr<DeviceToken>&& token) {
   if (DeviceSignature::DeviceMatchToken(*token, m_types)) {
     m_tokensLock.lock();
     TInsertedDeviceToken inseredTok = m_tokens.insert(std::make_pair(token->getDevicePath(), std::move(token)));
     m_tokensLock.unlock();
     deviceConnected(*inseredTok.first->second);
     return true;
   }
   return false;
 }
Пример #13
0
void LocalStorage::init()
{
    setName(i18n("Local Storage"));

    LocalStorageDevice *device = new LocalStorageDevice(this);

    addDevice(device);
    connectDevice(device);
    emit deviceConnected(device);
}
Пример #14
0
int TestMonitor::onStartTest()
{
    srand(time(0));

    DeviceAgent *deviceSock = new DeviceAgent(this);
    deviceSock->m_devID = QString("test123%1").arg(rand());
    emit deviceConnected(deviceSock);
    
    return PL_RET_OK;
    
}
Пример #15
0
void CANCom::timerTimeout() {
  try {
    if (!mDevice.getConnection().isOpen())
      mDevice.getConnection().open();
    std::shared_ptr<PRIUSMessage> message = mDevice.readMessage();
    emit readMessage(message);
    emit deviceConnected(true);
  }
  catch (IOException& e) {
    emit comException(e.what());
  }
}
Пример #16
0
WaterTowerWidget::WaterTowerWidget(int id, QWidget *parent) :
    QGroupBox(parent),
    ui(new Ui::WaterTowerWidget),
    uuid(NotifyPanel::instance()->uuid())
{
    ui->setupUi(this);

    setTitle(readableName(id));
    waterTower = WaterTower::instance(id);
    connect(waterTower, SIGNAL(waterLevelChanged(int)), this, SLOT(waterLevelChanged(int)));
    connect(waterTower, SIGNAL(deviceConnected()), this, SLOT(deviceConnect()));
    connect(waterTower, SIGNAL(deviceDisconnected()), this, SLOT(deviceDisconnect()));
    connect(waterTower, SIGNAL(highWaterLevelAlarm()), this, SLOT(highWaterLevelAlarm()));

    waterTower->getWaterLevel();
    ui->avatarWidget->setAvatar(QPixmap(QString(qApp->applicationDirPath() + "/images/watertower-%1.png").arg(id)));
    ui->progressBar->setRange(0, waterTower->getHeight());
    ui->progressBar->setFormat("%v");
    deviceDisconnect();
    connect(waterTower, SIGNAL(waterLevelRangeChanged(int,int)), ui->progressBar, SLOT(setRange(int,int)));

    enableWidget = new QCheckBox();
    enableWidget->setChecked(waterTower->isEnabled());

    enableAlarmWidget = new QCheckBox();
    enableAlarmWidget->setChecked(waterTower->isAlarmEnabled());

    addressWidget = new QSpinBox();
    addressWidget->setRange(0, 15);
    addressWidget->setValue(waterTower->getAddress());
    connect(addressWidget, SIGNAL(valueChanged(int)), this, SLOT(addressChanged(int)));

    radiusWidget = new QSpinBox();
    radiusWidget->setRange(20, 300);
    radiusWidget->setValue(waterTower->getRadius());
    connect(radiusWidget, SIGNAL(valueChanged(int)), this, SLOT(radiusChanged(int)));

    levelSensorHeightWidget = new QSpinBox();
    levelSensorHeightWidget->setRange(20, 100);
    levelSensorHeightWidget->setValue(waterTower->getLevelSensorHeight());
    connect(levelSensorHeightWidget, SIGNAL(valueChanged(int)), this, SLOT(levelSensorHeightChanged(int)));

    levelSensorNumberWidget = new QSpinBox();
    levelSensorNumberWidget->setRange(1, 8);
    levelSensorNumberWidget->setValue(waterTower->getSensorNumber());
    connect(levelSensorNumberWidget, SIGNAL(valueChanged(int)), this, SLOT(levelSensorNumberChanged(int)));

    getSampleIntervalWidget();
    connect(sampleIntervalWidget, SIGNAL(valueChanged(int)), this, SLOT(sampleIntervalChanged(int)));
    connect(enableWidget, SIGNAL(clicked(bool)), this, SLOT(readyForUse(bool)));
    connect(enableAlarmWidget, SIGNAL(clicked(bool)), this, SLOT(enableAlarm(bool)));
}
Пример #17
0
 void register_uri(std::string uri) {
   OniDeviceInfo info;
   strncpy(info.uri, uri.c_str(), ONI_MAX_STR);
   strncpy(info.vendor, "Microsoft", ONI_MAX_STR);
   //strncpy(info.name, "Kinect 2", ONI_MAX_STR); // XXX, NiTE does not accept new name
   strncpy(info.name, "Kinect", ONI_MAX_STR);
   if (devices.find(info) == devices.end()) {
     WriteMessage("Driver: register new uri: " + uri);
     devices[info] = NULL;
     deviceConnected(&info);
     deviceStateChanged(&info, 0);
   }
 }
Пример #18
0
void TCPCom::writePacket(std::shared_ptr<Packet> packet) {
  try {
    mDevice.writePacket(packet);
  }
  catch (IOException& e) {
    emit comException(e.what());
    emit deviceConnected(false);
  }
  catch (SystemException& e) {
    emit comException(e.what());
    emit deviceConnected(false);
  }
  try {
    emit readPacket(mDevice.readPacket());
  }
  catch (IOException& e) {
  }
  catch (SystemException& e) {
    emit comException(e.what());
    emit deviceConnected(false);
  }
}
Пример #19
0
void Device::scanServices(const QString &address)
{
    // We need the current device for service discovery.
    for (int i = 0; i < devices.size(); i++) {
        if (((DeviceInfo*)devices.at(i))->getAddress() == address )
            currentDevice.setDevice(((DeviceInfo*)devices.at(i))->getDevice());
    }

    if (!currentDevice.getDevice().isValid()) {
        qWarning() << "Not a valid device";
        return;
    }

    qDeleteAll(m_characteristics);
    m_characteristics.clear();
    emit characteristicsUpdated();
    qDeleteAll(m_services);
    m_services.clear();
    emit servicesUpdated();

    setUpdate("Back\n(Connecting to device...)");

    if (controller && controller->remoteAddress() != currentDevice.getDevice().address()) {
        controller->disconnectFromDevice();
        delete controller;
        controller = 0;
    }

    //! [les-controller-1]
    if (!controller) {
        // Connecting signals and slots for connecting to LE services.
        controller = new QLowEnergyController(currentDevice.getDevice().address());
        connect(controller, SIGNAL(connected()),
                this, SLOT(deviceConnected()));
        connect(controller, SIGNAL(error(QLowEnergyController::Error)),
                this, SLOT(errorReceived(QLowEnergyController::Error)));
        connect(controller, SIGNAL(disconnected()),
                this, SLOT(deviceDisconnected()));
        connect(controller, SIGNAL(serviceDiscovered(QBluetoothUuid)),
                this, SLOT(addLowEnergyService(QBluetoothUuid)));
        connect(controller, SIGNAL(discoveryFinished()),
                this, SLOT(serviceScanDone()));
    }

    if (isRandomAddress())
        controller->setRemoteAddressType(QLowEnergyController::RandomAddress);
    else
        controller->setRemoteAddressType(QLowEnergyController::PublicAddress);
    controller->connectToDevice();
    //! [les-controller-1]
}
Пример #20
0
void MonitorThread::run()
{
    m_monitor = new DeviceMonitor(NULL);

    connect(m_monitor, SIGNAL(deviceDisconnected(QString)), parent(), SLOT(onDeviceDisconnected(QString)),Qt::QueuedConnection);
    connect(m_monitor, SIGNAL(deviceConnected(QString)), parent(), SLOT(onDeviceConnected(QString)),Qt::QueuedConnection);
    connect(m_monitor, SIGNAL(busyMessage(QString)), parent(), SLOT(onBusyMessage(QString)),Qt::QueuedConnection);
    connect(m_monitor, SIGNAL(errorMessage(QString,QString)), parent(), SLOT(onShowErrorInfo(QString,QString)),Qt::QueuedConnection);

    connect(this, SIGNAL(monitorCreated(DeviceMonitor *)), parent(), SLOT(onMonitorCreated(DeviceMonitor*)),Qt::QueuedConnection);
    emit monitorCreated(m_monitor);
    m_monitor->start();
    exec();
}
Пример #21
0
/**
*   Method called when the user clicks the "Connect" button
*/
bool ConnectionManager::connectDevice()
{
	devListItem connection_device = findDevice(m_availableDevList->currentText());
	if (!connection_device.connection)
		return false;

	QIODevice *io_dev = connection_device.connection->openDevice(connection_device.devName);
	if (!io_dev)
		return false;

	io_dev->open(QIODevice::ReadWrite);

	// check if opening the device worked
	if (!io_dev->isOpen())
	{
		qDebug() << "Error: io_dev->isOpen() returned FALSE .. could not open connection too " << connection_device.devName;

		// close the device
		try
		{
			connection_device.connection->closeDevice(connection_device.devName);
		}
		catch (...)
		{	// handle exception
			qDebug() << "Exception: connection_device.connection->closeDevice(" << connection_device.devName << ")";
		}

		return false;
	}

	// we appear to have connected to the device OK

	// remember the connection/device details
	m_connectionDevice = connection_device;
	m_ioDev = io_dev;

//	connect(m_connectionDevice.connection, SIGNAL(deviceClosed(QObject *)), this, SLOT(onConnectionClosed(QObject *)));
	connect(m_connectionDevice.connection, SIGNAL(destroyed(QObject *)), this, SLOT(onConnectionDestroyed(QObject *)), Qt::QueuedConnection);

	m_connectBtn->setText("Disconnect");
	m_availableDevList->setEnabled(false);

	// signal interested plugins that we connected to the device
	emit deviceConnected(m_ioDev);

	return true;
}
Пример #22
0
/**
*   Method called when the user clicks the "Connect" button
*/
bool ConnectionManager::connectDevice(DevListItem device)
{
    if (!device.connection) {
        emit connectDeviceFailed(&device);
        return false;
    }

    QIODevice *io_dev = device.connection->openDevice(device.device);
    if (!io_dev) {
        emit connectDeviceFailed(&device);
        return false;
    }

    io_dev->open(QIODevice::ReadWrite);

    // check if opening the device worked
    if (!io_dev->isOpen()) {
        emit connectDeviceFailed(&device);
        return false;
    }

    // The device is connected make it the one selected on the dropbox
    for(int x = 0; x < m_availableDevList->count(); ++x)
    {
        if(device.getConName() == m_availableDevList->itemData(x,Qt::ToolTipRole).toString())
            m_availableDevList->setCurrentIndex(x);
    }
    // we appear to have connected to the device OK
    // remember the connection/device details
    m_connectionDevice = device;
    m_ioDev = io_dev;

    connect(m_connectionDevice.connection, SIGNAL(destroyed(QObject *)), this, SLOT(onConnectionDestroyed(QObject *)), Qt::QueuedConnection);

    // signal interested plugins that we connected to the device
    emit deviceConnected(io_dev);
    m_connectBtn->setText("Disconnect");
    m_availableDevList->setEnabled(false);

    // tell the monitorwidget we're conneced
    m_monitorWidget->connected();

    return true;
}
Пример #23
0
 OniStatus initialize(oni::driver::DeviceConnectedCallback connectedCallback, oni::driver::DeviceDisconnectedCallback disconnectedCallback, oni::driver::DeviceStateChangedCallback deviceStateChangedCallback, void* pCookie)
 {
   DriverBase::initialize(connectedCallback, disconnectedCallback, deviceStateChangedCallback, pCookie);
   for (int i = 0; i < Freenect::deviceCount(); i++)
   {
     std::string uri = "freenect://" + to_string(i);
     
     WriteMessage("Found device " + uri);
     
     OniDeviceInfo info;
     strncpy(info.uri, uri.c_str(), ONI_MAX_STR);
     strncpy(info.vendor, "Microsoft", ONI_MAX_STR);
     strncpy(info.name, "Kinect", ONI_MAX_STR);
     devices[info] = NULL;
     deviceConnected(&info);
     deviceStateChanged(&info, 0);
   }
   return ONI_STATUS_OK;
 }
Пример #24
0
	virtual OniStatus tryDevice(const char* uri)
	{
		if (xnOSStrCmp(uri, "Dummy") != 0 &&
			xnOSStrCmp(uri, "Oz") != 0 &&
			xnOSStrCmp(uri, "PingPong") != 0)
		{
			return ONI_STATUS_ERROR;
		}


		OniDeviceInfo* pInfo = XN_NEW(OniDeviceInfo);
		xnOSStrCopy(pInfo->uri, uri, ONI_MAX_STR);
		xnOSStrCopy(pInfo->vendor, "Table Tennis", ONI_MAX_STR);
		m_devices[pInfo] = NULL;

		deviceConnected(pInfo);

		return ONI_STATUS_OK;
	}
	// Initialize the driver
	// ドライバを初期化する
	virtual OniStatus initialize(
		oni::driver::DeviceConnectedCallback connectedCallback,
		oni::driver::DeviceDisconnectedCallback disconnectedCallback,
		oni::driver::DeviceStateChangedCallback deviceStateChangedCallback,
		void* pCookie)
	{
		oni::driver::DriverBase::initialize(connectedCallback, disconnectedCallback, deviceStateChangedCallback, pCookie);

		// Connect to the DepthSense device
		// DepthSense デバイスに接続する
		m_context = DepthSense::Context::create("localhost");

		// Enumerate the connected devices
		// 接続されているデバイスの情報を作成する
		m_depthSenseDevices = m_context.getDevices();
		int deviceIndex = 0;
		for ( auto it = m_depthSenseDevices.begin(); it != m_depthSenseDevices.end(); ++it ) {
			// Populate the device information
			// デバイス情報をコピーする
			OniDeviceInfo* pInfo = XN_NEW(OniDeviceInfo);
			xnOSStrCopy(pInfo->vendor, "DepthSense", ONI_MAX_STR);
			xnOSStrCopy(pInfo->name, DepthSense::Device::Model_toString( it->getModel() ).c_str(), ONI_MAX_STR);

			XnUInt32 uriLen;
			xnOSStrFormat(pInfo->uri, ONI_MAX_STR, &uriLen, "%s/%d", pInfo->name, deviceIndex++);

			// Register the device information with the map
			// デバイス情報を登録する
			m_devices[pInfo] = NULL;

			// Raise events
			// デバイスの接続を通知する
			deviceConnected(pInfo);
			deviceStateChanged(pInfo, 0);
		}

		// Create the thread for main loop
		// デバイスのメインループ用スレッドを生成する
		xnOSCreateThread(threadFunc, this, &m_threadHandle);

		return ONI_STATUS_OK;
	}
Пример #26
0
void EkosManager::processRemoteDevice(ISD::GDInterface *devInterface)
{
    if (!strcmp(devInterface->getDeviceName(), Options::remoteScopeName().toLatin1()))
        scope = devInterface;
    else if (!strcmp(devInterface->getDeviceName(), Options::remoteCCDName().toLatin1()))
    {
        ccd = devInterface;

        if (useGuiderFromCCD)
            guider = ccd;
    }
    else if (!strcmp(devInterface->getDeviceName(), Options::remoteGuiderName().toLatin1()))
    {
        guider = devInterface;
        guiderName = devInterface->getDeviceName();
    }
    else if (!strcmp(devInterface->getDeviceName(), Options::remoteFocuserName().toLatin1()))
        focuser = devInterface;
    else if (!strcmp(devInterface->getDeviceName(), Options::remoteFilterName().toLatin1()))
        filter = devInterface;
    else if (!strcmp(devInterface->getDeviceName(), Options::remoteAuxName().toLatin1()))
        aux = devInterface;
    else
        return;

    nDevices--;
    connect(devInterface, SIGNAL(Connected()), this, SLOT(deviceConnected()));
    connect(devInterface, SIGNAL(Disconnected()), this, SLOT(deviceDisconnected()));
    connect(devInterface, SIGNAL(propertyDefined(INDI::Property*)), this, SLOT(processNewProperty(INDI::Property*)));


    if (nDevices == 0)
    {
        connectB->setEnabled(true);
        disconnectB->setEnabled(false);
        controlPanelB->setEnabled(true);

        appendLogText(i18n("Remote devices established. Please connect devices."));
    }

}
Пример #27
0
MountButton::MountButton(QWidget * parent, RazorPanel *panel) :
    QToolButton(parent),
    mPopup(this),
    m_panel(panel),
    mDevAction(DevActionInfo),
    mPopupHideDelay(5000)
{
    if (!QDBusConnection::systemBus().isConnected())
    {
        qWarning() << "Can't connect to dbus daemon. Some functions will be omited";
    }

    setIcon(XdgIcon::fromTheme(QStringList() << "device-notifier" << "drive-removable-media-usb"));
    setToolTip(tr("Removable media/devices manager"));

    initialScanDevices();

    QDBusConnection conn = QDBusConnection::systemBus();
    // TODO: Check for connection, timer for reconect
    /*bool connected =*/ conn.connect("org.freedesktop.UDisks",
                                  "/org/freedesktop/UDisks",
                                  "org.freedesktop.UDisks",
                                  "DeviceChanged",
                                  this,
                                  SLOT(onDbusDeviceChangesMessage(QDBusObjectPath)));


    connect(&mPopup, SIGNAL(visibilityChanged(bool)), this, SLOT(setDown(bool)));

    connect(m_panel, SIGNAL(positionChanged()), &mPopup, SLOT(hide()));

    connect(this, SIGNAL(clicked()), this, SLOT(showHidePopup()));

    connect(&_dm, SIGNAL(deviceConnected(DiskInfo)),
            this, SLOT(onDiskAdded(DiskInfo)));

    connect(&_dm, SIGNAL(deviceDisconnected(DiskInfo)),
            this, SLOT(onDiskRemoved(DiskInfo)));

    _dm.start();
}
Пример #28
0
void MainWidget::createTrayIcon()
{    
    trayIcon = createTrayObject(this);
    trayIcon->init();

#ifndef Q_OS_WIN32
    trayIcon->setIcon("qcma_off");
#else
    trayIcon->setIcon("tray/qcma_off_16");
#endif
    trayIcon->show();

    connect(trayIcon, SIGNAL(openConfig()), this, SLOT(openConfig()));
    connect(trayIcon, SIGNAL(openManager()), this, SLOT(openManager()));
    connect(trayIcon, SIGNAL(refreshDatabase()), this, SLOT(refreshDatabase()));
    connect(trayIcon, SIGNAL(showAboutDialog()), this, SLOT(showAboutDialog()));
    connect(trayIcon, SIGNAL(showAboutQt()), this, SLOT(showAboutQt()));
    connect(trayIcon, SIGNAL(stopServer()), this, SLOT(stopServer()));

    connect(managerForm, SIGNAL(deviceConnected(QString)), this, SLOT(deviceConnect(QString)));
    connect(managerForm, SIGNAL(deviceDisconnected()), this, SLOT(deviceDisconnect()));
    connect(managerForm, SIGNAL(messageSent(QString)), this, SLOT(receiveMessage(QString)));
}
Пример #29
0
void MultiPointCom::run()
{
    mutex.lock();

    QTime timeout = lastConnectTime.addSecs(30);

    if (timeout < QTime::currentTime()) {
        qDebug() << "Device connected timeout" << disconnectCount++;
        lastConnectTime = QTime::currentTime();
#ifdef __arm__
        ioctl(device, SI4432_IOC_RESET, 1);
#endif
    }

#ifdef __arm__
    si4432_ioc_transfer tr;
    char txBuf[64], rxBuf[64];
    memcpy(txBuf, request.data(), request.size());
    memset(&tr, 0, sizeof(si4432_ioc_transfer));
    tr.tx_buf = (__u64)txBuf;
    tr.rx_buf = (__u64)rxBuf;
    tr.len = request.size();
    int len = ioctl(device, SI4432_IOC_MESSAGE(1), &tr);
    if (len > 0) {
        response.clear();
        response.append(rxBuf, len);
        quint8 addr = response.at(0);
        if (addr == address) {
            lastConnectTime = QTime::currentTime();
            disconnect = 0;
            emit deviceConnected();
            emit responseReceived(response.at(1), QByteArray(response.data() + 2, len - 2));
        }
    } else {
        disconnect++;
        if (disconnect > 3) {
            disconnect = 0;
            emit deviceDisconnected();
        }
    }
#else
    QUdpSocket *udp = new QUdpSocket();
    udp->writeDatagram(request, QHostAddress::LocalHost, 19999);

    if (udp->waitForReadyRead(100) && (udp->pendingDatagramSize() > 0)) {
        response.resize(udp->pendingDatagramSize());
        udp->readDatagram(response.data(), response.size());
        quint8 addr = response.at(0);
        if (addr == address) {
            lastConnectTime = QTime::currentTime();
            disconnect = 0;
            emit deviceConnected();
            emit responseReceived(response.at(1), response.mid(2));
        }
    } else {
        disconnect++;
        if (disconnect > 3) {
            disconnect = 0;
            emit deviceDisconnected();
        }
    }
    delete udp;
#endif

    mutex.unlock();
}
Пример #30
0
void USBHALHost::init() {
    NVIC_DisableIRQ(USB_IRQn);
    
    //Cut power
    LPC_SC->PCONP &= ~(1UL<<31);
    wait_ms(100);

    // turn on power for USB
    LPC_SC->PCONP       |= (1UL<<31);

    // Enable USB host clock, port selection and AHB clock
    LPC_USB->USBClkCtrl |= CLOCK_MASK;

    // Wait for clocks to become available
    while ((LPC_USB->USBClkSt & CLOCK_MASK) != CLOCK_MASK);

    // it seems the bits[0:1] mean the following
    // 0: U1=device, U2=host
    // 1: U1=host, U2=host
    // 2: reserved
    // 3: U1=host, U2=device
    // NB: this register is only available if OTG clock (aka "port select") is enabled!!
    // since we don't care about port 2, set just bit 0 to 1 (U1=host)
    LPC_USB->OTGStCtrl |= 1;

    // now that we've configured the ports, we can turn off the portsel clock
    LPC_USB->USBClkCtrl &= ~PORTSEL_CLK_EN;

    // configure USB D+/D- pins
    // P0[29] = USB_D+, 01
    // P0[30] = USB_D-, 01
    LPC_PINCON->PINSEL1 &= ~((3<<26) | (3<<28));
    LPC_PINCON->PINSEL1 |=  ((1<<26) | (1<<28));

    LPC_USB->HcControl       = 0; // HARDWARE RESET
    LPC_USB->HcControlHeadED = 0; // Initialize Control list head to Zero
    LPC_USB->HcBulkHeadED    = 0; // Initialize Bulk list head to Zero

    // Wait 100 ms before apply reset
    wait_ms(100);

    // software reset
    LPC_USB->HcCommandStatus = OR_CMD_STATUS_HCR;
    
    // Write Fm Interval and Largest Data Packet Counter
    LPC_USB->HcFmInterval    = DEFAULT_FMINTERVAL;
    LPC_USB->HcPeriodicStart = FI * 90 / 100;

    // Put HC in operational state
    LPC_USB->HcControl  = (LPC_USB->HcControl & (~OR_CONTROL_HCFS)) | OR_CONTROL_HC_OPER;
    // Set Global Power
    LPC_USB->HcRhStatus = OR_RH_STATUS_LPSC;

    LPC_USB->HcHCCA = (uint32_t)(usb_hcca);
    
    // Clear Interrrupt Status
    LPC_USB->HcInterruptStatus |= LPC_USB->HcInterruptStatus;

    LPC_USB->HcInterruptEnable  = OR_INTR_ENABLE_MIE | OR_INTR_ENABLE_WDH | OR_INTR_ENABLE_RHSC;

    // Enable the USB Interrupt
    NVIC_SetVector(USB_IRQn, (uint32_t)(_usbisr));
    LPC_USB->HcRhPortStatus1 = OR_RH_PORT_CSC;
    LPC_USB->HcRhPortStatus1 = OR_RH_PORT_PRSC;

    NVIC_EnableIRQ(USB_IRQn);

    // Check for any connected devices
    if (LPC_USB->HcRhPortStatus1 & OR_RH_PORT_CCS) {
        //Device connected
        wait_ms(150);
        USB_DBG("Device connected (%08x)\n\r", LPC_USB->HcRhPortStatus1);
        deviceConnected(0, 1, LPC_USB->HcRhPortStatus1 & OR_RH_PORT_LSDA);
    }
}