reads the data from WMI Win32_Processor

@return array
187874
private function _get_Win32_Processor()
    {
        if ($this->_Win32_Processor === null) $this->_Win32_Processor = CommonFunctions::getWMI($this->_wmi, 'Win32_Processor', array('LoadPercentage', 'AddressWidth', 'Name', 'L2CacheSize', 'L3CacheSize', 'CurrentClockSpeed', 'ExtClock', 'NumberOfCores', 'NumberOfLogicalProcessors', 'MaxClockSpeed'));
        return $this->_Win32_Processor;
    }
1362045
public function toArray()
    {
        return [
            'folderId' => $this->folder->getId(),
            'usageType' => $this->usageType,
            'usageId' => $this->usageId,
            'status' => $this->status,
        ];
    }
317075
def read_wmic
      res = @backend.run_command('wmic os get * /format:list')
      if res.exit_status == 0
        sys_info = {}
        res.stdout.lines.each { |line|
          m = /^\s*([^=]*?)\s*=\s*(.*?)\s*$/.match(line)
          sys_info[m[1].to_sym] = m[2] unless m.nil? || m[1].nil?
        }

        @platform[:release] = sys_info[:Version]
        # additional info on windows
        @platform[:build] = sys_info[:BuildNumber]
        @platform[:name] = sys_info[:Caption]
        @platform[:name] = @platform[:name].gsub('Microsoft', '').strip unless @platform[:name].empty?
        @platform[:arch] = read_wmic_cpu
      end
    end
578800
public function getNet()
    {

        // Time?
        if (!empty($this->settings['timer'])) {
            $t = new Timer('Network Devices');
        }

        $return = array();
        $i = 0;

        if (version_compare($this->windows_version,'6.1.0000')>0) {
            $object = $this->wmi->ExecQuery('SELECT AdapterType, Name, NetConnectionStatus, GUID FROM Win32_NetworkAdapter WHERE PhysicalAdapter = TRUE');
        } else {
            $object = $this->wmi->ExecQuery('SELECT AdapterType, Name, NetConnectionStatus FROM Win32_NetworkAdapter WHERE NetConnectionStatus != NULL');
        }

        foreach ($object as $net) {
            // Save and get info for each
            $return[$net->Name] = array(
                'recieved' => array(
                    'bytes' => 0,
                    'errors' => 0,
                    'packets' => 0,
                ),
                'sent' => array(
                    'bytes' => 0,
                    'errors' => 0,
                    'packets' => 0,
                ),
                'state' => 0,
                'type' => $net->AdapterType,
            );
            switch ($net->NetConnectionStatus) {
                case 0:
                    $return[$net->Name]['state'] = 'down';
                    break;
                case 1:
                    $return[$net->Name]['state'] = 'Connecting';
                    break;
                case 2:
                    $return[$net->Name]['state'] = 'up';
                    break;
                case 3:
                    $return[$net->Name]['state'] = 'Disconnecting';
                    break;
                case 4:
                    $return[$net->Name]['state'] = 'down'; // MSDN 'Hardware not present'
                    break;
                case 5:
                    $return[$net->Name]['state'] = 'Hardware disabled';
                    break;
                case 6:
                    $return[$net->Name]['state'] = 'Hardware malfunction';
                    break;
                case 7:
                    $return[$net->Name]['state'] = 'Media disconnected';
                    break;
                case 8:
                    $return[$net->Name]['state'] = 'Authenticating';
                    break;
                case 9:
                    $return[$net->Name]['state'] = 'Authentication succeeded';
                    break;
                case 10:
                    $return[$net->Name]['state'] = 'Authentication failed';
                    break;
                case 11:
                    $return[$net->Name]['state'] = 'Invalid address';
                    break;
                case 12:
                    $return[$net->Name]['state'] = 'Credentials required';
                    break;
                default:
                    $return[$net->Name]['state'] = 'unknown';
                    break;
            }
            // @Microsoft: An index would be nice here indeed.
            if (version_compare($this->windows_version,'6.1.0000')>0) {
                $canonname = preg_replace('/[^A-Za-z0-9- ]/', '_', $net->Name);
                $canonname2 = str_replace(['(', ')'], ['[', ']'], $canonname);
                $isatapname = 'isatap.'.$net->GUID;

                $result = $this->wmi->ExecQuery("SELECT BytesReceivedPersec, PacketsReceivedErrors, PacketsReceivedPersec, BytesSentPersec, PacketsSentPersec FROM Win32_PerfRawData_Tcpip_NetworkInterface WHERE Name = '$canonname' OR Name = '$isatapname' OR Name = '$canonname2'");
            } else {
                $canonname = preg_replace('/[^A-Za-z0-9- ]/', '_', $net->Name);
                $result = $this->wmi->ExecQuery("SELECT BytesReceivedPersec, PacketsReceivedErrors, PacketsReceivedPersec, BytesSentPersec, PacketsSentPersec FROM Win32_PerfRawData_Tcpip_NetworkInterface WHERE Name = '$canonname'");
            }
            foreach ($result as $netspeed) {
                $return[$net->Name]['recieved'] = array(
                    'bytes' => (int) $netspeed->BytesReceivedPersec,
                    'errors' => (int) $netspeed->PacketsReceivedErrors,
                    'packets' => (int) $netspeed->PacketsReceivedPersec,
                );
                $return[$net->Name]['sent'] = array(
                    'bytes' => (int) $netspeed->BytesSentPersec,
                    'errors' => 0,
                    'packets' => (int) $netspeed->PacketsSentPersec,
                );
            }
            ++$i;
        }

        return $return;
    }
