snap7.h 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957
  1. /*=============================================================================|
  2. | PROJECT SNAP7 1.4.0 |
  3. |==============================================================================|
  4. | Copyright (C) 2013, 2014 Davide Nardella |
  5. | All rights reserved. |
  6. |==============================================================================|
  7. | SNAP7 is free software: you can redistribute it and/or modify |
  8. | it under the terms of the Lesser GNU General Public License as published by |
  9. | the Free Software Foundation, either version 3 of the License, or |
  10. | (at your option) any later version. |
  11. | |
  12. | It means that you can distribute your commercial software linked with |
  13. | SNAP7 without the requirement to distribute the source code of your |
  14. | application and without the requirement that your application be itself |
  15. | distributed under LGPL. |
  16. | |
  17. | SNAP7 is distributed in the hope that it will be useful, |
  18. | but WITHOUT ANY WARRANTY; without even the implied warranty of |
  19. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
  20. | Lesser GNU General Public License for more details. |
  21. | |
  22. | You should have received a copy of the GNU General Public License and a |
  23. | copy of Lesser GNU General Public License along with Snap7. |
  24. | If not, see http://www.gnu.org/licenses/ |
  25. |==============================================================================|
  26. | |
  27. | C/C++ Snap 7 classes/Imports definitions |
  28. | |
  29. |=============================================================================*/
  30. #ifndef snap7_h
  31. #define snap7_h
  32. //---------------------------------------------------------------------------
  33. // Platform detection
  34. //---------------------------------------------------------------------------
  35. #if defined (_WIN32)||defined(_WIN64)||defined(__WIN32__)||defined(__WINDOWS__)
  36. # define OS_WINDOWS
  37. #endif
  38. // Visual Studio needs this to use the correct time_t size
  39. #if defined (_WIN32) && !defined(_WIN64)
  40. # define _USE_32BIT_TIME_T
  41. #endif
  42. #if defined(unix) || defined(__unix__) || defined(__unix)
  43. # define PLATFORM_UNIX
  44. #endif
  45. #if defined(__SVR4) || defined(__svr4__)
  46. # define OS_SOLARIS
  47. #endif
  48. #if BSD>=0
  49. # define OS_BSD
  50. #endif
  51. #if defined(__APPLE__)
  52. # define OS_OSX
  53. #endif
  54. #if defined(PLATFORM_UNIX) || defined(OS_OSX)
  55. # include <unistd.h>
  56. # if defined(_POSIX_VERSION)
  57. # define POSIX
  58. # endif
  59. #endif
  60. //---------------------------------------------------------------------------
  61. // C++ Library
  62. //---------------------------------------------------------------------------
  63. #ifdef __cplusplus
  64. #include <string>
  65. #include <time.h>
  66. // Visual C++ not C99 compliant (VS2008--)
  67. #ifdef _MSC_VER
  68. # if _MSC_VER >= 1600
  69. # include <stdint.h> // VS2010++ have it
  70. # else
  71. typedef signed __int8 int8_t;
  72. typedef signed __int16 int16_t;
  73. typedef signed __int32 int32_t;
  74. typedef signed __int64 int64_t;
  75. typedef unsigned __int8 uint8_t;
  76. typedef unsigned __int16 uint16_t;
  77. typedef unsigned __int32 uint32_t;
  78. typedef unsigned __int64 uint64_t;
  79. #ifdef _WIN64
  80. typedef unsigned __int64 uintptr_t;
  81. #else
  82. typedef unsigned __int32 uintptr_t;
  83. #endif
  84. # endif
  85. #else
  86. # include <stdint.h>
  87. #endif
  88. extern "C" {
  89. #endif
  90. //---------------------------------------------------------------------------
  91. // C exact length types
  92. //---------------------------------------------------------------------------
  93. #ifndef __cplusplus
  94. #ifdef OS_BSD
  95. # include <stdint.h>
  96. # include <time.h>
  97. #endif
  98. #ifdef OS_OSX
  99. # include <stdint.h>
  100. # include <time.h>
  101. #endif
  102. #ifdef OS_SOLARIS
  103. # include <stdint.h>
  104. # include <time.h>
  105. #endif
  106. #if defined(_UINTPTR_T_DEFINED)
  107. # include <stdint.h>
  108. # include <time.h>
  109. #endif
  110. #if !defined(_UINTPTR_T_DEFINED) && !defined(OS_SOLARIS) && !defined(OS_BSD) && !defined(OS_OSX)
  111. typedef unsigned char uint8_t; // 8 bit unsigned integer
  112. typedef unsigned short uint16_t; // 16 bit unsigned integer
  113. typedef unsigned int uint32_t; // 32 bit unsigned integer
  114. typedef unsigned long uintptr_t;// 64 bit unsigned integer
  115. #endif
  116. #endif
  117. #ifdef OS_WINDOWS
  118. # define S7API __stdcall
  119. #else
  120. # define S7API
  121. #endif
  122. #pragma pack(1)
  123. //******************************************************************************
  124. // COMMON
  125. //******************************************************************************
  126. // Exact length types regardless of platform/processor
  127. typedef uint8_t byte;
  128. typedef uint16_t word;
  129. typedef uint32_t longword;
  130. typedef byte *pbyte;
  131. typedef word *pword;
  132. typedef uintptr_t S7Object; // multi platform/processor object reference
  133. // DON'T CONFUSE IT WITH AN OLE OBJECT, IT'S SIMPLY
  134. // AN INTEGER VALUE (32 OR 64 BIT) USED AS HANDLE.
  135. #ifndef __cplusplus
  136. typedef struct
  137. {
  138. int tm_sec;
  139. int tm_min;
  140. int tm_hour;
  141. int tm_mday;
  142. int tm_mon;
  143. int tm_year;
  144. int tm_wday;
  145. int tm_yday;
  146. int tm_isdst;
  147. }tm;
  148. typedef int bool;
  149. #define false 0;
  150. #define true 1;
  151. #endif
  152. const int errLibInvalidParam = -1;
  153. const int errLibInvalidObject = -2;
  154. // CPU status
  155. #define S7CpuStatusUnknown 0x00
  156. #define S7CpuStatusRun 0x08
  157. #define S7CpuStatusStop 0x04
  158. // ISO Errors
  159. const longword errIsoConnect = 0x00010000; // Connection error
  160. const longword errIsoDisconnect = 0x00020000; // Disconnect error
  161. const longword errIsoInvalidPDU = 0x00030000; // Bad format
  162. const longword errIsoInvalidDataSize = 0x00040000; // Bad Datasize passed to send/recv buffer is invalid
  163. const longword errIsoNullPointer = 0x00050000; // Null passed as pointer
  164. const longword errIsoShortPacket = 0x00060000; // A short packet received
  165. const longword errIsoTooManyFragments = 0x00070000; // Too many packets without EoT flag
  166. const longword errIsoPduOverflow = 0x00080000; // The sum of fragments data exceded maximum packet size
  167. const longword errIsoSendPacket = 0x00090000; // An error occurred during send
  168. const longword errIsoRecvPacket = 0x000A0000; // An error occurred during recv
  169. const longword errIsoInvalidParams = 0x000B0000; // Invalid TSAP params
  170. const longword errIsoResvd_1 = 0x000C0000; // Unassigned
  171. const longword errIsoResvd_2 = 0x000D0000; // Unassigned
  172. const longword errIsoResvd_3 = 0x000E0000; // Unassigned
  173. const longword errIsoResvd_4 = 0x000F0000; // Unassigned
  174. // Tag Struct
  175. typedef struct{
  176. int Area;
  177. int DBNumber;
  178. int Start;
  179. int Size;
  180. int WordLen;
  181. }TS7Tag, *PS7Tag;
  182. //------------------------------------------------------------------------------
  183. // PARAMS LIST
  184. //------------------------------------------------------------------------------
  185. const int p_u16_LocalPort = 1;
  186. const int p_u16_RemotePort = 2;
  187. const int p_i32_PingTimeout = 3;
  188. const int p_i32_SendTimeout = 4;
  189. const int p_i32_RecvTimeout = 5;
  190. const int p_i32_WorkInterval = 6;
  191. const int p_u16_SrcRef = 7;
  192. const int p_u16_DstRef = 8;
  193. const int p_u16_SrcTSap = 9;
  194. const int p_i32_PDURequest = 10;
  195. const int p_i32_MaxClients = 11;
  196. const int p_i32_BSendTimeout = 12;
  197. const int p_i32_BRecvTimeout = 13;
  198. const int p_u32_RecoveryTime = 14;
  199. const int p_u32_KeepAliveTime = 15;
  200. // Client/Partner Job status
  201. const int JobComplete = 0;
  202. const int JobPending = 1;
  203. //******************************************************************************
  204. // CLIENT
  205. //******************************************************************************
  206. // Error codes
  207. const longword errNegotiatingPDU = 0x00100000;
  208. const longword errCliInvalidParams = 0x00200000;
  209. const longword errCliJobPending = 0x00300000;
  210. const longword errCliTooManyItems = 0x00400000;
  211. const longword errCliInvalidWordLen = 0x00500000;
  212. const longword errCliPartialDataWritten = 0x00600000;
  213. const longword errCliSizeOverPDU = 0x00700000;
  214. const longword errCliInvalidPlcAnswer = 0x00800000;
  215. const longword errCliAddressOutOfRange = 0x00900000;
  216. const longword errCliInvalidTransportSize = 0x00A00000;
  217. const longword errCliWriteDataSizeMismatch = 0x00B00000;
  218. const longword errCliItemNotAvailable = 0x00C00000;
  219. const longword errCliInvalidValue = 0x00D00000;
  220. const longword errCliCannotStartPLC = 0x00E00000;
  221. const longword errCliAlreadyRun = 0x00F00000;
  222. const longword errCliCannotStopPLC = 0x01000000;
  223. const longword errCliCannotCopyRamToRom = 0x01100000;
  224. const longword errCliCannotCompress = 0x01200000;
  225. const longword errCliAlreadyStop = 0x01300000;
  226. const longword errCliFunNotAvailable = 0x01400000;
  227. const longword errCliUploadSequenceFailed = 0x01500000;
  228. const longword errCliInvalidDataSizeRecvd = 0x01600000;
  229. const longword errCliInvalidBlockType = 0x01700000;
  230. const longword errCliInvalidBlockNumber = 0x01800000;
  231. const longword errCliInvalidBlockSize = 0x01900000;
  232. const longword errCliDownloadSequenceFailed = 0x01A00000;
  233. const longword errCliInsertRefused = 0x01B00000;
  234. const longword errCliDeleteRefused = 0x01C00000;
  235. const longword errCliNeedPassword = 0x01D00000;
  236. const longword errCliInvalidPassword = 0x01E00000;
  237. const longword errCliNoPasswordToSetOrClear = 0x01F00000;
  238. const longword errCliJobTimeout = 0x02000000;
  239. const longword errCliPartialDataRead = 0x02100000;
  240. const longword errCliBufferTooSmall = 0x02200000;
  241. const longword errCliFunctionRefused = 0x02300000;
  242. const longword errCliDestroying = 0x02400000;
  243. const longword errCliInvalidParamNumber = 0x02500000;
  244. const longword errCliCannotChangeParam = 0x02600000;
  245. const int MaxVars = 20; // Max vars that can be transferred with MultiRead/MultiWrite
  246. // Client Connection Type
  247. const word CONNTYPE_PG = 0x0001; // Connect to the PLC as a PG
  248. const word CONNTYPE_OP = 0x0002; // Connect to the PLC as an OP
  249. const word CONNTYPE_BASIC = 0x0003; // Basic connection
  250. // Area ID
  251. const byte S7AreaPE = 0x81;
  252. const byte S7AreaPA = 0x82;
  253. const byte S7AreaMK = 0x83;
  254. const byte S7AreaDB = 0x84;
  255. const byte S7AreaCT = 0x1C;
  256. const byte S7AreaTM = 0x1D;
  257. // Word Length
  258. const int S7WLBit = 0x01;
  259. const int S7WLByte = 0x02;
  260. const int S7WLWord = 0x04;
  261. const int S7WLDWord = 0x06;
  262. const int S7WLReal = 0x08;
  263. const int S7WLCounter = 0x1C;
  264. const int S7WLTimer = 0x1D;
  265. // Block type
  266. const byte Block_OB = 0x38;
  267. const byte Block_DB = 0x41;
  268. const byte Block_SDB = 0x42;
  269. const byte Block_FC = 0x43;
  270. const byte Block_SFC = 0x44;
  271. const byte Block_FB = 0x45;
  272. const byte Block_SFB = 0x46;
  273. // Sub Block Type
  274. const byte SubBlk_OB = 0x08;
  275. const byte SubBlk_DB = 0x0A;
  276. const byte SubBlk_SDB = 0x0B;
  277. const byte SubBlk_FC = 0x0C;
  278. const byte SubBlk_SFC = 0x0D;
  279. const byte SubBlk_FB = 0x0E;
  280. const byte SubBlk_SFB = 0x0F;
  281. // Block languages
  282. const byte BlockLangAWL = 0x01;
  283. const byte BlockLangKOP = 0x02;
  284. const byte BlockLangFUP = 0x03;
  285. const byte BlockLangSCL = 0x04;
  286. const byte BlockLangDB = 0x05;
  287. const byte BlockLangGRAPH = 0x06;
  288. // Read/Write Multivars
  289. typedef struct{
  290. int Area;
  291. int WordLen;
  292. int Result;
  293. int DBNumber;
  294. int Start;
  295. int Amount;
  296. void *pdata;
  297. } TS7DataItem, *PS7DataItem;
  298. //typedef int TS7ResultItems[MaxVars];
  299. //typedef TS7ResultItems *PS7ResultItems;
  300. // List Blocks
  301. typedef struct {
  302. int OBCount;
  303. int FBCount;
  304. int FCCount;
  305. int SFBCount;
  306. int SFCCount;
  307. int DBCount;
  308. int SDBCount;
  309. } TS7BlocksList, *PS7BlocksList;
  310. // Blocks info
  311. typedef struct {
  312. int BlkType; // Block Type (OB, DB)
  313. int BlkNumber; // Block number
  314. int BlkLang; // Block Language
  315. int BlkFlags; // Block flags
  316. int MC7Size; // The real size in bytes
  317. int LoadSize; // Load memory size
  318. int LocalData; // Local data
  319. int SBBLength; // SBB Length
  320. int CheckSum; // Checksum
  321. int Version; // Block version
  322. // Chars info
  323. char CodeDate[11]; // Code date
  324. char IntfDate[11]; // Interface date
  325. char Author[9]; // Author
  326. char Family[9]; // Family
  327. char Header[9]; // Header
  328. } TS7BlockInfo, *PS7BlockInfo ;
  329. typedef word TS7BlocksOfType[0x2000];
  330. typedef TS7BlocksOfType *PS7BlocksOfType;
  331. // Order code
  332. typedef struct {
  333. char Code[21];
  334. byte V1;
  335. byte V2;
  336. byte V3;
  337. } TS7OrderCode, *PS7OrderCode;
  338. // CPU Info
  339. typedef struct {
  340. char ModuleTypeName[33];
  341. char SerialNumber[25];
  342. char ASName[25];
  343. char Copyright[27];
  344. char ModuleName[25];
  345. } TS7CpuInfo, *PS7CpuInfo;
  346. // CP Info
  347. typedef struct {
  348. int MaxPduLengt;
  349. int MaxConnections;
  350. int MaxMpiRate;
  351. int MaxBusRate;
  352. } TS7CpInfo, *PS7CpInfo;
  353. // See §33.1 of "System Software for S7-300/400 System and Standard Functions"
  354. // and see SFC51 description too
  355. typedef struct {
  356. word LENTHDR;
  357. word N_DR;
  358. } SZL_HEADER, *PSZL_HEADER;
  359. typedef struct {
  360. SZL_HEADER Header;
  361. byte Data[0x4000-4];
  362. } TS7SZL, *PS7SZL;
  363. // SZL List of available SZL IDs : same as SZL but List items are big-endian adjusted
  364. typedef struct {
  365. SZL_HEADER Header;
  366. word List[0x2000-2];
  367. } TS7SZLList, *PS7SZLList;
  368. // See §33.19 of "System Software for S7-300/400 System and Standard Functions"
  369. typedef struct {
  370. word sch_schal;
  371. word sch_par;
  372. word sch_rel;
  373. word bart_sch;
  374. word anl_sch;
  375. } TS7Protection, *PS7Protection;
  376. // Client completion callback
  377. typedef void (S7API *pfn_CliCompletion) (void *usrPtr, int opCode, int opResult);
  378. //------------------------------------------------------------------------------
  379. // Import prototypes
  380. //------------------------------------------------------------------------------
  381. S7Object S7API Cli_Create();
  382. void S7API Cli_Destroy(S7Object *Client);
  383. int S7API Cli_ConnectTo(S7Object Client, const char *Address, int Rack, int Slot);
  384. int S7API Cli_SetConnectionParams(S7Object Client, const char *Address, word LocalTSAP, word RemoteTSAP);
  385. int S7API Cli_SetConnectionType(S7Object Client, word ConnectionType);
  386. int S7API Cli_Connect(S7Object Client);
  387. int S7API Cli_Disconnect(S7Object Client);
  388. int S7API Cli_GetParam(S7Object Client, int ParamNumber, void *pValue);
  389. int S7API Cli_SetParam(S7Object Client, int ParamNumber, void *pValue);
  390. int S7API Cli_SetAsCallback(S7Object Client, pfn_CliCompletion pCompletion, void *usrPtr);
  391. // Data I/O main functions
  392. int S7API Cli_ReadArea(S7Object Client, int Area, int DBNumber, int Start, int Amount, int WordLen, void *pUsrData);
  393. int S7API Cli_WriteArea(S7Object Client, int Area, int DBNumber, int Start, int Amount, int WordLen, void *pUsrData);
  394. int S7API Cli_ReadMultiVars(S7Object Client, PS7DataItem Item, int ItemsCount);
  395. int S7API Cli_WriteMultiVars(S7Object Client, PS7DataItem Item, int ItemsCount);
  396. // Data I/O Lean functions
  397. int S7API Cli_DBRead(S7Object Client, int DBNumber, int Start, int Size, void *pUsrData);
  398. int S7API Cli_DBWrite(S7Object Client, int DBNumber, int Start, int Size, void *pUsrData);
  399. int S7API Cli_MBRead(S7Object Client, int Start, int Size, void *pUsrData);
  400. int S7API Cli_MBWrite(S7Object Client, int Start, int Size, void *pUsrData);
  401. int S7API Cli_EBRead(S7Object Client, int Start, int Size, void *pUsrData);
  402. int S7API Cli_EBWrite(S7Object Client, int Start, int Size, void *pUsrData);
  403. int S7API Cli_ABRead(S7Object Client, int Start, int Size, void *pUsrData);
  404. int S7API Cli_ABWrite(S7Object Client, int Start, int Size, void *pUsrData);
  405. int S7API Cli_TMRead(S7Object Client, int Start, int Amount, void *pUsrData);
  406. int S7API Cli_TMWrite(S7Object Client, int Start, int Amount, void *pUsrData);
  407. int S7API Cli_CTRead(S7Object Client, int Start, int Amount, void *pUsrData);
  408. int S7API Cli_CTWrite(S7Object Client, int Start, int Amount, void *pUsrData);
  409. // Directory functions
  410. int S7API Cli_ListBlocks(S7Object Client, TS7BlocksList *pUsrData);
  411. int S7API Cli_GetAgBlockInfo(S7Object Client, int BlockType, int BlockNum, TS7BlockInfo *pUsrData);
  412. int S7API Cli_GetPgBlockInfo(S7Object Client, void *pBlock, TS7BlockInfo *pUsrData, int Size);
  413. int S7API Cli_ListBlocksOfType(S7Object Client, int BlockType, TS7BlocksOfType *pUsrData, int *ItemsCount);
  414. // Blocks functions
  415. int S7API Cli_Upload(S7Object Client, int BlockType, int BlockNum, void *pUsrData, int *Size);
  416. int S7API Cli_FullUpload(S7Object Client, int BlockType, int BlockNum, void *pUsrData, int *Size);
  417. int S7API Cli_Download(S7Object Client, int BlockNum, void *pUsrData, int Size);
  418. int S7API Cli_Delete(S7Object Client, int BlockType, int BlockNum);
  419. int S7API Cli_DBGet(S7Object Client, int DBNumber, void *pUsrData, int *Size);
  420. int S7API Cli_DBFill(S7Object Client, int DBNumber, int FillChar);
  421. // Date/Time functions
  422. int S7API Cli_GetPlcDateTime(S7Object Client, tm *DateTime);
  423. int S7API Cli_SetPlcDateTime(S7Object Client, tm *DateTime);
  424. int S7API Cli_SetPlcSystemDateTime(S7Object Client);
  425. // System Info functions
  426. int S7API Cli_GetOrderCode(S7Object Client, TS7OrderCode *pUsrData);
  427. int S7API Cli_GetCpuInfo(S7Object Client, TS7CpuInfo *pUsrData);
  428. int S7API Cli_GetCpInfo(S7Object Client, TS7CpInfo *pUsrData);
  429. int S7API Cli_ReadSZL(S7Object Client, int ID, int Index, TS7SZL *pUsrData, int *Size);
  430. int S7API Cli_ReadSZLList(S7Object Client, TS7SZLList *pUsrData, int *ItemsCount);
  431. // Control functions
  432. int S7API Cli_PlcHotStart(S7Object Client);
  433. int S7API Cli_PlcColdStart(S7Object Client);
  434. int S7API Cli_PlcStop(S7Object Client);
  435. int S7API Cli_CopyRamToRom(S7Object Client, int Timeout);
  436. int S7API Cli_Compress(S7Object Client, int Timeout);
  437. int S7API Cli_GetPlcStatus(S7Object Client, int *Status);
  438. // Security functions
  439. int S7API Cli_GetProtection(S7Object Client, TS7Protection *pUsrData);
  440. int S7API Cli_SetSessionPassword(S7Object Client, char *Password);
  441. int S7API Cli_ClearSessionPassword(S7Object Client);
  442. // Low level
  443. int S7API Cli_IsoExchangeBuffer(S7Object Client, void *pUsrData, int *Size);
  444. // Misc
  445. int S7API Cli_GetExecTime(S7Object Client, int *Time);
  446. int S7API Cli_GetLastError(S7Object Client, int *LastError);
  447. int S7API Cli_GetPduLength(S7Object Client, int *Requested, int *Negotiated);
  448. int S7API Cli_ErrorText(int Error, char *Text, int TextLen);
  449. // 1.1.0
  450. int S7API Cli_GetConnected(S7Object Client, int *Connected);
  451. //------------------------------------------------------------------------------
  452. // Async functions
  453. //------------------------------------------------------------------------------
  454. int S7API Cli_AsReadArea(S7Object Client, int Area, int DBNumber, int Start, int Amount, int WordLen, void *pUsrData);
  455. int S7API Cli_AsWriteArea(S7Object Client, int Area, int DBNumber, int Start, int Amount, int WordLen, void *pUsrData);
  456. int S7API Cli_AsDBRead(S7Object Client, int DBNumber, int Start, int Size, void *pUsrData);
  457. int S7API Cli_AsDBWrite(S7Object Client, int DBNumber, int Start, int Size, void *pUsrData);
  458. int S7API Cli_AsMBRead(S7Object Client, int Start, int Size, void *pUsrData);
  459. int S7API Cli_AsMBWrite(S7Object Client, int Start, int Size, void *pUsrData);
  460. int S7API Cli_AsEBRead(S7Object Client, int Start, int Size, void *pUsrData);
  461. int S7API Cli_AsEBWrite(S7Object Client, int Start, int Size, void *pUsrData);
  462. int S7API Cli_AsABRead(S7Object Client, int Start, int Size, void *pUsrData);
  463. int S7API Cli_AsABWrite(S7Object Client, int Start, int Size, void *pUsrData);
  464. int S7API Cli_AsTMRead(S7Object Client, int Start, int Amount, void *pUsrData);
  465. int S7API Cli_AsTMWrite(S7Object Client, int Start, int Amount, void *pUsrData);
  466. int S7API Cli_AsCTRead(S7Object Client, int Start, int Amount, void *pUsrData);
  467. int S7API Cli_AsCTWrite(S7Object Client, int Start, int Amount, void *pUsrData);
  468. int S7API Cli_AsListBlocksOfType(S7Object Client, int BlockType, TS7BlocksOfType *pUsrData, int *ItemsCount);
  469. int S7API Cli_AsReadSZL(S7Object Client, int ID, int Index, TS7SZL *pUsrData, int *Size);
  470. int S7API Cli_AsReadSZLList(S7Object Client, TS7SZLList *pUsrData, int *ItemsCount);
  471. int S7API Cli_AsUpload(S7Object Client, int BlockType, int BlockNum, void *pUsrData, int *Size);
  472. int S7API Cli_AsFullUpload(S7Object Client, int BlockType, int BlockNum, void *pUsrData, int *Size);
  473. int S7API Cli_AsDownload(S7Object Client, int BlockNum, void *pUsrData, int Size);
  474. int S7API Cli_AsCopyRamToRom(S7Object Client, int Timeout);
  475. int S7API Cli_AsCompress(S7Object Client, int Timeout);
  476. int S7API Cli_AsDBGet(S7Object Client, int DBNumber, void *pUsrData, int *Size);
  477. int S7API Cli_AsDBFill(S7Object Client, int DBNumber, int FillChar);
  478. int S7API Cli_CheckAsCompletion(S7Object Client, int *opResult);
  479. int S7API Cli_WaitAsCompletion(S7Object Client, int Timeout);
  480. //******************************************************************************
  481. // SERVER
  482. //******************************************************************************
  483. const int OperationRead = 0;
  484. const int OperationWrite = 1;
  485. const int mkEvent = 0;
  486. const int mkLog = 1;
  487. // Server Area ID (use with Register/unregister - Lock/unlock Area)
  488. const int srvAreaPE = 0;
  489. const int srvAreaPA = 1;
  490. const int srvAreaMK = 2;
  491. const int srvAreaCT = 3;
  492. const int srvAreaTM = 4;
  493. const int srvAreaDB = 5;
  494. // Errors
  495. const longword errSrvCannotStart = 0x00100000; // Server cannot start
  496. const longword errSrvDBNullPointer = 0x00200000; // Passed null as PData
  497. const longword errSrvAreaAlreadyExists = 0x00300000; // Area Re-registration
  498. const longword errSrvUnknownArea = 0x00400000; // Unknown area
  499. const longword errSrvInvalidParams = 0x00500000; // Invalid param(s) supplied
  500. const longword errSrvTooManyDB = 0x00600000; // Cannot register DB
  501. const longword errSrvInvalidParamNumber = 0x00700000; // Invalid param (srv_get/set_param)
  502. const longword errSrvCannotChangeParam = 0x00800000; // Cannot change because running
  503. // TCP Server Event codes
  504. const longword evcServerStarted = 0x00000001;
  505. const longword evcServerStopped = 0x00000002;
  506. const longword evcListenerCannotStart = 0x00000004;
  507. const longword evcClientAdded = 0x00000008;
  508. const longword evcClientRejected = 0x00000010;
  509. const longword evcClientNoRoom = 0x00000020;
  510. const longword evcClientException = 0x00000040;
  511. const longword evcClientDisconnected = 0x00000080;
  512. const longword evcClientTerminated = 0x00000100;
  513. const longword evcClientsDropped = 0x00000200;
  514. const longword evcReserved_00000400 = 0x00000400; // actually unused
  515. const longword evcReserved_00000800 = 0x00000800; // actually unused
  516. const longword evcReserved_00001000 = 0x00001000; // actually unused
  517. const longword evcReserved_00002000 = 0x00002000; // actually unused
  518. const longword evcReserved_00004000 = 0x00004000; // actually unused
  519. const longword evcReserved_00008000 = 0x00008000; // actually unused
  520. // S7 Server Event Code
  521. const longword evcPDUincoming = 0x00010000;
  522. const longword evcDataRead = 0x00020000;
  523. const longword evcDataWrite = 0x00040000;
  524. const longword evcNegotiatePDU = 0x00080000;
  525. const longword evcReadSZL = 0x00100000;
  526. const longword evcClock = 0x00200000;
  527. const longword evcUpload = 0x00400000;
  528. const longword evcDownload = 0x00800000;
  529. const longword evcDirectory = 0x01000000;
  530. const longword evcSecurity = 0x02000000;
  531. const longword evcControl = 0x04000000;
  532. const longword evcReserved_08000000 = 0x08000000; // actually unused
  533. const longword evcReserved_10000000 = 0x10000000; // actually unused
  534. const longword evcReserved_20000000 = 0x20000000; // actually unused
  535. const longword evcReserved_40000000 = 0x40000000; // actually unused
  536. const longword evcReserved_80000000 = 0x80000000; // actually unused
  537. // Masks to enable/disable all events
  538. const longword evcAll = 0xFFFFFFFF;
  539. const longword evcNone = 0x00000000;
  540. // Event SubCodes
  541. const word evsUnknown = 0x0000;
  542. const word evsStartUpload = 0x0001;
  543. const word evsStartDownload = 0x0001;
  544. const word evsGetBlockList = 0x0001;
  545. const word evsStartListBoT = 0x0002;
  546. const word evsListBoT = 0x0003;
  547. const word evsGetBlockInfo = 0x0004;
  548. const word evsGetClock = 0x0001;
  549. const word evsSetClock = 0x0002;
  550. const word evsSetPassword = 0x0001;
  551. const word evsClrPassword = 0x0002;
  552. // Event Params : functions group
  553. const word grProgrammer = 0x0041;
  554. const word grCyclicData = 0x0042;
  555. const word grBlocksInfo = 0x0043;
  556. const word grSZL = 0x0044;
  557. const word grPassword = 0x0045;
  558. const word grBSend = 0x0046;
  559. const word grClock = 0x0047;
  560. const word grSecurity = 0x0045;
  561. // Event Params : control codes
  562. const word CodeControlUnknown = 0x0000;
  563. const word CodeControlColdStart = 0x0001;
  564. const word CodeControlWarmStart = 0x0002;
  565. const word CodeControlStop = 0x0003;
  566. const word CodeControlCompress = 0x0004;
  567. const word CodeControlCpyRamRom = 0x0005;
  568. const word CodeControlInsDel = 0x0006;
  569. // Event Result
  570. const word evrNoError = 0x0000;
  571. const word evrFragmentRejected = 0x0001;
  572. const word evrMalformedPDU = 0x0002;
  573. const word evrSparseBytes = 0x0003;
  574. const word evrCannotHandlePDU = 0x0004;
  575. const word evrNotImplemented = 0x0005;
  576. const word evrErrException = 0x0006;
  577. const word evrErrAreaNotFound = 0x0007;
  578. const word evrErrOutOfRange = 0x0008;
  579. const word evrErrOverPDU = 0x0009;
  580. const word evrErrTransportSize = 0x000A;
  581. const word evrInvalidGroupUData = 0x000B;
  582. const word evrInvalidSZL = 0x000C;
  583. const word evrDataSizeMismatch = 0x000D;
  584. const word evrCannotUpload = 0x000E;
  585. const word evrCannotDownload = 0x000F;
  586. const word evrUploadInvalidID = 0x0010;
  587. const word evrResNotFound = 0x0011;
  588. typedef struct{
  589. time_t EvtTime; // Timestamp
  590. int EvtSender; // Sender
  591. longword EvtCode; // Event code
  592. word EvtRetCode; // Event result
  593. word EvtParam1; // Param 1 (if available)
  594. word EvtParam2; // Param 2 (if available)
  595. word EvtParam3; // Param 3 (if available)
  596. word EvtParam4; // Param 4 (if available)
  597. }TSrvEvent, *PSrvEvent;
  598. // Server Events callback
  599. typedef void (S7API *pfn_SrvCallBack)(void *usrPtr, PSrvEvent PEvent, int Size);
  600. // Server Read/Write callback
  601. typedef int(S7API *pfn_RWAreaCallBack)(void *usrPtr, int Sender, int Operation, PS7Tag PTag, void *pUsrData);
  602. S7Object S7API Srv_Create();
  603. void S7API Srv_Destroy(S7Object *Server);
  604. int S7API Srv_GetParam(S7Object Server, int ParamNumber, void *pValue);
  605. int S7API Srv_SetParam(S7Object Server, int ParamNumber, void *pValue);
  606. int S7API Srv_StartTo(S7Object Server, const char *Address);
  607. int S7API Srv_Start(S7Object Server);
  608. int S7API Srv_Stop(S7Object Server);
  609. int S7API Srv_RegisterArea(S7Object Server, int AreaCode, word Index, void *pUsrData, int Size);
  610. int S7API Srv_UnregisterArea(S7Object Server, int AreaCode, word Index);
  611. int S7API Srv_LockArea(S7Object Server, int AreaCode, word Index);
  612. int S7API Srv_UnlockArea(S7Object Server, int AreaCode, word Index);
  613. int S7API Srv_GetStatus(S7Object Server, int *ServerStatus, int *CpuStatus, int *ClientsCount);
  614. int S7API Srv_SetCpuStatus(S7Object Server, int CpuStatus);
  615. int S7API Srv_ClearEvents(S7Object Server);
  616. int S7API Srv_PickEvent(S7Object Server, TSrvEvent *pEvent, int *EvtReady);
  617. int S7API Srv_GetMask(S7Object Server, int MaskKind, longword *Mask);
  618. int S7API Srv_SetMask(S7Object Server, int MaskKind, longword Mask);
  619. int S7API Srv_SetEventsCallback(S7Object Server, pfn_SrvCallBack pCallback, void *usrPtr);
  620. int S7API Srv_SetReadEventsCallback(S7Object Server, pfn_SrvCallBack pCallback, void *usrPtr);
  621. int S7API Srv_SetRWAreaCallback(S7Object Server, pfn_RWAreaCallBack pCallback, void *usrPtr);
  622. int S7API Srv_EventText(TSrvEvent *Event, char *Text, int TextLen);
  623. int S7API Srv_ErrorText(int Error, char *Text, int TextLen);
  624. //******************************************************************************
  625. // PARTNER
  626. //******************************************************************************
  627. // Status
  628. const int par_stopped = 0; // stopped
  629. const int par_connecting = 1; // running and active connecting
  630. const int par_waiting = 2; // running and waiting for a connection
  631. const int par_linked = 3; // running and connected : linked
  632. const int par_sending = 4; // sending data
  633. const int par_receiving = 5; // receiving data
  634. const int par_binderror = 6; // error starting passive server
  635. // Errors
  636. const longword errParAddressInUse = 0x00200000;
  637. const longword errParNoRoom = 0x00300000;
  638. const longword errServerNoRoom = 0x00400000;
  639. const longword errParInvalidParams = 0x00500000;
  640. const longword errParNotLinked = 0x00600000;
  641. const longword errParBusy = 0x00700000;
  642. const longword errParFrameTimeout = 0x00800000;
  643. const longword errParInvalidPDU = 0x00900000;
  644. const longword errParSendTimeout = 0x00A00000;
  645. const longword errParRecvTimeout = 0x00B00000;
  646. const longword errParSendRefused = 0x00C00000;
  647. const longword errParNegotiatingPDU = 0x00D00000;
  648. const longword errParSendingBlock = 0x00E00000;
  649. const longword errParRecvingBlock = 0x00F00000;
  650. const longword errParBindError = 0x01000000;
  651. const longword errParDestroying = 0x01100000;
  652. const longword errParInvalidParamNumber = 0x01200000; // Invalid param (par_get/set_param)
  653. const longword errParCannotChangeParam = 0x01300000; // Cannot change because running
  654. const longword errParBufferTooSmall = 0x01400000; // Raised by LabVIEW wrapper
  655. // Brecv Data incoming Callback
  656. typedef void (S7API *pfn_ParRecvCallBack)(void * usrPtr, int opResult, longword R_ID, void *pData, int Size);
  657. // BSend Completion Callback
  658. typedef void (S7API *pfn_ParSendCompletion)(void * usrPtr, int opResult);
  659. S7Object S7API Par_Create(int Active);
  660. void S7API Par_Destroy(S7Object *Partner);
  661. int S7API Par_GetParam(S7Object Partner, int ParamNumber, void *pValue);
  662. int S7API Par_SetParam(S7Object Partner, int ParamNumber, void *pValue);
  663. int S7API Par_StartTo(S7Object Partner, const char *LocalAddress, const char *RemoteAddress,
  664. word LocTsap, word RemTsap);
  665. int S7API Par_Start(S7Object Partner);
  666. int S7API Par_Stop(S7Object Partner);
  667. // BSend
  668. int S7API Par_BSend(S7Object Partner, longword R_ID, void *pUsrData, int Size);
  669. int S7API Par_AsBSend(S7Object Partner, longword R_ID, void *pUsrData, int Size);
  670. int S7API Par_CheckAsBSendCompletion(S7Object Partner, int *opResult);
  671. int S7API Par_WaitAsBSendCompletion(S7Object Partner, longword Timeout);
  672. int S7API Par_SetSendCallback(S7Object Partner, pfn_ParSendCompletion pCompletion, void *usrPtr);
  673. // BRecv
  674. int S7API Par_BRecv(S7Object Partner, longword *R_ID, void *pData, int *Size, longword Timeout);
  675. int S7API Par_CheckAsBRecvCompletion(S7Object Partner, int *opResult, longword *R_ID,
  676. void *pData, int *Size);
  677. int S7API Par_SetRecvCallback(S7Object Partner, pfn_ParRecvCallBack pCompletion, void *usrPtr);
  678. // Stat
  679. int S7API Par_GetTimes(S7Object Partner, longword *SendTime, longword *RecvTime);
  680. int S7API Par_GetStats(S7Object Partner, longword *BytesSent, longword *BytesRecv,
  681. longword *SendErrors, longword *RecvErrors);
  682. int S7API Par_GetLastError(S7Object Partner, int *LastError);
  683. int S7API Par_GetStatus(S7Object Partner, int *Status);
  684. int S7API Par_ErrorText(int Error, char *Text, int TextLen);
  685. #pragma pack()
  686. #ifdef __cplusplus
  687. }
  688. #endif // __cplusplus
  689. #ifdef __cplusplus
  690. //******************************************************************************
  691. // CLIENT CLASS DEFINITION
  692. //******************************************************************************
  693. class TS7Client
  694. {
  695. private:
  696. S7Object Client;
  697. public:
  698. TS7Client();
  699. ~TS7Client();
  700. // Control functions
  701. int Connect();
  702. int ConnectTo(const char *RemAddress, int Rack, int Slot);
  703. int SetConnectionParams(const char *RemAddress, word LocalTSAP, word RemoteTSAP);
  704. int SetConnectionType(word ConnectionType);
  705. int Disconnect();
  706. int GetParam(int ParamNumber, void *pValue);
  707. int SetParam(int ParamNumber, void *pValue);
  708. // Data I/O Main functions
  709. int ReadArea(int Area, int DBNumber, int Start, int Amount, int WordLen, void *pUsrData);
  710. int WriteArea(int Area, int DBNumber, int Start, int Amount, int WordLen, void *pUsrData);
  711. int ReadMultiVars(PS7DataItem Item, int ItemsCount);
  712. int WriteMultiVars(PS7DataItem Item, int ItemsCount);
  713. // Data I/O Lean functions
  714. int DBRead(int DBNumber, int Start, int Size, void *pUsrData);
  715. int DBWrite(int DBNumber, int Start, int Size, void *pUsrData);
  716. int MBRead(int Start, int Size, void *pUsrData);
  717. int MBWrite(int Start, int Size, void *pUsrData);
  718. int EBRead(int Start, int Size, void *pUsrData);
  719. int EBWrite(int Start, int Size, void *pUsrData);
  720. int ABRead(int Start, int Size, void *pUsrData);
  721. int ABWrite(int Start, int Size, void *pUsrData);
  722. int TMRead(int Start, int Amount, void *pUsrData);
  723. int TMWrite(int Start, int Amount, void *pUsrData);
  724. int CTRead(int Start, int Amount, void *pUsrData);
  725. int CTWrite(int Start, int Amount, void *pUsrData);
  726. // Directory functions
  727. int ListBlocks(PS7BlocksList pUsrData);
  728. int GetAgBlockInfo(int BlockType, int BlockNum, PS7BlockInfo pUsrData);
  729. int GetPgBlockInfo(void *pBlock, PS7BlockInfo pUsrData, int Size);
  730. int ListBlocksOfType(int BlockType, TS7BlocksOfType *pUsrData, int *ItemsCount);
  731. // Blocks functions
  732. int Upload(int BlockType, int BlockNum, void *pUsrData, int *Size);
  733. int FullUpload(int BlockType, int BlockNum, void *pUsrData, int *Size);
  734. int Download(int BlockNum, void *pUsrData, int Size);
  735. int Delete(int BlockType, int BlockNum);
  736. int DBGet(int DBNumber, void *pUsrData, int *Size);
  737. int DBFill(int DBNumber, int FillChar);
  738. // Date/Time functions
  739. int GetPlcDateTime(tm *DateTime);
  740. int SetPlcDateTime(tm *DateTime);
  741. int SetPlcSystemDateTime();
  742. // System Info functions
  743. int GetOrderCode(PS7OrderCode pUsrData);
  744. int GetCpuInfo(PS7CpuInfo pUsrData);
  745. int GetCpInfo(PS7CpInfo pUsrData);
  746. int ReadSZL(int ID, int Index, PS7SZL pUsrData, int *Size);
  747. int ReadSZLList(PS7SZLList pUsrData, int *ItemsCount);
  748. // Control functions
  749. int PlcHotStart();
  750. int PlcColdStart();
  751. int PlcStop();
  752. int CopyRamToRom(int Timeout);
  753. int Compress(int Timeout);
  754. // Security functions
  755. int GetProtection(PS7Protection pUsrData);
  756. int SetSessionPassword(char *Password);
  757. int ClearSessionPassword();
  758. // Properties
  759. int ExecTime();
  760. int LastError();
  761. int PDURequested();
  762. int PDULength();
  763. int PlcStatus();
  764. bool Connected();
  765. // Async functions
  766. int SetAsCallback(pfn_CliCompletion pCompletion, void *usrPtr);
  767. bool CheckAsCompletion(int *opResult);
  768. int WaitAsCompletion(longword Timeout);
  769. int AsReadArea(int Area, int DBNumber, int Start, int Amount, int WordLen, void *pUsrData);
  770. int AsWriteArea(int Area, int DBNumber, int Start, int Amount, int WordLen, void *pUsrData);
  771. int AsListBlocksOfType(int BlockType, PS7BlocksOfType pUsrData, int *ItemsCount);
  772. int AsReadSZL(int ID, int Index, PS7SZL pUsrData, int *Size);
  773. int AsReadSZLList(PS7SZLList pUsrData, int *ItemsCount);
  774. int AsUpload(int BlockType, int BlockNum, void *pUsrData, int *Size);
  775. int AsFullUpload(int BlockType, int BlockNum, void *pUsrData, int *Size);
  776. int AsDownload(int BlockNum, void *pUsrData, int Size);
  777. int AsCopyRamToRom(int Timeout);
  778. int AsCompress(int Timeout);
  779. int AsDBRead(int DBNumber, int Start, int Size, void *pUsrData);
  780. int AsDBWrite(int DBNumber, int Start, int Size, void *pUsrData);
  781. int AsMBRead(int Start, int Size, void *pUsrData);
  782. int AsMBWrite(int Start, int Size, void *pUsrData);
  783. int AsEBRead(int Start, int Size, void *pUsrData);
  784. int AsEBWrite(int Start, int Size, void *pUsrData);
  785. int AsABRead(int Start, int Size, void *pUsrData);
  786. int AsABWrite(int Start, int Size, void *pUsrData);
  787. int AsTMRead(int Start, int Amount, void *pUsrData);
  788. int AsTMWrite(int Start, int Amount, void *pUsrData);
  789. int AsCTRead(int Start, int Amount, void *pUsrData);
  790. int AsCTWrite(int Start, int Amount, void *pUsrData);
  791. int AsDBGet(int DBNumber, void *pUsrData, int *Size);
  792. int AsDBFill(int DBNumber, int FillChar);
  793. };
  794. typedef TS7Client *PS7Client;
  795. //******************************************************************************
  796. // SERVER CLASS DEFINITION
  797. //******************************************************************************
  798. class TS7Server
  799. {
  800. private:
  801. S7Object Server;
  802. public:
  803. TS7Server();
  804. ~TS7Server();
  805. // Control
  806. int Start();
  807. int StartTo(const char *Address);
  808. int Stop();
  809. int GetParam(int ParamNumber, void *pValue);
  810. int SetParam(int ParamNumber, void *pValue);
  811. // Events
  812. int SetEventsCallback(pfn_SrvCallBack PCallBack, void *UsrPtr);
  813. int SetReadEventsCallback(pfn_SrvCallBack PCallBack, void *UsrPtr);
  814. int SetRWAreaCallback(pfn_RWAreaCallBack PCallBack, void *UsrPtr);
  815. bool PickEvent(TSrvEvent *pEvent);
  816. void ClearEvents();
  817. longword GetEventsMask();
  818. longword GetLogMask();
  819. void SetEventsMask(longword Mask);
  820. void SetLogMask(longword Mask);
  821. // Resources
  822. int RegisterArea(int AreaCode, word Index, void *pUsrData, word Size);
  823. int UnregisterArea(int AreaCode, word Index);
  824. int LockArea(int AreaCode, word Index);
  825. int UnlockArea(int AreaCode, word Index);
  826. // Properties
  827. int ServerStatus();
  828. int GetCpuStatus();
  829. int SetCpuStatus(int Status);
  830. int ClientsCount();
  831. };
  832. typedef TS7Server *PS7Server;
  833. //******************************************************************************
  834. // PARTNER CLASS DEFINITION
  835. //******************************************************************************
  836. class TS7Partner
  837. {
  838. private:
  839. S7Object Partner; // Partner Handle
  840. public:
  841. TS7Partner(bool Active);
  842. ~TS7Partner();
  843. // Control
  844. int GetParam(int ParamNumber, void *pValue);
  845. int SetParam(int ParamNumber, void *pValue);
  846. int Start();
  847. int StartTo(const char *LocalAddress,
  848. const char *RemoteAddress,
  849. int LocalTSAP,
  850. int RemoteTSAP);
  851. int Stop();
  852. // Data I/O functions : BSend
  853. int BSend(longword R_ID, void *pUsrData, int Size);
  854. int AsBSend(longword R_ID, void *pUsrData, int Size);
  855. bool CheckAsBSendCompletion(int *opResult);
  856. int WaitAsBSendCompletion(longword Timeout);
  857. int SetSendCallback(pfn_ParSendCompletion pCompletion, void *usrPtr);
  858. // Data I/O functions : BRecv
  859. int BRecv(longword *R_ID, void *pUsrData, int *Size, longword Timeout);
  860. bool CheckAsBRecvCompletion(int *opResult, longword *R_ID, void *pUsrData, int *Size);
  861. int SetRecvCallback(pfn_ParRecvCallBack pCallback, void *usrPtr);
  862. // Properties
  863. int Status();
  864. int LastError();
  865. int GetTimes(longword *SendTime, longword *RecvTime);
  866. int GetStats(longword *BytesSent,
  867. longword *BytesRecv,
  868. longword *ErrSend,
  869. longword *ErrRecv);
  870. bool Linked();
  871. };
  872. typedef TS7Partner *PS7Partner;
  873. //******************************************************************************
  874. // TEXT ROUTINES
  875. // Only for C++, for pure C use xxx_ErrorText() which uses *char
  876. //******************************************************************************
  877. #define TextLen 1024
  878. // String type
  879. // Here we define generic TextString (by default mapped onto std::string).
  880. // So you can change it if needed (Unicodestring, Ansistring etc...)
  881. typedef std::string TextString;
  882. TextString CliErrorText(int Error);
  883. TextString SrvErrorText(int Error);
  884. TextString ParErrorText(int Error);
  885. TextString SrvEventText(TSrvEvent *Event);
  886. #endif // __cplusplus
  887. #endif // snap7_h