No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 
 

285 líneas
11 KiB

  1. #ifndef __SEAMAX_H__
  2. #define __SEAMAX_H__
  3. #ifdef LINUX
  4. #include "wincompat.h"
  5. #endif
  6. typedef void *LPVOID;
  7. #define SM_HANDLE void*
  8. #define SME_HANDLE void*
  9. #define SDL_HANDLE void*
  10. /// \page Enumerations Global Types and Enumerations.
  11. /// Listed here are the types, enumerations, and definitions used throughout the %SeaMAX library.
  12. ///
  13. /// \section semax_enumerations SeaMAX Enumerations
  14. ///
  15. /// \subsection sm_deviceconfig DeviceConfig
  16. /// \code
  17. typedef struct configuration
  18. {
  19. int model;
  20. int commType;
  21. int baudrate;
  22. int parity;
  23. int firmware;
  24. } DeviceConfig;
  25. /// \endcode
  26. extern "C"
  27. {
  28. extern int __stdcall SM_Version(int* major, int* minor, int* revision, int* build);
  29. extern int __stdcall SM_Open(SM_HANDLE* handle, char* connection);
  30. extern int __stdcall SM_ConfigureSerialConnection(SM_HANDLE handle, int baudrate, int parity);
  31. extern int __stdcall SM_ConfigureSerialTimeouts(SM_HANDLE handle, int multiple, int constant, int interval);
  32. extern int __stdcall SM_SelectDevice(SM_HANDLE handle, int slaveID);
  33. extern int __stdcall SM_GetDeviceConfig(SM_HANDLE handle, DeviceConfig* config);
  34. extern int __stdcall SM_Close(SM_HANDLE handle);
  35. extern int __stdcall SM_GetAnalogInputConfig(SM_HANDLE handle, unsigned char* reference, unsigned char* mode);
  36. extern int __stdcall SM_GetAnalogInputRanges(SM_HANDLE handle, unsigned char* ranges);
  37. extern int __stdcall SM_SetAnalogInputConfig(SM_HANDLE handle, unsigned char reference, unsigned char mode);
  38. extern int __stdcall SM_SetAnalogInputRanges(SM_HANDLE handle, unsigned char* ranges);
  39. extern int __stdcall SM_GetAnalogOutputRanges(SM_HANDLE handle, unsigned char* ranges);
  40. extern int __stdcall SM_GetPIOPresets(SM_HANDLE handle, unsigned char* config);
  41. extern int __stdcall SM_SetPIOPresets(SM_HANDLE handle, unsigned char* config);
  42. extern int __stdcall SM_GetPIODirection(SM_HANDLE handle, unsigned char* config);
  43. extern int __stdcall SM_SetPIODirection(SM_HANDLE handle, unsigned char* config);
  44. extern int __stdcall SM_ReadPIO(SM_HANDLE handle, unsigned char* values);
  45. extern int __stdcall SM_WritePIO(SM_HANDLE handle, unsigned char* values);
  46. extern int __stdcall SM_SetCommunications(SM_HANDLE handle, int baudrate, int parity);
  47. extern int __stdcall SM_SetSoftwareAddress(SM_HANDLE handle, int slaveID);
  48. extern int __stdcall SM_ReadDigitalInputs(SM_HANDLE handle, int start, int number, unsigned char *values);
  49. extern int __stdcall SM_ReadAnalogInputs(SM_HANDLE handle, int start, int number, double* analogValues, unsigned char* ranges, unsigned char *byteValues);
  50. extern int __stdcall SM_WriteDigitalOutputs(SM_HANDLE handle, int start, int number, unsigned char *values);
  51. extern int __stdcall SM_ReadDigitalOutputs(SM_HANDLE handle, int start, int number, unsigned char *values);
  52. extern int __stdcall SM_WriteAnalogOutputs(SM_HANDLE handle, int start, int number, double* analogValues, unsigned char* ranges, unsigned char *byteValues);
  53. extern int __stdcall SM_SetBridgeType(SM_HANDLE handle, int bridgeType);
  54. // Customer specific methods (Oncology Inc.)
  55. extern int __stdcall SM_GlobalCommsReset(SM_HANDLE handle);
  56. #ifndef LINUX
  57. extern int __stdcall SM_NotifyInputState(SM_HANDLE handle, int cancel);
  58. extern int __stdcall SM_NotifyOnInputChange(SM_HANDLE handle, int start, int number, unsigned char* values, int delay, int blocking);
  59. #endif
  60. // Deprecated Functions
  61. extern int __stdcall SM_GetConfig(SM_HANDLE handle, int* model, int* commType, int* baudrate, int* parity);
  62. extern int __stdcall SM_ReadDiscreteInputs(SM_HANDLE handle, int start, int number, unsigned char *values);
  63. extern int __stdcall SM_ReadHoldingRegisters(SM_HANDLE handle, int start, int number, unsigned char *values);
  64. extern int __stdcall SM_ReadInputRegisters(SM_HANDLE handle, int start, int number, unsigned char *values);
  65. extern int __stdcall SM_WriteCoils(SM_HANDLE handle, int start, int number, unsigned char *values);
  66. extern int __stdcall SM_ReadCoils(SM_HANDLE handle, int start, int number, unsigned char *values);
  67. extern int __stdcall SM_WriteHoldingRegisters(SM_HANDLE handle, int start, int number, unsigned char *values);
  68. extern int __stdcall SM_GetADDAExtendedConfig(SM_HANDLE handle, int* multiplierEnabled, unsigned char* daConfig);
  69. extern int __stdcall SM_SetADDAConfig(SM_HANDLE handle, unsigned char* deviceConfig, unsigned char* channelsConfig);
  70. extern int __stdcall SM_GetADDAConfig(SM_HANDLE handle, unsigned char* deviceConfig, unsigned char* channelsConfig);
  71. extern int __stdcall SM_AtoDConversion(SM_HANDLE handle, double *value, unsigned char *data, int channelRange);
  72. extern int __stdcall SM_DtoAConversion(SM_HANDLE handle, double value, unsigned char *data, int channelRange);
  73. extern int __stdcall SME_Initialize(SME_HANDLE* handle);
  74. extern int __stdcall SME_Cleanup(SME_HANDLE handle);
  75. extern int __stdcall SME_SearchForModules(SME_HANDLE handle);
  76. extern int __stdcall SME_FirstModule(SME_HANDLE handle);
  77. extern int __stdcall SME_NextModule(SME_HANDLE handle);
  78. extern int __stdcall SME_Ping(SME_HANDLE handle);
  79. extern int __stdcall SME_ModuleByName(SME_HANDLE handle, char* moduleName);
  80. extern int __stdcall SME_ModuleByIP(SME_HANDLE handle, char* ipAddress);
  81. extern int __stdcall SME_ModuleByMAC(SME_HANDLE handle, char* mac);
  82. extern int __stdcall SME_ModuleCount(SME_HANDLE handle);
  83. extern int __stdcall SME_GetName(SME_HANDLE handle, char* moduleName);
  84. extern int __stdcall SME_GetNetworkConfig(SME_HANDLE handle, char* ipAddress, char* netmask, char* gateway);
  85. extern int __stdcall SME_GetNetworkConfigBytes(SME_HANDLE handle, unsigned char* ipAddress, unsigned char* netmask, unsigned char* gateway);
  86. extern int __stdcall SME_GetMACAddress(SME_HANDLE handle, char* address);
  87. extern int __stdcall SME_GetDHCPConfig(SME_HANDLE handle, int* status);
  88. extern int __stdcall SME_GetType(SME_HANDLE handle, char* type);
  89. extern int __stdcall SME_GetFirmwareVersion(SME_HANDLE handle, int* major, int* minor);
  90. extern int __stdcall SME_GetNetworkSerialParams(SME_HANDLE handle, int* baudrate, int* parity);
  91. extern int __stdcall SME_SetName(SME_HANDLE handle, char *name);
  92. extern int __stdcall SME_SetNetworkConfig(SME_HANDLE handle, char* ipAddress, char* netmask, char* gateway);
  93. extern int __stdcall SME_SetNetworkConfigBytes(SME_HANDLE handle, unsigned char* ipAddress, unsigned char* netmask, unsigned char* gateway);
  94. extern int __stdcall SME_SetDHCPConfig(SME_HANDLE handle, int status);
  95. extern int __stdcall SME_RebootModule(SME_HANDLE handle);
  96. extern int __stdcall SME_SetNetworkSerialParams(SME_HANDLE handle, int baudrate, int parity);
  97. extern int __stdcall SME_GetNetworkSerialParams(SME_HANDLE handle, int* baudrate, int* parity);
  98. extern int __stdcall SME_GetWirelessConfig(SME_HANDLE handle, int* network, char* SSID, int* channel, int* security, int* keyType);
  99. extern int __stdcall SME_SetWirelessConfig(SME_HANDLE handle, int network, char* SSID, int channel, int security, int keyType, char* key);
  100. extern int __stdcall SME_ARPAddress(SME_HANDLE handle, char* ipAddress);
  101. extern int __stdcall SME_IsReachable(SME_HANDLE handle);
  102. extern int __stdcall SDL_Initialize(SDL_HANDLE* handle);
  103. extern int __stdcall SDL_Cleanup(SDL_HANDLE handle);
  104. extern int __stdcall SDL_SearchForDevices(SDL_HANDLE handle);
  105. extern int __stdcall SDL_FirstDevice(SDL_HANDLE handle);
  106. extern int __stdcall SDL_NextDevice(SDL_HANDLE handle);
  107. extern int __stdcall SDL_DeviceCount(SDL_HANDLE handle);
  108. extern int __stdcall SDL_GetName(SDL_HANDLE handle, char* deviceName);
  109. extern int __stdcall SDL_GetModel(SDL_HANDLE handle, int* model);
  110. extern int __stdcall SDL_GetDeviceID(SDL_HANDLE handle, int* id);
  111. extern int __stdcall SDL_GetSerial(SDL_HANDLE handle, char* serialNumber);
  112. extern int __stdcall SDL_GetNameBySerial(SDL_HANDLE handle, char* serialNumber, char* deviceName);
  113. }
  114. #ifndef ENUMERATIONS
  115. #define ENUMERATIONS
  116. ///
  117. /// \page Enumerations
  118. /// \subsection sm_baudrates Baudrates
  119. ///
  120. /// \code
  121. enum
  122. {
  123. SM_BAUD_INVALID = 0,
  124. SM_BAUD_1200 = 1,
  125. SM_BAUD_2400 = 2,
  126. SM_BAUD_4800 = 3,
  127. SM_BAUD_9600 = 4,
  128. SM_BAUD_14400 = 5,
  129. SM_BAUD_19200 = 6,
  130. SM_BAUD_28800 = 7,
  131. SM_BAUD_38400 = 8,
  132. SM_BAUD_57600 = 9,
  133. SM_BAUD_115200 = 10
  134. };
  135. /// \endcode
  136. ///
  137. /// \page Enumerations
  138. /// \subsection sm_databits Databits
  139. /// \code
  140. enum
  141. {
  142. SM_DATABITS_5 = 5,
  143. SM_DATABITS_6 = 6,
  144. SM_DATABITS_7 = 7,
  145. SM_DATABITS_8 = 8
  146. };
  147. /// \endcode
  148. ///
  149. /// \page Enumerations
  150. /// \subsection sm_parity Parity
  151. /// \code
  152. enum
  153. {
  154. SM_PARITY_NONE = 0,
  155. SM_PARITY_ODD = 1,
  156. SM_PARITY_EVEN = 2,
  157. SM_PARITY_MARK = 3,
  158. SM_PARITY_SPACE = 4
  159. };
  160. /// \endcode
  161. ///
  162. /// \page Enumerations
  163. /// \subsection sm_stopbits Stopbits
  164. /// \code
  165. enum
  166. {
  167. SM_STOPBITS_1 = 0,
  168. SM_STOPBITS_1_5 = 1,
  169. SM_STOPBITS_2 = 2
  170. };
  171. /// \endcode
  172. ///
  173. /// \page Enumerations
  174. /// \subsection sm_comtype Communications Type
  175. /// \code
  176. enum
  177. {
  178. SM_COMTYPE_RS485 = 0,
  179. SM_COMTYPE_ETHERNET = 1,
  180. SM_COMTYPE_USB = 2,
  181. SM_COMTYPE_RS232 = 3,
  182. SM_COMTYPE_EXPANSION = 4,
  183. SM_COMTYPE_RS422 = 5,
  184. SM_COMTYPE_WIRELESS = 6,
  185. SM_COMTYPE_INTELLIGENT = 7,
  186. SM_COMTYPE_P_O_ETH = 8,
  187. SM_COMTYPE_P_O_USB = 9
  188. };
  189. /// \endcode
  190. ///
  191. /// \subsection ad_reference Analog to Digital Voltage Reference
  192. /// \code
  193. enum
  194. {
  195. ANALOG = 0,
  196. GROUND = 1,
  197. AD_REFERENCE = 2,
  198. FLOATING = 3,
  199. DA_CHANNEL_1 = 4,
  200. DA_CHANNEL_2 = 8
  201. };
  202. /// \endcode
  203. ///
  204. /// \subsection ad_channel_modes Analog to Digital Channel Modes
  205. /// \code
  206. enum
  207. {
  208. SINGLE_ENDED = 0,
  209. DIFFERENTIAL = 1,
  210. CURRENT_LOOP = 2
  211. };
  212. /// \endcode
  213. ///
  214. /// \subsection channel_ranges Channel Range Values
  215. /// \code
  216. enum
  217. {
  218. ZERO_TO_FIVE = 0,
  219. PLUS_MINUS_FIVE = 1,
  220. ZERO_TO_TEN = 2,
  221. PLUS_MINUS_TEN = 3,
  222. ZERO_TO_FIFTEEN = 2,
  223. PLUS_MINUS_FIFTEEN = 3
  224. };
  225. /// \endcode
  226. ///
  227. /// \section sme_enumerations SeaMAX Ethernet Enumerations
  228. ///
  229. /// \subsection network_types Network Types
  230. /// \code
  231. enum
  232. {
  233. NETWORK_INFRASTRUCTURE = 0,
  234. NETWORK_ADHOC = 1
  235. };
  236. /// \endcode
  237. ///
  238. /// \subsection security_enum Security Type
  239. /// \code
  240. enum
  241. {
  242. SECURITY_NONE = 0,
  243. SECURITY_WEP_OPEN_64 = 1,
  244. SECURITY_WEP_SHARED_64 = 2,
  245. SECURITY_WEP_OPEN_128 = 3,
  246. SECURITY_WEP_SHARED_128 = 4,
  247. SECURITY_WPA_TKIP = 5,
  248. SECURITY_WPA2_AES = 6,
  249. SECURITY_UNKNOWN = 0xFF
  250. };
  251. /// \endcode
  252. ///
  253. /// \subsection seckey_enum Key Type
  254. /// \code
  255. enum
  256. {
  257. HEX_KEY = 0,
  258. PASSPHRASE_KEY = 1
  259. };
  260. /// \endcode
  261. #endif
  262. #endif