feat(monitors): 为无内置电池的 Mac 采样整机即时功率
加入整机功率采样、XPC 读取和历史记录,并覆盖无电池设备的采样分支。
This commit is contained in:
@@ -7,6 +7,14 @@ nonisolated struct SensorReadings: Sendable {
|
||||
}
|
||||
|
||||
nonisolated enum CPUTemperatureServiceClient {
|
||||
static func readSystemPower() async -> Double? {
|
||||
await ServiceRequest.perform(timeout: 2) { proxy, finish in
|
||||
proxy.readSystemPower { value in
|
||||
finish(value.flatMap { $0.doubleValue.isFinite && $0.doubleValue > 0 ? $0.doubleValue : nil })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static func readSensors(cpu: Bool, gpu: Bool, fans: Bool) async -> SensorReadings? {
|
||||
await ServiceRequest.perform(timeout: 2) { proxy, finish in
|
||||
proxy.readSensors(cpu: cpu, gpu: gpu, fans: fans) { cpu, gpu, fans in
|
||||
|
||||
@@ -4,6 +4,7 @@ import Foundation
|
||||
@objc protocol SMARTServiceProtocol {
|
||||
nonisolated func readProcessMemory(_ request: Data, withReply reply: @escaping (Data?) -> Void)
|
||||
nonisolated func readProcessEnergy(_ request: Data, withReply reply: @escaping (Data?) -> Void)
|
||||
nonisolated func readSystemPower(withReply reply: @escaping (NSNumber?) -> Void)
|
||||
nonisolated func readSensors(cpu: Bool, gpu: Bool, fans: Bool,
|
||||
withReply reply: @escaping (NSNumber?, NSNumber?, [NSNumber]?) -> Void)
|
||||
nonisolated func readSMART(withReply reply: @escaping (NSNumber?, NSNumber?) -> Void)
|
||||
|
||||
Reference in New Issue
Block a user