Ejemplo n.º 1
0
CoreControlOffliningMode::Type LpmConfigurationReaderV0::readCpuOffliningMode()
{
    string key = "CpuOffLiningMode";
    CoreControlOffliningMode::Type cpuOffliningMode;
    try
    {
        UIntN valueInt = getPolicyServices().platformConfigurationData->readConfigurationUInt32(
            root() + keyPath() + key);
        if (valueInt > CoreControlOffliningMode::Core)
        {
            postErrorMessage(PolicyMessage(FLF,
            "Invalid CoreControlOffliningMode returned (" + to_string(valueInt) + ")" +
                " - defaulting to core", Constants::Invalid));
            cpuOffliningMode = CoreControlOffliningMode::Core;
        }
        else
        {
            cpuOffliningMode = (CoreControlOffliningMode::Type)valueInt;
        }
    }
    catch(dptf_exception& e)
    {
        string msg = e.what();
        postInfoMessage(PolicyMessage(FLF,
            "No CoreControlOffliningMode returned - defaulting to core. msg - " + msg,
            Constants::Invalid));
        cpuOffliningMode = CoreControlOffliningMode::Core;
    }

    return cpuOffliningMode;
}
Ejemplo n.º 2
0
UInt32 LpmConfigurationReaderV0::readGfxTargetFrequency()
{
    string key = "GfxTargetFrequency";
    UInt32 gfxTargetFrequency;
    try
    {
        gfxTargetFrequency =
            getPolicyServices().platformConfigurationData->readConfigurationUInt32(
            root() + keyPath() + key);
    }
    catch(dptf_exception& e)
    {
        string msg = e.what();

        postErrorMessage(PolicyMessage(FLF,
            "Error in reading GfxTargetFrequency, default 100Mhz. msg - " + msg,
            Constants::Invalid));

        //
        // if not found, we default to 100 mhz,
        // which will be the lowest graphics p-state (since we round up)
        //
        gfxTargetFrequency = 100;
    }

    return gfxTargetFrequency;
}
Ejemplo n.º 3
0
void MainWindow::generateRouteReport()
{
    int     totalCost = 0;
    QString route;

    // Check a route actually exists
    if (m_route.isEmpty() || !m_routeStart || !m_routeEnd) {
        postErrorMessage("Route has not been built.");
        return;
    }

    // Seed the route with the start node
    route = m_routeStart->text();

    // Iterate over the route list updating the variables above
    QListIterator<EdgeItem*> i(m_route);
    while (i.hasNext()) {
        EdgeItem* edge = i.next();

        // Add the target to the route
        route += edge->endNode()->text();

        // Update the cost
        totalCost += edge->weight();
    }

    // Print the result
    postInfoMessage(QString("Total route cost: %1").arg(totalCost));
    postInfoMessage(QString("Route taken:      %1").arg(route));
}
Ejemplo n.º 4
0
// Network specification stuff
void MainWindow::parseAndRouteNetwork(const QString& description)
{
    // Attempt to build the graph
    int buildResult = buildNetwork(description);
    if (buildResult < 0) {
        // Error occurred; just clear everything and abort
        clearNetwork();
        return;
    }

    // Load complete, lay it out
    if ((buildResult & WarningAbort) == 0) {
        postInfoMessage("Laying out graph...");
        applySpringLayout();
        postSuccessMessage("Graph loaded successfully!");

        // Enable the UI
        m_controlsDock->enableClearNetwork(true);
        m_controlsDock->enableGraphLayoutOptions(true);

        // Extract the start and end points
        if (buildResult == Success) {
            postInfoMessage("Beginning routing step...");
            routeNetwork();

            // Enable the graph display controls and the report generator
            m_controlsDock->enableGraphDisplayOptions(true);
            m_controlsDock->enableGenerateReport(true);
        } else {
            // Make sure the route does not exist
            m_routeStart = m_routeEnd = nullptr;
            m_route.clear();

            // Disable the UI stuff that depends on the route being generated
            m_controlsDock->enableGraphDisplayOptions(false);
            m_controlsDock->enableGenerateReport(false);

            // Inform the user
            postErrorMessage("Routing skipped step due to warnings.");
        }
    }

}
Ejemplo n.º 5
0
UInt32 LpmConfigurationReaderV0::readPackagePowerLimit()
{
    // TODO: Check regarding PL -> string/uint? Do we need to sku check like 7.0?
    UInt32 packagePowerLimit;
    string key = "PackagePowerLimit";

    try
    {
        string valueString = getPolicyServices().platformConfigurationData->readConfigurationString(
            root() + keyPath() + key);
        packagePowerLimit = extractPowerLimit(valueString);
    }
    catch (dptf_exception& e)
    {
        string msg = e.what();

        postErrorMessage(PolicyMessage(FLF,
            "Error in reading PackagePowerLimit, default 10000000. msg - " + msg,
            Constants::Invalid));
        packagePowerLimit = 10000000; // Max valid power
    }

    return packagePowerLimit;
}
Ejemplo n.º 6
0
int MainWindow::buildNetwork(const QString& description)
{
    int result = Success;

    // Split into lines
    QStringList lines = description.split(QRegExp("[\\n|\\r]"),
        QString::SkipEmptyParts);
    if (lines.isEmpty()) {
        postErrorMessage("Problem specification is empty after whitespace "
            "removed!");
        return ErrorEmpty;
    }

    // Validate the length of the specification
    int nodeCount = lines[0].toInt();
    postInfoMessage(QString("Expecting %1x%1 adjacency matrix...")
        .arg(nodeCount));

    if (lines.length() != (nodeCount + 2)) {
        postErrorMessage(QString("Expecting %1 lines in specification; read %2")
            .arg(nodeCount + 2)
            .arg(lines.length()));
        return ErrorSpecTooSmall;
    }

    // Clear the existing graph and scene
    if (boost::num_vertices(m_graph) != 0) {
        postWarningMessage("Existing network already loaded; must be cleared "
            "in order to continue.");

        int response = QMessageBox::question(this, "NetRoute", "There is "
            "already a graph in the explorer; the current data will have to "
            "be discared.  Continue?");
        if (response == QMessageBox::No) {
            postErrorMessage("Aborted by user.");
            return WarningAbort;
        }

        postInfoMessage("Discarding network.");
        clearNetwork();
    }

    // Create the nodes
    postInfoMessage("Creating nodes...");
    for (int i = 0; i < nodeCount; ++i) {
        QString name = QString("%1").arg(QChar('A' + i));

        NodeItem* node = new NodeItem;
        node->setText(name);
        
        m_graphNodes[name] = node;
        
        boost::add_vertex(NodeProperties(node), m_graph);

        m_graphScene->addItem(node);
    }

    // Create the edges
    postInfoMessage("Creating edges from adjacency matrix...");
    for (int i = 0; i < nodeCount; ++i) {
        QString     line    = lines[i + 1].trimmed();
        QStringList weights = line.split(',', QString::SkipEmptyParts);

        // Sanity check
        if (weights.length() != nodeCount) {
            postErrorMessage(
                QString("Matrix row %1 has %2 columns; expecting %3.")
                    .arg(i)
                    .arg(weights.length())
                    .arg(nodeCount));
            return ErrorRowTooShort;
        }

        // Actually create the edges
        postInfoMessage(QString("Creating edges for node %1")
            .arg(QChar('A' + i)));
        DigraphVertex vStart = boost::vertex(i, m_graph);
        for (int j = 0; j < nodeCount; ++j) {
            bool ok;
            int weight = weights[j].trimmed().toInt(&ok);

            if (ok && weight >= 0) {
                DigraphVertex vEnd = boost::vertex(j, m_graph);

                // Create the new edge item
                EdgeItem* edge = new EdgeItem;
                edge->setStartNode(m_graph[vStart].item);
                edge->setEndNode(m_graph[vEnd].item);
                edge->setWeight(weight);
                m_graphScene->addItem(edge);

                // Add it to the graph
                boost::add_edge(vStart, vEnd, EdgeProperties(edge), m_graph);
            } else if (!ok) {
                postWarningMessage(QString("Weight (%1,%2) is malformed: %3.")
                    .arg(i)
                    .arg(j)
                    .arg(weights[j]));
                result |= WarningBadCell;
            }
        }
    }

    // Parse the final line of the description: the start/end nodes
    QStringList nodes = lines[lines.length() - 1].split(QRegExp("\\s+"),
        QString::SkipEmptyParts);
    if (nodes.length() != 2) {
        postWarningMessage("Start and end nodes line is malformed; "
            "routing will not take place.");
        result |= WarningBadStartEnd;
    } else {
        QString startNodeName = nodes[0];
        QString endNodeName   = nodes[1];

        m_routeStart = m_graphNodes[startNodeName];
        m_routeEnd   = m_graphNodes[endNodeName];

        if (!m_routeStart) {
            postWarningMessage(QString("Failed to find start node '%1'; "
                "routing will not take place.")
                    .arg(startNodeName));
            result |= WarningNoStartNode;
        }

        if (!m_routeEnd) {
            postWarningMessage(QString("Failed to find end node '%1'; "
                "routing will not take place.")
                    .arg(endNodeName));
            result |= WarningNoEndNode;
        }
    }

    // Graph was built successfully, even if some parsing errors arose.
    return result;
}