Skip to content

Commit

Permalink
fix: M900问题修复
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffshuai committed Dec 15, 2023
1 parent 5e9df47 commit 6eb559b
Show file tree
Hide file tree
Showing 13 changed files with 438 additions and 55 deletions.
14 changes: 14 additions & 0 deletions deepin-devicemanager-server/src/LoadInfo/ThreadPool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ void ThreadPool::initCmd()
cmdDmiSPN.canNotReplace = true;
m_ListCmd.append(cmdDmiSPN);

// 添加dmidecode -t process命令
Cmd cmdDmiPRO;
cmdDmiPRO.cmd = QString("%1 %2%3").arg("dmidecode -t processor > ").arg(PATH).arg("dmidecode_pro.txt");
cmdDmiPRO.file = "dmidecode_pro.txt";
cmdDmiPRO.canNotReplace = true;
m_ListCmd.append(cmdDmiPRO);

// 添加dmidecode -t 0命令
Cmd cmdDmi0;
cmdDmi0.cmd = QString("%1 %2%3").arg("dmidecode -t 0 > ").arg(PATH).arg("dmidecode_0.txt");
Expand Down Expand Up @@ -131,6 +138,13 @@ void ThreadPool::initCmd()
cmdDmi4.canNotReplace = true;
m_ListCmd.append(cmdDmi4);

// 添加dmidecode -t 11命令
Cmd cmdDmi11;
cmdDmi11.cmd = QString("%1 %2%3").arg("dmidecode -t 11 > ").arg(PATH).arg("dmidecode_11.txt");
cmdDmi11.file = "dmidecode_11.txt";
cmdDmi11.canNotReplace = true;
m_ListCmd.append(cmdDmi11);

// 添加dmidecode -t 13命令
Cmd cmdDmi13;
cmdDmi13.cmd = QString("%1 %2%3").arg("dmidecode -t 13 > ").arg(PATH).arg("dmidecode_13.txt");
Expand Down
2 changes: 2 additions & 0 deletions deepin-devicemanager/src/DeviceManager/DeviceMonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ void DeviceMonitor::setInfoFromEdid(const QMap<QString, QString> &mapInfo)
setAttribute(mapInfo, "Vendor", m_Vendor);
setAttribute(mapInfo, "Date", m_ProductionWeek);
setAttribute(mapInfo, "Display Input", m_DisplayInput);
setAttribute(mapInfo, "Model", m_Model);
if(m_Model.isEmpty()) m_Model = m_Name ;
getOtherMapInfo(mapInfo);
}

Expand Down
3 changes: 2 additions & 1 deletion deepin-devicemanager/src/DeviceManager/DeviceNetwork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ void DeviceNetwork::setInfoFromLshw(const QMap<QString, QString> &mapInfo)
{
if (!matchToLshw(mapInfo)
&& Common::boardVendorType() != "KLVV" && Common::boardVendorType() != "KLVU"
&& Common::boardVendorType() != "PGUW" && Common::boardVendorType() != "PGUV") {
&& Common::boardVendorType() != "PGUW" && Common::boardVendorType() != "PGUV"
&& Common::boardVendorType() != "PANGUM900" ) {
return;
}
// 设置由lshw获取的信息
Expand Down
3 changes: 3 additions & 0 deletions deepin-devicemanager/src/GenerateDevice/DeviceFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "KLUGenerator.h"
#include "PanguGenerator.h"
#include "PanguVGenerator.h"
#include "M900Generator.h"
#include "HWGenerator.h"
#include "KLVGenerator.h"
#include "commonfunction.h"
Expand Down Expand Up @@ -41,6 +42,8 @@ DeviceGenerator *DeviceFactory::getDeviceGenerator()
generator = new KLVGenerator();
else if (type == "PGUV" || type == "PGUW")
generator = new PanguVGenerator();
else if (type == "PANGUM900")
generator = new M900Generator();
else if (type == "KLVU")
generator = new KLUGenerator();
else
Expand Down
55 changes: 2 additions & 53 deletions deepin-devicemanager/src/GenerateDevice/DeviceGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "DeviceManager/DevicePrint.h"
#include "DeviceManager/DeviceInput.h"
#include "MacroDefinition.h"
#include "commontools.h"

// Dtk头文件
#include <DSysInfo>
Expand Down Expand Up @@ -86,58 +87,6 @@ void DeviceGenerator::generatorComputerDevice()
DeviceManager::instance()->addComputerDevice(device);
}

