equal
deleted
inserted
replaced
30 #include <iostream> |
30 #include <iostream> |
31 #include <algorithm> |
31 #include <algorithm> |
32 using namespace std; |
32 using namespace std; |
33 |
33 |
34 #include "CommandStates.h" |
34 #include "CommandStates.h" |
|
35 #include "MasterDevice.h" |
35 |
36 |
36 /*****************************************************************************/ |
37 /*****************************************************************************/ |
37 |
38 |
38 CommandStates::CommandStates(): |
39 CommandStates::CommandStates(): |
39 Command("states", "Request application-layer states.") |
40 Command("states", "Request application-layer states.") |
63 return str.str(); |
64 return str.str(); |
64 } |
65 } |
65 |
66 |
66 /****************************************************************************/ |
67 /****************************************************************************/ |
67 |
68 |
68 void CommandStates::execute(MasterDevice &m, const StringVector &args) |
69 void CommandStates::execute(const StringVector &args) |
69 { |
70 { |
70 SlaveList slaves; |
71 SlaveList slaves; |
71 SlaveList::const_iterator si; |
72 SlaveList::const_iterator si; |
72 stringstream err; |
73 stringstream err; |
73 string stateStr; |
74 string stateStr; |
95 } else { |
96 } else { |
96 err << "Invalid state '" << args[0] << "'!"; |
97 err << "Invalid state '" << args[0] << "'!"; |
97 throwInvalidUsageException(err); |
98 throwInvalidUsageException(err); |
98 } |
99 } |
99 |
100 |
100 m.open(MasterDevice::ReadWrite); |
101 MasterIndexList::const_iterator mi; |
101 slaves = selectedSlaves(m); |
102 for (mi = getMasterIndices().begin(); |
|
103 mi != getMasterIndices().end(); mi++) { |
|
104 MasterDevice m(*mi); |
|
105 m.open(MasterDevice::ReadWrite); |
|
106 slaves = selectedSlaves(m); |
102 |
107 |
103 if (!slaves.size() && getVerbosity() != Quiet) { |
108 for (si = slaves.begin(); si != slaves.end(); si++) { |
104 cerr << "Warning: Selection matches no slaves!" << endl; |
109 m.requestState(si->position, state); |
105 } |
110 } |
106 |
|
107 for (si = slaves.begin(); si != slaves.end(); si++) { |
|
108 m.requestState(si->position, state); |
|
109 } |
111 } |
110 } |
112 } |
111 |
113 |
112 /*****************************************************************************/ |
114 /*****************************************************************************/ |