tool/CommandSlaves.cpp
author Florian Pose <fp@igh-essen.com>
Tue, 24 Feb 2009 08:54:17 +0000
changeset 1357 b065f49113f4
parent 1337 0253c74d0940
child 1363 11c0b2caa253
permissions -rw-r--r--
Added missing headers for newer GCC versions.
1142
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     1
/*****************************************************************************
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     2
 *
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     3
 * $Id$
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     4
 *
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     5
 ****************************************************************************/
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     6
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     7
#include <iostream>
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     8
#include <iomanip>
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     9
#include <list>
1222
7348d6abb6cb Applied patch by Karsten Schwinne, adding a few header files necessary
Florian Pose <fp@igh-essen.com>
parents: 1220
diff changeset
    10
#include <string.h>
1142
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    11
using namespace std;
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    12
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    13
#include "CommandSlaves.h"
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    14
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    15
/*****************************************************************************/
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    16
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    17
CommandSlaves::CommandSlaves():
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    18
    Command("slaves", "Display slaves on the bus.")
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    19
{
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    20
}
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    21
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    22
/*****************************************************************************/
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    23
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    24
string CommandSlaves::helpString() const
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    25
{
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    26
    stringstream str;
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    27
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    28
    str << getName() << " [OPTIONS]" << endl
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    29
        << endl
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    30
        << getBriefDescription() << endl
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    31
        << endl
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    32
        << "If the --verbose option is not given, the slaves are" << endl
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    33
        << "displayed one-per-line. Example:" << endl
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    34
        << endl
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    35
        << "1  5555:0  PREOP  +  EL3162 2C. Ana. Input 0-10V" << endl
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    36
        << "|  |    |  |      |  |" << endl
1144
7dbfdd61812c Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents: 1142
diff changeset
    37
        << "|  |    |  |      |  \\- Name from the SII if avaliable," << endl
7dbfdd61812c Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents: 1142
diff changeset
    38
        << "|  |    |  |      |     otherwise vendor ID and product" << endl
7dbfdd61812c Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents: 1142
diff changeset
    39
        << "|  |    |  |      |     code (both hexadecimal)." << endl
1142
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    40
        << "|  |    |  |      \\- Error flag. '+' means no error," << endl
1144
7dbfdd61812c Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents: 1142
diff changeset
    41
        << "|  |    |  |         'E' means that scan or" << endl
1142
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    42
        << "|  |    |  |         configuration failed." << endl
1144
7dbfdd61812c Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents: 1142
diff changeset
    43
        << "|  |    |  \\- Current application-layer state." << endl
1157
04d1c950cf9d Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents: 1151
diff changeset
    44
        << "|  |    \\- Decimal relative position to the last" << endl
1142
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    45
        << "|  |       slave with an alias address set." << endl
1157
04d1c950cf9d Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents: 1151
diff changeset
    46
        << "|  \\- Decimal alias address of this slave (if set)," << endl
04d1c950cf9d Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents: 1151
diff changeset
    47
        << "|     otherwise of the last slave with an alias set," << endl
04d1c950cf9d Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents: 1151
diff changeset
    48
        << "|     or zero, if no alias was encountered up to this" << endl
04d1c950cf9d Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents: 1151
diff changeset
    49
        << "|     position." << endl
04d1c950cf9d Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents: 1151
diff changeset
    50
        << "\\- Absolute ring position in the bus." << endl
1142
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    51
        << endl
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    52
        << "If the --verbose option is given, a detailed (multi-line)" << endl
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    53
        << "description is output for each slave." << endl
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    54
        << endl
1157
04d1c950cf9d Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents: 1151
diff changeset
    55
        << "Slave selection:" << endl
04d1c950cf9d Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents: 1151
diff changeset
    56
        << "  Slaves for this and other commands can be selected with" << endl
04d1c950cf9d Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents: 1151
diff changeset
    57
        << "  the --alias and --position parameters as follows:" << endl
04d1c950cf9d Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents: 1151
diff changeset
    58
        << endl
04d1c950cf9d Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents: 1151
diff changeset
    59
        << "  1) If neither the --alias nor the --position option" << endl
04d1c950cf9d Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents: 1151
diff changeset
    60
        << "     is given, all slaves are selected." << endl
04d1c950cf9d Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents: 1151
diff changeset
    61
        << "  2) If only the --position option is given, it is" << endl
04d1c950cf9d Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents: 1151
diff changeset
    62
        << "     interpreted as an absolute ring position and" << endl
04d1c950cf9d Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents: 1151
diff changeset
    63
        << "     a slave with this position is matched." << endl
04d1c950cf9d Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents: 1151
diff changeset
    64
        << "  3) If only the --alias option is given, all slaves" << endl
04d1c950cf9d Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents: 1151
diff changeset
    65
        << "     with the given alias address and subsequent" << endl
04d1c950cf9d Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents: 1151
diff changeset
    66
        << "     slaves before a slave with a different alias" << endl
04d1c950cf9d Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents: 1151
diff changeset
    67
        << "     address match (use -p0 if only the slaves" << endl
04d1c950cf9d Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents: 1151
diff changeset
    68
        << "     with the given alias are desired, see 4))." << endl
04d1c950cf9d Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents: 1151
diff changeset
    69
        << "  4) If both the --alias and the --position option are" << endl
04d1c950cf9d Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents: 1151
diff changeset
    70
        << "     given, the latter is interpreted as relative" << endl
04d1c950cf9d Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents: 1151
diff changeset
    71
        << "     position behind any slave with the given alias." << endl
04d1c950cf9d Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents: 1151
diff changeset
    72
        << endl
1142
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    73
        << "Command-specific options:" << endl
1157
04d1c950cf9d Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents: 1151
diff changeset
    74
        << "  --alias    -a <alias>  Slave alias (see above)." << endl
04d1c950cf9d Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents: 1151
diff changeset
    75
        << "  --position -p <pos>    Slave position (see above)." << endl
04d1c950cf9d Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents: 1151
diff changeset
    76
        << "  --verbose  -v          Show detailed slave information." << endl
1142
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    77
        << endl
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    78
        << numericInfo();
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    79
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    80
    return str.str();
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    81
}
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    82
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    83
/****************************************************************************/
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    84
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    85
void CommandSlaves::execute(MasterDevice &m, const StringVector &args)
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    86
{
1151
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
    87
    SlaveList slaves;
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
    88
    
1142
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    89
    m.open(MasterDevice::Read);
1151
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
    90
    slaves = selectedSlaves(m);
1142
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    91
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    92
    if (getVerbosity() == Verbose) {
1151
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
    93
        showSlaves(m, slaves);
1142
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    94
    } else {
1151
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
    95
        listSlaves(m, slaves);
1142
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    96
    }
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    97
}
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    98
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    99
/****************************************************************************/
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   100
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   101
void CommandSlaves::listSlaves(
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   102
        MasterDevice &m,
1151
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   103
        const SlaveList &slaves
1142
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   104
        )
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   105
{
1160
f02ff486b313 Removed MasterDevice::slaveCount().
Florian Pose <fp@igh-essen.com>
parents: 1157
diff changeset
   106
    ec_ioctl_master_t master;
f02ff486b313 Removed MasterDevice::slaveCount().
Florian Pose <fp@igh-essen.com>
parents: 1157
diff changeset
   107
    unsigned int i;
1142
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   108
    ec_ioctl_slave_t slave;
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   109
    uint16_t lastAlias, aliasIndex;
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   110
    Info info;
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   111
    typedef list<Info> InfoList;
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   112
    InfoList infoList;
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   113
    InfoList::const_iterator iter;
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   114
    stringstream str;
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   115
    unsigned int maxPosWidth = 0, maxAliasWidth = 0,
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   116
                 maxRelPosWidth = 0, maxStateWidth = 0;
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   117
    
1160
f02ff486b313 Removed MasterDevice::slaveCount().
Florian Pose <fp@igh-essen.com>
parents: 1157
diff changeset
   118
    m.getMaster(&master);
1142
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   119
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   120
    lastAlias = 0;
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   121
    aliasIndex = 0;
1160
f02ff486b313 Removed MasterDevice::slaveCount().
Florian Pose <fp@igh-essen.com>
parents: 1157
diff changeset
   122
    for (i = 0; i < master.slave_count; i++) {
1142
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   123
        m.getSlave(&slave, i);
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   124
        
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   125
        if (slave.alias) {
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   126
            lastAlias = slave.alias;
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   127
            aliasIndex = 0;
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   128
        }
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   129
1151
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   130
        if (slaveInList(slave, slaves)) {
1142
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   131
            str << dec << i;
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   132
            info.pos = str.str();
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   133
            str.clear();
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   134
            str.str("");
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   135
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   136
            str << lastAlias;
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   137
            info.alias = str.str();
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   138
            str.str("");
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   139
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   140
            str << aliasIndex;
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   141
            info.relPos = str.str();
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   142
            str.str("");
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   143
1148
1762296870bd Renamed state field to al_state.
Florian Pose <fp@igh-essen.com>
parents: 1146
diff changeset
   144
            info.state = alStateString(slave.al_state);
1142
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   145
            info.flag = (slave.error_flag ? 'E' : '+');
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   146
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   147
            if (strlen(slave.name)) {
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   148
                info.name = slave.name;
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   149
            } else {
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   150
                str << "0x" << hex << setfill('0')
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   151
                    << setw(8) << slave.vendor_id << ":0x"
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   152
                    << setw(8) << slave.product_code;
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   153
                info.name = str.str();
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   154
                str.str("");
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   155
            }
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   156
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   157
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   158
            infoList.push_back(info);
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   159
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   160
            if (info.pos.length() > maxPosWidth)
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   161
                maxPosWidth = info.pos.length();
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   162
            if (info.alias.length() > maxAliasWidth)
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   163
                maxAliasWidth = info.alias.length();
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   164
            if (info.relPos.length() > maxRelPosWidth)
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   165
                maxRelPosWidth = info.relPos.length();
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   166
            if (info.state.length() > maxStateWidth)
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   167
                maxStateWidth = info.state.length();
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   168
        }
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   169
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   170
        aliasIndex++;
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   171
    }
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   172
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   173
    for (iter = infoList.begin(); iter != infoList.end(); iter++) {
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   174
        cout << setfill(' ') << right
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   175
            << setw(maxPosWidth) << iter->pos << "  "
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   176
            << setw(maxAliasWidth) << iter->alias
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   177
            << ":" << left
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   178
            << setw(maxRelPosWidth) << iter->relPos << "  "
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   179
            << setw(maxStateWidth) << iter->state << "  "
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   180
            << iter->flag << "  "
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   181
            << iter->name << endl;
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   182
    }
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   183
}
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   184
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   185
/****************************************************************************/
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   186
1151
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   187
void CommandSlaves::showSlaves(
1142
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   188
        MasterDevice &m,
1151
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   189
        const SlaveList &slaves
1142
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   190
        )
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   191
{
1151
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   192
    SlaveList::const_iterator si;
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   193
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   194
    for (si = slaves.begin(); si != slaves.end(); si++) {
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   195
        cout << "=== Slave " << dec << si->position << " ===" << endl;
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   196
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   197
        if (si->alias)
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   198
            cout << "Alias: " << si->alias << endl;
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   199
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   200
        cout
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   201
            << "State: " << alStateString(si->al_state) << endl
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   202
            << "Flag: " << (si->error_flag ? 'E' : '+') << endl
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   203
            << "Identity:" << endl
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   204
            << "  Vendor Id:       0x"
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   205
            << hex << setfill('0')
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   206
            << setw(8) << si->vendor_id << endl
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   207
            << "  Product code:    0x"
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   208
            << setw(8) << si->product_code << endl
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   209
            << "  Revision number: 0x"
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   210
            << setw(8) << si->revision_number << endl
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   211
            << "  Serial number:   0x"
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   212
            << setw(8) << si->serial_number << endl;
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   213
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   214
        if (si->mailbox_protocols) {
1220
15e8768b304f Fixed minor supported mailbox protocol display bug.
Florian Pose <fp@igh-essen.com>
parents: 1160
diff changeset
   215
            list<string> protoList;
15e8768b304f Fixed minor supported mailbox protocol display bug.
Florian Pose <fp@igh-essen.com>
parents: 1160
diff changeset
   216
            list<string>::const_iterator protoIter;
15e8768b304f Fixed minor supported mailbox protocol display bug.
Florian Pose <fp@igh-essen.com>
parents: 1160
diff changeset
   217
1151
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   218
            cout << "Mailboxes:" << endl
1337
0253c74d0940 merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
   219
               << "  Bootstrap RX: 0x"
0253c74d0940 merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
   220
                << hex << setw(4) << si->boot_rx_mailbox_offset << "/"
0253c74d0940 merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
   221
                << dec << si->boot_rx_mailbox_size
1151
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   222
                << ", TX: 0x"
1337
0253c74d0940 merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
   223
                << hex << setw(4) << si->boot_tx_mailbox_offset << "/"
0253c74d0940 merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
   224
                << dec << si->boot_tx_mailbox_size << endl
0253c74d0940 merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
   225
                << "  Standard  RX: 0x"
0253c74d0940 merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
   226
                << hex << setw(4) << si->std_rx_mailbox_offset << "/"
0253c74d0940 merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
   227
                << dec << si->std_rx_mailbox_size
0253c74d0940 merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
   228
                << ", TX: 0x"
0253c74d0940 merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
   229
                << hex << setw(4) << si->std_tx_mailbox_offset << "/"
0253c74d0940 merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
   230
                << dec << si->std_tx_mailbox_size << endl
1151
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   231
                << "  Supported protocols: ";
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   232
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   233
            if (si->mailbox_protocols & EC_MBOX_AOE) {
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   234
                protoList.push_back("AoE");
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   235
            }
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   236
            if (si->mailbox_protocols & EC_MBOX_EOE) {
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   237
                protoList.push_back("EoE");
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   238
            }
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   239
            if (si->mailbox_protocols & EC_MBOX_COE) {
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   240
                protoList.push_back("CoE");
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   241
            }
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   242
            if (si->mailbox_protocols & EC_MBOX_FOE) {
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   243
                protoList.push_back("FoE");
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   244
            }
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   245
            if (si->mailbox_protocols & EC_MBOX_SOE) {
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   246
                protoList.push_back("SoE");
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   247
            }
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   248
            if (si->mailbox_protocols & EC_MBOX_VOE) {
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   249
                protoList.push_back("VoE");
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   250
            }
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   251
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   252
            for (protoIter = protoList.begin(); protoIter != protoList.end();
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   253
                    protoIter++) {
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   254
                if (protoIter != protoList.begin())
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   255
                    cout << ", ";
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   256
                cout << *protoIter;
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   257
            }
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   258
            cout << endl;
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   259
        }
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   260
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   261
        if (si->has_general_category) {
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   262
            cout << "General:" << endl
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   263
                << "  Group: " << si->group << endl
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   264
                << "  Image name: " << si->image << endl
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   265
                << "  Order number: " << si->order << endl
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   266
                << "  Device name: " << si->name << endl;
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   267
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   268
            if (si->mailbox_protocols & EC_MBOX_COE) {
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   269
                cout << "  CoE details:" << endl
1327
4d179b06dd3c merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents: 1222
diff changeset
   270
                    << "    Enable SDO: "
1151
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   271
                    << (si->coe_details.enable_sdo ? "yes" : "no") << endl
1327
4d179b06dd3c merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents: 1222
diff changeset
   272
                    << "    Enable SDO Info: "
1151
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   273
                    << (si->coe_details.enable_sdo_info ? "yes" : "no") << endl
1327
4d179b06dd3c merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents: 1222
diff changeset
   274
                    << "    Enable PDO Assign: "
1151
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   275
                    << (si->coe_details.enable_pdo_assign
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   276
                            ? "yes" : "no") << endl
1327
4d179b06dd3c merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents: 1222
diff changeset
   277
                    << "    Enable PDO Configuration: "
1151
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   278
                    << (si->coe_details.enable_pdo_configuration
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   279
                            ? "yes" : "no") << endl
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   280
                    << "    Enable Upload at startup: "
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   281
                    << (si->coe_details.enable_upload_at_startup
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   282
                            ? "yes" : "no") << endl
1327
4d179b06dd3c merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents: 1222
diff changeset
   283
                    << "    Enable SDO complete access: "
1151
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   284
                    << (si->coe_details.enable_sdo_complete_access
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   285
                            ? "yes" : "no") << endl;
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   286
            }
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   287
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   288
            cout << "  Flags:" << endl
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   289
                << "    Enable SafeOp: "
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   290
                << (si->general_flags.enable_safeop ? "yes" : "no") << endl
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   291
                << "    Enable notLRW: "
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   292
                << (si->general_flags.enable_not_lrw ? "yes" : "no") << endl
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   293
                << "  Current consumption: "
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   294
                << dec << si->current_on_ebus << " mA" << endl;
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   295
        }
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   296
    }
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   297
}
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   298
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   299
/****************************************************************************/
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   300
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   301
bool CommandSlaves::slaveInList(
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   302
        const ec_ioctl_slave_t &slave,
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   303
        const SlaveList &slaves
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   304
        )
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   305
{
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   306
    SlaveList::const_iterator si;
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   307
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   308
    for (si = slaves.begin(); si != slaves.end(); si++) {
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   309
        if (si->position == slave.position) {
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   310
            return true;
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   311
        }
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   312
    }
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   313
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1148
diff changeset
   314
    return false;
1142
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   315
}
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   316
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   317
/*****************************************************************************/