void mergeSortCpuInfoByLogicalID(QList<QMap<QString, QString> > &lsCpu, QList<QMap<QString, QString> > &tmpLst, int begin, int end)
{
// 合并列表
int left_length = (end - begin + 1) / 2;
int left_index = begin;
int right_index = begin + left_length;
int result_index = begin;

// 合并左右区间 左区间未合并结束且右区间未合并结束时
while (left_index < begin + left_length && right_index < end + 1) {
// 左右区间,哪个小先排哪个,下标加1
if (lsCpu[left_index]["processor"].toInt() <= lsCpu[right_index]["processor"].toInt())
tmpLst[result_index++] = lsCpu[left_index++];
else
tmpLst[result_index++] = lsCpu[right_index++];
}

// 合并左区间剩余数据
while (left_index < begin + left_length)
tmpLst[result_index++] = lsCpu[left_index++];

// 合并右区间剩余数据
while (right_index < end + 1)
tmpLst[result_index++] = lsCpu[right_index++];
}

void sortCpuInfoByLogicalID(QList<QMap<QString, QString> > &lsCpu, QList<QMap<QString, QString> > &tmpLst, int begin, int end)
{
// 列表个数为1,直接返回
if (0 == end - begin)
return;

// bug 后台获取CPU信息是按照物理CPU,核心,逻辑CPU顺序获取的
// 界面上展示顺序混乱实际是按照物理CPU,核心,逻辑CPU顺序展示
// 与产品沟通后,按照用户的使用感修改,CPU信息按照逻辑CPU的id从小到大显示
// 区间个数为2
if (1 == end - begin) {
// 前 processor > 后 processor 时交换位置
if (lsCpu[begin]["processor"].toInt() > lsCpu[end]["processor"].toInt()) {
QMap<QString, QString> tmpMap = lsCpu[begin];
lsCpu[begin] = lsCpu[end];
lsCpu[end] = tmpMap;
}
} else {
// 区间个数 > 2 递归
sortCpuInfoByLogicalID(lsCpu, tmpLst, begin, (end - begin) / 2 + begin);
sortCpuInfoByLogicalID(lsCpu, tmpLst, (end - begin + 1) / 2 + begin, end);
mergeSortCpuInfoByLogicalID(lsCpu, tmpLst, begin, end);
lsCpu = tmpLst;
}
}

void DeviceGenerator::generatorCpuDevice()
{
// 生成CPU
Expand All @@ -150,7 +99,7 @@ void DeviceGenerator::generatorCpuDevice()

// 按照processor id 从小到大排序
if (lsCpu.size() > 1)
sortCpuInfoByLogicalID(srcLst, tmpLst, 0, lsCpu.size() - 1);
CommonTools::sortCpuInfoByLogicalID(srcLst, tmpLst, 0, lsCpu.size() - 1);

// get info from lshw
const QList<QMap<QString, QString> > &lshwCpu = DeviceManager::instance()->cmdInfo("lshw_cpu");
Expand Down
5 changes: 4 additions & 1 deletion deepin-devicemanager/src/GenerateDevice/HWGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "DeviceManager/DeviceBluetooth.h"
#include "DeviceManager/DeviceNetwork.h"
#include "DeviceManager/DeviceMemory.h"
#include "commonfunction.h"

HWGenerator::HWGenerator()
{
Expand Down Expand Up @@ -111,7 +112,9 @@ void HWGenerator::generatorGpuDevice()
QStringList items = deviceInfo.split("\n");

QMap<QString, QString> mapInfo;
for (QString itemStr : items) {
if(Common::boardVendorType() == "PANGUM900")
mapInfo.insert("Name", "PANGU M900");
else for (QString itemStr : items) {
if (itemStr.contains(":"))
continue;
QString curItemStr = itemStr.trimmed();
Expand Down
Loading

0 comments on commit 6eb559b

Please sign in to comment.