<?php
class SystemInfo
{
    private $memoryInfo = null;
    private $thermalInfo = null;
    private $systemLoadInfo = null;
    
    public function __construct() {
        if (PhonalisaCtrldConnector::hasConnection()) {
            $systemInfo = PhonalisaCtrldConnector::getSystemInfo();
            $this->memoryInfo = new MemoryInfo(@$systemInfo->meminfo);
            $this->thermalInfo = new ThermalInfo(@$systemInfo->thermalinfo);
            $this->systemLoadInfo = new SystemLoadInfo(@$systemInfo->systemloadinfo);
        }
    }
    
    public function getMemoryInfo() {
        return $this->memoryInfo;
    }
    
    public function getThermalInfo() {
        return $this->thermalInfo;
    }
    
    public function getSystemLoadInfo() {
        return $this->systemLoadInfo;
    }
    
    public function getMemUsed($mountPoint = null) {
        return $this->memoryInfo->getMemUsed($mountPoint);
    }
    
    public function getMemTotal($mountPoint = null) {
        return $this->memoryInfo->getMemTotal($mountPoint);
    }
    
    public function getMemTotalInGiB($mountPoint = null)
    {
        return $this->memoryInfo->getMemTotalInGiB($mountPoint);
    }


    public function thermalInfoIsEnabled()
    {
        return $this->getThermalInfo()->isEnabled();
    }
    
    public function getCPUTemperature() {
        return $this->thermalInfo->getCPUTemperature();
    }
    
    public function getSystemLoad($duration = SystemLoadInfo::ONE_MINUTE)
    {
        return $this->systemLoadInfo->getSystemLoad($duration);
    }
}
