author | Florian Pose <fp@igh-essen.com> |
Fri, 30 Jan 2009 10:50:21 +0000 | |
changeset 1348 | 8db0f72ace11 |
parent 1337 | 0253c74d0940 |
child 1363 | 11c0b2caa253 |
permissions | -rw-r--r-- |
1142 | 1 |
/***************************************************************************** |
2 |
* |
|
3 |
* $Id$ |
|
4 |
* |
|
5 |
****************************************************************************/ |
|
6 |
||
7 |
#include "Command.h" |
|
8 |
||
9 |
/*****************************************************************************/ |
|
10 |
||
11 |
Command::Command(const string &name, const string &briefDesc): |
|
12 |
name(name), |
|
13 |
briefDesc(briefDesc), |
|
14 |
verbosity(Normal) |
|
15 |
{ |
|
16 |
} |
|
17 |
||
18 |
/*****************************************************************************/ |
|
19 |
||
20 |
Command::~Command() |
|
21 |
{ |
|
22 |
} |
|
23 |
||
24 |
/*****************************************************************************/ |
|
25 |
||
26 |
void Command::setVerbosity(Verbosity v) |
|
27 |
{ |
|
28 |
verbosity = v; |
|
29 |
}; |
|
30 |
||
1151 | 31 |
/*****************************************************************************/ |
32 |
||
33 |
void Command::setAlias(int a) |
|
34 |
{ |
|
35 |
alias = a; |
|
36 |
}; |
|
37 |
||
38 |
/*****************************************************************************/ |
|
39 |
||
40 |
void Command::setPosition(int p) |
|
41 |
{ |
|
42 |
position = p; |
|
43 |
}; |
|
44 |
||
1166 | 45 |
/*****************************************************************************/ |
46 |
||
47 |
void Command::setDomain(int d) |
|
48 |
{ |
|
49 |
domain = d; |
|
50 |
}; |
|
51 |
||
52 |
/*****************************************************************************/ |
|
53 |
||
54 |
void Command::setDataType(const string &t) |
|
55 |
{ |
|
56 |
dataType = t; |
|
57 |
}; |
|
58 |
||
59 |
/*****************************************************************************/ |
|
60 |
||
61 |
void Command::setForce(bool f) |
|
62 |
{ |
|
63 |
force = f; |
|
64 |
}; |
|
65 |
||
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1199
diff
changeset
|
66 |
/*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1199
diff
changeset
|
67 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1199
diff
changeset
|
68 |
void Command::setOutputFile(const string &f) |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1199
diff
changeset
|
69 |
{ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1199
diff
changeset
|
70 |
outputFile = f; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1199
diff
changeset
|
71 |
}; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1199
diff
changeset
|
72 |
|
1142 | 73 |
/****************************************************************************/ |
74 |
||
75 |
bool Command::matchesSubstr(const string &cmd) const |
|
76 |
{ |
|
77 |
return name.substr(0, cmd.length()) == cmd; |
|
78 |
} |
|
79 |
||
80 |
/****************************************************************************/ |
|
81 |
||
82 |
bool Command::matchesAbbrev(const string &abb) const |
|
83 |
{ |
|
84 |
unsigned int i; |
|
85 |
size_t pos = 0; |
|
86 |
||
87 |
for (i = 0; i < abb.length(); i++) { |
|
88 |
pos = name.find(abb[i], pos); |
|
89 |
if (pos == string::npos) |
|
90 |
return false; |
|
91 |
} |
|
92 |
||
93 |
return true; |
|
94 |
} |
|
95 |
||
96 |
/*****************************************************************************/ |
|
97 |
||
1144
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
98 |
string Command::numericInfo() |
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
99 |
{ |
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
100 |
stringstream str; |
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
101 |
|
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
102 |
str << "Numerical values can be specified either with decimal (no" << endl |
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
103 |
<< "prefix), octal (prefix '0') or hexadecimal (prefix '0x') base." |
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
104 |
<< endl; |
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
105 |
|
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
106 |
return str.str(); |
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
107 |
} |
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
108 |
|
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
109 |
/*****************************************************************************/ |
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
110 |
|
1155
bd4e5b544473
Common message for single slave selections.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
111 |
void Command::throwInvalidUsageException(const stringstream &s) const |
1142 | 112 |
{ |
113 |
throw InvalidUsageException(s); |
|
114 |
} |
|
115 |
||
116 |
/*****************************************************************************/ |
|
117 |
||
1155
bd4e5b544473
Common message for single slave selections.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
118 |
void Command::throwCommandException(const stringstream &s) const |
1142 | 119 |
{ |
120 |
throw CommandException(s); |
|
121 |
} |
|
122 |
||
1151 | 123 |
/*****************************************************************************/ |
124 |
||
1155
bd4e5b544473
Common message for single slave selections.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
125 |
void Command::throwSingleSlaveRequired(unsigned int size) const |
bd4e5b544473
Common message for single slave selections.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
126 |
{ |
bd4e5b544473
Common message for single slave selections.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
127 |
stringstream err; |
bd4e5b544473
Common message for single slave selections.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
128 |
|
1199 | 129 |
err << "The slave selection matches " << size << " slaves. '" |
1155
bd4e5b544473
Common message for single slave selections.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
130 |
<< name << "' requires a single slave."; |
bd4e5b544473
Common message for single slave selections.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
131 |
|
bd4e5b544473
Common message for single slave selections.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
132 |
throwInvalidUsageException(err); |
bd4e5b544473
Common message for single slave selections.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
133 |
} |
bd4e5b544473
Common message for single slave selections.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
134 |
|
bd4e5b544473
Common message for single slave selections.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
135 |
/*****************************************************************************/ |
bd4e5b544473
Common message for single slave selections.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
136 |
|
1151 | 137 |
Command::SlaveList Command::selectedSlaves(MasterDevice &m) |
138 |
{ |
|
1160
f02ff486b313
Removed MasterDevice::slaveCount().
Florian Pose <fp@igh-essen.com>
parents:
1159
diff
changeset
|
139 |
ec_ioctl_master_t master; |
f02ff486b313
Removed MasterDevice::slaveCount().
Florian Pose <fp@igh-essen.com>
parents:
1159
diff
changeset
|
140 |
unsigned int i, aliasIndex; |
1151 | 141 |
uint16_t lastAlias; |
142 |
ec_ioctl_slave_t slave; |
|
143 |
SlaveList list; |
|
144 |
||
1160
f02ff486b313
Removed MasterDevice::slaveCount().
Florian Pose <fp@igh-essen.com>
parents:
1159
diff
changeset
|
145 |
m.getMaster(&master); |
f02ff486b313
Removed MasterDevice::slaveCount().
Florian Pose <fp@igh-essen.com>
parents:
1159
diff
changeset
|
146 |
|
1151 | 147 |
if (alias == -1) { // no alias given |
148 |
if (position == -1) { // no alias and position given |
|
149 |
// all items |
|
1160
f02ff486b313
Removed MasterDevice::slaveCount().
Florian Pose <fp@igh-essen.com>
parents:
1159
diff
changeset
|
150 |
for (i = 0; i < master.slave_count; i++) { |
1151 | 151 |
m.getSlave(&slave, i); |
152 |
list.push_back(slave); |
|
153 |
} |
|
154 |
} else { // no alias, but position given |
|
155 |
// one item by position |
|
156 |
m.getSlave(&slave, position); |
|
157 |
list.push_back(slave); |
|
158 |
} |
|
159 |
} else { // alias given |
|
160 |
if (position == -1) { // alias, but no position given |
|
161 |
// take all items with a given alias |
|
162 |
lastAlias = 0; |
|
1160
f02ff486b313
Removed MasterDevice::slaveCount().
Florian Pose <fp@igh-essen.com>
parents:
1159
diff
changeset
|
163 |
for (i = 0; i < master.slave_count; i++) { |
1151 | 164 |
m.getSlave(&slave, i); |
165 |
if (slave.alias) { |
|
166 |
lastAlias = slave.alias; |
|
167 |
} |
|
168 |
if (lastAlias == (uint16_t) alias) { |
|
169 |
list.push_back(slave); |
|
170 |
} |
|
171 |
} |
|
172 |
} else { // alias and position given |
|
173 |
lastAlias = 0; |
|
174 |
aliasIndex = 0; |
|
1160
f02ff486b313
Removed MasterDevice::slaveCount().
Florian Pose <fp@igh-essen.com>
parents:
1159
diff
changeset
|
175 |
for (i = 0; i < master.slave_count; i++) { |
1151 | 176 |
m.getSlave(&slave, i); |
1159
25cc77cf3993
Improved alias/position addressing in case od duplicated aliases.
Florian Pose <fp@igh-essen.com>
parents:
1157
diff
changeset
|
177 |
if (slave.alias && slave.alias == (uint16_t) alias) { |
1151 | 178 |
lastAlias = slave.alias; |
179 |
aliasIndex = 0; |
|
180 |
} |
|
1159
25cc77cf3993
Improved alias/position addressing in case od duplicated aliases.
Florian Pose <fp@igh-essen.com>
parents:
1157
diff
changeset
|
181 |
if (lastAlias && aliasIndex == (unsigned int) position) { |
1151 | 182 |
list.push_back(slave); |
183 |
} |
|
184 |
aliasIndex++; |
|
185 |
} |
|
186 |
} |
|
187 |
} |
|
188 |
||
189 |
return list; |
|
190 |
} |
|
191 |
||
1156
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
192 |
/*****************************************************************************/ |
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
193 |
|
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
194 |
bool operator<( |
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
195 |
const ec_ioctl_config_t &a, |
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
196 |
const ec_ioctl_config_t &b |
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
197 |
) |
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
198 |
{ |
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
199 |
return a.alias < b.alias |
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
200 |
|| (a.alias == b.alias && a.position < b.position); |
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
201 |
} |
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
202 |
|
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
203 |
/*****************************************************************************/ |
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
204 |
|
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
205 |
Command::ConfigList Command::selectedConfigs(MasterDevice &m) |
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
206 |
{ |
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
207 |
unsigned int i; |
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
208 |
ec_ioctl_master_t master; |
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
209 |
ec_ioctl_config_t config; |
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
210 |
ConfigList list; |
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
211 |
stringstream err; |
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
212 |
|
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
213 |
m.getMaster(&master); |
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
214 |
|
1157
04d1c950cf9d
Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents:
1156
diff
changeset
|
215 |
if (alias == -1) { // no alias given |
1156
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
216 |
if (position == -1) { // no alias and position given |
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
217 |
// all items |
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
218 |
for (i = 0; i < master.config_count; i++) { |
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
219 |
m.getConfig(&config, i); |
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
220 |
list.push_back(config); |
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
221 |
} |
1157
04d1c950cf9d
Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents:
1156
diff
changeset
|
222 |
} else { // no alias, but position given |
04d1c950cf9d
Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents:
1156
diff
changeset
|
223 |
for (i = 0; i < master.config_count; i++) { |
04d1c950cf9d
Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents:
1156
diff
changeset
|
224 |
m.getConfig(&config, i); |
04d1c950cf9d
Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents:
1156
diff
changeset
|
225 |
if (!config.alias && config.position == position) { |
04d1c950cf9d
Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents:
1156
diff
changeset
|
226 |
list.push_back(config); |
04d1c950cf9d
Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents:
1156
diff
changeset
|
227 |
break; // there can be at most one matching |
04d1c950cf9d
Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents:
1156
diff
changeset
|
228 |
} |
04d1c950cf9d
Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents:
1156
diff
changeset
|
229 |
} |
1156
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
230 |
} |
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
231 |
} else { // alias given |
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
232 |
if (position == -1) { // alias, but no position given |
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
233 |
// take all items with a given alias |
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
234 |
for (i = 0; i < master.config_count; i++) { |
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
235 |
m.getConfig(&config, i); |
1157
04d1c950cf9d
Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents:
1156
diff
changeset
|
236 |
if (config.alias == alias) { |
1156
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
237 |
list.push_back(config); |
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
238 |
} |
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
239 |
} |
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
240 |
} else { // alias and position given |
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
241 |
for (i = 0; i < master.config_count; i++) { |
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
242 |
m.getConfig(&config, i); |
1157
04d1c950cf9d
Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents:
1156
diff
changeset
|
243 |
if (config.alias == alias && config.position == position) { |
1156
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
244 |
list.push_back(config); |
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
245 |
break; // there can be at most one matching |
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
246 |
} |
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
247 |
} |
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
248 |
} |
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
249 |
} |
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
250 |
|
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
251 |
list.sort(); |
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
252 |
return list; |
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
253 |
} |
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
254 |
|
1142 | 255 |
/****************************************************************************/ |
1146
f18d124d7fbc
Moved slaveState() to Command::alStateString().
Florian Pose <fp@igh-essen.com>
parents:
1144
diff
changeset
|
256 |
|
1166 | 257 |
Command::DomainList Command::selectedDomains(MasterDevice &m) |
258 |
{ |
|
259 |
ec_ioctl_domain_t d; |
|
260 |
DomainList list; |
|
261 |
||
262 |
if (domain == -1) { |
|
263 |
ec_ioctl_master_t master; |
|
264 |
unsigned int i; |
|
265 |
||
266 |
m.getMaster(&master); |
|
267 |
||
268 |
for (i = 0; i < master.domain_count; i++) { |
|
269 |
m.getDomain(&d, i); |
|
270 |
list.push_back(d); |
|
271 |
} |
|
272 |
} else { |
|
273 |
m.getDomain(&d, domain); |
|
274 |
list.push_back(d); |
|
275 |
} |
|
276 |
||
277 |
return list; |
|
278 |
} |
|
279 |
||
280 |
/****************************************************************************/ |
|
281 |
||
1146
f18d124d7fbc
Moved slaveState() to Command::alStateString().
Florian Pose <fp@igh-essen.com>
parents:
1144
diff
changeset
|
282 |
string Command::alStateString(uint8_t state) |
f18d124d7fbc
Moved slaveState() to Command::alStateString().
Florian Pose <fp@igh-essen.com>
parents:
1144
diff
changeset
|
283 |
{ |
f18d124d7fbc
Moved slaveState() to Command::alStateString().
Florian Pose <fp@igh-essen.com>
parents:
1144
diff
changeset
|
284 |
switch (state) { |
f18d124d7fbc
Moved slaveState() to Command::alStateString().
Florian Pose <fp@igh-essen.com>
parents:
1144
diff
changeset
|
285 |
case 1: return "INIT"; |
f18d124d7fbc
Moved slaveState() to Command::alStateString().
Florian Pose <fp@igh-essen.com>
parents:
1144
diff
changeset
|
286 |
case 2: return "PREOP"; |
1337
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
287 |
case 3: return "BOOT"; |
1146
f18d124d7fbc
Moved slaveState() to Command::alStateString().
Florian Pose <fp@igh-essen.com>
parents:
1144
diff
changeset
|
288 |
case 4: return "SAFEOP"; |
f18d124d7fbc
Moved slaveState() to Command::alStateString().
Florian Pose <fp@igh-essen.com>
parents:
1144
diff
changeset
|
289 |
case 8: return "OP"; |
f18d124d7fbc
Moved slaveState() to Command::alStateString().
Florian Pose <fp@igh-essen.com>
parents:
1144
diff
changeset
|
290 |
default: return "???"; |
f18d124d7fbc
Moved slaveState() to Command::alStateString().
Florian Pose <fp@igh-essen.com>
parents:
1144
diff
changeset
|
291 |
} |
f18d124d7fbc
Moved slaveState() to Command::alStateString().
Florian Pose <fp@igh-essen.com>
parents:
1144
diff
changeset
|
292 |
} |
f18d124d7fbc
Moved slaveState() to Command::alStateString().
Florian Pose <fp@igh-essen.com>
parents:
1144
diff
changeset
|
293 |
|
f18d124d7fbc
Moved slaveState() to Command::alStateString().
Florian Pose <fp@igh-essen.com>
parents:
1144
diff
changeset
|
294 |
/****************************************************************************/ |