You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
274 lines
8.9 KiB
C
274 lines
8.9 KiB
C
2 years ago
|
////////////////////////////////////////////////////////////////////////////////
|
||
|
// File: AdsDef.h
|
||
|
// Description: Prototypes and Definitions for ads communications
|
||
|
// Author: RamonB
|
||
|
// Created: Wed Nov 6 10:00:00 1996
|
||
|
//
|
||
|
//
|
||
|
// BECKHOFF-Industrieelektronik-GmbH
|
||
|
//
|
||
|
// Modifications:
|
||
|
// KlausBue 11/99
|
||
|
// Added router callback definitions
|
||
|
//
|
||
|
// ChristophC 16/07/2001
|
||
|
// Changed the definition of nAmsRouterEvent type
|
||
|
//
|
||
|
// ChristophC 6/08/2001
|
||
|
// Fixed bug in PADSNEXTSYMBOLENTRY macro
|
||
|
//
|
||
|
////////////////////////////////////////////////////////////////////////////////
|
||
|
|
||
|
#ifndef __ADSDEF_H__
|
||
|
#define __ADSDEF_H__
|
||
|
|
||
|
#ifndef ANYSIZE_ARRAY
|
||
|
#define ANYSIZE_ARRAY 1
|
||
|
#endif
|
||
|
|
||
|
#define ADS_FIXEDNAMESIZE 16
|
||
|
|
||
|
#define AMSPORT_LOGGER 100
|
||
|
#define AMSPORT_R0_RTIME 200
|
||
|
#define AMSPORT_R0_TRACE (AMSPORT_R0_RTIME+90)
|
||
|
#define AMSPORT_R0_IO 300
|
||
|
#define AMSPORT_R0_SPS 400
|
||
|
#define AMSPORT_R0_NC 500
|
||
|
#define AMSPORT_R0_ISG 550
|
||
|
#define AMSPORT_R0_PCS 600
|
||
|
#define AMSPORT_R0_PLC 801
|
||
|
#define AMSPORT_R0_PLC_RTS1 801
|
||
|
#define AMSPORT_R0_PLC_RTS2 811
|
||
|
#define AMSPORT_R0_PLC_RTS3 821
|
||
|
#define AMSPORT_R0_PLC_RTS4 831
|
||
|
|
||
|
////////////////////////////////////////////////////////////////////////////////
|
||
|
// ADS reserved index groups
|
||
|
#define ADSIGRP_SYMTAB 0xF000
|
||
|
#define ADSIGRP_SYMNAME 0xF001
|
||
|
#define ADSIGRP_SYMVAL 0xF002
|
||
|
|
||
|
#define ADSIGRP_SYM_HNDBYNAME 0xF003
|
||
|
#define ADSIGRP_SYM_VALBYNAME 0xF004
|
||
|
#define ADSIGRP_SYM_VALBYHND 0xF005
|
||
|
#define ADSIGRP_SYM_RELEASEHND 0xF006
|
||
|
#define ADSIGRP_SYM_INFOBYNAME 0xF007
|
||
|
#define ADSIGRP_SYM_VERSION 0xF008
|
||
|
#define ADSIGRP_SYM_INFOBYNAMEEX 0xF009
|
||
|
|
||
|
#define ADSIGRP_SYM_DOWNLOAD 0xF00A
|
||
|
#define ADSIGRP_SYM_UPLOAD 0xF00B
|
||
|
#define ADSIGRP_SYM_UPLOADINFO 0xF00C
|
||
|
|
||
|
#define ADSIGRP_SYMNOTE 0xF010 // notification of named handle
|
||
|
|
||
|
#define ADSIGRP_IOIMAGE_RWIB 0xF020 // read/write input byte(s)
|
||
|
#define ADSIGRP_IOIMAGE_RWIX 0xF021 // read/write input bit
|
||
|
#define ADSIGRP_IOIMAGE_RWOB 0xF030 // read/write output byte(s)
|
||
|
#define ADSIGRP_IOIMAGE_RWOX 0xF031 // read/write output bit
|
||
|
#define ADSIGRP_IOIMAGE_CLEARI 0xF040 // write inputs to null
|
||
|
#define ADSIGRP_IOIMAGE_CLEARO 0xF050 // write outputs to null
|
||
|
|
||
|
#define ADSIGRP_DEVICE_DATA 0xF100 // state, name, etc...
|
||
|
#define ADSIOFFS_DEVDATA_ADSSTATE 0x0000 // ads state of device
|
||
|
#define ADSIOFFS_DEVDATA_DEVSTATE 0x0002 // device state
|
||
|
|
||
|
#pragma pack( push, 1)
|
||
|
typedef struct AmsNetId_
|
||
|
{
|
||
|
unsigned char b[6];
|
||
|
|
||
|
} AmsNetId, *PAmsNetId;
|
||
|
|
||
|
typedef struct
|
||
|
{
|
||
|
AmsNetId netId;
|
||
|
unsigned short port;
|
||
|
} AmsAddr, *PAmsAddr;
|
||
|
|
||
|
typedef struct
|
||
|
{
|
||
|
unsigned char version;
|
||
|
unsigned char revision;
|
||
|
unsigned short build;
|
||
|
} AdsVersion;
|
||
|
|
||
|
typedef AdsVersion* PAdsVersion;
|
||
|
|
||
|
////////////////////////////////////////////////////////////////////////////////
|
||
|
typedef enum nAdsTransMode
|
||
|
{
|
||
|
ADSTRANS_NOTRANS =0,
|
||
|
ADSTRANS_CLIENTCYCLE =1,
|
||
|
ADSTRANS_CLIENT1REQ =2,
|
||
|
ADSTRANS_SERVERCYCLE =3,
|
||
|
ADSTRANS_SERVERONCHA =4
|
||
|
}ADSTRANSMODE;
|
||
|
|
||
|
typedef enum nAdsState
|
||
|
{
|
||
|
ADSSTATE_INVALID =0,
|
||
|
ADSSTATE_IDLE =1,
|
||
|
ADSSTATE_RESET =2,
|
||
|
ADSSTATE_INIT =3,
|
||
|
ADSSTATE_START =4,
|
||
|
ADSSTATE_RUN =5,
|
||
|
ADSSTATE_STOP =6,
|
||
|
ADSSTATE_SAVECFG =7,
|
||
|
ADSSTATE_LOADCFG =8,
|
||
|
ADSSTATE_POWERFAILURE =9,
|
||
|
ADSSTATE_POWERGOOD =10,
|
||
|
ADSSTATE_ERROR =11,
|
||
|
ADSSTATE_SHUTDOWN =12,
|
||
|
ADSSTATE_SUSPEND =13,
|
||
|
ADSSTATE_RESUME =14,
|
||
|
ADSSTATE_MAXSTATES
|
||
|
} ADSSTATE;
|
||
|
|
||
|
typedef struct
|
||
|
{
|
||
|
unsigned long cbLength;
|
||
|
ADSTRANSMODE nTransMode;
|
||
|
unsigned long nMaxDelay;
|
||
|
union
|
||
|
{
|
||
|
unsigned long nCycleTime;
|
||
|
unsigned long dwChangeFilter;
|
||
|
};
|
||
|
} AdsNotificationAttrib, *PAdsNotificationAttrib;
|
||
|
|
||
|
////////////////////////////////////////////////////////////////////////////////
|
||
|
typedef struct
|
||
|
{
|
||
|
unsigned long hNotification;
|
||
|
__int64 nTimeStamp;
|
||
|
unsigned long cbSampleSize;
|
||
|
unsigned char data[ANYSIZE_ARRAY];
|
||
|
} AdsNotificationHeader, *PAdsNotificationHeader;
|
||
|
|
||
|
////////////////////////////////////////////////////////////////////////////////
|
||
|
|
||
|
#define ADSNOTIFICATION_PDATA( pAdsNotificationHeader ) \
|
||
|
( (unsigned char*) (((PAdsNotificationHeader)pAdsNotificationHeader->data )
|
||
|
|
||
|
|
||
|
////////////////////////////////////////////////////////////////////////////////
|
||
|
typedef void (*PAdsNotificationFunc)( AmsAddr* pAddr,
|
||
|
AdsNotificationHeader* pNotification,
|
||
|
unsigned long hUser // user handle
|
||
|
);
|
||
|
|
||
|
////////////////////////////////////////////////////////////////////////////////
|
||
|
#define ADSSYMBOLFLAG_PERSISTENT 0x00000001
|
||
|
#define ADSSYMBOLFLAG_BITVALUE 0x00000002
|
||
|
|
||
|
typedef struct
|
||
|
{
|
||
|
unsigned long entryLength; // length of complete symbol entry
|
||
|
unsigned long iGroup; // indexGroup of symbol: input, output etc.
|
||
|
unsigned long iOffs; // indexOffset of symbol
|
||
|
unsigned long size; // size of symbol ( in bytes, 0 = bit )
|
||
|
unsigned long dataType; // adsDataType of symbol
|
||
|
unsigned long flags; // see above
|
||
|
unsigned short nameLength; // length of symbol name (excl. \0)
|
||
|
unsigned short typeLength; // length of type name (excl. \0)
|
||
|
unsigned short commentLength; // length of comment (excl. \0)
|
||
|
// ADS_INT8 name[]; // name of symbol with terminating \0
|
||
|
// ADS_INT8 type[]; // type name of symbol with terminating \0
|
||
|
// ADS_INT8 comment[]; // comment of symbol with terminating \0
|
||
|
} AdsSymbolEntry, *PAdsSymbolEntry, **PPAdsSymbolEntry;
|
||
|
|
||
|
|
||
|
#define PADSSYMBOLNAME(p) ((char*)(((PAdsSymbolEntry)p)+1))
|
||
|
#define PADSSYMBOLTYPE(p) (((char*)(((PAdsSymbolEntry)p)+1))+((PAdsSymbolEntry)p)->nameLength+1)
|
||
|
#define PADSSYMBOLCOMMENT(p) (((char*)(((PAdsSymbolEntry)p)+1))+((PAdsSymbolEntry)p)->nameLength+1+((PAdsSymbolEntry)p)->typeLength+1)
|
||
|
|
||
|
#define PADSNEXTSYMBOLENTRY(pEntry) (*((unsigned long*)(((char*)pEntry)+((PAdsSymbolEntry)pEntry)->entryLength)) \
|
||
|
? ((PAdsSymbolEntry)(((char*)pEntry)+((PAdsSymbolEntry)pEntry)->entryLength)): NULL)
|
||
|
|
||
|
|
||
|
|
||
|
////////////////////////////////////////////////////////////////////////////////
|
||
|
#define ADSDATATYPEFLAG_DATATYPE 0x00000001
|
||
|
#define ADSDATATYPEFLAG_DATAITEM 0x00000002
|
||
|
|
||
|
#define ADSDATATYPE_VERSION_NEWEST 0x00000001
|
||
|
|
||
|
typedef struct
|
||
|
{
|
||
|
unsigned long lBound; //
|
||
|
unsigned long elements; //
|
||
|
} AdsDatatypeArrayInfo, *PAdsDatatypeArrayInfo;
|
||
|
|
||
|
typedef struct
|
||
|
{
|
||
|
unsigned long entryLength; // length of complete datatype entry
|
||
|
unsigned long version; // version of datatype structure
|
||
|
unsigned long hashValue; // hashValue of datatype to compare datatypes
|
||
|
unsigned long typeHashValue; // hashValue of base type
|
||
|
unsigned long size; // size of datatype ( in bytes )
|
||
|
unsigned long offs; // offs of dataitem in parent datatype ( in bytes )
|
||
|
unsigned long dataType; // adsDataType of symbol (if alias)
|
||
|
unsigned long flags; //
|
||
|
unsigned short nameLength; // length of datatype name (excl. \0)
|
||
|
unsigned short typeLength; // length of dataitem type name (excl. \0)
|
||
|
unsigned short commentLength; // length of comment (excl. \0)
|
||
|
unsigned short arrayDim; //
|
||
|
unsigned short subItems; //
|
||
|
// ADS_INT8 name[]; // name of datatype with terminating \0
|
||
|
// ADS_INT8 type[]; // type name of dataitem with terminating \0
|
||
|
// ADS_INT8 comment[]; // comment of datatype with terminating \0
|
||
|
// AdsDatatypeArrayInfo array[]; //
|
||
|
// AdsDatatypeEntry subItems[]; //
|
||
|
} AdsDatatypeEntry, *PAdsDatatypeEntry, **PPAdsDatatypeEntry;
|
||
|
|
||
|
#define PADSDATATYPENAME(p) ((PCHAR)(((PAdsDatatypeEntry)p)+1))
|
||
|
#define PADSDATATYPETYPE(p) (((PCHAR)(((PAdsDatatypeEntry)p)+1))+((PAdsDatatypeEntry)p)->nameLength+1)
|
||
|
#define PADSDATATYPECOMMENT(p) (((PCHAR)(((PAdsDatatypeEntry)p)+1))+((PAdsDatatypeEntry)p)->nameLength+1+((PAdsDatatypeEntry)p)->typeLength+1)
|
||
|
#define PADSDATATYPEARRAYINFO(p) (PAdsDatatypeArrayInfo)(((PCHAR)(((PAdsDatatypeEntry)p)+1))+((PAdsDatatypeEntry)p)->nameLength+1+((PAdsDatatypeEntry)p)->typeLength+1+((PAdsDatatypeEntry)p)->commentLength+1)
|
||
|
|
||
|
__inline PAdsDatatypeEntry AdsDatatypeStructItem(PAdsDatatypeEntry p, unsigned short iItem)
|
||
|
{
|
||
|
unsigned short i;
|
||
|
PAdsDatatypeEntry pItem;
|
||
|
if ( iItem >= p->subItems )
|
||
|
return NULL;
|
||
|
pItem = (PAdsDatatypeEntry)(((unsigned char*)(p+1))+p->nameLength+p->typeLength+p->commentLength+3+p->arrayDim*sizeof(AdsDatatypeArrayInfo));
|
||
|
for ( i=0; i < iItem; i++ )
|
||
|
pItem = (PAdsDatatypeEntry)(((unsigned char*)pItem)+pItem->entryLength);
|
||
|
return pItem;
|
||
|
}
|
||
|
|
||
|
////////////////////////////////////////////////////////////////////////////////
|
||
|
typedef struct
|
||
|
{
|
||
|
unsigned long nSymbols;
|
||
|
unsigned long nSymSize;
|
||
|
} AdsSymbolUploadInfo, *PAdsSymbolUploadInfo;
|
||
|
|
||
|
////////////////////////////////////////////////////////////////////////////////
|
||
|
typedef struct
|
||
|
{
|
||
|
unsigned long indexGroup;
|
||
|
unsigned long indexOffset;
|
||
|
unsigned long cbLength;
|
||
|
} AdsSymbolInfoByName, *PAdsSymbolInfoByName;
|
||
|
|
||
|
////////////////////////////////////////////////////////////////////////////////
|
||
|
typedef enum nAmsRouterEvent //KlausBue 11/99
|
||
|
{
|
||
|
AMSEVENT_ROUTERSTOP = 0,
|
||
|
AMSEVENT_ROUTERSTART = 1,
|
||
|
AMSEVENT_ROUTERREMOVED = 2
|
||
|
}AmsRouterEvent;
|
||
|
|
||
|
typedef void (*PAmsRouterNotificationFunc)( long nEvent );
|
||
|
|
||
|
////////////////////////////////////////////////////////////////////////////////
|
||
|
|
||
|
|
||
|
|
||
|
#pragma pack( pop )
|
||
|
|
||
|
#endif // __ADSDEF_H__
|