Beispiel #1
0
void CCdromSelectionWnd::PopulateDeviceList()
{
	uint32 nDrives = GetLogicalDrives();
	for(uint32 i = 0; i < 32; i++)
	{
		if((nDrives & (1 << i)) == 0) continue;

		TCHAR sDeviceRoot[32];
		_sntprintf(sDeviceRoot, countof(sDeviceRoot), _T("%c:\\"), _T('A') + i);
		if(GetDriveType(sDeviceRoot) != DRIVE_CDROM) continue;

		TCHAR sDevicePath[32];
		_sntprintf(sDevicePath, countof(sDevicePath), _T("\\\\.\\%c:"), _T('A') + i);

		TCHAR sVendorId[256];
		TCHAR sProductId[256];
		_tcscpy(sVendorId, _T(""));
		_tcscpy(sProductId, _T("(Unknown device)"));

		HANDLE hDevice = CreateFile(sDevicePath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_NO_BUFFERING, NULL);
		if(hDevice != INVALID_HANDLE_VALUE)
		{
			STORAGE_PROPERTY_QUERY Query;
			memset(&Query, 0, sizeof(STORAGE_PROPERTY_QUERY));
			Query.PropertyId	= StorageDeviceProperty;
			Query.QueryType		= PropertyStandardQuery;

			DWORD nRetSize = 0;
			uint8 nBuffer[512];
			if(DeviceIoControl(hDevice, IOCTL_STORAGE_QUERY_PROPERTY, &Query, sizeof(STORAGE_PROPERTY_QUERY), &nBuffer, 512, &nRetSize, NULL) != 0)
			{
				auto pDesc = reinterpret_cast<STORAGE_DEVICE_DESCRIPTOR*>(nBuffer);

				_tcsncpy(sVendorId, GetVendorId(pDesc) != NULL ? string_cast<std::tstring>(GetVendorId(pDesc)).c_str() : _T(""), 256);
				_tcsncpy(sProductId, GetProductId(pDesc) != NULL ? string_cast<std::tstring>(GetProductId(pDesc)).c_str() : _T(""), 256);

				if(GetVendorId(pDesc) != NULL)
				{
					_tcscat(sVendorId, _T(" "));
				}
			}

			CloseHandle(hDevice);
		}

		TCHAR sDisplay[256];
		_sntprintf(sDisplay, countof(sDisplay), _T("%s - %s%s"),  sDeviceRoot, sVendorId, sProductId);

		unsigned int nIndex = m_pDeviceCombo->AddString(sDisplay);
		m_pDeviceCombo->SetItemData(nIndex, i);
	}
}
QVariant tNDP2kVirtualDeviceInfoParam::GetValueForNDP2k(const unsigned short paramID, const unsigned char destAddress, const unsigned char paramInstance) 
{ 
    Q_UNUSED(paramID);
    Q_UNUSED(destAddress);
    Q_UNUSED(paramInstance);

    QVariant value;

    switch(m_VirtualDeviceInfoParamType)
    {
        case eVirtualDeviceInfoParamType_ProductId :
            value = GetProductId();
            break;

        case eVirtualDeviceInfoParamType_SerialNumber :
            value = GetSerialNumber();
            break;

        case eVirtualDeviceInfoParamType_DeviceInstance :
            value = GetDeviceInstance();
            break;

        case eVirtualDeviceInfoParamType_SystemInstance :
            value = GetSysInstance();
            break;

        default :
            Assert(0);
            break;

    }

    return value;
}
string CSymbolInfoRepositry::GetExchangeId( const string& instrument )
{
	string prodId;
	int prodLen = GetProductId(instrument, prodId);
	if(prodLen > 0)
	{
		map<string, string>::iterator iterExch = m_prodExchMap.find(prodId);
		if(iterExch != m_prodExchMap.end())
		{
			return iterExch->second;
		}
	}
	return "";
}
CSymbolInfo* CSymbolInfoRepositry::Get( const char* instrument )
{
	string symbol = instrument;
	SymbolInfoMapIter iterSI = m_symbolInfoMap.find(symbol);
	if(iterSI != m_symbolInfoMap.end())
	{
		return (iterSI->second).get();
	}
	else
	{
		string prodId;
		int prodLen = GetProductId(symbol, prodId);
		map<string, string>::iterator iterExch = m_prodExchMap.find(prodId);
		if(iterExch != m_prodExchMap.end())
		{
			SymbolInfoPtr siPtr(new CSymbolInfo(symbol, iterExch->second, prodId));
			m_symbolInfoMap.insert(make_pair(siPtr->Instrument(), siPtr));
			return siPtr.get();
		}
	}

	return NULL;
}
Beispiel #5
0
void NTFFileReader::EstablishRasterAccess()

