Exemple #1
0
//----------------------------------------
void CProductErs::ProcessHighResolutionWithoutFieldCalculation()
{
  if (m_dataSet.size() <= 0)
  {
    return;
  }
 
  // Get the current recordset (that which has been just read)
  CRecordSet* recordSetToProcess = m_dataSet.GetCurrentRecordSet();

  if (recordSetToProcess == NULL)
  {
    string msg = "ERROR in CProductErs::ProcessHighResolutionWithoutFieldCalculation - No current recordset";
    CProductException e(msg, m_currFileName, GetProductClass(), GetProductType(), BRATHL_LOGIC_ERROR);
    throw (e);
  }

  CFieldSetDbl *fieldSetLat = m_dataSet.GetFieldSetAsDbl( m_fieldNameEquivalence.Exists(m_latitudeFieldName) );
  CFieldSetDbl *fieldSetLon = m_dataSet.GetFieldSetAsDbl( m_fieldNameEquivalence.Exists(m_longitudeFieldName) );
  CFieldSetDbl *fieldSetTimeStampSecond = m_dataSet.GetFieldSetAsDbl( m_fieldNameEquivalence.Exists(m_timeStampSecondFieldName) );
  CFieldSetDbl *fieldSetTimeStampMicrosecond = m_dataSet.GetFieldSetAsDbl( m_fieldNameEquivalence.Exists(m_timeStampMicrosecondFieldName) );

  if (fieldSetLat == NULL)
  {
    string msg = "ERROR in CProductErs::ProcessHighResolutionWithoutFieldCalculation - latitude field has not been read";
    CProductException e(msg, m_currFileName, GetProductClass(), GetProductType(), BRATHL_LOGIC_ERROR);
    throw (e);
  }

  if (fieldSetLon == NULL)
  {
    string msg = "ERROR in CProductErs::ProcessHighResolutionWithoutFieldCalculation - longitude field has not been read";
    CProductException e(msg, m_currFileName, GetProductClass(), GetProductType(), BRATHL_LOGIC_ERROR);
    throw (e);
  }

  if (fieldSetTimeStampSecond == NULL)
  {
    string msg = "ERROR in CProductErs::ProcessHighResolutionWithoutFieldCalculation - timestamp second field has not been read";
    CProductException e(msg, m_currFileName, GetProductClass(), GetProductType(), BRATHL_LOGIC_ERROR);
    throw (e);
  }
  if (fieldSetTimeStampMicrosecond == NULL)
  {
    string msg = "ERROR in CProductErs::ProcessHighResolutionWithoutFieldCalculation - timestamp microsecond field has not been read";
    CProductException e(msg, m_currFileName, GetProductClass(), GetProductType(), BRATHL_LOGIC_ERROR);
    throw (e);
  }


  // if time difference between the the current timestamp and the previous timestamp is greater than 2 seconds 
  // or if current timestamp is less or equal than the previous timestamp
  // skip the current recordset (data will be lost)
  

  // WARNING -  fieldSetTimeStampSecond, fieldSetTimeStampMicrosecond are converted to SI
  // after they have been read. So their value are stated in seconds
  double timeStamp = 0;
  timeStamp = CTools::Plus(timeStamp, fieldSetTimeStampSecond->m_value);
  timeStamp = CTools::Plus(timeStamp, fieldSetTimeStampMicrosecond->m_value);

  if  ( (timeStamp - m_previousTimeStamp > 2.0) ||
        (timeStamp <= m_previousTimeStamp) )
  {
    string msg = CTools::Format("INFO - record skipped due to inconsistency between two measures\n"
                                "\t previous record --> timestamp %f seconds\n"
                                "\t current record --> timestamp %f seconds\n"
                                "\t timestamp difference is %f seconds\n",
                                m_previousTimeStamp,
                                timeStamp,
                                timeStamp - m_previousTimeStamp);
    CTrace::Tracer(3, msg); 

    m_previousLatitude = fieldSetLat->m_value;
    m_previousLongitude = fieldSetLon->m_value;
    m_previousTimeStamp = timeStamp;
    
    // Erase the current recordset in the main dataset (data are lost)
    m_dataSet.Erase(recordSetToProcess);
    recordSetToProcess = NULL;  
    m_nSkippedRecord++;
    return;
  }

  // Create a new dataset which contains 'normal' fields of the current recordset of the main dataset and
  // high resolution fields
  // This dataset will contains as  many records as number of high resolution measures (m_numHighResolutionMeasure)
  CDataSet dataSetHighResolution("HighResolution", false);

  if (CTools::IsDefaultValue(m_previousLatitude))
  {
    string msg = "ERROR in CProductErs::ProcessHighResolutionWithoutFieldCalculation - previous latitude value read is inconsistent (is default value)";
    CProductException e(msg, m_currFileName, GetProductClass(), GetProductType(), BRATHL_INCONSISTENCY_ERROR);
    throw (e);
  }
  if (CTools::IsDefaultValue(m_previousLongitude))
  {
    string msg = "ERROR in CProductErs::ProcessHighResolutionWithoutFieldCalculation - previous longitude value read is inconsistent (is default value)";
    CProductException e(msg, m_currFileName, GetProductClass(), GetProductType(), BRATHL_INCONSISTENCY_ERROR);
    throw (e);
  }

  // Compute delta latitude an deltat longitude.
  double deltaLat = (fieldSetLat->m_value - m_previousLatitude) / m_numHighResolutionMeasure;
  double deltaLon = (fieldSetLon->m_value - m_previousLongitude) / m_numHighResolutionMeasure;

  if ( (m_numHighResolutionMeasure * deltaLon) < -1.0)
  {
    deltaLon += 360 / m_numHighResolutionMeasure;
  }
  else if ( (m_numHighResolutionMeasure * deltaLon) > 1.0)
  {
    deltaLon -= 360 / m_numHighResolutionMeasure;
  }

  if ( (m_numHighResolutionMeasure * CTools::Abs(deltaLon)) > 1.0)
  {
    string msg = CTools::Format("ERROR in CProductErs::ProcessHighResolutionWithoutFieldCalculation - delta of longitude is set to an unexpected value: %f "
                                "\n\tcurrent datetime: %f current latitude: %f current longitude: %f"
                                "\n\tprevious datetime: %f previous latitude: %f previous longitude: %f",
                                deltaLon,
                                timeStamp, 
                                fieldSetLat->m_value, 
                                fieldSetLon->m_value,
                                m_previousTimeStamp,
                                m_previousLatitude,
                                m_previousLongitude);
    CProductException e(msg, m_currFileName, GetProductClass(), GetProductType(), BRATHL_INCONSISTENCY_ERROR);
    throw (e);
  }

  CRecordSet::iterator it;
  for (it = recordSetToProcess->begin() ; it != recordSetToProcess->end() ; it++)
  {
    CFieldSet* fieldSet = recordSetToProcess->GetFieldSet(it);
    CFieldSetDbl* fieldSetDbl = dynamic_cast<CFieldSetDbl*>(fieldSet); 
    CFieldSetArrayDbl* fieldSetArrayDbl = dynamic_cast<CFieldSetArrayDbl*>(fieldSet); 

    // the field is hidden, it is just use for calculation, don't set it in output
    if (fieldSet->GetField()->IsHidden())
    {
      continue;
    }    

    // data is an array of double
    if (fieldSetArrayDbl != NULL)
    {
      // field is a high resolution field 
      // transform array of double  in a set of records with a double value
      if ( fieldSetArrayDbl->GetField()->IsHighResolution() )
      {
        PutFlatHighResolution(&dataSetHighResolution, fieldSetArrayDbl);      
      }
      else
      {
        // field is an array
        // put it into the set of records (array is repeated for each record)
        Put(&dataSetHighResolution, fieldSetArrayDbl, m_numHighResolutionMeasure);      
      }
    }
    
    // data is a double
    if (fieldSetDbl != NULL)
    {
      // field is a double
      // put it into the set of records (value is repeated for each record)
      Put(&dataSetHighResolution, fieldSetDbl);      
    }    
  }


  // Compute high resolution fields
  ComputeHighResolutionFields(&dataSetHighResolution, deltaLat, deltaLon);      

  m_previousLatitude = fieldSetLat->m_value;
  m_previousLongitude = fieldSetLon->m_value;
  m_previousTimeStamp = timeStamp;

  // Erase the current recordset in the main dataset 
  m_dataSet.Erase(recordSetToProcess);
  
  recordSetToProcess = NULL;
  
  fieldSetLat = NULL;
  fieldSetLon = NULL;
  fieldSetTimeStampSecond = NULL;
  fieldSetTimeStampMicrosecond = NULL;
   
  // Insert the record of the new dataset in the main dataset
  m_dataSet.InsertDataset(&dataSetHighResolution);
  
}
Exemple #2
0
bool GetWindowsVersionName(std::string* out)
{
	if (!out) return false;

	*out = "Microsoft ";

	BYTE dwType = GetProductType();
	DWORD dwSubType = 0;

	SYSTEM_INFO si;
	ZeroMemory(&si, sizeof(SYSTEM_INFO));
	GetNativeSystemInfo(&si);

	if (EqualsMajorVersion(6) && EqualsMinorVersion(3))
	{
		MyGetProductInfo(6, 3, 0, 0, &dwSubType);

		if (dwType == VER_NT_WORKSTATION)
		{
			out->append("Windows 8.1");
			if (dwSubType == PRODUCT_PROFESSIONAL)
				out->append(" Pro");
		}
		else if (dwType == VER_NT_SERVER)
		{
			out->append("Windows Server 2012 R2");
		}
	}
	else if (EqualsMajorVersion(6) && EqualsMinorVersion(2))
	{
		MyGetProductInfo(6, 2, 0, 0, &dwSubType);

		if (dwType == VER_NT_WORKSTATION)
		{
			out->append("Windows 8");
			if (dwSubType == PRODUCT_PROFESSIONAL)
				out->append(" Pro");
		}
		else if (dwType == VER_NT_SERVER)
		{
			out->append("Windows Server 2012");
		}
	}
	else // older than Windows 8 use GetVersionExA
	{
		OSVERSIONINFOEXA osvi;
		ZeroMemory(&osvi, sizeof(OSVERSIONINFOEXA));
		osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA);
		MyGetVersionExA(&osvi);

		if (osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 1)
		{
			MyGetProductInfo(6, 1, 0, 0, &dwSubType);

			if (dwType == VER_NT_WORKSTATION)
				out->append("Windows 7");
			else out->append("Windows Server 2008 R2");

			switch (dwSubType)
			{
				case PRODUCT_ULTIMATE:
					out->append(" Ultimate Edition");
					break;
				case PRODUCT_PROFESSIONAL:
					out->append(" Professional");
					break;
				case PRODUCT_HOME_PREMIUM:
					out->append(" Home Premium Edition");
					break;
				case PRODUCT_HOME_BASIC:
					out->append(" Home Basic Edition");
					break;
				case PRODUCT_ENTERPRISE:
					out->append(" Enterprise Edition");
					break;
				case PRODUCT_BUSINESS:
					out->append(" Business Edition");
					break;
				case PRODUCT_STARTER:
					out->append(" Starter Edition");
					break;
			}
		}
		else if (osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 0)
		{
			if (dwType == VER_NT_WORKSTATION)
				out->append("Windows Vista");
			else out->append("Windows Server 2008");
		}
		else if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2)
		{

			if (GetSystemMetrics(SM_SERVERR2))
				out->append("Windows Server 2003 R2");
			else if (osvi.wSuiteMask & VER_SUITE_STORAGE_SERVER)
				out->append("Windows Storage Server 2003");
			else if (osvi.wSuiteMask & VER_SUITE_WH_SERVER)
				out->append("Windows Home Server");
			else if (osvi.wProductType == VER_NT_WORKSTATION &&
				si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)
			{
				out->append("Windows XP Professional x64 Edition");
			}
			else out->append("Windows Server 2003 ");
		}
		else if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1)
		{
			out->append("Windows XP");
			if (osvi.wSuiteMask & VER_SUITE_PERSONAL)
				out->append(" Home Edition");
			else out->append(" Professional");
		}

	}
	if (EqualsMajorVersion(6))
	{
		if (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)
			out->append(" (x64)");
		else if (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL)
			out->append(" (x86)");
	}

	return true;
}