added cpuFlags() to getStaticData(), bug fix graphics() (Win)

This commit is contained in:
Sebastian Hildebrandt
2017-07-11 11:29:56 +02:00
parent 98e8db51e5
commit f691942c44
6 changed files with 97 additions and 23 deletions
+48 -12
View File
@@ -315,24 +315,60 @@ function graphics(callback) {
// https://blogs.technet.microsoft.com/heyscriptingguy/2013/10/03/use-powershell-to-discover-multi-monitor-information/
exec("wmic path win32_VideoController get AdapterCompatibility, AdapterDACType, name, PNPDeviceID, CurrentVerticalResolution, CurrentHorizontalResolution, CurrentNumberOfColors, AdapterRAM, CurrentBitsPerPixel, CurrentRefreshRate, MinRefreshRate, MaxRefreshRate /value", function (error, stdout) {
if (!error) {
let lines = stdout.split('\r\n');
result.controllers.push({});
result.displays.push({});
result.controllers[0].model = getValue(lines, 'name', '=');
result.controllers[0].vendor = getValue(lines, 'AdapterCompatibility', '=');
result.controllers[0].bus = getValue(lines, 'PNPDeviceID', '=').startsWith('PCI') ? 'PCI' : '';
result.controllers[0].vram = getValue(lines, 'AdapterRAM', '=');
result.displays[0].resolutionx = getValue(lines, 'CurrentHorizontalResolution', '=');
result.displays[0].resolutiony = getValue(lines, 'CurrentVerticalResolution', '=');
result.displays[0].depth = getValue(lines, 'CurrentBitsPerPixel', '=');
let csections = stdout.split(/\n\s*\n/);
result.controllers = parseLinesWindowsControllers(csections);
exec("wmic path win32_desktopmonitor get MonitorManufacturer, ScreenWidth, ScreenHeight /value", function (error, stdout) {
let dsections = stdout.split(/\n\s*\n/);
if (!error) {
result.displays = parseLinesWindowsDisplays(dsections);
}
if (callback) {
callback(result)
}
resolve(result);
})
}
resolve(result);
})
}
});
});
function parseLinesWindowsControllers(sections){
let controllers = [];
for (let i in sections) {
if (sections.hasOwnProperty(i)) {
if (sections[i].trim() !== "") {
let lines = sections[i].trim().split('\r\n');
controllers.push({
model: getValue(lines, 'name', '='),
vendor: getValue(lines, 'AdapterCompatibility', '='),
bus: getValue(lines, 'PNPDeviceID', '=').startsWith('PCI') ? 'PCI' : '',
vram: getValue(lines, 'AdapterRAM', '=')
});
}
}
}
return controllers;
}
function parseLinesWindowsDisplays(sections){
let displays = [];
for (let i in sections) {
if (sections.hasOwnProperty(i)) {
if (sections[i].trim() !== "") {
let lines = sections[i].trim().split('\r\n');
displays.push({
model: getValue(lines, 'MonitorManufacturer', '='),
resolutionx: getValue(lines, 'ScreenWidth', '='),
resolutiony: getValue(lines, 'ScreenHeight', '=')
});
}
}
}
return displays;
}
}
exports.graphics = graphics;
+13 -10
View File
@@ -138,16 +138,19 @@ function getStaticData(callback) {
data.versions = res;
cpu.cpu().then(res => {
data.cpu = res;
graphics.graphics().then(res => {
data.graphics = res;
network.networkInterfaces().then(res => {
data.net = res;
mem.memLayout().then(res => {
data.memLayout = res;
filesystem.diskLayout().then(res => {
data.diskLayout = res;
if (callback) { callback(data) }
resolve(data);
cpu.cpuFlags().then(res => {
data.cpu.flags = res;
graphics.graphics().then(res => {
data.graphics = res;
network.networkInterfaces().then(res => {
data.net = res;
mem.memLayout().then(res => {
data.memLayout = res;
filesystem.diskLayout().then(res => {
data.diskLayout = res;
if (callback) { callback(data) }
resolve(data);
})
})
})
})