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.

89 lines
2.1 KiB

  1. /*
  2. *
  3. * NOTES:
  4. *
  5. * REVISIONS:
  6. * xxxddMMMyy
  7. * SjA10Dec92: Small Syntax error. READ_WRITE needs to be changed to AREAD_WRITE
  8. * srt24Dec96: Fixe init to use config mgr instead of hard-coded disabled.
  9. */
  10. #define INCL_BASE
  11. #define INCL_DOS
  12. #define INCL_NOPM
  13. #include "cdefine.h"
  14. extern "C" {
  15. #if (C_OS & C_OS2)
  16. #include <os2.h>
  17. #endif
  18. #include <stdlib.h>
  19. #include <stdio.h>
  20. #include <malloc.h>
  21. #include <string.h>
  22. }
  23. #include "turnoff.h"
  24. #include "cfgmgr.h"
  25. #include "comctrl.h"
  26. #include "dispatch.h"
  27. //Constructor
  28. TurnOffUpsOnBatterySensor :: TurnOffUpsOnBatterySensor(PDevice aParent,
  29. PCommController aCommController)
  30. : Sensor(aParent,aCommController,TURN_OFF_UPS_ON_BATTERY,AREAD_WRITE)
  31. {
  32. CHAR aValue[8];
  33. INT err = _theConfigManager->Get(CFG_AUTO_UPS_REBOOT_ENABLED, aValue);
  34. //Make sure this value is correct
  35. AutoRebootEnabled = (('Y' == aValue[0]) || ('y' == aValue[0]));
  36. }
  37. INT TurnOffUpsOnBatterySensor::Get(INT aCode, PCHAR aValue)
  38. {
  39. INT err = ErrNO_ERROR;
  40. switch(aCode) {
  41. case AUTO_REBOOT_ENABLED:
  42. err = _theConfigManager->Get(CFG_AUTO_UPS_REBOOT_ENABLED, aValue);
  43. //Make sure this value is correct
  44. AutoRebootEnabled = (('Y' == aValue[0]) || ('y' == aValue[0]));
  45. break;
  46. default:
  47. break;
  48. }
  49. return err;
  50. }
  51. INT TurnOffUpsOnBatterySensor::Set(INT aCode, const PCHAR aValue)
  52. {
  53. INT err = ErrNO_ERROR;
  54. switch(aCode) {
  55. case AUTO_REBOOT_ENABLED:
  56. // err = _theConfigManager->Set(CFG_AUTO_UPS_REBOOT_ENABLED, aValue);
  57. //Make sure this value is correct
  58. AutoRebootEnabled = (('Y' == aValue[0]) || ('y' == aValue[0]));
  59. break;
  60. case TURN_OFF_UPS_ON_BATTERY:
  61. // We use this data member because the file system is down (in Novell)
  62. // before we check this config parameter in the INI file. So we hold
  63. // this boolean value which is set every time we check AUTO_REBOOT_ENABLED
  64. // -- James
  65. if (AutoRebootEnabled) {
  66. // reboot when power returns;
  67. err = theCommController->Set(TURN_OFF_UPS_ON_BATTERY, (CHAR*)NULL);
  68. }
  69. else {
  70. // Don't reboot when power returns;
  71. err = theCommController->Set(TURN_OFF_UPS_AFTER_DELAY, (CHAR*)NULL);
  72. }
  73. default:
  74. break;
  75. }
  76. return err;
  77. }