AdsLib
 All Classes Files Functions Variables Typedefs Macros Pages
AdsDef.h
Go to the documentation of this file.
1 
23 #ifndef __ADSDEF_H__
24 #define __ADSDEF_H__
25 
26 #ifdef __cplusplus
27 #include <cstdint>
28 #include <iosfwd>
29 #include <string>
30 #else
31 #include <stdint.h>
32 #endif
33 
34 #define ADS_TCP_SERVER_PORT 0xBF02
35 
37 // AMS Ports
38 #define AMSPORT_LOGGER 100
39 #define AMSPORT_R0_RTIME 200
40 #define AMSPORT_R0_TRACE (AMSPORT_R0_RTIME + 90)
41 #define AMSPORT_R0_IO 300
42 #define AMSPORT_R0_SPS 400
43 #define AMSPORT_R0_NC 500
44 #define AMSPORT_R0_ISG 550
45 #define AMSPORT_R0_PCS 600
46 #define AMSPORT_R0_PLC 801
47 #define AMSPORT_R0_PLC_RTS1 801
48 #define AMSPORT_R0_PLC_RTS2 811
49 #define AMSPORT_R0_PLC_RTS3 821
50 #define AMSPORT_R0_PLC_RTS4 831
51 #define AMSPORT_R0_PLC_TC3 851
52 
54 // ADS Cmd Ids
55 #define ADSSRVID_INVALID 0x00
56 #define ADSSRVID_READDEVICEINFO 0x01
57 #define ADSSRVID_READ 0x02
58 #define ADSSRVID_WRITE 0x03
59 #define ADSSRVID_READSTATE 0x04
60 #define ADSSRVID_WRITECTRL 0x05
61 #define ADSSRVID_ADDDEVICENOTE 0x06
62 #define ADSSRVID_DELDEVICENOTE 0x07
63 #define ADSSRVID_DEVICENOTE 0x08
64 #define ADSSRVID_READWRITE 0x09
65 
67 // ADS reserved index groups
68 #define ADSIGRP_SYMTAB 0xF000
69 #define ADSIGRP_SYMNAME 0xF001
70 #define ADSIGRP_SYMVAL 0xF002
71 
72 #define ADSIGRP_SYM_HNDBYNAME 0xF003
73 #define ADSIGRP_SYM_VALBYNAME 0xF004
74 #define ADSIGRP_SYM_VALBYHND 0xF005
75 #define ADSIGRP_SYM_RELEASEHND 0xF006
76 #define ADSIGRP_SYM_INFOBYNAME 0xF007
77 #define ADSIGRP_SYM_VERSION 0xF008
78 #define ADSIGRP_SYM_INFOBYNAMEEX 0xF009
79 
80 #define ADSIGRP_SYM_DOWNLOAD 0xF00A
81 #define ADSIGRP_SYM_UPLOAD 0xF00B
82 #define ADSIGRP_SYM_UPLOADINFO 0xF00C
83 #define ADSIGRP_SYM_DOWNLOAD2 0xF00D
84 #define ADSIGRP_SYM_DT_UPLOAD 0xF00E
85 #define ADSIGRP_SYM_UPLOADINFO2 0xF00F
86 
87 #define ADSIGRP_SYMNOTE 0xF010
95 #define ADSIGRP_SUMUP_READ 0xF080
96 
102 #define ADSIGRP_SUMUP_WRITE 0xF081
103 
109 #define ADSIGRP_SUMUP_READWRITE 0xF082
110 
115 #define ADSIGRP_SUMUP_READEX 0xF083
116 
122 #define ADSIGRP_SUMUP_READEX2 0xF084
123 
129 #define ADSIGRP_SUMUP_ADDDEVNOTE 0xF085
130 
136 #define ADSIGRP_SUMUP_DELDEVNOTE 0xF086
137 
138 #define ADSIGRP_IOIMAGE_RWIB 0xF020
139 #define ADSIGRP_IOIMAGE_RWIX 0xF021
140 #define ADSIGRP_IOIMAGE_RISIZE 0xF025
141 #define ADSIGRP_IOIMAGE_RWOB 0xF030
142 #define ADSIGRP_IOIMAGE_RWOX 0xF031
143 #define ADSIGRP_IOIMAGE_ROSIZE 0xF035
144 #define ADSIGRP_IOIMAGE_CLEARI 0xF040
145 #define ADSIGRP_IOIMAGE_CLEARO 0xF050
146 #define ADSIGRP_IOIMAGE_RWIOB 0xF060
148 #define ADSIGRP_DEVICE_DATA 0xF100
149 #define ADSIOFFS_DEVDATA_ADSSTATE 0x0000
150 #define ADSIOFFS_DEVDATA_DEVSTATE 0x0002
152 // Global Return codes
154 #define ERR_GLOBAL 0x0000
155 
156 #define GLOBALERR_TARGET_PORT (0x06 + ERR_GLOBAL)
157 #define GLOBALERR_MISSING_ROUTE (0x07 + ERR_GLOBAL)
158 #define GLOBALERR_NO_MEMORY (0x19 + ERR_GLOBAL)
159 #define GLOBALERR_TCP_SEND (0x1A + ERR_GLOBAL)
161 // Router Return codes
163 #define ERR_ROUTER 0x0500
164 
165 #define ROUTERERR_NOTREGISTERED (0x07 + ERR_ROUTER)
166 #define ROUTERERR_NOMOREQUEUES (0x08 + ERR_ROUTER)
168 // ADS Return codes
170 #define ADSERR_NOERR 0x00
171 #define ERR_ADSERRS 0x0700
172 
173 #define ADSERR_DEVICE_ERROR (0x00 + ERR_ADSERRS)
174 #define ADSERR_DEVICE_SRVNOTSUPP (0x01 + ERR_ADSERRS)
175 #define ADSERR_DEVICE_INVALIDGRP (0x02 + ERR_ADSERRS)
176 #define ADSERR_DEVICE_INVALIDOFFSET (0x03 + ERR_ADSERRS)
177 #define ADSERR_DEVICE_INVALIDACCESS (0x04 + ERR_ADSERRS)
178 #define ADSERR_DEVICE_INVALIDSIZE (0x05 + ERR_ADSERRS)
179 #define ADSERR_DEVICE_INVALIDDATA (0x06 + ERR_ADSERRS)
180 #define ADSERR_DEVICE_NOTREADY (0x07 + ERR_ADSERRS)
181 #define ADSERR_DEVICE_BUSY (0x08 + ERR_ADSERRS)
182 #define ADSERR_DEVICE_INVALIDCONTEXT (0x09 + ERR_ADSERRS)
183 #define ADSERR_DEVICE_NOMEMORY (0x0A + ERR_ADSERRS)
184 #define ADSERR_DEVICE_INVALIDPARM (0x0B + ERR_ADSERRS)
185 #define ADSERR_DEVICE_NOTFOUND (0x0C + ERR_ADSERRS)
186 #define ADSERR_DEVICE_SYNTAX (0x0D + ERR_ADSERRS)
187 #define ADSERR_DEVICE_INCOMPATIBLE (0x0E + ERR_ADSERRS)
188 #define ADSERR_DEVICE_EXISTS (0x0F + ERR_ADSERRS)
189 #define ADSERR_DEVICE_SYMBOLNOTFOUND (0x10 + ERR_ADSERRS)
190 #define ADSERR_DEVICE_SYMBOLVERSIONINVALID (0x11 + ERR_ADSERRS)
191 #define ADSERR_DEVICE_INVALIDSTATE (0x12 + ERR_ADSERRS)
192 #define ADSERR_DEVICE_TRANSMODENOTSUPP (0x13 + ERR_ADSERRS)
193 #define ADSERR_DEVICE_NOTIFYHNDINVALID (0x14 + ERR_ADSERRS)
194 #define ADSERR_DEVICE_CLIENTUNKNOWN (0x15 + ERR_ADSERRS)
195 #define ADSERR_DEVICE_NOMOREHDLS (0x16 + ERR_ADSERRS)
196 #define ADSERR_DEVICE_INVALIDWATCHSIZE (0x17 + ERR_ADSERRS)
197 #define ADSERR_DEVICE_NOTINIT (0x18 + ERR_ADSERRS)
198 #define ADSERR_DEVICE_TIMEOUT (0x19 + ERR_ADSERRS)
199 #define ADSERR_DEVICE_NOINTERFACE (0x1A + ERR_ADSERRS)
200 #define ADSERR_DEVICE_INVALIDINTERFACE (0x1B + ERR_ADSERRS)
201 #define ADSERR_DEVICE_INVALIDCLSID (0x1C + ERR_ADSERRS)
202 #define ADSERR_DEVICE_INVALIDOBJID (0x1D + ERR_ADSERRS)
203 #define ADSERR_DEVICE_PENDING (0x1E + ERR_ADSERRS)
204 #define ADSERR_DEVICE_ABORTED (0x1F + ERR_ADSERRS)
205 #define ADSERR_DEVICE_WARNING (0x20 + ERR_ADSERRS)
206 #define ADSERR_DEVICE_INVALIDARRAYIDX (0x21 + ERR_ADSERRS)
207 #define ADSERR_DEVICE_SYMBOLNOTACTIVE (0x22 + ERR_ADSERRS)
208 #define ADSERR_DEVICE_ACCESSDENIED (0x23 + ERR_ADSERRS)
209 #define ADSERR_DEVICE_LICENSENOTFOUND (0x24 + ERR_ADSERRS)
210 #define ADSERR_DEVICE_LICENSEEXPIRED (0x25 + ERR_ADSERRS)
211 #define ADSERR_DEVICE_LICENSEEXCEEDED (0x26 + ERR_ADSERRS)
212 #define ADSERR_DEVICE_LICENSEINVALID (0x27 + ERR_ADSERRS)
213 #define ADSERR_DEVICE_LICENSESYSTEMID (0x28 + ERR_ADSERRS)
214 #define ADSERR_DEVICE_LICENSENOTIMELIMIT (0x29 + ERR_ADSERRS)
215 #define ADSERR_DEVICE_LICENSEFUTUREISSUE (0x2A + ERR_ADSERRS)
216 #define ADSERR_DEVICE_LICENSETIMETOLONG (0x2B + ERR_ADSERRS)
217 #define ADSERR_DEVICE_EXCEPTION (0x2C + ERR_ADSERRS)
218 #define ADSERR_DEVICE_LICENSEDUPLICATED (0x2D + ERR_ADSERRS)
219 #define ADSERR_DEVICE_SIGNATUREINVALID (0x2E + ERR_ADSERRS)
220 #define ADSERR_DEVICE_CERTIFICATEINVALID (0x2F + ERR_ADSERRS)
222 #define ADSERR_CLIENT_ERROR (0x40 + ERR_ADSERRS)
223 #define ADSERR_CLIENT_INVALIDPARM (0x41 + ERR_ADSERRS)
224 #define ADSERR_CLIENT_LISTEMPTY (0x42 + ERR_ADSERRS)
225 #define ADSERR_CLIENT_VARUSED (0x43 + ERR_ADSERRS)
226 #define ADSERR_CLIENT_DUPLINVOKEID (0x44 + ERR_ADSERRS)
227 #define ADSERR_CLIENT_SYNCTIMEOUT (0x45 + ERR_ADSERRS)
228 #define ADSERR_CLIENT_W32ERROR (0x46 + ERR_ADSERRS)
229 #define ADSERR_CLIENT_TIMEOUTINVALID (0x47 + ERR_ADSERRS)
230 #define ADSERR_CLIENT_PORTNOTOPEN (0x48 + ERR_ADSERRS)
231 #define ADSERR_CLIENT_NOAMSADDR (0x49 + ERR_ADSERRS)
232 #define ADSERR_CLIENT_SYNCINTERNAL (0x50 + ERR_ADSERRS)
233 #define ADSERR_CLIENT_ADDHASH (0x51 + ERR_ADSERRS)
234 #define ADSERR_CLIENT_REMOVEHASH (0x52 + ERR_ADSERRS)
235 #define ADSERR_CLIENT_NOMORESYM (0x53 + ERR_ADSERRS)
236 #define ADSERR_CLIENT_SYNCRESINVALID (0x54 + ERR_ADSERRS)
237 #define ADSERR_CLIENT_SYNCPORTLOCKED (0x55 + ERR_ADSERRS)
239 #pragma pack( push, 1)
240 
244 struct AmsNetId {
246  uint8_t b[6];
247 
248 #ifdef __cplusplus
249  AmsNetId(uint32_t ipv4Addr = 0);
250  AmsNetId(const std::string& addr);
251  AmsNetId(uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t);
252  bool operator<(const AmsNetId& rhs) const;
253  operator bool() const;
254 #endif
255 };
256 
260 struct AmsAddr {
263 
265  uint16_t port;
266 };
267 
268 #ifdef __cplusplus
269 bool operator<(const AmsAddr& lhs, const AmsAddr& rhs);
270 std::ostream& operator<<(std::ostream& os, const AmsNetId& netId);
271 #endif /* #ifdef __cplusplus */
272 
276 struct AdsVersion {
278  uint8_t version;
279 
281  uint8_t revision;
282 
284  uint16_t build;
285 };
286 
287 enum ADSTRANSMODE {
288  ADSTRANS_NOTRANS = 0,
289  ADSTRANS_CLIENTCYCLE = 1,
290  ADSTRANS_CLIENTONCHA = 2,
291  ADSTRANS_SERVERCYCLE = 3,
292  ADSTRANS_SERVERONCHA = 4,
293  ADSTRANS_SERVERCYCLE2 = 5,
294  ADSTRANS_SERVERONCHA2 = 6,
295  ADSTRANS_CLIENT1REQ = 10,
296  ADSTRANS_MAXMODES
297 };
298 
299 enum ADSSTATE {
300  ADSSTATE_INVALID = 0,
301  ADSSTATE_IDLE = 1,
302  ADSSTATE_RESET = 2,
303  ADSSTATE_INIT = 3,
304  ADSSTATE_START = 4,
305  ADSSTATE_RUN = 5,
306  ADSSTATE_STOP = 6,
307  ADSSTATE_SAVECFG = 7,
308  ADSSTATE_LOADCFG = 8,
309  ADSSTATE_POWERFAILURE = 9,
310  ADSSTATE_POWERGOOD = 10,
311  ADSSTATE_ERROR = 11,
312  ADSSTATE_SHUTDOWN = 12,
313  ADSSTATE_SUSPEND = 13,
314  ADSSTATE_RESUME = 14,
315  ADSSTATE_CONFIG = 15,
316  ADSSTATE_RECONFIG = 16,
317  ADSSTATE_STOPPING = 17,
318  ADSSTATE_INCOMPATIBLE = 18,
319  ADSSTATE_EXCEPTION = 19,
320  ADSSTATE_MAXSTATES
321 };
322 
353  uint32_t cbLength;
354 
359  uint32_t nTransMode;
360 
362  uint32_t nMaxDelay;
363 
364  union {
366  uint32_t nCycleTime;
367  uint32_t dwChangeFilter;
368  };
369 };
370 
376  uint64_t nTimeStamp;
377 
379  uint32_t hNotification;
380 
382  uint32_t cbSampleSize;
383 };
384 
391 typedef void (* PAdsNotificationFuncEx)(const AmsAddr* pAddr, const AdsNotificationHeader* pNotification,
392  uint32_t hUser);
393 
394 #pragma pack( pop )
395 #endif // __ADSDEF_H__
The complete address of an ADS device can be stored in this structure.
Definition: AdsDef.h:260
uint16_t port
Definition: AdsDef.h:265
uint32_t nMaxDelay
Definition: AdsDef.h:362
uint8_t b[6]
Definition: AdsDef.h:246
uint16_t build
Definition: AdsDef.h:284
The structure contains the version number, revision number and build number.
Definition: AdsDef.h:276
uint8_t version
Definition: AdsDef.h:278
This structure contains all the attributes for the definition of a notification.
Definition: AdsDef.h:351
uint32_t nCycleTime
Definition: AdsDef.h:366
This structure is also passed to the callback function.
Definition: AdsDef.h:374
uint8_t revision
Definition: AdsDef.h:281
void(* PAdsNotificationFuncEx)(const AmsAddr *pAddr, const AdsNotificationHeader *pNotification, uint32_t hUser)
Type definition of the callback function required by the AdsSyncAddDeviceNotificationReqEx() function...
Definition: AdsDef.h:391
uint32_t nTransMode
Definition: AdsDef.h:359
AmsNetId netId
Definition: AdsDef.h:262
uint32_t hNotification
Definition: AdsDef.h:379
uint32_t cbLength
Definition: AdsDef.h:353
The NetId of and ADS device can be represented in this structure.
Definition: AdsDef.h:244
uint32_t cbSampleSize
Definition: AdsDef.h:382
uint64_t nTimeStamp
Definition: AdsDef.h:376