Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

168 lines
3.4 KiB

  1. /* Copyright 1999 American Power Conversion, All Rights Reserved
  2. *
  3. * Description:
  4. * Provides the interface to the generic UPS
  5. *
  6. * Revision History:
  7. * mholly 19Apr1999 initial revision.
  8. * mholly 12May1999 UPSInit no longer takes the comm port param
  9. *
  10. */
  11. #ifndef _INC_GENERIC_UPS_H_
  12. #define _INC_GENERIC_UPS_H_
  13. /**
  14. * GenericUPSInit
  15. *
  16. * Description:
  17. * Retrieves the UPS signalling information from the
  18. * NT Registry and attempts to open the comm port and
  19. * configure it as defined by the signalling data.
  20. * Starts the monitoring of the UPS on a separate thread
  21. * The GenericUPSInit function must be called before any
  22. * other function in this file
  23. *
  24. * Parameters:
  25. * None
  26. *
  27. * Returns:
  28. * UPS_INITOK: Initalization was successful
  29. * UPS_INITREGISTRYERROR: The 'Options' registry value is corrupt
  30. * UPS_INITCOMMOPENERROR: The comm port could not be opened
  31. * UPS_INITCOMMSETUPERROR: The comm port could not be configured
  32. * UPS_INITUNKNOWNERROR: Undefined error has occurred
  33. *
  34. */
  35. DWORD GenericUPSInit(void);
  36. /**
  37. * GenericUPSStop
  38. *
  39. * Description:
  40. * calls GenericUPSCancelWait to release pending threads
  41. * Stops the thread that is monitoring the UPS
  42. * Closes the comm port
  43. * Resets all data to default values
  44. * After a call to GenericUPSStop, only the GenericUPSInit
  45. * function is valid
  46. *
  47. * Parameters:
  48. * None
  49. *
  50. * Returns:
  51. * None
  52. *
  53. */
  54. void GenericUPSStop(void);
  55. /**
  56. * GenericUPSWaitForStateChange
  57. *
  58. * Description:
  59. * Blocks until the state of the UPS differs
  60. * from the value passed in via aState or
  61. * anInterval milliseconds has expired. If
  62. * anInterval has a value of INFINITE this
  63. * function will never timeout
  64. *
  65. * Parameters:
  66. * aState: defines the state to wait for a change from,
  67. * possible values:
  68. * UPS_ONLINE
  69. * UPS_ONBATTERY
  70. * UPS_LOWBATTERY
  71. * UPS_NOCOMM
  72. *
  73. * anInterval: timeout in milliseconds, or INFINITE for
  74. * no timeout interval
  75. *
  76. * Returns:
  77. * None
  78. *
  79. */
  80. void GenericUPSWaitForStateChange(DWORD, DWORD);
  81. /**
  82. * GenericUPSGetState
  83. *
  84. * Description:
  85. * returns the current state of the UPS
  86. *
  87. * Parameters:
  88. * None
  89. *
  90. * Returns:
  91. * possible values:
  92. * UPS_ONLINE
  93. * UPS_ONBATTERY
  94. * UPS_LOWBATTERY
  95. * UPS_NOCOMM
  96. *
  97. */
  98. DWORD GenericUPSGetState(void);
  99. /**
  100. * GenericUPSCancelWait
  101. *
  102. * Description:
  103. * interrupts pending calls to GenericUPSWaitForStateChange
  104. * without regard to timout or state change
  105. *
  106. * Parameters:
  107. * None
  108. *
  109. * Returns:
  110. * None
  111. *
  112. */
  113. void GenericUPSCancelWait(void);
  114. /**
  115. * GenericUPSTurnOff
  116. *
  117. * Description:
  118. * Attempts to turn off the outlets on the UPS
  119. * after the specified delay. This call must
  120. * return immediately. Any work, such as a timer,
  121. * must be performed on a another thread.
  122. *
  123. * Parameters:
  124. * aTurnOffDelay: the minimum amount of time to wait before
  125. * turning off the outlets on the UPS
  126. *
  127. * Returns:
  128. * None
  129. *
  130. */
  131. void GenericUPSTurnOff(DWORD aTurnOffDelay);
  132. //
  133. // values returned from GenericUPSGetState
  134. //
  135. #define UPS_ONLINE 1
  136. #define UPS_ONBATTERY 2
  137. #define UPS_LOWBATTERY 4
  138. #define UPS_NOCOMM 8
  139. //
  140. // possible error codes for GenericUPSInit
  141. //
  142. #define UPS_INITUNKNOWNERROR 0
  143. #define UPS_INITOK 1
  144. #define UPS_INITNOSUCHDRIVER 2
  145. #define UPS_INITBADINTERFACE 3
  146. #define UPS_INITREGISTRYERROR 4
  147. #define UPS_INITCOMMOPENERROR 5
  148. #define UPS_INITCOMMSETUPERROR 6
  149. #endif