35 #include "MasterDevice.h" |
35 #include "MasterDevice.h" |
36 |
36 |
37 /*****************************************************************************/ |
37 /*****************************************************************************/ |
38 |
38 |
39 CommandSoeWrite::CommandSoeWrite(): |
39 CommandSoeWrite::CommandSoeWrite(): |
40 Command("soe_write", "Write an SoE IDN to a slave.") |
40 SoeCommand("soe_write", "Write an SoE IDN to a slave.") |
41 { |
41 { |
42 } |
42 } |
43 |
43 |
44 /*****************************************************************************/ |
44 /*****************************************************************************/ |
45 |
45 |
46 string CommandSoeWrite::helpString() const |
46 string CommandSoeWrite::helpString() const |
47 { |
47 { |
48 stringstream str; |
48 stringstream str; |
49 |
49 |
50 str << getName() << " [OPTIONS] <INDEX> <SUBINDEX> <VALUE>" << endl |
50 str << getName() << " [OPTIONS] <IDN> <VALUE>" << endl |
51 << endl |
51 << endl |
52 << getBriefDescription() << endl |
52 << getBriefDescription() << endl |
53 << endl |
53 << endl |
54 << "This command requires a single slave to be selected." << endl |
54 << "This command requires a single slave to be selected." << endl |
55 << endl |
55 << endl |
56 << "Arguments:" << endl |
56 << "Arguments:" << endl |
57 << " IDN is the IDN and must be an unsigned" << endl |
57 << " IDN is the IDN and must be either an unsigned" << endl |
58 << " 16 bit number." << endl |
58 << " 16 bit number acc. to IEC 61800-7-204:" << endl |
|
59 << " Bit 15: (0) Standard data, (1) Product data" << endl |
|
60 << " Bit 14 - 12: Parameter set (0 - 7)" << endl |
|
61 << " Bit 11 - 0: Data block number" << endl |
|
62 << " or a string like 'P-0-150'." << endl |
59 << " VALUE is the value to write and is interpreted" << endl |
63 << " VALUE is the value to write and is interpreted" << endl |
60 << " as the given datatype (see above)." << endl |
64 << " as the given datatype (see above)." << endl |
|
65 << endl |
|
66 << typeInfo() |
61 << endl |
67 << endl |
62 << "Command-specific options:" << endl |
68 << "Command-specific options:" << endl |
63 << " --alias -a <alias>" << endl |
69 << " --alias -a <alias>" << endl |
64 << " --position -p <pos> Slave selection. See the help of" << endl |
70 << " --position -p <pos> Slave selection. See the help of" << endl |
65 << " the 'slaves' command." << endl |
71 << " the 'slaves' command." << endl |
83 if (args.size() != 2) { |
89 if (args.size() != 2) { |
84 err << "'" << getName() << "' takes 2 arguments!"; |
90 err << "'" << getName() << "' takes 2 arguments!"; |
85 throwInvalidUsageException(err); |
91 throwInvalidUsageException(err); |
86 } |
92 } |
87 |
93 |
88 strIdn << args[0]; |
94 try { |
89 strIdn |
95 ioctl.idn = parseIdn(args[0]); |
90 >> resetiosflags(ios::basefield) // guess base from prefix |
96 } catch (runtime_error &e) { |
91 >> ioctl.idn; |
97 err << "Invalid IDN '" << args[0] << "': " << e.what(); |
92 if (strIdn.fail()) { |
|
93 err << "Invalid IDN '" << args[0] << "'!"; |
|
94 throwInvalidUsageException(err); |
98 throwInvalidUsageException(err); |
95 } |
99 } |
96 |
100 |
97 if (getMasterIndices().size() != 1) { |
101 if (getMasterIndices().size() != 1) { |
98 err << getName() << " requires to select a single master!"; |
102 err << getName() << " requires to select a single master!"; |