当前位置: 首页>>代码示例>>C++>>正文


C++ GmatBase类代码示例

本文整理汇总了C++中GmatBase的典型用法代码示例。如果您正苦于以下问题:C++ GmatBase类的具体用法?C++ GmatBase怎么用?C++ GmatBase使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了GmatBase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: OnSolverSelection

//------------------------------------------------------------------------------
// void VaryPanel::OnSolverSelection(wxCommandEvent &event)
//------------------------------------------------------------------------------
void VaryPanel::OnSolverSelection(wxCommandEvent &event)
{
   #ifdef DEBUG_VARYPANEL_SOLVER
   MessageInterface::ShowMessage("VaryPanel::OnSolverSelection() entered\n");
   #endif
   
   solverName = mSolverComboBox->GetStringSelection().c_str();
   
   GmatBase *slvr = theGuiInterpreter->GetConfiguredObject(solverName);
   
   #ifdef DEBUG_VARYPANEL_SOLVER
   MessageInterface::ShowMessage
      ("   solverName='%s', solver=<%p>'%s'\n", solverName.c_str(), slvr,
       slvr ? slvr->GetName().c_str() : "NULL");
   #endif
   
   if (slvr == NULL)
   {
      MessageInterface::PopupMessage(Gmat::ERROR_, "The solver " + solverName + " is NULL");
   }
   else
   {
      solverChanged = true;
      SetControlEnabling(slvr);
      EnableUpdate(true);
   }
}
开发者ID:,项目名称:,代码行数:30,代码来源:

示例2: BufferObjects

//------------------------------------------------------------------------------
void EstimationStateManager::BufferObjects(ObjectArray *buffer)
{
#ifdef DEBUG_CLONING
   MessageInterface::ShowMessage("EstimationStateManager::BufferObjects(%p) "
         "called\n", buffer);
#endif

   GmatBase *clone;
   for (UnsignedInt i = 0; i < estimationObjectClones.size(); ++i)
      delete estimationObjectClones[i];
   estimationObjectClones.clear();

   if (buffer != NULL)
   {
      for (UnsignedInt i = 0; i < buffer->size(); ++i)
         delete (*buffer)[i];
      buffer->clear();
   }

   for (UnsignedInt i = 0; i < objects.size(); ++i)
   {
      clone = objects[i]->Clone();
      estimationObjectClones.push_back(clone);
      if (buffer != NULL)
         buffer->push_back(clone->Clone());
   }
}
开发者ID:,项目名称:,代码行数:28,代码来源:

示例3: tank

//------------------------------------------------------------------------------
// void DecrementMass()
//------------------------------------------------------------------------------
void ImpulsiveBurn::DecrementMass()
{
   #ifdef DEBUG_IMPBURN_DECMASS
   MessageInterface::ShowMessage
      (wxT("ImpulsiveBurn::DecrementMass() <%p>'%s' entered. There are %d tank(s)\n"),
       this, instanceName.c_str(), tankMap.size());
   #endif
   totalTankMass = spacecraft->GetRealParameter(wxT("TotalMass"));
   
   #ifdef DEBUG_IMPBURN_DECMASS
   MessageInterface::ShowMessage
      (wxT("   Now decrementing mass\n      before maneuver totalTankMass = %f\n"),
       totalTankMass);
   #endif
   
   Real dv = sqrt( deltaV[0]*deltaV[0] + deltaV[1]*deltaV[1] + deltaV[2]*deltaV[2]);
   deltaTankMass = totalTankMass * (exp(-dv * 1000/(isp * gravityAccel)) - 1.0);
   
   #ifdef DEBUG_IMPBURN_DECMASS
   MessageInterface::ShowMessage
      (wxT("       after maneuver deltaTankMass = %f\n"), deltaTankMass);
   #endif
   
   totalTankMass = totalTankMass + deltaTankMass;
   
   #ifdef DEBUG_IMPBURN_DECMASS
   MessageInterface::ShowMessage
      (wxT("       after maneuver totalTankMass = %f\n"), totalTankMass);
   #endif

   // Update tank mass
   if (!tankMap.empty())
   {
      for (ObjectMap::iterator tankPos = tankMap.begin();
           tankPos != tankMap.end(); ++tankPos)
      {
         GmatBase *currTank = tankPos->second;

         #ifdef DEBUG_IMPBURN_DECMASS
         MessageInterface::ShowMessage
            (wxT("       Decrementing tank mass for <%p>'%s'\n"), currTank,
             (tankPos->first).c_str());
         #endif
         Integer paramID = currTank->GetParameterID(wxT("FuelMass"));
         Real oldTankMass = currTank->GetRealParameter(paramID);
         Real currTankMass = oldTankMass + deltaTankMass;
         #ifdef DEBUG_IMPBURN_DECMASS
         MessageInterface::ShowMessage
            (wxT("       it was %f, it is now %f\n"), oldTankMass, currTankMass);
         #endif
         //@todo What should we do if decremented tank mass is below zero?
         currTank->SetRealParameter(paramID, currTankMass);
      }
   }
   #ifdef DEBUG_IMPBURN_DECMASS
   MessageInterface::ShowMessage
      (wxT("ImpulsiveBurn::DecrementMass() <%p>'%s' returning\n"), this, GetName().c_str());
   #endif
}
开发者ID:,项目名称:,代码行数:62,代码来源:

