Example #1
0
//------------------------------------------------------------------------------
void CallFunction::SetGlobalObjectMap(std::map<wxString, GmatBase *> *map)
{
   #ifdef DEBUG_GLOBAL_OBJECT_MAP
   MessageInterface::ShowMessage
      (wxT("CallFunction::SetGlobalObjectMap() entered, mFunctionName='%s', ")
       wxT("map=<%p>\n"), mFunctionName.c_str(), map);
   #endif
   
   GmatCommand::SetGlobalObjectMap(map);
   
   // Now, find the function object
   GmatBase *mapObj = FindObject(mFunctionName);
   
   #ifdef DEBUG_GLOBAL_OBJECT_MAP
   MessageInterface::ShowMessage
      (wxT("   mapObj=<%p><%s>'%s'\n"), mapObj,
       mapObj ? mapObj->GetTypeName().c_str() : wxT("NULL"),
       mapObj ? mapObj->GetName().c_str() : wxT("NULL"));
   #endif
   
   if (mapObj == NULL)
   {
      //throw CommandException(wxT("CallFunction command cannot find Function ") +
      //         mFunctionName + wxT("\n"));
      ; // leave NULL for now
   }
   else
   {
      mFunction = (Function *)mapObj;
      
      #ifdef DEBUG_GLOBAL_OBJECT_MAP
      MessageInterface::ShowMessage
         (wxT("   mFunction=<%p><%s>\n"), mFunction, mFunction->GetName().c_str());
      #endif
      
      // Set only GmatFunction to FunctionManager (loj: 2008.09.03)
      if (mapObj->GetTypeName() == wxT("GmatFunction"))
         fm.SetFunction(mFunction);
   }
   fm.SetGlobalObjectMap(map);
   
   #ifdef DEBUG_GLOBAL_OBJECT_MAP
   MessageInterface::ShowMessage(wxT("CallFunction::SetGlobalObjectMap() exiting\n"));
   #endif
}
Example #2
0
//------------------------------------------------------------------------------
bool PenDown::Initialize()
{
   #ifdef DEBUG_PENDOWN
      MessageInterface::ShowMessage("PenDown::Initialize() entered\n");
   #endif
      
   PlotCommand::Initialize();
   
   GmatBase *sub;
   thePlotList.clear();
   
   for (unsigned int ii = 0; ii < plotNameList.size(); ii++)
   {
      if ((sub = FindObject(plotNameList.at(ii))) != NULL) 
      {
         if (sub->GetTypeName() == "XYPlot" ||
             sub->GetTypeName() == "OrbitView" ||
             sub->GetTypeName() == "GroundTrackPlot") 
            thePlotList.push_back((Subscriber*) sub);
         else
            throw CommandException(
               "Object named \"" + plotNameList.at(ii) +
               "\" should be an XYPlot, OrbitView or GroundTrackPlot to use the "
               "PenDown command for this object, but it is a " + 
               sub->GetTypeName());      
      }
      else 
      {
         MessageInterface::ShowMessage
            ("PenDown command cannot find Plot \"%s\"; command has no effect."
            "\n", (plotNameList.at(ii)).c_str());
         return false;
      }
   }
   
   #ifdef DEBUG_PENDOWN
      MessageInterface::ShowMessage
         ("   thePlotList.size()=%d\n", thePlotList.size());
      MessageInterface::ShowMessage("PenDown::Initialize() returning true\n");
   #endif
   return true;
}
Example #3
0
//------------------------------------------------------------------------------
bool ClearPlot::Initialize()
{
   #ifdef DEBUG_CLEARPLOT
      MessageInterface::ShowMessage(wxT("ClearPlot::Initialize() entered\n"));
   #endif
      
   PlotCommand::Initialize();
   
   GmatBase *xy;
   thePlotList.clear();
   
   for (unsigned int ii = 0; ii < plotNameList.size(); ii++)
   {
      if ((xy = FindObject(plotNameList.at(ii))) != NULL) 
      {
         if (xy->GetTypeName() == wxT("XYPlot")) 
            thePlotList.push_back((XyPlot*) xy);
         else
            throw CommandException(
               wxT("Object named \"") + plotNameList.at(ii) + wxT("\" should be an XYPlot to use the ")
               wxT("ClearPlot command for this object, but it is a ") + 
               xy->GetTypeName());      
      }
      else 
      {
         MessageInterface::ShowMessage
            (wxT("ClearPlot command cannot find XY Plot \"%s\"; command has no effect.")
            wxT("\n"), (plotNameList.at(ii)).c_str());
         return false;
      }
   }
   
   #ifdef DEBUG_CLEARPLOT
      MessageInterface::ShowMessage("ClearPlot::Initialize() returning true\n");
   #endif
   return true;
}
Example #4
0
//------------------------------------------------------------------------------
void GmatDialog::OnHelp(wxCommandEvent &event)
{
   #ifdef DEBUG_GMAT_DIALOG_HELP
   MessageInterface::ShowMessage
      ("GmatDialog::OnHelp() entered, mObject=<%p><%s>'%s'\n", mObject,
       mObject ? mObject->GetTypeName().c_str() : "NULL",
       mObject ? mObject->GetName().c_str() : "NULL");
   #endif
   
   wxString objLink;
   wxString sHTML;
   wxString baseHelpLink;
   char msgBuffer[255];
   
   // get the config object
   wxConfigBase *pConfig = wxConfigBase::Get();
   pConfig->SetPath(wxT("/Help"));
   if (mObject != NULL)
   {
      objLink = mObject->GetTypeName().c_str();
   }
   else
   {
      wxString prefix = "Scripting for ";
      objLink = GetName().c_str();
      if (objLink.Find(prefix) != wxNOT_FOUND)
		objLink = objLink.Mid(prefix.size());
      GmatBase *obj = theGuiInterpreter->GetConfiguredObject(objLink.c_str());
      if (obj != NULL)
         objLink = obj->GetTypeName().c_str();
   }
   
   wxHelpController *theHelpController = GmatAppData::Instance()->GetMainFrame()->GetHelpController();
	if (theHelpController != NULL)
	{
		#ifdef DEBUG_GMAT_DIALOG_HELP
		MessageInterface::ShowMessage
			("GmatPanel::OnHelp() theHelpController=<%p>\n   "
			"File to display=%s\n", theHelpController,
			s);
		#endif
		// displays chm, not html
		// see if there is an override for panel (e.g., PropSetupKeyword=Propagator)
		sHTML = objLink+".html";
		objLink = pConfig->Read(objLink+"Keyword", sHTML);

		if (!theHelpController->DisplaySection(objLink)) 
			theHelpController->DisplayContents();
	}
	else
	{
	   // get base help link if available
      baseHelpLink = pConfig->Read(_T("BaseHelpLink"),_T("http://gmat.sourceforge.net/docs/latest/html/%s.html"));
	   sprintf( msgBuffer, baseHelpLink.c_str(), objLink.WX_TO_C_STRING);
      
	   #ifdef DEBUG_GMAT_DIALOG_HELP
	   MessageInterface::ShowMessage
		  ("   objLink = '%s', baseHelpLink = '%s'\n   helpLink = '%s'\n",
		   objLink.c_str(), baseHelpLink.c_str(), msgBuffer);
	   #endif
      
	   // open separate window to show help
	   objLink = pConfig->Read(objLink, wxString(&msgBuffer[0]));
	   #ifdef DEBUG_GMAT_DIALOG_HELP
	   MessageInterface::ShowMessage("   actual help Link = '%s'\n", objLink.c_str());
	   #endif
      
      // if path is relative, try to append it to gmat root 
	   if (GmatFileUtil::IsPathRelative(objLink.c_str()))
	   {
			FileManager *fm = FileManager::Instance();
			if (GmatStringUtil::EndsWithPathSeparator(fm->GetRootPath()))
				objLink = fm->GetRootPath().c_str() + objLink;
			else
			{
			   wxString pathSep = GmatFileUtil::GetPathSeparator().c_str();
				objLink = fm->GetRootPath().c_str() + pathSep + objLink;
			}

	   }
	   wxLaunchDefaultBrowser(objLink);
	}
   
   #ifdef DEBUG_GMAT_DIALOG_HELP
   MessageInterface::ShowMessage("GmatDialog::OnHelp() leaving\n");
   #endif

}
Example #5
0
//------------------------------------------------------------------------------
// void SaveChildPositionAndSize()
//------------------------------------------------------------------------------
void GmatMdiChildFrame::SaveChildPositionAndSize()
{
   if (mCanSaveLocation == false)
      return;

   if (IsIconized())
      return;
   
   // Get the position and size of the window first
   #ifdef __WXMAC__
      Integer screenWidth  = wxSystemSettings::GetMetric(wxSYS_SCREEN_X);
      Integer screenHeight = wxSystemSettings::GetMetric(wxSYS_SCREEN_Y);
   #else
      Integer screenWidth;
      Integer screenHeight;
      GmatAppData::Instance()->GetMainFrame()->GetActualClientSize(&screenWidth, &screenHeight, true);
      // Since GmatMainFrame::GetActualClientSize() subtracts one, add one here (LOJ: 2012.07.23)
      screenWidth++;
      screenHeight++;
   #endif

   bool isMinimized = IsIconized(), isMaximized = IsMaximized();
   if (isMinimized)	
	  Iconize(false);
   else if (isMaximized)
	  Maximize(false);

   int tmpX = -1, tmpY = -1;
   int tmpW = -1, tmpH = -1;
   GetPosition(&tmpX, &tmpY);
   GetSize(&tmpW, &tmpH);
   Rvector upperLeft(2, ((Real) tmpX /(Real)  screenWidth), ((Real) tmpY /(Real)  screenHeight));
   Rvector childSize(2,  ((Real) tmpW /(Real)  screenWidth), ((Real) tmpH /(Real)  screenHeight));

   if (isMinimized)	
	  Iconize();
   else if (isMaximized)
	  Maximize();


   #ifdef DEBUG_PERSISTENCE
   // ======================= begin temporary ==============================
   MessageInterface::ShowMessage("*** Size of SCREEN %s is: width = %d, height = %d\n",
                                 mChildName.WX_TO_C_STRING, screenWidth, screenHeight);
   MessageInterface::ShowMessage("Position of View plot %s is: x = %d, y = %d\n",
                                 mChildName.WX_TO_C_STRING, tmpX, tmpY);
   MessageInterface::ShowMessage("Size of View plot %s is: width = %d, height = %d\n",
                                 mChildName.WX_TO_C_STRING, tmpW, tmpH);
   // ======================= end temporary ==============================
   #endif

   if ((mItemType == GmatTree::OUTPUT_REPORT)  ||
       (mItemType == GmatTree::OUTPUT_CCSDS_OEM_FILE ) ||
       (mItemType == GmatTree::OUTPUT_ORBIT_VIEW) ||
       (mItemType == GmatTree::OUTPUT_XY_PLOT) ||
       (mItemType == GmatTree::OUTPUT_GROUND_TRACK_PLOT)
       // We'll want to add the event reports eventually, but they are not subscriber based
       //|| (mItemType == GmatTree::EVENT_REPORT)
       )
   {
      GmatBase *obj = theGuiInterpreter->GetConfiguredObject(mChildName.c_str());
      
      #ifdef DEBUG_FUNCTION
      // Check if child name is the configured object name
      MessageInterface::ShowMessage
         ("GmatMdiChildFrame::SaveChildPositionAndSize() the child '%s' %s a "
          "configured object, obj = <%p>[%s]'%s'\n", mChildName.WX_TO_C_STRING,
          obj ? "is" : "is not", obj, obj ? obj->GetTypeName().c_str() : "NULL",
          obj ? obj->GetName().c_str() : "NULL");
      #endif
      
      if (!obj)
      {
         // Just return if child is not a configured subscriber,ie,
         // plotting from GMAT function (LOJ: 2015.06.26)
         #ifdef DEBUG_FUNCTION
         MessageInterface::ShowMessage
            ("**** WARNING **** GmatMdiChildFrame::SaveChildPositionAndSize() "
             "will not save position and size for unconfigured subscriber '%s'\n",
             mChildName.WX_TO_C_STRING);
         #endif
         return;
      }
      else if (!obj->IsOfType("Subscriber"))
      {
         #ifdef DEBUG_PERSISTENCE
         MessageInterface::ShowMessage
            ("**** WARNING **** GmatMdiChildFrame::SaveChildPositionAndSize() "
             "cannot not save position and size for non-subscriber '%s'\n",
             mChildName.WX_TO_C_STRING);
         #endif
         SubscriberException se;
         se.SetDetails("Cannot set position and size for non-subscriber '%s'");
         throw se;
      }
      
      Subscriber *sub = (Subscriber*) obj;
      
      #ifdef DEBUG_PERSISTENCE
         MessageInterface::ShowMessage("...... Now saving plot data to %s:\n", (sub->GetName()).c_str());
         MessageInterface::ShowMessage("       Upper left             = %12.10f   %12.10f\n", upperLeft[0], upperLeft[1]);
         MessageInterface::ShowMessage("       Size                   = %12.10f   %12.10f\n", childSize[0], childSize[1]);
         MessageInterface::ShowMessage("       RelativeZOrder         = %d\n", relativeZOrder);
      #endif
      sub->SetRvectorParameter(sub->GetParameterID("UpperLeft"), upperLeft);
      sub->SetRvectorParameter(sub->GetParameterID("Size"), childSize);
      sub->SetIntegerParameter(sub->GetParameterID("RelativeZOrder"), relativeZOrder);
      sub->SetBooleanParameter(sub->GetParameterID("Maximized"), isMaximized);
   }
   else if (mItemType == GmatTree::MISSION_TREE_UNDOCKED)
   {
      // get the config object
      wxFileConfig *pConfig;
      pConfig = (wxFileConfig *) GmatAppData::Instance()->GetPersonalizationConfig();
      std::stringstream location("");
      location << upperLeft[0] << " " << upperLeft[1];
      std::stringstream size("");
      size << childSize[0] << " " << childSize[1];
      pConfig->Write("/MissionTree/UpperLeft", location.str().c_str());
      pConfig->Write("/MissionTree/Size", size.str().c_str());
      pConfig->Write("/MissionTree/IsMaximized", isMaximized);
      pConfig->Write("/MissionTree/IsMinimized", isMinimized);
   }
   else if (mItemType == GmatTree::SCRIPT_FILE)
   {
      // get the config object
      wxFileConfig *pConfig;
      pConfig = (wxFileConfig *) GmatAppData::Instance()->GetPersonalizationConfig();
      std::stringstream location("");
      location << upperLeft[0] << " " << upperLeft[1];
      std::stringstream size("");
      size << childSize[0] << " " << childSize[1];
      pConfig->Write("/ScriptEditor/UpperLeft", location.str().c_str());
      pConfig->Write("/ScriptEditor/Size", size.str().c_str());
      pConfig->Write("/ScriptEditor/IsMaximized", isMaximized);
      pConfig->Write("/ScriptEditor/IsMinimized", isMinimized);
   }
}
Example #6
0
//------------------------------------------------------------------------------
// int main(int argc, char *argv[])
//------------------------------------------------------------------------------
int main(int argc, char *argv[])
{
   cout << "=-=-=-=-=-=-= TEST coordinate system ....." << endl;
   cout << " ------ number of objects instantiated = " << GmatBase::GetInstanceCount() << endl;
   
   cout.setf(ios::fixed);
   cout.precision(16);

   std::string eopFileName    = "/GMAT/dev/datafiles/EOPFiles/eopc04.62-now";
   std::string nutFileName    = "/GMAT/dev/datafiles/ITRF/NUTATION.DAT";
   std::string planFileName   = "/GMAT/dev/datafiles/ITRF/NUT85.DAT";
   std::string SLPFileName    = "/GMAT/dev/datafiles/mac/DBS_mn2000.dat";
   std::string DEFileName     = "/GMAT/dev/datafiles/DEascii/macp1941.405";
   std::string LeapFileName   = "/GMAT/dev/datafiles/tai-utcFiles/tai-utc.dat";
   
   cout << "\n==> First, test the AxisSystemFactory <==" << endl;
   AxisSystemFactory *asf = new AxisSystemFactory();
   cout << "AxisSystemFactory created .........." << endl;
   cout << " ------ number of objects instantiated = " << GmatBase::GetInstanceCount() << endl;
   std::string
      AXES_TYPE[13] =
   {
      "MJ2000Eq",
      "MJ2000Ec",
      "TOEEq",
      "TOEEc",
      "MOEEq",
      "MOEEc",
      "TODEq",
      "TODEc",
      "MODEq",
      "MODEc",
      "ObjectReferenced",
      "Equator",
      "BodyFixed",
   };
   
   AxisSystem *as;
   MJ2000EqAxes* mj;
   MJ2000EqAxes* mj2;
   //MJ2000EcAxes* mj2;
   std::string tmpStr = "";
   //for (int i = 0; i < 13 ; i++)
   for (int i = 0; i < 2 ; i++) // only do the first one, for now
   {
      tmpStr = AXES_TYPE[i] + "1";
      as = asf->CreateAxisSystem(AXES_TYPE[i], tmpStr);
      if (as) 
      {
         cout << "AxisSystem of type " << AXES_TYPE[i] << 
                  " was created with name " << tmpStr << endl;
         if (i > 1)       delete as; 
         else if (i == 0) mj   = (MJ2000EqAxes*) as;
         //else             mj2  = (MJ2000EcAxes*) as;
      }
      else    cout << "NO " << AXES_TYPE[i] << " AxisSystem created." << endl;
   }
   
   cout << " ------ number of objects instantiated = " << GmatBase::GetInstanceCount() << endl;
   if (mj)
   {
      cout << "MJ2000EqAxes object exists with name " << mj->GetName() << 
      " and type " << mj->GetTypeName() << endl;
   }
   mj2 = (MJ2000EqAxes*)(asf->CreateAxisSystem("MJ2000Eq","MJ2000Eq2"));
   if (mj2)
   {
      cout << "MJ20002 object exists with name " << mj2->GetName() << 
      " and type " << mj2->GetTypeName() << endl;
   }

   try
   {
      LeapSecsFileReader* ls     = new LeapSecsFileReader(LeapFileName);
      ls->Initialize();
      EopFile *eop               = new EopFile(eopFileName);
      eop->Initialize();
      ItrfCoefficientsFile* itrf = new ItrfCoefficientsFile(nutFileName, planFileName);
      itrf->Initialize();
      //bf->SetEopFile(eop);
      //bf->SetCoefficientsFile(itrf);
      TimeConverterUtil::SetLeapSecsFileReader(ls);
      TimeConverterUtil::SetEopFile(eop);
   }
   catch (BaseException &bbee)
   {
      cout << "ERROR !!!!! " << bbee.GetMessage() << endl;
   }
   
   SolarSystem*   ss;
   Star*          sol;
   Planet*        earth;
   Planet*        mars;
   Planet*        jupiter;
   Moon*          luna;
   std::string    j2000BN = "";
   SpacePoint*    j2000B  = NULL;
   try
   {
      cout << "\n==> Create the solar system <==" << endl;
      
      ss              = new SolarSystem("TheSS");
      cout << "solar system name = " << ss->GetName() << endl;
      cout << " ------ number of objects instantiated = " << GmatBase::GetInstanceCount() << endl;

      earth = (Planet*) ss->GetBody(SolarSystem::EARTH_NAME);
      cout << "earth name = " << earth->GetName() << endl;
      cout << "earth's type name is " << earth->GetTypeName() << endl;
      
      sol = (Star*) ss->GetBody(SolarSystem::SUN_NAME);
      cout << "sol name = " << sol->GetName() << endl;
      cout << "sol's type name is " << sol->GetTypeName() << endl;
      cout << " ------ number of objects instantiated = " << GmatBase::GetInstanceCount() << endl;

      luna = (Moon*) ss->GetBody(SolarSystem::MOON_NAME);
      cout << "luna name = " << luna->GetName() << endl;
      cout << "luna's type name is " << luna->GetTypeName() << endl;

      mars = (Planet*) ss->GetBody(SolarSystem::MARS_NAME);
      cout << "mars name = " << mars->GetName() << endl;
      cout << "mars's type name is " << mars->GetTypeName() << endl;

      jupiter = (Planet*) ss->GetBody(SolarSystem::JUPITER_NAME);
      cout << "jupiter name = " << jupiter->GetName() << endl;
      cout << "jupiter's type name is " << jupiter->GetTypeName() << endl;

      SlpFile* anSLP;
      DeFile*  aDE;
      try
      {
std::string SLPFileName = "/GMAT/dev/datafiles/mac/DBS_mn2000.dat";
std::string DEFileName  = "/GMAT/dev/datafiles/DEascii/macp1941.405";
         anSLP          = new SlpFile(SLPFileName);
         aDE            = new DeFile(Gmat::DE405,DEFileName);
         cout << "the SLP file is : " << anSLP->GetName() << endl;
         cout << "the DE file is : " << aDE->GetName() << endl;
      }
      catch (BaseException &be1)
      {
         cout << "ERROR with ephem file -> " << be1.GetMessage() << endl;
      }

      ss->SetSource(Gmat::SLP);
      ss->SetSourceFile(anSLP);
      //ss->SetSource(Gmat::DE_405);
      //ss->SetSourceFile(aDE);

      // set the j2000Body
      j2000BN = "Earth";
      j2000B  = earth;

      sol->SetJ2000BodyName(j2000BN);
      sol->SetJ2000Body(j2000B);
      earth->SetJ2000BodyName(j2000BN);
      earth->SetJ2000Body(j2000B);
      luna->SetJ2000BodyName(j2000BN);
      luna->SetJ2000Body(j2000B);
      mars->SetJ2000BodyName(j2000BN);
      mars->SetJ2000Body(j2000B);
      jupiter->SetJ2000BodyName(j2000BN);
      jupiter->SetJ2000Body(j2000B);
      
   }
   catch (GmatBaseException &ex)
   {
      cout << "Some kind of error ..........." << endl;
   }

   
   bool isOK = false;
   cout << "\n==> Now creating CoordinateSystems <==" << endl;
   CoordinateSystem* mj2000 = new CoordinateSystem("", "CoordSystemMJ2000");
   cout << " ------ number of objects instantiated = " << GmatBase::GetInstanceCount() << endl;
   mj2000->SetSolarSystem(ss);
   mj2000->SetStringParameter("OriginName","Earth"); 
   mj2000->SetStringParameter("J2000BodyName",j2000BN); 
   isOK = mj2000->SetRefObject(earth,Gmat::SPACE_POINT,"Earth");
   isOK = mj2000->SetRefObject(j2000B,Gmat::SPACE_POINT,j2000BN);
   isOK = mj2000->SetRefObject(mj, Gmat::AXIS_SYSTEM, mj->GetName());
   if (isOK) cout << "It seems to have been set OK!!!!!!!!!!!" << endl;
   else      cout << "ERROR setting axis system for coordinate system!!!!!" << endl;
   mj2000->Initialize();
   
   
   CoordinateSystem* mj20002 = new CoordinateSystem("", "CoordSystemMJ2000eq");
   cout << " ------ number of objects instantiated = " << GmatBase::GetInstanceCount() << endl;
   mj20002->SetSolarSystem(ss);
   mj20002->SetStringParameter("OriginName",SolarSystem::SUN_NAME); 
   mj20002->SetStringParameter("J2000BodyName",j2000BN);
   isOK = mj20002->SetRefObject(sol,Gmat::SPACE_POINT,SolarSystem::SUN_NAME);
   //isOK = mj20002->SetRefObject(mars,Gmat::SPACE_POINT,"Earth");
   isOK = mj20002->SetRefObject(j2000B,Gmat::SPACE_POINT,j2000BN);
   isOK = mj20002->SetRefObject(mj2, Gmat::AXIS_SYSTEM, mj2->GetName());
   if (isOK) cout << "It seems to have been set OK!!!!!!!!!!!" << endl;
   else      cout << "ERROR setting axis system for coordinate system!!!!!" << endl;
   mj20002->Initialize();
   
   try
   {
      cout << "Now checking CoordinateSystems' AxisSystems ..." << endl;
      GmatBase *mjObj = mj2000->GetRefObject(Gmat::AXIS_SYSTEM, mj->GetName());
      if (mjObj) 
      {
         cout << "mj2000 has a pointer to the axis system " << mjObj->GetName() << 
         " of type " << mjObj->GetTypeName() << endl;
      }
      else       cout << "ERROR -  no pointer to the axis system ????????" << endl;
      GmatBase *mjObj2 = mj20002->GetRefObject(Gmat::AXIS_SYSTEM, mj2->GetName());
      if (mjObj2) 
      {
         cout << "mj2000ec has a pointer to the axis system " << mjObj2->GetName() << 
         " of type " << mjObj2->GetTypeName() << endl;
      }
      else       cout << "ERROR -  no pointer to the axis system ????????" << endl;
   }
   catch (BaseException &be)
   {
      cout << "ERROR ------------- : " << be.GetMessage() << endl;
   }
   
   CoordinateConverter *cc = new CoordinateConverter();
   //cc->SetJ2000BodyName("Earth");
   //cc->SetJ2000Body(earth);

   //Rvector6 theState(15999.99999999998,0.0,0.0,
   //                  0.0, 3.8662018270519716, 3.8662018270519711);
   Rvector6 theState(18407337.2437560,146717552.364272,2436998.6080801622,
                     -29.85775713588113, 3.7988731566283533, -0.0883535323140749);
   Rvector6 outState;
   
   A1Mjd atTime1;
   Real ut1_utc = 0.456647;
   Real atTime = atTime1.UtcMjdToA1Mjd(ModifiedJulianDate(2012,1,1,0,0,ut1_utc));
   A1Mjd testTime(atTime);
   cout << "The test time is " << testTime.Get() << endl;
   cout << "The test Rvector6 is " << theState << endl;
   
   cout << "About to try to convert!!!!!" << endl;
   
   try
   {
      cc->Convert(testTime,theState, mj2000, outState, mj20002);
      cout << "The output state is : " << outState << endl;
   }
   catch (BaseException &cse)
   {
      cout << "ERROR: " << cse.GetMessage() << endl;
   }
   
   
   cout << "Now delete SolarSystem ............." << endl;
   delete ss;
   cout << "Now delete CoordinateConverter ............." << endl;
   delete cc;
   cout << "Now delete CoordinateSystem (and its AxisSystem) ............." << endl;
   delete mj2000;
   cout << "Now delete other CoordinateSystem (and its AxisSystem) ............." << endl;
   delete mj20002;
   //cout << "Now delete AxisSystem ............." << endl;
   //delete mj;
   cout << " ------ number of objects instantiated = " << GmatBase::GetInstanceCount() << endl;
   
   cout << "Now delete everything else ............." << endl;
   delete asf;
   cout << " ------ number of objects instantiated = " << GmatBase::GetInstanceCount() << endl;
   
   cout << "=-=-=-=-=-=-= END TEST coordinate system ....." << endl;

}
Example #7
0
//-------------------------------------------------------------------------
// This function is used to verify GroundStation's added hardware.
//
// return true if there is no error, false otherwise.
//-------------------------------------------------------------------------
// made changes by Tuan Nguyen
bool GroundStation::VerifyAddHardware()
{
   Gmat::ObjectType type;
   std::string subTypeName;
   GmatBase* obj;

   // 1. Verify all hardware in hardwareList are not NULL:
   for(ObjectArray::iterator i= hardwareList.begin(); i != hardwareList.end(); ++i)
   {
	   obj = (*i);
	   if (obj == NULL)
	   {
		   MessageInterface::ShowMessage("***Error***:One element of hardwareList = NULL\n");
		   return false;
	   }
   }

   // 2. Verify primary antenna to be in hardwareList:
   // 2.1. Create antenna list from hardwareList for searching:
   // extract all antenna from hardwareList and store to antennaList
   ObjectArray antennaList;
   for(ObjectArray::iterator i= hardwareList.begin(); i != hardwareList.end(); ++i)
   {
	  obj = (*i);
      subTypeName = obj->GetTypeName();
	  if (subTypeName == "Antenna")
		 antennaList.push_back(obj);
   }

   // 2.2. Verify primary antenna of Receiver, Transmitter, and Transponder:
   GmatBase* antenna;
   GmatBase* primaryAntenna;
   std::string primaryAntennaName;
   bool verify = true;
   for(ObjectArray::iterator i= hardwareList.begin(); i != hardwareList.end(); ++i)
   {
	  obj = (*i);
	  type = obj->GetType();
	  if (type == Gmat::HARDWARE)
	  {
         subTypeName = obj->GetTypeName();
         if ((subTypeName == "Transmitter")||
        	 (subTypeName == "Receiver")||
        	 (subTypeName == "Transponder"))
         {
    		 // Get primary antenna:
    		 primaryAntennaName = obj->GetRefObjectName(Gmat::HARDWARE);
    		 primaryAntenna = obj->GetRefObject(Gmat::HARDWARE,primaryAntennaName);

    		 bool check;
    		 if (primaryAntenna == NULL)
    		 {
    			 MessageInterface::ShowMessage
					 ("***Error***:primary antenna of %s in %s's AddHardware list is NULL \n",
					  obj->GetName().c_str(), this->GetName().c_str());
    			 check = false;
    		 }
    		 else
    		 {
    			 // Check primary antenna of transmitter, receiver, or transponder is in antenna list:
    			 check = false;
    			 for(ObjectArray::iterator j= antennaList.begin(); j != antennaList.end(); ++j)
    			 {
    				 antenna = (*j);
    				 if (antenna == primaryAntenna)
    				 {
    					 check = true;
    					 break;
    				 }
    				 else if (antenna->GetName() == primaryAntenna->GetName())
    				 {
    					 MessageInterface::ShowMessage
							 ("Primary antenna %s of %s is a clone of an antenna in %s's AddHardware\n",
							  primaryAntenna->GetName().c_str(), obj->GetName().c_str(), this->GetName().c_str());
    				 }
    			 }
            	 if (check == false)
            	 {
            		 // Display error message:
            		 MessageInterface::ShowMessage
							 ("***Error***:primary antenna of %s is not in %s's AddHardware\n",
							  obj->GetName().c_str(), this->GetName().c_str());
            	 }

        	 }

        	 verify = verify && check;
         }
	  }
   }

   return verify;
}