Exemple #1
0
//------------------------------------------------------------------------------
// 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);
   }
}
Exemple #2
0
//------------------------------------------------------------------------------
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());
   }
}
Exemple #3
0
//------------------------------------------------------------------------------
// 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
}
Exemple #4
0
//------------------------------------------------------------------------------
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;
}
Exemple #5
0
//------------------------------------------------------------------------------
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;
}
Exemple #6
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
}
Exemple #7
0
//------------------------------------------------------------------------------
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;
}
Exemple #8
0
//------------------------------------------------------------------------------
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;
}
Exemple #9
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;
}
Exemple #10
0
//------------------------------------------------------------------------------
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;
}
Exemple #11
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;
}
Exemple #12
0
//------------------------------------------------------------------------------
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;
}
Exemple #13
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;
}
Exemple #14
0
//------------------------------------------------------------------------------
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;
}
Exemple #15
0
//------------------------------------------------------------------------------
// 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
}
Exemple #16
0
//------------------------------------------------------------------------------
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();
         }
         propagators.push_back(ps);
         p.push_back(ps->GetPropagator());
         fm.push_back(ps->GetODEModel());
         eventMan->SetObject(ps);  // todo <-- Check this -- added 6/28

//         PropagationStateManager *psm = ps->GetPropStateManager();
//         StringArray propObjects = ps->GetStringArrayParameter("");

         retval = true;
      }
   }
   else
      throw CommandException("Cannot initialize RunSimulator command; the "
            "propagator pointer in the Simulator " +
            theSimulator->GetName() + " is NULL.");

   // Now set the participant list
   MeasurementManager *mm = theSimulator->GetMeasurementManager();
   StringArray participants = mm->GetParticipantList();

   #ifdef DEBUG_INITIALIZATION
      MessageInterface::ShowMessage("RunSimulator command found %d "
            "participants\n", participants.size());
   #endif

   propObjectNames.clear();
   propObjectNames.push_back(participants);

   // Now we can initialize the propagation subsystem by calling up the
   // inheritance tree.
   if (retval)
      retval = RunSolver::Initialize();

   #ifdef DEBUG_INITIALIZATION
      if (retval == false)
         MessageInterface::ShowMessage("RunSimulator command failed to "
               "initialize; RunSolver::Initialize() call failed.\n");
   #endif

   return retval;
}
Exemple #17
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

}
Exemple #18
0
//------------------------------------------------------------------------------
const std::vector<RealArray>& TDRSSTwoWayRange::CalculateMeasurementDerivatives(
      GmatBase *obj, Integer id)
{
   #ifdef DEBUG_DERIVATIVES
      MessageInterface::ShowMessage("TDRSSTwoWayRange::CalculateMeasurement"
            "Derivatives(%s, %d) called\n", obj->GetName().c_str(), id);
   #endif

   if (!initialized)
      InitializeMeasurement();

   GmatBase *objPtr = NULL;

   Integer size = obj->GetEstimationParameterSize(id);
   Integer objNumber = -1;

   #ifdef DEBUG_DERIVATIVES
      MessageInterface::ShowMessage("   ParameterSize = %d\n", size);
   #endif

   if (size <= 0)
      throw MeasurementException("The derivative parameter on derivative "
            "object " + obj->GetName() + "is not recognized");

   // Check to see if obj is a participant
   for (UnsignedInt i = 0; i < this->participants.size(); ++i)
   {
      if (participants[i] == obj)
      {
         objPtr = participants[i];
         objNumber = i + 1;
         #ifdef DEBUG_DERIVATIVES
            MessageInterface::ShowMessage("   Participant %s found\n",
                  objPtr->GetName().c_str());
         #endif
         break;
      }
   }

   // Or if it is the measurement model for this object
   if (obj->IsOfType(Gmat::MEASUREMENT_MODEL))
   if (obj->GetRefObject(Gmat::CORE_MEASUREMENT, "") == this)
   {
      objPtr = obj;
      objNumber = 0;
      #ifdef DEBUG_DERIVATIVES
         MessageInterface::ShowMessage("   The measurement is the object\n",
               objPtr->GetName().c_str());
      #endif
   }

   if (objNumber == -1)
      throw MeasurementException(
            "TDRSSTwoWayRange error - object is neither participant nor "
            "measurement model.");

   RealArray oneRow;
   oneRow.assign(size, 0.0);
   currentDerivatives.clear();
   currentDerivatives.push_back(oneRow);

   Integer parameterID = GetParmIdFromEstID(id, obj);

   #ifdef DEBUG_DERIVATIVES
      MessageInterface::ShowMessage("   Looking up id %d\n", parameterID);
   #endif

   if (objPtr != NULL)
   {
      if (objNumber == 1) // participant number 1, either a GroundStation or a Spacecraft
      {
         #ifdef DEBUG_DERIVATIVES
            MessageInterface::ShowMessage("   Deriv is w.r.t. %s of Participant"
                     " 1\n", objPtr->GetParameterText(parameterID).c_str());
         #endif
         if (objPtr->GetParameterText(parameterID) == "Position")
         {
            throw MeasurementException("Derivative w.r.t. " +
                  participants[0]->GetName() + " Position is not yet implemented");
         }
         else if (objPtr->GetParameterText(parameterID) == "Velocity")
         {
            throw MeasurementException("Derivative w.r.t. " +
                  participants[0]->GetName() + " Velocity is not yet implemented");
         }
         else if (objPtr->GetParameterText(parameterID) == "CartesianX")
         {
            throw MeasurementException("Derivative w.r.t. " +
                  participants[0]->GetName() + " CartesianState is not yet implemented");
         }
         else if (objPtr->GetParameterText(parameterID) == "Bias")
         {
            for (Integer i = 0; i < size; ++i)
               currentDerivatives[0][i] = 1.0;
         }
         else
         {
            #ifdef DEBUG_DERIVATIVES
               MessageInterface::ShowMessage("   Deriv is w.r.t. something "
                        "independent, so zero\n");
            #endif
            for (UnsignedInt i = 0; i < 3; ++i)
               currentDerivatives[0][i] = 0.0;
         }
      }
      else if (objNumber == 2) // participant 2, should be a TDRSS Spacecraft
      {
         #ifdef DEBUG_DERIVATIVES
            MessageInterface::ShowMessage("   Deriv is w.r.t. %s of Participant"
                     " 1\n", objPtr->GetParameterText(parameterID).c_str());
         #endif
         if (objPtr->GetParameterText(parameterID) == "Position")
         {
            throw MeasurementException("Derivative w.r.t. " +
                  participants[0]->GetName() + " Position is not yet implemented");
         }
         else if (objPtr->GetParameterText(parameterID) == "Velocity")
         {
            throw MeasurementException("Derivative w.r.t. " +
                  participants[0]->GetName() + " Velocity is not yet implemented");
         }
         else if (objPtr->GetParameterText(parameterID) == "CartesianX")
         {
            throw MeasurementException("Derivative w.r.t. " +
                  participants[0]->GetName() + " CartesianState is not yet implemented");
         }
         else if (objPtr->GetParameterText(parameterID) == "Bias")
         {
            for (Integer i = 0; i < size; ++i)
               currentDerivatives[0][i] = 1.0;
         }
         else
         {
            #ifdef DEBUG_DERIVATIVES
               MessageInterface::ShowMessage("   Deriv is w.r.t. something "
                        "independent, so zero\n");
            #endif
            for (UnsignedInt i = 0; i < 3; ++i)
               currentDerivatives[0][i] = 0.0;
         }
      }
      else if (objNumber == 3) // participant 3, always a Spacecraft
      {
         #ifdef DEBUG_DERIVATIVES
            MessageInterface::ShowMessage("   Deriv is w.r.t. %s of Participant"
                     " 3\n", objPtr->GetParameterText(parameterID).c_str());
         #endif

         if (objPtr->GetParameterText(parameterID) == "Position")
         {
            // Get the inverse of the orbit STM at the measurement epoch
            // Will need adjustment if stm changes
            Rmatrix stmInv(6,6);
            GetInverseSTM(obj, stmInv);

            Rvector3 forwardlinkRderiv;
            GetRangeDerivative(forwardlinkLeg, stmInv, forwardlinkRderiv, false,
                  1, 2, true, false);

            // Downlink leg
            Rvector3 backlinkRderiv;
            GetRangeDerivative(backlinkLeg, stmInv, backlinkRderiv, false, 1, 2,
                  true, false);

            // Add 'em up per eq tbd
            for (Integer i = 0; i < 3; ++i)
               currentDerivatives[0][i] =
                     0.5 * (forwardlinkRderiv[i] + backlinkRderiv[i]);
            #ifdef DEBUG_DERIVATIVES
               MessageInterface::ShowMessage("Position Derivative: [%.12lf "
                     "%.12lf %.12lf]\n", currentDerivatives[0][0],
                     currentDerivatives[0][1], currentDerivatives[0][2]);
            #endif
         }
         else if (objPtr->GetParameterText(parameterID) == "Velocity")
         {
            // Get the inverse of the orbit STM at the measurement epoch
            // Will need adjustment if stm changes
            Rmatrix stmInv(6,6);
            GetInverseSTM(obj, stmInv);

            Rvector3 forwardlinkVderiv;
            GetRangeDerivative(forwardlinkLeg, stmInv, forwardlinkVderiv, false,
                  1, 2, false);

            // Downlink leg
            Rvector3 backlinkVderiv;
            GetRangeDerivative(backlinkLeg, stmInv, backlinkVderiv, false, 1, 2,
                  false);

            // Add 'em up per eq tbd
            for (Integer i = 0; i < 3; ++i)
               currentDerivatives[0][i] =
                     0.5 * (forwardlinkVderiv[i] + backlinkVderiv[i]);
            #ifdef DEBUG_DERIVATIVES
               MessageInterface::ShowMessage("Velocity Derivative: [%.12lf "
                     "%.12lf %.12lf]\n", currentDerivatives[0][0],
                     currentDerivatives[0][1], currentDerivatives[0][2]);
            #endif
         }
         else if (objPtr->GetParameterText(parameterID) == "CartesianX")
         {
            // Get the inverse of the orbit STM at the measurement epoch
            // Will need adjustment if stm changes
            Rmatrix stmInv(6,6);
            GetInverseSTM(obj, stmInv);

            Rvector6 forwardlinkDeriv;
            GetRangeDerivative(forwardlinkLeg, stmInv, forwardlinkDeriv, false,
                  1, 2);

            // Downlink leg
            Rvector6 backlinkDeriv;
            GetRangeDerivative(backlinkLeg, stmInv, backlinkDeriv, false, 1, 2);


            // Add 'em up per eq tbd
            for (Integer i = 0; i < 6; ++i)
               currentDerivatives[0][i] =
                     0.5 * (forwardlinkDeriv[i] + backlinkDeriv[i]);
            #ifdef DEBUG_DERIVATIVES
               MessageInterface::ShowMessage("CartesianState Derivative: "
                     "[%.12lf %.12lf %.12lf %.12lf %.12lf %.12lf]\n",
                     currentDerivatives[0][0], currentDerivatives[0][1],
                     currentDerivatives[0][2], currentDerivatives[0][3],
                     currentDerivatives[0][4], currentDerivatives[0][5]);
            #endif
         }
         else if (objPtr->GetParameterText(parameterID) == "Bias")
         {
            for (Integer i = 0; i < size; ++i)
               currentDerivatives[0][i] = 1.0;
         }
         else
         {
            for (UnsignedInt i = 0; i < 3; ++i)
               currentDerivatives[0][i] = 0.0;
         }

      }
      else if (objNumber == 0) // measurement model
      {
         #ifdef DEBUG_DERIVATIVES
            MessageInterface::ShowMessage("   Deriv is w.r.t. %s of the "
                     "measurement model\n",
                     objPtr->GetParameterText(parameterID).c_str());
         #endif
         if (objPtr->GetParameterText(parameterID) == "Bias")
         {
            for (Integer i = 0; i < size; ++i)
               currentDerivatives[0][i] = 1.0;
         }
      }
      else
      {
         #ifdef DEBUG_DERIVATIVES
            MessageInterface::ShowMessage("   Deriv is w.r.t. %s of a non-"
                     "Participant\n",
                     objPtr->GetParameterText(parameterID).c_str());
         #endif
         for (UnsignedInt i = 0; i < 3; ++i)
            currentDerivatives[0][i] = 0.0;
      }

      #ifdef DEBUG_DERIVATIVES
         MessageInterface::ShowMessage("   Deriv =\n   ");

         for (Integer i = 0; i < size; ++i)
            MessageInterface::ShowMessage("   %.12le",currentDerivatives[0][i]);
         MessageInterface::ShowMessage("\n");
      #endif
   }
   return currentDerivatives;
}
//------------------------------------------------------------------------------
// 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);
   }
}
Exemple #20
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;

}
Exemple #21
0
//------------------------------------------------------------------------------
// void LoadData()
//------------------------------------------------------------------------------
void CallFunctionPanel::LoadData()
{
   #ifdef DEBUG_CALLFUNCTION_PANEL_LOAD
   MessageInterface::ShowMessage(wxT("CallFunctionPanel::LoadData() entered\n"));
   #endif
   
   // Set the pointer for the "Show Script" button
   mObject = theCommand;
   
   int id = theCommand->GetParameterID(wxT("FunctionName"));
   wxString functionName = theCommand->GetStringParameter(id);
   
   // If function name is not in the ComboBox list, add blank
   if (!theFunctionComboBox->SetStringSelection(functionName.c_str()))
   {
      theFunctionComboBox->Append(wxT(""));
      theFunctionComboBox->SetStringSelection(wxT(""));
   }
   
   #ifdef DEBUG_CALLFUNCTION_PANEL_LOAD
   MessageInterface::ShowMessage
      (wxT("   Function name is: <%s>\n"), functionName.c_str());
   #endif
   
   // get input parameters
   StringArray inputList = theCommand->GetStringArrayParameter(wxT("AddInput"));
   mNumInput = inputList.size();
   mInputWxStrings.Clear();
   
   #ifdef DEBUG_CALLFUNCTION_PANEL_LOAD
   MessageInterface::ShowMessage
      (wxT("   Found %d input parameters:\n"), mNumInput);
   for (StringArray::iterator i = inputList.begin(); i != inputList.end(); ++i)
      MessageInterface::ShowMessage(wxT("      '%s'\n"), i->c_str());
   #endif
   
   if (mNumInput > 0)
   {
      wxString *inputNames = new wxString[mNumInput];
      GmatBase *param;
      wxString cellValue = wxT("");
      wxString delimiter = wxT(", ");
      
      for (int i=0; i<mNumInput; i++)
      {
         inputNames[i] = inputList[i].c_str();
         
         #ifdef DEBUG_CALLFUNCTION_PANEL_LOAD
         MessageInterface::ShowMessage(wxT("   Looking up ") + inputList[i] + wxT("\n"));
         #endif
         
         param = theGuiInterpreter->GetConfiguredObject(inputList[i]);
         
         if (i == mNumInput-1)
            delimiter = wxT("");
         
         if (param != NULL)
         {
            cellValue = cellValue + param->GetName().c_str() + delimiter;
            mInputWxStrings.Add(param->GetName().c_str());
         }
      }
      
      #ifdef __USE_GRID_FOR_INPUT_OUTPUT__
      theInputGrid->SetCellValue(0, 0, cellValue);
      #else
      theInputTextCtrl->SetValue(cellValue);
      #endif
      
      delete [] inputNames;
   }
   
   // get output parameters
   StringArray outputList = theCommand->GetStringArrayParameter(wxT("AddOutput"));
   mNumOutput = outputList.size();
   mOutputWxStrings.Clear();
   
   #ifdef DEBUG_CALLFUNCTION_PANEL_LOAD
   MessageInterface::ShowMessage
      (wxT("   Found %d output parameters:\n"), mNumOutput);
   for (StringArray::iterator i = outputList.begin(); i != outputList.end(); ++i)
      MessageInterface::ShowMessage(wxT("      '%s'\n"), i->c_str());
   #endif
   
   if (mNumOutput > 0)
   {
      wxString *outputNames = new wxString[mNumOutput];
      GmatBase *param;
      wxString cellValue = wxT("");
      wxString delimiter = wxT(", ");
      
      for (int i=0; i<mNumOutput; i++)
      {
         outputNames[i] = outputList[i].c_str();
         
         #ifdef DEBUG_CALLFUNCTION_PANEL_LOAD
         MessageInterface::ShowMessage(wxT("   Looking up ") + outputList[i] + wxT("\n"));
         #endif
         
         param = theGuiInterpreter->GetConfiguredObject(outputList[i]);
         
         if (i == mNumOutput-1)
            delimiter = wxT("");
         
         if (param != NULL)
         {
            cellValue = cellValue + param->GetName().c_str() + delimiter;
            mOutputWxStrings.Add(param->GetName().c_str());
         }
      }
      
      #ifdef __USE_GRID_FOR_INPUT_OUTPUT__
      theOutputGrid->SetCellValue(0, 0, cellValue);
      #else
      theOutputTextCtrl->SetValue(cellValue);
      #endif
      
      delete [] outputNames;
   }

}
Exemple #22
0
//------------------------------------------------------------------------------
void GmatFunction::BuildUnusedGlobalObjectList()
{
   #ifdef DEBUG_UNUSED_GOL
   MessageInterface::ShowMessage
      (wxT("BuildUnusedGlobalObjectList() entered. There are %d global objects\n"),
       globalObjectStore->size());
   #endif
   
   if (unusedGlobalObjectList != NULL)
      delete unusedGlobalObjectList;
   
   unusedGlobalObjectList = new StringArray;
   
   // Check global object store
   wxString cmdUsed;
   std::map<wxString, GmatBase *>::iterator omi;
   for (omi = globalObjectStore->begin(); omi != globalObjectStore->end(); ++omi)
   {
      GmatBase *obj = omi->second;
      if (!GmatCommandUtil::FindObject(fcs, (omi->second)->GetType(), omi->first,
                                       cmdUsed))
      {
         // Add unused global CoordinateSystem with Spacecraft origin,  primary,
         // or secondary, since Spacecraft is not an automatic global object and
         // we don't want to throw an exception for unexisting Spacecraft in the GOS.
         if (obj->IsOfType(Gmat::COORDINATE_SYSTEM))
         {
            GmatBase *origin = obj->GetRefObject(Gmat::SPACE_POINT, wxT("_GFOrigin_"));
            GmatBase *primary = obj->GetRefObject(Gmat::SPACE_POINT, wxT("_GFPrimary_"));
            GmatBase *secondary = obj->GetRefObject(Gmat::SPACE_POINT, wxT("_GFSecondary_"));
            
            if ((origin != NULL && origin->IsOfType(Gmat::SPACECRAFT)) ||
                (primary != NULL && primary->IsOfType(Gmat::SPACECRAFT)) ||
                (secondary != NULL && secondary->IsOfType(Gmat::SPACECRAFT)))
            {
               #ifdef DEBUG_UNUSED_GOL
               MessageInterface::ShowMessage
                  (wxT("==> Adding '%s' to unusedGOL\n"), (omi->first).c_str());
               #endif
               unusedGlobalObjectList->push_back(omi->first);
            }
         }
      }
   }
   #ifdef DEBUG_UNUSED_GOL
   MessageInterface::ShowMessage
      (wxT("BuildUnusedGlobalObjectList() leaving, There are %d unused global objects\n"),
       unusedGlobalObjectList->size());
   #endif
}
Exemple #23
0
//------------------------------------------------------------------------------
const std::vector<RealArray>& USNTwoWayRange::CalculateMeasurementDerivatives(
      GmatBase *obj, Integer id)
{
   #ifdef DEBUG_DERIVATIVES
      MessageInterface::ShowMessage("USNTwoWayRange::CalculateMeasurement"
            "Derivatives(%s, %d) called\n", obj->GetName().c_str(), id);
   #endif

   if (!initialized)
      InitializeMeasurement();

   GmatBase *objPtr = NULL;

   Integer size = obj->GetEstimationParameterSize(id);
   Integer objNumber = -1;

   #ifdef DEBUG_DERIVATIVES
      MessageInterface::ShowMessage("   ParameterSize = %d\n", size);
   #endif

   if (size <= 0)
      throw MeasurementException("The derivative parameter on derivative "
            "object " + obj->GetName() + "is not recognized");

   // Check to see if obj is a participant
   for (UnsignedInt i = 0; i < participants.size(); ++i)
   {
      if (participants[i] == obj)
      {
         objPtr = participants[i];
         objNumber = i + 1;
         #ifdef DEBUG_DERIVATIVES
            MessageInterface::ShowMessage("   Participant %s found\n",
                  objPtr->GetName().c_str());
         #endif
         break;
      }
   }

   // Or if it is the measurement model for this object
   if (obj->IsOfType(Gmat::MEASUREMENT_MODEL))
   if (obj->GetRefObject(Gmat::CORE_MEASUREMENT, "") == this)
   {
      objPtr = obj;
      objNumber = 0;
      #ifdef DEBUG_DERIVATIVES
         MessageInterface::ShowMessage("   The measurement is the object\n",
               objPtr->GetName().c_str());
      #endif
   }

   if (objNumber == -1)
      throw MeasurementException(
            "USNTwoWayRange error - object is neither participant nor "
            "measurement model.");

   RealArray oneRow;
   oneRow.assign(size, 0.0);
   currentDerivatives.clear();
   currentDerivatives.push_back(oneRow);

   Integer parameterID = GetParmIdFromEstID(id, obj);

   #ifdef DEBUG_DERIVATIVES
      MessageInterface::ShowMessage("   Looking up id %d\n", parameterID);
   #endif

   if (objPtr != NULL)
   {
      if (objNumber == 1) // participant number 1, either a GroundStation or a Spacecraft
      {
         #ifdef DEBUG_DERIVATIVES
            MessageInterface::ShowMessage("   Deriv is w.r.t. %s of Participant"
                     " 1\n", objPtr->GetParameterText(parameterID).c_str());
         #endif
         if (objPtr->GetParameterText(parameterID) == "Position")
         {
            throw MeasurementException("Derivative w.r.t. " +
                  participants[0]->GetName() +" position is not yet implemented");

//            CalculateRangeVectorInertial();
//            Rvector3 tmp, result;
//            Rvector3 rangeUnit = rangeVecInertial.GetUnitVector();
//            #ifdef DEBUG_DERIVATIVES
//               MessageInterface::ShowMessage("   RVInertial      = %.12lf %.12lf %.12lf\n",
//                        rangeVecInertial[0], rangeVecInertial[1], rangeVecInertial[2]);
//               MessageInterface::ShowMessage("   Unit RVInertial = %.12lf %.12lf %.12lf ",
//                        rangeUnit[0], rangeUnit[1], rangeUnit[2]);
//            #endif
//            if (stationParticipant)
//            {
//               for (UnsignedInt i = 0; i < 3; ++i)
//                  tmp[i] = - rangeUnit[i];
//
//               // for a Ground Station, need to rotate to the F1 frame
//               result = tmp * R_j2k_1;
//               for (UnsignedInt jj = 0; jj < 3; jj++)
//                  currentDerivatives[0][jj] = result[jj];
//            }
//            else
//            {
//               // for a spacecraft participant 1, we don't need the rotation matrices (I33)
//               for (UnsignedInt i = 0; i < 3; ++i)
//                  currentDerivatives[0][i] = - rangeUnit[i];
//            }
         }
         else if (objPtr->GetParameterText(parameterID) == "Velocity")
         {
            throw MeasurementException("Derivative w.r.t. " +
                  participants[0]->GetName() +" velocity is not yet implemented");

//            for (UnsignedInt i = 0; i < 3; ++i)
//               currentDerivatives[0][i] = 0.0;
         }
         else if (objPtr->GetParameterText(parameterID) == "CartesianX")
         {
            throw MeasurementException("Derivative w.r.t. " +
                  participants[0]->GetName() + " CartesianState is not yet implemented");
//
//            CalculateRangeVectorInertial();
//            Rvector3 tmp, result;
//            Rvector3 rangeUnit = rangeVecInertial.GetUnitVector();
//            #ifdef DEBUG_DERIVATIVES
//               MessageInterface::ShowMessage("   RVInertial      = %.12lf %.12lf %.12lf\n",
//                        rangeVecInertial[0], rangeVecInertial[1], rangeVecInertial[2]);
//               MessageInterface::ShowMessage("   Unit RVInertial = %.12lf %.12lf %.12lf ",
//                        rangeUnit[0], rangeUnit[1], rangeUnit[2]);
//            #endif
//            if (stationParticipant)
//            {
//               for (UnsignedInt i = 0; i < size; ++i)
//                  tmp[i] = - rangeUnit[i];
//
//               // for a Ground Station, need to rotate to the F1 frame
//               result = tmp * R_j2k_1;
//               for (UnsignedInt jj = 0; jj < size; jj++)
//                  currentDerivatives[0][jj] = result[jj];
//            }
//            else
//            {
//               // for a spacecraft participant 1, we don't need the rotation matrices (I33)
//               for (UnsignedInt i = 0; i < size; ++i)
//                  currentDerivatives[0][i] = - rangeUnit[i];
//            }
//            // velocity all zeroes
//            for (UnsignedInt ii = 3; ii < size; ii++)
//               currentDerivatives[0][ii] = 0.0;
         }
         else if (objPtr->GetParameterText(parameterID) == "Bias")
         {
            for (Integer i = 0; i < size; ++i)
               currentDerivatives[0][i] = 1.0;
         }
         else
         {
            #ifdef DEBUG_DERIVATIVES
               MessageInterface::ShowMessage("   Deriv is w.r.t. something "
                        "independent, so zero\n");
            #endif
            for (Integer i = 0; i < size; ++i)
               currentDerivatives[0][i] = 0.0;
         }

      }
      else if (objNumber == 2) // participant 2, always a Spacecraft
      {
         #ifdef DEBUG_DERIVATIVES
            MessageInterface::ShowMessage("   Deriv is w.r.t. %s of Participant"
                     " 2\n", objPtr->GetParameterText(parameterID).c_str());
         #endif

         if (objPtr->GetParameterText(parameterID) == "Position")
         {
            // Get the inverse of the orbit STM at the measurement epoch
            // Will need adjustment if stm changes
            Rmatrix stmInv(6,6);
            GetInverseSTM(obj, stmInv);

            Rvector3 uplinkRderiv;
            GetRangeDerivative(uplinkLeg, stmInv, uplinkRderiv, false, 0, 1,
                  true, false);

            // Downlink leg
            Rvector3 downlinkRderiv;
            GetRangeDerivative(downlinkLeg, stmInv, downlinkRderiv, false, 0, 1,
                  true, false);

            // Add 'em up per eq 7.52 and 7.53
            for (Integer i = 0; i < size; ++i)
               currentDerivatives[0][i] =
                     0.5 * (uplinkRderiv[i] + downlinkRderiv[i]);
            #ifdef DEBUG_DERIVATIVES
               MessageInterface::ShowMessage("Position Derivative: [%.12lf "
                     "%.12lf %.12lf]\n", currentDerivatives[0][0],
                     currentDerivatives[0][1], currentDerivatives[0][2]);
            #endif
         }
         else if (objPtr->GetParameterText(parameterID) == "Velocity")
         {
            // Get the inverse of the orbit STM at the measurement epoch
            // Will need adjustment if stm changes
            Rmatrix stmInv(6,6);
            GetInverseSTM(obj, stmInv);

            Rvector3 uplinkVderiv;
            GetRangeDerivative(uplinkLeg, stmInv, uplinkVderiv, false, 0, 1,
                  false);

            // Downlink leg
            Rvector3 downlinkVderiv;
            GetRangeDerivative(downlinkLeg, stmInv, downlinkVderiv, false, 0, 1,
                  false);

            // Add 'em up per eq 7.52 and 7.53
            for (Integer i = 0; i < size; ++i)
               currentDerivatives[0][i] =
                     0.5 * (uplinkVderiv[i] + downlinkVderiv[i]);
            #ifdef DEBUG_DERIVATIVES
               MessageInterface::ShowMessage("Velocity Derivative: [%.12lf "
                     "%.12lf %.12lf]\n", currentDerivatives[0][0],
                     currentDerivatives[0][1], currentDerivatives[0][2]);
            #endif
         }
         else if (objPtr->GetParameterText(parameterID) == "CartesianX")
         {
            // Get the inverse of the orbit STM at the measurement epoch
            // Will need adjustment if stm changes
            Rmatrix stmInv(6,6);
            GetInverseSTM(obj, stmInv);

            Rvector6 uplinkDeriv;
            GetRangeDerivative(uplinkLeg, stmInv, uplinkDeriv, false);

            // Downlink leg
            Rvector6 downlinkDeriv;
            GetRangeDerivative(downlinkLeg, stmInv, downlinkDeriv, false);


            // Add 'em up per eq 7.52 and 7.53
            for (Integer i = 0; i < 6; ++i)
               currentDerivatives[0][i] =
                     0.5 * (uplinkDeriv[i] + downlinkDeriv[i]);
            #ifdef DEBUG_DERIVATIVES
               MessageInterface::ShowMessage("CartesianState Derivative: "
                     "[%.12lf %.12lf %.12lf %.12lf %.12lf %.12lf]\n",
                     currentDerivatives[0][0], currentDerivatives[0][1],
                     currentDerivatives[0][2], currentDerivatives[0][3],
                     currentDerivatives[0][4], currentDerivatives[0][5]);
            #endif
      }
      else if (objPtr->GetParameterText(parameterID) == "Bias")
      {
         for (Integer i = 0; i < size; ++i)
            currentDerivatives[0][i] = 1.0;
      }
      else
      {
         for (Integer i = 0; i < size; ++i)
            currentDerivatives[0][i] = 0.0;
      }

   }
   else if (objNumber == 0) // measurement model
   {
      #ifdef DEBUG_DERIVATIVES
         MessageInterface::ShowMessage("   Deriv is w.r.t. %s of the "
                  "measurement model\n",
                  objPtr->GetParameterText(parameterID).c_str());
      #endif
      if (objPtr->GetParameterText(parameterID) == "Bias")
      {
         for (Integer i = 0; i < size; ++i)
            currentDerivatives[0][i] = 1.0;
      }
   }
   else
   {
      #ifdef DEBUG_DERIVATIVES
         MessageInterface::ShowMessage("   Deriv is w.r.t. %s of a non-"
                  "Participant\n",
                  objPtr->GetParameterText(parameterID).c_str());
      #endif
      for (Integer i = 0; i < size; ++i)
         currentDerivatives[0][i] = 0.0;
   }

      #ifdef DEBUG_DERIVATIVES
         MessageInterface::ShowMessage("   Deriv =\n   ");

         for (Integer i = 0; i < size; ++i)
            MessageInterface::ShowMessage("   %.12le",currentDerivatives[0][i]);
         MessageInterface::ShowMessage("\n");
      #endif
   }
   return currentDerivatives;
}
Exemple #24
0
//------------------------------------------------------------------------------
bool RunSimulator::Initialize()
{
   bool retval = false;

   // First set the simulator object
   if (solverName == wxT(""))
      throw CommandException(wxT("Cannot initialize RunSimulator command -- the ")
            wxT("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(wxT("Cannot initialize RunSimulator command -- the ")
            wxT("simulator named ") + solverName + wxT(" cannot be found."));

   if (!simObj->IsOfType(wxT("Simulator")))
      throw CommandException(wxT("Cannot initialize RunSimulator command -- the ")
            wxT("object named ") + solverName + wxT(" 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(wxT("Did not find the object named ") +
               streamList[ms]);
   }

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

   #ifdef DEBUG_INITIALIZATION
      MessageInterface::ShowMessage(wxT("Propagator at address %p "), obj);
      if (obj != NULL)
         MessageInterface::ShowMessage(wxT("is named %s\n"),
               obj->GetName().c_str());
      else
         MessageInterface::ShowMessage(wxT("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();
         }
         propagators.push_back(ps);
         p.push_back(ps->GetPropagator());
         fm.push_back(ps->GetODEModel());
         retval = true;
      }
   }
   else
      throw CommandException(wxT("Cannot initialize RunSimulator command; the ")
            wxT("propagator pointer in the Simulator ") +
            theSimulator->GetName() + wxT(" is NULL."));

   // Now set the participant list
   MeasurementManager *mm = theSimulator->GetMeasurementManager();
   StringArray participants = mm->GetParticipantList();

   #ifdef DEBUG_INITIALIZATION
      MessageInterface::ShowMessage(wxT("RunSimulator command found %d ")
            wxT("participants\n"), participants.size());
   #endif

   propObjectNames.clear();
   propObjectNames.push_back(participants);

   // Now we can initialize the propagation subsystem by calling up the
   // inheritance tree.
   retval = RunSolver::Initialize();

   #ifdef DEBUG_INITIALIZATION
      if (retval == false)
         MessageInterface::ShowMessage(wxT("RunSimulator command failed to ")
               wxT("initialize; RunSolver::Initialize() call failed.\n"));
   #endif

   return retval;
}
//------------------------------------------------------------------------------
// virtual void SaveData()
//------------------------------------------------------------------------------
void GroundTrackPlotPanel::SaveData()
{
   #if DEBUG_PANEL_SAVE
   MessageInterface::ShowMessage
      ("GroundTrackPlotPanel::SaveData() entered, mHasCentralBodyChanged=%d, "
       " mHasObjectListChanged=%d\n   mHasIntegerDataChanged=%d, "
       "mHasTextureMapChanged=%d\n", mHasCentralBodyChanged, mHasObjectListChanged,
       mHasIntegerDataChanged, mHasTextureMapChanged);
   #endif
   
   canClose = true;
   std::string str1, str2;
   Integer collectFreq = 0, updateFreq = 0, pointsToRedraw = 0;
   
   //-----------------------------------------------------------------
   // check values from text field
   //-----------------------------------------------------------------
   
   if (mHasIntegerDataChanged)
   {
      CheckInteger(collectFreq, mDataCollectFreqTextCtrl->GetValue().c_str(),
                   "DataCollectFrequency", "Integer Number > 0", false, true, true);
      
      CheckInteger(updateFreq, mUpdatePlotFreqTextCtrl->GetValue().c_str(),
                   "UpdatePlotFrequency", "Integer Number > 0", false, true, true);
      
      CheckInteger(pointsToRedraw, mNumPointsToRedrawTextCtrl->GetValue().c_str(),
                   "NumPointsToRedraw", "Integer Number >= 0", false, true, true, true);
   }
      
   if (!canClose)
      return;
   
   //-----------------------------------------------------------------
   // save values to base, base code should do the range checking
   //-----------------------------------------------------------------
   GmatBase *clonedObj = mGroundTrackPlot->Clone();
   try
   {
      if (mHasCentralBodyChanged)
      {
         std::string newCentralBody = mCentralBodyComboBox->GetValue().WX_TO_STD_STRING;
         std::string newTexture = mTextureMapTextCtrl->GetValue().WX_TO_STD_STRING;
         clonedObj->SetStringParameter("CentralBody", newCentralBody);
         mHasCentralBodyChanged = false;
         // Set mHasTextureMapChanged to true so that it can be validated below (LOJ: 2014.11.03)
         mHasTextureMapChanged = true;
      }
      
      if (mHasObjectListChanged)
      {
         #if DEBUG_PANEL_SAVE
         MessageInterface::ShowMessage("   Saving object list\n");
         #endif
         clonedObj->TakeAction("Clear");
         int count = mObjectCheckListBox->GetCount();
         for (int i = 0; i < count; i++)
         {
            if (mObjectCheckListBox->IsChecked(i))
            {
               std::string objName =  mObjectCheckListBox->GetString(i).WX_TO_STD_STRING;
               #ifdef DEBUG_PANEL_SAVE
               MessageInterface::ShowMessage("   objName = '%s'\n", objName.c_str());
               #endif
               clonedObj->SetStringParameter("Add", objName);
            }
         }
         mHasObjectListChanged = false;
      }
      
      if (mHasIntegerDataChanged)
      {
         #if DEBUG_PANEL_SAVE
         MessageInterface::ShowMessage("   Saving Integer data\n");
         #endif
         clonedObj->SetIntegerParameter("DataCollectFrequency", collectFreq);
         clonedObj->SetIntegerParameter("UpdatePlotFrequency", updateFreq);
         clonedObj->SetIntegerParameter("NumPointsToRedraw", pointsToRedraw);
         mHasIntegerDataChanged = false;
      }
      
      if (mHasDataOptionChanged)
      {
         #if DEBUG_PANEL_SAVE
         MessageInterface::ShowMessage("   Saving drawing options\n");
         #endif
         clonedObj->SetBooleanParameter("ShowPlot", mShowPlotCheckBox->GetValue());
         clonedObj->SetStringParameter("SolverIterations",
                                       mSolverIterComboBox->GetValue().c_str());
         mHasDataOptionChanged = false;
      }
      
      // Save texture map
      if (mHasTextureMapChanged)
      {
         #if DEBUG_PANEL_SAVE
         MessageInterface::ShowMessage("   Saving new texture map\n");
         #endif
         // Validate texture map file (LOJ: 2014.10.30)
         wxString wxTextureMap = mTextureMapTextCtrl->GetValue();
         std::string textureMap = wxTextureMap.WX_TO_STD_STRING;
         if (clonedObj->IsParameterValid("TextureMap", textureMap))
         {
            clonedObj->SetStringParameter("TextureMap", textureMap);
            // If texture map file is blank, display default one
            if (wxTextureMap == "")
               mTextureMapTextCtrl->SetValue(STD_TO_WX_STRING(clonedObj->GetStringParameter("TextureMap").c_str()));
            mHasTextureMapChanged = false;
         }
         else
         {
            // Recheck central body
            mHasCentralBodyChanged = true;
            canClose = false;
            MessageInterface::PopupMessage(Gmat::ERROR_, clonedObj->GetLastErrorMessage());
         }
      }
      
      #ifdef __USE_COLOR_FROM_SUBSCRIBER__
      // Save orbit colors
      if (mHasOrbitColorChanged)
      {
         SaveObjectColors("Orbit", mOrbitColorMap);
         mHasOrbitColorChanged = false;
      }
      
      // Save target colors
      if (mHasTargetColorChanged)
      {
         SaveObjectColors("Target", mTargetColorMap);
         mHasTargetColorChanged = false;
      }
      #endif
      
      // Copy new values to original object (LOJ: 2014.10.30)
      if (canClose)
      {
         mGroundTrackPlot->Copy(clonedObj);
         mCentralBody = mCentralBodyComboBox->GetValue().c_str();
         mTextureFile = mTextureMapTextCtrl->GetValue().c_str();
         EnableUpdate(false);
      }
   }
   catch (BaseException &e)
   {
      canClose = false;
      MessageInterface::PopupMessage(Gmat::ERROR_, e.GetFullMessage().c_str());
   }
   
   delete clonedObj;
   
   #if DEBUG_PANEL_SAVE
   MessageInterface::ShowMessage("GroundTrackPlotPanel::SaveData() exiting.\n");
   #endif
}
Exemple #26
0
//------------------------------------------------------------------------------
bool BeginFiniteBurn::Initialize()
{
   bool retval = GmatCommand::Initialize();
   
   #ifdef DEBUG_BEGIN_MANEUVER
      MessageInterface::ShowMessage
         ("BeginFiniteBurn::Initialize() entered. burnName=%s\n", burnName.c_str());
   #endif
   
   GmatBase *mapObj = NULL;
   if (retval)
   {
      // Look up the maneuver object
      if ((mapObj = FindObject(burnName)) == NULL) 
         throw CommandException("Unknown finite burn \"" + burnName + "\"\n");
      if (mapObj->IsOfType("FiniteBurn") == false)
         throw CommandException(burnName + " is not a FiniteBurn\n");

      maneuver = (FiniteBurn*)mapObj;

      #ifdef DEBUG_BEGIN_MANEUVER
         MessageInterface::ShowMessage(
            "BeginFiniteBurn::Initialize() found %s with type %s\n", 
            maneuver->GetName().c_str(), maneuver->GetTypeName().c_str());
      #endif      

      // 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("Unknown SpaceObject \"" + (*scName) + "\"");

         if (mapObj->IsOfType(Gmat::SPACECRAFT) == false)
            throw CommandException((*scName) + " is not a Spacecraft");
         sc = (Spacecraft*)mapObj;

         #ifdef DEBUG_BEGIN_MANEUVER
            MessageInterface::ShowMessage(
               "BeginFiniteBurn::Initialize() found %s with type %s\n", 
               scName->c_str(), sc->GetTypeName().c_str());
         #endif
         
         sats.push_back(sc);
      }
      
      // Delete old burnForce
      if (burnForce != NULL)
      {
         #ifdef DEBUG_MEMORY
         MemoryTracker::Instance()->Remove
            (burnForce, burnForce->GetName(), "BeginFiniteBurn::Initialize()",
             "deleting burn force");
         #endif
         if (transientForces != NULL)
         {
            std::vector<PhysicalModel *>::iterator transient = find(
               transientForces->begin(), transientForces->end(), burnForce);
            if (transient != transientForces->end())
            {
               #ifdef DEBUG_TRANSIENTFORCE_MANAGEMENT
                  MessageInterface::ShowMessage("Removing burn force <%p> from "
                        "the transient force list\n", burnForce);
               #endif
               transientForces->erase(transient);
            }
         }
         delete burnForce;
         burnForce = NULL;
      }
      
      // If all is okay, create the FiniteThrust object and configure it.
      std::string thrustName = burnName + "_FiniteThrust";
      burnForce = new FiniteThrust(thrustName);
      #ifdef DEBUG_MEMORY
      MemoryTracker::Instance()->Add
         (burnForce, thrustName, "BeginFiniteBurn::Initialize()",
          "burnForce = new FiniteThrust()");
      #endif
      
      burnForce->SetRefObject(maneuver, maneuver->GetType(),
                              maneuver->GetName());

      Gmat::ObjectType type = Gmat::SPACECRAFT;
      StringArray::iterator iter;
      
      // load up the spacecraft name list
      for (iter = satNames.begin(); iter != satNames.end(); ++iter)
      {
         #ifdef DEBUG_BEGIN_MANEUVER
            MessageInterface::ShowMessage(
               "BeginFiniteBurn::Initialize() setting %s on %s\n", 
               iter->c_str(), thrustName.c_str());
         #endif
         burnForce->SetRefObjectName(type, *iter);
      }
   }
   
   #ifdef DEBUG_BEGIN_MANEUVER
   MessageInterface::ShowMessage
      ("BeginFiniteBurn::Initialize() returning %d\n", isInitialized);
   #endif
   
   return isInitialized;
}
Exemple #27
0
//------------------------------------------------------------------------------
bool Target::Initialize()
{
    GmatBase *mapObj = NULL;
    cloneCount = 0;

    if ((mapObj = FindObject(solverName)) == NULL)
    {
        wxString errorString = wxT("Target command cannot find targeter \"");
        errorString += solverName;
        errorString += wxT("\"");
        throw CommandException(errorString, Gmat::ERROR_);
    }

    // Clone the targeter for local use
#ifdef DEBUG_TARGET_INIT
    MessageInterface::ShowMessage
    (wxT("Target::Initialize() cloning mapObj <%p>'%s'\n"), mapObj,
     mapObj->GetName().c_str());
    MessageInterface::ShowMessage
    (wxT("mapObj maxIter=%d\n"),
     mapObj->GetIntegerParameter(mapObj->GetParameterID(wxT("MaximumIterations"))));
#endif

    // Delete the old cloned solver
    if (theSolver)
    {
#ifdef DEBUG_MEMORY
        MemoryTracker::Instance()->Remove
        (theSolver, wxT("local solver", "Target::Initialize()"),
         wxT("deleting local cloned solver"));
#endif
        delete theSolver;
    }

    theSolver = (Solver *)(mapObj->Clone());
    if (theSolver != NULL)
        ++cloneCount;

#ifdef DEBUG_MEMORY
    MemoryTracker::Instance()->Add
    (theSolver, theSolver->GetName(), wxT("Target::Initialize()"),
     wxT("theSolver = (Solver *)(mapObj->Clone())"));
#endif

    theSolver->TakeAction(wxT("ResetInstanceCount"));
    mapObj->TakeAction(wxT("ResetInstanceCount"));

    theSolver->TakeAction(wxT("IncrementInstanceCount"));
    mapObj->TakeAction(wxT("IncrementInstanceCount"));

    if (theSolver->GetStringParameter(wxT("ReportStyle")) == wxT("Debug"))
        targeterInDebugMode = true;
    theSolver->SetStringParameter(wxT("SolverMode"),
                                  GetStringParameter(SOLVER_SOLVE_MODE));
    theSolver->SetStringParameter(wxT("ExitMode"),
                                  GetStringParameter(SOLVER_EXIT_MODE));

    // Set the local copy of the targeter on each node
    std::vector<GmatCommand*>::iterator node;
    GmatCommand *current;
    specialState = Solver::INITIALIZING;

    for (node = branch.begin(); node != branch.end(); ++node)
    {
        current = *node;

#ifdef DEBUG_TARGET_COMMANDS
        Integer nodeNum = 0;
#endif
        while ((current != NULL) && (current != this))
        {
#ifdef DEBUG_TARGET_COMMANDS
            MessageInterface::ShowMessage(
                wxT("   Target Command %d:  %s\n"), ++nodeNum,
                current->GetTypeName().c_str());
#endif
            if ((current->GetTypeName() == wxT("Vary")) ||
                    (current->GetTypeName() == wxT("Achieve")))
                current->SetRefObject(theSolver, Gmat::SOLVER, solverName);
            current = current->GetNext();
        }
    }

    bool retval = SolverBranchCommand::Initialize();

    if (retval == true) {
        // Targeter specific initialization goes here:
        if (FindObject(solverName) == NULL)
        {
            wxString errorString = wxT("Target command cannot find targeter \"");
            errorString += solverName;
            errorString += wxT("\"");
            throw CommandException(errorString);
        }

        retval = theSolver->Initialize();
    }

    targeterInFunctionInitialized = false;
    return retval;
}
Exemple #28
0
//------------------------------------------------------------------------------
// void SaveChildPositionAndSize()
//------------------------------------------------------------------------------
void GmatMdiChildFrame::SaveChildPositionAndSize()
{
   if (mCanSaveLocation == false)
      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;
      //theParent->GetClientSize(&screenWidth, &screenHeight);
      GmatAppData::Instance()->GetMainFrame()->GetActualClientSize(&screenWidth, &screenHeight, true);
   #endif

//   #ifdef DEBUG_PERSISTENCE
//   wxRect      wxR         = GetScreenRect();
//   wxPoint     wxP         = wxR.GetPosition();
//   wxSize      wxS         = wxR.GetSize();
//   Integer     x           = (Integer) wxP.x;
//   Integer     y           = (Integer) wxP.y;
//   Integer     w           = (Integer) wxS.GetWidth();
//   Integer     h           = (Integer) wxS.GetHeight();
//   MessageInterface::ShowMessage
//      (wxT("wxP.x = %d, wxP.y = %d, wxS.w = %d, wxS.h = %d\n"), x, y, w, h);
//   #endif

   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));

   #ifdef DEBUG_PERSISTENCE
   // ======================= begin temporary ==============================
   MessageInterface::ShowMessage(wxT("*** Size of SCREEN %s is: width = %d, height = %d\n"), mPlotName.c_str(), screenWidth, screenHeight);
   MessageInterface::ShowMessage(wxT("Position of View plot %s is: x = %d, y = %d\n"), mPlotName.c_str(), tmpX, tmpY);
   MessageInterface::ShowMessage(wxT("Size of View plot %s is: width = %d, height = %d\n"), mPlotName.c_str(), tmpW, tmpH);