示例4: MapObjectsToSTM

//------------------------------------------------------------------------------
bool EstimationStateManager::MapObjectsToSTM()
{
   bool retval = true;

   // Fill in the STM based on the objects that comprise the state vector
   GmatBase* obj;
   Integer elementId; //, elementLength;
   for (UnsignedInt h = 0; h < stateMap.size(); ++h)
   {
      obj = stateMap[h]->object;
      if (stateMap[h]->subelement == 1)
      {
         elementId = stateMap[h]->parameterID;
//         elementLength = stateMap[h]->length;

         bool hasDstm = obj->HasDynamicParameterSTM(elementId);

         #ifdef DEBUG_STM_MAPPING
            MessageInterface::ShowMessage("Prepping for STM; element %s for "
                  "object %s has ID %d and length %d, and %s a dynamic STM "
                  "contribution\n", stateMap[h]->elementName.c_str(),
                  obj->GetName().c_str(), elementId, elementLength,
                  (hasDstm ? "has" : "does not have"));
         #endif

         if (hasDstm)
         {
            const Rmatrix* dstm = obj->GetParameterSTM(elementId);
            Integer stmSize = dstm->GetNumRows();
            // Fill in the master stm with the current data
            for (Integer i = 0; i < stmSize; ++i)
               for (Integer j = 0; j < stmSize; ++j)
                  stm(h+i, h+j) = (*dstm)(i,j);
         }

      }
   }

   #ifdef DEBUG_STM_MAPPING
      MessageInterface::ShowMessage("Loaded object STM's; esm STM now contains\n");
      for (Integer i = 0; i < stateSize; ++i)
      {
         for (Integer j = 0; j < stateSize; ++j)
            MessageInterface::ShowMessage("   %.12lf", stm(i,j));
         MessageInterface::ShowMessage("\n");
      }
      MessageInterface::ShowMessage("\n");
   #endif

   return retval;
}
开发者ID:,项目名称:,代码行数:52,代码来源:

示例5: while

//------------------------------------------------------------------------------
PropSetup *GetFirstPropagator(GmatCommand *cmd)
{
   static PropSetup *retval = NULL;
   GmatCommand *current = cmd;

   #ifdef DEBUG_ODE_SEARCH
      extraMsg = "Commands checked:\n";
   #endif
   while (current != NULL)
   {
      #ifdef DEBUG_ODE_SEARCH
            extraMsg += "   '" + current->GetTypeName() + "'\n";
      #endif
      if (current->GetTypeName() == "Propagate")
      {
         try
         {
            // Set all of the internal connections
//               current->TakeAction("PrepareToPropagate");
            current->Execute();
         }
         catch (BaseException &ex)
         {
            lastMsg = ex.GetFullMessage();
         }
         #ifdef DEBUG_ODE_SEARCH
            extraMsg += "      Checking in this command\n";
         #endif
         GmatBase *obj = current->GetRefObject(Gmat::PROP_SETUP, "", 0);

         #ifdef DEBUG_ODE_SEARCH
            if (obj != NULL)
               extraMsg += "      Found an object of type PROPSETUP\n";
            else
               extraMsg += "      Propagate command returns NULL PROPSETUP\n";
         #endif

         if (obj->IsOfType("PropSetup"))
         {
            retval = (PropSetup*)(obj);
            break;
         }
      }

      current = current->GetNext();
   }

   return retval;
}
开发者ID:,项目名称:,代码行数:50,代码来源:

