fp@1485: /***************************************************************************** fp@1485: * fp@1524: * $Id$ fp@1485: * fp@1485: * Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH fp@1485: * fp@1485: * This file is part of the IgH EtherCAT Master. fp@1485: * fp@1485: * The IgH EtherCAT Master is free software; you can redistribute it and/or fp@1485: * modify it under the terms of the GNU General Public License version 2, as fp@1485: * published by the Free Software Foundation. fp@1485: * fp@1485: * The IgH EtherCAT Master is distributed in the hope that it will be useful, fp@1485: * but WITHOUT ANY WARRANTY; without even the implied warranty of fp@1485: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General fp@1485: * Public License for more details. fp@1485: * fp@1485: * You should have received a copy of the GNU General Public License along fp@1485: * with the IgH EtherCAT Master; if not, write to the Free Software fp@1485: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA fp@1485: * fp@1485: * --- fp@1485: * fp@1485: * The license mentioned above concerns the source code only. Using the fp@1485: * EtherCAT technology and brand is only permitted in compliance with the fp@1485: * industrial property and similar rights of Beckhoff Automation GmbH. fp@1485: * fp@1485: ****************************************************************************/ fp@1485: fp@1485: #include fp@1485: #include fp@1485: #include fp@1485: #include fp@1485: using namespace std; fp@1485: fp@1485: #include "CommandEoe.h" fp@1826: #include "MasterDevice.h" fp@1485: fp@1485: /*****************************************************************************/ fp@1485: fp@1485: CommandEoe::CommandEoe(): fp@1485: Command("eoe", "Display Ethernet over EtherCAT statictics.") fp@1485: { fp@1485: } fp@1485: fp@1485: /*****************************************************************************/ fp@1485: fp@1968: string CommandEoe::helpString(const string &binaryBaseName) const fp@1485: { fp@1485: stringstream str; fp@1485: fp@1968: str << binaryBaseName << " " << getName() << endl fp@1485: << endl fp@1485: << getBriefDescription() << endl fp@1485: << endl fp@1485: << "The TxRate and RxRate are displayed in Byte/s." << endl fp@1485: << endl; fp@1485: fp@1485: return str.str(); fp@1485: } fp@1485: fp@1485: /****************************************************************************/ fp@1485: fp@1826: void CommandEoe::execute(const StringVector &args) fp@1485: { fp@1869: MasterIndexList masterIndices; fp@1485: ec_ioctl_master_t master; fp@1485: unsigned int i; fp@1485: ec_ioctl_eoe_handler_t eoe; fp@1826: bool doIndent; fp@1826: string indent; fp@2421: fp@1485: if (args.size()) { fp@1485: stringstream err; fp@1485: err << "'" << getName() << "' takes no arguments!"; fp@1485: throwInvalidUsageException(err); fp@1485: } fp@1485: fp@1869: masterIndices = getMasterIndices(); fp@1869: doIndent = masterIndices.size(); fp@1826: indent = doIndent ? " " : ""; fp@1826: MasterIndexList::const_iterator mi; fp@1869: for (mi = masterIndices.begin(); fp@1869: mi != masterIndices.end(); mi++) { fp@1826: MasterDevice m(*mi); fp@1826: m.open(MasterDevice::Read); fp@1826: m.getMaster(&master); fp@1485: fp@1827: if (master.eoe_handler_count) { fp@1827: if (doIndent) { fp@1827: cout << "Master" << dec << *mi << endl; fp@1827: } fp@1827: fp@1827: cout << indent << "Interface Slave State " fp@1827: << "RxBytes RxRate " fp@1827: << "TxBytes TxRate TxQueue" fp@1827: << endl; fp@1826: } fp@1485: fp@1826: for (i = 0; i < master.eoe_handler_count; i++) { fp@1826: stringstream queue; fp@1485: fp@1826: m.getEoeHandler(&eoe, i); fp@1485: fp@1826: queue << eoe.tx_queued_frames << "/" << eoe.tx_queue_size; fp@1826: fp@1826: cout << indent fp@1826: << setw(9) << eoe.name << " " fp@1826: << setw(5) << dec << eoe.slave_position << " " fp@1826: << setw(5) << (eoe.open ? "up" : "down") << " " fp@1826: << setw(7) << eoe.rx_bytes << " " fp@1826: << setw(6) << eoe.rx_rate << " " fp@1826: << setw(7) << eoe.tx_bytes << " " fp@1826: << setw(6) << eoe.tx_rate << " " fp@1826: << setw(7) << queue.str() fp@1826: << endl; fp@1826: } fp@1485: } fp@1485: } fp@1485: fp@1485: /*****************************************************************************/