//   MessageInterface::ShowMessage(wxT("Position of View plot %s in pixels rel. to parent window is: x = %d, y = %d\n"),
//                                 mPlotName.c_str(), (Integer) tmpX, (Integer) tmpY);
//   MessageInterface::ShowMessage(wxT("Size of View plot %s in pixels rel. to parent window is: x = %d, y = %d\n"),
//                                 mPlotName.c_str(), (Integer) tmpW, (Integer) tmpH);
//   wxPoint tmpPt = ScreenToClient(wxP);
//   MessageInterface::ShowMessage(wxT("--- Position of View plot %s in client coords is: x = %d, y = %d\n"),
//                                 mPlotName.c_str(), (Integer) tmpPt.x, (Integer) tmpPt.y);
   // ======================= end temporary ==============================
   #endif

   if ((mItemType == GmatTree::OUTPUT_REPORT)  || (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 =
         (Subscriber*)theGuiInterpreter->GetConfiguredObject(mPlotName.c_str());
         
      if (!obj || !obj->IsOfType(wxT("Subscriber")))
      {
         wxString errmsg = wxT("Cannot find subscriber ");
         errmsg += mPlotName + wxT("\n");
         throw SubscriberException(errmsg);
      }
      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(wxT("UpperLeft")), upperLeft);
      sub->SetRvectorParameter(sub->GetParameterID(wxT("Size")), childSize);
      sub->SetIntegerParameter(sub->GetParameterID(wxT("RelativeZOrder")), relativeZOrder);
   }
   else if (mItemType == GmatTree::MISSION_TREE_UNDOCKED)
   {
      // get the config object
      wxFileConfig *pConfig;
      pConfig = (wxFileConfig *) GmatAppData::Instance()->GetPersonalizationConfig();
      wxString location;
      location << upperLeft[0] << wxT(" ") << upperLeft[1];
      wxString size;
      size << childSize[0] << wxT(" ") << childSize[1];
      pConfig->Write(wxT("/MissionTree/UpperLeft"), location.c_str());
      pConfig->Write(wxT("/MissionTree/Size"), size.c_str());
   }
}
Exemple #29
0
//------------------------------------------------------------------------------
void TopocentricAxes::CalculateRotationMatrix(const A1Mjd &atEpoch,
                                              bool forceComputation) 
{   
   // Check to make sure that the central body is a celestial body
   itsBodyName       = bfPoint->GetStringParameter("CentralBody");
   #ifdef DEBUG_TOPOCENTRIC_AXES
      MessageInterface::ShowMessage("Origin's central body is %s\n",
            itsBodyName.c_str());
   #endif
   GmatBase *bodyPtr = bfPoint->GetRefObject(Gmat::CELESTIAL_BODY, itsBodyName);
   if (!bodyPtr)
   {
      std::string errMsg = "Central Body for a BodyFixedPoint used in a ";
      errMsg += " Topocentric Coordinate System is NULL";
      throw CoordinateSystemException(errMsg);
   }
   if (!(bodyPtr->IsOfType("CelestialBody")))
   {
      std::string errMsg = "Central Body for a BodyFixedPoint used in a ";
      errMsg += " Topocentric Coordinate System must be a Celestial Body";
      throw CoordinateSystemException(errMsg);
   }
   centralBody      = (CelestialBody*) bodyPtr;
   flattening       = centralBody->GetFlattening();
   radius           = centralBody->GetEquatorialRadius();
   bfcs             = bfPoint->GetBodyFixedCoordinateSystem();
   horizonReference = bfPoint->GetStringParameter("HorizonReference");
   if ((horizonReference != "Sphere") && (horizonReference != "Ellipsoid"))
   {
      std::string errMsg = "Unexpected horizon reference \"";
      errMsg += horizonReference + "\" received from BodyFixedPoint \"";
      errMsg += bfPoint->GetName() + "\"";
      throw CoordinateSystemException(errMsg);
   }

   // compute rotMatrix and rotDotMatrix
   // First, calculate the Rft matrix, if the position has changed
   Rvector3 newLoc  = bfPoint->GetBodyFixedLocation(atEpoch);
   
   #ifdef DEBUG_TOPOCENTRIC_AXES
      MessageInterface::ShowMessage("horizon reference is %s:\n",
            horizonReference.c_str());
      MessageInterface::ShowMessage("flattening of %s is %12.17f:\n",
            itsBodyName.c_str(), flattening);
      MessageInterface::ShowMessage("equatorial radius of %s is %12.17f:\n\n",
            itsBodyName.c_str(), radius);
      MessageInterface::ShowMessage("bfPoint's old location is:\n");
      MessageInterface::ShowMessage("%12.17f\n", bfLocation[0]);
      MessageInterface::ShowMessage("%12.17f\n", bfLocation[1]);
      MessageInterface::ShowMessage("%12.17f\n", bfLocation[2]);
      MessageInterface::ShowMessage("bfPoint's new location is:\n");
      MessageInterface::ShowMessage("%12.17f\n", newLoc[0]);
      MessageInterface::ShowMessage("%12.17f\n", newLoc[1]);
      MessageInterface::ShowMessage("%12.17f\n", newLoc[2]);
   #endif
   if (newLoc != bfLocation)
      CalculateRFT(atEpoch, newLoc);
   // save the location
   bfLocation  = newLoc;
   #ifdef DEBUG_TOPOCENTRIC_AXES
      MessageInterface::ShowMessage("Now bfLocation is set to:\n");
      MessageInterface::ShowMessage("%12.17f\n", bfLocation[0]);
      MessageInterface::ShowMessage("%12.17f\n", bfLocation[1]);
      MessageInterface::ShowMessage("%12.17f\n", bfLocation[2]);
   #endif
   // Determine rotation matrix from body-fixed to inertial
   Rvector bogusIn(6,7000.0,1000.0,6000.0, 0.0, 0.0, 0.0);
   Rvector bogusOut = bfcs->ToBaseSystem(atEpoch, bogusIn); // @todo - need ToMJ2000Eq here?
   #ifdef DEBUG_TOPOCENTRIC_AXES
      MessageInterface::ShowMessage("bogusIn:\n");
      MessageInterface::ShowMessage("%12.17f\n", bogusIn[0]);
      MessageInterface::ShowMessage("%12.17f\n", bogusIn[1]);
      MessageInterface::ShowMessage("%12.17f\n", bogusIn[2]);
      MessageInterface::ShowMessage("%12.17f\n", bogusIn[3]);
      MessageInterface::ShowMessage("%12.17f\n", bogusIn[4]);
      MessageInterface::ShowMessage("%12.17f\n", bogusIn[5]);
      MessageInterface::ShowMessage("bogusOut:\n");
      MessageInterface::ShowMessage("%12.17f\n", bogusOut[0]);
      MessageInterface::ShowMessage("%12.17f\n", bogusOut[1]);
      MessageInterface::ShowMessage("%12.17f\n", bogusOut[2]);
      MessageInterface::ShowMessage("%12.17f\n", bogusOut[3]);
      MessageInterface::ShowMessage("%12.17f\n", bogusOut[4]);
      MessageInterface::ShowMessage("%12.17f\n", bogusOut[5]);
   #endif
   Rmatrix33 RIF    = bfcs->GetLastRotationMatrix();
   Rmatrix33 RIFDot = bfcs->GetLastRotationDotMatrix();
   #ifdef DEBUG_TOPOCENTRIC_AXES
      MessageInterface::ShowMessage("last Rotation Matrix (RIF):\n");
      MessageInterface::ShowMessage("%12.17f  %12.17f  %12.17f \n",
            RIF(0,0), RIF(0,1), RIF(0,2));
      MessageInterface::ShowMessage("%12.17f  %12.17f  %12.17f \n",
            RIF(1,0), RIF(1,1), RIF(1,2));
      MessageInterface::ShowMessage("%12.17f  %12.17f  %12.17f \n",
            RIF(2,0), RIF(2,1), RIF(2,2));
      MessageInterface::ShowMessage("last Rotation Dot Matrix (RIFDot):\n");
      MessageInterface::ShowMessage("%12.17f  %12.17f  %12.17f \n",
            RIFDot(0,0), RIFDot(0,1), RIFDot(0,2));
      MessageInterface::ShowMessage("%12.17f  %12.17f  %12.17f \n",
            RIFDot(1,0), RIFDot(1,1), RIFDot(1,2));
      MessageInterface::ShowMessage("%12.17f  %12.17f  %12.17f \n",
            RIFDot(2,0), RIFDot(2,1), RIFDot(2,2));
   #endif
   
   rotMatrix        = RIF    * RFT;
   rotDotMatrix     = RIFDot * RFT;

   #ifdef DEBUG_TOPOCENTRIC_AXES
      MessageInterface::ShowMessage("rotMatrix:\n");
      MessageInterface::ShowMessage("%12.17f  %12.17f  %12.17f \n",
            rotMatrix(0,0), rotMatrix(0,1), rotMatrix(0,2));
      MessageInterface::ShowMessage("%12.17f  %12.17f  %12.17f \n",
            rotMatrix(1,0), rotMatrix(1,1), rotMatrix(1,2));
      MessageInterface::ShowMessage("%12.17f  %12.17f  %12.17f \n",
            rotMatrix(2,0), rotMatrix(2,1), rotMatrix(2,2));
      MessageInterface::ShowMessage("rotDotMatrix:\n");
      MessageInterface::ShowMessage("%12.17f  %12.17f  %12.17f \n",
            rotDotMatrix(0,0), rotDotMatrix(0,1), rotDotMatrix(0,2));
      MessageInterface::ShowMessage("%12.17f  %12.17f  %12.17f \n",
            rotDotMatrix(1,0), rotDotMatrix(1,1), rotDotMatrix(1,2));
      MessageInterface::ShowMessage("%12.17f  %12.17f  %12.17f \n",
            rotDotMatrix(2,0), rotDotMatrix(2,1), rotDotMatrix(2,2));
   #endif
}
Exemple #30
0
//------------------------------------------------------------------------------
// void LoadData()
//------------------------------------------------------------------------------
void VaryPanel::LoadData()
{
   #ifdef DEBUG_VARYPANEL_LOAD
   MessageInterface::ShowMessage("VaryPanel::LoadData() entered\n");
   MessageInterface::ShowMessage
      ("   Command=<%p>'%s'\n", mVaryCommand, mVaryCommand ?
       mVaryCommand->GetTypeName().c_str() : "NULL");
   #endif
   
   mVarNameTextCtrl->Disable(); // we don't want user to edit this box
   mViewVarButton->Enable();
   
   if (mVaryCommand == NULL)
   {
      MessageInterface::PopupMessage(Gmat::ERROR_, "The Vary command is NULL\n");
      return;
   }
   
   try
   {
      // Set the pointer for the "Show Script" button
      mObject = mVaryCommand;
      
      solverName =
         mVaryCommand->GetStringParameter(mVaryCommand->GetParameterID("SolverName"));
      
      #ifdef DEBUG_VARYPANEL_LOAD
      MessageInterface::ShowMessage("   solverName=%s\n", solverName.c_str());
      #endif
      
      variableName =
         mVaryCommand->GetStringParameter(mVaryCommand->GetParameterID("Variable"));
      
      #ifdef DEBUG_VARYPANEL_LOAD
      MessageInterface::ShowMessage("   variableName=%s\n", variableName.c_str());
      #endif
      
      wxString initValStr = 
         mVaryCommand->GetStringParameter(mVaryCommand->GetParameterID("InitialValue")).c_str();
      wxString pertStr = 
         mVaryCommand->GetStringParameter(mVaryCommand->GetParameterID("Perturbation")).c_str();
      wxString lowerStr = 
         mVaryCommand->GetStringParameter(mVaryCommand->GetParameterID("Lower")).c_str();
      wxString upperStr = 
         mVaryCommand->GetStringParameter(mVaryCommand->GetParameterID("Upper")).c_str();      
      wxString maxStepStr = 
         mVaryCommand->GetStringParameter(mVaryCommand->GetParameterID("MaxStep")).c_str();
      wxString addSfStr = 
         mVaryCommand->GetStringParameter(mVaryCommand->GetParameterID("AdditiveScaleFactor")).c_str();
      wxString multCfStr =
         mVaryCommand->GetStringParameter(mVaryCommand->GetParameterID("MultiplicativeScaleFactor")).c_str();
      
      mSolverComboBox->SetStringSelection(solverName.c_str());
      mVarNameTextCtrl->SetValue(variableName.c_str());
      
      mInitialTextCtrl->SetValue(initValStr);
      mPertTextCtrl->SetValue(pertStr);
      mLowerValueTextCtrl->SetValue(lowerStr);
      mUpperValueTextCtrl->SetValue(upperStr);
      mMaxStepTextCtrl->SetValue(maxStepStr);
      mAdditiveTextCtrl->SetValue(addSfStr);
      mMultiplicativeTextCtrl->SetValue(multCfStr);
      
      //  Enalbe or disable fields depends on the solver type
      GmatBase *solver = theGuiInterpreter->GetConfiguredObject(solverName);
      if (solver != NULL)
      {
//         mVaryCommand->SetRefObject(solver, Gmat::SOLVER, solverName);
         solver->SetStringParameter
            (solver->GetParameterID("Variables"), variableName);
         SetControlEnabling(solver);
      }
   }
   catch (BaseException &e)
   {
      MessageInterface::PopupMessage(Gmat::ERROR_, e.GetFullMessage());
   }
   
   #ifdef DEBUG_VARYPANEL_LOAD
   MessageInterface::ShowMessage("VaryPanel::LoadData() leaving\n");
   #endif
}