feat(monitors): 为无内置电池的 Mac 采样整机即时功率
加入整机功率采样、XPC 读取和历史记录,并覆盖无电池设备的采样分支。
This commit is contained in:
@@ -3,6 +3,7 @@ import Foundation
|
||||
private actor CPUTemperatureReader {
|
||||
private let monitor = CPUTemperatureMonitor()
|
||||
private let gpuMonitor = CPUTemperatureMonitor(zone: .gpu)
|
||||
func sampleSystemPower() -> Double? { monitor.sampleSystemPower() }
|
||||
func sampleFans() -> [Double?]? { monitor.sampleFans() }
|
||||
func sampleGPU() -> Double? { gpuMonitor.sample() }
|
||||
|
||||
@@ -14,6 +15,10 @@ private actor CPUTemperatureReader {
|
||||
final class SMARTService: NSObject, SMARTServiceProtocol {
|
||||
private let temperatureReader = CPUTemperatureReader()
|
||||
|
||||
func readSystemPower(withReply reply: @escaping (NSNumber?) -> Void) {
|
||||
Task { reply(await temperatureReader.sampleSystemPower().map(NSNumber.init(value:))) }
|
||||
}
|
||||
|
||||
func readSensors(cpu: Bool, gpu: Bool, fans: Bool,
|
||||
withReply reply: @escaping (NSNumber?, NSNumber?, [NSNumber]?) -> Void) {
|
||||
Task {
|
||||
|
||||
Reference in New Issue
Block a user