-
Notifications
You must be signed in to change notification settings - Fork 40
Feat: [cpu] Add max boost clock item on special cpu type. #580
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat: [cpu] Add max boost clock item on special cpu type. #580
Conversation
-- Add max boost clock item on special cpu type. Log: add feature Task: https://pms.uniontech.com/task-view-384577.html
deepin pr auto review我来对这段代码进行审查:
enum SpecialCpuType {
kUnknownCpuType = 0, // "Unknow"拼写错误,应为"Unknown"
kSpecialCpuType1 // 建议使用更具描述性的名称,如kTurboBoostCpuType
};
static const bool IS_SPECIAL_CPU_TYPE = (Common::curCpuType == Common::kSpecialCpuType1);
if (dconfig->keyList().contains("specialCpuType")) {
bool ok;
int value = dconfig->value("specialCpuType").toInt(&ok);
if (ok) {
Common::curCpuType = static_cast<Common::SpecialCpuType>(value);
}
}
总体来说,代码实现合理,但需要在细节处理上进一步完善,特别是在错误处理和命名规范方面。 |
Reviewer's GuideAdds support for a configurable special CPU type so that, for a specific CPU type, the device manager reads and displays a Max Boost Clock value obtained from dmidecode, wiring the configuration through DConfig into the CPU view model and table rendering. Sequence diagram for configuring specialCpuType and displaying Max Boost ClocksequenceDiagram
actor User
participant AppMain
participant DConfig
participant Common
participant DeviceCpu
User ->> AppMain: startApplication()
AppMain ->> DConfig: create(org.deepin.devicemanager)
AppMain ->> DConfig: isValid()
alt DConfig valid
AppMain ->> DConfig: keyList()
AppMain ->> DConfig: value(specialCpuType)
AppMain ->> Common: set curCpuType(static_cast SpecialCpuType)
end
AppMain ->> DeviceCpu: createAndInit()
AppMain ->> DeviceCpu: setInfoFromDmidecode(mapInfo)
DeviceCpu ->> Common: read curCpuType
alt curCpuType == kSpecialCpuType1
DeviceCpu ->> DeviceCpu: setAttribute(mapInfo, Max Speed, m_MaxBoostClock)
end
AppMain ->> DeviceCpu: loadTableHeader()
DeviceCpu ->> Common: read curCpuType
alt curCpuType == kSpecialCpuType1
DeviceCpu ->> DeviceCpu: append Max Boost Clock to m_TableHeader
end
AppMain ->> DeviceCpu: loadTableData()
DeviceCpu ->> Common: read curCpuType
alt curCpuType == kSpecialCpuType1
DeviceCpu ->> DeviceCpu: append m_MaxBoostClock to m_TableData
end
Class diagram for Common and DeviceCpu CPU type and Max Boost Clock supportclassDiagram
class Common {
<<utility>>
+static int specialComType
+static SpecialCpuType curCpuType
+static QString getArch()
+static QString getArchStore()
+static QByteArray executeClientCmd(QString cmd, QStringList args, QString workPath, int msecsWaiting)
}
class SpecialType {
<<enumeration>>
kSpecialType1
kSpecialType2
kSpecialType3
kSpecialType4
kSpecialType5
kSpecialType6
kSpecialType7
kCustomType
}
class SpecialCpuType {
<<enumeration>>
kUnknowCpuType = 0
kSpecialCpuType1
}
class DeviceCpu {
+void setInfoFromDmidecode(QMap~QString, QString~ mapInfo)
+void loadTableHeader()
+void loadTableData()
-QString m_Name
-QString m_Vendor
-QString m_Frequency
-QString m_Architecture
-bool m_FrequencyIsCur
-QMap~int, QString~ m_trNumber
-QString m_MaxBoostClock
}
class QString
class QMap
Common --> SpecialCpuType : uses
Common --> SpecialType : uses
DeviceCpu --> Common : reads curCpuType
DeviceCpu --> QString : uses
DeviceCpu --> QMap : uses
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey there - I've reviewed your changes - here's some feedback:
- When reading
specialCpuTypefrom DConfig, consider validating or clamping the integer value beforestatic_casttoCommon::SpecialCpuTypeso that unexpected config values don’t silently map to an unintended enum case. - In
main.cppthe DConfig key lookup callsdconfig->keyList()three times; caching the key list (or using a helper to query keys) would make the logic cheaper and easier to extend as more keys are added.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- When reading `specialCpuType` from DConfig, consider validating or clamping the integer value before `static_cast` to `Common::SpecialCpuType` so that unexpected config values don’t silently map to an unintended enum case.
- In `main.cpp` the DConfig key lookup calls `dconfig->keyList()` three times; caching the key list (or using a helper to query keys) would make the logic cheaper and easier to extend as more keys are added.
## Individual Comments
### Comment 1
<location> `deepin-devicemanager/src/commonfunction.h:32` </location>
<code_context>
};
+
+ enum SpecialCpuType {
+ kUnknowCpuType = 0,
+ kSpecialCpuType1
+ };
</code_context>
<issue_to_address>
**issue (typo):** Fix the spelling of `kUnknowCpuType` to `kUnknownCpuType` for clarity.
If you rename this enum value, make sure all references are updated consistently, including the initialization in `commonfunction.cpp`.
Suggested implementation:
```c
enum SpecialCpuType {
kUnknownCpuType = 0,
kSpecialCpuType1
};
```
You should also:
1. Search in `deepin-devicemanager/src` (especially `commonfunction.cpp`) for all occurrences of `kUnknowCpuType` and rename them to `kUnknownCpuType`.
2. Rebuild to ensure there are no remaining references to the old identifier.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| }; | ||
|
|
||
| enum SpecialCpuType { | ||
| kUnknowCpuType = 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (typo): Fix the spelling of kUnknowCpuType to kUnknownCpuType for clarity.
If you rename this enum value, make sure all references are updated consistently, including the initialization in commonfunction.cpp.
Suggested implementation:
enum SpecialCpuType {
kUnknownCpuType = 0,
kSpecialCpuType1
};You should also:
- Search in
deepin-devicemanager/src(especiallycommonfunction.cpp) for all occurrences ofkUnknowCpuTypeand rename them tokUnknownCpuType. - Rebuild to ensure there are no remaining references to the old identifier.
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: GongHeng2017, max-lvs The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
/forcemerge |
|
This pr force merged! (status: unstable) |
6924401
into
linuxdeepin:develop/eagle
-- Add max boost clock item on special cpu type.
Log: add feature
Task: https://pms.uniontech.com/task-view-384577.html
Summary by Sourcery
Add support for special CPU types and display their maximum boost clock in the device manager UI.
New Features:
Enhancements: