Skip to content
Snippets Groups Projects
Commit ca542003 authored by Florian Pose's avatar Florian Pose
Browse files

Moved slaveState() to Command::alStateString().

parent 46c4fa6c
No related branches found
No related tags found
No related merge requests found
...@@ -79,3 +79,16 @@ void Command::throwCommandException(const stringstream &s) ...@@ -79,3 +79,16 @@ void Command::throwCommandException(const stringstream &s)
} }
/****************************************************************************/ /****************************************************************************/
string Command::alStateString(uint8_t state)
{
switch (state) {
case 1: return "INIT";
case 2: return "PREOP";
case 4: return "SAFEOP";
case 8: return "OP";
default: return "???";
}
}
/****************************************************************************/
...@@ -83,6 +83,8 @@ class Command ...@@ -83,6 +83,8 @@ class Command
void throwCommandException(const stringstream &); void throwCommandException(const stringstream &);
enum {BreakAfterBytes = 16}; enum {BreakAfterBytes = 16};
static string alStateString(uint8_t);
private: private:
string name; string name;
......
...@@ -126,7 +126,7 @@ void CommandSlaves::listSlaves( ...@@ -126,7 +126,7 @@ void CommandSlaves::listSlaves(
info.relPos = str.str(); info.relPos = str.str();
str.str(""); str.str("");
info.state = slaveState(slave.state); info.state = alStateString(slave.state);
info.flag = (slave.error_flag ? 'E' : '+'); info.flag = (slave.error_flag ? 'E' : '+');
if (strlen(slave.name)) { if (strlen(slave.name)) {
...@@ -186,7 +186,7 @@ void CommandSlaves::showSlave( ...@@ -186,7 +186,7 @@ void CommandSlaves::showSlave(
cout << "Alias: " << slave.alias << endl; cout << "Alias: " << slave.alias << endl;
cout cout
<< "State: " << slaveState(slave.state) << endl << "State: " << alStateString(slave.state) << endl
<< "Flag: " << (slave.error_flag ? 'E' : '+') << endl << "Flag: " << (slave.error_flag ? 'E' : '+') << endl
<< "Identity:" << endl << "Identity:" << endl
<< " Vendor Id: 0x" << " Vendor Id: 0x"
...@@ -274,17 +274,4 @@ void CommandSlaves::showSlave( ...@@ -274,17 +274,4 @@ void CommandSlaves::showSlave(
} }
} }
/****************************************************************************/
string CommandSlaves::slaveState(uint8_t state)
{
switch (state) {
case 1: return "INIT";
case 2: return "PREOP";
case 4: return "SAFEOP";
case 8: return "OP";
default: return "???";
}
}
/*****************************************************************************/ /*****************************************************************************/
...@@ -32,8 +32,6 @@ class CommandSlaves: ...@@ -32,8 +32,6 @@ class CommandSlaves:
void listSlaves(MasterDevice &, int); void listSlaves(MasterDevice &, int);
void showSlave(MasterDevice &, uint16_t); void showSlave(MasterDevice &, uint16_t);
static string slaveState(uint8_t);
}; };
/****************************************************************************/ /****************************************************************************/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment