コード例 #1
0
void SocketController::getWifiConfiguration()
{
    if (!connectionLost)
    {
        ssidTextInput->setProperty("text", getParamInfo("Ssid"));
        frequencyRangeComboBox->setProperty("currentIndex",
                                            findIndexByValue(frequencyRangeModel, frequencyRangeCount, //"2.4"));
                                                             getParamInfo("FrequencyRange")));
        wifiStatusServerValue = getParamInfo("WifiStatus");
        wifiStatusComboBox->setProperty("currentIndex",
                                        findIndexByValue(wifiStatusNameList, wifiStatusCount,
                                                         wifiStatusServerValue));
    }
}
コード例 #2
0
void SocketController::getPortStatusCountersList()
{
    if (!connectionLost)
    {
        QMetaObject::invokeMethod(portStatusCountersModel, "clear");
        QVariant retValue;
        //QString data = "1        0              0               0            0              0               0 \n2        0              0               0            0              0               0 \n3        0              0               0            0              0               0 \n4         0              0               0            0              0               0  \n5         0              0               0            0              0               0  \n6         0              0               0            0              0               0  \n7         0              0               0            0              0               0  \n8         0              0               0            0              0               0  \n";
        QString data = getParamInfo("PortStatusCountersList");

        if(data == emptyString)
        {
            logOutSignal();
            return;
        }

        PortStatusCountersParser* parser = new PortStatusCountersParser();
        PortStatusCountParseResult result;
        result = parser->parsePortStatusCountData(data);
        int portsCount = result.params[0].length();

        for(int i = 0; i < portsCount; i++)
        {
            QMetaObject::invokeMethod(portStatusCountersModel, "addPortStatusCounter",
                                      Q_RETURN_ARG(QVariant, retValue),
                                      Q_ARG(QVariant, result.params[result.columnIndexes["port"]].at(i)),
                    Q_ARG(QVariant, result.params[result.columnIndexes["rx_packets_count"]].at(i)),
                    Q_ARG(QVariant, result.params[result.columnIndexes["rx_bytes_count"]].at(i)),
                    Q_ARG(QVariant, result.params[result.columnIndexes["error_count"]].at(i)),
                    Q_ARG(QVariant, result.params[result.columnIndexes["tx_packets_count"]].at(i)),
                    Q_ARG(QVariant, result.params[result.columnIndexes["tx_bytes_count"]].at(i)),
                    Q_ARG(QVariant, result.params[result.columnIndexes["collisions"]].at(i)));
        }
    }
}
コード例 #3
0
ファイル: CFGManager.cpp プロジェクト: EwaldHartmann/mars
 const cfgParamInfo CFGManager::getParamInfo(const string &_group,
                                             const string &_name) const {
   utils::MutexLocker locker(&mutexCFGParams);
   CFGParam *param = NULL;
   getParam(&param, _group, _name);
   return getParamInfo(param);
 }