951619
private function _memory()
    {
        if ($this->_wmi) {
            $buffer = $this->_get_Win32_OperatingSystem();
            if ($buffer) {
                $this->sys->setMemTotal($buffer[0]['TotalVisibleMemorySize'] * 1024);
                $this->sys->setMemFree($buffer[0]['FreePhysicalMemory'] * 1024);
                $this->sys->setMemUsed($this->sys->getMemTotal() - $this->sys->getMemFree());
            }
            $buffer = CommonFunctions::getWMI($this->_wmi, 'Win32_PageFileUsage');
            foreach ($buffer as $swapdevice) {
                $dev = new DiskDevice();
                $dev->setName("SWAP");
                $dev->setMountPoint($swapdevice['Name']);
                $dev->setTotal($swapdevice['AllocatedBaseSize'] * 1024 * 1024);
                $dev->setUsed($swapdevice['CurrentUsage'] * 1024 * 1024);
                $dev->setFree($dev->getTotal() - $dev->getUsed());
                $dev->setFsType('swap');
                $this->sys->setSwapDevices($dev);
            }
        } elseif (($buffer = $this->_get_systeminfo()) && preg_match("/:\s([\d \xFF]+)\sMB\r\n.+:\s([\d \xFF]+)\sMB\r\n.+:\s([\d \xFF]+)\sMB\r\n.+:\s([\d \xFF]+)\sMB\r\n.+\s([\d \xFF]+)\sMB\r\n/m", $buffer, $buffer2)) {
//           && (preg_match("/:\s([\d \xFF]+)\sMB\r\n.+:\s([\d \xFF]+)\sMB\r\n.+:\s([\d \xFF]+)\sMB\r\n.+:\s([\d \xFF]+)\sMB\r\n.+\s([\d \xFF]+)\sMB\r\n.*:\s+(\S+)\r\n/m", $buffer, $buffer2)) {
            $this->sys->setMemTotal(preg_replace('/(\s)|(\xFF)/', '', $buffer2[1]) * 1024 * 1024);
            $this->sys->setMemFree(preg_replace('/(\s)|(\xFF)/', '', $buffer2[2]) * 1024 * 1024);
            $this->sys->setMemUsed($this->sys->getMemTotal() - $this->sys->getMemFree());
        }
    }
