예제 #1
0
void EventHandler::customEvent(QEvent *e) {
  if (e->type() == 10001) {    

    // Forward the event to the next in the chain
    forwardEvent(e);

    MClientEvent* me = static_cast<MClientEvent*>(e);

    if(me->dataTypes().contains("SendToSocketData")) {
      QByteArray ba = me->payload()->toByteArray();
      sendData(ba);
      
    } else if (me->dataTypes().contains("ConnectToHost")) {
      connectDevice(me->payload()->toString());
      
    } else if (me->dataTypes().contains("DisconnectFromHost")) {
      //QString arg = me->payload()->toString();
      disconnectDevice();
      
    } else if (me->dataTypes().contains("MUMEPromptGARequest")) {
      //do not allow server to suppress go-aheads (MUME is backwards)
      sendMUMEGARequest();
      
    } else if (me->dataTypes().contains("DoneLoading")) {
      // auto connect on session start
      if (_autoConnect) connectDevice();

    }

    
  }
  else 
    qDebug() << "SocketManagerIO got a customEvent of type" << e->type();
}
        virtual void initializeTransportAdapters()
        {
            // Preparing custom device adapter
            mpTransportAdapter = new MockTransportAdapter(*this, *this);

            EXPECT_CALL(*mpTransportAdapter, run()).Times(1);
            EXPECT_CALL(*mpTransportAdapter, scanForNewDevices())
                .Times(1)
                .WillOnce(Invoke(mpTransportAdapter, &MockTransportAdapter::doScanForNewDevices))
            ;

            EXPECT_CALL(*mpTransportAdapter, connectDevice(Data::DeviceHandle))
                .Times(1)
                .WillOnce(Invoke(mpTransportAdapter, &MockTransportAdapter::doConnectDevice))
            ;

            EXPECT_CALL(*mpTransportAdapter, sendFrame(Data::ConnectionHandle, _, 512, Data::UserData))
                .Times(1)
                .WillOnce(Invoke(mpTransportAdapter, &MockTransportAdapter::doSendFrame))
            ;

            EXPECT_CALL(*mpTransportAdapter, disconnectDevice(Data::DeviceHandle))
                .Times(1)
                .WillOnce(Invoke(mpTransportAdapter, &MockTransportAdapter::doDisconnectDevice))
            ;

            addTransportAdapter(mpTransportAdapter);
            LOG4CPLUS_INFO_EXT(mLogger, "Transport adapters initialized");
        }
