148 /*****************************************************************************/ |
148 /*****************************************************************************/ |
149 |
149 |
150 Command::Command(const string &name, const string &briefDesc): |
150 Command::Command(const string &name, const string &briefDesc): |
151 name(name), |
151 name(name), |
152 briefDesc(briefDesc), |
152 briefDesc(briefDesc), |
153 verbosity(Normal) |
153 verbosity(Normal), |
|
154 emergency(false), |
|
155 force(false) |
154 { |
156 { |
155 } |
157 } |
156 |
158 |
157 /*****************************************************************************/ |
159 /*****************************************************************************/ |
158 |
160 |
214 void Command::setOutputFile(const string &f) |
223 void Command::setOutputFile(const string &f) |
215 { |
224 { |
216 outputFile = f; |
225 outputFile = f; |
217 }; |
226 }; |
218 |
227 |
|
228 /*****************************************************************************/ |
|
229 |
|
230 void Command::setSkin(const string &s) |
|
231 { |
|
232 skin = s; |
|
233 }; |
|
234 |
219 /****************************************************************************/ |
235 /****************************************************************************/ |
220 |
236 |
221 bool Command::matchesSubstr(const string &cmd) const |
237 bool Command::matchesSubstr(const string &cmd) const |
222 { |
238 { |
223 return name.substr(0, cmd.length()) == cmd; |
239 return name.substr(0, cmd.length()) == cmd; |
224 } |
240 } |
225 |
241 |
226 /****************************************************************************/ |
242 /****************************************************************************/ |
227 |
243 |
228 bool Command::matchesAbbrev(const string &abb) const |
244 bool Command::matchesAbbrev(const string &abb) const |
229 { |
245 { |
230 unsigned int i; |
246 unsigned int i; |
458 return list; |
474 return list; |
459 } |
475 } |
460 |
476 |
461 /****************************************************************************/ |
477 /****************************************************************************/ |
462 |
478 |
463 Command::DomainList Command::selectedDomains(MasterDevice &m) |
479 Command::DomainList Command::selectedDomains(MasterDevice &m, |
464 { |
480 const ec_ioctl_master_t &io) |
465 ec_ioctl_master_t master; |
481 { |
466 DomainList list; |
482 DomainList list; |
467 |
483 |
468 m.getMaster(&master); |
484 PositionParser pp(io.domain_count); |
469 |
|
470 PositionParser pp(master.domain_count); |
|
471 NumberListParser::List domList = pp.parse(domains.c_str()); |
485 NumberListParser::List domList = pp.parse(domains.c_str()); |
472 NumberListParser::List::const_iterator di; |
486 NumberListParser::List::const_iterator di; |
473 |
487 |
474 for (di = domList.begin(); di != domList.end(); di++) { |
488 for (di = domList.begin(); di != domList.end(); di++) { |
475 if (*di < master.domain_count) { |
489 if (*di < io.domain_count) { |
476 ec_ioctl_domain_t d; |
490 ec_ioctl_domain_t d; |
477 m.getDomain(&d, *di); |
491 m.getDomain(&d, *di); |
478 list.push_back(d); |
492 list.push_back(d); |
479 } |
493 } |
480 } |
494 } |
481 |
495 |
482 return list; |
496 return list; |
|
497 } |
|
498 |
|
499 /****************************************************************************/ |
|
500 |
|
501 int Command::emergencySlave() const |
|
502 { |
|
503 unsigned int ret; |
|
504 |
|
505 stringstream str; |
|
506 str << positions; |
|
507 str >> ret; |
|
508 |
|
509 return ret; |
483 } |
510 } |
484 |
511 |
485 /****************************************************************************/ |
512 /****************************************************************************/ |
486 |
513 |
487 string Command::alStateString(uint8_t state) |
514 string Command::alStateString(uint8_t state) |