示例6: wxT

//------------------------------------------------------------------------------
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
}
开发者ID:,项目名称:,代码行数:46,代码来源:

示例7: stm

//------------------------------------------------------------------------------
bool EstimationStateManager::MapSTMToObjects()
{
   bool retval = true;

   #ifdef DEBUG_STM_MAPPING
      MessageInterface::ShowMessage("Setting object STM's to\n");
      for (Integer i = 0; i < stateSize; ++i)
      {
         for (Integer j = 0; j < stateSize; ++j)
            MessageInterface::ShowMessage("   %.12lf", stm(i,j));
         MessageInterface::ShowMessage("\n");
      }
      MessageInterface::ShowMessage("\n");
   #endif

   // Fill in the STM based on the objects that comprise the state vector
   GmatBase* obj;
   Integer elementId; //, elementLength;
   for (UnsignedInt h = 0; h < stateMap.size(); ++h)
   {
      obj = stateMap[h]->object;
      if (stateMap[h]->subelement == 1)
      {
         elementId = stateMap[h]->parameterID;
//         elementLength = stateMap[h]->length;

         bool hasDstm = obj->HasDynamicParameterSTM(elementId);

         if (hasDstm)
         {
            Rmatrix* dstm = obj->GetParameterSTM(elementId);
            Integer stmSize = dstm->GetNumRows();
            // Fill in the object stm's from the master stm
            for (Integer i = 0; i < stmSize; ++i)
               for (Integer j = 0; j < stmSize; ++j)
                  (*dstm)(i,j) = stm(h+i, h+j);
         }

      }
   }

   return retval;
}
开发者ID:,项目名称:,代码行数:44,代码来源:

示例8: Initialize

//------------------------------------------------------------------------------
bool EndFiniteBurn::Initialize()
{
   bool retval = GmatCommand::Initialize();
   GmatBase *mapObj;
   
   if (retval)
   {
      // Look up the maneuver object
      if ((mapObj = FindObject(burnName)) == NULL) 
         throw CommandException("EndFiniteBurn: Unknown finite burn \"" +
               burnName + "\"");
      if (mapObj->IsOfType("FiniteBurn") == false)
         throw CommandException("EndFiniteBurn: " + (burnName) + " is not a "
               "FiniteBurn");
      maneuver = (FiniteBurn*)mapObj;
      
      // Find all of the spacecraft
      StringArray::iterator scName;
      Spacecraft *sc;
      sats.clear();
      for (scName = satNames.begin(); scName != satNames.end(); ++scName)
      {
         if ((mapObj = FindObject(*scName)) == NULL) 
            throw CommandException("EndFiniteBurn: Unknown SpaceObject \"" +
                  (*scName) + "\"");
         
         if (mapObj->IsOfType(Gmat::SPACECRAFT) == false)
            throw CommandException("EndFiniteBurn: " + (*scName) +
                  " is not a Spacecraft");
         sc = (Spacecraft*)mapObj;
         sats.push_back(sc);
      }
   }
   
   thrustName = burnName + "_FiniteThrust";
   #ifdef DEBUG_END_MANEUVER
      MessageInterface::ShowMessage
         ("EndFiniteBurn initialized with thrust force named \"%s\"\n", 
          thrustName.c_str());
   #endif
   
   return isInitialized;
}
开发者ID:,项目名称:,代码行数:44,代码来源:

示例9: Initialize

//------------------------------------------------------------------------------
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;
}
开发者ID:rockstorm101,项目名称:GMAT,代码行数:43,代码来源:PenDown.cpp

示例10: FindObject

