91 cout |
91 cout |
92 << "Master" << m.getIndex() << endl |
92 << "Master" << m.getIndex() << endl |
93 << " Phase: "; |
93 << " Phase: "; |
94 |
94 |
95 switch (data.phase) { |
95 switch (data.phase) { |
96 case 0: cout << "Waiting for device..."; break; |
96 case 0: cout << "Waiting for device(s)..."; break; |
97 case 1: cout << "Idle"; break; |
97 case 1: cout << "Idle"; break; |
98 case 2: cout << "Operation"; break; |
98 case 2: cout << "Operation"; break; |
99 default: cout << "???"; |
99 default: cout << "???"; |
100 } |
100 } |
101 |
101 |
102 cout << endl |
102 cout << endl |
103 << " Active: " << (data.active ? "yes" : "no") << endl |
103 << " Active: " << (data.active ? "yes" : "no") << endl |
104 << " Slaves: " << data.slave_count << endl |
104 << " Slaves: " << data.slave_count << endl |
105 << " Ethernet devices:" << endl; |
105 << " Ethernet devices:" << endl; |
106 |
106 |
107 for (i = 0; i < 2; i++) { |
107 for (dev_idx = EC_DEVICE_MAIN; dev_idx < data.num_devices; |
108 cout << " " << (i == 0 ? "Main" : "Backup") << ": "; |
108 dev_idx++) { |
109 if (data.devices[i].address[0] == 0x00 |
109 cout << " " << (dev_idx == EC_DEVICE_MAIN ? "Main" : "Backup") |
110 && data.devices[i].address[1] == 0x00 |
110 << ": "; |
111 && data.devices[i].address[2] == 0x00 |
111 cout << hex << setfill('0') |
112 && data.devices[i].address[3] == 0x00 |
112 << setw(2) << (unsigned int) data.devices[dev_idx].address[0] |
113 && data.devices[i].address[4] == 0x00 |
113 << ":" |
114 && data.devices[i].address[5] == 0x00) { |
114 << setw(2) << (unsigned int) data.devices[dev_idx].address[1] |
115 cout << "None."; |
115 << ":" |
116 } else { |
116 << setw(2) << (unsigned int) data.devices[dev_idx].address[2] |
117 unsigned int lost = |
117 << ":" |
118 data.devices[i].tx_count - data.devices[i].rx_count; |
118 << setw(2) << (unsigned int) data.devices[dev_idx].address[3] |
119 if (lost == 1) { |
119 << ":" |
120 // allow one frame travelling |
120 << setw(2) << (unsigned int) data.devices[dev_idx].address[4] |
121 lost = 0; |
121 << ":" |
122 } |
122 << setw(2) << (unsigned int) data.devices[dev_idx].address[5] |
123 cout << hex << setfill('0') |
123 << " (" |
124 << setw(2) << (unsigned int) data.devices[i].address[0] |
124 << (data.devices[dev_idx].attached ? |
125 << ":" |
125 "attached" : "waiting...") |
126 << setw(2) << (unsigned int) data.devices[i].address[1] |
126 << ")" << endl << dec |
127 << ":" |
127 << " Link: " |
128 << setw(2) << (unsigned int) data.devices[i].address[2] |
128 << (data.devices[dev_idx].link_state ? "UP" : "DOWN") << endl |
129 << ":" |
129 << " Tx frames: " |
130 << setw(2) << (unsigned int) data.devices[i].address[3] |
130 << data.devices[dev_idx].tx_count << endl |
131 << ":" |
131 << " Tx bytes: " |
132 << setw(2) << (unsigned int) data.devices[i].address[4] |
132 << data.devices[dev_idx].tx_bytes << endl |
133 << ":" |
133 << " Rx frames: " |
134 << setw(2) << (unsigned int) data.devices[i].address[5] |
134 << data.devices[dev_idx].rx_count << endl |
135 << " (" |
135 << " Rx bytes: " |
136 << (data.devices[i].attached ? "attached" : "waiting...") |
136 << data.devices[dev_idx].rx_bytes << endl |
137 << ")" << endl << dec |
137 << " Tx errors: " |
138 << " Link: " |
138 << data.devices[dev_idx].tx_errors << endl |
139 << (data.devices[i].link_state ? "UP" : "DOWN") << endl |
139 << " Tx frame rate [1/s]: " |
140 << " Tx frames: " |
140 << setfill(' ') << setprecision(0) << fixed; |
141 << data.devices[i].tx_count << endl |
141 for (j = 0; j < EC_RATE_COUNT; j++) { |
142 << " Rx frames: " |
142 cout << setw(ColWidth) |
143 << data.devices[i].rx_count << endl |
143 << data.devices[dev_idx].tx_frame_rates[j] / 1000.0; |
144 << " Lost frames: " << lost << endl |
144 if (j < EC_RATE_COUNT - 1) { |
145 << " Tx bytes: " |
145 cout << " "; |
146 << data.devices[i].tx_bytes << endl |
146 } |
147 << " Tx errors: " |
147 } |
148 << data.devices[i].tx_errors << endl |
148 cout << endl |
149 << " Tx frame rate [1/s]: " |
149 << " Tx rate [KByte/s]: " |
150 << setfill(' ') << setprecision(0) << fixed; |
150 << setprecision(1) << fixed; |
151 for (j = 0; j < EC_RATE_COUNT; j++) { |
151 for (j = 0; j < EC_RATE_COUNT; j++) { |
152 cout << setw(ColWidth) |
152 cout << setw(ColWidth) |
153 << data.devices[i].tx_frame_rates[j] / 1000.0; |
153 << data.devices[dev_idx].tx_byte_rates[j] / 1024.0; |
154 if (j < EC_RATE_COUNT - 1) { |
154 if (j < EC_RATE_COUNT - 1) { |
155 cout << " "; |
155 cout << " "; |
156 } |
156 } |
157 } |
157 } |
158 cout << endl |
158 cout << endl |
159 << " Tx rate [KByte/s]: " |
159 << " Rx frame rate [1/s]: " |
160 << setprecision(1) << fixed; |
160 << setfill(' ') << setprecision(0) << fixed; |
161 for (j = 0; j < EC_RATE_COUNT; j++) { |
161 for (j = 0; j < EC_RATE_COUNT; j++) { |
162 cout << setw(ColWidth) |
162 cout << setw(ColWidth) |
163 << data.devices[i].tx_byte_rates[j] / 1024.0; |
163 << data.devices[dev_idx].rx_frame_rates[j] / 1000.0; |
164 if (j < EC_RATE_COUNT - 1) { |
164 if (j < EC_RATE_COUNT - 1) { |
165 cout << " "; |
165 cout << " "; |
166 } |
166 } |
167 } |
167 } |
168 cout << endl |
168 cout << endl |
169 << " Loss rate [1/s]: " |
169 << " Rx rate [KByte/s]: " |
170 << setprecision(0) << fixed; |
170 << setprecision(1) << fixed; |
171 for (j = 0; j < EC_RATE_COUNT; j++) { |
171 for (j = 0; j < EC_RATE_COUNT; j++) { |
172 cout << setw(ColWidth) |
172 cout << setw(ColWidth) |
173 << data.devices[i].loss_rates[j] / 1000.0; |
173 << data.devices[dev_idx].rx_byte_rates[j] / 1024.0; |
174 if (j < EC_RATE_COUNT - 1) { |
174 if (j < EC_RATE_COUNT - 1) { |
175 cout << " "; |
175 cout << " "; |
176 } |
176 } |
177 } |
177 } |
178 cout << endl |
178 cout << setprecision(0) << endl; |
179 << " Frame loss [%]: " |
179 } |
180 << setprecision(1) << fixed; |
180 unsigned int lost = data.tx_count - data.rx_count; |
181 for (j = 0; j < EC_RATE_COUNT; j++) { |
181 if (lost == 1) { |
182 double perc = 0.0; |
182 // allow one frame travelling |
183 if (data.devices[i].tx_frame_rates[j]) { |
183 lost = 0; |
184 perc = 100.0 * data.devices[i].loss_rates[j] / |
184 } |
185 data.devices[i].tx_frame_rates[j]; |
185 cout << " Common:" << endl |
186 } |
186 << " Tx frames: " |
187 cout << setw(ColWidth) << perc; |
187 << data.tx_count << endl |
188 if (j < EC_RATE_COUNT - 1) { |
188 << " Tx bytes: " |
189 cout << " "; |
189 << data.tx_bytes << endl |
190 } |
190 << " Rx frames: " |
191 } |
191 << data.rx_count << endl |
192 cout << setprecision(0) << endl; |
192 << " Rx bytes: " |
193 } |
193 << data.rx_bytes << endl |
194 cout << endl; |
194 << " Lost frames: " << lost << endl |
195 } |
195 << " Tx frame rate [1/s]: " |
|
196 << setfill(' ') << setprecision(0) << fixed; |
|
197 for (j = 0; j < EC_RATE_COUNT; j++) { |
|
198 cout << setw(ColWidth) |
|
199 << data.tx_frame_rates[j] / 1000.0; |
|
200 if (j < EC_RATE_COUNT - 1) { |
|
201 cout << " "; |
|
202 } |
|
203 } |
|
204 cout << endl |
|
205 << " Tx rate [KByte/s]: " |
|
206 << setprecision(1) << fixed; |
|
207 for (j = 0; j < EC_RATE_COUNT; j++) { |
|
208 cout << setw(ColWidth) |
|
209 << data.tx_byte_rates[j] / 1024.0; |
|
210 if (j < EC_RATE_COUNT - 1) { |
|
211 cout << " "; |
|
212 } |
|
213 } |
|
214 cout << endl |
|
215 << " Rx frame rate [1/s]: " |
|
216 << setfill(' ') << setprecision(0) << fixed; |
|
217 for (j = 0; j < EC_RATE_COUNT; j++) { |
|
218 cout << setw(ColWidth) |
|
219 << data.rx_frame_rates[j] / 1000.0; |
|
220 if (j < EC_RATE_COUNT - 1) { |
|
221 cout << " "; |
|
222 } |
|
223 } |
|
224 cout << endl |
|
225 << " Rx rate [KByte/s]: " |
|
226 << setprecision(1) << fixed; |
|
227 for (j = 0; j < EC_RATE_COUNT; j++) { |
|
228 cout << setw(ColWidth) |
|
229 << data.rx_byte_rates[j] / 1024.0; |
|
230 if (j < EC_RATE_COUNT - 1) { |
|
231 cout << " "; |
|
232 } |
|
233 } |
|
234 cout << endl |
|
235 << " Loss rate [1/s]: " |
|
236 << setprecision(0) << fixed; |
|
237 for (j = 0; j < EC_RATE_COUNT; j++) { |
|
238 cout << setw(ColWidth) |
|
239 << data.loss_rates[j] / 1000.0; |
|
240 if (j < EC_RATE_COUNT - 1) { |
|
241 cout << " "; |
|
242 } |
|
243 } |
|
244 cout << endl |
|
245 << " Frame loss [%]: " |
|
246 << setprecision(1) << fixed; |
|
247 for (j = 0; j < EC_RATE_COUNT; j++) { |
|
248 double perc = 0.0; |
|
249 if (data.tx_frame_rates[j]) { |
|
250 perc = 100.0 * data.loss_rates[j] / data.tx_frame_rates[j]; |
|
251 } |
|
252 cout << setw(ColWidth) << perc; |
|
253 if (j < EC_RATE_COUNT - 1) { |
|
254 cout << " "; |
|
255 } |
|
256 } |
|
257 cout << setprecision(0) << endl; |
196 |
258 |
197 cout << " Distributed clocks:" << endl |
259 cout << " Distributed clocks:" << endl |
198 << " Reference clock: "; |
260 << " Reference clock: "; |
199 if (data.ref_clock != 0xffff) { |
261 if (data.ref_clock != 0xffff) { |
200 cout << "Slave " << dec << data.ref_clock; |
262 cout << "Slave " << dec << data.ref_clock; |