コード例 #4
0
int ConfigManager::setParamValue(int fd, int id, int value)
{
    calibration::CameraParam* info = getParamInfo(id);

    if(!info)
    {
        ROS_FATAL("Could not find param with ID %d", id);
        return -1;
    }

    v4l2_control ctrl;
    memset(&ctrl, 0, sizeof(ctrl));
    ctrl.id = info->id;
    ctrl.value = value;

    if(ioctl(fd, VIDIOC_S_CTRL, &ctrl) != 0)
    {
        ROS_FATAL("Could not set control '%s' (id 0x%X): %s",
                  info->label.c_str(), info->id, strerror(errno)
                 );
        return -1;
    }

    info->value = value;
    m_writePending = true;

    return 0;
}
コード例 #5
0
void SocketController::getPortStatusList()
{
    if (!connectionLost)
    {
        QMetaObject::invokeMethod(portStatusModel, "clear");
        QVariant retValue;
        //QString data = "1         Down              -               -            - \n2         Down              -               -            - \n3         Down              -               -            -   \n4         up              100M               Full            Off \n";
        QString data = getParamInfo("PortStatusList");

        if(data == emptyString)
        {
            logOutSignal();
            return;
        }

        PortStatusDataParser* parser = new PortStatusDataParser();
        PortStatusParseResult result;
        result = parser->parsePortStatusData(data);
        int portsCount = result.params[0].length();

        for(int i = 0; i < portsCount; i++)
        {
            QMetaObject::invokeMethod(portStatusModel, "addPortStatus",
                                      Q_RETURN_ARG(QVariant, retValue),
                                      Q_ARG(QVariant, result.params[result.columnIndexes["port"]].at(i)),
                    Q_ARG(QVariant, result.params[result.columnIndexes["link"]].at(i)),
                    Q_ARG(QVariant, result.params[result.columnIndexes["speed"]].at(i)),
                    Q_ARG(QVariant, result.params[result.columnIndexes["duplex"]].at(i)),
                    Q_ARG(QVariant, result.params[result.columnIndexes["flow_control"]].at(i)));
        }
    }
}
コード例 #6
0
ファイル: CFGManager.cpp プロジェクト: EwaldHartmann/mars
    bool CFGManager::getAllParams(vector<cfgParamInfo> *allParams) const {
      mapIdToParam::const_iterator iterId = cfgParamsById.begin();

      for(; iterId != cfgParamsById.end(); iterId++) {
        allParams->push_back(getParamInfo(iterId->first));
      }
      return true;
    }
