///------------------------------------------------------------------
/// Retrieves an integer property from the specified Node
///------------------------------------------------------------------
int GetIntProperty( const XMLNode& node, const std::string& propertyName, int defaultValue )
{
	std::string	propertyString	= GetPropertyValueAsString( node, propertyName );
	int		propertyValue	= defaultValue ;

	if ( propertyString.length() )
		propertyValue			= GetIntFromString( propertyString );

	return propertyValue ;
}
Exemplo n.º 2
0
void handleReadCommand(StringArray commandList)
{
  DebugPrint("Function handleReadCommand"); 
  String temp = "";
  if (commandList.GetElementCount() > 1)
    temp = commandList.GetString(1);
  else
    temp = "0";

  int test = GetIntFromString(temp);

  byte data = EEPROM.read(test);
  String outputstring = commandList.GetString(1) + ": [" + commandList.GetString(1) + "]: " + String(data,HEX) + "\0";

  PrintMessage(outputstring);   
}
Exemplo n.º 3
0
int
DoPtsUserMaxSet(struct cmd_syndesc *as, void *arock)
{
    enum { MAX };
    afs_status_t st = 0;
    const char *max = as->parms[MAX].items->data;
    int max_user_id;

    max_user_id = GetIntFromString(max, "bad user id");

    if (!pts_UserMaxSet(cellHandle, max_user_id, &st)) {
	ERR_ST_EXT("pts_UserMaxSet", st);
    }

    return 0;
}
Exemplo n.º 4
0
void handleSerialCommands()
{
  DebugPrint("Function handleSerialCommands");
  StringArray commandList = GetCommandList(INPUT_STRING);
  String command = commandList.GetString(0);

  DebugPrint("Command was: " + command);

  // RobotControl
  // Switch Robot On
  if (command == "ON")
  {
    GLOBAL_IS_CONNECTED = true;
    digitalWrite(13,HIGH);
    Servos_Init();
    PrintMessage(command); 
  }
  // Switch Robot Off
  else if (command == "OFF")
  {
    GLOBAL_IS_CONNECTED = false;
    PrintMessage("OFF"); 
    digitalWrite(13,LOW);
    Servos_Release();
  } 
  // EEPROM Handling
  // Store Movement List
  else if (command == "STORE")
  {
    SaveToEEPROM();
  }
  // Retrieve Movement List  
  else if (command == "GET")
  {
    // PrintMessage("get");
    LoadFromEEPROM();
  }
  // Erase Movement List
  else if (command == "ERASE")
  {
    ClearEEPROM();
  }  
  // READ Specified EEPROM Address
  else if (command == "READ")
  {
    handleReadCommand(commandList);
  } 
  // Servohandling
  // Move Servo
  else if (command == "MOVE")
  {
    Move_Servo(commandList);
    /*
    int oldValue = servo.read();
     int newValue = GetIntFromString(commandList.GetString(1));
     
     if (oldValue <= newValue)
     {
     for (int i = oldValue; i <= newValue; i++)
     {
     servo.write(i);
     delay(10 * (5 - GLOBAL_SERVO_SPEED));
     }
     }
     else
     {
     for (int i = oldValue; i >= newValue; i--)
     {
     servo.write(i);
     delay(10 * (5 - GLOBAL_SERVO_SPEED));
     }
     }
     */
    /*
    if (commandList.GetElementCount() >= 4)
     Move_Servo(commandList);
     else
     PrintMessage("Error: not enough Arguments, Example MOVE;SERVONUMBER;SPEED;VALUE");
     */
  }
  // Set Speed
  else if (command == "SPEED")
  {
    int newSpeed = GetIntFromString(commandList.GetString(1));
    if (newSpeed >= 0 && newSpeed <= 5)
    {
      DebugPrint("GLOBAL_SERVO_SPEED  set to: " + String(newSpeed));
      GLOBAL_SERVO_SPEED = newSpeed;
      SaveSpeed(newSpeed);
    }
    PrintMessage("Speed set to: " + String(GLOBAL_SERVO_SPEED));
  }
  else if (command == "SPEED?")
  {
    PrintMessage(String(GLOBAL_SERVO_SPEED));
  }
  // Play LISTPOS #position
  else if (command == "LISTPOS")
  {
    int numberPositions = commandList.GetElementCount();
    
    for (int i = 1; i < numberPositions; i++)
    {
      int pos = GetIntFromString(commandList.GetString(i));
      DebugPrint("Try to get position " + String(pos) + " from List..." );
      DebugPrint("Number of Stored Commands is " + String(GetAnzahlBefehle()));
      if (pos > -1 && GetAnzahlBefehle() > pos)
      {
        String listCommand = GetCommandWithServoNumber(pos);
        StringArray tempArray = GetCommandList(listCommand);
        DebugPrint(tempArray.GetAsConcatedString());
        Move_Servo(tempArray);
      }
    }
  }
  // Opens the Gripper
  else if (command == "OPEN_GRIPPER")
  {
    Open_Gripper();
    PrintMessage(String("Gripper opened..."));
  }
  // Closes the Gripper
  else if (command == "CLOSE_GRIPPER")
  {
    Close_Gripper();
    PrintMessage(String("Gripper closed..."));
  }
  // Other Command
  else
  {
    DebugPrint("Unknown Command");
    for (int i = 0; i < commandList.GetElementCount(); i++)
    {
      PrintMessage(commandList.GetString(i));
      PrintMessage("|");
    }
  }
}
Exemplo n.º 5
0
int
DoPtsUserModify(struct cmd_syndesc *as, void *arock)
{
    enum { USER, GROUPQUOTA, LISTSTATUS, LISTGROUPSOWNED,
	LISTMEMBERSHIP
    };
    afs_status_t st = 0;
    const char *user = as->parms[USER].items->data;
    pts_UserUpdateEntry_t entry;
    int have_list_status_perm = 0;
    int have_list_groups_owned_perm = 0;
    int have_list_membership_perm = 0;

    entry.flag = 0;

    if (as->parms[GROUPQUOTA].items) {
	entry.groupCreationQuota =
	    GetIntFromString(as->parms[GROUPQUOTA].items->data, "bad quota");
	entry.flag = PTS_USER_UPDATE_GROUP_CREATE_QUOTA;
    }

    if (as->parms[LISTSTATUS].items) {
	entry.listStatus =
	    GetUserAccessFromString(as->parms[LISTSTATUS].items->data,
				    "invalid permission specifier");
	entry.flag |= PTS_USER_UPDATE_PERMISSIONS;
	have_list_status_perm = 1;
    }

    if (as->parms[LISTGROUPSOWNED].items) {
	entry.listGroupsOwned =
	    GetUserAccessFromString(as->parms[LISTGROUPSOWNED].items->data,
				    "invalid permission specifier");
	entry.flag |= PTS_USER_UPDATE_PERMISSIONS;
	have_list_groups_owned_perm = 1;
    }

    if (as->parms[LISTMEMBERSHIP].items) {
	entry.listMembership =
	    GetUserAccessFromString(as->parms[LISTMEMBERSHIP].items->data,
				    "invalid permission specifier");
	entry.flag |= PTS_USER_UPDATE_PERMISSIONS;
	have_list_membership_perm = 1;
    }

    if (entry.flag == 0) {
	ERR_EXT("you must specify either quota or permissions to modify");
    } else {
	if (entry.flag & PTS_USER_UPDATE_PERMISSIONS) {
	    if ((have_list_status_perm + have_list_groups_owned_perm +
		 have_list_membership_perm) != 3) {
		ERR_EXT("you must completely specify all permissions "
			"when modifying a user");
	    }
	}
    }

    if (!pts_UserModify(cellHandle, user, &entry, &st)) {
	ERR_ST_EXT("pts_UserModify", st);
    }

    return 0;
}