tool/CommandMaster.cpp
branchstable-1.5
changeset 2419 fdb85a806585
parent 2158 69f2b2702336
child 2421 bc2d4bf9cbe5
equal deleted inserted replaced
2417:63bef67e812b 2419:fdb85a806585
    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 
   112                     && data.devices[i].address[3] == 0x00
   112                     && data.devices[i].address[3] == 0x00
   113                     && data.devices[i].address[4] == 0x00
   113                     && data.devices[i].address[4] == 0x00
   114                     && data.devices[i].address[5] == 0x00) {
   114                     && data.devices[i].address[5] == 0x00) {
   115                 cout << "None.";
   115                 cout << "None.";
   116             } else {
   116             } else {
   117                 unsigned int lost =
       
   118                     data.devices[i].tx_count - data.devices[i].rx_count;
       
   119                 if (lost == 1) {
       
   120                     // allow one frame travelling
       
   121                     lost = 0;
       
   122                 }
       
   123                 cout << hex << setfill('0')
   117                 cout << hex << setfill('0')
   124                     << setw(2) << (unsigned int) data.devices[i].address[0]
   118                     << setw(2) << (unsigned int) data.devices[i].address[0]
   125                     << ":"
   119                     << ":"
   126                     << setw(2) << (unsigned int) data.devices[i].address[1]
   120                     << setw(2) << (unsigned int) data.devices[i].address[1]
   127                     << ":"
   121                     << ":"
   137                     << ")" << endl << dec
   131                     << ")" << endl << dec
   138                     << "      Link: "
   132                     << "      Link: "
   139                     << (data.devices[i].link_state ? "UP" : "DOWN") << endl
   133                     << (data.devices[i].link_state ? "UP" : "DOWN") << endl
   140                     << "      Tx frames:   "
   134                     << "      Tx frames:   "
   141                     << data.devices[i].tx_count << endl
   135                     << data.devices[i].tx_count << endl
       
   136                     << "      Tx bytes:    "
       
   137                     << data.devices[i].tx_bytes << endl
   142                     << "      Rx frames:   "
   138                     << "      Rx frames:   "
   143                     << data.devices[i].rx_count << endl
   139                     << data.devices[i].rx_count << endl
   144                     << "      Lost frames: " << lost << endl
   140                     << "      Rx bytes:    "
   145                     << "      Tx bytes:    "
   141                     << data.devices[i].rx_bytes << endl
   146                     << data.devices[i].tx_bytes << endl
       
   147                     << "      Tx errors:   "
   142                     << "      Tx errors:   "
   148                     << data.devices[i].tx_errors << endl
   143                     << data.devices[i].tx_errors << endl
   149                     << "      Tx frame rate [1/s]: "
   144                     << "      Tx frame rate [1/s]: "
   150                     << setfill(' ') << setprecision(0) << fixed;
   145                     << setfill(' ') << setprecision(0) << fixed;
   151                 for (j = 0; j < EC_RATE_COUNT; j++) {
   146                 for (j = 0; j < EC_RATE_COUNT; j++) {
   164                     if (j < EC_RATE_COUNT - 1) {
   159                     if (j < EC_RATE_COUNT - 1) {
   165                         cout << " ";
   160                         cout << " ";
   166                     }
   161                     }
   167                 }
   162                 }
   168                 cout << endl
   163                 cout << endl
   169                     << "      Loss rate [1/s]:     "
   164                     << "      Rx frame rate [1/s]: "
   170                     << setprecision(0) << fixed;
   165                     << setfill(' ') << setprecision(0) << fixed;
   171                 for (j = 0; j < EC_RATE_COUNT; j++) {
   166                 for (j = 0; j < EC_RATE_COUNT; j++) {
   172                     cout << setw(ColWidth)
   167                     cout << setw(ColWidth)
   173                         << data.devices[i].loss_rates[j] / 1000.0;
   168                         << data.devices[i].rx_frame_rates[j] / 1000.0;
   174                     if (j < EC_RATE_COUNT - 1) {
   169                     if (j < EC_RATE_COUNT - 1) {
   175                         cout << " ";
   170                         cout << " ";
   176                     }
   171                     }
   177                 }
   172                 }
   178                 cout << endl
   173                 cout << endl
   179                     << "      Frame loss [%]:      "
   174                     << "      Rx rate [KByte/s]:   "
   180                     << setprecision(1) << fixed;
   175                     << setprecision(1) << fixed;
   181                 for (j = 0; j < EC_RATE_COUNT; j++) {
   176                 for (j = 0; j < EC_RATE_COUNT; j++) {
   182                     double perc = 0.0;
   177                     cout << setw(ColWidth)
   183                     if (data.devices[i].tx_frame_rates[j]) {
   178                         << data.devices[i].rx_byte_rates[j] / 1024.0;
   184                         perc = 100.0 * data.devices[i].loss_rates[j] /
       
   185                             data.devices[i].tx_frame_rates[j];
       
   186                     }
       
   187                     cout << setw(ColWidth) << perc;
       
   188                     if (j < EC_RATE_COUNT - 1) {
   179                     if (j < EC_RATE_COUNT - 1) {
   189                         cout << " ";
   180                         cout << " ";
   190                     }
   181                     }
   191                 }
   182                 }
   192                 cout << setprecision(0) << endl;
   183                 cout << setprecision(0) << endl;
   193             }
   184             }
   194             cout << endl;
   185         }
   195         }
   186         unsigned int lost = data.tx_count - data.rx_count;
       
   187         if (lost == 1) {
       
   188             // allow one frame travelling
       
   189             lost = 0;
       
   190         }
       
   191         cout << "    Common:" << endl
       
   192             << "      Tx frames:   "
       
   193             << data.tx_count << endl
       
   194             << "      Tx bytes:    "
       
   195             << data.tx_bytes << endl
       
   196             << "      Rx frames:   "
       
   197             << data.rx_count << endl
       
   198             << "      Rx bytes:    "
       
   199             << data.rx_bytes << endl
       
   200             << "      Lost frames: " << lost << endl
       
   201             << "      Tx frame rate [1/s]: "
       
   202             << setfill(' ') << setprecision(0) << fixed;
       
   203         for (j = 0; j < EC_RATE_COUNT; j++) {
       
   204             cout << setw(ColWidth)
       
   205                 << data.tx_frame_rates[j] / 1000.0;
       
   206             if (j < EC_RATE_COUNT - 1) {
       
   207                 cout << " ";
       
   208             }
       
   209         }
       
   210         cout << endl
       
   211             << "      Tx rate [KByte/s]:   "
       
   212             << setprecision(1) << fixed;
       
   213         for (j = 0; j < EC_RATE_COUNT; j++) {
       
   214             cout << setw(ColWidth)
       
   215                 << data.tx_byte_rates[j] / 1024.0;
       
   216             if (j < EC_RATE_COUNT - 1) {
       
   217                 cout << " ";
       
   218             }
       
   219         }
       
   220         cout << endl
       
   221             << "      Rx frame rate [1/s]: "
       
   222             << setfill(' ') << setprecision(0) << fixed;
       
   223         for (j = 0; j < EC_RATE_COUNT; j++) {
       
   224             cout << setw(ColWidth)
       
   225                 << data.rx_frame_rates[j] / 1000.0;
       
   226             if (j < EC_RATE_COUNT - 1) {
       
   227                 cout << " ";
       
   228             }
       
   229         }
       
   230         cout << endl
       
   231             << "      Rx rate [KByte/s]:   "
       
   232             << setprecision(1) << fixed;
       
   233         for (j = 0; j < EC_RATE_COUNT; j++) {
       
   234             cout << setw(ColWidth)
       
   235                 << data.rx_byte_rates[j] / 1024.0;
       
   236             if (j < EC_RATE_COUNT - 1) {
       
   237                 cout << " ";
       
   238             }
       
   239         }
       
   240         cout << endl
       
   241             << "      Loss rate [1/s]:     "
       
   242             << setprecision(0) << fixed;
       
   243         for (j = 0; j < EC_RATE_COUNT; j++) {
       
   244             cout << setw(ColWidth)
       
   245                 << data.loss_rates[j] / 1000.0;
       
   246             if (j < EC_RATE_COUNT - 1) {
       
   247                 cout << " ";
       
   248             }
       
   249         }
       
   250         cout << endl
       
   251             << "      Frame loss [%]:      "
       
   252             << setprecision(1) << fixed;
       
   253         for (j = 0; j < EC_RATE_COUNT; j++) {
       
   254             double perc = 0.0;
       
   255             if (data.tx_frame_rates[j]) {
       
   256                 perc = 100.0 * data.loss_rates[j] / data.tx_frame_rates[j];
       
   257             }
       
   258             cout << setw(ColWidth) << perc;
       
   259             if (j < EC_RATE_COUNT - 1) {
       
   260                 cout << " ";
       
   261             }
       
   262         }
       
   263         cout << setprecision(0) << endl;
   196 
   264 
   197         cout << "  Distributed clocks:" << endl
   265         cout << "  Distributed clocks:" << endl
   198             << "    Reference clock: ";
   266             << "    Reference clock: ";
   199         if (data.ref_clock != 0xffff) {
   267         if (data.ref_clock != 0xffff) {
   200             cout << "Slave " << dec << data.ref_clock;
   268             cout << "Slave " << dec << data.ref_clock;