//------------------------------------------------------------------------------
bool Set::Initialize()
{
   bool retval = GmatCommand::Initialize();
   
   target = FindObject(targetName);
   if (target == NULL)
      throw CommandException("The Set command could not find the target "
            "object \"" + targetName + "\" needed to initialize");

   GmatBase *obj = FindObject(interfaceName);
   if (obj == NULL)
      throw CommandException("The Set command could not find the interface "
            "object \"" + interfaceName + "\" needed to initialize");

   if (obj->IsOfType("DataInterface"))
      theInterface = (DataInterface*)obj;
   else
      throw CommandException("The object \"" + interfaceName +
               "\" is not a FileInterface object."); 


   // If specific data elements are requested, warn if not in the reader
   if (!loadAll)
   {
      StringArray allKeywords = 
         theInterface->GetStringArrayParameter("SupportedFields");
      for (UnsignedInt i = 0; i < selections.size(); ++i)
         if (find(allKeywords.begin(), allKeywords.end(), selections[i]) ==
               allKeywords.end())
            MessageInterface::ShowMessage("*** Warning ***: The data keyword "
                  "\"%s\" is not a recognized keyword in the data reader "
                  "\"tvhf\" on the line:\n%s\n", selections[i].c_str(), 
                  generatingString.c_str());
   }
   
   return retval;
}
开发者ID:rockstorm101,项目名称:GMAT,代码行数:38,代码来源:Set.cpp

示例11: SetProperty

//------------------------------------------------------------------------------
bool PropagationStateManager::SetProperty(std::string propName, Integer index)
{
   #ifdef DEBUG_STATE_CONSTRUCTION
      MessageInterface::ShowMessage("Entered SetProperty(%s, %d)\n",
            propName.c_str(), index);
   #endif

   if ((index < 0) || (index >= (Integer)objects.size()))
      throw PropagatorException("Index out of bounds specifying a prop object "
            "in a propagation state manager\n");

   GmatBase *obj = objects[index];

   if (obj)
   {
      // Validate that the property can be propagated
      if (obj->SetPropItem(propName) == Gmat::UNKNOWN_STATE)
         throw PropagatorException(propName
               + " is not a known propagation parameter on "
               + obj->GetName());
      if (find(elements[obj]->begin(), elements[obj]->end(), propName) ==
            elements[obj]->end())
         elements[obj]->push_back(propName);

      #ifdef DEBUG_STATE_CONSTRUCTION
         MessageInterface::ShowMessage("Current property List:\n");
            for (StringArray::iterator i = elements[obj]->begin();
                  i != elements[obj]->end(); ++i)
               MessageInterface::ShowMessage("   %s\n", i->c_str());
      #endif

      return true;
   }

   return false;
}
开发者ID:,项目名称:,代码行数:37,代码来源:

示例12: VerifyAddHardware

//-------------------------------------------------------------------------
// 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;
}
开发者ID:rockstorm101,项目名称:GMAT,代码行数:99,代码来源:GroundStation.cpp

示例13: catch

//------------------------------------------------------------------------------
PropSetup *GetPropagator(GmatCommand **cmd)
{
   PropSetup *retval = NULL;
   static Integer setupIndex = 0;

   if ((*cmd) != NULL)
   {
      bool findNextPropagate = false;
      std::string currentType = (*cmd)->GetTypeName();

      if ((currentType == "Propagate") && (setupIndex > 0))
      {
         try
         {
            if ((*cmd)->GetRefObject(Gmat::PROP_SETUP, "", setupIndex) == NULL)
            {
               findNextPropagate = true;
               (*cmd) = (*cmd)->GetNext();
               setupIndex = 0;
            }
         }
         catch (BaseException &)
         {
            findNextPropagate = true;
            (*cmd) = (*cmd)->GetNext();
         }
      }
      else
         findNextPropagate = true;

      if (findNextPropagate)
      {
         // Find the next propagate command
         setupIndex = 0;
         if ((*cmd) != NULL)
         {
            while ((*cmd)->GetTypeName() != "Propagate")
            {
               (*cmd) = (*cmd)->GetNext();
               if ((*cmd) == NULL)
                  break;
            }
         }
      }

      if ((*cmd) != NULL)
      {
         #ifdef DEBUG_INTERFACE_FROM_MATLAB
            fprintf(fp, "Current <%p>: %s; SetupIndex %d\n", (*cmd),
                  (*cmd)->GetGeneratingString(Gmat::NO_COMMENTS).c_str(),
                  setupIndex);
         #endif
         GmatBase *obj = NULL;
         try
         {
            if (setupIndex == 0)
            {
               try
               {
                  // Set all of the internal connections
      //               current->TakeAction("PrepareToPropagate");
                  (*cmd)->Execute();
               }
               catch (BaseException &ex)
               {
                  lastMsg = ex.GetFullMessage();
               }
            }

            obj = (*cmd)->GetRefObject(Gmat::PROP_SETUP, "", setupIndex);
         }
         catch (BaseException *)
         {
            obj = NULL;
         }

         if (obj == NULL)
         {
            (*cmd) = (*cmd)->GetNext();
            #ifdef DEBUG_INTERFACE_FROM_MATLAB
               fprintf(fp, "obj was NULL; new command is <%p>: %s\n", (*cmd),
                     (*cmd)->GetGeneratingString(Gmat::NO_COMMENTS).c_str());
            #endif
            setupIndex = 0;
         }
         else
         {
            if (obj->IsOfType(Gmat::PROP_SETUP))
               retval = (PropSetup*)obj;
            ++setupIndex;
         }
      }
   }

   return retval;
}
开发者ID:,项目名称:,代码行数:97,代码来源:

