fp@1126: /***************************************************************************** fp@1126: * fp@1126: * $Id$ fp@1126: * fp@1126: ****************************************************************************/ fp@1126: fp@1126: #include fp@1126: using namespace std; fp@1126: fp@1126: #include "globals.h" fp@1126: fp@1126: /****************************************************************************/ fp@1126: fp@1130: // FIXME fp@1126: const char *help_states = fp@1126: "[OPTIONS]\n" fp@1126: "\n" fp@1126: "\n" fp@1126: "Command-specific options:\n"; fp@1126: fp@1126: /****************************************************************************/ fp@1126: fp@1126: void command_states(void) fp@1126: { fp@1126: string stateStr; fp@1126: uint8_t state; fp@1126: fp@1126: if (commandArgs.size() != 1) { fp@1126: stringstream err; fp@1126: err << "'state' takes exactly one argument!"; fp@1126: throw MasterDeviceException(err.str()); fp@1126: } fp@1126: fp@1126: stateStr = commandArgs[0]; fp@1126: transform(stateStr.begin(), stateStr.end(), fp@1126: stateStr.begin(), (int (*) (int)) std::toupper); fp@1126: fp@1126: if (stateStr == "INIT") { fp@1126: state = 0x01; fp@1126: } else if (stateStr == "PREOP") { fp@1126: state = 0x02; fp@1126: } else if (stateStr == "SAFEOP") { fp@1126: state = 0x04; fp@1126: } else if (stateStr == "OP") { fp@1126: state = 0x08; fp@1126: } else { fp@1126: stringstream err; fp@1126: err << "Invalid state '" << commandArgs[0] << "'!"; fp@1126: throw MasterDeviceException(err.str()); fp@1126: } fp@1126: fp@1126: masterDev.open(MasterDevice::ReadWrite); fp@1126: fp@1126: if (slavePosition == -1) { fp@1126: unsigned int i, numSlaves = masterDev.slaveCount(); fp@1126: for (i = 0; i < numSlaves; i++) fp@1126: masterDev.requestState(i, state); fp@1126: } else { fp@1126: masterDev.requestState(slavePosition, state); fp@1126: } fp@1126: } fp@1126: fp@1126: /*****************************************************************************/