443743
public function getProcessStats()
    {

        // Time?
        if (!empty($this->settings['timer'])) {
            $t = new Timer('Process Stats');
        }

        $result = array(
            'exists' => true,
            'proc_total' => 0,
            'threads' => 0,
        );

        foreach ($this->wmi->ExecQuery('SELECT ThreadCount FROM Win32_Process') as $proc) {
            $result['threads'] += (int) $proc->ThreadCount;
            ++$result['proc_total'];
        }

        return $result;
    }
930427
public function getHostData($wmiConnection) {
        $return = Array();

        $OperatingSystem = $wmiConnection->query("SELECT LocalDateTime, LastBootUpTime, NumberOfUsers, NumberOfProcesses FROM Win32_OperatingSystem");

        foreach ($OperatingSystem as $wmi_operatingsystem) {
            $LocalDateTime = $wmi_operatingsystem->LocalDateTime;
            $LastBootUpTime = $wmi_operatingsystem->LastBootUpTime;
            $return['users_connected'] = $wmi_operatingsystem->NumberOfUsers;
            $return['running_process'] = 0; //$wmi_operatingsystem->NumberOfProcesses;
        }

        
        $return['uptime'] = \Cityware\Utility\UpTime::calculationUpTime($LocalDateTime, $LastBootUpTime);

        return $return;
    }
1282434
public function getInspectionData()
    {
        return [
            static::PARAM_COMPOSER_JSON      => $this->composer,
            static::PARAM_COMPOSER_LOCK      => $this->composerLock,
            static::PARAM_COMPOSER_INSTALLED => $this->composerInstalled,
        ];
    }
644429
public function toArray() : array {
        return [
            'command'   => $this->getCommand(),
            'running'   => $this->isRunning(),
            'info'      => $this->getInfo() ? $this->getInfo()->toArray() : null,
        ];
    }
1060140
private function readImData()
    {
        $length = self::getInt2d($this->data, $this->pos + 2);

        // get spliced record data
        $splicedRecordData = $this->getSplicedRecordData();
        $recordData = $splicedRecordData['recordData'];

        // UNDER CONSTRUCTION

        // offset: 0; size: 2; image format
        $cf = self::getInt2d($recordData, 0);

        // offset: 2; size: 2; environment from which the file was written
        $env = self::getInt2d($recordData, 2);

        // offset: 4; size: 4; length of the image data
        $lcb = self::getInt4d($recordData, 4);

        // offset: 8; size: var; image data
        $iData = substr($recordData, 8);

        switch ($cf) {
            case 0x09: // Windows bitmap format
                // BITMAPCOREINFO
                // 1. BITMAPCOREHEADER
                // offset: 0; size: 4; bcSize, Specifies the number of bytes required by the structure
                $bcSize = self::getInt4d($iData, 0);
    //            var_dump($bcSize);

                // offset: 4; size: 2; bcWidth, specifies the width of the bitmap, in pixels
                $bcWidth = self::getInt2d($iData, 4);
    //            var_dump($bcWidth);

                // offset: 6; size: 2; bcHeight, specifies the height of the bitmap, in pixels.
                $bcHeight = self::getInt2d($iData, 6);
    //            var_dump($bcHeight);
                $ih = imagecreatetruecolor($bcWidth, $bcHeight);

                // offset: 8; size: 2; bcPlanes, specifies the number of planes for the target device. This value must be 1

                // offset: 10; size: 2; bcBitCount specifies the number of bits-per-pixel. This value must be 1, 4, 8, or 24
                $bcBitCount = self::getInt2d($iData, 10);
    //            var_dump($bcBitCount);

                $rgbString = substr($iData, 12);
                $rgbTriples = array();
                while (strlen($rgbString) > 0) {
                    $rgbTriples[] = unpack('Cb/Cg/Cr', $rgbString);
                    $rgbString = substr($rgbString, 3);
                }
                $x = 0;
                $y = 0;
                foreach ($rgbTriples as $i => $rgbTriple) {
                    $color = imagecolorallocate($ih, $rgbTriple['r'], $rgbTriple['g'], $rgbTriple['b']);
                    imagesetpixel($ih, $x, $bcHeight - 1 - $y, $color);
                    $x = ($x + 1) % $bcWidth;
                    $y = $y + floor(($x + 1) / $bcWidth);
                }
                //imagepng($ih, 'image.png');

                $drawing = new PHPExcel_Worksheet_Drawing();
                $drawing->setPath($filename);
                $drawing->setWorksheet($this->phpSheet);
                break;
            case 0x02: // Windows metafile or Macintosh PICT format
            case 0x0e: // native format
            default:
                break;
        }

        // getSplicedRecordData() takes care of moving current position in data stream
    }
