package cn.reghao.bnt.common.machine;

import cn.reghao.bnt.common.machine.model.CPUInfo;
import cn.reghao.jutil.jdk.machine.data.MachineData;
import cn.reghao.jutil.jdk.machine.data.detail.CpuDetail;
import cn.reghao.jutil.jdk.machine.data.stat.CpuStat;
import oshi.SystemInfo;
import oshi.hardware.CentralProcessor;
import oshi.hardware.HardwareAbstractionLayer;

/**
 * @author reghao
 * @date 2019-10-25 13:12:36
 */
public class CPU implements MachineData<CpuDetail, CpuStat> {
    private final CentralProcessor processor;

    public CPU(SystemInfo si) {
        this.processor = si.getHardware().getProcessor();
    }

    @Override
    public CpuDetail detail() {
        CentralProcessor.ProcessorIdentifier processorIdentifier = processor.getProcessorIdentifier();
        String vendor = processorIdentifier.getVendor();
        String name = processorIdentifier.getName();
        int physicalCore = processor.getPhysicalProcessorCount();
        int logicalCore = processor.getLogicalProcessorCount();
        return new CpuDetail(vendor, name, physicalCore, logicalCore);
    }

    @Override
    public CpuStat stat() {
        return null;
    }

    public CPUInfo getCPUInfo() {
        return null;
    }
}
