コード例 #1
0
ファイル: Minimize.cpp プロジェクト: rockstorm101/GMAT
//------------------------------------------------------------------------------
bool Minimize::Execute()
{
   #ifdef DEBUG_MINIMIZE_EXEC // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ debug ~~~~
   MessageInterface::ShowMessage
      ("Minimize::Execute() optimizerDataFinalized=%d\n   optimizer=%p, objective=%p\n", 
       optimizerDataFinalized, optimizer, objective);
   MessageInterface::ShowMessage
      ("   objectiveName=%s\n", objectiveName.c_str());
   if (objective)
      MessageInterface::ShowMessage("   objective=%s\n", objective->GetDescription().c_str());
   #endif // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ end debug ~~~~
   
   bool retval = true;
   if (!optimizerDataFinalized) 
   {
      // Tell the optimizer about the objective function
      Real minData[1];
      minData[0] = objective->EvaluateReal(); 
      //minData[1] = tolerance;
      objId = optimizer->SetSolverResults(minData, objectiveName, "Objective");

      optimizerDataFinalized = true;
      return retval;
   }
   
   Real val = -999.999;
   // Evaluate variable and pass it to the optimizer
   if (objective != NULL)
   {
      val = objective->EvaluateReal();
      #ifdef DEBUG_MINIMIZE_EXEC // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ debug ~~~~
         MessageInterface::ShowMessage
            ("   objective=%s, %p\n", objective->GetDescription().c_str(), objective);
         MessageInterface::ShowMessage("   Parameter target: %s val = %lf\n",
            objective->GetDescription().c_str(), val);
      #endif // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ end debug ~~~~
      optimizer->SetResultValue(objId, val, "Objective");
   }
   else 
   {  // ERROR ERROR - should I throw an exception here? *********** TBD **************
      MessageInterface::ShowMessage(
         "Minimize: Warning - objective function is NULL\n"); 
      val = -999.999;
      //val = goalObject->GetRealParameter(parmId);  // again,no clue
      optimizer->SetResultValue(objId, val, "Objective");
      #ifdef DEBUG_MINIMIZE_EXEC // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ debug ~~~~
         MessageInterface::ShowMessage("   Object target: val = %lf\n", val);
      #endif // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ end debug ~~~~
   }

   //targeter->SetResultValue(goalId, val);
   BuildCommandSummary(true);
   
   return retval;
}
コード例 #2
0
//---------------------------------------------------------------------------
bool PenUp::Execute()
{
   for (unsigned int ii = 0; ii < thePlotList.size(); ii++)
   {
      if (thePlotList.at(ii))
         if (!(thePlotList.at(ii)->TakeAction("PenUp"))) return false;
   }
   
   // Build command summary
   BuildCommandSummary(true);
   
   return true;
}
コード例 #3
0
//------------------------------------------------------------------------------
bool EndTarget::Execute()
{
   #ifdef DEBUG_TARGET_COMMANDS
      if (next)
         MessageInterface::ShowMessage(
            wxT("End Target points to a %s command\n"), next->GetTypeName().c_str());
      else
         MessageInterface::ShowMessage(
            wxT("EndTarget does not reconnect to Target comamnd\n"));
   #endif
   
   BuildCommandSummary(true);
   return true;
}
コード例 #4
0
ファイル: EndOptimize.cpp プロジェクト: rockstorm101/GMAT
//------------------------------------------------------------------------------
// Execute
//------------------------------------------------------------------------------
bool EndOptimize::Execute()
{
   #ifdef DEBUG_OPTIMIZER_COMMANDS
      if (next)
         MessageInterface::ShowMessage(
            "End Optimize points to a %s command\n", next->GetTypeName().c_str());
      else
         MessageInterface::ShowMessage(
            "EndOptimize does not reconnect to Optimize comamnd\n");
   #endif
   
   BuildCommandSummary(true);
   return true;
}
コード例 #5
0
ファイル: PenDown.cpp プロジェクト: rockstorm101/GMAT
//---------------------------------------------------------------------------
bool PenDown::Execute()
{
   #ifdef DEBUG_PENDOWN
      MessageInterface::ShowMessage
         ("PenDown::Execute() thePlotList.size()=%d\n", thePlotList.size());
   #endif
      
   for (unsigned int ii = 0; ii < thePlotList.size(); ii++)
   {
      if (thePlotList.at(ii))
         if (!(thePlotList.at(ii)->TakeAction("PenDown"))) return false;
   }
   
   // Build command summary
   BuildCommandSummary(true);
   
   #ifdef DEBUG_PENDOWN
      MessageInterface::ShowMessage("PenDown::Execute() returning true\n");
   #endif
   return true;
}
コード例 #6
0
//------------------------------------------------------------------------------
bool NonlinearConstraint::Execute()
{
   #ifdef DEBUG_NONLINEAR_CONSTRAINT_EXEC
   MessageInterface::ShowMessage
      (wxT("NonlinearConstraint::Execute() optimizerDataFinalized=%d\n, optimizer=%s, ")
       wxT("arg1=%p, arg2=%p\n"), optimizerDataFinalized, optimizer, arg1, arg2);
   MessageInterface::ShowMessage
      (wxT("   arg1Name=%s\n"), arg1Name.c_str());
   MessageInterface::ShowMessage
      (wxT("   arg2Name=%s\n"), arg2Name.c_str());
   #endif
   
   bool retval = true;
   if (!optimizerDataFinalized) 
   {
      // Tell the optimizer about the constraint
      Real conData[1];
      conData[0] = 54321.0;  // objective function value here .........
      constraintId = optimizer->SetSolverResults(conData, arg1Name, 
                     isIneqString);

      optimizerDataFinalized = true;
      return retval;
   }
   
   //#ifdef DEBUG_NLC_VALUES
   //   MessageInterface::ShowMessage("NLC:Execute - desiredValue = %.12f\n",
   //      desiredValue);
   //#endif
   
   Real constraintValue = -999.99;
   // Evaluate variable and pass it to the optimizer
   if ( (arg1 != NULL) && (arg2 != NULL) )
   {
      desiredValue    = arg2->EvaluateReal();
      constraintValue = arg1->EvaluateReal();
      #ifdef DEBUG_NLC_VALUES
         MessageInterface::ShowMessage(wxT("NLC:Execute - desiredValue = %.12f\n"),
            desiredValue);
         MessageInterface::ShowMessage(wxT("NLC:Execute - (1) constraintValue = %.12f\n"),
            constraintValue);
      #endif
      switch (op)
      {
         case EQUAL:
         case LESS_THAN_OR_EQUAL:
            constraintValue = constraintValue - desiredValue;
            break;
         case GREATER_THAN_OR_EQUAL:
            constraintValue = desiredValue - constraintValue;
            break;
         default:
            break;
      }
      #ifdef DEBUG_NLC_VALUES
         MessageInterface::ShowMessage(wxT("NLC:Execute - (2) constraintValue now = %.12f\n"),
            constraintValue);
      #endif
      optimizer->SetResultValue(constraintId, constraintValue, isIneqString);
      #ifdef DEBUG_NONLINEAR_CONSTRAINT_EXEC
         MessageInterface::ShowMessage
            (wxT("   constraint=%s, %p\n"), constraint->GetTypeName().c_str(), constraint);
         MessageInterface::ShowMessage(wxT("   Parameter target: %s constraintValue = %lf\n"),
            constraint->GetTypeName().c_str(), constraintValue);
      #endif
   }
   else 
   {
      // isn't this an error???
      //constraintValue = -999.99;  // what to do here?
      //constraintValue = constraintObject->GetRealParameter(parmId);  // again,no clue
      optimizer->SetResultValue(constraintId, constraintValue, isIneqString);
      #ifdef DEBUG_NONLINEAR_CONSTRAINT_EXEC
         MessageInterface::ShowMessage(wxT("   Object target: constraintValue = %lf\n"), 
         constraintValue);
      #endif
   }

   BuildCommandSummary(true);
   
   return retval;
}
コード例 #7
0
//------------------------------------------------------------------------------
bool Target::Execute()
{
#ifdef DEBUG_TARGET_EXEC
    MessageInterface::ShowMessage
    (wxT("Target::Execute() entered, theSolver=<%p>'%s'\n"), (GmatBase*)theSolver,
     theSolver->GetName().c_str());
    MessageInterface::ShowMessage
    (wxT("maxIter=%d\n"),
     theSolver->GetIntegerParameter(theSolver->GetParameterID(wxT("MaximumIterations"))));
    MessageInterface::ShowMessage
    (wxT("currentFunction=<%p>'%s'\n"),
     currentFunction, currentFunction ? ((GmatBase*)currentFunction)->GetName().c_str() : wxT("NULL"));
#endif

    // If targeting inside a function, we need to reinitialize since the local solver is
    // cloned in Initialize(). All objects including solvers are initialized in
    // assignment command which happens after Target::Initialize(). (LOJ: 2009.03.17)
    if (currentFunction != NULL && !targeterInFunctionInitialized)
    {
        Initialize();
        targeterInFunctionInitialized = true;
    }

    bool retval = true;

    // Drive through the state machine.
    Solver::SolverState state = theSolver->GetState();

#ifdef DEBUG_TARGET_COMMANDS
    MessageInterface::ShowMessage(wxT("TargetExecute(%c%c%c%d)\n"),
                                  (commandExecuting?wxT('Y'):wxT('N')),
                                  (commandComplete?wxT('Y'):wxT('N')),
                                  (branchExecuting?wxT('Y'):wxT('N')),
                                  state);
    MessageInterface::ShowMessage(wxT("   targeterConverged=%d\n"),
                                  targeterConverged);
#endif

    // Attempt to reset if recalled
    if (commandComplete)
    {
        commandComplete = false;
        commandExecuting = false;
        specialState = Solver::INITIALIZING;
    }

    if (!commandExecuting)
    {
#ifdef DEBUG_TARGET_COMMANDS
        MessageInterface::ShowMessage(
            wxT("Entered Targeter while command is not executing\n"));
#endif

        FreeLoopData();
        StoreLoopData();


        retval = SolverBranchCommand::Execute();

#ifdef DEBUG_TARGETER
        MessageInterface::ShowMessage(wxT("Resetting the Differential Corrector\n"));
#endif

        theSolver->TakeAction(wxT("Reset"));
        state = theSolver->GetState();
    }

    if (branchExecuting)
    {
        retval = ExecuteBranch();
        if (!branchExecuting)
        {
            if ((state == Solver::FINISHED) || (specialState == Solver::FINISHED))
            {
                PenDownSubscribers();
                LightenSubscribers(1);
                commandComplete = true;
            }
            else
            {
                PenUpSubscribers();
            }
        }
    }
    else
    {
        GmatCommand *currentCmd;

        publisher->SetRunState(Gmat::SOLVING);

        switch (startMode)
        {
        case RUN_INITIAL_GUESS:
#ifdef DEBUG_START_MODE
            MessageInterface::ShowMessage(
                wxT("Running as RUN_INITIAL_GUESS, specialState = %d, currentState = %d\n"),
                specialState, theSolver->GetState());
#endif
            switch (specialState)
            {
            case Solver::INITIALIZING:
                // Finalize initialization of the targeter data
                currentCmd = branch[0];
                targeterConverged = false;
                while (currentCmd != this)
                {
                    wxString type = currentCmd->GetTypeName();
                    if ((type == wxT("Target")) || (type == wxT("Vary")) ||
                            (type == wxT("Achieve")))
                        currentCmd->Execute();
                    currentCmd = currentCmd->GetNext();
                }
                StoreLoopData();
                specialState = Solver::NOMINAL;
                break;

            case Solver::NOMINAL:
                // Execute the nominal sequence
                if (!commandComplete)
                {
                    branchExecuting = true;
                    ResetLoopData();
                }
                specialState = Solver::RUNSPECIAL;
                break;

            case Solver::RUNSPECIAL:
                // Run once more to publish the data from the converged state
                if (!commandComplete)
                {
                    ResetLoopData();
                    branchExecuting = true;
                    publisher->SetRunState(Gmat::SOLVEDPASS);
                }
                theSolver->Finalize();
                specialState = Solver::FINISHED;

                // Final clean-up
                targeterConverged = true;
                break;

            case Solver::FINISHED:
                specialState = Solver::INITIALIZING;
                break;

            default:
                break;
            }
            break;

        case RUN_SOLUTION:
#ifdef DEBUG_START_MODE
            MessageInterface::ShowMessage(
                wxT("Running as RUN_SOLUTION, state = %d\n"), state);
#endif
            throw SolverException(
                wxT("Run Solution is not yet implemented for the Target ")
                wxT("command\n"));
            break;

        case RUN_AND_SOLVE:
        default:
#ifdef DEBUG_START_MODE
            MessageInterface::ShowMessage(
                wxT("Running as RUN_AND_SOLVE or default, state = %d\n"),
                state);
#endif
            switch (state)
            {
            case Solver::INITIALIZING:
                // Finalize initialization of the targeter data
                currentCmd = branch[0];
                targeterConverged = false;
                while (currentCmd != this)
                {
                    wxString type = currentCmd->GetTypeName();
                    if ((type == wxT("Target")) || (type == wxT("Vary")) ||
                            (type == wxT("Achieve")))
                    {
                        currentCmd->Execute();
                        if ((type == wxT("Vary")) && (targeterRunOnce))
                            currentCmd->TakeAction(wxT("SolverReset"));
                    }
                    currentCmd = currentCmd->GetNext();
                }
                StoreLoopData();
                GetActiveSubscribers();
                SetSubscriberBreakpoint();
                break;

            case Solver::NOMINAL:
                // Execute the nominal sequence
                if (!commandComplete)
                {
                    branchExecuting = true;
                    ApplySubscriberBreakpoint();
                    PenDownSubscribers();
                    LightenSubscribers(1);
                    ResetLoopData();
                }
                break;

            case Solver::CHECKINGRUN:
                // Check for convergence; this is done in the targeter state
                // machine, so this case is a NoOp for the Target command
                break;

            case Solver::PERTURBING:
                branchExecuting = true;
                ApplySubscriberBreakpoint();
                PenDownSubscribers();
                LightenSubscribers(4);
                ResetLoopData();
                break;

            case Solver::CALCULATING:
                // Calculate the next set of variables to use; this is
                // performed in the targeter -- nothing to be done here
                break;

            case Solver::FINISHED:
                // Final clean-up
                targeterConverged = true;
                targeterRunOnce = true;

                // Run once more to publish the data from the converged state
                if (!commandComplete)
                {
                    ResetLoopData();
                    branchExecuting = true;
                    ApplySubscriberBreakpoint();
                    PenDownSubscribers();
                    LightenSubscribers(1);
                    publisher->SetRunState(Gmat::SOLVEDPASS);
                }
                break;

            case Solver::ITERATING:     // Intentional fall-through
            default:
                throw CommandException(
                    wxT("Invalid state in the Targeter state machine"));
            }
            break;
        }
    }

    if (!branchExecuting)
    {
        theSolver->AdvanceState();

        if (theSolver->GetState() == Solver::FINISHED)
        {
            publisher->FlushBuffers();
            targeterConverged = true;
        }
    }

    // Pass spacecraft data to the targeter for reporting in debug mode
    if (targeterInDebugMode)
    {
        wxString dbgData = wxT("");
        for (ObjectArray::iterator i = localStore.begin(); i < localStore.end();
                ++i)
        {
            dbgData += (*i)->GetGeneratingString() + wxT("\n---\n");
        }
        theSolver->SetDebugString(dbgData);
    }
    BuildCommandSummary(true);

#ifdef DEBUG_TARGET_EXEC
    MessageInterface::ShowMessage
    (wxT("Target::Execute() returning %d, theSolver=<%p>'%s'\n"), retval,
     theSolver, theSolver->GetName().c_str());
#endif

    return retval;
}
コード例 #8
0
//------------------------------------------------------------------------------
bool EndFiniteBurn::Execute()
{
   ValidateThrusters();

   // Only do this if the FiniteBurn is the one this command controls...
   bool forceActive = false;
   for (std::vector<PhysicalModel*>::iterator j = transientForces->begin();
        j != transientForces->end(); ++j)
   {
      if (((*j)->GetName()) == thrustName)
      {
         // ... and if it is set for the right spacecraft
         StringArray burnSatNames = (*j)->GetRefObjectNameArray(Gmat::SPACECRAFT);

         bool foundSats = false;
         UnsignedInt numberFound = 0;
         for (UnsignedInt i = 0; i < satNames.size(); ++i)
         {
            if (find(burnSatNames.begin(), burnSatNames.end(), satNames[i]) != burnSatNames.end())
            {
               foundSats = true;
               ++numberFound;
            }
         }
         if (foundSats)
         {
            #ifdef DEBUG_TRANSIENT_FORCES
               MessageInterface::ShowMessage("EndFiniteBurn::Execute(): The burn "
                     "is active\n");
            #endif

            forceActive = true;

            if (numberFound != satNames.size())
               MessageInterface::ShowMessage("*** WARNING *** Turning off the "
                     "finite burn %s, but the EndFiniteBurn command did not "
                     "list all of the spacecraft that are no longer "
                     "maneuvering.\n", burnName.c_str());

            break;
         }
      }
   }
   
   if (forceActive)
   {
      // Turn off all of the referenced thrusters
      for (std::vector<Thruster*>::iterator i = thrusters.begin();
           i != thrusters.end(); ++i)
      {
         Thruster *th = *i;
         #ifdef DEBUG_END_MANEUVER_EXE
            MessageInterface::ShowMessage
               ("EndFiniteBurn::Execute() Deactivating engine <%p>'%s'\n", th,
                th->GetName().c_str());
         #endif
         th->SetBooleanParameter(th->GetParameterID("IsFiring"), false);
   
         #ifdef DEBUG_END_MANEUVER_EXE
            MessageInterface::ShowMessage
               ("Checking to see if engine is inactive: returned %s\n",
                (th->GetBooleanParameter(th->GetParameterID("IsFiring")) ?
                 "true" : "false"));
         #endif
      }

      // Tell active spacecraft that they are no longer firing
      for (std::vector<Spacecraft*>::iterator s=sats.begin(); s!=sats.end(); ++s)
      {
         #ifdef DEBUG_END_MANEUVER_EXE
            MessageInterface::ShowMessage
                  ("EndFiniteBurn::Execute() Deactivating maneuvers on Spacecraft "
                   "<%p>'%s'\n", *s, (*s)->GetName().c_str());
         #endif
         /// todo: Be sure that no other maneuver has the spacecraft maneuvering;
         /// for R2013a this is not an issue since only 1 burn per spacecraft is
         /// allowed.  We'll need to fix this when that restriction is removed.
         (*s)->IsManeuvering(false);
      }

      // Remove the force from the list of transient forces
      for (std::vector<PhysicalModel*>::iterator j = transientForces->begin();
           j != transientForces->end(); ++j)
      {
         if (((*j)->GetName()) == thrustName)
         {
            #ifdef DEBUG_TRANSIENT_FORCES
            MessageInterface::ShowMessage
               ("EndFiniteBurn::Execute() Removing burnForce<%p>'%s' from "
                     "transientForces\n", *j, (*j)->GetName().c_str());
            #endif
            transientForces->erase(j);
            break;
         }
      }

      // Reset maneuvering to Publisher so that any subscriber can do its own action
      if (!sats.empty())
      {
         Real epoch = sats[0]->GetEpoch();
         publisher->SetManeuvering(this, false, epoch, satNames, "end of finite "
               "maneuver");
      }

      #ifdef DEBUG_END_MANEUVER_EXE
         MessageInterface::ShowMessage("EndFiniteBurn::Execute() 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;
}
コード例 #9
0
//------------------------------------------------------------------------------
bool EndIf::Execute()
{
   BuildCommandSummary(true);
   return true;
}
コード例 #10
0
//------------------------------------------------------------------------------
bool If::Execute()
{
   bool retval = true;
   
   if (branchExecuting)
   {
      #ifdef DEBUG_IF_EXEC
      MessageInterface::ShowMessage
      (wxT("In If::Execute - Branch Executing -------------\n"));
      #endif
      retval = ExecuteBranch(branchToExecute);
      #ifdef DEBUG_IF_EXEC
         MessageInterface::ShowMessage
         (wxT("In If:: retval returned from ExecuteBranch = %s\n"), (retval? wxT("true") : wxT("false")));
         MessageInterface::ShowMessage
         (wxT("        branchExecuting=%d\n"), branchExecuting);
      #endif
      if (!branchExecuting)
      {
         commandComplete  = true;
         commandExecuting = false;
      }
   }
   else 
   {
      #ifdef DEBUG_IF_EXEC
      MessageInterface::ShowMessage
      (wxT("In If::Execute - Branch NOT Executing -------------\n"));
      #endif
      if (!commandExecuting)
         ConditionalBranch::Execute();
      
      //if (EvaluateCondition(0)) // must deal with multiple conditions later
      if (EvaluateAllConditions()) 
      {
         #ifdef DEBUG_IF_EXEC
         MessageInterface::ShowMessage
         (wxT("In If::Execute all conditions are true - executing first branch\n"));
         #endif
         branchToExecute = 0;
         branchExecuting = true;
         commandComplete = false;
         commandExecuting = true;
      }
      else if ((Integer)branch.size() > 1)  // there could be an 'Else'
      {
         #ifdef DEBUG_IF_EXEC
         MessageInterface::ShowMessage
         (wxT("In If::Execute some conditions are FALSE - executing second branch\n"));
         #endif
         branchExecuting = true;
         branchToExecute = 1; // @todo - add ElseIf (more than two branches)
         commandComplete = false;
         commandExecuting = true;
      }
      else
      {
         #ifdef DEBUG_IF_EXEC
         MessageInterface::ShowMessage
         (wxT("In If::Execute - conditions are FALSE - no other branch to execute\n"));
         //("In If::Execute - ERROR with number of branches - more than two not yet implemented\n");
         #endif
         branchToExecute = 0;
         commandComplete  = true;
         commandExecuting = false;
         branchExecuting = false;  // try this - shouldn't matter
      }
   }
   
   BuildCommandSummary(true);
   #ifdef DEBUG_IF_EXEC
   MessageInterface::ShowMessage
      (wxT("If::BuildCommandSummary completed\n"));
   #endif
   return retval;
} // Execute()
コード例 #11
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;
}
コード例 #12
0
//------------------------------------------------------------------------------
bool BeginScript::Execute()
{
   BuildCommandSummary(true);
   return true;
}
コード例 #13
0
//------------------------------------------------------------------------------
bool NoOp::Execute()
{
   BuildCommandSummary(true);
   return true;
}
コード例 #14
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;
}