106127
private function _machine()
    {
        $buffer = $this->_get_Win32_ComputerSystem();
        if ($buffer) {
            $buf = "";
            if (isset($buffer[0]['Manufacturer']) && !preg_match("/^To be filled by O\.E\.M\.$|^System manufacturer$|^Not Specified$/i", $buf2=$buffer[0]['Manufacturer'])) {
                $buf .= ' '.$buf2;
            }

            if (isset($buffer[0]['Model']) && !preg_match("/^To be filled by O\.E\.M\.$|^System Product Name$|^Not Specified$/i", $buf2=$buffer[0]['Model'])) {
                $buf .= ' '.$buf2;
            }
            if (trim($buf) != "") {
                $this->sys->setMachine(trim($buf));
            }
        }
    }
765977
public function get()
    {
        $disks = [];

        $result = $this->connection->newQuery()->from(Classes::WIN32_LOGICALDISK)->get();

        foreach($result as $disk) {
            $disks[] = new HardDisk($disk);
        }

        return $disks;
    }
612186
public function getMemoryData($wmiConnection) {


        $Computersystem = $wmiConnection->query("SELECT TotalPhysicalMemory from Win32_ComputerSystem");
        $OperatingSystem = $wmiConnection->query("SELECT FreePhysicalMemory, TotalVisibleMemorySize FROM Win32_OperatingSystem");
        $PageFileUsage = $wmiConnection->query("SELECT AllocatedBaseSize, CurrentUsage FROM Win32_PageFileUsage");

        $return = Array();

        foreach ($Computersystem as $wmi_computersystem) {
            $return['total_ram_machine'] = $wmi_computersystem->TotalPhysicalMemory;
        }
        foreach ($OperatingSystem as $wmi_operatingsystem) {
            $return['avaliable_ram_real'] = \Cityware\Format\Number::convertByteFormat($wmi_operatingsystem->FreePhysicalMemory, 'KB', 'B');
        }

        $return['total_memory_used'] = $return['total_ram_machine'] - $return['avaliable_ram_real'];
        $return['perc_memory_used'] = round((($return['total_memory_used'] / $return['total_ram_machine']) * 100), 2);
        
        foreach ($PageFileUsage as $wmi_pagefileusage) {
            $return['total_swap_size'] = \Cityware\Format\Number::convertByteFormat($wmi_pagefileusage->AllocatedBaseSize, 'MB', 'B');
            $return['total_swap_used'] = \Cityware\Format\Number::convertByteFormat($wmi_pagefileusage->CurrentUsage, 'MB', 'B');
        }
        
        $return['avaliable_swap_size'] = $return['total_swap_size'] - $return['total_swap_used'];
        $return['perc_swap_used'] = round((($return['total_swap_used'] / $return['total_swap_size']) * 100), 2);
        
        return $return;
    }
351481
public function memory_total()
    {
        $mem_total = 0;
        if ($this->host_os === 'WINDOWS') {
            $wmi = new \COM("winmgmts:\\\\.\\root\\cimv2");
            $os =  $wmi->ExecQuery("SELECT * FROM Win32_OperatingSystem");

            foreach ($os as $m) {
                $mem_total = $m->TotalVisibleMemorySize;
            }
        } else {
            $fh = fopen('/proc/meminfo', 'r');

            while ($line = fgets($fh)) {
                $pieces = array();
                if (preg_match('/^MemTotal:\s+(\d+)\skB$/', trim($line), $pieces)) {
                    $mem_total = $pieces[1];
                    break;
                }
            }
            fclose($fh);
        }
        return $mem_total;
    }
