2
0

app_data.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /*********************************************************************
  2. * _ _ _
  3. * _ __ | |_ _ | | __ _ | |__ ___
  4. * | '__|| __|(_)| | / _` || '_ \ / __|
  5. * | | | |_ _ | || (_| || |_) |\__ \
  6. * |_| \__|(_)|_| \__,_||_.__/ |___/
  7. *
  8. * www.rt-labs.com
  9. * Copyright 2018 rt-labs AB, Sweden.
  10. *
  11. * This software is dual-licensed under GPLv3 and a commercial
  12. * license. See the file LICENSE.md distributed with this software for
  13. * full license information.
  14. ********************************************************************/
  15. #ifndef APP_DATA_H
  16. #define APP_DATA_H
  17. /**
  18. * @file
  19. * @brief Sample application data interface
  20. *
  21. * Functions for:
  22. * - Getting input data (Button 1 and counter value)
  23. * - Setting output data (LED 1)
  24. * - Setting default output state. This should be
  25. * part of all device implementations for setting
  26. * defined state when device is not connected to PLC
  27. * - Reading and writing parameters
  28. */
  29. #ifdef __cplusplus
  30. extern "C" {
  31. #endif
  32. #include <stdint.h>
  33. #include <stdbool.h>
  34. /**
  35. * Get application specific PNIO input data (for sending to PLC)
  36. *
  37. * The main sample application keeps track
  38. * of button so it is a parameter to this function.
  39. *
  40. * This function is not called for the DAP submodules (slot_nbr==0).
  41. *
  42. * @param slot_nbr In: Slot number
  43. * @param subslot_nbr In: Subslot number
  44. * @param submodule_id In: Submodule id
  45. * @param button_state In: State of button 1
  46. * @param size Out: Size of pnio data.
  47. * Not modified on error.
  48. * @param iops Out: Provider status. If for example
  49. * a sensor is failing or a short
  50. * circuit is detected on digital
  51. * input this shall be set to BAD.
  52. * Not modified on error.
  53. * @return Reference to PNIO data, NULL on error
  54. */
  55. uint8_t * app_data_get_input_data (
  56. uint16_t slot_nbr,
  57. uint16_t subslot_nbr,
  58. uint32_t submodule_id,
  59. bool button_state,
  60. uint16_t * size,
  61. uint8_t * iops);
  62. /**
  63. * Set application specific PNIO output data (received from PLC)
  64. *
  65. * This function is not called for the DAP submodules (slot_nbr==0).
  66. *
  67. * @param slot_nbr In: Slot number
  68. * @param subslot_nbr In: Subslot number
  69. * @param submodule_id In: Submodule id
  70. * @param data In: Reference to output data
  71. * @param size In: Length of output data
  72. * @return 0 on success, -1 on error
  73. */
  74. int app_data_set_output_data (
  75. uint16_t slot_nbr,
  76. uint16_t subslot_nbr,
  77. uint32_t submodule_id,
  78. uint8_t * data,
  79. uint16_t size);
  80. /**
  81. * Set default outputs for all subslots.
  82. *
  83. * For the sample application this means that
  84. * LED 1 is turned off.
  85. *
  86. * @return 0 on success, -1 on error
  87. */
  88. int app_data_set_default_outputs (void);
  89. /**
  90. * Write parameter index for a subslot
  91. *
  92. * @param slot_nbr In: Slot number
  93. * @param subslot_nbr In: Subslot number
  94. * @param submodule_id In: Submodule id
  95. * @param index In: Parameter index
  96. * @param data In: New parameter value
  97. * @param write_length In: Length of parameter data
  98. * @return 0 on success, -1 on error
  99. */
  100. int app_data_write_parameter (
  101. uint16_t slot_nbr,
  102. uint16_t subslot_nbr,
  103. uint32_t submodule_id,
  104. uint32_t index,
  105. const uint8_t * data,
  106. uint16_t write_length);
  107. /**
  108. * Read parameter index from a subslot
  109. *
  110. * @param slot_nbr In: Slot number
  111. * @param subslot_nbr In: Subslot number
  112. * @param submodule_id In: Submodule id
  113. * @param index In: Parameter index
  114. * @param data In: Reference to parameter data
  115. * @param length InOut: The maximum (in) and actual (out) length in
  116. * bytes of the data.
  117. * @return 0 on success, -1 on error
  118. */
  119. int app_data_read_parameter (
  120. uint16_t slot_nbr,
  121. uint16_t subslot_nbr,
  122. uint32_t submodule_id,
  123. uint32_t index,
  124. uint8_t ** data,
  125. uint16_t * length);
  126. #ifdef __cplusplus
  127. }
  128. #endif
  129. #endif /* APP_DATA_H */