author | Florian Pose <fp@igh-essen.com> |
Thu, 15 Dec 2011 14:05:44 +0100 | |
branch | stable-1.5 |
changeset 2202 | 14728d0c4a66 |
parent 1968 | 4f682084c643 |
child 2421 | bc2d4bf9cbe5 |
permissions | -rw-r--r-- |
1485 | 1 |
/***************************************************************************** |
2 |
* |
|
1524
e7bdab4d6189
Committed misteriously modified files...
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
3 |
* $Id$ |
1485 | 4 |
* |
5 |
* Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH |
|
6 |
* |
|
7 |
* This file is part of the IgH EtherCAT Master. |
|
8 |
* |
|
9 |
* The IgH EtherCAT Master is free software; you can redistribute it and/or |
|
10 |
* modify it under the terms of the GNU General Public License version 2, as |
|
11 |
* published by the Free Software Foundation. |
|
12 |
* |
|
13 |
* The IgH EtherCAT Master is distributed in the hope that it will be useful, |
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
|
16 |
* Public License for more details. |
|
17 |
* |
|
18 |
* You should have received a copy of the GNU General Public License along |
|
19 |
* with the IgH EtherCAT Master; if not, write to the Free Software |
|
20 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
|
21 |
* |
|
22 |
* --- |
|
23 |
* |
|
24 |
* The license mentioned above concerns the source code only. Using the |
|
25 |
* EtherCAT technology and brand is only permitted in compliance with the |
|
26 |
* industrial property and similar rights of Beckhoff Automation GmbH. |
|
27 |
* |
|
28 |
****************************************************************************/ |
|
29 |
||
30 |
#include <iostream> |
|
31 |
#include <iomanip> |
|
32 |
#include <list> |
|
33 |
#include <string.h> |
|
34 |
using namespace std; |
|
35 |
||
36 |
#include "CommandEoe.h" |
|
1826
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1524
diff
changeset
|
37 |
#include "MasterDevice.h" |
1485 | 38 |
|
39 |
/*****************************************************************************/ |
|
40 |
||
41 |
CommandEoe::CommandEoe(): |
|
42 |
Command("eoe", "Display Ethernet over EtherCAT statictics.") |
|
43 |
{ |
|
44 |
} |
|
45 |
||
46 |
/*****************************************************************************/ |
|
47 |
||
1968
4f682084c643
Implemented drive_no for command-line tool; binary base name is now a
Florian Pose <fp@igh-essen.com>
parents:
1869
diff
changeset
|
48 |
string CommandEoe::helpString(const string &binaryBaseName) const |
1485 | 49 |
{ |
50 |
stringstream str; |
|
51 |
||
1968
4f682084c643
Implemented drive_no for command-line tool; binary base name is now a
Florian Pose <fp@igh-essen.com>
parents:
1869
diff
changeset
|
52 |
str << binaryBaseName << " " << getName() << endl |
1485 | 53 |
<< endl |
54 |
<< getBriefDescription() << endl |
|
55 |
<< endl |
|
56 |
<< "The TxRate and RxRate are displayed in Byte/s." << endl |
|
57 |
<< endl; |
|
58 |
||
59 |
return str.str(); |
|
60 |
} |
|
61 |
||
62 |
/****************************************************************************/ |
|
63 |
||
1826
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1524
diff
changeset
|
64 |
void CommandEoe::execute(const StringVector &args) |
1485 | 65 |
{ |
1869
14f634f5b613
Open master device as late as possible.
Florian Pose <fp@igh-essen.com>
parents:
1827
diff
changeset
|
66 |
MasterIndexList masterIndices; |
1485 | 67 |
ec_ioctl_master_t master; |
68 |
unsigned int i; |
|
69 |
ec_ioctl_eoe_handler_t eoe; |
|
1826
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1524
diff
changeset
|
70 |
bool doIndent; |
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1524
diff
changeset
|
71 |
string indent; |
1485 | 72 |
|
73 |
if (args.size()) { |
|
74 |
stringstream err; |
|
75 |
err << "'" << getName() << "' takes no arguments!"; |
|
76 |
throwInvalidUsageException(err); |
|
77 |
} |
|
78 |
||
1869
14f634f5b613
Open master device as late as possible.
Florian Pose <fp@igh-essen.com>
parents:
1827
diff
changeset
|
79 |
masterIndices = getMasterIndices(); |
14f634f5b613
Open master device as late as possible.
Florian Pose <fp@igh-essen.com>
parents:
1827
diff
changeset
|
80 |
doIndent = masterIndices.size(); |
1826
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1524
diff
changeset
|
81 |
indent = doIndent ? " " : ""; |
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1524
diff
changeset
|
82 |
MasterIndexList::const_iterator mi; |
1869
14f634f5b613
Open master device as late as possible.
Florian Pose <fp@igh-essen.com>
parents:
1827
diff
changeset
|
83 |
for (mi = masterIndices.begin(); |
14f634f5b613
Open master device as late as possible.
Florian Pose <fp@igh-essen.com>
parents:
1827
diff
changeset
|
84 |
mi != masterIndices.end(); mi++) { |
1826
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1524
diff
changeset
|
85 |
MasterDevice m(*mi); |
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1524
diff
changeset
|
86 |
m.open(MasterDevice::Read); |
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1524
diff
changeset
|
87 |
m.getMaster(&master); |
1485 | 88 |
|
1827
489be2180f71
Improved multi-master capabilities of ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
89 |
if (master.eoe_handler_count) { |
489be2180f71
Improved multi-master capabilities of ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
90 |
if (doIndent) { |
489be2180f71
Improved multi-master capabilities of ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
91 |
cout << "Master" << dec << *mi << endl; |
489be2180f71
Improved multi-master capabilities of ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
92 |
} |
489be2180f71
Improved multi-master capabilities of ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
93 |
|
489be2180f71
Improved multi-master capabilities of ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
94 |
cout << indent << "Interface Slave State " |
489be2180f71
Improved multi-master capabilities of ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
95 |
<< "RxBytes RxRate " |
489be2180f71
Improved multi-master capabilities of ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
96 |
<< "TxBytes TxRate TxQueue" |
489be2180f71
Improved multi-master capabilities of ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
97 |
<< endl; |
1826
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1524
diff
changeset
|
98 |
} |
1485 | 99 |
|
1826
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1524
diff
changeset
|
100 |
for (i = 0; i < master.eoe_handler_count; i++) { |
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1524
diff
changeset
|
101 |
stringstream queue; |
1485 | 102 |
|
1826
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1524
diff
changeset
|
103 |
m.getEoeHandler(&eoe, i); |
1485 | 104 |
|
1826
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1524
diff
changeset
|
105 |
queue << eoe.tx_queued_frames << "/" << eoe.tx_queue_size; |
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1524
diff
changeset
|
106 |
|
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1524
diff
changeset
|
107 |
cout << indent |
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1524
diff
changeset
|
108 |
<< setw(9) << eoe.name << " " |
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1524
diff
changeset
|
109 |
<< setw(5) << dec << eoe.slave_position << " " |
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1524
diff
changeset
|
110 |
<< setw(5) << (eoe.open ? "up" : "down") << " " |
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1524
diff
changeset
|
111 |
<< setw(7) << eoe.rx_bytes << " " |
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1524
diff
changeset
|
112 |
<< setw(6) << eoe.rx_rate << " " |
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1524
diff
changeset
|
113 |
<< setw(7) << eoe.tx_bytes << " " |
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1524
diff
changeset
|
114 |
<< setw(6) << eoe.tx_rate << " " |
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1524
diff
changeset
|
115 |
<< setw(7) << queue.str() |
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1524
diff
changeset
|
116 |
<< endl; |
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1524
diff
changeset
|
117 |
} |
1485 | 118 |
} |
119 |
} |
|
120 |
||
121 |
/*****************************************************************************/ |