Кодом, как я могу отправить жесткий диск для сна

Я думаю, ты скучаешь? для второго параметра вашего запроса:

  def self.search(params)
      articles = Article.where("text LIKE ? or title LIKE ?", "%# 
      {params[:search]}%", "%#{params[:search]}%") if params[:search].present?
      articles
  end
6
задан Jonx 13 May 2009 в 23:51
поделиться

4 ответа

I do not know of the API to do this directly but there are tools that can do it. One that I have seen is Hard Disk Sleeper. I have not used it on my own machines so I cannot speak to its quality or effectiveness.

1
ответ дан 17 December 2019 в 18:19
поделиться

It is possible to do this if you send ATA commands directly to a drive using IOCTL_ATA_PASS_THROUGH. You will need to pass the SLEEP command.

I don't think that this is a project for C# though.

1
ответ дан 17 December 2019 в 18:19
поделиться

I honestly don't think it is possible to do that by using only C# (i.e. the .NET framework).

Regardless, I would start by learning about WMI and ACPI.

This tends to be the sort of thing that requires you to delve into a lower level language (at least to figure out the API calls to use with P\Invoke) because it usually involves interacting closely with the Operating System or possibly directly with a driver.

Maybe you could start by investigating the Windows Power Management Functions although I don't think it allows control of the individual hard drives.

0
ответ дан 17 December 2019 в 18:19
поделиться

AFAIK, это команда ATA, которая устанавливает * время замедления8, то есть отключается сам диск. Вы можете использовать IOCTL_ATA_PASS_THROUGH для отправки команд непосредственно на диск, но я боюсь, что вы не сделаете ничего лучше, чем просто установите его на какое-то минимальное значение (которое я не знаю, что это такое, но оно должно быть в спецификациях ATA

Редактировать: Похоже, почтенный hdparm поддерживает его , поэтому он должен быть в спецификации ATA:

-y Force an IDE drive to immediately enter the low power consumption standby mode, usually causing it to spin down.

-Y Force an IDE drive to immediately enter the lowest power consumption sleep mode, causing it to shut down completely. A hard or soft reset is required before the drive can be accessed again (the Linux IDE driver will automatically handle issuing a reset if/when needed).

Since hdparm (and the underlying Linux kernel it uses to communicate with the drive) is GPL - you should be able to crib the specifics from there if you don't have an ATA spec handy.

Or, just use the win32 port.

1
ответ дан 17 December 2019 в 18:19
поделиться
Другие вопросы по тегам:

Похожие вопросы: