Esempio n. 1
0
void NodeActionsExecutor::execute(const Array<Node*>& nodes)
{
   std::set<NodeAction*> actions;

   unsigned int nodesCount = nodes.size();
   for (unsigned int i = 0; i < nodesCount; ++i)
   {
      findActionNodes(*(nodes[i]), actions);
   }

   executeActions(actions);
}
Esempio n. 2
0
void NodeActionsExecutor::execute(Node& node)
{
   std::set<NodeAction*> actions;
   findActionNodes(node, actions);
   executeActions(actions);
}
Esempio n. 3
0
void processRunCommand() {  

  char rounds = 1;
  short int roundDelay = 0; // ms
  
  // TODO use sscanf instead?
  
  // read number of rounds
  char* argToken = strtok(NULL, FIELD_SEPARATOR);
  if(argToken != NULL) {
    rounds = atoi(argToken);
            
    // read round delay
    argToken = strtok(NULL, FIELD_SEPARATOR);
    if(argToken != NULL) {
       roundDelay = atoi(argToken);
    }
    
  }
  
  // TODO brenner: ignore further input or check?
  
  long startMillis = millis();
  
  // execute actions on droplet
  for(int i = 1; i <= rounds; ) {
    
    long roundStartMillis =  startMillis + (i * (long) roundDelay);
    long currentMillis = millis();
    
    // execute next round at the right time
    if(currentMillis - roundStartMillis >= 0) {
      
      Serial.println("roundDelay " + String(roundDelay));
      Serial.println("roundStartMillis " + String(roundStartMillis));
      Serial.println("currentMillis " + String(currentMillis));
      
      Serial.println("Execute round #" + String(i));
      executeActions();
      i++;
    }
    
    // check if execution should be cancled
    if(Serial.available()) {
      char inChar = (char) Serial.peek();
      if(inChar == CMD_CANCEL) {
        
        // remove serial input from stream
        Serial.read(); // remove cancle command from stream
        // TODO brenner: remove newline from stream
        
        logging(INFO, "execution cancled");
        return;
      }
    }
   
  }
  
  logging(INFO, "Finished execution");
  
}
Esempio n. 4
0
/*
* Update the game objects based on the physics
*/
void Game::doPhysics() {
	executeActions();								
}
Esempio n. 5
0
int main (void) {
  /* program to coordinate the menu options and calls the requested 
     function */ 

  struct node * first = NULL;   /* pointer to the first list item */
  char option[strMax];          /* user response to menu selection */

  printf ("Program to Maintain a List of Robot Actions\n");

  while (1) {
    /* print menu options */
    printf ("Options available\n");
    printf ("I - Insert an action into the list\n");
    printf ("D - Delete an action from the list\n");
    printf ("C - Count the number of items in the list\n");
    printf ("F - Move an item to the front of the list\n");
    printf ("L - Print the last item in the list\n");
    printf ("P - Print the actions in the list and the UIDs of the nodes\n");
    printf ("R - Print the actions and UIDs in reverse order\n");
    printf ("E - Execute all the action commands contained in the list\n");
    printf ("Q - Quit\n");

    /* determine user selection */
    printf ("Enter desired option: ");
    scanf ("%s", option);
    
    switch (option[0])
      { case 'I':
      case 'i': 
        addAction(&first);
        break;
      case 'D':
      case 'd': 
        deleteAction(&first);
        break;
      case 'C':
      case 'c': 
        countList(first);
        break;
      case 'F':
      case 'f': 
        putFirst(&first);
        break;
      case 'L':
      case 'l': 
        printLast(first);
        break;
      case 'P':
      case 'p': 
        print(first);
        break;
      case 'R':
      case 'r': 
        printReverse(first);
        break;
      case 'E':
      case 'e':
        executeActions(first);
        break;
      case 'Q':
      case 'q':
        printf ("Program terminated\n");
        return 0;
        break;
      default: printf ("Invalid Option - Try Again!\n");
        continue;
      }
  }
}