battery() improved detection (additional batteries windows)
This commit is contained in:
parent
b120e27c72
commit
ac828716f7
@ -77,6 +77,7 @@ For major (breaking) changes - **version 4, 3 and 2** - see end of page.
|
|||||||
|
|
||||||
| Version | Date | Comment |
|
| Version | Date | Comment |
|
||||||
| -------------- | -------------- | -------- |
|
| -------------- | -------------- | -------- |
|
||||||
|
| 5.7.6 | 2021-06-09 | `battery()` improved detection (additional batteries windows) |
|
||||||
| 5.7.5 | 2021-06-08 | `memLayout()` improved clock speed detection (windows) |
|
| 5.7.5 | 2021-06-08 | `memLayout()` improved clock speed detection (windows) |
|
||||||
| 5.7.4 | 2021-05-27 | `osInfo()`, `cpu()` improved hypervisor, virtualization detection (windows) |
|
| 5.7.4 | 2021-05-27 | `osInfo()`, `cpu()` improved hypervisor, virtualization detection (windows) |
|
||||||
| 5.7.3 | 2021-05-26 | `osInfo()` improved UEFI detection (windows) |
|
| 5.7.3 | 2021-05-26 | `osInfo()` improved UEFI detection (windows) |
|
||||||
|
|||||||
@ -226,6 +226,16 @@
|
|||||||
<td></td>
|
<td></td>
|
||||||
<td>battery serial</td>
|
<td>battery serial</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td></td>
|
||||||
|
<td>additionalBatteries[]</td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
<td>X</td>
|
||||||
|
<td></td>
|
||||||
|
<td>array of additional batteries</td>
|
||||||
|
</tr>
|
||||||
<tr class="example">
|
<tr class="example">
|
||||||
<td></td>
|
<td></td>
|
||||||
<td colspan="7">
|
<td colspan="7">
|
||||||
|
|||||||
@ -56,6 +56,11 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<th scope="row">5.7.6</th>
|
||||||
|
<td>2021-06-09</td>
|
||||||
|
<td><span class="code">battery()</span> improved detection (additional batteries windows)</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">5.7.5</th>
|
<th scope="row">5.7.5</th>
|
||||||
<td>2021-06-08</td>
|
<td>2021-06-08</td>
|
||||||
|
|||||||
@ -170,7 +170,7 @@
|
|||||||
<img class="logo" src="assets/logo.png">
|
<img class="logo" src="assets/logo.png">
|
||||||
<div class="title">systeminformation</div>
|
<div class="title">systeminformation</div>
|
||||||
<div class="subtitle"><span id="typed"></span> </div>
|
<div class="subtitle"><span id="typed"></span> </div>
|
||||||
<div class="version">New Version: <span id="version">5.7.5</span></div>
|
<div class="version">New Version: <span id="version">5.7.6</span></div>
|
||||||
<button class="btn btn-light" onclick="location.href='https://github.com/sebhildebrandt/systeminformation'">View on Github <i class=" fab fa-github"></i></button>
|
<button class="btn btn-light" onclick="location.href='https://github.com/sebhildebrandt/systeminformation'">View on Github <i class=" fab fa-github"></i></button>
|
||||||
</div>
|
</div>
|
||||||
<div class="down">
|
<div class="down">
|
||||||
|
|||||||
@ -41,7 +41,7 @@ function parseWinBatteryPart(lines, designCapacity, fullChargeCapacity) {
|
|||||||
// 9 = "Charging Critical"
|
// 9 = "Charging Critical"
|
||||||
// 10 = "Undefined"
|
// 10 = "Undefined"
|
||||||
// 11 = "Partially Charged"
|
// 11 = "Partially Charged"
|
||||||
if (lines.join('').toLowerCase().indexOf('BatteryStatus') >= 0) {
|
if (status >= 0) {
|
||||||
const statusValue = status ? parseInt(status) : 0;
|
const statusValue = status ? parseInt(status) : 0;
|
||||||
result.status = statusValue;
|
result.status = statusValue;
|
||||||
result.hasBattery = true;
|
result.hasBattery = true;
|
||||||
@ -50,7 +50,7 @@ function parseWinBatteryPart(lines, designCapacity, fullChargeCapacity) {
|
|||||||
result.voltage = parseInt(util.getValue(lines, 'DesignVoltage', '=') || 0) / 1000.0;
|
result.voltage = parseInt(util.getValue(lines, 'DesignVoltage', '=') || 0) / 1000.0;
|
||||||
result.capacityUnit = 'mWh';
|
result.capacityUnit = 'mWh';
|
||||||
result.percent = parseInt(util.getValue(lines, 'EstimatedChargeRemaining', '=') || 0);
|
result.percent = parseInt(util.getValue(lines, 'EstimatedChargeRemaining', '=') || 0);
|
||||||
result.currentCapacity = parseInt(result.maxcapacity * result.percent / 100);
|
result.currentCapacity = parseInt(result.maxCapacity * result.percent / 100);
|
||||||
result.isCharging = (statusValue >= 6 && statusValue <= 9) || statusValue === 11 || (!(statusValue === 3) && !(statusValue === 1) && result.percent < 100);
|
result.isCharging = (statusValue >= 6 && statusValue <= 9) || statusValue === 11 || (!(statusValue === 3) && !(statusValue === 1) && result.percent < 100);
|
||||||
result.acConnected = result.ischarging || statusValue === 2;
|
result.acConnected = result.ischarging || statusValue === 2;
|
||||||
result.model = util.getValue(lines, 'DeviceID', '=');
|
result.model = util.getValue(lines, 'DeviceID', '=');
|
||||||
@ -217,14 +217,25 @@ module.exports = function (callback) {
|
|||||||
workload
|
workload
|
||||||
).then(data => {
|
).then(data => {
|
||||||
if (data) {
|
if (data) {
|
||||||
let parts = data.results[0].split(/\n\s*\n/);
|
// let parts = data.results[0].split(/\n\s*\n/);
|
||||||
|
let parts = data.results[0].split('\r\n');
|
||||||
|
let batteries = [];
|
||||||
|
for (let i = 0; i < parts.length; i++) {
|
||||||
|
const hasValue = value => /\S/.test(value);
|
||||||
|
if (hasValue(parts[i]) && (!batteries.length || !hasValue(parts[i - 1]))) {
|
||||||
|
batteries.push([]);
|
||||||
|
}
|
||||||
|
if (hasValue(parts[i])) {
|
||||||
|
batteries[batteries.length - 1].push(parts[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
let designCapacities = data.results[1].split('\r\n');
|
let designCapacities = data.results[1].split('\r\n');
|
||||||
let fullChargeCapacities = data.results[2].split('\r\n');
|
let fullChargeCapacities = data.results[2].split('\r\n');
|
||||||
if (parts && parts.length) {
|
if (batteries && batteries.length) {
|
||||||
let first = false;
|
let first = false;
|
||||||
let additionalBatteries = [];
|
let additionalBatteries = [];
|
||||||
for (let i = 0; i < parts.length; i++) {
|
for (let i = 0; i < batteries.length; i++) {
|
||||||
let lines = parts[i].split('\r\n');
|
let lines = batteries[i];
|
||||||
const designCapacity = designCapacities && designCapacities.length >= (i + 1) && designCapacities[i] ? util.toInt(designCapacities[i]) : 0;
|
const designCapacity = designCapacities && designCapacities.length >= (i + 1) && designCapacities[i] ? util.toInt(designCapacities[i]) : 0;
|
||||||
const fullChargeCapacity = fullChargeCapacities && fullChargeCapacities.length >= (i + 1) && fullChargeCapacities[i] ? util.toInt(fullChargeCapacities[i]) : 0;
|
const fullChargeCapacity = fullChargeCapacities && fullChargeCapacities.length >= (i + 1) && fullChargeCapacities[i] ? util.toInt(fullChargeCapacities[i]) : 0;
|
||||||
const parsed = parseWinBatteryPart(lines, designCapacity, fullChargeCapacity);
|
const parsed = parseWinBatteryPart(lines, designCapacity, fullChargeCapacity);
|
||||||
|
|||||||
1
lib/index.d.ts
vendored
1
lib/index.d.ts
vendored
@ -284,6 +284,7 @@ export namespace Systeminformation {
|
|||||||
model: string;
|
model: string;
|
||||||
manufacturer: string;
|
manufacturer: string;
|
||||||
serial: string;
|
serial: string;
|
||||||
|
additionalBatteries?: BatteryData[];
|
||||||
}
|
}
|
||||||
|
|
||||||
interface GraphicsData {
|
interface GraphicsData {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user