本文整理汇总了PHP中HWDevice::setCapacity方法的典型用法代码示例。如果您正苦于以下问题:PHP HWDevice::setCapacity方法的具体用法?PHP HWDevice::setCapacity怎么用?PHP HWDevice::setCapacity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HWDevice
的用法示例。
在下文中一共展示了HWDevice::setCapacity方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ide
/**
* IDE information
*
* @return void
*/
protected function ide()
{
foreach ($this->readdmesg() as $line) {
if (preg_match('/^(.*) at (pciide|wdc|atabus|atapibus)[0-9] (.*): <(.*)>/', $line, $ar_buf)) {
$dev = new HWDevice();
$dev->setName($ar_buf[1]);
// now loop again and find the capacity
foreach ($this->readdmesg() as $line2) {
if (preg_match("/^(" . $ar_buf[1] . "): (.*), (.*), (.*)MB, .*\$/", $line2, $ar_buf_n)) {
$dev->setCapacity($ar_buf_n[4] * 2048 * 1.049);
} elseif (preg_match("/^(" . $ar_buf[1] . "): (.*) MB, (.*), (.*), .*\$/", $line2, $ar_buf_n)) {
$dev->setCapacity($ar_buf_n[2] * 2048);
}
}
$this->sys->setIdeDevices($dev);
}
}
}
示例2: ide
/**
* IDE devices
* get the ide device information out of dmesg
*
* @return void
*/
protected function ide()
{
foreach ($this->readdmesg() as $line) {
if (preg_match('/^(ad[0-9]+): (.*)MB <(.*)> (.*) (.*)/', $line, $ar_buf)) {
$dev = new HWDevice();
$dev->setName($ar_buf[1]);
$dev->setCapacity($ar_buf[2] * 1024);
$this->sys->setIdeDevices($dev);
} elseif (preg_match('/^(acd[0-9]+): (.*) <(.*)> (.*)/', $line, $ar_buf)) {
$dev = new HWDevice();
$dev->setName($ar_buf[1]);
$this->sys->setIdeDevices($dev);
}
}
}
示例3: ide
/**
* IDE devices
* get the ide device information out of dmesg
*
* @return void
*/
protected function ide()
{
foreach ($this->readdmesg() as $line) {
if (preg_match('/^(ad[0-9]+): (.*)MB <(.*)> (.*) (.*)/', $line, $ar_buf)) {
$dev = new HWDevice();
$dev->setName($ar_buf[1] . ": " . $ar_buf[3]);
$dev->setCapacity($ar_buf[2] * 1024);
$this->sys->setIdeDevices($dev);
} elseif (preg_match('/^(acd[0-9]+): (.*) <(.*)> (.*)/', $line, $ar_buf)) {
$dev = new HWDevice();
$dev->setName($ar_buf[1] . ": " . $ar_buf[3]);
$this->sys->setIdeDevices($dev);
} elseif (preg_match('/^(ada[0-9]+): <(.*)> (.*)/', $line, $ar_buf)) {
$dev = new HWDevice();
$dev->setName($ar_buf[1] . ": " . $ar_buf[2]);
$this->sys->setIdeDevices($dev);
} elseif (preg_match('/^(ada[0-9]+): (.*)MB \\((.*)\\)/', $line, $ar_buf)) {
/* duplication security */
$notwas = true;
foreach ($this->sys->getIdeDevices() as $finddev) {
if ($notwas && substr($finddev->getName(), 0, strpos($finddev->getName(), ': ')) == $ar_buf[1]) {
$finddev->setCapacity($ar_buf[2] * 1024);
$notwas = false;
break;
}
}
if ($notwas) {
$dev = new HWDevice();
$dev->setName($ar_buf[1]);
$dev->setCapacity($ar_buf[2] * 1024);
$this->sys->setIdeDevices($dev);
}
}
}
/* cleaning */
foreach ($this->sys->getIdeDevices() as $finddev) {
if (strpos($finddev->getName(), ': ') !== false) {
$finddev->setName(substr(strstr($finddev->getName(), ': '), 2));
}
}
}
示例4: _ide
/**
* IDE devices
*
* @return void
*/
private function _ide()
{
$bufd = CommonFunctions::gdc('/proc/ide', false);
foreach ($bufd as $file) {
if (preg_match('/^hd/', $file)) {
$dev = new HWDevice();
$dev->setName(trim($file));
if (CommonFunctions::rfts("/proc/ide/" . $file . "/media", $buf, 1)) {
if (trim($buf) == 'disk') {
if (CommonFunctions::rfts("/proc/ide/" . $file . "/capacity", $buf, 1, 4096, false) || CommonFunctions::rfts("/sys/block/" . $file . "/size", $buf, 1, 4096, false)) {
$dev->setCapacity(trim($buf) * 512 / 1024);
}
}
}
if (CommonFunctions::rfts("/proc/ide/" . $file . "/model", $buf, 1)) {
$dev->setName($dev->getName() . ": " . trim($buf));
}
$this->sys->setIdeDevices($dev);
}
}
}
示例5: ide
/**
* get the ide information
*
* @return array
*/
protected function ide()
{
foreach ($this->readdmesg() as $line) {
if (preg_match('/^(.*): (.*) <(.*)> at (ata[0-9]\\-(.*)) (.*)/', $line, $ar_buf)) {
$dev = new HWDevice();
$dev->setName($ar_buf[1]);
if (!preg_match("/^acd[0-9](.*)/", $ar_buf[1])) {
$dev->setCapacity($ar_buf[2] * 1024);
}
$this->sys->setIdeDevices($dev);
}
}
}