View Javadoc
1   /*
2    * Copyright 2020-2022 The OSHI Project Contributors
3    * SPDX-License-Identifier: MIT
4    */
5   package oshi.driver.windows.wmi;
6   
7   import java.util.Objects;
8   
9   import com.sun.jna.platform.win32.COM.WbemcliUtil.WmiQuery;
10  import com.sun.jna.platform.win32.COM.WbemcliUtil.WmiResult;
11  
12  import oshi.annotation.concurrent.ThreadSafe;
13  import oshi.util.platform.windows.WmiQueryHandler;
14  
15  /**
16   * Utility to query WMI class {@code Win32_Fan}
17   */
18  @ThreadSafe
19  public final class Win32Fan {
20  
21      private static final String WIN32_FAN = "Win32_Fan";
22  
23      /**
24       * Fan speed property.
25       */
26      public enum SpeedProperty {
27          DESIREDSPEED;
28      }
29  
30      private Win32Fan() {
31      }
32  
33      /**
34       * Queries the fan speed.
35       *
36       * @return Currently requested fan speed, defined in revolutions per minute, when a variable speed fan is supported.
37       */
38      public static WmiResult<SpeedProperty> querySpeed() {
39          WmiQuery<SpeedProperty> fanQuery = new WmiQuery<>(WIN32_FAN, SpeedProperty.class);
40          return Objects.requireNonNull(WmiQueryHandler.createInstance()).queryWMI(fanQuery);
41      }
42  }