author | Florian Pose <fp@igh-essen.com> |
Tue, 09 Mar 2010 14:40:25 +0100 | |
changeset 1865 | c6c8b457bb40 |
parent 1827 | 489be2180f71 |
child 1869 | 14f634f5b613 |
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 |
||
48 |
string CommandEoe::helpString() const |
|
49 |
{ |
|
50 |
stringstream str; |
|
51 |
||
52 |
str << getName() << endl |
|
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 |
{ |
66 |
ec_ioctl_master_t master; |
|
67 |
unsigned int i; |
|
68 |
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
|
69 |
bool doIndent; |
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1524
diff
changeset
|
70 |
string indent; |
1485 | 71 |
|
72 |
if (args.size()) { |
|
73 |
stringstream err; |
|
74 |
err << "'" << getName() << "' takes no arguments!"; |
|
75 |
throwInvalidUsageException(err); |
|
76 |
} |
|
77 |
||
1826
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1524
diff
changeset
|
78 |
doIndent = getMasterIndices().size(); |
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1524
diff
changeset
|
79 |
indent = doIndent ? " " : ""; |
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1524
diff
changeset
|
80 |
MasterIndexList::const_iterator mi; |
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1524
diff
changeset
|
81 |
for (mi = getMasterIndices().begin(); |
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1524
diff
changeset
|
82 |
mi != getMasterIndices().end(); mi++) { |
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1524
diff
changeset
|
83 |
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
|
84 |
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
|
85 |
m.getMaster(&master); |
1485 | 86 |
|
1827
489be2180f71
Improved multi-master capabilities of ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
87 |
if (master.eoe_handler_count) { |
489be2180f71
Improved multi-master capabilities of ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
88 |
if (doIndent) { |
489be2180f71
Improved multi-master capabilities of ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
89 |
cout << "Master" << dec << *mi << endl; |
489be2180f71
Improved multi-master capabilities of ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
90 |
} |
489be2180f71
Improved multi-master capabilities of ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
91 |
|
489be2180f71
Improved multi-master capabilities of ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
92 |
cout << indent << "Interface Slave State " |
489be2180f71
Improved multi-master capabilities of ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
93 |
<< "RxBytes RxRate " |
489be2180f71
Improved multi-master capabilities of ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
94 |
<< "TxBytes TxRate TxQueue" |
489be2180f71
Improved multi-master capabilities of ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
95 |
<< endl; |
1826
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1524
diff
changeset
|
96 |
} |
1485 | 97 |
|
1826
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1524
diff
changeset
|
98 |
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
|
99 |
stringstream queue; |
1485 | 100 |
|
1826
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1524
diff
changeset
|
101 |
m.getEoeHandler(&eoe, i); |
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 |
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
|
104 |
|
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1524
diff
changeset
|
105 |
cout << indent |
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1524
diff
changeset
|
106 |
<< 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
|
107 |
<< 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
|
108 |
<< 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
|
109 |
<< 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
|
110 |
<< 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
|
111 |
<< 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
|
112 |
<< 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
|
113 |
<< 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
|
114 |
<< endl; |
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1524
diff
changeset
|
115 |
} |
1485 | 116 |
} |
117 |
} |
|
118 |
||
119 |
/*****************************************************************************/ |