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.

83 lines
1.7 KiB

  1. /*
  2. * pcy17Dec92 Added Validate()
  3. * cad10Jun93: fixed GetState()
  4. *
  5. */
  6. #include "cdefine.h"
  7. #define INCL_BASE
  8. #define INCL_DOS
  9. #define INCL_NOPM
  10. extern "C" {
  11. #if (C_OS & C_OS2)
  12. #include <os2.h>
  13. #endif
  14. #include <stdlib.h>
  15. #include <stdio.h>
  16. #include <malloc.h>
  17. #include <string.h>
  18. }
  19. #include "event.h"
  20. #include "apc.h"
  21. #include "chgsensr.h"
  22. #include "utils.h"
  23. #include "device.h"
  24. //Constructor
  25. ChangeSensor :: ChangeSensor(PDevice aParent,
  26. PCommController aCommController,
  27. INT aSensorCode,
  28. INT anUpperEventCode,
  29. INT aLowerEventCode,
  30. ACCESSTYPE anACCESSTYPE)
  31. : StateSensor(aParent,aCommController, aSensorCode, anACCESSTYPE)
  32. {
  33. theUpperEventCode = anUpperEventCode;
  34. theLowerEventCode = aLowerEventCode;
  35. // Disable validation checking until the sensor value
  36. // is initialized
  37. theValidationCheckingEnabled = 0;
  38. }
  39. INT ChangeSensor::Validate(INT aCode, const PCHAR aValue)
  40. {
  41. INT err = StateSensor::Validate(aCode, aValue);
  42. if (theValidationCheckingEnabled)
  43. {
  44. if (err != ErrNO_STATE_CHANGE )
  45. {
  46. PEvent change_event;
  47. // Check for a positive change
  48. if (strcmp(aValue, theValue) > 0)
  49. {
  50. change_event = new Event(theUpperEventCode, "");
  51. }
  52. // Otherwise the change must be negative
  53. else
  54. {
  55. change_event = new Event(theLowerEventCode, "");
  56. }
  57. theDevice->Update(change_event);
  58. delete change_event;
  59. change_event = NULL;
  60. }
  61. }
  62. else
  63. {
  64. // Enable validation checking once the sensor value
  65. // has been initialized
  66. theValidationCheckingEnabled = 1;
  67. }
  68. return err;
  69. }