示例14: tank

//------------------------------------------------------------------------------
// void DecrementMass()
//------------------------------------------------------------------------------
void ImpulsiveBurn::DecrementMass(bool backwards)
{
   #ifdef DEBUG_IMPBURN_DECMASS
   MessageInterface::ShowMessage
      ("ImpulsiveBurn::DecrementMass() <%p>'%s' entered. There are %d tank(s)\n",
       this, instanceName.c_str(), tankMap.size());
   #endif
   totalTankMass = spacecraft->GetRealParameter("TotalMass");
   
   #ifdef DEBUG_IMPBURN_DECMASS
   MessageInterface::ShowMessage
      ("   Now decrementing mass\n      before maneuver totalTankMass = %f\n",
       totalTankMass);
   #endif
   
   Real dv = sqrt( deltaV[0]*deltaV[0] + deltaV[1]*deltaV[1] + deltaV[2]*deltaV[2]);
   if (!backwards)
      deltaTankMass = totalTankMass * (exp(-dv * 1000/(isp * gravityAccel)) - 1.0);
   else
      deltaTankMass = totalTankMass * (exp(dv * 1000/(isp * gravityAccel)) - 1.0);
   
   #ifdef DEBUG_IMPBURN_DECMASS
   MessageInterface::ShowMessage
      ("       after maneuver deltaTankMass = %f\n", deltaTankMass);
   #endif
   
   totalTankMass = totalTankMass + deltaTankMass;
   
   #ifdef DEBUG_IMPBURN_DECMASS
   MessageInterface::ShowMessage
      ("       after maneuver totalTankMass = %f\n", totalTankMass);
   #endif

   // Update tank mass
   if (!tankMap.empty())
   {
      if (tankMap.size() > 1)
         throw BurnException("The ImpulsiveBorn object " + instanceName +
               " is configured to draw mass from multiple tanks, but only one "
               "tank is supported in the current implementation.");

      // This code is set up to draw from multiple tanks, but the amount drawn
      // is not calculated to draw proportionally.  Instead, it reduces each
      // tank by deltaTankMass.  We need to check this code before enabling
      // mass reduction from multiple tanks in a single impulsive burn.
      for (ObjectMap::iterator tankPos = tankMap.begin();
           tankPos != tankMap.end(); ++tankPos)
      {
         GmatBase *currTank = tankPos->second;

         #ifdef DEBUG_IMPBURN_DECMASS
         MessageInterface::ShowMessage
            ("       Decrementing tank mass for <%p>'%s'\n", currTank,
             (tankPos->first).c_str());
         #endif
         Integer paramID = currTank->GetParameterID("FuelMass");
         Real oldTankMass = currTank->GetRealParameter(paramID);
         Real currTankMass = oldTankMass + deltaTankMass;
         #ifdef DEBUG_IMPBURN_DECMASS
         MessageInterface::ShowMessage
            ("       it was %f, it is now %f\n", oldTankMass, currTankMass);
         #endif
         //@todo What should we do if decremented tank mass is below zero?
         currTank->SetRealParameter(paramID, currTankMass);
      }
   }
   else
      throw BurnException("Impulsive Burn " + instanceName +
            " is set to decrement mass from a tank named "  + tankNames[0] +
            ", but the Spacecraft " + spacecraft->GetName() +
            " does not have the selected fuel tank.");

   #ifdef DEBUG_IMPBURN_DECMASS
   MessageInterface::ShowMessage
      ("ImpulsiveBurn::DecrementMass() <%p>'%s' returning\n", this, GetName().c_str());
   #endif
}
开发者ID:rockstorm101,项目名称:GMAT,代码行数:80,代码来源:ImpulsiveBurn.cpp

