Esempio n. 1
0
//------------------------------------------------------------------------------
bool GmatCommandUtil::IsElseFoundInIf(GmatCommand *ifCmd)
{
   if (ifCmd == NULL)
      return false;
   
   #ifdef DEBUG_IF_ELSE
   ShowCommand
      ("===> GmatCommandUtil::IsElseFoundInIf() ifCmd = ", ifCmd);
   #endif
   
   if (!ifCmd->IsOfType("If"))
   {
      #ifdef DEBUG_IF_ELSE
      MessageInterface::ShowMessage
         ("IsElseFoundInIf() returning false, it is not If command\n");
      #endif
      return false;
   }
   
   GmatCommand *current = ifCmd;
   GmatCommand *child = NULL;
   Integer branch = 0;
   
   // Check only one level first branch
   child = current->GetChildCommand(branch);
   
   while (child != NULL)
   {
      #ifdef DEBUG_IF_ELSE
      ShowCommand("   child = ", child);
      #endif
      
      if (child->IsOfType("BranchEnd"))
      {
         if (child->GetTypeName() == "Else")
         {
            #ifdef DEBUG_IF_ELSE
            MessageInterface::ShowMessage("IsElseFoundInIf() returning true\n");
            #endif
            return true;
         }            
         break;
      }
      
      child = child->GetNext();
   }
   
   #ifdef DEBUG_IF_ELSE
   MessageInterface::ShowMessage("IsElseFoundInIf() returning false\n");
   #endif
   
   return false;
}
Esempio n. 2
0
//------------------------------------------------------------------------------
GmatCommand* GmatCommandUtil::GetSubParent(GmatCommand *brCmd, GmatCommand *cmd)
{
   #ifdef DEBUG_GET_PARENT
   ShowCommand
      ("     GmatCommandUtil::GetSubParent() brCmd = ", brCmd, ", cmd = ", cmd);
   #endif
   
   GmatCommand *current = brCmd;
   GmatCommand *child;
   GmatCommand *subParent = NULL;
   Integer childNo = 0;
   
   while((child = current->GetChildCommand(childNo)) != NULL)
   {
      while ((child != NULL) && (child != current))
      {
         if (child == cmd)
         {
            #ifdef DEBUG_GET_PARENT
            ShowCommand
               ("     GmatCommandUtil::GetSubParent() returning ", current);
            #endif
            return current;
         }
         
         if (child->GetChildCommand() != NULL)
            subParent = GetSubParent(child, cmd);
         
         if (subParent != NULL)
            return subParent;
         
         child = child->GetNext();
         
         #ifdef DEBUG_GET_PARENT
         ShowCommand
            ("     GmatCommandUtil::GetSubParent() child = ", child);
         #endif
      }
      
      ++childNo;
   }
   
   #ifdef DEBUG_GET_PARENT
   MessageInterface::ShowMessage
      ("     GmatCommandUtil::GetSubParent() returning NULL\n");
   #endif
   
   return NULL;
}
Esempio n. 3
0
//------------------------------------------------------------------------------
GmatCommand* GmatCommandUtil::GetParentCommand(GmatCommand *top, GmatCommand *cmd)
{
   #ifdef DEBUG_GET_PARENT
   ShowCommand
      ("===> GmatCommandUtil::GetParentCommand() top = ", top, ", cmd = ", cmd);
   #endif
   
   GmatCommand *current = top;
   GmatCommand *parent = NULL;
   
   while (current != NULL)
   {
      #ifdef DEBUG_GET_PARENT
      ShowCommand("     current = ", current);
      #endif
      
      if (current == cmd)
      {
         parent = top;
         break;
      }
      
      if ((current->GetChildCommand(0)) != NULL)
      {
         parent = GetSubParent(current, cmd);
         
         #ifdef DEBUG_GET_PARENT
         ShowCommand("     parent = ", current);
         #endif
         
         if (parent != NULL)
            break;
      }
      
      current = current->GetNext();
   }
   
   #ifdef DEBUG_GET_PARENT
   ShowCommand("===> GmatCommandUtil::GetParentCommand() returning ", parent);
   #endif
   
   return parent;
}
Esempio n. 4
0
void Test_Operation()// ²âÊÔ²Ù×÷
{
	int choice = 1;
	Display_Menu();
	while(choice!=0)
	{
		Display_SubMenu();
		scanf("%d",&choice);
		printf("*****************THE RESULT OF TESTING:***********\n");
		printf("\n");
		switch(choice)
		{
		case  88:ShowCommand();
			break;
		case 100:InitServer();
			break;
		case 101:ShowServerInfo();
			break;
		case 111:Display_Plnode_Client_111();
			break;
		case 201:Test_201();
			break;
		case 202:Test_202();
			break;
		case 301:Test_301();
			break;
		case 3020:Init_Test302();
			break;
		case 302:Test_302();
			break;
		case 401:Test_401();
			break;
		case 402:Test_402();
			break;
		case 403:Test_403();
			break;
		case 501:Test_501();
			break;
		case 502:Test_502();
			break;
		case 1:
			system("cls");
			Display_Menu();
			break;
		case 0: 
			break;
		}
		system("pause");
		system("cls");
	}
	printf("Test end.Press any key to exit.\n");
}
Esempio n. 5
0
//------------------------------------------------------------------------------
GmatCommand* GmatCommandUtil::GetFirstCommand(GmatCommand *cmd)
{
   #ifdef DEBUG_GET_FIRST
   ShowCommand("GmatCommandUtil::GetFirstCommand() entered, cmd = ", cmd);
   #endif
   
   GmatCommand *prevCmd = cmd;
   
   while (cmd != NULL)
   {
      cmd = cmd->GetPrevious();
      
      #ifdef DEBUG_GET_FIRST
      ShowCommand("   previous command = ", cmd);
      #endif
      
      if (cmd != NULL)
         prevCmd = cmd;
   }
   
   return prevCmd;
}
Esempio n. 6
0
//------------------------------------------------------------------------------
//void IndentChildString(wxStringstream &gen, GmatCommand* cmd, 
//                       wxString &indent, Gmat::WriteMode mode,
//                       const wxString &prefix, const wxString &useName,
//                       bool indentCommentOnly)
//------------------------------------------------------------------------------
void BeginScript::IndentChildString(wxString &gen, GmatCommand* cmd, 
                                    wxString &indent, Gmat::WriteMode mode,
                                    const wxString &prefix,
                                    const wxString &useName,
                                    bool indentCommentOnly)
{
   TextParser tp;
   
   #if DBGLVL_GEN_STRING
   ShowCommand(wxT(""), wxT("BeginScript::IndentChildString() cmd = "), cmd);
   MessageInterface::ShowMessage
      (wxT("BeginScript::IndentChildString() indent='%s', mode=%d, prefix='%s', ")
       wxT("useName='%s', indentCommentOnly=%d\n"), indent.c_str(), mode, prefix.c_str(),
       useName.c_str(), indentCommentOnly);
   #endif
   
   wxString cmdstr;
   if (indentCommentOnly)
      cmdstr = cmd->GetCommentLine();
   else
      cmdstr = cmd->GetGeneratingString(mode, prefix, useName);
   
   StringArray textArray = tp.DecomposeBlock(cmdstr);
   UnsignedInt size = textArray.size();
   
   #if DBGLVL_GEN_STRING
   MessageInterface::ShowMessage(wxT("   There are %d text lines\n"), size);
   #endif
   
   if (size > 0 && textArray[0] != wxT(""))
   {
      for (UnsignedInt i=0; i<size; i++)
      {
         if (indentCommentOnly)
            gen << indent << prefix << textArray[i];
         else
            gen << indent << textArray[i];
         
         if (textArray[i].find(wxT("\n")) == cmdstr.npos &&
             textArray[i].find(wxT("\r")) == cmdstr.npos)
         {
            gen << wxT("\n");
         }
      }
   }
   
   if (indentCommentOnly)
      gen << prefix << cmd->GetTypeName() << wxT(";");
}
Esempio n. 7
0
//------------------------------------------------------------------------------
GmatCommand* GmatCommandUtil::GetLastCommand(GmatCommand *cmd)
{
   GmatCommand *nextCmd = cmd;
   
   while (cmd != NULL)
   {
      #ifdef DEBUG_GET_LAST
      ShowCommand("===> GmatCommandUtil::GetLastCommand() cmd = ", cmd);
      #endif
      
      cmd = cmd->GetNext();
      
      if (cmd != NULL)
         nextCmd = cmd;
   }
   
   return nextCmd;
}
Esempio n. 8
0
//------------------------------------------------------------------------------
GmatCommand* GmatCommandUtil::GetPreviousCommand(GmatCommand *from,
                                                 GmatCommand *cmd)
{
   GmatCommand *current = from;
   GmatCommand *prevCmd = NULL;
   GmatCommand *child = NULL;
   Integer branch = 0;
   
   while (current != NULL)
   {
      if (current == cmd)
         return prevCmd;
      
      // check branch commands
      while ((current->GetChildCommand(branch)) != NULL)
      {
         child = current->GetChildCommand(branch);
         
         while (child != NULL)
         {
            #ifdef DEBUG_PREV_COMMAND
            ShowCommand("   child = ", child);
            #endif
            
            if (child == cmd)
               return prevCmd;
            
            prevCmd = child;
            child = child->GetNext();
         }
         
         branch++;
      }
      
      prevCmd = current;
      current = current->GetNext();
      
   }
   
   return NULL;
}
Esempio n. 9
0
void Applet::Activate()
{
  ShowCommand();
}
Esempio n. 10
0
//------------------------------------------------------------------------------
bool GmatCommandUtil::ClearCommandSeq(GmatCommand *seq, bool leaveFirstCmd,
                                      bool callRunComplete)
{
   #ifdef DEBUG_SEQUENCE_CLEARING
   MessageInterface::ShowMessage("CommandUtil::ClearCommandSeq() entered\n");
   #endif
   
   GmatCommand *cmd = seq, *removedCmd = NULL;
   
   if (cmd == NULL)
   {
      #ifdef DEBUG_SEQUENCE_CLEARING
      MessageInterface::ShowMessage
         ("CommandUtil::ClearCommandSeq() exiting, first command is NULL\n");
      #endif
      return true;
   }
   
   #ifdef DEBUG_SEQUENCE_CLEARING
   GmatCommand *current = cmd;
   MessageInterface::ShowMessage("\nClearing this command list:\n");
   while (current)
   {
      ShowCommand("   ", current);
      current = current->GetNext();
   }
   MessageInterface::ShowMessage("\n");
   #endif
   
   cmd = cmd->GetNext();
   while (cmd)
   {
      if (callRunComplete)
      {
         // Be sure we're in an idle state first
         #ifdef DEBUG_SEQUENCE_CLEARING
         MessageInterface::ShowMessage
            ("   Calling %s->RunComplete\n", cmd->GetTypeName().c_str());
         #endif
         
         cmd->RunComplete();
      }
      
      removedCmd = RemoveCommand(seq, cmd);
      
      if (removedCmd != NULL)
      {
         #ifdef DEBUG_MEMORY
         MemoryTracker::Instance()->Remove
            (removedCmd, removedCmd->GetTypeName(), "CommandUtil::ClearCommandSeq()");
         #endif
         delete removedCmd;
      }
      removedCmd = NULL;
      cmd = seq->GetNext();
   }
   
   // if first command is to be delete
   if (!leaveFirstCmd)
   {
      #ifdef DEBUG_SEQUENCE_CLEARING
      MessageInterface::ShowMessage("   seq=<%p>\n", seq);
      #endif
      
      #ifdef DEBUG_MEMORY
      MemoryTracker::Instance()->Remove
         (seq, seq->GetTypeName(), "CommandUtil::ClearCommandSeq()");
      #endif
      delete seq;
      seq = NULL;
   }
   
   #ifdef DEBUG_SEQUENCE_CLEARING
   MessageInterface::ShowMessage("CommandUtil::ClearCommandSeq() returning true\n");
   #endif
   
   return true;
}
Esempio n. 11
0
//------------------------------------------------------------------------------
GmatCommand* GmatCommandUtil::RemoveCommand(GmatCommand *seq, GmatCommand *cmd)
{
   #ifdef DEBUG_COMMAND_DELETE
   ShowCommand("==========> CommandUtil::RemoveCommand() removing ", cmd,
               " from ", seq);
   #endif
   
   if (cmd == NULL)
      return NULL;
   
   GmatCommand *remvCmd;
   if (cmd->GetTypeName() != "BeginScript")
   {
      GmatCommand *remvCmd = seq->Remove(cmd);
      
      #ifdef DEBUG_COMMAND_DELETE
      ShowCommand("   Removed = ", remvCmd);
      #endif
      
      #ifdef DEBUG_COMMAND_DELETE
      ShowCommand("==========> CommandUtil::RemoveCommand() Returning ", remvCmd);
      #endif
      
      return remvCmd;
   }
   
   //-------------------------------------------------------
   // Remove commands inside Begin/EndScript block
   //-------------------------------------------------------

   // Check for previous command, it should not be NULL,
   // since "NoOp" is the first command
   
   GmatCommand *prevCmd = cmd->GetPrevious();
   if (prevCmd == NULL)
   {
      MessageInterface::PopupMessage
         (Gmat::ERROR_, "CommandUtil::RemoveCommand() *** INTERNAL ERROR *** \n"
          "The previous command cannot be NULL.\n");
      return NULL;
   }
   
   ////GmatCommand *first = GetFirstCommand();
   GmatCommand *first = seq;
   
   #ifdef DEBUG_COMMAND_DELETE
   std::string cmdString1 = GmatCommandUtil::GetCommandSeqString(first);
   MessageInterface::ShowMessage("     ==> Current sequence:");
   MessageInterface::ShowMessage(cmdString1);
   #endif
   
   GmatCommand *current = cmd->GetNext();
   
   #ifdef DEBUG_COMMAND_DELETE
   GmatCommand *nextCmd = GmatCommandUtil::GetNextCommand(cmd);
   ShowCommand("     prevCmd = ", prevCmd, " nextCmd = ", nextCmd);
   #endif
   
   // Get matching EndScript for BeginScript
   GmatCommand *endScript = GmatCommandUtil::GetMatchingEnd(cmd);
   
   #ifdef DEBUG_COMMAND_DELETE
   ShowCommand("     endScript = ", endScript);
   #endif
   
   GmatCommand* next;
   while (current != NULL)
   {
      #ifdef DEBUG_COMMAND_DELETE
      ShowCommand("     current = ", current);
      #endif
      
      if (current == endScript)
         break;
      
      next = current->GetNext();
      
      #ifdef DEBUG_COMMAND_DELETE
      ShowCommand("     removing and deleting ", current);
      #endif
      
      remvCmd = cmd->Remove(current);
      
      // per kw report - check remvCmd first
      if (remvCmd != NULL)
      {
         remvCmd->ForceSetNext(NULL);
         
         #ifdef DEBUG_MEMORY
         MemoryTracker::Instance()->Remove
            (remvCmd, remvCmd->GetTypeName(), "CommandUtil::RemoveCommand()");
         #endif
         delete remvCmd;
      }
      
      current = next;
   }
   
   //-------------------------------------------------------
   // Remove and delete EndScript
   //-------------------------------------------------------
   #ifdef DEBUG_COMMAND_DELETE
   ShowCommand("     removing and deleting ", current);
   #endif
   
   remvCmd = cmd->Remove(current);
   
   // per kw report - check remvCmd first
   if (remvCmd != NULL)
   {
      remvCmd->ForceSetNext(NULL);
      
      #ifdef DEBUG_MEMORY
      MemoryTracker::Instance()->Remove
         (remvCmd, remvCmd->GetTypeName(), "CommandUtil::RemoveCommand()");
      #endif
      delete remvCmd;
      remvCmd = NULL;
   }
   
   next = cmd->GetNext();
   
   #ifdef DEBUG_COMMAND_DELETE
   ShowCommand("     next    = ", next, " nextCmd = ", nextCmd);
   #endif
   
   //-------------------------------------------------------
   // Remove and delete BeginScript
   //-------------------------------------------------------
   #ifdef DEBUG_COMMAND_DELETE
   ShowCommand("     removing and deleting ", cmd);
   #endif
   
   // Remove BeginScript
   remvCmd = first->Remove(cmd);
   
   // Set next command NULL
   cmd->ForceSetNext(NULL);
   if (cmd != NULL)
   {
      #ifdef DEBUG_MEMORY
      MemoryTracker::Instance()->Remove
         (cmd, cmd->GetTypeName(), "CommandUtil::RemoveCommand()");
      #endif
      delete cmd;
      cmd = NULL;
   }
   
   #ifdef DEBUG_COMMAND_DELETE
   std::string cmdString2 = GmatCommandUtil::GetCommandSeqString(first);
   MessageInterface::ShowMessage("     ==> sequence after delete:");
   MessageInterface::ShowMessage(cmdString2);
   ShowCommand("==========> CommandUtil::RemoveCommand() Returning cmd = ", cmd);
   #endif
   
   // Just return cmd, it should be deleted by the caller.
   return cmd;
}
Esempio n. 12
0
//------------------------------------------------------------------------------
GmatCommand* GmatCommandUtil::GetMatchingEnd(GmatCommand *cmd, bool getMatchingElse)
{
   if (cmd == NULL)
      return NULL;
   
   #ifdef DEBUG_MATCHING_END
   ShowCommand
      ("===> GmatCommandUtil::GetMatchingEnd() cmd = ", cmd);
   #endif
   
   if (cmd->GetTypeName() != "BeginScript" && !cmd->IsOfType("BranchCommand"))
      return NULL;
   
   GmatCommand *current = cmd;
   
   if (cmd->GetTypeName() == "BeginScript")
   {
      Integer scriptEventCount = 0;
   
      while (current != NULL)
      {
         if (current->GetTypeName() == "BeginScript")
            scriptEventCount++;
      
         if (current->GetTypeName() == "EndScript")
            scriptEventCount--;

         #ifdef DEBUG_MATCHING_END
         MessageInterface::ShowMessage
            ("     scriptEventCount=%d, current=<%p><%s>\n", scriptEventCount, current,
             current->GetTypeName().c_str());
         #endif
      
         if (scriptEventCount == 0)
            break;
      
         current = current->GetNext();
      }
      
      #ifdef DEBUG_MATCHING_END
      ShowCommand("===> GmatCommandUtil::GetMatchingEnd() returning ", current);
      #endif
   
      return current;
   }
   else
   {
      GmatCommand *child = NULL;
      Integer branch = 0;
      bool elseFound = false;
      
      while ((current->GetChildCommand(branch)) != NULL)
      {
         child = current->GetChildCommand(branch);
         
         while (child != NULL)
         {
            #ifdef DEBUG_MATCHING_END
            ShowCommand("   child = ", child);
            #endif
            
            if (child->IsOfType("BranchEnd"))
            {
               if (child->GetTypeName() == "Else")
               {
                  elseFound = true;
                  if (getMatchingElse)
                     break;
                  
                  branch++;
               }
               
               break;
            }
            
            child = child->GetNext();
         }
         
         if (elseFound && branch == 1)
         {
            elseFound = false;
            continue;
         }
         else
            break;
      }
      
      #ifdef DEBUG_MATCHING_END
      ShowCommand("===> GmatCommandUtil::GetMatchingEnd() returning ", child);
      #endif
      
      return child;
   }
}