コード例 #7
0
int ConfigManager::getParamValue(int id, int* value)
{
    calibration::CameraParam* info = getParamInfo(id);

    if(!info)
    {
        ROS_FATAL("Could not find param with ID %d", id);
        return -1;
    }

    *value = info->value;
    return 0;
}
コード例 #8
0
int ConfigManager::getParamValue(const std::string& name, int* value)
{
    calibration::CameraParam* info = getParamInfo(name);

    if(!info)
    {
        ROS_FATAL("Could not find param '%s'", name.c_str());
        return -1;
    }

    *value = info->value;
    return 0;
}
コード例 #9
0
void SocketController::getPortSetupList()
{
    if (!connectionLost)
    {
        QMetaObject::invokeMethod(portSetupModel, "clear");
        QVariant retValue;
        //QString data = "1        Auto              On               On            Normal              -               \n2        Auto              On               On            Normal              -               \n3        Auto              On               On            Normal              -               \n4        Auto              On               On            Normal              -               \n5        Auto              On               On            Normal              -               \n6        Auto              On               On            Normal              -               \n7        Auto              On               On            Normal              -               \n8        Auto              On               On            Normal              -               \n";
        QString data = getParamInfo("PortSetupDataList");

        if(data == emptyString)
        {
            logOutSignal();
            return;
        }

        PortSetupDataParser* parser = new PortSetupDataParser();
        PortSetupParseResult result;
        result = parser->parsePortSetupData(data);
        int portsCount = result.params[0].length();

        for(int i = 0; i < portsCount; i++)
        {
            int modeIndex  = findIndexByValue(portSetupModeNameList,
                                              portSetupModeCount,
                                              result.params[result.columnIndexes["mode"]].at(i));
            int flowControlIndex = findIndexByValue(portSetupFlowControlNameList,
                                                    portSetupFlowControlCount,
                                                    result.params[result.columnIndexes["flow_control"]].at(i));
            int priority802Index = findIndexByValue(priority802NameList,
                                                    priority802Count,
                                                    result.params[result.columnIndexes["priority802"]].at(i));
            int portBasePriorityIndex = findIndexByValue(portBasePriorityNameList,
                                                         portBasePriorityCount,
                                                         result.params[result.columnIndexes["port_base_priority"]].at(i));
            QMetaObject::invokeMethod(portSetupModel, "addPortSetupData",
                                      Q_RETURN_ARG(QVariant, retValue),
                                      Q_ARG(QVariant, result.params[result.columnIndexes["port"]].at(i)),
                    Q_ARG(QVariant, modeIndex),
                    Q_ARG(QVariant, flowControlIndex),
                    Q_ARG(QVariant, priority802Index),
                    Q_ARG(QVariant, portBasePriorityIndex),
                    Q_ARG(QVariant, result.params[result.columnIndexes["port_description"]].at(i)));
        }
    }
}
コード例 #10
0
void SocketController::getPortTrunkSetup()
{
    if (!connectionLost)
    {
        portTrunkStatusServerValue = getParamInfo("PortTrunkStatus");

        if (portTrunkStatusServerValue == emptyString)
        {
            logOutSignal();
            return;
        }

        //portTrunkStatusServerValue = "On";
        portTrunkStatusComboBox->setProperty("currentIndex",
                                             findIndexByValue(portTrunkStatusNameList, portTrunkStatusCount,
                                                              portTrunkStatusServerValue));
    }
}
コード例 #11
0
ファイル: filecommon.cpp プロジェクト: WarmongeR1/QSopherim
//------------------------------------------------------------------------------
QStringList getInfoFromFile(QString file_path)
{
    QStringList list;
    if(QFile::exists(file_path))
    {
        QString encoding = getEncodingFromFile(file_path);
        QFile file(file_path);
        QString str;
        QString info[7];
        if(file.open(QIODevice::ReadOnly))
        {
            QTextStream stream(&file);
            stream.setCodec(getCodecOfEncoding(encoding));
            do
            {
                str = stream.readLine();
                if (str.indexOf("<meta name=\"Author\"") != -1)
                    info[0] = getParamInfo(&str, "Author");
                if (str.indexOf("<meta name=\"Revision\"") != -1)
                    info[1] = getParamInfo(&str, "Revision");
                if (str.indexOf("<meta name=\"Language\"") != -1)
                    info[2] = getParamInfo(&str, "Language");
                if (str.indexOf("<meta name=\"Type\"") != -1)
                    info[3] = getParamInfo(&str, "Type");
                if (str.indexOf("<meta name=\"Description\"") != -1)
                    info[4] = getParamInfo(&str, "Description");
                if (str.indexOf("<meta name=\"Rights\"") != -1)
                    info[5] = getParamInfo(&str, "Rights");
                if (str.indexOf("<meta name=\"Numbering\"") != -1)
                    info[6] = getParamInfo(&str, "Numbering");
            } while(!stream.atEnd());
            file.close();

            for (int i = 0; i < 7; i++)
            {
                list << info[i];
            }
        }
        else
        {
            qDebug() << "Error: not open file for read(get info from file):"
                     << file_path;
        }
    }

    return list;
}
コード例 #12
0
void SocketController::getGeneralConfigData()
{
    if (!connectionLost)
    {
        configHostAddressTextInput->setProperty("text", hostAddressTextInput->property("text").toString());
        networkMaskTextInput->setProperty("text", getParamInfo("NetworkMask"));
        macAddressTextInput->setProperty("text", getParamInfo("MacAddress"));
        modelTextInput->setProperty("text", getParamInfo("Model"));
        swVersionTextInput->setProperty("text", getParamInfo("SwVersion"));
        managementVlanServerValue = getParamInfo("ManagementVlan");
        managementVlanComboBox->setProperty("currentIndex",
                                            findIndexByValue(managementVlanModel, managementVlanCount,
                                                             managementVlanServerValue));
        broadcastStormServerValue = getParamInfo("BroadcastStormControl");
        broadcastStormComboBox->setProperty("currentIndex",
                                            findIndexByValue(broadcastStormNameList, broadcastStormCount,
                                                             broadcastStormServerValue));
        gatewayTextInput->setProperty("text", getParamInfo("Gateway"));
        systemDescriptionTextInput->setProperty("text", getParamInfo("SystemDescription"));
    }
}
コード例 #13
0
void SocketController::getInfoAboutWifiConnections()
{
    if(!connectionLost)
    {
        QMetaObject::invokeMethod(wifiConnectionsModel, "clear");
        QVariant retValue;
        //QString data = "*  SSID             MODE   CHAN  RATE       SIGNAL  BARS  SECURITY \n   Promwad Devices  Infra  1     54 Mbit/s  100     ▂▄▆█  WPA2     \n   Promwad Guest    Infra  1     54 Mbit/s  100     ▂▄▆█  WPA2     \n   Promwad Test     Infra  1     54 Mbit/s  100     ▂▄▆█  WPA2     \n   AP-lo1-10        Infra  1     54 Mbit/s  65      ▂▄▆_  WPA2     \n";
        //QString data = "DEVICE  TYPE      STATE        CONNECTION \neth0   ethernet      notconnected    Wired Connection 0    \nwlan0   wifi      connected    eduroam    \neth1    ethernet  unavailable  --         \nlo      loopback  unmanaged    --         \n";
        //QString data = "DEVICE  TYPE      STATE        CONNECTION \nwlan0   wifi      connected    eduroam    \neth0    ethernet  unavailable  --         \nlo      loopback  unmanaged    --         \n";
        //QString data = "  SSID             MODE   CHAN  RATE       SIGNAL  BARS  SECURITY  \n    Promwad  Infra  1     54 Mbit/s 100     ▂▄▆█  WPA2     \n   *         Promwad Guest    Infra  1     54 Mbit/s  100     ▂▄▆█  WPA2     \n *  Promwad Test     Infra  1     54 Mbit/s  100     ▂▄▆█  WPA2      \n   AP-lo1-10        Infra  1     54 Mbit/s  65      ▂▄▆_  WPA2";
        QString data = getParamInfo("WifiConnections");

        if(data == emptyString)
        {
            logOutSignal();
            return;
        }

        WifiDataParser* parser = new WifiDataParser();
        WifiInfoParseResult result;
        result = parser->parseWifiConnectionsInfo(data);
        QVariant varParams;
        varParams.setValue<QList<int>>(result.connectedIndexes);
        QMetaObject::invokeMethod(availableWifiSubtab, "addWifiConnectedIndexes",
                                  Q_RETURN_ARG(QVariant, retValue),
                                  Q_ARG(QVariant, varParams));
        int networksCount = result.params[0].length();

        for(int i = 0; i < networksCount; i++)
        {
            bool isConnected = result.connectedIndexes.contains(i);
            QMetaObject::invokeMethod(wifiConnectionsModel, "addWifiConnection",
                                      Q_RETURN_ARG(QVariant, retValue),
                                      Q_ARG(QVariant, result.params[result.columnIndexes["ssid"]].at(i)),
                    Q_ARG(QVariant, isConnected),
                    Q_ARG(QVariant, result.params[result.columnIndexes["rate"]].at(i)),
                    Q_ARG(QVariant, result.params[result.columnIndexes["bars"]].at(i)),
                    Q_ARG(QVariant, result.params[result.columnIndexes["security"]].at(i)));
        }
    }
}
コード例 #14
0
void SocketController::getValuesFromServer()
{
    connectionLost = false;
    getGeneralConfigData();
    getWifiConfiguration();

    accountSettingsLoginTextInput->setProperty("text", getLogin());

    getPortTrunkSetup();
    getVlanSettings();

    corporationInfoText->setProperty("text", getParamInfo("CorporationInfo"));

    getInfoAboutWifiConnections();
    getPortStatusList();
    getPortStatusCountersList();
    getPortSetupList();
    getPoeSetupList();

    if (connectionLost)
        sendErrorMessage(QT_TR_NOOP("connection_lost"));
}
コード例 #15
0
void SocketController::getPoeSetupList()
{
    if (!connectionLost)
    {
        QMetaObject::invokeMethod(poeSetupModel, "clear");
        QVariant retValue;
        //QString data = "1        On              0               0            15,4              0               \n2       On              0               0            15,4              0              \n3        On              0               0            15,4              0              \n4       On              0               0            15,4              0              \n5       On              0               0            15,4              0               \n6       On              0               0            15,4              0                \n7       On              0               0            15,4              0               \n8        On              0               0            15,4              0              \n";
        QString data = getParamInfo("PoeSetupDataList");
        PoeSetupDataParser* parser = new PoeSetupDataParser();

        if(data == emptyString)
        {
            logOutSignal();
            return;
        }

        PoeSetupParseResult result;
        result = parser->parsePoeSetupData(data);
        int portsCount = result.params[0].length();

        for(int i = 0; i < portsCount; i++)
        {
            int statusIndex  = findIndexByValue(poeSetupStatusNameList,
                                                poeSetupStatusCount,
                                                result.params[result.columnIndexes["status"]].at(i));
            int priorityIndex = findIndexByValue(poeSetupPriorityNameList,
                                                 poeSetupPriorityCount,
                                                 result.params[result.columnIndexes["priority"]].at(i));
            QMetaObject::invokeMethod(poeSetupModel, "addPoeSetupData",
                                      Q_RETURN_ARG(QVariant, retValue),
                                      Q_ARG(QVariant, result.params[result.columnIndexes["port"]].at(i)),
                    Q_ARG(QVariant, statusIndex),
                    Q_ARG(QVariant, result.params[result.columnIndexes["delivering_power"]].at(i)),
                    Q_ARG(QVariant, result.params[result.columnIndexes["current_ma"]].at(i)),
                    Q_ARG(QVariant, result.params[result.columnIndexes["power_limit_w"]].at(i)),
                    Q_ARG(QVariant, priorityIndex));
        }
    }
}
コード例 #16
0
int ConfigManager::readConfigFile(int fd, std::istream* stream)
{
    YAML::Parser p;
    YAML::Node doc;
    int ret = 0;
    std::vector<v4l2_ext_control> controls;

    try
    {
        p.Load(*stream);
    }
    catch(YAML::Exception& e)
    {
        ROS_FATAL("Could not parse config file: %s", e.what());
        return -1;
    }

    if(!p.GetNextDocument(doc))
    {
        ROS_FATAL("Could not get YAML document");
        return -1;
    }

    for(YAML::Iterator it = doc.begin(); it != doc.end(); ++it)
    {
        std::string key, value;

        try
        {
            (*it).begin().first() >> key;
            (*it).begin().second() >> value;
        }
        catch(YAML::Exception& e)
        {
            ROS_FATAL("Invalid parameter specification: %s", e.what());
            return -1;
        }

        int ivalue = -1;
        calibration::CameraParam* info = getParamInfo(key);
        if(!info)
        {
            ROS_FATAL("Unknown parameter '%s' in config file, ignoring...", key.c_str());
            continue;
        }

        ivalue = atoi(value.c_str());

        info->value = ivalue;
        v4l2_ext_control control;
        memset(&control, 0, sizeof(control));
        control.id = info->id;
        control.value = ivalue;

        controls.push_back(control);
    }

    v4l2_ext_controls request;
    memset(&request, 0, sizeof(request));
    request.controls = &controls[0];
    request.count = controls.size();
    request.ctrl_class = V4L2_CTRL_CLASS_USER;

    if(ioctl(fd, VIDIOC_S_EXT_CTRLS, &request) != 0)
    {
        ROS_FATAL("Control setting failed. This may have happened at control 0x%X with value %d",
                  controls[request.error_idx].id,
                  controls[request.error_idx].value
                 );
        return -1;
    }
    ROS_INFO("Controls set successfully from config file");

    return ret;
}
コード例 #17
0
void SocketController::getVlanSettings()
{
    if (!connectionLost)
    {
        vlanSubtab->setProperty("init", true);
        vlanTabId->setProperty("init", true);
        //QString vlanType =  "portBased";//"802.1q";//
        QString vlanType = getParamInfo("VlanType");

        if(vlanType == emptyString)
        {
            logOutSignal();
            return;
        }

        vlanTypeComboBox->setProperty("currentIndex",
                                      findIndexByValue(vlanTypeList, vlanTypeCount,
                                                       vlanType));

        if(vlanType != "noVlan")
        {
            //portCount = 8;
            QString portCountStr = getParamInfo("PortCount");

            if(portCountStr == emptyString)
            {
                logOutSignal();
                return;
            }

            portCount = portCountStr.toInt();

            QVariant retValue;
            QMetaObject::invokeMethod(vlanCurrentModel, "init",
                                      Q_RETURN_ARG(QVariant, retValue),
                                      Q_ARG(QVariant, portCount),
                                      Q_ARG(QVariant, vlanCount));

            portRepeater->setProperty("model", portCount);

            QMetaObject::invokeMethod(vlanCurrentModel, "deleteAllChecks",
                                      Q_RETURN_ARG(QVariant, retValue));

            VlanSettingsParser* parser = new VlanSettingsParser();


            QString portVlanData = getParamInfo("VlanSettings");
            // QString portVlanData = "1 1\n2 1\n3 1\n1 3\n4 2\n5 2\n6 2\n7 3\n8 3\n";//

            if(portVlanData == emptyString)
            {
                logOutSignal();
                return;
            }

            QList<QPair<int, int>> portVlanDataResult = parser->parsePortVlanData(portVlanData);

            for (int i = 0; i < portVlanDataResult.count(); i++)
            {
                QPair<int, int> portVlanPair = portVlanDataResult.at(i);
                QMetaObject::invokeMethod(vlanCurrentModel, "addPortVlanEnabled",
                                          Q_RETURN_ARG(QVariant, retValue),
                                          Q_ARG(QVariant, portVlanPair.first),
                                          Q_ARG(QVariant, portVlanPair.second));
            }

            //QString portPvidData = "1 1\n2 2\n3 3\n4 4\n5 5\n6 6\n7 7\n8 8\n"; //
            QString portPvidData = getParamInfo("PortsPvid");

            if(portPvidData == emptyString)
            {
                logOutSignal();
                return;
            }

            QMap<int, int> portPvidDataResult = parser->parsePortPvidData(portPvidData);

            for(int port = 1; port <= portCount; port++)
            {
                QMetaObject::invokeMethod(vlanCurrentModel, "setPortPvid",
                                          Q_RETURN_ARG(QVariant, retValue),
                                          Q_ARG(QVariant, port),
                                          Q_ARG(QVariant, portPvidDataResult[port]));
            }

            if (vlanType == "802.1q")
            {
                //QString portTaggingData = "1 On\n2 Off\n3 On\n4 On\n5 On\n6 On\n7 On\n8 On\n";//
                QString portTaggingData = getParamInfo("PortsTaggingStatus");

                if(portTaggingData == emptyString)
                {

                    logOutSignal();
                    return;
                }

                QMap<int, QString> portTaggingDataResult = parser->parsePortTaggingData(portTaggingData);

                for(int port = 1; port <= portCount; port++)
                {
                    QMetaObject::invokeMethod(vlanCurrentModel, "setPortTaggingStatus",
                                              Q_RETURN_ARG(QVariant, retValue),
                                              Q_ARG(QVariant, port),
                                              Q_ARG(QVariant, findIndexByValue(portTaggingStatusList,
                                                                               portTaggingStatusCount,
                                                                               portTaggingDataResult[port])));
                }
            }
        }

        vlanSubtab->setProperty("init", false);
        vlanTabId->setProperty("init", false);
    }
}
コード例 #18
0
ファイル: CFGManager.cpp プロジェクト: EwaldHartmann/mars
 const cfgParamInfo CFGManager::getParamInfo(const cfgParamId &_id) const {
   utils::MutexLocker locker(&mutexCFGParams);
   CFGParam *param = NULL;
   getParam(&param, _id);
   return getParamInfo(param);
 }