fp@1961: /***************************************************************************** fp@1961: * fp@1961: * $Id$ fp@1961: * fp@1961: * Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH fp@1961: * fp@1961: * This file is part of the IgH EtherCAT Master. fp@1961: * fp@1961: * The IgH EtherCAT Master is free software; you can redistribute it and/or fp@1961: * modify it under the terms of the GNU General Public License version 2, as fp@1961: * published by the Free Software Foundation. fp@1961: * fp@1961: * The IgH EtherCAT Master is distributed in the hope that it will be useful, fp@1961: * but WITHOUT ANY WARRANTY; without even the implied warranty of fp@1961: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General fp@1961: * Public License for more details. fp@1961: * fp@1961: * You should have received a copy of the GNU General Public License along fp@1961: * with the IgH EtherCAT Master; if not, write to the Free Software fp@1961: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA fp@1961: * fp@1961: * --- fp@1961: * fp@1961: * The license mentioned above concerns the source code only. Using the fp@1961: * EtherCAT technology and brand is only permitted in compliance with the fp@1961: * industrial property and similar rights of Beckhoff Automation GmbH. fp@1961: * fp@1961: * vim: expandtab fp@1961: * fp@1961: ****************************************************************************/ fp@1961: fp@1961: #include fp@1961: #include fp@1961: using namespace std; fp@1961: fp@1961: #include "CommandRescan.h" fp@1961: #include "MasterDevice.h" fp@1961: fp@1961: /*****************************************************************************/ fp@1961: fp@1961: CommandRescan::CommandRescan(): fp@1961: Command("rescan", "Rescan the bus.") fp@1961: { fp@1961: } fp@1961: fp@1961: /*****************************************************************************/ fp@1961: fp@1968: string CommandRescan::helpString(const string &binaryBaseName) const fp@1961: { fp@1961: stringstream str; fp@1961: fp@1968: str << binaryBaseName << " " << getName() << endl fp@1961: << endl fp@1961: << getBriefDescription() << endl fp@1961: << endl fp@1961: << "Command a bus rescan. Gathered slave information will be" << endl fp@1961: << "forgotten and slaves will be read in again." << endl fp@1961: << endl; fp@1961: fp@1961: return str.str(); fp@1961: } fp@1961: fp@1961: /****************************************************************************/ fp@1961: fp@1961: void CommandRescan::execute(const StringVector &args) fp@1961: { fp@1961: MasterIndexList masterIndices; fp@2421: fp@1961: if (args.size() != 0) { fp@1961: stringstream err; fp@1961: err << "'" << getName() << "' takes no arguments!"; fp@1961: throwInvalidUsageException(err); fp@1961: } fp@1961: fp@1961: masterIndices = getMasterIndices(); fp@1961: MasterIndexList::const_iterator mi; fp@1961: for (mi = masterIndices.begin(); fp@1961: mi != masterIndices.end(); mi++) { fp@1961: MasterDevice m(*mi); fp@1961: m.open(MasterDevice::ReadWrite); fp@1961: m.rescan(); fp@1961: } fp@1961: } fp@1961: fp@1961: /*****************************************************************************/