Exemplo n.º 1
0
//------------------------------------------------------------------------------
void ConsoleMessageReceiver::SetLogPath(const std::string &pathname, 
      bool append)
{
   FileManager *fm = FileManager::Instance();
   std::string fname;
   try
   {
      std::string filename = fm->GetFilename(FileManager::LOG_FILE);
      fname = pathname + filename;
   }
   catch (BaseException &e)
   {
      ShowMessage
         ("**** ERROR **** " + e.GetFullMessage() + 
          "So setting log file name to GmatLog.txt");
      
      fname = "GmatLog.txt";
   }
   
   OpenLogFile(fname, append);
}
Exemplo n.º 2
0
//------------------------------------------------------------------------------
bool ITRFAxes::Initialize()
{
   #ifdef DEBUG_ITRFAXES_INITIALIZE
      MessageInterface::ShowMessage("Initialize ITRFAxes: with name '%s'\n",
         instanceName.c_str());
   #endif

   DynamicAxes::Initialize();
   if (originName == SolarSystem::EARTH_NAME) InitializeFK5();
   #ifdef DEBUG_FIRST_CALL
      firstCallFired = false;
   #endif
   
   // create and initialize IAU2000/2006 object:
   if (iauFile == NULL)
	   iauFile = IAUFile::Instance();
   iauFile->Initialize();

   // create and initialize EopFile object:
   if (eop == NULL)
   {
	   FileManager* fm = FileManager::Instance();
	   std::string name = fm->GetFilename("EOP_FILE");
	   EopFile* eopFile = new EopFile(name);
	   eopFile->Initialize();
	   SetEopFile(eopFile);
   }

   isInitialized = true;

   #ifdef DEBUG_ITRFAXES_INITIALIZE
      MessageInterface::ShowMessage("End initialize ITRFAxes: with name '%s'\n",
         instanceName.c_str());
   #endif

   return true;
}
Exemplo n.º 3
0
//------------------------------------------------------------------------------
void IAUFile::Initialize()
{
	if (isInitialized)
		return;
   
	// Allocate buffer to store IAU2000/2006 data:
	AllocateArrays();
   
   // Use FileManager::FindPath() for new file path implementation (LOJ: 2014.07.01)
   
	// Open IAU2000/2006 data file:
   // FileManager* fm = FileManager::Instance();
   // std::string path = fm->GetPathname(FileManager::IAUSOFA_FILE);
   // std::string name = fm->GetFilename(FileManager::IAUSOFA_FILE);
   // iauFileName = path+name;
	// FILE* fpt = fopen(iauFileName.c_str(), "r");
   
   FileManager *fm = FileManager::Instance();
   iauFileName = fm->GetFilename(FileManager::IAUSOFA_FILE);
   iauFileNameFullPath = fm->FindPath(iauFileName, FileManager::IAUSOFA_FILE, true, true, true);
   
   // Check full path file
   if (iauFileNameFullPath == "")
		throw GmatBaseException("The IAU file '" + iauFileName + "' does not exist\n");
   
   FILE* fpt = fopen(iauFileNameFullPath.c_str(), "r");
   if (fpt == NULL)
      throw GmatBaseException("Error: GMAT cann't open '" + iauFileName + "' file!!!\n");
   
	// Read IAU2000/2006 data from data file and store to buffer:
	Real t;
	Real XYs[3];
	int c;
	Integer i;
	for (i= 0; (c = fscanf(fpt, "%lf %lf %lf %lf\n",&t,&XYs[0],&XYs[1],&XYs[2])) != EOF; ++i)
	{
		// expend the buffer size when it has no room to contain data:
		if (i >= tableSz)
		{
			// create a new buffer with a larger size:
			Integer new_size = tableSz*2;
			Real* ind = new Real[new_size];
			Real** dep = new Real*[new_size];

			// copy contain in the current buffer to the new buffer:
			memcpy(ind, independence, tableSz*sizeof(Real));
			memcpy(dep, dependences, tableSz*sizeof(Real*));
			for (Integer k=tableSz; k < new_size; ++k)
				dep[k] = NULL;

			// delete the current buffer and use the new buffer as the current buffer:
			delete independence;
			delete dependences;
			independence = ind;
			dependences = dep;
			tableSz = new_size;
		}

		// store data to buffer:
		independence[i] = t;
		if (dependences[i] == NULL)
			dependences[i] = new Real[dimension];

		for (Integer j = 0; j < dimension; ++j)
			dependences[i][j] = XYs[j];
	}

	fclose(fpt);

	pointsCount = i;  // why "this->"?
}