예제 #3
0
void ScopeINDI::serverConnected()
{
    // After connection to the server
    // set option to receive only the messages, no blob
    setBLOBMode(B_NEVER, INDIMountName.mb_str(wxConvUTF8), NULL);
    modal = true; 
    // wait for the device port property
    wxLongLong msec;
    msec = wxGetUTCTimeMillis();
    while ((!scope_port) && wxGetUTCTimeMillis() - msec < 2 * 1000) {
	::wxSafeYield();
    }
    // Set the port, this must be done before to try to connect the device
    if (scope_port && INDIMountPort.Length()) {  // the mount port is not mandatory
	char* porttext = (const_cast<char*>((const char*)INDIMountPort.mb_str()));
	scope_port->tp->text = porttext;
	sendNewText(scope_port); 
    }
    // Connect the mount device
    connectDevice(INDIMountName.mb_str(wxConvUTF8));
    
    msec = wxGetUTCTimeMillis();
    while (modal && wxGetUTCTimeMillis() - msec < 5 * 1000) {
	::wxSafeYield();
    }
    modal = false;
    // In case we not get all the required properties or connection to the device failed
    if( ready) {
       Scope::Connect();
    }
    else {
       Disconnect();
    }
}
예제 #4
0
int KMobileGnokii::numAddresses()
{
  if (!connectDevice(NULL))
	return 0;

  gn_memory_status memstat;
  gn_error error;

  if (m_numAddresses>=0)
	return m_numAddresses;

  error = read_phone_memstat( GN_MT_ME, &memstat );
  GNOKII_CHECK_ERROR(error);
  if (error)
	memstat.used = -1;

  m_numAddresses = memstat.used;

  if (m_numAddresses>0) {
	// initialize the addrList array
	m_addrList.clear();
	KABC::Addressee addr;
	for (int i=0; i<=m_numAddresses; i++)
		m_addrList.append(addr);
  }

  return m_numAddresses;
}  
예제 #5
0
main() {
    connectDevice();
    printf("Connected\n");
//    queryData();
    benchmark();
    disconnectDevice();
    printf("Disconnected\n");
}
예제 #6
0
void NTFCDevice::connectDevice()
{
    if (this->connected)
        return;

    this->socket->connectToHost(this->address, this->port);

    QTimer::singleShot(5000, this, SLOT(connectDevice()));
}
예제 #7
0
void NTFCDevice::setDisconnected()
{
    this->connected = false;
    this->command = NTFCDevice::CONNECTIONSTATE;

    sendNotification();

    QTimer::singleShot(5000, this, SLOT(connectDevice()));
}
예제 #8
0
void InputDevice::connectSession ( int sessionid ) {
    // Cannot connect session: no device for this object known
    if ( !m_device )
        return;

    m_sessionids.insert ( sessionid );
    if ( !fd ) {
        connectDevice();
    }
}
예제 #9
0
HRESULT KTM::KinectWrapper::streamFromKinect(){
	HRESULT hr;

	streamingFromFile = false;
	inFile.close();

	hr = connectDevice();

	return hr;
}
예제 #10
0
void LocalStorage::init()
{
    setName(i18n("Local Storage"));

    LocalStorageDevice *device = new LocalStorageDevice(this);

    addDevice(device);
    connectDevice(device);
    emit deviceConnected(device);
}
예제 #11
0
/**
*   Slot called when the user pressed the connect/disconnect button
*/
void ConnectionManager::onConnectPressed()
{
	if (!m_ioDev || !m_connectionDevice.connection)
	{	// connecting
		connectDevice();
    }
    else
	{	// disconnecting
		disconnectDevice();
    }
}
예제 #12
0
/**
*   Slot called when the user pressed the connect/disconnect button
*/
void ConnectionManager::onConnectPressed()
{
    // Check if we have a ioDev already created:
    if (!m_ioDev)
    {	// connecting
        connectDevice();
    }
    else
    {	// disconnecting
        disconnectDevice();
    }
}
예제 #13
0
/**
*   Slot called when the user clicks the connect/disconnect button
*/
void ConnectionManager::onConnectClicked()
{
    // Check if we have a ioDev already created:
    if (!m_ioDev)
    {
        // connecting to currently selected device
        DevListItem device = findDevice(m_availableDevList->itemData(m_availableDevList->currentIndex(), Qt::ToolTipRole).toString());
        if (device.connection)
            connectDevice(device);
    }
    else
    {	// disconnecting
        disconnectDevice();
    }
}
예제 #14
0
// Menu
const MenuData& EventHandler::createMenus() {
  QAction *connectAct = new QAction(tr("&Connect"), 0);
  connectAct->setStatusTip(tr("Connect to the remote host"));
  connect(connectAct, SIGNAL(triggered()), SLOT(connectDevice()) );
  
  QAction *disconnectAct = new QAction(tr("&Disconnect"), 0);
  disconnectAct->setStatusTip(tr("Disconnect from the host"));
  connect(disconnectAct, SIGNAL(triggered()), SLOT(disconnectDevice()) );

  SmartMenu *fileMenu = new SmartMenu(tr("&File"), 0, 0);
  fileMenu->addAction(connectAct);
  fileMenu->addAction(disconnectAct);

  _menus.insert(fileMenu);

  return _menus;
}
예제 #15
0
void PLabBTLEController::connectDevice(const PLabBTLEDevice &device)
{
	if (!isReady() || connected || role != CENTRAL || workImmediately || (device.id < 0 && device.address == 0)) return;
	if (device.address != 0)
	{
		connectDevice(device.address);
	}
	else
	{
		state = CONNECT_RUNNING;
		commandIssued = millis();
		replyStarted = false;
		print("AT+CONN");
		print(device.id);
		engine.prefix = statePrefixes[statePrefixIndex[state]];
	}
}
예제 #16
0
PacketChunker::PacketChunker(unsigned port, unsigned nAntennas, unsigned nSubbands, 
                             unsigned nSpectra, unsigned packetsPerHeap)
        : _port(port), _nsamp(nSpectra), _nchans(nSubbands), _npackets(packetsPerHeap), _nantennas(nAntennas)
{   
    // Set configuration options
    _startTime = _startBlockid = 0;
    _heapSize  = nAntennas * nSubbands * nSpectra * sizeof(char);

    // Initialise chunker
    connectDevice();

    // Set thread affinity
    pthread_t thread = pthread_self();
    cpu_set_t cpuset;
    CPU_ZERO(&cpuset);
    CPU_SET(0, &cpuset);

    if ((pthread_setaffinity_np(thread, sizeof(cpu_set_t), &cpuset)) != 0)
        perror("Cannot set pthread affinity");
}
예제 #17
0
int BTConnection::connect()
{
    FUNCTION_CALL_TRACE;

    if( iFd != -1 ) {
        LOG_DEBUG( "Using existing connection" );
        return iFd;
    }

    iDevice = connectDevice( iBTAddress, iServiceUUID );

    if( iDevice.isEmpty() ) {
        LOG_CRITICAL("Could not connect to device" << iBTAddress << ", aborting" );
        return -1;
    }

    // HACK: In Sailfish, sometimes, opening the device
    // immediately after the bluetooth connect fails and works only
    // if some delay is introduced.
    // Since a plugin runs in a separate thread/process (incase of oop)
    // it is okay to introduce some delay before the open. We will use
    // a retry count of 3 to open the connection and finally giveup
    // otherwise
    int retryCount = 3;
    do {
        iFd = open( iDevice.toLatin1().constData(), O_RDWR | O_NOCTTY | O_SYNC );
        if (iFd > 0) break;
        QThread::msleep (100); // Sleep for 100msec before trying again
    } while ((--retryCount > 0) && (iFd == -1));

    if( iFd == -1 ) {
        LOG_CRITICAL( "Could not open file descriptor of the connection, aborting" );
        disconnectDevice( iBTAddress, iDevice );
        return -1;
    }

    fdRawMode( iFd );

    return iFd;
}
예제 #18
0
파일: cam_INDI.cpp 프로젝트: xeqtr1982/phd2
void Camera_INDIClass::serverConnected()
{
    // After connection to the server
    // set option to receive blob and messages for the selected CCD
    setBLOBMode(B_ALSO, INDICameraName.mb_str(wxConvUTF8), INDICameraBlobName.mb_str(wxConvUTF8));
    modal = true;
    // wait for the device port property
    wxLongLong msec;
    msec = wxGetUTCTimeMillis();
    while ((!camera_port) && wxGetUTCTimeMillis() - msec < 1 * 1000) {
        ::wxSafeYield();
    }
    // Set the port, this must be done before to try to connect the device
    if (camera_port && INDICameraPort.Length()) {  // the camera port is not mandatory
        char* porttext = (const_cast<char*>((const char*)INDICameraPort.mb_str()));
        camera_port->tp->text = porttext;
        sendNewText(camera_port);
    }
    // Connect the camera device
    connectDevice(INDICameraName.mb_str(wxConvUTF8));

    msec = wxGetUTCTimeMillis();
    while (modal && wxGetUTCTimeMillis() - msec < 5 * 1000) {
        ::wxSafeYield();
    }
    modal = false;
    // In case we not get all the required properties or connection to the device failed
    if(ready)
    {
        Connected = true;
        m_hasGuideOutput = (pulseGuideNS_prop && pulseGuideEW_prop);
    }
    else {
        pFrame->Alert(_("Cannot connect to camera ")+INDICameraName);
        Connected = false;
        Disconnect();
    }
}
void QFESPIMB040SimpleCameraConfig::disConnectAcquisitionDevice() {
    if (cmbAcquisitionDevice->currentIndex()<0) {
        // if there are no devices registered: deactivate everything!
        displayStates(QFESPIMB040SimpleCameraConfig::Disconnected);
        return;
    }

    QFExtension* extension=cmbAcquisitionDevice->currentExtension();
    QFExtensionCamera* cam=cmbAcquisitionDevice->currentExtensionCamera();
    int camIdx=cmbAcquisitionDevice->currentCameraID();

    //std::cout<<"disConnectAcquisitionDevice()  dev="<<p.x()<<" cam="<<p.y()<<"  cam*="<<cam<<" extension*="<<extension<<std::endl;

    if (cam && extension) {
        if (!cam->isCameraConnected(camIdx)) {
            // connect to a device

            connectDevice(cmbAcquisitionDevice->currentExtension(), cmbAcquisitionDevice->currentExtensionCamera(), cmbAcquisitionDevice->currentCameraID(), cmbAcquisitionDevice->currentCameraQObject());
            if (!cam->isCameraConnected(camIdx)) {
                displayStates(QFESPIMB040SimpleCameraConfig::Disconnected);
                if (m_log) m_log->log_error(tr("error connecting to device %1, camera %2!\n").arg(extension->getName()).arg(camIdx));
            } else {
                displayStates(QFESPIMB040SimpleCameraConfig::Connected);
                if (m_log) m_log->log_text(tr("connected to device %1, camera %2!\n").arg(extension->getName()).arg(camIdx));
                cmbPreviewConfiguration->setDefaultAsCurrentConfig();
            }
        } else {
            //disconnect from the current device and delete the settings widget
            displayStates(QFESPIMB040SimpleCameraConfig::Disconnected);
            //if (cam->isCameraConnected(camIdx))  {
                cam->disconnectCameraDevice(camIdx);

            //}
            if (m_log) m_log->log_text(tr("disconnected from device %1, camera %2!\n").arg(extension->getName()).arg(camIdx));
        }
    }
}
TrackEditor::TrackEditor(QWidget *parent) :
        QMainWindow(parent),
        // m_idev_factory(),
        m_serial_port(0),
        m_device_io(0),
        m_dev_data(0),
        m_command_mode_step(-1),
        m_command_response_step(-1),
        m_device_file(0),
        m_socket_notifier(0),
        m_nema_string(""),
        m_line(""),
        m_log_buf(),
        m_tmp_buf(),
        m_read_start(-1),
        m_retry_count(-1),
        m_expect_binary_data(-1),
        m_binary_data_already_read(-1),
        m_lastsection(false),
        m_blocksize(-1),
        m_track_collection(0),
        m_selection_model(0),
        m_track_filename("")
{
    ui.setupUi(this);

        // set m_track_collection to 0 to prevent setTrackCollection() from trying to delete it.
	m_track_collection = 0;

	PlotData::initializeMaps();

	connect(ui.actionExit, SIGNAL(triggered()), this, SLOT(close()));

	connect(ui.action_Connect, SIGNAL(triggered()), this, SLOT(connectDevice()));
	connect(ui.action_Disconnect, SIGNAL(triggered()), this, SLOT(disconnectDevice()));

	connect(ui.action_Load_Track, SIGNAL(triggered()), this, SLOT(loadTrack()));
	connect(ui.actionAppend_Track, SIGNAL(triggered()), this, SLOT(appendTrack()));
	connect(ui.action_Save_Track, SIGNAL(triggered()), this, SLOT(saveTrack()));
	connect(ui.action_Save_Track_As, SIGNAL(triggered()), this, SLOT(saveTrackAs()));

	connect(ui.action_Read_Log, SIGNAL(triggered()), this, SLOT(readLog()));
	ui.action_Read_Log->setDisabled(true);
	connect(ui.action_Start_Recording, SIGNAL(triggered()), this, SLOT(startRecording()));
	connect(ui.action_Stop_Recording, SIGNAL(triggered()), this, SLOT(stopRecording()));

	connect(ui.actionStart_Animation, SIGNAL(triggered()), &m_animation, SLOT(start()));
	connect(ui.actionStop_Animation, SIGNAL(triggered()), &m_animation, SLOT(stop()));

	connect(ui.actionFaster, SIGNAL(triggered()), &m_animation, SLOT(incSpeed()));
	connect(ui.actionSlower, SIGNAL(triggered()), &m_animation, SLOT(decSpeed()));

	connect(ui.actionX_0_125, SIGNAL(triggered()), &m_animation, SLOT(setTimeScaleX0125()));
	connect(ui.actionX_0_25, SIGNAL(triggered()), &m_animation, SLOT(setTimeScaleX025()));
	connect(ui.actionX_0_5, SIGNAL(triggered()), &m_animation, SLOT(setTimeScaleX05()));
	connect(ui.actionX_1, SIGNAL(triggered()), &m_animation, SLOT(setTimeScaleX1()));
	connect(ui.actionX_2, SIGNAL(triggered()), &m_animation, SLOT(setTimeScaleX2()));
	connect(ui.actionX_4, SIGNAL(triggered()), &m_animation, SLOT(setTimeScaleX4()));
	connect(ui.actionX_8, SIGNAL(triggered()), &m_animation, SLOT(setTimeScaleX8()));
	connect(ui.actionX_16, SIGNAL(triggered()), &m_animation, SLOT(setTimeScaleX16()));
	connect(ui.actionX_32, SIGNAL(triggered()), &m_animation, SLOT(setTimeScaleX32()));
	connect(ui.actionX_64, SIGNAL(triggered()), &m_animation, SLOT(setTimeScaleX64()));
	connect(ui.actionX_128, SIGNAL(triggered()), &m_animation, SLOT(setTimeScaleX128()));


	connect(ui.actionSettings, SIGNAL(triggered()), this, SLOT(showSettingsDlg()));

	connect(ui.action_About, SIGNAL(triggered()), this, SLOT(showAboutDialog()));

	connect(this, SIGNAL(setText(QString)), ui.nemaText, SLOT(appendPlainText(QString)));


	m_track_view = new TrackView(ui.scrollArea);
	ui.scrollArea->setWidget(m_track_view);

	connect(&m_animation, SIGNAL(setMarkers(QList<CMarker>)), m_track_view, SLOT(setMarkers(QList<CMarker>)));

	connect(ui.actionZoom_in, SIGNAL(triggered()), m_track_view, SLOT(zoomIn()));
	connect(ui.actionZoom_out, SIGNAL(triggered()), m_track_view, SLOT(zoomOut()));

	ui.treeView->setSelectionMode(QAbstractItemView::ExtendedSelection);
    m_selection_model = ui.treeView->selectionModel();
    connect(m_selection_model, SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(selectionChanged(QItemSelection,QItemSelection)));


	m_diagrams_layout = new CDiagramsLayout(ui.diagramWidget);
	ui.diagramWidget->setLayout(m_diagrams_layout);

	connect(m_diagrams_layout, SIGNAL(setMarkers(QList<CMarker>)), m_track_view, SLOT(setMarkers(QList<CMarker>)));

	m_settings = new CSettings();
	m_settings->load();

	QList<enum plotTypeY> distList;
	distList = m_settings->getDistQuantities();

	QList<enum plotTypeY> timeList;
	timeList = m_settings->getTimeQuantities();

	QList<enum plotTypeY> trackPointsList;
	trackPointsList = m_settings->getTrackpointsQuantities();

	m_diagrams_layout->setQuantities(distList, timeList, trackPointsList );


	setTrackCollection(new TrackCollection);

    m_device_io = 0;
	m_dev_data = 0;
	m_expect_binary_data = 0;

	m_command_mode_step = 0;
	m_command_response_step = 0;

	m_track_filename.clear();

    connect(ui.treeView, SIGNAL(clicked(QModelIndex)), this, SLOT(treeViewClicked(QModelIndex)));

    ui.treeView->setEditTriggers( QAbstractItemView::DoubleClicked
								| QAbstractItemView::SelectedClicked
								| QAbstractItemView::EditKeyPressed );


    m_progress_dlg = new QDialog(this);
    prg_dlg.setupUi(m_progress_dlg);
    m_progress_dlg->setModal(false);
    connect(prg_dlg.cancelButton, SIGNAL(clicked()), this, SLOT(readLogFinished()));

	statusBar()->addWidget(m_animation.statusBarWidget());
	statusBar()->addPermanentWidget(m_track_view->statusBarWidget());

	restoreLayout();
}
예제 #21
0
status_t BnCameraService::onTransact(
    uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
    switch(code) {
        case GET_NUMBER_OF_CAMERAS: {
            CHECK_INTERFACE(ICameraService, data, reply);
            reply->writeNoException();
            reply->writeInt32(getNumberOfCameras());
            return NO_ERROR;
        } break;
        case GET_CAMERA_INFO: {
            CHECK_INTERFACE(ICameraService, data, reply);
            CameraInfo cameraInfo = CameraInfo();
            memset(&cameraInfo, 0, sizeof(cameraInfo));
            status_t result = getCameraInfo(data.readInt32(), &cameraInfo);
            reply->writeNoException();
            reply->writeInt32(result);

            // Fake a parcelable object here
            reply->writeInt32(1); // means the parcelable is included
            reply->writeInt32(cameraInfo.facing);
            reply->writeInt32(cameraInfo.orientation);
            return NO_ERROR;
        } break;
        case GET_CAMERA_CHARACTERISTICS: {
            CHECK_INTERFACE(ICameraService, data, reply);
            CameraMetadata info;
            status_t result = getCameraCharacteristics(data.readInt32(), &info);
            reply->writeNoException();
            reply->writeInt32(result);

            // out-variables are after exception and return value
            reply->writeInt32(1); // means the parcelable is included
            info.writeToParcel(reply);
            return NO_ERROR;
        } break;
        case CONNECT: {
            CHECK_INTERFACE(ICameraService, data, reply);
            sp<ICameraClient> cameraClient =
                    interface_cast<ICameraClient>(data.readStrongBinder());
            int32_t cameraId = data.readInt32();
            const String16 clientName = data.readString16();
            int32_t clientUid = data.readInt32();
            sp<ICamera> camera;
            status_t status = connect(cameraClient, cameraId,
                    clientName, clientUid, /*out*/ camera);
            reply->writeNoException();
            reply->writeInt32(status);
            if (camera != NULL) {
                reply->writeInt32(1);
                reply->writeStrongBinder(camera->asBinder());
            } else {
                reply->writeInt32(0);
            }
            return NO_ERROR;
        } break;
        case CONNECT_PRO: {
            CHECK_INTERFACE(ICameraService, data, reply);
            sp<IProCameraCallbacks> cameraClient =
                interface_cast<IProCameraCallbacks>(data.readStrongBinder());
            int32_t cameraId = data.readInt32();
            const String16 clientName = data.readString16();
            int32_t clientUid = data.readInt32();
            sp<IProCameraUser> camera;
            status_t status = connectPro(cameraClient, cameraId,
                    clientName, clientUid, /*out*/ camera);
            reply->writeNoException();
            reply->writeInt32(status);
            if (camera != NULL) {
                reply->writeInt32(1);
                reply->writeStrongBinder(camera->asBinder());
            } else {
                reply->writeInt32(0);
            }
            return NO_ERROR;
        } break;
        case CONNECT_DEVICE: {
            CHECK_INTERFACE(ICameraService, data, reply);
            sp<ICameraDeviceCallbacks> cameraClient =
                interface_cast<ICameraDeviceCallbacks>(data.readStrongBinder());
            int32_t cameraId = data.readInt32();
            const String16 clientName = data.readString16();
            int32_t clientUid = data.readInt32();
            sp<ICameraDeviceUser> camera;
            status_t status = connectDevice(cameraClient, cameraId,
                    clientName, clientUid, /*out*/ camera);
            reply->writeNoException();
            reply->writeInt32(status);
            if (camera != NULL) {
                reply->writeInt32(1);
                reply->writeStrongBinder(camera->asBinder());
            } else {
                reply->writeInt32(0);
            }
            return NO_ERROR;
        } break;
        case ADD_LISTENER: {
            CHECK_INTERFACE(ICameraService, data, reply);
            sp<ICameraServiceListener> listener =
                interface_cast<ICameraServiceListener>(data.readStrongBinder());
            reply->writeNoException();
            reply->writeInt32(addListener(listener));
            return NO_ERROR;
        } break;
        case REMOVE_LISTENER: {
            CHECK_INTERFACE(ICameraService, data, reply);
            sp<ICameraServiceListener> listener =
                interface_cast<ICameraServiceListener>(data.readStrongBinder());
            reply->writeNoException();
            reply->writeInt32(removeListener(listener));
            return NO_ERROR;
        } break;
        default:
            return BBinder::onTransact(code, data, reply, flags);
    }
}