コード例 #1
0
//------------------------------------------------------------------------------
// bool Execute()
//------------------------------------------------------------------------------
bool CallFunction::Execute()
{
   bool status = false;
   
   if (mFunction == NULL)
      throw CommandException(wxT("Function is not defined for CallFunction"));
   
   #ifdef DEBUG_TRACE
   static Integer callCount = 0;
   callCount++;      
   clock_t t1 = clock();
   MessageInterface::ShowMessage
      (wxT("=== CallFunction::Execute() entered, '%s' Count = %d\n"),
       GetGeneratingString(Gmat::NO_COMMENTS).c_str(), callCount);
   #endif
   
   #ifdef DEBUG_CALL_FUNCTION_EXEC
      MessageInterface::ShowMessage
         (wxT("CallFunction::Execute() this=<%p> entered, command = '%s'\n   ")
          wxT("function type is '%s', callingFunction is '%s'\n"), this,
          GetGeneratingString(Gmat::NO_COMMENTS).c_str(), mFunction->GetTypeName().c_str(),
          callingFunction? (callingFunction->GetFunctionName()).c_str() : wxT("NULL"));
      #ifdef DEBUG_OBJECT_MAP
      ShowObjectMaps(wxT("object maps at the start"));
      #endif
   #endif
      
   return status;
}
コード例 #2
0
//------------------------------------------------------------------------------
// bool Initialize()
//------------------------------------------------------------------------------
bool CallFunction::Initialize()
{
   #ifdef DEBUG_CALL_FUNCTION_INIT
      MessageInterface::ShowMessage
         (wxT("CallFunction::Initialize() this=<%p> entered, command = '%s'\n   ")
          wxT("function type is '%s', callingFunction is '%s'\n"), this,
          GetGeneratingString(Gmat::NO_COMMENTS).c_str(), mFunction->GetTypeName().c_str(),
          callingFunction? (callingFunction->GetFunctionName()).c_str() : wxT("NULL"));
   #endif
   
   GmatCommand::Initialize();
   
   #ifdef DEBUG_OBJECT_MAP
   ShowObjectMaps(wxT("In CallFunction::Initialize()"));
   #endif
   
   isGmatFunction = false;
   isMatlabFunction = false;
   
   bool rv = true;  // Initialization return value
   if (mFunction == NULL)
      throw CommandException(wxT("CallFunction::Initialize() the function pointer is NULL"));
   
   if (mFunction->GetTypeName() == wxT("GmatFunction"))
      isGmatFunction = true;
   else if (mFunction->GetTypeName() == wxT("MatlabFunction"))
      isMatlabFunction = true;
   
   if (!isGmatFunction && !isMatlabFunction)
      throw CommandException
         (wxT("CallFunction::Initialize() the function is neither GmatFunction nor MatlabFunction"));
   
   mFunctionPathAndName = mFunction->GetFunctionPathAndName();
   wxString fname = GmatFileUtil::ParseFileName(mFunctionPathAndName);
   if (fname == wxT(""))
      mFunctionPathAndName += mFunctionName;
   
   #ifdef DEBUG_CALL_FUNCTION_INIT
   MessageInterface::ShowMessage
      (wxT("CallFunction::Initialize() returning %d, fname='%s', mFunctionName='%s', ")
       wxT("mFunctionPathAndName='%s'\n"), rv, fname.c_str(), mFunctionName.c_str(),
       mFunctionPathAndName.c_str());
   #endif
   
   return rv;
}
コード例 #3
0
//------------------------------------------------------------------------------
bool BeginFiniteBurn::SetRefObjectName(const Gmat::ObjectType type, 
                                       const std::string &name)
{
   switch (type)
   {
      case Gmat::SPACECRAFT:
         #ifdef DEBUG_BEGIN_MANEUVER
            MessageInterface::ShowMessage
               ("Setting BeginFiniteBurn reference spacecraft \"%s\"\n", 
                name.c_str());
         #endif
         if (find(satNames.begin(), satNames.end(), name) != satNames.end())
         {
            MessageInterface::ShowMessage("In the BeginFiniteBurn command %s, "
                  "the spacecraft %s is set more than once.  Only one instance "
                  "will be used.\n",
                  GetGeneratingString(Gmat::NO_COMMENTS).c_str(), name.c_str());
            return true;
         }
         satNames.push_back(name);
         if (satNames.size() > 1)
            throw CommandException("BeginFiniteBurn commands do not currently "
                  "support multiple Spacecraft; please toggle finite burns on "
                  "one spacecraft at a time.");
         return true;
      
      case Gmat::FINITE_BURN:
         #ifdef DEBUG_BEGIN_MANEUVER
            MessageInterface::ShowMessage
               ("Setting BeginFiniteBurn reference burn \"%s\"\n",
                     name.c_str());
         #endif
         burnName = name;
         return true;
         
      default:
         #ifdef DEBUG_BEGIN_MANEUVER
            MessageInterface::ShowMessage
               ("BeginFiniteBurn reference object \"%s\" not set!\n", 
                name.c_str());
         #endif
         break;
   }
   
   return GmatCommand::SetRefObjectName(type, name);
}
コード例 #4
0
//------------------------------------------------------------------------------
// void RunComplete()
//------------------------------------------------------------------------------
void CallFunction::RunComplete()
{
   #ifdef DEBUG_RUN_COMPLETE
   MessageInterface::ShowMessage
      (wxT("CallFunction::RunComplete() entered for this=<%p> '%s',\n   ")
       wxT("FCS %sfinalized\n"), this, GetGeneratingString(Gmat::NO_COMMENTS).c_str(),
       fm.IsFinalized() ? wxT("already ") : wxT("NOT "));
   #endif
   
   if (!fm.IsFinalized())
   {
      #ifdef DEBUG_RUN_COMPLETE
      MessageInterface::ShowMessage(wxT("   calling FunctionManager::Finalize()\n"));
      #endif
      fm.Finalize();
   }
   
   GmatCommand::RunComplete();
}
コード例 #5
0
ファイル: Minimize.cpp プロジェクト: rockstorm101/GMAT
bool Minimize::SetElementWrapper(ElementWrapper *toWrapper, const std::string &withName)
{
   bool retval = false;

   if (toWrapper == NULL) return false;
   
   if (toWrapper->GetWrapperType() == Gmat::ARRAY_WT)
   {
      throw CommandException("A value of type \"Array\" on command \"" + typeName + 
                  "\" is not an allowed value.\nThe allowed values are:"
                  " [ Variable, Array Element, or Parameter ]. "); 
   }
   if (toWrapper->GetWrapperType() == Gmat::NUMBER_WT)
   {
      throw CommandException("A value of type \"Number\" on command \"" + typeName + 
                  "\" is not an allowed value.\nThe allowed values are:"
                  " [ Variable, Array Element, or Parameter ]. "); 
   }
   //if (toWrapper->GetWrapperType() == Gmat::STRING_OBJECT_WT)
   //{
   //   throw CommandException("A value of type \"String Object\" on command \"" + typeName + 
   //               "\" is not an allowed value.\nThe allowed values are:"
   //               " [ Real Number, Variable, Array Element, or Parameter ]. "); 
   //}
   
   #ifdef DEBUG_WRAPPER_CODE   
   MessageInterface::ShowMessage("   Setting wrapper \"%s\" on Minimize command\n", 
      withName.c_str());
   #endif
   
   CheckDataType(toWrapper, Gmat::REAL_TYPE, "Minimize", true);

   if (objectiveName == withName)
   {
      objective = toWrapper;
      // Reset the generating string so initialization works correctly
      GetGeneratingString(Gmat::SCRIPTING, "", "");
      retval = true;
   }
   
   return retval;
}
コード例 #6
0
//------------------------------------------------------------------------------
bool BeginFiniteBurn::Execute()
{
   ValidateThrusters();
   
   // Turn on all of the referenced thrusters
   #ifdef DEBUG_BEGIN_MANEUVER_EXE
   MessageInterface::ShowMessage
      ("BeginFiniteBurn::Execute() <%p>'%s' entered\n   "
       "There are %d thruster(s) in use\n", this,
       GetGeneratingString(Gmat::NO_COMMENTS).c_str(), thrusters.size());
   #endif
   for (std::vector<Thruster*>::iterator i = thrusters.begin(); 
        i != thrusters.end(); ++i)
   {
      Thruster *th = *i;
      #ifdef DEBUG_BEGIN_MANEUVER_EXE
         MessageInterface::ShowMessage
            ("Activating engine <%p>'%s'\n", th, th->GetName().c_str());
      #endif
      th->SetBooleanParameter(th->GetParameterID("IsFiring"), true);
      
      #ifdef DEBUG_BEGIN_MANEUVER_EXE
         MessageInterface::ShowMessage
            ("Checking to see if engine is active: returned %s\n", 
             (th->GetBooleanParameter(th->GetParameterID("IsFiring")) ? 
              "true" : "false"));
      #endif
   }
   
   // Tell active spacecraft that they are now firing
   for (std::vector<Spacecraft*>::iterator s=sats.begin(); s!=sats.end(); ++s)
   {
      (*s)->IsManeuvering(true);
   }

   if (transientForces == NULL)
      throw CommandException("Transient force list was NOT initialized; "
            "ABORTING RUN!!!\n\n");
   
   // Insert the force into the list of transient forces if not found
   if (transientForces->size() == 0)
   {
      #ifdef DEBUG_TRANSIENT_FORCES
      MessageInterface::ShowMessage
         ("BeginFiniteBurn::Execute() Adding first burnForce<%p>'%s' to "
               "transientForces\n", burnForce, burnForce->GetName().c_str());
      #endif
      transientForces->push_back(burnForce);
   }
   else
   {
      bool alreadyThere = false;
      for (std::vector<PhysicalModel*>::iterator i = transientForces->begin();
            i !=transientForces->end(); ++i)
      {
         if ((*i)->IsOfType("FiniteThrust"))
         {
            FiniteThrust *transient = (FiniteThrust*)(*i);
            if (transient == burnForce)
            {
               alreadyThere = true;
            }

            if ((*transient) == (*burnForce))
            {
               MessageInterface::ShowMessage("Burn activated by the line\n   "
                     "%s\noverlaps with an active finite burn.  No new finite "
                     "burn will be applied.\n",
                     GetGeneratingString(Gmat::NO_COMMENTS).c_str());
               alreadyThere = true;
            }
         }
      }
      if (alreadyThere == false)
      {
         #ifdef DEBUG_TRANSIENT_FORCES
         MessageInterface::ShowMessage("BeginFiniteBurn::Execute() Adding "
               "burnForce<%p>'%s' to transientForces\n", burnForce,
               burnForce->GetName().c_str());
         #endif
         transientForces->push_back(burnForce);
      }
   }
   
   // Set maneuvering to Publisher so that any subscriber can do its own action
   if (!sats.empty())
   {
      Real epoch = sats[0]->GetEpoch();
      publisher->SetManeuvering(this, true, epoch, satNames,
            "begin of finite maneuver");
   }
   
   #ifdef DEBUG_BEGIN_MANEUVER_EXE
      MessageInterface::ShowMessage
         ("There are %d transient force(s)\n", transientForces->size());
      MessageInterface::ShowMessage("Current TransientForces list:\n");
      for (std::vector<PhysicalModel*>::iterator j = transientForces->begin();
           j != transientForces->end(); ++j)
         MessageInterface::ShowMessage("   %s\n", (*j)->GetName().c_str());
   #endif
   
   BuildCommandSummary(true);
   return true;
}
コード例 #7
0
ファイル: Set.cpp プロジェクト: rockstorm101/GMAT
//------------------------------------------------------------------------------
bool Set::Execute()
{
   #ifdef DEBUG_SET_EXEC
      MessageInterface::ShowMessage("Set::Execute() entered\n");
   #endif
   
   bool retval = false, valueSet = false;

   if (theInterface == NULL)
      throw CommandException("The FileInterface object \"" + interfaceName +
               "\" was not found."); 
   
   if (theInterface->Open() == 0)
   {
      retval = theInterface->LoadData();
      if (theInterface->Close() != 0)
      {
         MessageInterface::ShowMessage("The interface failed to close\n");
      }

      if (retval)
      {
         UnsignedInt parmCount = 0;
         StringArray allItems =
               theInterface->GetStringArrayParameter("SupportedFields");
         std::string theItem, theParmString;

         if (loadAll)
            parmCount = allItems.size();
         else
            parmCount = selections.size();

         std::stringstream parametersNotSet;

         for (UnsignedInt i = 0; i < parmCount; ++i)
         {
            theItem = (loadAll ? allItems[i] : selections[i]);
            DataReader::readerDataType fieldType =
                     theInterface->GetReaderParameterType(theItem);

            if (SetTargetParameterData(fieldType, theItem))
               valueSet = true;
            else
               parametersNotSet << "   The parameter " << theItem 
                                << " did not set data on the object "
                                << targetName 
                                << "; either the field is missing from the "
                                << "file or the field value is not valid.\n";
         }

         if (parametersNotSet.str().length() > 0)
            //if (loadAll)
            //   MessageInterface::ShowMessage("*** Warning *** Loading failed "
            //            "for the following parameters:\n%sin the line\n%s\n",
            //            parametersNotSet.str().c_str(),
            //            GetGeneratingString(Gmat::NO_COMMENTS).c_str());
            //else
               throw CommandException("Error loading data from a DataInterface:\n" +
                        parametersNotSet.str() + "in the line\n" + 
                        GetGeneratingString(Gmat::NO_COMMENTS));
      }
      #ifdef DEBUG_SET_EXEC
         else
            MessageInterface::ShowMessage("Set::Execute() LoadData returned "
                  "false\n");
      #endif
   }
   #ifdef DEBUG_SET_EXEC
      else
         MessageInterface::ShowMessage("Set::Execute(): The interface did not "
               "open\n");
   #endif

   BuildCommandSummary();

   return retval && valueSet;
}