1359873
public function stream_stat(): array
    {
        $fileStat = [
            'dev'     => 0,
            'ino'     => 0,
            'mode'    => $this->content->getType() | $this->content->getPermissions(),
            'nlink'   => 0,
            'uid'     => $this->content->getUser(),
            'gid'     => $this->content->getGroup(),
            'rdev'    => 0,
            'size'    => $this->content->size(),
            'atime'   => $this->content->fileatime(),
            'mtime'   => $this->content->filemtime(),
            'ctime'   => $this->content->filectime(),
            'blksize' => -1,
            'blocks'  => -1
        ];
        return array_merge(array_values($fileStat), $fileStat);
    }
1242316
public function read() : array
    {
        if (!$this->weights or !$this->biases) {
            throw new RuntimeException('Layer has not been initialized');
        }

        return [
            'weights' => clone $this->weights,
            'biases' => clone $this->biases,
        ];
    }
471805
public function getMounts()
    {

        // Time?
        if (!empty($this->settings['timer'])) {
            $t = new Timer('Mounted file systems');
        }

        $volumes = array();

        if (version_compare($this->windows_version,'6.1.0000')>0) {
            $object = $this->wmi->ExecQuery('SELECT Automount, BootVolume, Compressed, IndexingEnabled, Label, Caption, FileSystem, Capacity, FreeSpace, DriveType FROM Win32_Volume');
        } else {
            $object = $this->wmi->ExecQuery('SELECT Compressed, Name, FileSystem, Size, FreeSpace, DriveType FROM Win32_LogicalDisk');
        }

        foreach ($object as $volume) {
            $options = array();
            if (version_compare($this->windows_version,'6.1.0000')>0) {
                if ($volume->Automount) {
                    $options[] = 'automount';
                }
                if ($volume->BootVolume) {
                    $options[] = 'boot';
                }
                if ($volume->IndexingEnabled) {
                    $options[] = 'indexed';
                }
            }
            if ($volume->Compressed) {
                $options[] = 'compressed';
            }
            $capacity = (version_compare($this->windows_version,'6.1.0000')>0) ? $volume->Capacity : $volume->Size;
            $label = (version_compare($this->windows_version,'6.1.0000')>0) ? $volume->Label : $volume->Name;
            $mount = (version_compare($this->windows_version,'6.1.0000')>0) ? $volume->Caption : $label.'\\';
            $a = array(
                'device' => false,
                'label' => $label,
                'devtype' => '',
                'mount' => $mount,
                'type' => $volume->FileSystem,
                'size' => $capacity,
                'used' => $capacity - $volume->FreeSpace,
                'free' => $volume->FreeSpace,
                'free_percent' => 0,
                'used_percent' => 0,
                'options' => $options,
            );

            switch ($volume->DriveType) {
                case 2:
                    $a['devtype'] = 'Removable drive';
                    break;
                case 3:
                    $a['devtype'] = 'Fixed drive';
                    break;
                case 4:
                    $a['devtype'] = 'Remote drive';
                    break;
                case 5:
                    $a['devtype'] = 'CD-ROM';
                    break;
                case 6:
                    $a['devtype'] = 'RAM disk';
                    break;
                default:
                    $a['devtype'] = 'Unknown';
                    break;
            }

            if ($capacity != 0) {
                $a['free_percent'] = round($volume->FreeSpace / $capacity, 2) * 100;
                $a['used_percent'] = round(($capacity - $volume->FreeSpace) / $capacity, 2) * 100;
            }

            $volumes[] = $a;
        }

        usort($volumes, array('Linfo\OS\Windows', 'compare_mounts'));

        return $volumes;
    }