Old fashion design for PC-104
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.

106 lines
3.1 KiB

4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. //----------------------------------------------------------------------------
  2. // Laser Guard Ltd.
  3. // Copyright � 2000-2002. All Rights Reserved.
  4. // Version 1.0 01/01/2000
  5. // Last modification: 08/10/2003
  6. // PROJECT:
  7. // SUBSYSTEM:
  8. // FILE: LgNetMessageGPIO.cpp
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Source file of LgNetMessageGPIO.cpp
  13. //----------------------------------------------------------------------------
  14. #include "stdafx.h"
  15. #include "LgNetMessageGPIO.h"
  16. #include "..\Device\LgDeviceGPIO.h"
  17. // commands
  18. BOOL CLgNetMessageGPIO::BuildCmdGetOutput( INT nOutput )
  19. {
  20. CLgDeviceGPIO::GPIO_PIN output;
  21. output.nIndex = nOutput;
  22. output.bOn = 0;
  23. return Build( CLgDeviceGPIO::CMD_GET_OUTPUT, &output, sizeof(output) );
  24. }
  25. BOOL CLgNetMessageGPIO::BuildCmdGetOutputAll()
  26. {
  27. return Build( CLgDeviceGPIO::CMD_GET_OUTPUT_ALL );
  28. }
  29. BOOL CLgNetMessageGPIO::BuildCmdSetOutput( INT nOutput, BOOL bOn )
  30. {
  31. CLgDeviceGPIO::GPIO_PIN output;
  32. output.nIndex = nOutput;
  33. output.bOn = bOn;
  34. return Build( CLgDeviceGPIO::CMD_SET_OUTPUT, &output, sizeof( output ) );
  35. }
  36. BOOL CLgNetMessageGPIO::BuildCmdGetInput( INT nInput )
  37. {
  38. CLgDeviceGPIO::GPIO_PIN input;
  39. input.nIndex = nInput;
  40. input.bOn = 0;
  41. return Build( CLgDeviceGPIO::CMD_GET_INPUT, &nInput, sizeof(nInput) );
  42. }
  43. BOOL CLgNetMessageGPIO::BuildCmdGetInputAll()
  44. {
  45. return Build( CLgDeviceGPIO::CMD_GET_INPUT_ALL );
  46. }
  47. // events
  48. BOOL CLgNetMessageGPIO::BuildEvtSetOutput( INT nOutput, BOOL bOn )
  49. {
  50. CLgDeviceGPIO::GPIO_PIN output;
  51. output.nIndex = nOutput;
  52. output.bOn = bOn;
  53. return Build( CLgDeviceGPIO::EVT_SET_OUTPUT, &output, sizeof( output ) );
  54. }
  55. BOOL CLgNetMessageGPIO::BuildEvtGetOutput( INT nOutput, BOOL bOn )
  56. {
  57. CLgDeviceGPIO::GPIO_PIN output;
  58. output.nIndex = nOutput;
  59. output.bOn = bOn;
  60. return Build( CLgDeviceGPIO::EVT_GET_OUTPUT, &output, sizeof( output ) );
  61. }
  62. BOOL CLgNetMessageGPIO::BuildEvtGetOutputAll( CLgDeviceGPIO::PGPIO_PINS pPins )
  63. {
  64. return Build( CLgDeviceGPIO::EVT_GET_OUTPUT_ALL, pPins, sizeof(CLgDeviceGPIO::GPIO_PINS) + ( pPins->nCount ? pPins->nCount - 1 : 0 ) * sizeof(CLgDeviceGPIO::GPIO_PIN) );
  65. }
  66. BOOL CLgNetMessageGPIO::BuildEvtGetInput( INT nInput, BOOL bOn )
  67. {
  68. CLgDeviceGPIO::GPIO_PIN input;
  69. input.nIndex = nInput;
  70. input.bOn = bOn;
  71. return Build( CLgDeviceGPIO::EVT_GET_INPUT, &input, sizeof( input ) );
  72. }
  73. BOOL CLgNetMessageGPIO::BuildEvtGetInputAll( CLgDeviceGPIO::PGPIO_PINS pPins )
  74. {
  75. return Build( CLgDeviceGPIO::EVT_GET_INPUT_ALL, pPins, sizeof(CLgDeviceGPIO::GPIO_PINS) + ( pPins->nCount ? pPins->nCount - 1 : 0 ) * sizeof(CLgDeviceGPIO::GPIO_PIN) );
  76. }
  77. BOOL CLgNetMessageGPIO::BuildEvtInputChange( INT nInput, BOOL bOn )
  78. {
  79. CLgDeviceGPIO::GPIO_PIN input;
  80. input.nIndex = nInput;
  81. input.bOn = bOn;
  82. return Build( CLgDeviceGPIO::EVT_INPUT_CHANGE, &input, sizeof( input ) );
  83. }
  84. CLgDeviceGPIO::PGPIO_PINS CLgNetMessageGPIO::GetInputPins()
  85. {
  86. if( !CLgNetMessage::GetData() || CLgNetMessage::GetDataCount() < sizeof(CLgDeviceGPIO::GPIO_PINS) )
  87. return NULL;
  88. PBYTE pData = (PBYTE)CLgNetMessage::GetData();
  89. return (CLgDeviceGPIO::PGPIO_PINS)&pData[1];
  90. }