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.

58 lines
1.3 KiB

  1. /*
  2. *
  3. * NOTES:
  4. *
  5. * REVISIONS:
  6. * pcy13Jan92: Implement
  7. * pcy16Feb93: Use %d for sleep time in sprintf to solve bug
  8. * ajr09May95: Need to fix for keeping internal time in seconds.
  9. * srt04Jun97: Added support for 15 day sleep.
  10. */
  11. #define INCL_BASE
  12. #define INCL_DOS
  13. #define INCL_NOPM
  14. #include "cdefine.h"
  15. extern "C" {
  16. #if (C_OS & C_OS2)
  17. #include <os2.h>
  18. #endif
  19. #include <stdlib.h>
  20. #include <stdio.h>
  21. #include <malloc.h>
  22. #include <string.h>
  23. }
  24. #include "ups2slep.h"
  25. #include "comctrl.h"
  26. #include "dispatch.h"
  27. #include "errlogr.h"
  28. #include "utils.h"
  29. //Constructor
  30. PutUpsToSleepSensor :: PutUpsToSleepSensor(PDevice aParent, PCommController aCommController)
  31. : Sensor(aParent,aCommController, PUT_UPS_TO_SLEEP, AREAD_WRITE)
  32. {
  33. }
  34. INT PutUpsToSleepSensor::Set(const PCHAR aValue)
  35. {
  36. INT err = ErrNO_ERROR;
  37. CHAR sleep_time[32];
  38. long iValue;
  39. CHAR sHuns[4];
  40. // only ups-compatible values should get to this point, having been validated in the FE &
  41. if ((iValue=atol(aValue)/360) <= 3599) { // convert msecs to tenths of an hour (TOHs).
  42. sprintf(sleep_time,"%s%02d",_ltoa(iValue/100L,sHuns,36),iValue%100); // format the sleep command
  43. err = theCommController->Set(PUT_UPS_TO_SLEEP, sleep_time);
  44. }
  45. else {
  46. err= ErrINVALID_VALUE;
  47. }
  48. return err;
  49. }