{
/* -------------------------------------------------------------------- */
/*      Read the type 50 record.                                        */
/* -------------------------------------------------------------------- */
    NTFRecord   *poRecord;

    while( (poRecord = ReadRecord()) != NULL
           && poRecord->GetType() != NRT_GRIDHREC
           && poRecord->GetType() != NRT_VTR )
    {
        delete poRecord;
    }

    if( poRecord->GetType() != NRT_GRIDHREC )
    {
        delete poRecord;
        CPLError( CE_Failure, CPLE_AppDefined,
                  "Unable to find GRIDHREC (type 50) record in what appears\n"
                  "to be an NTF Raster DTM product." );
        return;
    }

/* -------------------------------------------------------------------- */
/*      Parse if LANDRANGER_DTM                                         */
/* -------------------------------------------------------------------- */
    if( GetProductId() == NPC_LANDRANGER_DTM )
    {
        nRasterXSize = atoi(poRecord->GetField(13,16));
        nRasterYSize = atoi(poRecord->GetField(17,20));

        // NOTE: unusual use of GeoTransform - the pixel origin is the
        // bottom left corner!
        adfGeoTransform[0] = atoi(poRecord->GetField(25,34));
        adfGeoTransform[1] = 50;
        adfGeoTransform[2] = 0;
        adfGeoTransform[3] = atoi(poRecord->GetField(35,44));
        adfGeoTransform[4] = 0;
        adfGeoTransform[5] = 50;
        
        nRasterDataType = 3; /* GDT_Int16 */
    }

/* -------------------------------------------------------------------- */
/*      Parse if LANDFORM_PROFILE_DTM                                   */
/* -------------------------------------------------------------------- */
    else if( GetProductId() == NPC_LANDFORM_PROFILE_DTM )
    {
        nRasterXSize = atoi(poRecord->GetField(23,30));
        nRasterYSize = atoi(poRecord->GetField(31,38));

        // NOTE: unusual use of GeoTransform - the pixel origin is the
        // bottom left corner!
        adfGeoTransform[0] = atoi(poRecord->GetField(13,17))
                           + GetXOrigin();
        adfGeoTransform[1] = atoi(poRecord->GetField(39,42));
        adfGeoTransform[2] = 0;
        adfGeoTransform[3] = atoi(poRecord->GetField(18,22))
                           + GetYOrigin();
        adfGeoTransform[4] = 0;
        adfGeoTransform[5] = atoi(poRecord->GetField(43,46));
        
        nRasterDataType = 3; /* GDT_Int16 */
    }

/* -------------------------------------------------------------------- */
/*      Initialize column offsets table.                                */
/* -------------------------------------------------------------------- */
    delete poRecord;

    panColumnOffset = (long *) CPLCalloc(sizeof(long),nRasterXSize);

    GetFPPos( panColumnOffset+0, NULL );

/* -------------------------------------------------------------------- */
/*      Create an OGRSFLayer for this file readers raster points.       */
/* -------------------------------------------------------------------- */
    if( poDS != NULL )
    {
        poRasterLayer = new OGRNTFRasterLayer( poDS, this );
        poDS->AddLayer( poRasterLayer );
    }
}
Beispiel #6
0
int NTFFileReader::IsRasterProduct()

{
    return GetProductId() == NPC_LANDRANGER_DTM
        || GetProductId() == NPC_LANDFORM_PROFILE_DTM;
}
Beispiel #7
0
CPLErr NTFFileReader::ReadRasterColumn( int iColumn, float *pafElev )

{
/* -------------------------------------------------------------------- */
/*      If we don't already have the scanline offset of the previous    */
/*      line, force reading of previous records to establish it.        */
/* -------------------------------------------------------------------- */
    if( panColumnOffset[iColumn] == 0 )
    {
        int     iPrev;
        
        for( iPrev = 0; iPrev < iColumn-1; iPrev++ )
        {
            if( panColumnOffset[iPrev+1] == 0 )
            {
                CPLErr  eErr;
                
                eErr = ReadRasterColumn( iPrev, NULL );
                if( eErr != CE_None )
                    return eErr;
            }
        }
    }

/* -------------------------------------------------------------------- */
/*      If the dataset isn't open, open it now.                         */
/* -------------------------------------------------------------------- */
    if( GetFP() == NULL )
        Open();
    
/* -------------------------------------------------------------------- */
/*      Read requested record.                                          */
/* -------------------------------------------------------------------- */
    NTFRecord   *poRecord;
    
    SetFPPos( panColumnOffset[iColumn], iColumn );
    poRecord = ReadRecord();

    if( iColumn < nRasterXSize-1 )
    {
        GetFPPos( panColumnOffset+iColumn+1, NULL );
    }
    
/* -------------------------------------------------------------------- */
/*      Handle LANDRANGER DTM columns.                                  */
/* -------------------------------------------------------------------- */
    if( pafElev != NULL && GetProductId() == NPC_LANDRANGER_DTM )
    {
        double  dfVScale, dfVOffset;

        dfVOffset = atoi(poRecord->GetField(56,65));
        dfVScale = atoi(poRecord->GetField(66,75)) * 0.001;

        for( int iPixel = 0; iPixel < nRasterXSize; iPixel++ )
        {
            pafElev[iPixel] = (float) (dfVOffset + dfVScale *
                atoi(poRecord->GetField(84+iPixel*4,87+iPixel*4)));
        }
    }
            
/* -------------------------------------------------------------------- */
/*      Handle PROFILE                                                  */
/* -------------------------------------------------------------------- */
    else if( pafElev != NULL && GetProductId() == NPC_LANDFORM_PROFILE_DTM )
    {
        for( int iPixel = 0; iPixel < nRasterXSize; iPixel++ )
        {
            pafElev[iPixel] = (float) 
           (atoi(poRecord->GetField(19+iPixel*5,23+iPixel*5)) * GetZMult());
        }
    }
    
    delete poRecord;

    return CE_None;
}