author | Martin Troxler <martin.troxler@komaxgroup.com> |
Wed, 12 May 2010 15:07:13 +0200 | |
changeset 1990 | b0dcdfbd4238 |
parent 1870 | 0cee1fb7f0fd |
child 1968 | 4f682084c643 |
permissions | -rw-r--r-- |
1422
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1 |
/***************************************************************************** |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
2 |
* |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
3 |
* $Id$ |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
4 |
* |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
5 |
* Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
6 |
* |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
7 |
* This file is part of the IgH EtherCAT Master. |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
8 |
* |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
9 |
* The IgH EtherCAT Master is free software; you can redistribute it and/or |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
10 |
* modify it under the terms of the GNU General Public License version 2, as |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
11 |
* published by the Free Software Foundation. |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
12 |
* |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
13 |
* The IgH EtherCAT Master is distributed in the hope that it will be useful, |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
16 |
* Public License for more details. |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
17 |
* |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
18 |
* You should have received a copy of the GNU General Public License along |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
19 |
* with the IgH EtherCAT Master; if not, write to the Free Software |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
20 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
21 |
* |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
22 |
* --- |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
23 |
* |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
24 |
* The license mentioned above concerns the source code only. Using the |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
25 |
* EtherCAT technology and brand is only permitted in compliance with the |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
26 |
* industrial property and similar rights of Beckhoff Automation GmbH. |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
27 |
* |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
28 |
****************************************************************************/ |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
29 |
|
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
30 |
#include <iostream> |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
31 |
#include <map> |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
32 |
using namespace std; |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
33 |
|
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
34 |
#include "CommandGraph.h" |
1826
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
35 |
#include "MasterDevice.h" |
1422
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
36 |
|
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
37 |
/*****************************************************************************/ |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
38 |
|
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
39 |
CommandGraph::CommandGraph(): |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
40 |
Command("graph", "Output the bus topology as a graph.") |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
41 |
{ |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
42 |
} |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
43 |
|
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
44 |
/*****************************************************************************/ |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
45 |
|
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
46 |
string CommandGraph::helpString() const |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
47 |
{ |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
48 |
stringstream str; |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
49 |
|
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
50 |
str << getName() << " [OPTIONS]" << endl |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
51 |
<< endl |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
52 |
<< getBriefDescription() << endl |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
53 |
<< endl |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
54 |
<< "The bus is output in DOT language (see" << endl |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
55 |
<< "http://www.graphviz.org/doc/info/lang.html), which can" << endl |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
56 |
<< "be processed with the tools from the Graphviz" << endl |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
57 |
<< "package. Example:" << endl |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
58 |
<< endl |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
59 |
<< " ethercat graph | dot -Tsvg > bus.svg" << endl |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
60 |
<< endl |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
61 |
<< "See 'man dot' for more information." << endl; |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
62 |
|
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
63 |
return str.str(); |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
64 |
} |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
65 |
|
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
66 |
/****************************************************************************/ |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
67 |
|
1826
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
68 |
void CommandGraph::execute(const StringVector &args) |
1422
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
69 |
{ |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
70 |
ec_ioctl_master_t master; |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
71 |
unsigned int i; |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
72 |
typedef vector<ec_ioctl_slave_t> SlaveVector; |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
73 |
SlaveVector slaves; |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
74 |
ec_ioctl_slave_t slave; |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
75 |
SlaveVector::const_iterator si; |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
76 |
map<int, string> portMedia; |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
77 |
map<int, string>::const_iterator mi; |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
78 |
map<int, int> mediaWeights; |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
79 |
map<int, int>::const_iterator wi; |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
80 |
|
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
81 |
portMedia[EC_PORT_MII] = "MII"; |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
82 |
mediaWeights[EC_PORT_MII] = 1; |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
83 |
|
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
84 |
portMedia[EC_PORT_EBUS] = "EBUS"; |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
85 |
mediaWeights[EC_PORT_EBUS] = 5; |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
86 |
|
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
87 |
if (args.size()) { |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
88 |
stringstream err; |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
89 |
err << "'" << getName() << "' takes no arguments!"; |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
90 |
throwInvalidUsageException(err); |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
91 |
} |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
92 |
|
1870
0cee1fb7f0fd
Added getSingleMasterIndex() for command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1869
diff
changeset
|
93 |
MasterDevice m(getSingleMasterIndex()); |
1422
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
94 |
m.open(MasterDevice::Read); |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
95 |
m.getMaster(&master); |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
96 |
|
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
97 |
for (i = 0; i < master.slave_count; i++) { |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
98 |
m.getSlave(&slave, i); |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
99 |
slaves.push_back(slave); |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
100 |
} |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
101 |
|
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
102 |
cout << "/* EtherCAT bus graph. Generated by 'ethercat graph'. */" << endl |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
103 |
<< endl |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
104 |
<< "strict graph bus {" << endl |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
105 |
<< " rankdir=\"LR\"" << endl |
1425
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1422
diff
changeset
|
106 |
<< " ranksep=0.8" << endl |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1422
diff
changeset
|
107 |
<< " nodesep=0.8" << endl |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1422
diff
changeset
|
108 |
<< " node [fontname=\"Helvetica\"]" << endl |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1422
diff
changeset
|
109 |
<< " edge [fontname=\"Helvetica\",fontsize=\"10\"]" << endl |
1422
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
110 |
<< endl |
1425
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1422
diff
changeset
|
111 |
<< " master [label=\"EtherCAT\\nMaster\"]" << endl; |
1422
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
112 |
|
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
113 |
if (slaves.size()) { |
1425
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1422
diff
changeset
|
114 |
cout << " master -- slave0"; |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1422
diff
changeset
|
115 |
mi = portMedia.find(slaves.front().ports[0].desc); |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1422
diff
changeset
|
116 |
if (mi != portMedia.end()) |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1422
diff
changeset
|
117 |
cout << "[label=\"" << mi->second << "\"]"; |
1422
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
118 |
|
1425
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1422
diff
changeset
|
119 |
cout << endl; |
1422
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
120 |
} |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
121 |
cout << endl; |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
122 |
|
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
123 |
for (si = slaves.begin(); si != slaves.end(); si++) { |
1804 | 124 |
cout << " slave" << si->position << " [shape=\"box\"" |
1425
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1422
diff
changeset
|
125 |
<< ",label=\"" << si->position; |
1422
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
126 |
if (string(si->order).size()) |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
127 |
cout << "\\n" << si->order; |
1425
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1422
diff
changeset
|
128 |
if (si->dc_supported) { |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1422
diff
changeset
|
129 |
cout << "\\nDC: "; |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1422
diff
changeset
|
130 |
if (si->has_dc_system_time) { |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1422
diff
changeset
|
131 |
switch (si->dc_range) { |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1422
diff
changeset
|
132 |
case EC_DC_32: |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1422
diff
changeset
|
133 |
cout << "32 bit"; |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1422
diff
changeset
|
134 |
break; |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1422
diff
changeset
|
135 |
case EC_DC_64: |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1422
diff
changeset
|
136 |
cout << "64 bit"; |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1422
diff
changeset
|
137 |
break; |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1422
diff
changeset
|
138 |
default: |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1422
diff
changeset
|
139 |
break; |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1422
diff
changeset
|
140 |
} |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1422
diff
changeset
|
141 |
} else { |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1422
diff
changeset
|
142 |
cout << "Delay meas."; |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1422
diff
changeset
|
143 |
} |
1426 | 144 |
cout << "\\nDelay: " << si->transmission_delay << " ns"; |
1425
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1422
diff
changeset
|
145 |
} |
1422
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
146 |
cout << "\"]" << endl; |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
147 |
|
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
148 |
for (i = 1; i < EC_MAX_PORTS; i++) { |
1425
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1422
diff
changeset
|
149 |
uint16_t next_pos = si->ports[i].next_slave; |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1422
diff
changeset
|
150 |
ec_ioctl_slave_t *next = NULL; |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1422
diff
changeset
|
151 |
|
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1422
diff
changeset
|
152 |
if (next_pos == 0xffff) |
1422
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
153 |
continue; |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
154 |
|
1425
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1422
diff
changeset
|
155 |
if (next_pos < slaves.size()) { |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1422
diff
changeset
|
156 |
next = &slaves[next_pos]; |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1422
diff
changeset
|
157 |
} else { |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1422
diff
changeset
|
158 |
cerr << "Invalid next slave pointer." << endl; |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1422
diff
changeset
|
159 |
} |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1422
diff
changeset
|
160 |
|
1422
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
161 |
cout << " slave" << si->position << " -- " |
1425
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1422
diff
changeset
|
162 |
<< "slave" << next_pos << " [taillabel=\"" << i; |
1422
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
163 |
|
1425
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1422
diff
changeset
|
164 |
if (si->dc_supported) { |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1422
diff
changeset
|
165 |
cout << " [" << si->ports[i].delay_to_next_dc << "]"; |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1422
diff
changeset
|
166 |
} |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1422
diff
changeset
|
167 |
cout << "\",headlabel=\"0"; |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1422
diff
changeset
|
168 |
|
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1422
diff
changeset
|
169 |
if (next && next->dc_supported) { |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1422
diff
changeset
|
170 |
cout << " [" << next->ports[0].delay_to_next_dc << "]"; |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1422
diff
changeset
|
171 |
} |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1422
diff
changeset
|
172 |
cout << "\""; |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1422
diff
changeset
|
173 |
|
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1422
diff
changeset
|
174 |
mi = portMedia.find(si->ports[i].desc); |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1422
diff
changeset
|
175 |
if (mi == portMedia.end() && next) { |
1422
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
176 |
/* Try medium of next-hop slave. */ |
1425
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1422
diff
changeset
|
177 |
mi = portMedia.find(next->ports[0].desc); |
1422
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
178 |
} |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
179 |
|
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
180 |
if (mi != portMedia.end()) |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
181 |
cout << ",label=\"" << mi->second << "\""; |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
182 |
|
1425
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1422
diff
changeset
|
183 |
wi = mediaWeights.find(si->ports[i].desc); |
1422
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
184 |
if (wi != mediaWeights.end()) |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
185 |
cout << ",weight=\"" << wi->second << "\""; |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
186 |
|
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
187 |
cout << "]" << endl; |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
188 |
} |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
189 |
|
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
190 |
cout << endl; |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
191 |
} |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
192 |
|
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
193 |
cout << "}" << endl; |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
194 |
} |
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
195 |
|
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
196 |
/*****************************************************************************/ |