示例15: CommandException

//------------------------------------------------------------------------------
bool RunSimulator::Initialize()
{
   bool retval = false;

   // First set the simulator object
   if (solverName == "")
      throw CommandException("Cannot initialize RunSimulator command -- the "
            "simulator name is not specified.");

   // Clear the old clone if it was set
   if (theSimulator != NULL)
      delete theSimulator;

   GmatBase *simObj = FindObject(solverName);
   if (simObj == NULL)
      throw CommandException("Cannot initialize RunSimulator command -- the "
            "simulator named " + solverName + " cannot be found.");

   if (!simObj->IsOfType("Simulator"))
      throw CommandException("Cannot initialize RunSimulator command -- the "
            "object named " + solverName + " is not a simulator.");

   theSimulator = (Simulator*)(simObj->Clone());

   // Set the streams for the measurement manager
   MeasurementManager *measman = theSimulator->GetMeasurementManager();
   StringArray streamList = measman->GetStreamList();
   for (UnsignedInt ms = 0; ms < streamList.size(); ++ms)
   {
      GmatBase *obj = FindObject(streamList[ms]);
      if (obj != NULL)
      {
         if (obj->IsOfType(Gmat::DATASTREAM))
         {
            DataFile *df = (DataFile*)obj;
            measman->SetStreamObject(df);
         }
      }
      else
         throw CommandException("Did not find the object named " +
               streamList[ms]);
   }

   // Find the event manager and store its pointer
   if (triggerManagers == NULL)
      throw CommandException("The Event Manager pointer was not set on the "
            "RunSimulator command");

   for (UnsignedInt i = 0; i < triggerManagers->size(); ++i)
   {
      #ifdef DEBUG_INITIALIZATION
         MessageInterface::ShowMessage("RunSimulator has an TriggerManager of "
               "type %s, id %d\n",
               (*triggerManagers)[i]->GetTriggerTypeString().c_str(),
               (*triggerManagers)[i]->GetTriggerType());
      #endif
      if ((*triggerManagers)[i]->GetTriggerType() == Gmat::EVENT)
      {
         eventMan = (EventManager*)(*triggerManagers)[i];
         #ifdef DEBUG_INITIALIZATION
            MessageInterface::ShowMessage("RunSimulator has an EventManager of "
                  "type %s\n", eventMan->GetTriggerTypeString().c_str());
         #endif
      }
   }
   if (eventMan == NULL)
      throw CommandException("The EventManager pointer was not set on the "
            "RunSimulator command");

   // Next comes the propagator
   PropSetup *obj = theSimulator->GetPropagator();

   #ifdef DEBUG_INITIALIZATION
      MessageInterface::ShowMessage("Propagator at address %p ", obj);
      if (obj != NULL)
         MessageInterface::ShowMessage("is named %s\n",
               obj->GetName().c_str());
      else
         MessageInterface::ShowMessage("is not yet set\n");
   #endif

   if (obj != NULL)
   {
      if (obj->IsOfType(Gmat::PROP_SETUP))
      {
         PropSetup *ps = (PropSetup*)obj->Clone();

         // RunSimulator only manages one PropSetup.  If that changes, so
         // does this code
         if (propagators.size() > 0)
         {
            for (std::vector<PropSetup*>::iterator pp = propagators.begin();
                  pp != propagators.end(); ++pp)
            {
               delete (*pp);
            }
            propagators.clear();
            p.clear();
            fm.clear();
//.........这里部分代码省略.........
开发者ID:ddj116,项目名称:gmat,代码行数:101,代码来源:RunSimulator.cpp


注:本文中的GmatBase类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。