void QsfpModule::getTransceiverInfo(TransceiverInfo &info) { lock_guard<std::mutex> g(qsfpModuleMutex_); info.present = present_; info.transceiver = type(); info.port = qsfpImpl_->getNum(); if (!cacheIsValid()) { return; } if (getSensorInfo(info.sensor)) { info.__isset.sensor = true; } if (getVendorInfo(info.vendor)) { info.__isset.vendor = true; } if (getCableInfo(info.cable)) { info.__isset.cable = true; } if (getThresholdInfo(info.thresholds)) { info.__isset.thresholds = true; } for (int i = 0; i < CHANNEL_COUNT; i++) { Channel chan; chan.channel = i; info.channels.push_back(chan); } if (getSensorsPerChanInfo(info.channels)) { info.__isset.channels = true; } else { info.channels.clear(); } }
QMimeData * SensorBrowserModel::mimeData ( const QModelIndexList & indexes ) const { //virtual QMimeData *mimeData = new QMimeData(); if(indexes.size() != 1) return mimeData; SensorInfo *sensor = getSensorInfo(indexes[0]); if(!sensor) return mimeData; // Create text drag object as // "<hostname> <sensorname> <sensortype> <sensordescription>". // Only the description may contain blanks. Q_ASSERT(sensor); Q_ASSERT(sensor->hostInfo()); QString mDragText = sensor->hostInfo()->hostName() + ' ' + sensor->name() + ' ' + sensor->type()+ ' ' + sensor->description(); mimeData->setData( "application/x-ksysguard", mDragText.toUtf8() ); return mimeData; }
//============================================================================= // querySteroeCamera() // // Given that the camera handle is a stereo camera, query the camera for // stereo specific information about this camera and populate the // PGRStereoCamera_t handle structure // dc1394error_t queryStereoCamera( dc1394camera_t* camera, PGRStereoCamera_t* stereoCamera ) { // set the camera handle stereoCamera->camera = camera; // find out what base model camera we have stereoCamera->model = getCameraModel( camera ); if ( stereoCamera->model == UNKNOWN_CAMERA ) return DC1394_FAILURE; dc1394error_t err; if ( stereoCamera->model != BUMBLEBEE ) { err = getSensorInfo( camera, &stereoCamera->bColor, &stereoCamera->nRows, &stereoCamera->nCols ); if ( err != DC1394_SUCCESS ) { fprintf( stderr, "Could not query the Sensor Info Register!\n" ); return err; } } else // model == BUMBLEBEE { // This is a Bumblebee "1". This camera does not support the // sensor board info register so we need to determine if it is color // and the resolution the hard way // // It will be nice when we don't need to support BB1 anymore as it is // not completely DC-compliant dc1394video_modes_t video_modes; err = dc1394_video_get_supported_modes( camera, &video_modes ); if ( err != DC1394_SUCCESS ) { fprintf( stderr, "Can't get video modes\n" ); return err; } // find the highest res mode that is greyscale (MONO16) printf( "Searching for the highest resolution MONO16 mode available...\n" ); dc1394video_mode_t video_mode; dc1394color_coding_t coding; for ( int i = video_modes.num-1; i >= 0; i-- ) { // don't consider FORMAT 7 modes (i.e. "scalable") if ( !dc1394_is_video_mode_scalable( video_modes.modes[i] ) ) { dc1394_get_color_coding_from_video_mode( camera, video_modes.modes[i], &coding ); if ( coding == DC1394_COLOR_CODING_MONO16 ) { video_mode = video_modes.modes[i]; break; } } } if ( video_mode == DC1394_VIDEO_MODE_640x480_MONO16 ) { stereoCamera->nRows = 480; stereoCamera->nCols = 640; } else if ( video_mode == DC1394_VIDEO_MODE_1024x768_MONO16 ) { stereoCamera->nRows = 768; stereoCamera->nCols = 1024; } else { fprintf( stderr, "Cannot find valid MONO16 video mode!\n" ); return DC1394_FAILURE; } dc1394color_filter_t bayerPattern; err = getBayerTile( stereoCamera->camera, &bayerPattern ); if ( err != DC1394_SUCCESS ) { fprintf( stderr, "Failed to read the Bayer Tile Pattern register\n" ); return err; } // at this point all we need to know is "is it color or mono?" if ( bayerPattern == 0 ) stereoCamera->bColor = false; else stereoCamera->bColor = true; } // a hack to figure out how many bytes per pixel are needed. // if the camera is a BB3, then it is 3, otherwise 2 if ( stereoCamera->nRows == 960 ) { //stereoCamera->nBytesPerPixel = 3; // note: for performance reasons we have changed the default behavior // of the XB3 for these examples to only use the 2 wide-baseline pair. // This makes for faster image transmission. // If you change the code to transmit all 3 images, this value will // have to revert to 3. stereoCamera->nBytesPerPixel = 2; } else { stereoCamera->nBytesPerPixel = 2; } return DC1394_SUCCESS; }
///////////////////////////////////////////////////////////////////////////////////////////// // Scan /dev looking for hidraw devices and then check to see if each is a Rift // nthDevice is 0-based ///////////////////////////////////////////////////////////////////////////////////////////// Device * openRiftHID( int nthDevice, Device *myDev ) { BOOLEAN didAlloc = FALSE; struct hid_device_info *devs, *cur_dev; wchar_t wstr[MAX_STR]; Device *dev = myDev; // Iterate over the devices matching our IDs devs = hid_enumerate(0x2833, 0x0001); cur_dev = devs; while (cur_dev) { // Skip to the one we want if( nthDevice-- ) { cur_dev = cur_dev->next; continue; } // Allocate space if we need to if (! dev ) { dev = (Device *)malloc(sizeof(Device)); didAlloc = TRUE; } // Open the device dev->hidapi_dev = (hid_device *)hid_open(cur_dev->vendor_id, cur_dev->product_id, cur_dev->serial_number); // Did we fail to open the device? if( !dev->hidapi_dev ) { // Yep. Clean up if( didAlloc ) { free(dev); } return 0; } // Save the vendor and product IDs (not that we need them) dev->vendorId = cur_dev->vendor_id; dev->productId = cur_dev->product_id; //printf("\n\nDevice Found:\n"); // Read the Manufacturer String hid_get_manufacturer_string(dev->hidapi_dev, wstr, MAX_STR); //printf("Manufacturer: %ls\n", wstr); dev->name = malloc(sizeof(wchar_t) * wcslen(wstr) + 1); wcstombs(dev->name, wstr, wcslen(wstr)); // Read the Product String hid_get_product_string(dev->hidapi_dev, wstr, MAX_STR); //printf("Product: %ls\n", wstr); dev->product = malloc(sizeof(wchar_t) * wcslen(wstr) + 1); wcstombs(dev->product, wstr, wcslen(wstr)); // Read the Serial Number String hid_get_serial_number_string(dev->hidapi_dev, wstr, MAX_STR); //printf("Serial Number: %ls", wstr); dev->serial = malloc(sizeof(wchar_t) * wcslen(wstr) + 1); wcstombs(dev->serial, wstr, wcslen(wstr)); //printf("\n\n"); break; } hid_free_enumeration(devs); if ( dev && dev->hidapi_dev > 0 ) { // Make our device nonblocking hid_set_nonblocking(dev->hidapi_dev, 1); // Init the Rift sensor info if( ! getSensorInfo( dev ) ) { // Clean up if( didAlloc ) { free(dev); } dev = 0; } } else { // Clean up if ( didAlloc ) { free(dev); } dev = 0; } return dev; }