Vous êtes sur la page 1sur 224

Industrial PLC Communication Suite Win32 with ACCON-AGLink S7-MPI serial ACCON-AGLink S7-MPI serial/TS ACCON-AGLink S7-PB/CIF ACCON-AGLink

S7-PB/NetLinkDrv ACCON-AGLink S7-PB/Softing ACCON-AGLink S7-TCP/IP ACCON-AGLink S7-TCP/NetLinkIP ACCON-AGLink S7-PPI serial ACCON-AGLink RK512/3964R ACCON-AGLink S5 serial

Version 10.03.2003 1994 2003 DELTALOGIC Automatisierungstechnik GmbH Post Office Box 70 D-73555 Mutlangen Tel.: (+49)-7171-916-120 Fax: (+49)-7171-62676 Internet: http://www.deltalogic.de Hotline: support@deltalogic.de

Page 2

Industrial PLC-Communication Suite

S7-200, S7-300, S7-400, HMI, STEP and SIMATIC are registered trademarks of Siemens AG, ACCON is a registered trademark of Rainer Hnle, DELTALOGIC is a registered trademark of DELTALOGIC Automatisierungstechnik GmbH.

Industrial PLC-Communication Suite

Seite 3

Preface
The quality of an automation solution depends strongly how far the different levels production control, production planning and quality assurance are integrated. One of the main problems is that production data are recorded by a PLC, but a long-term storage and a meaningful evaluation of these data isn't practicable on the PLC. PCs are excellently suitable for an economical solution of such tasks. You can save very much more data and are able to process these data due to the higher programming languages much more efficiently. Till now, unfortunately, PLC and PC couldn't be coupled program technically so that automation solutions frequently weren't realized optimally. The industrial PLC communication suite helps you. This consists of one single library that extends all common Windows programming languages by the ability to contact SIMATIC controls directly out of the PC and exchange data between PLC and PC in a simple way. You can build up the process data communication traffic from any programming language which can call functions in a 32 bit Windows DLL by handling calling simply manageable, efficient and tested functions. The developer needs no knowledge about the different used communication protocols, he can fully concentrate on the further processing of the data (e.g. by means of a data base). The industrial PLC communication suite offers the following highlights: Up to eight ports can be controlled by one PC at the same time. Via every port several PLCs can be addressed at the same time depending on the protocol and the used hardware. The industrial PLC communication suite is written in high optimized C/C++. For this reason there is very little time needed for the communication. From the industrial PLC communication suite you purchase only one developer version per developer place, no further runtime charges have to be paid. The industrial PLC communication suite is available as 32 bit DLL for Windows. For this the industrial PLC communication suite supports a variety of programming languages enables to you to concentrate on your application and not have to learn additional programming languages . Because of the uniform programming interface you can access the different controls without change of the PLC program. With the enclosed configuration tool all communication parameters can be adjusted without having to program the corresponding dialogues.

With the industrial PLC communication suite you can develop applications that collect a large quantity of process data. You can convert and store it into an arbitrary format. You can carry out meaningful evaluations and configure and steer your process therefore optimally. You can also influence the process in a simple way. For this you overwrite certain data ranges in the PLC memory and change the process parameters. With that e.g. a recipe administration is very simply feasible.

Page 4

Industrial PLC-Communication Suite

Industrial PLC-Communication Suite

Seite 5

1
1 2

Table of contents
Table of contents............................................................................................................. 5 The industrial PLC communication suite.................................................................... 14 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 General 14 The idea behind the industrial PLC communication suite ...................................... 15 License contract ..................................................................................................... 15 Support for ACCON-AGLink .................................................................................. 16 Project support ....................................................................................................... 16 Scope of delivery.................................................................................................... 16 Installation instruction ............................................................................................ 19 Limitations of the demo version ............................................................................. 19 Communication processing in general ................................................................... 19

2.10 Error codes............................................................................................................. 20 2.11 Call convention and structure orientation (alignment)............................................ 20 3 Enclosed programs....................................................................................................... 22 3.1 The configuration program (AGLink_Config.EXE) ................................................. 22 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 General ..................................................................................................... 22 The parameters for ACCON-AGLink S7-MPI serial.................................. 24 The parameters for ACCON-AGLink S7-MPI serial/TS ............................ 26 The parameters for ACCON-AGLink S7-PB/CIF ...................................... 32 The parameters for ACCON-AGLink S7 PB/NetLinkDrv .......................... 34 The parameters for ACCON-AGLink S7 PB/Softing................................. 36 The parameters for ACCON-AGLink S7 TCP/IP ...................................... 38 The parameters for ACCON-AGLink S7 TCP/NetLinkIP .......................... 40 The parameters for ACCON-AGLink S7 PPI serial .................................. 42

3.1.10 The parameters for ACCON-AGLink RK512/3964R................................. 43 3.1.11 The parameters for ACCON-AGLink S5 serial ......................................... 45 3.2 3.3 4 DLL info program (AGLink_Info.EXE) .................................................................... 46 Performance test program (AGLink_Performance.EXE) ....................................... 47

First steps ...................................................................................................................... 49

Page 6 4.1

Industrial PLC-Communication Suite First example in Microsoft Visual C/C++ ................................................................ 49 4.1.1 Reading of the diagnosis buffer ................................................................ 52

4.2

Additional hints for VBA ......................................................................................... 53 4.2.1 4.2.2 4.2.3 Remarks to data processing in Excel ....................................................... 54 Hints to the examples in Word and Excel ................................................. 54 The sample programs............................................................................... 55

4.3 5

Additional hints for .NET ........................................................................................ 57

Programming reference administration ...................................................................... 61 5.1 5.2 Releasing or activating AGLink (AGLActivate)....................................................... 61 Opening and closing of the device ......................................................................... 62 5.2.1 5.2.2 5.3 Opening device (AGLOpenDevice) .......................................................... 62 Closing device (AGLCloseDevice)............................................................ 63

Administration of jobs............................................................................................. 64 5.3.1 5.3.2 5.3.3 5.3.4 5.3.5 5.3.6 5.3.7 Setting window message handler (AGLSetWndMsgHandler) .................. 64 Setting thread message handler (AGLSetThrdMsgHandler) .................... 65 Setting event handle (AGLSetEventHandle) ............................................ 66 Installing callback function (AGLSetCallback) .......................................... 67 Waiting for job (AGLWaitForJob).............................................................. 68 Deleting job (AGLDeleteJob) .................................................................... 69 Querying the communication result of a job (AGLGetJobResult) ............. 70

Programming reference communication functions ................................................... 71 6.1 Function reference adapter .................................................................................... 72 6.1.1 6.1.2 6.1.3 6.1.4 6.1.5 6.1.6 6.2 Setting up connection to remote station (AGLDialUp) .............................. 72 Terminating connection to distant terminal (AGLHangUp) ....................... 73 Initializing communication adapter (AGLInitAdapter)................................ 74 Deinitializing communication adapter (AGLExitAdapter) .......................... 75 Querying active bus users (AGLGetLifeList) ............................................ 76 Querying directly attached PLC (AGLGetDirectPLC) ............................... 77

Function reference PLC ......................................................................................... 78 6.2.1 6.2.2 6.2.3 6.2.4 6.2.5 6.2.6 Setting up connection to a PLC (AGLPLCConnect) ................................. 78 Setting up connection to a PLC (AGLPLCConnectEx) ............................. 79 Disconnecting connection to a PLC (AGLPLCDisconnect) ...................... 81 Reading MLFB number of the PLC (AGLReadMLFBNr) .......................... 82 Reading extended MLFB number of the PLC (AGLReadMLFBNrEx) ...... 83 Reading AG-Info (AGLReadPLCInfo)...................................................... 85

Industrial PLC-Communication Suite 6.2.7 6.2.8 6.2.9

Seite 7

Reading diagnostic buffer of the PLC (AGLReadDiagBuffer)................... 87 Converting content of diagnostic buffer to text (AGLReadDiagBufferEntry) ...................................................................... 89 Querying operating state of the PLC (AGLReadOpState) ........................ 90

6.2.10 Stopping PLC (AGLPLCStop)................................................................... 91 6.2.11 Executing restart of the PLC (AGLPLCStart)............................................ 92 6.2.12 Executing resume of the PLC (AGLPLCResume) .................................... 93 6.3 Function reference reading data ............................................................................ 94 6.3.1 6.3.2 6.3.3 6.3.4 6.3.5 6.3.6 6.3.7 6.3.8 6.3.9 Reading input bytes (AGLReadInBytes)................................................... 94 Reading peripheral input bytes (AGLReadPInBytes) ............................... 95 Reading output bytes (AGLReadOutBytes).............................................. 96 Reading flag bytes (AGLReadFlagBytes)................................................. 97 Reading special flag bytes (AGLReadSFlagBytes) .................................. 98 Reading variables bytes (AGLReadVarBytes)........................................ 100 Reading data bytes (AGLReadDataBytes) ............................................. 102 Reading timer words (AGLReadTimerWords) ........................................ 103 Reading counter words (AGLReadCounterWords) ................................ 104

6.3.10 Mixed reading job (AGLReadMix)........................................................... 105 6.4 Function reference writing data............................................................................ 107 6.4.1 6.4.2 6.4.3 6.4.4 6.4.5 6.4.6 6.4.7 6.4.8 6.4.9 Writing input bytes (AGLWriteInBytes) ................................................... 107 Writing output bytes (AGLWriteOutBytes) .............................................. 108 Writing peripheral output bytes (AGLWritePOutBytes)........................... 109 Writing flag bytes (AGLWriteFlagBytes) ................................................. 110 Writing Special flag bytes (AGLWriteSFlagBytes) .................................. 111 Writing variables bytes (AGLWriteVarBytes) .......................................... 113 Writing data bytes (AGLWriteDataBytes) ............................................... 115 Writing Timer words (AGLWriteTimerWords) ......................................... 116 Writing Counter words (AGLWriteCounterWords) .................................. 117

6.4.10 Mixed writing job (AGLWriteMix) ............................................................ 118 6.5 Functions reference data block information ......................................................... 120 6.5.1 6.5.2 6.5.3 7 Determine number of data blocks (AGLReadDBCount) ......................... 120 Reading data block directory (AGLReadDBList) .................................... 121 Reading length of a data block (AGLReadDBLen) ................................. 122

Programming reference supplementary functions .................................................. 123 7.1 Function reference reading functions................................................................... 123 7.1.1 7.1.2 Reading 16 bit integer from byte buffer (AGLReadInt16) ....................... 123 Reading word from byte buffer (AGLReadWord).................................... 124

Page 8 7.1.3 7.1.4 7.1.5 7.2

Industrial PLC-Communication Suite Reading double word from byte buffer (AGLReadDWord) ..................... 125 Reading floating point number (real) from byte buffer (AGLReadReal) ...................................................................................... 126 Reading S5 time from byte buffer (AGLReadS5Time) ........................... 127

Function reference writing functions ................................................................... 128 7.2.1 7.2.2 7.2.3 7.2.4 Writing word into byte buffer (AGLWriteWord) ....................................... 128 Writing double word into byte buffer (AGLWriteDWord) ......................... 129 Writing floating point number (real) into byte buffer (AGLWriteReal) ..... 130 Writing S5 time into byte buffer (AGLWriteS5Time) ............................... 131

7.3

Function reference buffer convert functions......................................................... 132 7.3.1 7.3.2 7.3.3 7.3.4 7.3.5 7.3.6 7.3.7 7.3.8 Converting byte buffer into word buffer (AGLByte2Word) ...................... 132 Converting byte buffer into double word buffer (AGLByte2DWord)........ 133 Converting byte buffer into floating point number (real) buffer (AGLByte2Real)...................................................................................... 134 Converting word buffer into byte buffer (AGLWord2Byte) ...................... 135 Converting double word buffer into byte buffer (AGLDWord2Byte)........ 136 Converting floating point number (real) buffer into byte buffer (AGLReal2Byte)...................................................................................... 137 Converting string into byte buffer (AGLString2Buff) ............................... 138 Converting byte buffer into string(AGLBuff2String) ................................ 139

7.4

Function reference bit functions ........................................................................... 140 7.4.1 7.4.2 7.4.3 7.4.4 Requesting bit status (AGLGetBit).......................................................... 140 Setting bit on the value one (AGLSetBit) ................................................ 141 Setting bit on the value zero (AGLResetBit) ........................................... 142 Setting bit on value (AGLSetBitVal)........................................................ 143

7.5

Function reference miscellaneous ....................................................................... 144 7.5.1 7.5.2 Finding error text to the corresponding error code (AGLGetErrorMsg).................................................................................. 144 Adjusting time function for result (AGLUseSystemTime)........................ 145

7.6

Function reference DLL info functions ................................................................. 146 7.6.1 7.6.2 7.6.3 7.6.4 7.6.5 Determine version number of the DLL (AGLGetDLLVersion)................. 146 Determine extended version number of the DLL (AGLGetDLLVersionEx) ......................................................................... 147 Determine available options of the DLL (AGLGetOptions) ..................... 148 Determine serial number of the DLL (AGLGetSerialNumber) ................ 149 Determine the licensee of the DLL (AGLGetClientName) ...................... 150

Additional functions for VB and VBA ........................................................................ 151

Industrial PLC-Communication Suite 8.1 8.2 9

Seite 9

Returning an error message (AGLErrMsg) .......................................................... 151 Returning entry from the diagnostic buffer (AGLDiagBufferEntry) ....................... 152

Programming reference configuration functions..................................................... 153 9.1 Functions for reading the parameters from the registry ....................................... 153 9.1.1 9.1.2 9.1.3 9.1.4 9.1.5 9.1.6 9.1.7 9.1.8 9.1.9 Reading the complete device settings (AGLReadDevice)...................... 153 Reading device type (AGLReadDevType).............................................. 154 Reading port parameters S7-MPI serial (AGLReadIFPMPI) .................. 155 Reading port parameters S7-MPI serial/TS (AGLReadIFPTS) .............. 156 Reading location parameters S7-MPI serial/TS (AGLReadLPTS) ......... 157 Reading dial number parameters S7-MPI serial/TS (AGLReadDPTS) .. 158 Reading port parameters S7-PB/CIF (AGLReadIFPCIF) ....................... 159 Reading port parameters S7-PB/NetLinkDrv (AGLReadIFPNLDRV) ..... 160 Reading port parameters S7-PB/Softing (AGLReadIFPSOFTING)........ 161

9.1.10 Reading port parameters S7-TCP/IP (AGLReadIFPTCPIP) .................. 162 9.1.11 Reading port parameters S7-TCP/NetLinkIP (AGLReadIFPNLIP)......... 163 9.1.12 Reading port parameters S7-PPI serial (AGLReadIFPPPI) ................... 164 9.1.13 Reading port parameters RK512/3964R (AGLReadIFPRK)................... 165 9.1.14 Reading port parameters S5 serial (AGLReadIFPS5)............................ 166 9.2 Functions for writing the parameters into the registry .......................................... 167 9.2.1 9.2.2 9.2.3 9.2.4 9.2.5 9.2.6 9.2.7 9.2.8 9.2.9 Writing the complete device settings (AGLWriteDevice) ........................ 167 Writing device type (AGLWriteDevType) ................................................ 168 Writing port parameters S7-MPI serial (AGLWriteIFPMPI)..................... 169 Writing port parameters S7-MPI serial/TS (AGLWriteIFPTS)................. 170 Writing location parameters S7-MPI serial/TS (AGLWriteLPTS)............ 171 Writing dial number parameters S7-MPI serial/TS (AGLWriteDPTS)..... 172 Writing port parameters S7-PB/CIF (AGLWriteIFPCIF).......................... 173 Writing port parameters S7-PB/NetLinkDrv (AGLWriteIFPNLDRV) ....... 174 Writing port parameters S7-PB/Softing (AGLWriteIFPSOFTING) .......... 175

9.2.10 Writing port parameters S7-TCP/IP (AGLWriteIFPTCPIP)..................... 176 9.2.11 Writing port parameters S7-TCP/NetLinkIP (AGLWriteIFPNLIP) ........... 177 9.2.12 Writing port parameters S7-PPI serial (AGLWriteIFPPPI)...................... 178 9.2.13 Writing port parameters RK512/3964R (AGLWriteIFPRK) ..................... 179 9.2.14 Writing port parameters S5 serial (AGLWriteIFPS5) .............................. 180 9.3 Functions for querying the parameters ................................................................ 181 9.3.1 9.3.2 Querying the device type (AGLGetDevType) ......................................... 181 Querying the port parameters for S7-MPI serial (AGLGetIFPMPI)......... 182

Page 10 9.3.3 9.3.4 9.3.5 9.3.6 9.3.7 9.3.8 9.3.9

Industrial PLC-Communication Suite Querying the port parameters for S7-MPI serial/TS (AGLGetIFPTS)..... 183 Querying the location parameters for S7-MPI serial/TS (AGLGetLPTS) ....................................................................................... 184 Querying the dial number parameters for S7-MPI serial/TS (AGLGetDPTS)....................................................................................... 185 Querying the port parameters for S7-PB/CIF (AGLGetIFPCIF).............. 186 Querying the port parameters for S7-PB/NetLinkDrv (AGLGetIFPNLDRV)............................................................................... 187 Querying the port parameters for S7-PB/Softing (AGLGetIFPSOFTING)........................................................................... 188 Querying the port parameters for S7-TCP/IP (AGLGetIFPTCPIP) ......... 189

9.3.10 Querying the port parameters for S7-TCP/NetLinkIP (AGLGetIFPNLIP)................................................................................... 190 9.3.11 Querying the port parameters for S7-PPI serial (AGLGetIFPPPI).......... 191 9.3.12 Querying the port parameters for RK512/3964R (AGLGetIFPRK) ......... 192 9.3.13 Querying the port parameters for S5 serial (AGLGetIFPS5) .................. 193 9.4 Functions for setting the parameters.................................................................... 194 9.4.1 9.4.2 9.4.3 9.4.4 9.4.5 9.4.6 9.4.7 9.4.8 9.4.9 Setting device type (AGLSetDevType) ................................................... 194 Setting port parameters S7-MPI serial (AGLSetIFPMPI)........................ 195 Setting port parameters S7-MPI serial/TS (AGLSetIFPTS).................... 196 Setting location parameters S7-MPI serial/TS (AGLSetLPTS)............... 197 Setting dial number parameters S7-MPI serial/TS (AGLSetDPTS)........ 198 Setting port parameters S7-PB/CIF (AGLSetIFPCIF)............................. 199 Setting port parameters S7-PB/NetLinkDrv (AGLSetIFPNLDRV) .......... 200 Setting port parameters S7-PB/Softing (AGLSetIFPSOFTING) ............. 201 Setting port parameters S7-TCP/IP (AGLSetIFPTCPIP)........................ 202

9.4.10 Setting port parameters S7-TCP/NetLinkIP (AGLSetIFPNLIP) .............. 203 9.4.11 Setting port parameters S7-PPI serial (AGLSetIFPPPI)......................... 204 9.4.12 Setting port parameters RK512/3964R (AGLSetIFPRK) ........................ 205 9.4.13 Setting port parameters S5 serial (AGLSetIFPS5) ................................. 206 9.5 Additional functions .............................................................................................. 207 9.5.1 Calling external configuration program (AGLConfig) .............................. 207

10 Appendix A 209 10.1 Q&A list for ACCON-AGLink ................................................................................ 209 10.1.1 Whats about the transmission speed of ACCON-AGLink ?................... 209 10.1.2 Do I have to change my program, when I need an additional module? .................................................................................................. 210 10.1.3 When I need e.g. MPI serial and TCP/IP, do I obtain two different DLL versions?......................................................................................... 210

Industrial PLC-Communication Suite

Seite 11

10.1.4 Which advantages offer ACCON-AGLink to me? ................................... 210 10.1.5 What happens when there appear new hardware components, which were not yet supported from my ACCON-AGLink release? ......... 210 10.1.6 Whats about a demo version of ACCON-AGLink? ................................ 210 10.1.7 What is the scope of the demo version of ACCON-AGLink?.................. 211 10.1.8 Do I have to pay runtime charges for programs that are developed with ACCON-AGLink? ............................................................................ 211 10.1.9 Do I need for ACCON-AGLink S7-MPI serial/TS the TS software from Siemens?........................................................................................ 211 10.1.10 What happens when the cable is removed using ACCON-AGLink S7- MPI serial? ....................................................................................... 211 10.1.11 How large can the requested data packets be? ..................................... 211 10.1.12 Can I also read double words with ACCON-AGLink?............................. 211 10.1.13 For accessing the PLC do I have to change the S7 program? ............... 212 10.1.14 Can I access with ACCON-AGLink S7-MPI the PLC also via Profibus? ................................................................................................ 212 10.1.15 What can I do, when the communication via PC adapter is too slow? ... 212 10.1.16 Does every arbitrary Profibus card works with ACCON-AGLink S7PB? ......................................................................................................... 212 10.1.17 How can I access to the S7 with a PC adapter, when the MPI port is occupied from a OP? .............................................................................. 212 10.1.18 How can I access with ACCON-AGLink multiple PLCs simultaneous? ........................................................................................ 212 10.1.19 Can I connect the PPI cable only to one series 200 PLC? ..................... 213 10.1.20 The function AGLPLCConnect of ACCON AGLink S7 TCP/IP is successful, however the reading of the data provides an error code. What's wrong? ........................................................................................ 213 10.1.21 Why appears under Windows 95 an error message during processing a with ACCON-AGLink developed program ? ...................... 213 10.1.22 Why are the device settings not permanently stored under Windows 2000/XP ? ............................................................................................... 213 10.2 Documentation of updates release 2.x................................................................. 215 10.2.1 Release 2.1 ............................................................................................ 215 10.2.2 Release 2.2 ............................................................................................ 215 10.2.3 Release 2.3 ............................................................................................ 216 10.2.4 Release 2.3.1 ......................................................................................... 216 10.2.5 Release 2.4 ............................................................................................ 217 10.3 Documentation of updates release 3.x................................................................. 218 10.3.1 Release 3.0 ............................................................................................ 218 10.3.2 Version 3.1 ............................................................................................. 219 11 Appendix C 222

Page 12

Industrial PLC-Communication Suite

11.1 Software license agreement................................................................................. 222

Industrial PLC-Communication Suite

Seite 13

Page 14

Industrial PLC-Communication Suite

2
2.1

The industrial PLC communication suite


General

The industrial PLC communication suite consists of one single library where all functions of your license are included. The possible communication modules are: 1. 2. 3. 4. 5. 6. 7. 8. 9. ACCON-AGLink S7-MPI serial for the access to the SIMATIC S7 300 and S7 400 via PC adapter ACCON-AGLink S7-MPI serial/TS for the access to the SIMATIC S7 300 and S7 400 via a modem and the TS adapter ACCON-AGLink S7-PB/CIF for the access to the SIMATIC S7 300 and S7 400 via the ACCON-PB/MPI card ACCON-AGLink S7-PB/NetLinkDrv for the access to the SIMATIC S7 300 and S7 400 via the equipment driver of the ACCON-NetLink adapter ACCON-AGLink S7-PB/Softing for the access to the SIMATIC S7 300 and S7 400 via the Profibus boards of the company Softing ACCON-AGLink S7-TCP/IP for the access to the SIMATIC S7 300 and S7 400 via Ethernet ACCON-AGLink S7-TCP/NetLinkIP for the access to the SIMATIC S7 300 and S7 400 via the TCP/IP interface of the ACCON-NetLink adapter ACCON-AGLink S7-PPI serial for the access to the SIMATIC S7 200 ACCON-AGLink RK512/3964R for the RK512/3964 R communication

10. ACCON-AGLink S5 serial for the access to the SIMATIC S5 family The function library has been developed and tested in detail for Windows 98, Windows NT, Windows 2000 and Windows XP. As test programming languages MS Visual C/C++ 6, MS Visual BASIC 6, Borland C++ Builder 5, Delphi 5, NI LabView, MS Excel, MS C# and MS VB.net were used. Examples that clarify the application and make the start easier are provided to the function library. Please contact us if you need the support of the library for further platforms, e.g. MS DOS, Win 3.1 x, Windows CE, RTKernel, RTOS 32 or Linux.

Industrial PLC-Communication Suite

Seite 15

2.2

The idea behind the industrial PLC communication suite

In the industrial automation surroundings exists different control and therefore also communication standards. If access to different products is required, this means often 1. Search for a communication toolbox supplier 2. Acquisition of a new communication toolbox 3. Training into the contained functions 4. Hoping that the tools of the different manufacturers can be selected from one single program without problems. (Since a serial interface for the communication is often needed, this leads easily to complications.) 5. Adaptation of own programs 6. Administration of different releases This procedure is not only cost, but also time intensive. With the industrial PLC communication suite is now possible to access the different communication drivers with a uniform software interface. For sure, this can also be handled with OPC but not with such a low overhead and the compactness of industrial PLC communication suite. The mode of communication and the communication parameters can be set comfortably with a separate program and also by program code. The currently used communication driver can be used to investigate the run time. Furthermore every communication module still offers additional functions, to address the controls quite specifically. For portable programming it must be checked that for the other modules there must be possible that an error code can be delivered as a function result. With this technique it is possible to modify the interface for the S7 access without program changes or to modify the local access into an access via telephone and modem.

2.3

License contract

With the purchase of the library you have purchased the single, non-exclusive right to develop programs with use of the industrial PLC communication suite and distribute these programs arbitrarily often and without paying further license fees. Every developer who works with the industrial PLC communication suite completely or in parts, need his own license and thats it, further fees don't arise. Excluded from the license fee free disclosure are of course products, which are comparable in any kind with the industrial PLC communication suite (software interface for the access to PLC data, e.g. OPC servers based on the industrial PLC communication suite) or if the products are libraries or development tools. Provided that you have purchased the source code of the industrial PLC communication suite, you only may use this for the integration into your own products. Every disclosure or publication of the source code, the contained protocol documentation or components is forbidden. Also it is not allowed to develop and distribute products that are comparable with the industrial PLC communication suite in the way described above. This is also valid for the adaptation to another platform or another operating system.

Page 16

Industrial PLC-Communication Suite

The complete and detailed license agreement is included in the appendix in chapter 12.1 "software license agreement" on page 221.

2.4

Support for ACCON-AGLink

If questions or problems arise when using the industrial PLC communication suite, please consult our technical support. You can contact us either by phone either under (+49)-7171916-112 or preferably by e-mail: support@deltalogic.de. Send us your questions or the problem description with detail of the compiler release, the operating system release and the minimal source text part or even better with the minimal project with which the behavior can be reproduced. You get very quickly support from the developer team of the industrial PLC communication suite. Please check first, if your problem is already solved in the appendix in chapter documentation of updates on page 183 and if a solution is already offered or a new release is available.

2.5

Project support

Contact us if you have a personnel bottleneck or have simply need for competent project support. We offer you to realize economically partial or also complete projects for you with the industrial PLC communication suite according to your wishes and your requests. Contact us, we like to make you an offer without obligation.

2.6

Scope of delivery

The industrial PLC communication suite is delivered on a CD and a diskette. On the CD all base programs, examples and the demo version of the DLL is included. These are in particular: \AGLink_Demo\BCB AGLink.H AGLink.LIB AGLink_Test.BPF AGLink_Test.BPR AGLink_Test.EXE Unit1.CPP include file for C/C++ the ACCON-AGLink import library for Borland C++-Builder Borland C++-Builder module file Borland C++-Builder project file compiled example program ACCON-AGLink demo program as console application

\AGLink_Demo\Delphi AGLink.PAS AGLink_Test.CFG AGLink_Test.DOF module file for Delphi Delphi configuration file Delphi option file

Industrial PLC-Communication Suite AGLink_Test.DPR AGLink_Test.EXE

Seite 17

ACCON-AGLink demo program as console application compiled example program

\AGLink_Demo\DotNET \C# \VB.NET Dateien.TXT directory with all examples for C-Sharp directory with all examples for VB.NET additional description of files in the corresponding sub-directories

\AGLink_Demo\LabView AGLink.LLB Liesmich.TXT library file for LabView additional hints

\AGLink_Demo\VB AGLink.BAS AGParameter.FRM AGParameter.FRX Konfiguration.FRM Konfiguration.FRX MiniDemo.EXE MiniDemo.FRM MiniDemo.VBP MiniDemo.VBW S7CPU.FRM S7CPU.FRX VBDemo.EXE VBDemo.VBP VBDemo.VBW Win32.BAS \Paket module definition file for Visual Basic Visual Basic example file, for setting the PLC parameters (address, operands, etc.) Visual Basic FRX file main format of the example Visual Basic FRX file compiled example program Visual Basic file minimal example Visual Basic project file Visual Basic file format with picture of a S7-300-CPU Visual Basic FRX file compiled example program Visual Basic project file Visual Basic file module definition file with requested Win32API functions directory with installation program for VBDemo (if VB is not installed on the destination computer and you want to execute the example)

\AGLink_Demo\VBA

Page 18 *.DOC *.XLS *.TXT \Module+Forms

Industrial PLC-Communication Suite examples for Microsoft Word examples for Microsoft Excel additional explanations formats and modules used for VBA examples

\AGLink_Demo\VC AGLink.H AGLink.LIB AGLink_Test.CPP AGLink_Test.DSP AGLink_Test.DSW AGLink_Test.EXE AGLink_Test.OPT \FirstSteps include file for C/C++ ACCON-AGLink import library for Visual C/C++ ACCON-AGLink demo program as console application VC project file VC workspace compiled example program VC option file examples from the chapter first steps

\AGLink_Doku AGLink_Handbuch.PDF this documentation in PDF format

\AGLink_Redist AGLink.DLL the ACCON-AGLink library (demo version). Replace this file with licensed version of your original floppy disk. configuration program for parameterization of the communication path, similar adapting the PG/PC-interface file with german error message texts file with english error message texts

AGLink_Config.EXE

AGLink_Error.TXT AGLink_Error.ENG

\AGLink_Tools AGLink.H AGLink.LIB AGLink_Info.CPP AGLink_Info.DSP AGLink_Info.EXE include file for C/C++ the ACCON-AGLink import library for Visual C/C++ source code for info program VC project file program to determine the DLL version, the serial number, the license scope and the licensee.

AGLink_Performance.CPP source code for performance test program

Industrial PLC-Communication Suite AGLink_Performance.DSP VC project file

Seite 19

AGLink_Performance.Exe program to determine the communication speed or the data throughput Tools.DSW Tools.NCB Tools.OPT VC workspace VC program data base VC option file

On the floppy disk your find your licensed version of the industrial PLC communication suite in form of your version of the file "AGLink.DLL" . The additional files that you can forward to your customers in the context of the license conditions are on the CD in the directory \AGLink_Redist.

2.7

Installation instruction

You simply copy the CD contents into a directory of your choice, e.g. in C: \AGLink. Copy the files from the directory AGLink_Redist in the selected demo directories. Or you can copy these files in the system directory of Windows (e.g. C:\WINNT\SYSTEM32 for Windows NT or Windows 2000) This path can be located from all demo programs. If necessary reset the ReadOnly file attribute. In the demo DLL of the CD all currently available modules of ACCON-AGLink are contained. The DLL on your floppy disk contains only the modules purchased by you. If you like to test the further modules, then you simply keep the demo DLL. If only you like to work with the modules purchased by you, then you simply copy the file AGLink.DLL of your floppy disk and overwrite every DLL version of the CD. Since Version 3.1 you have the possibility to invoke the Setup program on the CD. You can enter interactively the selected settings and select the corresponding examples for the different programming languages. For the program development you copy the file AGLink.DLL of your floppy disk into your project directory, into the system directory of Windows or into another list in the search path. As a starting point for your application development you can simply use the example programs of your programming language and complete these correspondingly.

2.8

Limitations of the demo version

All functions of the complete version are at your disposal in the demo version. Every 5 minutes appears a small indication that you use the demo version of ACCON-AGLink. Further reduction, e.g. amount of handled data, is no longer contained since version 2.3. You can therefore check ACCON-AGLink for all conditions and get a view of the efficiency of this toolbox.

2.9

Communication processing in general

In this chapter the fundamental processing of a communication sequence is briefly explained. Please find the detailed description of the individual functions as well as the parameters and return values in the reference part of this manual.

Page 20

Industrial PLC-Communication Suite

Select the requested communication path with the program AGLink_Config.EXE. If you like to access a S7 control via a PC or TS adapter, then attach it to the parameterized port and adjust the baud rate at the adapter to 38400 bauds preferably. If you work with an ACCONMPI adapter (with an automatic baud rate recognition), then this is always controlled by ACCON-AGLink with its maximum communication speed. First call the function AGLActivate with your personal account. Then select next the function AGLOpenDevice. It checks whether the requested port exists and is available in the system. For compatibility reasons towards the TS version, please select as next function AGLDialUp. When you do not communicate via modem, the return value of this function is always success. In case of a modem connection, the function tries to dial the remote terminal. Now initialize the communication adapter with the function AGLInitAdapter. In case of a S7 communication, you can query the participants attached at the bus with the function AGLGetLifeList . Or when you communicate via a PC-/ TS adapter query the directly attached PLC with the function AGLGetDirectPLC. You can now build up a connection to the PLC with the function AGLPLCConnect or AGLPLCConnectEx. All functions can now be used to access to the PLC. Disconnect the connection with the function AGLPLCDisconnect. Sign off from the communication hardware with the function AGLExitAdapter. Terminate the modem connection with the function AGLHangUp. Unlock the resources with the function AGLCloseDevice. It is important that after every function Open, DialUp, Init, Connect must be called a function Close, HangUp, Exit, Disconnect.

2.10 Error codes


In ACCON AGLink after every function call an error code will be returned. Since changes of the absolute values can arise with later software releases, please always use the symbolic constants in the query. The meaning of the error codes is described in the respective header or module file.

2.11 Call convention and structure orientation (alignment)


The call convention of the DLL is for Win32 __stdcall. In C/C++ this is achieved with the definition of
#define AGLINK_API WINAPI

In Visual Basic standardcall is anyway the default setting for DLL functions. In Delphi the call convention stdcall is listed explicit behind every function declaration. For the data types a byte orientation is adjusted by pragmas in the header file. If possible the structures were arranged that in minimum one word alignment of the individual elements is

Industrial PLC-Communication Suite

Seite 21

possible (among other things because of VB). Where not doable, explicit filler bytes were implemented.

Page 22

Industrial PLC-Communication Suite

3
3.1

Enclosed programs
The configuration program (AGLink_Config.EXE)

3.1.1

General

You can handle the complete parameter and interface setting with the function AGLink_Config.EXE. When you execute this externally and not program-dependent, you can change in case of communication hardware change e.g. from PC adapter to Profibus card, only the setting and your application immediately runs without program changes. The function AGLink_Config.EXE requires only functions of the ACCON-AGLink.DLL, this means that the complete parameter setting is also feasible with your application. Call the program AGLink_Config.EXE.

Industrial PLC-Communication Suite

Seite 23

On the left side you can now select the requested device and adjust the type of the device in the accompanying combo box. In the Tab-Control on the right side there are always shown the configuration selections that match to the type. When you change the settings, the Change-button gets active and you can assign the changes of the chosen device, that means storing in the registry of the PC. If you exit the program with OK, all data sets that don't correspond to the standard setting are stored in the registry. For every device all communication paths are completely adjustable independently of each other. You can switch over the communication channel in the program with the function AGLSetDevType (of course only when the device is not opened) .You also can parameterize e.g. DEVICE 0 for the direct access and DEVICE 1 for the modem access. Depending which device you now used by program control, the access is via the local or the remote adapter. Or you use only DEVICE 0 and let it to your customer's decision, which way he chooses for the current access. Tip: You can also call the configuration program in the program with the function AGLConfig. For this the function must be in the current path. With this you don't have to program all dialogues completely. And you may forward the configuration program of course with your application in the context of the license conditions to your customers.

Page 24

Industrial PLC-Communication Suite

3.1.2

The parameters for ACCON-AGLink S7-MPI serial

The settings correspond to the following structure in C/C++:


typedef struct tagIFPARA_MPI { int PortNr; // // // // // // // // COM port for MPI adapter maximal baud rate to check minimal baud rate to check default HSA default PG address default timeout baud rate of MPI bus flag if PG/PC is single master on the bus long MaxBaud; long MinBaud; int int int int HSA; PGAdr; Timeout; SingleMaster;

long MPIBaud;

Industrial PLC-Communication Suite


int int int int int int int int Profil; ConnTyp; Reserve3; Reserve4; Reserve5; Reserve6; Reserve7; Reserve8; // // //

Seite 25
type of parameter (MPI, DP, standard, universal (DP/FMS)) type of connection (PG, OP or others) for possible extensions

} IFPARA_MPI, *LPIFPARA_MPI;

Page 26

Industrial PLC-Communication Suite

3.1.3

The parameters for ACCON-AGLink S7-MPI serial/TS

Industrial PLC-Communication Suite

Seite 27

The parameters of the pages `Schnittstelle and `Modem correspond to the following structure in C/C++:
typedef struct tagIFPARA_TS { int int int int int PortNr; DataBits; Parity; StopBits; Handshake; // // // // // // // // COM port for modem max. baud rate for modem data bits: 7, 8 parity: AGL_PARITY_NONE, AGL_PARITY_EVEN, AGL_PARITY_ODD stop bits: 1, 2 type of handshake: AGL_HANDSHAKE_HW, AGL_HANDSHAKE_SW, AGL_HANDSHAKE_NONE initialization string 1 for modem, will be checked for error return code initialization string 2 for modem, will be checked for error return code long MaxBaud;

char InitModem1[INIT_LEN]; char InitModem2[INIT_LEN];

Page 28
char InitModem3[INIT_LEN]; char InitModem4[INIT_LEN]; // //

Industrial PLC-Communication Suite


initialization string 3 for modem, will be checked for error return code initialization string 4 for modem, will NOT be checked for error return code (because of AT+CPIN=xxxx) Dialing procedure: empty for standard, 'T' for voice-frequency signaling, 'P' for pulse-frequency signaling number of bell characters until accepting the call: empty for standard, '0' to '9' if to be waited for dial tone: empty for standard, '4' for waiting for dial tone, '3' for dialing without dial tone filler byte with no meaning default timeout number of dial retries waiting time in seconds

char DialType;

//

char AutoAnswer;

//

char WaitForDialtone;

//

char dummy; int int int Timeout; DialRetries; RetryDelay;

// // // //

} IFPARA_TS, *LPIFPARA_TS;

Industrial PLC-Communication Suite

Seite 29

The parameters of the pages `Standort correspond to the following structure in C/C++:
typedef struct tagLOCPARA_TS { char OwnNoCountry[PHONENO_LEN]; // own country code without international prefix, e.g. 49 for Germany, 41 for Switzerland ... own city code, e.g. 0711 for Stuttgart, 07171 for Mutlangen ... own calling number, e.g. 916100 for DELTALOGIC GmbH exchange connection for international connections

char OwnNoCity[PHONENO_LEN]; char OwnNoLocal[PHONENO_LEN];

// //

char PreNoCountry[PHONENO_LEN]; // char PreNoCity[PHONENO_LEN]; char PreNoLocal[PHONENO_LEN];

// exchange connection for national connections // exchange connection for local connections

Page 30
} LOCPARA_TS, *LPLOCPARA_TS;

Industrial PLC-Communication Suite

The parameters of the pages ` Rufnummer correspond to the following structure in C/C++:
typedef struct tagDPARA_TS { char CallNoCountry[PHONENO_LEN];// char CallNoCity[PHONENO_LEN]; char CallNoLocal[PHONENO_LEN]; char User[PHONENO_LEN]; char Password[PHONENO_LEN]; } DPARA_TS, *LPDPARA_TS; // // // // country code of the destination number without international prefix city code of the destination number calling number of the destination number user code for calling to an adapter (8 byte data information!) password for calling to an adapter (8 byte data information!)

Industrial PLC-Communication Suite

Seite 31

Page 32

Industrial PLC-Communication Suite

3.1.4

The parameters for ACCON-AGLink S7-PB/CIF

The parameters correspond to the following structure in C/C++:


typedef struct tagIFPARA_CIF { int int int int int int int BoardNr; HSA; PGAdr; Timeout; SingleMaster; Profil; ConnTyp; // // // // // // // // number of card/board to be used default HSA default PG address default timeout baud rate of the MPI bus flag if PG/PC is single master on bus type of parameter (MPI, DP, standard, universal (DP/FMS)) type of connection (PG, OP or others)

long MPIBaud;

Industrial PLC-Communication Suite


int int int int int int Reserve3; Reserve4; Reserve5; Reserve6; Reserve7; Reserve8; // for future extensions

Seite 33

} IFPARA_CIF, *LPIFPARA_CIF;

Page 34

Industrial PLC-Communication Suite

3.1.5

The parameters for ACCON-AGLink S7 PB/NetLinkDrv

The parameters correspond to the following structure in C/C++:


typedef struct tagIFPARA_NL_DRV { int int int int int int int NLNr; HSA; PGAdr; Timeout; SingleMaster; Profil; ConnTyp; // // // // // // // // number of NetLink to be used default HSA default PG address default timeout baud rate of the MPI bus flag if PG/PC is single master on bus type of parameter (MPI, DP, standard, universal (DP/FMS)) type of connection (PG, OP or others)

long MPIBaud;

Industrial PLC-Communication Suite


int int int int int int Reserve3; Reserve4; Reserve5; Reserve6; Reserve7; Reserve8; // for future extensions

Seite 35

} IFPARA_NL_DRV, *LPIFPARA_NL_DRV;

Page 36

Industrial PLC-Communication Suite

3.1.6

The parameters for ACCON-AGLink S7 PB/Softing

The parameters correspond to the following structure in C/C++:


typedef struct tagIFPARA_SOFTING { int int int int int int int BoardNr; HSA; PGAdr; Timeout; SingleMaster; Profil; ConnTyp; // // // // // // // // number of card/board to be used default HSA default PG address default timeout baud rate of the MPI bus flag if PG/PC is single master on bus type of parameter (MPI, DP, standard, universal (DP/FMS)) type of connection (PG, OP or others)

long MPIBaud;

Industrial PLC-Communication Suite


int int int int int int Reserve3; Reserve4; Reserve5; Reserve6; Reserve7; Reserve8; // for future extensions

Seite 37

} IFPARA_SOFTING, *LPIFPARA_SOFTING;

Page 38

Industrial PLC-Communication Suite

3.1.7

The parameters for ACCON-AGLink S7 TCP/IP

The parameters correspond to the following structure in C/C++:


typedef struct tagPLCDEF { int int int PlcNr; Rack; Slot; // // // // logical number for PLC TCP/IP destination address or name used rack used slot char Dest[64];

} PLCDEF, *LPPLCDEF;

Industrial PLC-Communication Suite


typedef struct tagIFPARA_TCPIP { int Timeout; // // // default timeout PLCDEF Plc[MAX_PLC]; int int int int int int int int Reserve1; Reserve2; Reserve3; Reserve4; Reserve5; Reserve6; Reserve7; Reserve8;

Seite 39

for lifelist etc. for accessing with "regular" PLC number for future extensions

} IFPARA_TCPIP, *LPIFPARA_TCPIP;

Page 40

Industrial PLC-Communication Suite

3.1.8

The parameters for ACCON-AGLink S7 TCP/NetLinkIP

The parameters correspond to the following structure in C/C++:


typedef struct tagIFPARA_NL_IP { char Dest[64]; int int int int int int HSA; PGAdr; Timeout; SingleMaster; Profil; ConnTyp; // // // // // // // // TCP/IP destination address or name default HSA default PG address default timeout baud rate of the MPI bus flag if PG/PC is single master on bus type of parameter (MPI, DP, standard, universal (DP/FMS)) type of connection (PG, OP or others)

long MPIBaud;

Industrial PLC-Communication Suite


int int int int int int Reserve3; Reserve4; Reserve5; Reserve6; Reserve7; Reserve8; // for future extensions

Seite 41

} IFPARA_NL_IP, *LPIFPARA_NL_IP;

Page 42

Industrial PLC-Communication Suite

3.1.9

The parameters for ACCON-AGLink S7 PPI serial

The parameters correspond to the following structure in C/C++:


typedef struct tagIFPARA_PPI { int int int int PortNr; HSA; PGAdr; Timeout; // // // // // COM port for PPI adapter baud rate for communication default HSA default PG address default timeout long Baud;

} IFPARA_PPI, *LPIFPARA_PPI;

Industrial PLC-Communication Suite

Seite 43

3.1.10

The parameters for ACCON-AGLink RK512/3964R

The parameters correspond to the following structure in C/C++:


typedef struct tagIFPARA_RK { int int int int int int PortNr; HighPrio; UseBCC; Timeout; CPUNr; KMByte; // // // // // // // COM port for communication baud rate to be used flag if high priority flag if 3964R is used (with checksum) default timeout CPU number for RK512, valid values 14 and 15 switching flag byte number for RK512, valid values 0-255 long Baud;

Page 44
int KMBit; //

Industrial PLC-Communication Suite


switching flag bit number for RK512, valid values 0-7 and 15

} IFPARA_RK, *LPIFPARA_RK;

Industrial PLC-Communication Suite

Seite 45

3.1.11

The parameters for ACCON-AGLink S5 serial

The parameters correspond to the following structure in C/C++:


typedef struct tagIFPARA_S5 { int int PortNr; Timeout; // // COM port for S5 communication default timeout

} IFPARA_S5, *LPIFPARA_S5;

Page 46

Industrial PLC-Communication Suite

3.2

DLL info program (AGLink_Info.EXE)

You simply call AGLink_Info to get information about the present ACCON-AGLink DLL. The version, the license number, the licensee and the scope of the license are returned. AGLink_Info loads the ACCON-AGLink DLL dynamically to be able to handle all versions of the DLL. The DLL is searched in the current directory or in the current path. With the demo version of the DLL you receive the following output:

AGLink_Info is delivered completely as C/C++ source code for Microsoft C/C++ and serves as a further example.

Industrial PLC-Communication Suite

Seite 47

3.3

Performance test program (AGLink_Performance.EXE)

Simply call AGLink_Performance to check the data throughput of the selected connection. Therefore the attached PLCs are determined with the function AGLGetLifeList, then per PLC the number of data blocks and then the largest data block in the PLC. This is used for the tests. It is purpose of this program to be able to compare the individual communication channels objectively. In addition, you can check with the response, whether the selected type of connection meets your requirements or whether you should use another hardware. For the tests package sizes of 2, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000 and 50000 bytes were used per transmission, when the selected DB has the corresponding length.

You can indicate the following command line parameters: -An -Dn -Pn Indicating number of runs per packet size. -A100 uses 100 runs per packet size. If this option isn't indicated, 10 runs are used. Indicating the number of the device to be used. D2 used device 2 instead of device 0 (standard). Indicating the number of the PLC to be used. Per default AGLGetLifeList tries to determine all attached PLC and test the performance of all one after each other. You use this parameter if you want to measure only a certain PLC. Carrying out not only reading test but also writing test. NOTICE: the data of the used DBs are overwritten! Use this parameter with caution.

-W+

Page 48 Example output with an activated writing test:

Industrial PLC-Communication Suite

AGLink_Performance is delivered completely as C/C++ source code for Microsoft C/C++ and serves as a further example.

Industrial PLC-Communication Suite

Seite 49

4 First steps
In this chapter the fundamental procedure is introduced for creating an example program with ACCON-AGLink briefly. Start the enclosed program "AGLink_Config.EXE" and adjust the DEVICE 0 according to the hardware used by you. Copy the needed files according to your used compiler into the selected project directory. In the case of Microsoft C/C++ these are the files AGLink.H and AGLink.Lib from the directory AGLink_Demo/VC. The files AGLink.DLL, AGLink_Error.TXT, AGLink_Error.ENG and AGLink_Config.EXE from the directory AGLink_Redist can be stored in the project directory or in the Windows system directory.

4.1

First example in Microsoft Visual C/C++

On account of the simplicity we create a small console application. You start Microsoft Visual C/C++. You select with file/new in the Tab-Control in the folder projects the entry Win32console application. Enter the project name Test1 and the path/directory. Confirm with OK. Now you select an empty project. Insert with file/new a C++ source code file with the name Test1. Insert with the menu project/settings in the Tab-Control Linker the library AGLink.Lib in the entry field object-/ library modules. Then enter the program as follows:
// // attachment of header files // #define WIN32_LEAN_AND_MEAN #define STRICT #include <windows.h> #include <stdio.h> #include <conio.h> #include "AGLink.H" // // definition of constants // #define DEV_NR 0 #define WAIT_FLAG true #define PLC_NR 2 // // returning of an error code // void ShowError( int ErrNr, char *Func ) { char Fehler[128]; AGLGetErrorMsg( ErrNr, Fehler, sizeof( Fehler ) ); printf( "Fehler %d (%s) bei %s\n", ErrNr, Fehler, Func );

// we dont need all specifications // we want strict type checking

// // definition of the main function // int __cdecl main() { int RetVal; // // step 1: Activating of ACCON-AGLink with your personal activate key

Page 50
// AGLActivate( "123456-1234-123456" );

Industrial PLC-Communication Suite

// Please insert now your // personal activate key

// // step 2: Opening the device // if( (RetVal = AGLOpenDevice( DEV_NR )) == AGL_SUCCESS ) { printf( "device successfully opened\n" ); // // step 3: dialing up the connection if necessary // if( (RetVal = AGLDialUp( DEV_NR, WAIT_FLAG )) == AGL_SUCCESS ) { printf( "DialUp successfully processed\n" ); // // step 4: initialize the used communication adapter // if( (RetVal = AGLInitAdapter( DEV_NR, WAIT_FLAG )) == AGL_SUCCESS ) { printf( "adapter successfully initialized\n" ); // // step 5: Connecting to the selected plc // if( (RetVal = AGLPLCConnect( DEV_NR, PLC_NR, WAIT_FLAG )) == AGL_SUCCESS ) { printf( "connection to the plc\n", PLC_NR ); // // step 6: from now on all reading, writing and information functions. // can be used //

} else { ShowError( RetVal, "AGLOpenDevice" );

} else { ShowError( RetVal, "AGLDialUp" ); } // // step 10: closing the device // AGLCloseDevice( DEV_NR );

} else { ShowError( RetVal, "AGLInitAdapter" ); } // // step 9: hanging up the dial connection if necessary // AGLHangUp( DEV_NR, WAIT_FLAG );

} else { ShowError( RetVal, "AGLPLCConnect" ); } // // step 8: de-initializing the used communication adapter // AGLExitAdapter( DEV_NR, WAIT_FLAG );

// // step 7: disconnecting from the selected plc // AGLPLCDisconnect( DEV_NR, PLC_NR, WAIT_FLAG );

Industrial PLC-Communication Suite

Seite 51

} // // Still waiting for the keystroke so that the soft copy on the screen remains unchanged // printf( "please push an arbitrary button..." ); getch(); return( 0 ); }

Now you compile and start the program. You get the following information at the screen:

Page 52

Industrial PLC-Communication Suite

4.1.1

Reading of the diagnosis buffer

Please insert as step 6 the following program code:


DIAGBUFF DiagBuff; if( (RetVal = AGLReadDiagBuffer( DEV_NR, PLC_NR, &DiagBuff, WAIT_FLAG )) == AGL_SUCCESS ) { printf( "number of diagnosis buffer entries: %d\n", DiagBuff.EntrysRead for( int i=0; i<DiagBuff.EntrysRead; i++ ) { char Buff1[256];

);

AGLReadDiagBufferEntry( i, &DiagBuff, Buff1, sizeof( Buff1 ) ); #if defined( _CONSOLE ) CharToOem( Buff1, Buff1 ); // is necessary for console // applications because of umlauts #endif printf( "%3d: %s\n", i+1, Buff2 ); } } else { ShowError( RetVal, "AGLReadDiagBuffer" ); }

Now you compile and start the program. You get the following information at the screen:

Industrial PLC-Communication Suite

Seite 53

4.2

Additional hints for VBA

By preference all modules and UserForms should be provided with the following entries.
Option Explicit ' variables must be declared

With this entry you get while you enter the program code the information which variables are not yet declared. To switch off the demo-information window, you must replace the demo AGLink.DLL with your licensed AGLink.DLL. To enable the activation of your activation key you must call the function AGLActivate("12345-1234-12345") as first AGLink function and enter your activation code. For dialing up a connection it is recommended to follow the following steps: Run the following functions to determine the participants on the bus:
AGLOpenDevice(DevNr) AGLDialUp(DevNr, boWait) AGLInitAdapter(DevNr, boWait) AGLGetLifeList(DevNr, List(0), boWait) AGLExitAdapter(DevNr, boWait) AGLHangUp(DevNr, boWait) AGLCloseDevice(DevNr)

Use one of the plc numbers from the determined participants "List()". Run the following functions to process the data of the S7:
AGLOpenDevice(DevNr) AGLDialUp(DevNr, boWait) AGLInitAdapter(DevNr, boWait) AGLPLCConnect(DevNr, PLCNr, boWait)

. At his point you can insert the functions to read and write the data of the S7 .
AGLPLCDisconnect(DevNr, PLCNr, boWait) AGLExitAdapter(DevNr, boWait)

Page 54
AGLHangUp(DevNr, boWait) AGLCloseDevice(DevNr)

Industrial PLC-Communication Suite

4.2.1

Remarks to data processing in Excel

Writing data from a variable into a cell: "Daten" is a variable that is returned from AGLink.
Range("B1").Value = Daten

or
Cells(1,2).Value = Daten

When you dont want to write into the currently active table, the selected table object is proceeded.
Sheets("Tabelle1").Range("B1").Value = Daten

or
Worksheets(1).Cells(1,2).Value = Daten

Writing data from an Excel cell into a variable:


Daten = Range("B1").Value

4.2.2

Hints to the examples in Word and Excel

The files AGLink.DLL, AGL_Error.TXT and AGLink_Config.exe should be copied in the directory "System32" (Windows 98 -> directory:"System"). All examples are modular designed. It is always used a similar form: UserForm1 a dialog field to connect to the PLC. The communication parameters can be changed with the button "settings".

The following 3 modules are always used: AGLink Error handling: AGData declaration of all AGLink functions. the sub which returns the error message in a MsgBox. in this module are all functions that read or write data of the S7 after a successful dial up of a connection.

Industrial PLC-Communication Suite

Seite 55

The modules and forms are in the directory "Module+Forms" and can be used by importing in new applications. To be able to read data of VBA cyclically, a timer was used from the Windows "user32" directory.

4.2.3

The sample programs

Examples in Excel syntax Bits lesen.xls The sample shows how the status of single bits of a flag byte appear in an Excel sheet.

Byte Word Real lesen.xls The sample shows how words, double words and reals (floating point numbers) are converted from a flag byte buffer. Byte Word Real schreiben.xls The sample shows how a word value, double word value and real value (floating point numerical value) are written into a 10 bytes flag byte buffer. Bytes schreiben.xls Datenbausteine.xls The sample shows how data of a S7 plc can be changed by entering byte values into an Excel table. The sample shows how the existing data blocks are determined. It also determines the length of these data blocks and how the data can be inserted into an Excel table and presented in a diagram. The sample shows how the values of flag bytes can be read cyclically. At the same time the values are represented in a diagram and are permanently updated.

MerkerTimer.xls

MerkerTimerZyklen.xls This sample shoes how you write 10 values of a flag byte in an interval of 250 ms into an excel table and present as diagram. The course of time of data can be presented. Operanden gemischt lesen.xls This sample shows how you can use the function "AGLReadMix". With this function you can read different operand types (e.g. flags, input bytes, timer..) from one array (data buffer). This function enables also to select the size of the operands. For this you can read together in one reading job e.g. flag bits, timer words and data bytes from selected data blocks. You have a very efficient possibility to read different S7 data. S7CPU.xls This sample shows how Excel can be used to design with VBA operating devices and display elements. After successful connection set-up a S7 plc is shown on a form. At this virtual plc you can handle buttons, which write and show single bits of selected bytes. Also you can start and stop your plc by touch on the button. You have the possibility of using this sample to be able to renounce the programming of the connection set-up and connection hang-up. You can save time at the development of your application. You merely still must insert your selected function in the module "AGDaten" and achieve easily your target.

Vorlage.xls

Example in Word syntax


Vorlage.doc

You have the possibility of using this sample to be able to renounce the programming of the connection set-up and connection hang-up. You can save time at the development of your application. You merely still

Page 56

Industrial PLC-Communication Suite must insert your selected function in the module "AGDaten" and achieve easily your target.

AGLinkWord.doc

The example shows how you can insert with the help of an input menu selected details or data of the S7 in your Word document. The communication parameters will be adjusted and checked by pressing the button "Settings" .

Industrial PLC-Communication Suite

Seite 57

4.3

Additional hints for .NET

In the directory \AGLink_Demo\DotNET are stored several example projects for .NET. The demo examples contain some suggestions and examples how access to a S7 can be realized with the functions of ACCON-AGLink. All examples exist in the programming languages C# and VB.NET. The project files are created with Microsoft Visual studio .NET 2002. All examples require that all components of ACCON_AGLink are available and can be accessed. I.e. either the files AGLink.dll, AGLink_Config.exe and AGLink_Error.txt must be in the directory of the respective application or else better in a directory of the path. The easiest way is to copy the files in the Windows system directory, for NT/2000/XP this is in general C:\Windows\System32, for 9x/Me this is in general C:\Windows\System. Furthermore it is necessary that the customization layer AGLDotNet.dll is available in both, in the Global Assembly cache of the .NET framework (in general C:\ Windows\assembly), as also in the directory of the managed assemblies of the Microsoft Visual Studio .NET (in general C:\programs\Microsoft Visual studio .NET/Common7/IDE/PublicAssemblies). When developing own applications you must pay attention that a reference to the AGLDotNet.dll is included in the project. It functions as interface between your project and the AGLink.dll. The Namespace Accon is contained with the class AGL that contains most functions of ACCON-AGLink with a call interface for .NET. The activation of a licensed AGLink.dll is done with the function Accon.AGL.Activate that is included in all demos and works also with the demo version. As parameter the enclosed key must be entered, the value "123456-1234-123456" serves as specification value for the demo version. The function Accon.AGL.Activate only must be called once for the program start. Caution: Using a licensed AGLink.dll you must replace the key "123456-1234-123456" in all demos by the enclosed key. In addition you must replace the AGLink.dll by your licensed DLL. The directories C# and VB.NET include the following sub-directories:
ErsterSchritt ByteoperandenLesen ByteoperandenSchreiben connection dial-up and hang-up (incl. Error handling) Reading different byte operands Writing different byte operands

ByteoperandenLesenAsynchron Reading byte operands in asynchronous mode ByteblockLesen BitsLesen BitsSetzen ReadMix WriteMix ReadMixAsynchron Reading a byte block with multiple operands Shows the read access to single bits Shows the write access to single bits Multiple operands in one reading job Multiple operands in one writing job Multiple operands in one asynchronous reading job

Page 58
KonfigurationS7-MPI

Industrial PLC-Communication Suite


A separate setting dialog

All example projects are stored as executable program in the sub-directory "bin\Debug" (for C#) and "bin" (for VB.NET) and can be executed directly. ErsterSchritt A simple example about connection dial-up and connection hang-up incl. error handling. ByteoperandenLesen Reading single bytes (words for counters and timers) of the different operand types. ByteoperandenSchreiben Writing single bytes (words for counters and timers) of the different operand types. ByteoperandenLesenAsynchron Reading single bytes (words for counters and timers) of the different operand types in asynchronous modus (background mode) ByteblockLesen Reading a byte block (10 flag bytes) that contains different values. With the corresponding auxiliary functions will the single values of the byte block extracted, a word in fixed-point format, a double word in floating-point format and a double word in floating-point format. BitsLesen Shows the read access to single bits. For this the input byte is read and the single bit values are determined. BitsSetzen Shows the write access to single bits. For this the bits are inserted one by one into a byte value and written afterwards in an output byte. ReadMix Multiple different operands are read in one job. WriteMix Multiple different operands are written in one job. ReadMixAsynchron Multiple different operands are read in asynchronous modus (background mode).

Industrial PLC-Communication Suite KonfigurationS7-MPI

Seite 59

It is shown how an own setting dialog for the configuration can be built up instead of the use of AGLConfig or AGLink_Config.exe.

Page 60

Industrial PLC-Communication Suite

Industrial PLC-Communication Suite

Seite 61

5
5.1

Programming reference administration


Releasing or activating AGLink (AGLActivate)

This function activates the functionality of your acquired ACCON-AGLink DLL. It only must be called once at the program start with the enclosed activate key. This ensures that the ACCON-AGLink DLL delivered from you with your applications can only be used by you. C/C++ syntax:
void AGLINK_API AGLActivate( char *Key );

Visual Basic syntax:


Declare Sub AGLActivate Lib "AGLink.DLL" (ByVal Key As String)

Delphi syntax:
procedure AGLActivate( Key: PChar ); stdcall; external 'AGLink.DLL';

LabVIEW-Syntax:

Parameters: Key Return value: no return value activate key of your license

Page 62

Industrial PLC-Communication Suite

5.2

Opening and closing of the device

5.2.1

Opening device (AGLOpenDevice)

This function opens the requested device for the later use. Thereby is the memory allocated, according to the selected settings, and the protocol thread is started. C/C++ syntax:
int AGLINK_API AGLOpenDevice( int DevNr );

Visual Basic syntax:


Declare Function AGLOpenDevice Lib "AGLink.DLL" (ByVal DevNr As Long) As Long

Delphi syntax:
function AGLOpenDevice( DevNr: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW syntax:

Parameters: DevNr Return values: AGL_SUCCESS <0 in case of success an error code (see AGLink.H, AGLink.BAS or AGLink.PAS) number of device to be opened (0 ... 7)

Industrial PLC-Communication Suite

Seite 63

5.2.2

Closing device (AGLCloseDevice)

This function closes the requested device. Thereby the protocol thread is finished and the allocated memory is set free. C/C++ syntax:
int AGLINK_API AGLCloseDevice( int DevNr );

Visual Basic syntax:


Declare Function AGLCloseDevice Lib "AGLink.DLL" (ByVal DevNr As Long) As Long

Delphi syntax:
function AGLCloseDevice( DevNr: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW syntax:

Parameters: DevNr Return values: AGL_SUCCESS <0 in case of success an error code (see AGLink.H, AGLink.BAS or AGLink.PAS) number of device to be closed (0 ... 7)

Page 64

Industrial PLC-Communication Suite

5.3

Administration of jobs

If the communication functions are called with boWait == false, then the function returns immediately. The complete communication is carried out asynchronously, that means in the background, to your application. When the return value is >= 0, it corresponds to the internal job number. With this job number you can check the status of the job, interrupt the job (provided that it isn't already in processing) or install a message handler. If the return value is < 0, then this is a error. For the functions AGLSetWndMsgHandler, AGLSetThrdMsgHandler, AGLSetEventHandle and AGLSetCallback you also can submit the constant DEVICE_MSG instead of a job number. You then receive automatically a message from every finished job of the device without having to install a handler for every job explicitly. If you use an event, it is to take into account that this should be defined as auto reset. Or you must call ResetEvent in your program with every processing.

5.3.1

Setting window message handler (AGLSetWndMsgHandler)

With this function you give ACCON-AGLink the information which message your application shall be sent when the selected job is processed or interrupted. The message provides in the parameter wParam the job number. The parameter lParam is a pointer to the result structure RESULT which contains the communication status, if necessary the communication error and date/time information. C/C++ syntax:
int AGLINK_API AGLSetWndMsgHandler( int DevNr, int JobNr, HWND hWnd, UINT message );

Visual Basic syntax:


Declare Function AGLSetWndMsgHandler Lib "AGLink.DLL" (ByVal DevNr As Long, ByVal JobNr As Long, ByVal hwnd As Long, ByVal message As Long) As Long

Delphi syntax:
function AGLSetWndMsgHandler( DevNr, JobNr, hWnd, Msg: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW syntax:
not implemented

Parameters: DevNr JobNr hwnd message Return values: AGL_SUCCESS <0 in case of success an error code (see AGLink.H, AGLink.BAS or AGLink.PAS) number of device (0 ... 7) number of the job from the asynchronous call handle of the window where the message is to be sent message number to be sent

Industrial PLC-Communication Suite

Seite 65

5.3.2

Setting thread message handler (AGLSetThrdMsgHandler)

With this function you give ACCON-AGLink the information which message your application shall be sent when the selected job is processed or interrupted. The message provides in the parameter wParam the job number. The parameter lParam is a pointer to the result structure RESULT which contains the communication status, if necessary the communication error and date/time information. C/C++ syntax:
int AGLINK_API AGLSetThrdMsgHandler( int DevNr, int JobNr, DWORD ThreadID, UINT message );

Visual Basic syntax:


Declare Function AGLSetThrdMsgHandler Lib "AGLink.DLL" (ByVal DevNr As Long, ByVal JobNr As Long, ByVal ThreadID As Long, ByVal message As Long) As Long

Delphi syntax:
function AGLSetThrdMsgHandler( DevNr, JobNr, ThreadID, Msg: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW syntax:
not implemented

Parameters: DevNr JobNr ThreadID message Return values: AGL_SUCCESS <0 in case of success an error code (see AGLink.H, AGLink.BAS or AGLink.PAS) number of device (0 ... 7) number of the job from the asynchronous call ID of the thread where the message is to be sent Message number to be sent

Page 66

Industrial PLC-Communication Suite

5.3.3

Setting event handle (AGLSetEventHandle)

With this function you give ACCON-AGLink the information which event shall be indicated when the selected job order is processed or interrupted. The event is created by a call to CreateEvent. You can query with the job number the result of the communication (see AGLGetJobResult). This method is excellently suitable for the synchronization with the functions WaitForSingleObject or WaitForMultipleObjects. C/C++ syntax:
int AGLINK_API AGLSetEventHandle( int DevNr, int JobNr, HANDLE hEvent );

Visual Basic syntax:


Declare Function AGLSetEventHandle Lib "AGLink.DLL" (ByVal DevNr As Long, ByVal JobNr As Long, ByVal hEvent As Long) As Long

Delphi syntax:
function AGLSetEventHandle( DevNr, JobNr, hEvent: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW syntax:
not implemented

Parameters: DevNr JobNr hEvent Return values: AGL_SUCCESS <0 in case of success an error code (see AGLink.H, AGLink.BAS or AGLink.PAS) number of device (0 ... 7) number of the job from the asynchronous call handle of event to be set when the job ends

Industrial PLC-Communication Suite

Seite 67

5.3.4

Installing callback function (AGLSetCallback)

With this function you give ACCON-AGLink the information which callback function shall be started when the selected job is processed or interrupted. The function gets as parameter the job number and a pointer to the result structure. Therefore you should install for every opened device an own callback function. NOTICE: The callback function is called completely asynchronously out of the communication thread that runs with a higher priority. Keep the callback function as short as possible and return as fast as possible. This function is only for experts! C/C++ syntax:
int AGLINK_API AGLSetCallback( int DevNr, int JobNr, CALLBACK_FUNC Func );

Visual Basic syntax:


Declare Function AGLSetCallback Lib "AGLink.DLL" (ByVal DevNr As Long, ByVal JobNr As Long, ByVal Func As Long) As Long

Delphi syntax:
function AGLSetCallback( DevNr, JobNr, Func: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW syntax:
not implemented

Parameters: DevNr JobNr Func Return values: AGL_SUCCESS <0 in case of success an error code (see AGLink.H, AGLink.BAS or AGLink.PAS) number of device (0 ... 7) number of the job from the asynchronous call pointer to the callback function

Page 68

Industrial PLC-Communication Suite

5.3.5

Waiting for job (AGLWaitForJob)

With this function you wait for the end of an asynchronously started job. The function returns automatically the error code of the communication. C/C++ syntax:
int AGLINK_API AGLWaitForJob( int DevNr, int JobNr );

Visual Basic syntax:


Declare Function AGLWaitForJob Lib "AGLink.DLL" (ByVal DevNr As Long, ByVal JobNr As Long) As Long

Delphi syntax:
function AGLWaitForJob( DevNr, JobNr: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW syntax:
not implemented

Parameters: DevNr JobNr Return values: AGL_SUCCESS <0 in case of success an error code (see AGLink.H, AGLink.BAS or AGLink.PAS) number of device (0 ... 7) number of the job from the asynchronous call

Industrial PLC-Communication Suite

Seite 69

5.3.6

Deleting job (AGLDeleteJob)

This function deletes the job with the requested number from the job-processing queue. C/C++ syntax:
int AGLINK_API AGLDeleteJob( int DevNr, int JobNr );

Visual Basic syntax:


Declare Function AGLDeleteJob Lib "AGLink.DLL" (ByVal DevNr As Long, ByVal JobNr As Long) As Long

Delphi syntax:
function AGLDeleteJob( DevNr, JobNr: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW syntax:
not implemented

Parameters: DevNr JobNr Return values: AGL_SUCCESS <0 in case of success an error code (see AGLink.H, AGLink.BAS or AGLink.PAS) number of device (0 ... 7) number of the job from the asynchronous call

Page 70

Industrial PLC-Communication Suite

5.3.7

Querying the communication result of a job (AGLGetJobResult)

This function returns the communication result. C/C++ syntax:


int AGLINK_API AGLGetJobResult( int DevNr, int JobNr, LPRESULT pR );

Visual Basic syntax:


Declare Function AGLGetJobResult Lib "AGLink.DLL" (ByVal DevNr As Long, ByVal JobNr As Long, pR As Result) As Long

Delphi syntax:
function AGLGetJobResult( DevNr, JobNr: Long; var pR: Result ): Long; stdcall; external 'AGLink.DLL';

LabVIEW syntax:
not implemented

Parameters: DevNr JobNr pR Return values: AGL_SUCCESS <0 in case of success an error code (see AGLink.H, AGLink.BAS or AGLink.PAS) number of device (0 ... 7) number of the job from the asynchronous call pointer to result structure

Definition of the structure RESULT:


typedef struct tagRESULT { long State; long ErrCode; SYSTEMTIME SysTime; long SError; } RESULT, *LPRESULT; // // // // state of communication error code in case of communication abend date/time stamp when communication ended if necessary error code from hardware

Industrial PLC-Communication Suite

Seite 71

6 Programming reference communication functions


The functions from this chapter can only be executed, when the device was opened with the function AGLOpenDevice. For the functions in this chapter you can submit the parameter boWait. Thereby you fix whether the function shall return immediately or only after the complete function processing. When you don't want to wait until the function finished, you get a value greater or equal zero in the success case back. This is an internal job number for checking the status of the job. When you want to wait until the function finished(boWait != 0), you get directly the error code of the communication returned. The waiting till the function has finished is absolutely computing time harmless under Win32 because of WaitForSingleObject. NOTICE: If you use the asynchronous functionality, you must make sure that the buffer submitted to the communication driver is valid during the complete time of processing and is exclusively used by the communication driver. In addition, you must implement and guarantee the re-entrance capability in your application. Otherwise strange results up to program crashes can occur.

Page 72

Industrial PLC-Communication Suite

6.1

Function reference adapter

6.1.1

Setting up connection to remote station (AGLDialUp)

This function dials the remote station if the device type is AGL_DEVTYPE_TS. In all other cases the function returns with OK and for compatibility reasons can always be called after the function AGLOpenDevice and before the function AGLInitAdapter. C/C++ syntax:
int AGLINK_API AGLDialUp( int DevNr, int boWait );

Visual Basic syntax:


Declare Function AGLDialUp Lib "AGLink.DLL" (ByVal DevNr As Long, ByVal boWait As Long) As Long

Delphi syntax:
function AGLDialUp( DevNr, boWait: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW syntax:

Parameters: DevNr boWait Return values: >= 0 <0 number of job (boWait == 0) or AGL_SUCCESS (boWait != 0) an error code (see AGLink.H, AGLink.BAS or AGLink.PAS) number of device (0 ... 7) flag whether to wait

Industrial PLC-Communication Suite

Seite 73

6.1.2

Terminating connection to distant terminal (AGLHangUp)

This function terminates the connection with the distant terminal if the device type is AGL_DEVTYPE_TS. In all other cases the function returns with OK and for compatibility reasons can always be called after the function AGLExitAdapter and before the function AGLCloseDevice. C/C++ syntax:
int AGLINK_API AGLHangUp( int DevNr, int boWait );

Visual Basic syntax:


Declare Function AGLHangUp Lib "AGLink.DLL" (ByVal DevNr As Long, ByVal boWait As Long) As Long

Delphi syntax:
function AGLHangUp( DevNr, boWait: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW syntax:

Parameters: DevNr boWait Return values: >= 0 <0 number of job (boWait == 0) or AGL_SUCCESS (boWait != 0) an error code (see AGLink.H, AGLink.BAS or AGLink.PAS) number of device (0 ... 7) flag whether to wait

Page 74

Industrial PLC-Communication Suite

6.1.3

Initializing communication adapter (AGLInitAdapter)

This function initializes the communication adapter with the selected values. C/C++ syntax:
int AGLINK_API AGLInitAdapter( int DevNr, int boWait );

Visual Basic syntax:


Declare Function AGLInitAdapter Lib "AGLink.DLL" (ByVal DevNr As Long, ByVal boWait As Long) As Long

Delphi syntax:
function AGLInitAdapter( DevNr, boWait: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW syntax:

Parameters: DevNr boWait Return values: >= 0 <0 number of job (boWait == 0) or AGL_SUCCESS (boWait != 0) an error code (see AGLink.H, AGLink.BAS or AGLink.PAS) number of device (0 ... 7) flag whether to wait

Industrial PLC-Communication Suite

Seite 75

6.1.4

Deinitializing communication adapter (AGLExitAdapter)

This function cancels the connection to the communication adapter. C/C++ syntax:
int AGLINK_API AGLExitAdapter( int DevNr, int boWait );

Visual Basic syntax:


Declare Function AGLExitAdapter Lib "AGLink.DLL" (ByVal DevNr As Long, ByVal boWait As Long) As Long

Delphi syntax:
function AGLExitAdapter( DevNr, boWait: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW syntax:

Parameters: DevNr boWait Return values: >= 0 <0 number of job (boWait == 0) or AGL_SUCCESS (boWait != 0) an error code (see AGLink.H, AGLink.BAS or AGLink.PAS) number of device (0 ... 7) flag whether to wait

Page 76

Industrial PLC-Communication Suite

6.1.5

Querying active bus users (AGLGetLifeList)

This function determines with an access to the S7 controls the active participants at the MPI. In list[0] is the number of active participants at the bus returned, starting with list[1] the addresses of the active participants are listed. C/C++ syntax:
int AGLINK_API AGLGetLifeList( int DevNr, PBYTE List, int boWait );

Visual Basic syntax:


Declare Function AGLGetLifeList Lib "AGLink.DLL" (ByVal DevNr As Long, List As Byte, ByVal boWait As Long) As Long

Delphi syntax:
function AGLGetLifeList( DevNr: Long; var List: Byte; boWait: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW-Syntax:

Parameters: DevNr List boWait Return values: >= 0 <0 number of job (boWait == 0) or AGL_SUCCESS (boWait != 0) an error code (see AGLink.H, AGLink.BAS or AGLink.PAS) number of device (0 ... 7) array for participants, must have at least a size 128 bytes flag whether to wait

Industrial PLC-Communication Suite

Seite 77

6.1.6

Querying directly attached PLC (AGLGetDirectPLC)

This function determines with an access to the S7 controls via PC or TS adapter the directly attached PLC. When you access via the ACCON-PB/MPI card, ACCON-NetLink, a Softing Profibus card, the ACCON-PPI cable or via TCP/IP to the S7 controls, the directly attached PLC cannot be determined. Despite an error-free job processing you get as PLC number the default return value 255. Notice: This function returns only for the modules ACCON-AGLink S7 MPI serial and ACCON-AGLink S7 MPI serial/TS valid values for the directly attached PLC. For all other modules the return value is 255. C/C++ syntax:
int AGLINK_API AGLGetDirectPLC( int DevNr, PBYTE pPlcNr, int boWait );

Visual Basic syntax:


Declare Function AGLGetDirectPLC Lib "AGLink.DLL" (ByVal DevNr As Long, PLCNr As Byte, ByVal boWait As Long) As Long

Delphi syntax:
function AGLGetDirectPLC( DevNr: Long; var pPlcNr: Byte; boWait: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW syntax:

Parameters: DevNr pPlcNr boWait Return values: >= 0 <0 number of job (boWait == 0) or AGL_SUCCESS (boWait != 0) an error code (see AGLink.H, AGLink.BAS or AGLink.PAS) number of device (0 ... 7) variable for PLC number flag whether to wait

Page 78

Industrial PLC-Communication Suite

6.2

Function reference PLC

6.2.1

Setting up connection to a PLC (AGLPLCConnect)

With this function you set up a connection to a PLC. By multiple call of this function with different PLC numbers you can open several active connections at the same time. The maximum number of simultaneous connections per device is restricted to eight in the communication driver. It may be possible that the used communication hardware supports only less simultaneous connections. Every connection set up with AGLPLCConnect must be disconnected with the function AGLPLCDisconnect. C/C++ syntax:
int AGLINK_API AGLPLCConnect( int DevNr, int PlcNr, int boWait );

Visual Basic syntax:


Declare Function AGLPLCConnect Lib "AGLink.DLL" (ByVal DevNr As Long, ByVal PLCNr As Long, ByVal boWait As Long) As Long

Delphi syntax:
function AGLPLCConnect( DevNr, PlcNr, boWait: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW syntax:

Parameters: DevNr PlcNr boWait Return values: >= 0 <0 number of job (boWait == 0) or AGL_SUCCESS (boWait != 0) an error code (see AGLink.H, AGLink.BAS or AGLink.PAS) number of device (0 ... 7) number of selected PLC flag whether to wait

Industrial PLC-Communication Suite

Seite 79

6.2.2

Setting up connection to a PLC (AGLPLCConnectEx)

With this function you set up a connection to a PLC. By multiple call of this function with different PLC numbers you can open several active connections at the same time. The maximum number of simultaneous connections per device is restricted to eight in the communication driver. It may be possible that the used communication hardware supports only less simultaneous connections. Every connection set up with AGLPLCConnectEx must be disconnected with the function AGLPLCDisconnect. This function differs from the function AGLPLCConnect that you can set the rack and the slot number of the selected CPU. This is for example necessary when you want to access with a CP 342-5 to a S7 control. Normally in this case the rack number is 0 and the slot number 2. Please select the exact values from your hardware configuration. You can easily check whether you built up the connection to the right CPU when you check directly after AGLPLCConnect or AGLPLCConnectEx the function AGLReadMLFBNr. Then compare the MLFB number with the selected control. C/C++-Syntax:
int AGLINK_API AGLPLCConnectEx( int DevNr, int PlcNr, int RackNr, int SlotNr, int boWait );

Visual Basic-Syntax:
Declare Function AGLPLCConnectEx Lib "AGLink.DLL" (ByVal DevNr As Long, ByVal PLCNr As Long, ByVal RackNr As Long, ByVal SlotNr as Long, ByVal boWait As Long) As Long

Delphi-Syntax:
function AGLPLCConnectEx( DevNr, PlcNr, RackNr, SlotNr, boWait: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW-Syntax:

Parameters: DevNr PlcNr RackNr SlotNr boWait number of device (0 ... 7) number of selected PLC rack number of selected PLC slot number of selected PLC flag whether to wait

Page 80 Return values: >= 0 <0

Industrial PLC-Communication Suite

number of job (boWait == 0) or AGL_SUCCESS (boWait != 0) an error code (see AGLink.H, AGLink.BAS or AGLink.PAS)

Industrial PLC-Communication Suite

Seite 81

6.2.3

Disconnecting connection to a PLC (AGLPLCDisconnect)

This function cancels the connection set up with the function AGLPLCConnect. C/C++ syntax:
int AGLINK_API AGLPLCDisconnect( int DevNr, int PlcNr, int boWait );

Visual Basic syntax:


Declare Function AGLPLCDisconnect Lib "AGLink.DLL" (ByVal DevNr As Long, ByVal PLCNr As Long, ByVal boWait As Long) As Long

Delphi syntax:
function AGLPLCDisconnect( DevNr, PlcNr, boWait: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW syntax:

Parameters: DevNr PlcNr boWait Return values: >= 0 <0 number of job (boWait == 0) or AGL_SUCCESS (boWait != 0) an error code (see AGLink.H, AGLink.BAS or AGLink.PAS) number of device (0 ... 7) number of selected PLC flag whether to wait

Page 82

Industrial PLC-Communication Suite

6.2.4

Reading MLFB number of the PLC (AGLReadMLFBNr)

This function determines the MLFB number for the PLC with the selected device number. To this PLC must already be established a connection. C/C++ syntax:
int AGLINK_API AGLReadMLFBNr( int DevNr, int PlcNr, LPMLFB MLFBNr, int boWait );

Visual Basic syntax:


Declare Function AGLReadMLFBNr Lib "AGLink.DLL" (ByVal DevNr As Long, ByVal PLCNr As Long, MLFB As MLFBT, ByVal boWait As Long) As Long

Delphi syntax:
function AGLReadMLFBNr( DevNr, PlcNr: Long; var MLFBNr: MLFBT; boWait: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW syntax:

Parameters: DevNr PlcNr MLFBNr boWait Return values: >= 0 <0 number of job (boWait == 0) or AGL_SUCCESS (boWait != 0) an error code (see AGLink.H, AGLink.BAS or AGLink.PAS) number of device (0 ... 7) number of selected PLC pointer to MLFB number (string of 21 bytes) flag whether to wait

Definition of the structure MLFBT:


typedef struct tagMLFB { BYTE MLFB[21]; // MLFB number as zero terminated string } MLFB, *LPMLFB;

Industrial PLC-Communication Suite

Seite 83

6.2.5

Reading extended MLFB number of the PLC (AGLReadMLFBNrEx)

This function determines the MLFB number and the version numbers for the PLC with the selected device number. To this PLC must already be established a connection. C/C++ syntax:
int AGLINK_API AGLReadMLFBNrEx( int DevNr, int PlcNr, LPMLFBEX MLFBNr, int boWait );

Visual Basic syntax:


Declare Function AGLReadMLFBNrEx Lib "AGLink.DLL" (ByVal DevNr As Long, ByVal PLCNr As Long, MLFB As MLFBEX, ByVal boWait As Long) As Long

Delphi syntax:
function AGLReadMLFBNrEx( DevNr, PlcNr: Long; var MLFBNr: MLFBEX; boWait: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW-Syntax:

Parameters: DevNr PlcNr MLFBNr boWait Return values: >= 0 <0 number of job (boWait == 0) or AGL_SUCCESS (boWait != 0) an error code (see AGLink.H, AGLink.BAS or AGLink.PAS) number of device (0 ... 7) number of selected PLC pointer to MLFB number + releases flag whether to wait

Definition of the structure MLFBEX:


typedef struct tagMLFBEX { WORD WORD PLCVer; PGASVer; // // revision level PLC revision level PG interface connection

Page 84
BYTE MLFB[21]; //

Industrial PLC-Communication Suite


MLFB number as zero terminated string

} MLFBEX, *LPMLFBEX;

Industrial PLC-Communication Suite

Seite 85

6.2.6

Reading AG-Info (AGLReadPLCInfo)

You can query with this function how many inputs, outputs, flags, timer and counter the attached CPU has. To this PLC must already be established a connection. Notice: This function is not implemented for ACCON-AGLink S7 PPI serial and returns the value FUNC_NOT_SUPPORTED. C/C++ syntax:
int AGLINK_API AGLReadPLCInfo( int DevNr, int PlcNr, LPPLCINFO PLCInfo, int boWait );

Visual Basic syntax:


Declare Function AGLReadPLCInfo Lib "AGLink.DLL" (ByVal DevNr As Long, ByVal PLCNr As Long, Info As PLCInfo, ByVal boWait As Long) As Long

Delphi syntax:
function AGLReadPLCInfo( DevNr, PlcNr: Long; var PLCInfo: PLCINFO; boWait: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW syntax:

Parameters: DevNr PlcNr PLCInfo boWait Return values: >= 0 <0 number of job (boWait == 0) or AGL_SUCCESS (boWait != 0) an error code (see AGLink.H, AGLink.BAS or AGLink.PAS) number of device (0 ... 7) number of selected PLC buffer for maximal values flag whether to wait

Page 86 Definition of the structure PLCINFO:


typedef struct tagPLCINFO { DWORD PAE; DWORD PAA; DWORD Flags; DWORD Timer; DWORD Counter; DWORD LogAddress; DWORD LocalData; } PLCINFO, *LPPLCINFO; // // // // // // //

Industrial PLC-Communication Suite

number of input bytes number of output bytes number of flag bytes number of timer words number of counter words size of logical address space size of localdata storage

Industrial PLC-Communication Suite

Seite 87

6.2.7

Reading diagnostic buffer of the PLC (AGLReadDiagBuffer)

This function reads the diagnostic buffer of the PLC with the selected number. To this PLC must already be established a connection. The number of read diagnostic buffer entries is listed after the reading in the structure variable EntrysRead. The transition of the read binary content in plain text is carried out from the function AGLReadDiagBufferEntry. Invoke this function with the index from 0 to EntryRead-1. Other values are not valid and return and error message. C/C++-Syntax:
int AGLINK_API AGLReadDiagBuffer( int DevNr, int PlcNr, LPDIAGBUFF pDiagBuff, int boWait );

Visual Basic-Syntax:
Declare Function AGLReadDiagBuffer Lib "AGLink.DLL" (ByVal DevNr As Long, ByVal PLCNr As Long, pDiagBuff As DIAGBUFF, ByVal boWait As Long) As Long

Delphi-Syntax:
function AGLReadDiagBuffer( DevNr, PlcNr: Long; var pDiagBuff: DIAGBUFF; boWait: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW-Syntax:

Parameters: DevNr PlcNr pDiagBuff boWait Return values: >= 0 <0 number of job (boWait == 0) or AGL_SUCCESS (boWait != 0) an error code (s. AGLink.H, AGLink.BAS or AGLink.PAS) number of device (0 ... 7) number of selected PLC pointer to DIAGBUFF structure flag whether to wait

Definition of the structure DIAGBUFF:


typedef struct tagDIAGBUFF

Page 88
{ int EntrysRead; BYTE Buff[2400]; } DIAGBUFF, *LPDIAGBUFF; // //

Industrial PLC-Communication Suite

Anzahl gelesener Diagnoseeintrge Binrinhalt des Diagnosepuffers

Industrial PLC-Communication Suite

Seite 89

6.2.8

Converting content of diagnostic buffer to text (AGLReadDiagBufferEntry)

This function converts the content of the diagnostic buffer line by line to plain text Invoke this function with the index from 0 to EntryRead-1. Other values are not valid and return and error message. C/C++-Syntax:
int AGLINK_API AGLReadDiagBufferEntry( int Index, LPDIAGBUFF pDiagBuff, LPSTR Text, int TextLen );

Visual Basic-Syntax:
Declare Function AGLReadDiagBufferEntry Lib "AGLink.DLL" (ByVal Index As Long, pDiagBuff As DIAGBUFF, ByVal Text As String, ByVal TextLen as Long) As Long

Delphi-Syntax:
function AGLReadDiagBufferEntry( Index: Long; var pDiagBuff: DIAGBUFF; Text: Pchar; TextLen: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW-Syntax:

Parameters: Index pDiagBuff Text TextLen Return values: The length of the diagnostic buffer message. Index of the selected diagnostic buffer entry pointer to DIAGBUFF-structure pointer to text string maximal length of the string

Page 90

Industrial PLC-Communication Suite

6.2.9

Querying operating state of the PLC (AGLReadOpState)

With this function you can query the current operating state of the PLC. To this PLC must already be established a connection. In OpState the current operating state is returned. This can be the following constants: OPSTATE_STOP, OPSTATE_START, OPSTATE_RUN and OPSTATE_UNKNOWN. C/C++ syntax:
int AGLINK_API AGLReadOpState( int DevNr, int PlcNr, int *OpState, int boWait );

Visual Basic syntax:


Declare Function AGLReadOpState Lib "AGLink.DLL" (ByVal DevNr As Long, ByVal PLCNr As Long, OpState As Long, ByVal boWait As Long) As Long

Delphi syntax:
function AGLReadOpState( DevNr, PlcNr: Long; var OpState: Long; boWait: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW syntax:

Parameters: DevNr PlcNr OpState boWait Return values: >= 0 <0 number of job (boWait == 0) or AGL_SUCCESS (boWait != 0) an error code (see AGLink.H, AGLink.BAS or AGLink.PAS) number of device (0 ... 7) number of selected PLC pointer to operating status flag whether to wait

Industrial PLC-Communication Suite

Seite 91

6.2.10 Stopping PLC (AGLPLCStop)


With this function you can move the PLC to the status stop. To this PLC must already be established a connection. C/C++ syntax:
int AGLINK_API AGLPLCStop( int DevNr, int PlcNr, int boWait );

Visual Basic syntax:


Declare Function AGLPLCStop Lib "AGLink.DLL" (ByVal DevNr As Long, ByVal PLCNr As Long, ByVal boWait As Long) As Long

Delphi syntax:
function AGLPLCStop( DevNr, PlcNr, boWait: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW syntax:

Parameters: DevNr PlcNr boWait Return values: >= 0 <0 number of job (boWait == 0) or AGL_SUCCESS (boWait != 0) an error code (see AGLink.H, AGLink.BAS or AGLink.PAS) number of device (0 ... 7) number of selected PLC flag whether to wait

Page 92

Industrial PLC-Communication Suite

6.2.11

Executing restart of the PLC (AGLPLCStart)

With this function you can move the PLC to the status Run. A restart is done. To this PLC must already be established a connection. C/C++ syntax:
int AGLINK_API AGLPLCStart( int DevNr, int PlcNr, int boWait );

Visual Basic syntax:


Declare Function AGLPLCStart Lib "AGLink.DLL" (ByVal DevNr As Long, ByVal PLCNr As Long, ByVal boWait As Long) As Long

Delphi syntax:
function AGLPLCStart( DevNr, PlcNr, boWait: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW syntax:

Parameters: DevNr PlcNr boWait Return values: >= 0 <0 number of job (boWait == 0) or AGL_SUCCESS (boWait != 0) an error code (see AGLink.H, AGLink.BAS or AGLink.PAS) number of device (0 ... 7) number of selected PLC flag whether to wait

Industrial PLC-Communication Suite

Seite 93

6.2.12

Executing resume of the PLC (AGLPLCResume)

With this function you can move the PLC to the status Run. A resume is done. This function can not be executed at all controls and in all PLC parameter settings and therefore can provide an error. To this PLC must already be established a connection. C/C++ syntax:
int AGLINK_API AGLPLCResume( int DevNr, int PlcNr, int boWait );

Visual Basic syntax:


Declare Function AGLPLCResume Lib "AGLink.DLL" (ByVal DevNr As Long, ByVal PLCNr As Long, ByVal boWait As Long) As Long

Delphi syntax:
function AGLPLCResume( DevNr, PlcNr, boWait: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW syntax:

Parameters: DevNr PlcNr boWait Return values: >= 0 <0 number of job (boWait == 0) or AGL_SUCCESS (boWait != 0) an error code (see AGLink.H, AGLink.BAS or AGLink.PAS) number of device (0 ... 7) number of selected PLC flag whether to wait

Page 94

Industrial PLC-Communication Suite

6.3

Function reference reading data

6.3.1

Reading input bytes (AGLReadInBytes)

With this function you read the input bytes from the process image for the PLC with the requested device number. To this PLC must already be established a connection. C/C++ syntax:
int AGLINK_API AGLReadInBytes( int DevNr, int PlcNr, int Start, int Num, PBYTE Buff, int boWait );

Visual Basic syntax:


Declare Function AGLReadInBytes Lib "AGLink.DLL" (ByVal DevNr As Long, ByVal PLCNr As Long, ByVal Start As Long, ByVal Num As Long, Buff As Byte, ByVal boWait As Long) As Long

Delphi syntax:
function AGLReadInBytes( DevNr, PlcNr, Start, Num: Long; var Buff: Byte; boWait: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW syntax:

Parameters: DevNr PlcNr Start Num Buff boWait Return values: >= 0 <0 number of job (boWait == 0) or AGL_SUCCESS (boWait != 0) an error code (see AGLink.H, AGLink.BAS or AGLink.PAS) number of device (0 ... 7) number of selected PLC byte where start to be read number of bytes to be read pointer to buffer flag whether to wait

Industrial PLC-Communication Suite

Seite 95

6.3.2

Reading peripheral input bytes (AGLReadPInBytes)

With this function you read the peripheral input bytes for the PLC with the requested device number. To this PLC must already be established a connection. C/C++ syntax:
int AGLINK_API AGLReadPInBytes( int DevNr, int PlcNr, int Start, int Num, PBYTE Buff, int boWait );

Visual Basic syntax:


Declare Function AGLReadPInBytes Lib "AGLink.DLL" (ByVal DevNr As Long, ByVal PLCNr As Long, ByVal Start As Long, ByVal Num As Long, Buff As Byte, ByVal boWait As Long) As Long

Delphi syntax:
function AGLReadPInBytes( DevNr, PlcNr, Start, Num: Long; var Buff: Byte; boWait: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW syntax:

Parameters: DevNr PlcNr Start Num Buff boWait Return values: >= 0 <0 number of job (boWait == 0) or AGL_SUCCESS (boWait != 0) an error code (see AGLink.H, AGLink.BAS or AGLink.PAS) number of device (0 ... 7) number of selected PLC byte where start to be read number of bytes to be read pointer to buffer flag whether to wait

Page 96

Industrial PLC-Communication Suite

6.3.3

Reading output bytes (AGLReadOutBytes)

With this function you read the output bytes from the process image for the PLC with the requested device number. To this PLC must already be established a connection. C/C++ syntax:
int AGLINK_API AGLReadOutBytes( int DevNr, int PlcNr, int Start, int Num, PBYTE Buff, int boWait );

Visual Basic syntax:


Declare Function AGLReadOutBytes Lib "AGLink.DLL" (ByVal DevNr As Long, ByVal PLCNr As Long, ByVal Start As Long, ByVal Num As Long, Buff As Byte, ByVal boWait As Long) As Long

Delphi syntax:
function AGLReadOutBytes( DevNr, PlcNr, Start, Num: Long; var Buff: Byte; boWait: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW syntax:

Parameters: DevNr PlcNr Start Num Buff boWait Return values: >= 0 <0 number of job (boWait == 0) or AGL_SUCCESS (boWait != 0) an error code (see AGLink.H, AGLink.BAS or AGLink.PAS) number of device (0 ... 7) number of selected PLC byte where start to be read number of bytes to be read pointer to buffer flag whether to wait

Industrial PLC-Communication Suite

Seite 97

6.3.4

Reading flag bytes (AGLReadFlagBytes)

With this function you read the flag bytes for the PLC with the requested device number. To this PLC must already be established a connection. C/C++ syntax:
int AGLINK_API AGLReadFlagBytes( int DevNr, int PlcNr, int Start, int Num, PBYTE Buff, int boWait );

Visual Basic syntax:


Declare Function AGLReadFlagBytes Lib "AGLink.DLL" (ByVal DevNr As Long, ByVal PLCNr As Long, ByVal Start As Long, ByVal Num As Long, Buff As Byte, ByVal boWait As Long) As Long

Delphi syntax:
function AGLReadFlagBytes( DevNr, PlcNr, Start, Num: Long; var Buff: Byte; boWait: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW syntax:

Parameters: DevNr PlcNr Start Num Buff boWait Return values: >= 0 <0 number of job (boWait == 0) or AGL_SUCCESS (boWait != 0) an error code (see AGLink.H, AGLink.BAS or AGLink.PAS) number of device (0 ... 7) number of selected PLC byte where start to be read number of bytes to be read pointer to buffer flag whether to wait

Page 98

Industrial PLC-Communication Suite

6.3.5

Reading special flag bytes (AGLReadSFlagBytes)

With this function you read the special flag bytes for the PLC of the 200 series with the requested device number. To this PLC must already be established a connection. As an alternative to this function you can access for these PLCs to the flags starting with 256. This is internally mapped to the special flags. You can keep your programs hardwareindependently. Notice: This function is only implemented in ACCON-AGLink S7-PPI serial and otherwise returns the value FUNC_NOT_SUPPORTED. C/C++ syntax:
int AGLINK_API AGLReadSFlagBytes( int DevNr, int PlcNr, int Start, int Num, PBYTE Buff, int boWait );

Visual Basic syntax:


Declare Function AGLReadSFlagBytes Lib "AGLink.DLL" (ByVal DevNr As Long, ByVal PLCNr As Long, ByVal Start As Long, ByVal Num As Long, Buff As Byte, ByVal boWait As Long) As Long

Delphi syntax:
function AGLReadSFlagBytes( DevNr, PlcNr, Start, Num: Long; var Buff: Byte; boWait: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW-Syntax:

Parameters: DevNr PlcNr Start Num Buff boWait number of device (0 ... 7) number of selected PLC byte where start to be read number of bytes to be read pointer to buffer flag whether to wait

Industrial PLC-Communication Suite Return values: >= 0 <0

Seite 99

number of job (boWait == 0) or AGL_SUCCESS (boWait != 0) an error code (see AGLink.H, AGLink.BAS or AGLink.PAS)

Page 100

Industrial PLC-Communication Suite

6.3.6

Reading variables bytes (AGLReadVarBytes)

With this function you read the variables bytes for the PLC of the 200 series with the requested device number. To this PLC must already be established a connection. As an alternative to this function you can access for these PLCs to the DB 1. This is internally mapped to the variables. You can keep your programs hardware-independently. Notice: This function is only implemented in ACCON-AGLink S7-PPI serial and otherwise returns the value FUNC_NOT_SUPPORTED. C/C++ syntax:
int AGLINK_API AGLReadVarBytes( int DevNr, int PlcNr, int Start, int Num, PBYTE Buff, int boWait );

Visual Basic syntax:


Declare Function AGLReadVarBytes Lib "AGLink.DLL" (ByVal DevNr As Long, ByVal PLCNr As Long, ByVal Start As Long, ByVal Num As Long, Buff As Byte, ByVal boWait As Long) As Long

Delphi syntax:
function AGLReadVarBytes( DevNr, PlcNr, Start, Num: Long; var Buff: Byte; boWait: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW-Syntax:

Parameters: DevNr PlcNr Start Num Buff boWait Return values: number of device (0 ... 7) number of selected PLC byte where start to be read number of bytes to be read pointer to buffer flag whether to wait

Industrial PLC-Communication Suite >= 0 <0

Seite 101

number of job (boWait == 0) or AGL_SUCCESS (boWait != 0) an error code (see AGLink.H, AGLink.BAS or AGLink.PAS)

Page 102

Industrial PLC-Communication Suite

6.3.7

Reading data bytes (AGLReadDataBytes)

With this function you read the data bytes for the PLC with the requested device number. To this PLC must already be established a connection. C/C++ syntax:
int AGLINK_API AGLReadDataBytes( int DevNr, int PlcNr, int DBNr, int Start, int Num, PBYTE Buff, int boWait );

Visual Basic syntax:


Declare Function AGLReadDataBytes Lib "AGLink.DLL" (ByVal DevNr As Long, ByVal PLCNr As Long, ByVal DBNr As Long, ByVal Start As Long, ByVal Num As Long, Buff As Byte, ByVal boWait As Long) As Long

Delphi syntax:
function AGLReadDataBytes( DevNr, PlcNr, DBNr, Start, Num: Long; var Buff: Byte; boWait: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW syntax:

Parameters: DevNr PlcNr DBNr Start Num Buff boWait Return values: >= 0 <0 number of job (boWait == 0) or AGL_SUCCESS (boWait != 0) an error code (see AGLink.H, AGLink.BAS or AGLink.PAS) number of device (0 ... 7) number of selected PLC number of selected data block byte where start to be read number of bytes to be read pointer to buffer flag whether to wait

Industrial PLC-Communication Suite

Seite 103

6.3.8

Reading timer words (AGLReadTimerWords)

With this function you read the timer words for the PLC with the requested device number. To this PLC must already be established a connection. C/C++ syntax:
int AGLINK_API AGLReadTimerWords( int DevNr, int PlcNr, int Start, int Num, PWORD Buff, int boWait );

Visual Basic syntax:


Declare Function AGLReadTimerWords Lib "AGLink.DLL" (ByVal DevNr As Long, ByVal PLCNr As Long, ByVal Start As Long, ByVal Num As Long, Buff As Integer, ByVal boWait As Long) As Long

Delphi syntax:
function AGLReadTimerWords( DevNr, PlcNr, Start, Num: Long; var Buff: WORD; boWait: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW syntax:

Parameters: DevNr PlcNr Start Num Buff boWait Return values: >= 0 <0 number of job (boWait == 0) or AGL_SUCCESS (boWait != 0) an error code (see AGLink.H, AGLink.BAS or AGLink.PAS) number of device (0 ... 7) number of selected PLC timer word where start to be read number of timer words to be read pointer to buffer flag whether to wait

Page 104

Industrial PLC-Communication Suite

6.3.9

Reading counter words (AGLReadCounterWords)

With this function you read the counter words for the PLC with the requested device number. To this PLC must already be established a connection. C/C++ syntax:
int AGLINK_API AGLReadCounterWords( int DevNr, int PlcNr, int Start, int Num, PWORD Buff, int boWait );

Visual Basic syntax:


Declare Function AGLReadCounterWords Lib "AGLink.DLL" (ByVal DevNr As Long, ByVal PLCNr As Long, ByVal Start As Long, ByVal Num As Long, Buff As Integer, ByVal boWait As Long) As Long

Delphi syntax:
function AGLReadCounterWords( DevNr, PlcNr, Start, Num: Long; var Buff: WORD; boWait: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW syntax:

Parameters: DevNr PlcNr Start Num Buff boWait Return values: >= 0 <0 number of job (boWait == 0) or AGL_SUCCESS (boWait != 0) an error code (see AGLink.H, AGLink.BAS or AGLink.PAS) number of device (0 ... 7) number of selected PLC counter word where start to be read number of counter words to be read pointer to buffer flag whether to wait

Industrial PLC-Communication Suite

Seite 105

6.3.10 Mixed reading job (AGLReadMix)


With this function you can read different data types and data sizes in one job. To this PLC must already be established a connection. C/C++ syntax:
int AGLINK_API AGLReadMix( int DevNr, int PlcNr, LPDATA_RW Buff, int Num, int boWait );

Visual Basic syntax:


Declare Function AGLReadMix Lib "AGLink.DLL" (ByVal DevNr As Long, ByVal PLCNr As Long, Buff As DATA_RW, ByVal Num As Long, ByVal boWait As Long) As Long

Delphi syntax:
function AGLReadMix( DevNr, PlcNr: Long; var Buff: DATA_RW; Num, boWait: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW-Syntax:

Parameters: DevNr PlcNr Buff Num boWait Return values: >= 0 <0 number of job (boWait == 0) or AGL_SUCCESS (boWait != 0) an error code (see AGLink.H, AGLink.BAS or AGLink.PAS) number of device (0 ... 7) number of selected PLC pointer to array number of structures to be read flag whether to wait

Page 106 Definition of the structure DATA_RW:


typedef struct tagDATA_RW { WORD OpType; WORD OpSize; WORD DBNr; WORD ByteNr; WORD BitNr; SHORT Result; union { float fValue; DWORD Value; WORD BYTE }; } DATA_RW, *LPDATA_RW; W[2]; B[4]; // // // // // // // // // //

Industrial PLC-Communication Suite

type of operand which is accessed size of data number of data block offset for memory access bit number (if necessary) result (error code) of the read/write operation

value of the operand as float value of the operand as DWORD for more simple access for more simple access

The individual fields have following meaning: OpType The type of the operand is listed here. Permitted values for this are TYP_IN (inputs), TYP_OUT (outputs), TYP_FLAG (flags), TYP_DATA (data), TYP_TIMER (timer), TYP_COUNTER (counter), TYPE_SFLAG (special flag for series 200), TYPE_VAR (variable memory series 200), TYPE_TIMER_200 (time stamps series 200), TYPE_COUNTER_200 (counter series 200) and TYPE_PERIPHERIE (peripheral inputs). The size of the operand is listed here. Permitted values for this are SIZE_BIT, SIZE_BYTE, SIZE_WORD and SIZE_DWORD. Timer and counter must have the size SIZE_WORD. SIZE_BIT is not valid for TYPE_PERIPHERIE and leads to an error return code. The number of the DBs, in case of a data access. The offset for the memory access The number of the bit, if the access size is SIZE_BIT. The result of the operation. The read value, if no error appeared.

OpSize

DBNr ByteNr BitNr Result Value

Industrial PLC-Communication Suite

Seite 107

6.4 Function reference writing data

6.4.1

Writing input bytes (AGLWriteInBytes)

With this function you write the input bytes in the process image for the PLC with the requested device number. To this PLC must already be established a connection. Depending on the PLC the written bytes are immediately (that means at the system point) overwritten by the values of the physically available inputs. C/C++ syntax:
int AGLINK_API AGLWriteInBytes( int DevNr, int PlcNr, int Start, int Num, PBYTE Buff, int boWait );

Visual Basic syntax:


Declare Function AGLWriteInBytes Lib "AGLink.DLL" (ByVal DevNr As Long, ByVal PLCNr As Long, ByVal Start As Long, ByVal Num As Long, Buff As Byte, ByVal boWait As Long) As Long

Delphi syntax:
function AGLWriteInBytes( DevNr, PlcNr, Start, Num: Long; var Buff: Byte; boWait: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW syntax:

Parameters: DevNr PlcNr Start Num Buff boWait Return values: >= 0 <0 number of job (boWait == 0) or AGL_SUCCESS (boWait != 0) an error code (see AGLink.H, AGLink.BAS or AGLink.PAS) number of device (0 ... 7) number of selected PLC byte where start to be written number of bytes to be written pointer to buffer flag whether to wait

Page 108

Industrial PLC-Communication Suite

6.4.2

Writing output bytes (AGLWriteOutBytes)

With this function you write the output bytes in the process image for the PLC with the requested device number. To this PLC must already be established a connection. C/C++ syntax:
int AGLINK_API AGLWriteOutBytes( int DevNr, int PlcNr, int Start, int Num, PBYTE Buff, int boWait );

Visual Basic syntax:


Declare Function AGLWriteOutBytes Lib "AGLink.DLL" (ByVal DevNr As Long, ByVal PLCNr As Long, ByVal Start As Long, ByVal Num As Long, Buff As Byte, ByVal boWait As Long) As Long

Delphi syntax:
function AGLWriteOutBytes( DevNr, PlcNr, Start, Num: Long; var Buff: Byte; boWait: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW syntax:

Parameters: DevNr PlcNr Start Num Buff boWait Return values: >= 0 <0 number of job (boWait == 0) or AGL_SUCCESS (boWait != 0) an error code (see AGLink.H, AGLink.BAS or AGLink.PAS) number of device (0 ... 7) number of selected PLC byte where start to be written number of bytes to be written pointer to buffer flag whether to wait

Industrial PLC-Communication Suite

Seite 109

6.4.3

Writing peripheral output bytes (AGLWritePOutBytes)

With this function you write the peripherical output bytes for the PLC with the requested device number. To this PLC must already be established a connection. C/C++ syntax:
int AGLINK_API AGLWritePOutBytes( int DevNr, int PlcNr, int Start, int Num, PBYTE Buff, int boWait );

Visual Basic syntax:


Declare Function AGLWritePOutBytes Lib "AGLink.DLL" (ByVal DevNr As Long, ByVal PLCNr As Long, ByVal Start As Long, ByVal Num As Long, Buff As Byte, ByVal boWait As Long) As Long

Delphi syntax:
function AGLWritePOutBytes( DevNr, PlcNr, Start, Num: Long; var Buff: Byte; boWait: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW syntax:

Parameters: DevNr PlcNr Start Num Buff boWait Return values: >= 0 <0 number of job (boWait == 0) or AGL_SUCCESS (boWait != 0) an error code (see AGLink.H, AGLink.BAS or AGLink.PAS) number of device (0 ... 7) number of selected PLC byte where start to be written number of bytes to be written pointer to buffer flag whether to wait

Page 110

Industrial PLC-Communication Suite

6.4.4

Writing flag bytes (AGLWriteFlagBytes)

With this function you write the flag bytes for the PLC with the requested device number. To this PLC must already be established a connection. C/C++ syntax:
int AGLINK_API AGLWriteFlagBytes( int DevNr, int PlcNr, int Start, int Num, PBYTE Buff, int boWait );

Visual Basic syntax:


Declare Function AGLWriteFlagBytes Lib "AGLink.DLL" (ByVal DevNr As Long, ByVal PLCNr As Long, ByVal Start As Long, ByVal Num As Long, Buff As Byte, ByVal boWait As Long) As Long

Delphi syntax:
function AGLWriteFlagBytes( DevNr, PlcNr, Start, Num: Long; var Buff: Byte; boWait: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW syntax:

Parameters: DevNr PlcNr Start Num Buff boWait Return values: >= 0 <0 number of job (boWait == 0) or AGL_SUCCESS (boWait != 0) an error code (see AGLink.H, AGLink.BAS or AGLink.PAS) number of device (0 ... 7) number of selected PLC byte where start to be written number of bytes to be written pointer to buffer flag whether to wait

Industrial PLC-Communication Suite

Seite 111

6.4.5

Writing Special flag bytes (AGLWriteSFlagBytes)

With this function you write the special flag bytes for the PLC of the 200 series with the requested device number. To this PLC must already be established a connection. As an alternative to this function you can access for these PLCs to the flags starting with 256. This is internally mapped to the special flags. You can keep your programs hardwareindependently. Notice: This function is only implemented in ACCON-AGLink S7-PPI serial and otherwise returns the value FUNC_NOT_SUPPORTED. C/C++ syntax:
int AGLINK_API AGLWriteSFlagBytes( int DevNr, int PlcNr, int Start, int Num, PBYTE Buff, int boWait );

Visual Basic syntax:


Declare Function AGLWriteSFlagBytes Lib "AGLink.DLL" (ByVal DevNr As Long, ByVal PLCNr As Long, ByVal Start As Long, ByVal Num As Long, Buff As Byte, ByVal boWait As Long) As Long

Delphi syntax:
function AGLWriteSFlagBytes( DevNr, PlcNr, Start, Num: Long; var Buff: Byte; boWait: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW-Syntax:

Parameters: DevNr PlcNr Start Num Buff boWait number of device (0 ... 7) number of selected PLC byte where start to be written number of bytes to be written pointer to buffer flag whether to wait

Page 112 Return values: >= 0 <0

Industrial PLC-Communication Suite

number of job (boWait == 0) or AGL_SUCCESS (boWait != 0) an error code (see AGLink.H, AGLink.BAS or AGLink.PAS)

Industrial PLC-Communication Suite

Seite 113

6.4.6

Writing variables bytes (AGLWriteVarBytes)

With this function you write the variables bytes for the PLC of the 200 series with the requested device number. To this PLC must already be established a connection. As an alternative to this function you can access for these PLCs to the DB 1. This is internally mapped to the variables. You can keep your programs hardware-independently. Notice: This function is only implemented in ACCON-AGLink S7-PPI serial and otherwise returns the value FUNC_NOT_SUPPORTED. C/C++ syntax:
int AGLINK_API AGLWriteVarBytes( int DevNr, int PlcNr, int Start, int Num, PBYTE Buff, int boWait );

Visual Basic syntax:


Declare Function AGLWriteVarBytes Lib "AGLink.DLL" (ByVal DevNr As Long, ByVal PLCNr As Long, ByVal Start As Long, ByVal Num As Long, Buff As Byte, ByVal boWait As Long) As Long

Delphi syntax:
function AGLWriteVarBytes( DevNr, PlcNr, Start, Num: Long; var Buff: Byte; boWait: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW-Syntax:

Parameters: DevNr PlcNr Start Num Buff boWait Return values: >= 0 number of job (boWait == 0) or AGL_SUCCESS (boWait != 0) number of device (0 ... 7) number of selected PLC byte where start to be read number of bytes to be written pointer to buffer flag whether to wait

Page 114 <0

Industrial PLC-Communication Suite an error code (see AGLink.H, AGLink.BAS or AGLink.PAS)

Industrial PLC-Communication Suite

Seite 115

6.4.7

Writing data bytes (AGLWriteDataBytes)

With this function you write the data bytes for the PLC with the requested device number. To this PLC must already be established a connection. C/C++ syntax:
int AGLINK_API AGLWriteDataBytes( int DevNr, int PlcNr, int DBNr, int Start, int Num, PBYTE Buff, int boWait );

Visual Basic syntax:


Declare Function AGLWriteDataBytes Lib "AGLink.DLL" (ByVal DevNr As Long, ByVal PLCNr As Long, ByVal DBNr As Long, ByVal Start As Long, ByVal Num As Long, Buff As Byte, ByVal boWait As Long) As Long

Delphi syntax:
function AGLWriteDataBytes( DevNr, PlcNr, DBNr, Start, Num: Long; var Buff: Byte; boWait: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW syntax:

Parameters: DevNr PlcNr DBNr Start Num Buff boWait Return values: >= 0 <0 number of job (boWait == 0) or AGL_SUCCESS (boWait != 0) an error code (see AGLink.H, AGLink.BAS or AGLink.PAS) number of device (0 ... 7) number of selected PLC number of selected data block byte where start to be written number of bytes to be written pointer to buffer flag whether to wait

Page 116

Industrial PLC-Communication Suite

6.4.8

Writing Timer words (AGLWriteTimerWords)

With this function you write the timer words for the PLC with the requested device number. To this PLC must already be established a connection. C/C++ syntax:
int AGLINK_API AGLWriteTimerWords( int DevNr, int PlcNr, int Start, int Num, PWORD Buff, int boWait );

Visual Basic syntax:


Declare Function AGLWriteTimerWords Lib "AGLink.DLL" (ByVal DevNr As Long, ByVal PLCNr As Long, ByVal Start As Long, ByVal Num As Long, Buff As Integer, ByVal boWait As Long) As Long

Delphi syntax:
function AGLWriteTimerWords( DevNr, PlcNr, Start, Num: Long; var Buff: WORD; boWait: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW syntax:

Parameters: DevNr PlcNr Start Num Buff boWait Return values: >= 0 <0 number of job (boWait == 0) or AGL_SUCCESS (boWait != 0) an error code (see AGLink.H, AGLink.BAS or AGLink.PAS) number of device (0 ... 7) number of selected PLC timer word where start to be written number of timer words to be written pointer to buffer flag whether to wait

Industrial PLC-Communication Suite

Seite 117

6.4.9

Writing Counter words (AGLWriteCounterWords)

With this function you write the counter words for the PLC with the requested device number. To this PLC must already be established a connection. C/C++ syntax:
int AGLINK_API AGLWriteCounterWords( int DevNr, int PlcNr, int Start, int Num, PWORD Buff, int boWait );

Visual Basic syntax:


Declare Function AGLWriteCounterWords Lib "AGLink.DLL" (ByVal DevNr As Long, ByVal PLCNr As Long, ByVal Start As Long, ByVal Num As Long, Buff As Integer, ByVal boWait As Long) As Long

Delphi syntax:
function AGLWriteCounterWords( DevNr, PlcNr, Start, Num: Long; var Buff: WORD; boWait: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW syntax:

Parameters: DevNr PlcNr Start Num Buff boWait Return values: >= 0 <0 number of job (boWait == 0) or AGL_SUCCESS (boWait != 0) an error code (see AGLink.H, AGLink.BAS or AGLink.PAS) number of device (0 ... 7) number of selected PLC counter word where start to be written number of counter words to be written pointer to buffer flag whether to wait

Page 118

Industrial PLC-Communication Suite

6.4.10 Mixed writing job (AGLWriteMix)


With this function you can write different data types and data sizes in one job. To this PLC must already be established a connection. C/C++ syntax:
int AGLINK_API AGLWriteMix( int DevNr, int PlcNr, LPDATA_RW Buff, int Num, int boWait );

Visual Basic syntax:


Declare Function AGLWriteMix Lib "AGLink.DLL" (ByVal DevNr As Long, ByVal PLCNr As Long, Buff As DATA_RW, ByVal Num As Long, ByVal boWait As Long) As Long

Delphi syntax:
function AGLWriteMix( DevNr, PlcNr: Long; var Buff: DATA_RW; Num, boWait: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW-Syntax:

Parameters: DevNr PlcNr Buff Num boWait Return values: >= 0 <0 number of job (boWait == 0) or AGL_SUCCESS (boWait != 0) an error code (see AGLink.H, AGLink.BAS or AGLink.PAS) number of device (0 ... 7) number of selected PLC pointer to array number of structures flag whether to wait

Industrial PLC-Communication Suite Definition of the structure DATA_RW:


typedef struct tagDATA_RW { WORD OpType; WORD OpSize; WORD DBNr; WORD ByteNr; WORD BitNr; SHORT Result; union { float fValue; DWORD Value; WORD BYTE }; } DATA_RW, *LPDATA_RW; W[2]; B[4]; // // // // value of the operand as float value of the operand for more simple access for more simple access // // // // // //

Seite 119

type of operand which is accessed size of data number of data block offset for memory access (for T+Z number) bit number (if necessary) result (error code) of the read/write operation

The individual fields have following meaning: OpType The type of the operand is listed here. Permitted values for this are TYP_IN (inputs), TYP_OUT (outputs), TYP_FLAG (flags), TYP_DATA (data), TYP_TIMER (timer), TYP_COUNTER (counter), TYPE_SFLAG (special flag for series 200), TYPE_VAR (variable memory series 200), TYPE_TIMER_200 (time stamps series 200), TYPE_COUNTER_200 (counter series 200) and TYPE_PERIPHERIE (peripherical inputs). The size of the operand is listed here. Permitted values for this are SIZE_BIT, SIZE_BYTE, SIZE_WORD and SIZE_DWORD. Timer and counter must have the size SIZE_WORD. SIZE_BIT is not valid for TYPE_PERIPHERIE and leads to an error return code. The number of the DBs, if it is a data access. The offset for the memory access The number of the bit, if the access size is SIZE_BIT. The result of the operation. The read value, if no error appeared.

OpSize

DBNr ByteNr BitNr Result Value

Page 120

Industrial PLC-Communication Suite

6.5

Functions reference data block information

6.5.1

Determine number of data blocks (AGLReadDBCount)

With this function you determine how many data blocks are in this PLC available. To this PLC must already be established a connection. C/C++ syntax:
int AGLINK_API AGLReadDBCount( int DevNr, int PlcNr, int *DBCount, int boWait );

Visual Basic syntax:


Declare Function AGLReadDBCount Lib "AGLink.DLL" (ByVal DevNr As Long, ByVal PLCNr As Long, DBCount As Long, ByVal boWait As Long) As Long

Delphi syntax:
function AGLReadDBCount( DevNr, PlcNr: Long; var DBCount: Long; boWait: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW syntax:

Parameters: DevNr PlcNr DBCount boWait Return values: >= 0 <0 number of job (boWait == 0) or AGL_SUCCESS (boWait != 0) an error code (see AGLink.H, AGLink.BAS or AGLink.PAS) number of device (0 ... 7) number of selected PLC pointer to number of data blocks flag whether to wait

Industrial PLC-Communication Suite

Seite 121

6.5.2

Reading data block directory (AGLReadDBList)

With this function you read the directory of the data blocks. The memory for the data block numbers must be sufficiently allocated. For this you call the function AGLReadDBCount and then allocate the memory. To this PLC must already be established a connection. C/C++ syntax:
int AGLINK_API AGLReadDBList( int DevNr, int PlcNr, PWORD DBList, int boWait );

Visual Basic syntax:


Declare Function AGLReadDBList Lib "AGLink.DLL" (ByVal DevNr As Long, ByVal PLCNr As Long, DBList As Integer, ByVal boWait As Long) As Long

Delphi syntax:
function AGLReadDBList( DevNr, PlcNr: Long; var DBList: WORD; boWait: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW syntax:

Parameters: DevNr PlcNr DBList boWait Return values: >= 0 <0 number of job (boWait == 0) or AGL_SUCCESS (boWait != 0) an error code (see AGLink.H, AGLink.BAS or AGLink.PAS) number of device (0 ... 7) number of selected PLC directory of data block flag whether to wait

Page 122

Industrial PLC-Communication Suite

6.5.3

Reading length of a data block (AGLReadDBLen)

With this function you determine the length of a certain data block. To this PLC must already be established a connection. C/C++ syntax:
int AGLINK_API AGLReadDBLen( int DevNr, int PlcNr, int DBNr, int *DBLen, int boWait );

Visual Basic syntax


Declare Function AGLReadDBLen Lib "AGLink.DLL" (ByVal DevNr As Long, ByVal PLCNr As Long, ByVal DBNr As Long, DBLen As Long, ByVal boWait As Long) As Long

Delphi syntax:
function AGLReadDBLen( DevNr, PlcNr, DBNr: Long; var DBLen: Long; boWait: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW syntax:

Parameters: DevNr PlcNr DBNr DBLen boWait Return values: >= 0 <0 number of job (boWait == 0) or AGL_SUCCESS (boWait != 0) an error code (see AGLink.H, AGLink.BAS or AGLink.PAS) number of device (0 ... 7) number of selected PLC number of selected data block pointer to length of data blocks flag whether to wait

Industrial PLC-Communication Suite

Seite 123

Programming reference supplementary functions

The functions in this chapter support the simplified access to the data of the S5 and S7 control which are in the Motorola format (big endian) where as the PC data are in the Intel format (little endian).

7.1

Function reference reading functions

7.1.1

Reading 16 bit integer from byte buffer (AGLReadInt16)

With this function you read a signed 16 bit integer value from a byte buffer. C/C++-Syntax:
short AGLINK_API AGLReadInt16( PBYTE Buff );

Visual Basic-Syntax:
Declare Function AGLReadInt16 Lib "AGLink.DLL" (ByRef Buff As Byte) As Integer

Delphi-Syntax:
function AGLReadInt16( var Buff: Byte ): Short; stdcall; external 'AGLink.DLL';

LabVIEW syntax: Not implemented Parameters: Buff Return value: The value of the 16 bit integer from Buff[0], Buff[1]. buffer with data bytes

Page 124

Industrial PLC-Communication Suite

7.1.2

Reading word from byte buffer (AGLReadWord)

With this function you read a word from a byte buffer. C/C++ syntax:
WORD AGLINK_API AGLReadWord( PBYTE Buff );

Visual Basic syntax:


Declare Function AGLReadWord Lib "AGLink.DLL" (ByRef Buff As Byte) As Long

Delphi syntax:
function AGLReadWord( var Buff: Byte ): WORD; stdcall; external 'AGLink.DLL';

LabVIEW syntax:

Parameters: Buff Return value: The value of the word from Buff[0], Buff[1]. buffer with data bytes

Industrial PLC-Communication Suite

Seite 125

7.1.3

Reading double word from byte buffer (AGLReadDWord)

With this function you read a double word from a byte buffer. C/C++ syntax:
DWORD AGLINK_API AGLReadDWord( PBYTE Buff );

Visual Basic syntax:


Declare Function AGLReadDWord Lib "AGLink.DLL" (ByRef Buff As Byte) As Long

Delphi syntax:
function AGLReadDWord( var Buff: Byte ): DWORD; stdcall; external 'AGLink.DLL';

LabVIEW syntax:

Parameters: Buff Return value: The value of the double word at the address Buff[0], Buff[1]. buffer with data bytes

Page 126

Industrial PLC-Communication Suite

7.1.4

Reading floating point number (real) from byte buffer (AGLReadReal)

With this function you read a floating point number (real) from a byte buffer. C/C++ syntax:
float AGLINK_API AGLReadReal( PBYTE Buff );

Visual Basic syntax:


Declare Function AGLReadReal Lib "AGLink.DLL" (ByRef Buff As Byte) As Single

Delphi syntax:
function AGLReadReal( var Buff: Byte ): Single; stdcall; external 'AGLink.DLL';

LabVIEW syntax:

Parameters: Buff Return value: The value of the floating point number (real) from Buff[0], Buff[1], Buff[2], Buff[3]. buffer with data bytes

Industrial PLC-Communication Suite

Seite 127

7.1.5

Reading S5 time from byte buffer (AGLReadS5Time)

With this function you read a S5 time in BCD format from a byte buffer. C/C++ syntax:
int AGLINK_API AGLReadS5Time( PBYTE Buff );

Visual Basic syntax:


Declare Function AGLReadS5Time Lib "AGLink.DLL" (ByRef Buff As Byte) As Long

Delphi syntax:
function AGLReadS5Time( var Buff: Byte ): Long; stdcall; external 'AGLink.DLL';

LabVIEW syntax:

Parameters: Buff Return value: The value of the S5 time stamp (in milliseconds) from Buff[0], Buff[1]. buffer with data bytes

Page 128

Industrial PLC-Communication Suite

7.2

Function reference writing functions

7.2.1

Writing word into byte buffer (AGLWriteWord)

With this function you write a word into a byte buffer. C/C++ syntax:
void AGLINK_API AGLWriteWord( PBYTE Buff, WORD Val );

Visual Basic syntax:


Declare Sub AGLWriteWord Lib "AGLink.DLL" (ByRef Buff As Byte, ByVal Val As Long)

Delphi syntax:
procedure AGLWriteWord( var Buff: Byte; Val: WORD ); stdcall; external 'AGLink.DLL';

LabVIEW syntax:

Parameters: Buff Val Return value: no return value buffer with data bytes word value to be written

Industrial PLC-Communication Suite

Seite 129

7.2.2

Writing double word into byte buffer (AGLWriteDWord)

With this function you write a double word into a byte buffer. Syntax:
void AGLINK_API AGLWriteDWord( PBYTE Buff, DWORD Val );

Visual Basic syntax:


Declare Sub AGLWriteDWord Lib "AGLink.DLL" (ByRef Buff As Byte, ByVal Val As Long)

Delphi syntax:
procedure AGLWriteDWord( var Buff: Byte; Val: DWORD ); stdcall; external 'AGLink.DLL';

LabVIEW syntax:

Parameters: Buff Val Return value: no return value buffer with data bytes double word value to be written

Page 130

Industrial PLC-Communication Suite

7.2.3

Writing floating point number (real) into byte buffer (AGLWriteReal)

With this function you write a floating point number (real) into a byte buffer. C/C++ syntax:
void AGLINK_API AGLWriteReal( PBYTE Buff, float Val );

Visual Basic syntax:


Declare Sub AGLWriteReal Lib "AGLink.DLL" (ByRef Buff As Byte, ByVal Val As Single)

Delphi syntax:
procedure AGLWriteReal( var Buff: Byte; Val: Single ); stdcall; external 'AGLink.DLL';

LabVIEW syntax:

Parameters: Buff Val Return value: no return value buffer with data bytes floating point number (real) to be written

Industrial PLC-Communication Suite

Seite 131

7.2.4

Writing S5 time into byte buffer (AGLWriteS5Time)

With this function you write a time in milliseconds as S5Time into a byte buffer. The time is represented with the most possible precision and must lie in the area of 10 ms till 9990000 ms. C/C++ syntax:
void AGLINK_API AGLWriteS5Time( PBYTE Buff, int Val );

Visual Basic syntax:


Declare Sub AGLWriteS5Time Lib "AGLink.DLL" (ByRef Buff As Byte, ByVal Val As Long)

Delphi syntax:
procedure AGLWriteS5Time( var Buff: Byte; Val: Long ); stdcall; external 'AGLink.DLL';

LabVIEW syntax:

Parameters: Buff Val Return value: No return value buffer with data bytes value (time stamp) to be written

Page 132

Industrial PLC-Communication Suite

7.3

Function reference buffer convert functions

7.3.1

Converting byte buffer into word buffer (AGLByte2Word)

With this function a byte buffer is converted into a word buffer. C/C++ syntax:
void AGLINK_API AGLByte2Word( PWORD OutBuff, PBYTE InBuff, int AnzWords );

Visual Basic syntax:


Declare Sub AGLByte2Word Lib "AGLink.DLL" (ByRef OutBuff As Integer, ByRef InBuff As Byte, ByVal AnzWords As Long)

Delphi syntax:
procedure AGLByte2Word( var OutBuff: WORD; var InBuff: Byte; AnzWords: Long ); stdcall; external 'AGLink.DLL';

LabVIEW syntax:

Parameters: OutBuff InBuff AnzWords Return value: no return value pointer to word buffer pointer to byte buffer number of words to be converted

Industrial PLC-Communication Suite

Seite 133

7.3.2

Converting byte buffer into double word buffer (AGLByte2DWord)

With this function a byte buffer is converted into a double word buffer. C/C++ syntax:
void ); AGLINK_API AGLByte2DWord( PDWORD OutBuff, PBYTE InBuff, int AnzDWords

Visual Basic syntax:


Declare Sub AGLByte2DWord Lib "AGLink.DLL" (ByRef OutBuff As Long, ByRef InBuff As Byte, ByVal AnzDWords As Long)

Delphi syntax:
procedure AGLByte2DWord( var OutBuff: DWORD; var InBuff: Byte; AnzDWords: Long ); stdcall; external 'AGLink.DLL';

LabVIEW syntax:

Parameters: OutBuff InBuff AnzWords Return value: no return value pointer to double word buffer pointer to byte buffer number of double words to be converted

Page 134

Industrial PLC-Communication Suite

7.3.3

Converting byte buffer into floating point number (real) buffer (AGLByte2Real)

With this function a byte buffer is converted into a floating point number (real) buffer. C/C++ syntax:
void ); AGLINK_API AGLByte2Real( float *OutBuff, PBYTE InBuff, int AnzReals

Visual Basic syntax:


Declare Sub AGLByte2Real Lib "AGLink.DLL" (ByRef OutBuff As Single, ByRef InBuff As Byte, ByVal AnzReals As Long)

Delphi syntax:
procedure AGLByte2Real( var OutBuff: Single; var InBuff: Byte; AnzReals: Long ); stdcall; external 'AGLink.DLL';

LabVIEW syntax:

Parameters: OutBuff InBuff AnzWords Return value: no return value pointer to real buffer pointer to byte buffer number of floating point numbers (real) to be converted

Industrial PLC-Communication Suite

Seite 135

7.3.4

Converting word buffer into byte buffer (AGLWord2Byte)

With this function a word buffer is converted into a byte buffer. C/C++ syntax:
void AGLINK_API AGLWord2Byte( PBYTE OutBuff, PWORD InBuff, int AnzWords );

Visual Basic syntax:


Declare Sub AGLWord2Byte Lib "AGLink.DLL" (ByRef OutBuff As Byte, ByRef InBuff As Integer, ByVal AnzWords As Long)

Delphi syntax:
procedure AGLWord2Byte( var OutBuff: Byte; var InBuff: WORD; AnzWords: Long ); stdcall; external 'AGLink.DLL';

LabVIEW-Syntax:

Parameters: OutBuff InBuff AnzWords Return value: no return value pointer to byte buffer pointer to word buffer number of words to be converted

Page 136

Industrial PLC-Communication Suite

7.3.5

Converting double word buffer into byte buffer (AGLDWord2Byte)

With this function a double word buffer is converted into a byte buffer. C/C++ syntax:
void ); AGLINK_API AGLDWord2Byte( PBYTE OutBuff, PDWORD InBuff, int AnzDWords

Visual Basic syntax:


Declare Sub AGLDWord2Byte Lib "AGLink.DLL" (ByRef OutBuff As Byte, ByRef InBuff As Long, ByVal AnzDWords As Long)

Delphi syntax:
procedure AGLDWord2Byte( var OutBuff: Byte; var InBuff: DWORD; AnzDWords: Long ); stdcall; external 'AGLink.DLL';

LabVIEW-Syntax:

Parameters: OutBuff InBuff AnzDWords Return value: no return value pointer to byte buffer pointer to double word buffer number of double words to be converted

Industrial PLC-Communication Suite

Seite 137

7.3.6

Converting floating point number (real) buffer into byte buffer (AGLReal2Byte)

With this function a floating point number (real) buffer is converted into a byte buffer. C/C++ syntax:
void AGLINK_API AGLReal2Byte( PBYTE OutBuff, float *InBuff, int AnzReals );

Visual Basic syntax:


Declare Sub AGLReal2Byte Lib "AGLink.DLL" (ByRef OutBuff As Byte, ByRef InBuff As Single, ByVal AnzReals As Long)

Delphi syntax:
procedure AGLReal2Byte( var OutBuff: Byte; var InBuff: Single; AnzReals: Long ); stdcall; external 'AGLink.DLL';

LabVIEW-Syntax:

Parameters: OutBuff InBuff AnzReals Return value: no return value pointer to byte buffer pointer to real buffer number of floating point numbers (real) to be converted

Page 138

Industrial PLC-Communication Suite

7.3.7

Converting string into byte buffer (AGLString2Buff)

With this function a text string is converted into a byte buffer. This function was implemented for the easy access handling under VB and VBA. C/C++-Syntax:
int AGLINK_API AGLString2Buff( PBYTE Buff, LPSTR Text, int AnzBytes );

Visual Basic-Syntax:
Declare Function AGLString2Buff Lib "AGLink.DLL" (ByRef Buff As Byte, ByVal Text As String, ByVal AnzBytes As Long) As Long

Delphi-Syntax:
function AGLString2Buff( var Buff: Byte; Text: PChar; AnzBytess: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW-Syntax:
Not implemented

Parameters: Buff Text AnzReals Return value: AGL_SUCCESS <0 in case of success an error code (see AGLink.H, AGLink.BAS or AGLink.PAS) pointer to byte buffer pointer to string number of words to be converted

Industrial PLC-Communication Suite

Seite 139

7.3.8

Converting byte buffer into string(AGLBuff2String)

With this function a byte buffer is converted into a string. This function was implemented for the easy access handling under VB and VBA. C/C++-Syntax:
int AGLINK_API AGLBuff2String( PBYTE Buff, LPSTR Text, int AnzBytes );

Visual Basic-Syntax:
Declare Function AGLBuff2String Lib "AGLink.DLL" (ByRef Buff As Byte, ByVal Text As String, ByVal AnzBytes As Long) As Long

Delphi-Syntax:
function AGLBuff2String( var Buff: Byte; Text: PChar; AnzBytess: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW-Syntax:
Not implemented

Parameters: Buff Text AnzReals Return value: AGL_SUCCESS <0 in case of success an error code (see AGLink.H, AGLink.BAS or AGLink.PAS) pointer to byte buffer pointer to string number of words to be converted

Page 140

Industrial PLC-Communication Suite

7.4

Function reference bit functions

7.4.1

Requesting bit status (AGLGetBit)

This function determines the status of the requested bit. C/C++ syntax:
int AGLINK_API AGLGetBit( BYTE Wert, int BitNr );

Visual Basic syntax:


Declare Function AGLGetBit Lib "AGLink.DLL" (ByVal Wert As Byte, ByVal BitNr As Long) As Long

Delphi syntax:
function AGLGetBit ( Wert: Byte; BitNr: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW-Syntax:

Parameters: Wert BitNr Return value: status of the bit byte to be checked bit number to be checked (0 ... 7)

Industrial PLC-Communication Suite

Seite 141

7.4.2

Setting bit on the value one (AGLSetBit)

This function sets the requested bit on the value one. C/C++ syntax:
BYTE AGLSetBit( PBYTE Buff, int BitNr );

Visual Basic syntax:


Declare Function AGLSetBit Lib "AGLink.DLL" (ByRef Buff As Byte, ByVal BitNr As Long) As Byte

Delphi syntax:
Function AGLSetBit ( var Buff: Byte; BitNr: Long ): Byte; stdcall; external 'AGLink.DLL';

LabVIEW-Syntax:

Parameters: Buff BitNr Return value: the value of the byte pointer to byte where the bit should be set bit number to be set (0 ... 7)

Page 142

Industrial PLC-Communication Suite

7.4.3

Setting bit on the value zero (AGLResetBit)

This function sets the requested bit on the value zero. C/C++ syntax:
BYTE AGLResetBit( PBYTE Buff, int BitNr );

Visual Basic syntax:


Declare Function AGLResetBit Lib "AGLink.DLL" (ByRef Buff As Byte, ByVal BitNr As Long) As Byte

Delphi syntax:
Function AGLResetBit ( var Buff: Byte; BitNr: Long ): Byte; stdcall; external 'AGLink.DLL';

LabVIEW-Syntax:

Parameters: Buff BitNr Return value: the value of the byte pointer to byte where the bit should be reset bit number to be set (0 ... 7)

Industrial PLC-Communication Suite

Seite 143

7.4.4

Setting bit on value (AGLSetBitVal)

This function sets the requested bit on the selected value. C/C++ syntax:
BYTE AGLSetBitVal( PBYTE Buff, int BitNr, int Val );

Visual Basic syntax:


Declare Function AGLSetBitVal Lib "AGLink.DLL" (ByRef Buff As Byte, ByVal BitNr As Long, ByVal Val As Long ) As Byte

Delphi syntax:
Function AGLSetBitVal ( var Buff: Byte; BitNr, Val: Long ): Byte; stdcall; external 'AGLink.DLL';

LabVIEW-Syntax:

Parameters: Buff BitNr Val Return value: the value of the byte pointer to byte where the bit should be changed bit number to be set (0 ... 7) value of the bit

Page 144

Industrial PLC-Communication Suite

7.5

Function reference miscellaneous

7.5.1

Finding error text to the corresponding error code (AGLGetErrorMsg)

This function determines the error text to the corresponding error code. Therefore the contents of the file "AGLink_Error.TXT" are evaluated. At the first call of the function this file is read once and stands with no delay for further processing at the disposal. This file must be stored in the application directory. C/C++ syntax:
int AGLINK_API AGLGetErrorMsg( int ErrNr, char *Msg, int MaxLen );

Visual Basic syntax:


Declare Function AGLGetErrorMsg Lib "AGLink.DLL" (ByVal ErrNr As Long, ByVal ErrText As String, ByVal MaxLen As Long) As Long

Delphi syntax:
function AGLGetErrorMsg( ErrNr: Long; Msg: PChar; MaxLen: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW-Syntax:

Parameters: ErrNr Msg MaxLen Return value: Number of in Msg copied string number of error code pointer to string with error text length of message string

Industrial PLC-Communication Suite

Seite 145

7.5.2

Adjusting time function for result (AGLUseSystemTime)

With this function you can set whether the time in the result structure is determined with GetSystemTime (Flag != 0) or GetLocalTime (Flag == 0). C/C++ syntax:
void AGLINK_API AGLUseSystemTime( int Flag );

Visual Basic syntax:


Declare Sub AGLUseSystemTime Lib "AGLink.DLL" (ByVal Flag As Long)

Delphi syntax:
procedure AGLUseSystemTime ( Flag: Long ); stdcall; external 'AGLink.DLL';

LabVIEW syntax:
not implemented

Parameters: Flag Return value: no return value flag if GetSystemTime or GetLocalTime will be used

Page 146

Industrial PLC-Communication Suite

7.6

Function reference DLL info functions

7.6.1

Determine version number of the DLL (AGLGetDLLVersion)

This function returns the version number of the AGLink.DLL. Instead of the individual parameters also the value zero can be submitted, if this special information is not relevant. C/C++ syntax:
void AGLINK_API AGLGetDLLVersion( int *Major, int *Minor );

Visual Basic syntax:


Declare Sub AGLGetDLLVersion Lib "AGLink.DLL" (Major As Long, Minor As Long)

Delphi syntax:
procedure AGLGetDLLVersion( var Major, Minor: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW syntax:

Parameters: Major Minor Return value: no return value pointer to variable for major version pointer to variable for minor version

Industrial PLC-Communication Suite

Seite 147

7.6.2

Determine extended version number of the DLL (AGLGetDLLVersionEx)

This function returns the extended version number of the AGLink.DLL. Instead of the individual parameters also the value zero can be submitted, if this special information is not relevant. C/C++ syntax:
void AGLINK_API AGLGetDLLVersionEx( int *Major, int *Minor, int *Build, char *Date );

Visual Basic syntax:


Declare Sub AGLGetDLLVersionEx Lib "AGLink.DLL" (Major As Long, Minor As Long, Build As Long, ByVal Datum As String)

Delphi syntax:
procedure AGLGetDLLVersionEx( var Major, Minor, Build: Long, Date: PChar ): Long; stdcall; external 'AGLink.DLL';

LabVIEW-Syntax:

Parameters: Major Minor Build Date pointer to variable for major version pointer to variable for minor version pointer to variable for build version pointer to variable for build date, there must be space for in minimum 11 bytes, that means the date must be in the format 2002-07-08 (zero terminated string).

Return value: no return value

Page 148

Industrial PLC-Communication Suite

7.6.3

Determine available options of the DLL (AGLGetOptions)

This function returns the available options of AGLink.DLL. C/C++ syntax:


int AGLINK_API AGLGetOptions( void );

Visual Basic syntax:


Declare Function AGLGetOptions Lib "AGLink.DLL" () As Long

Delphi syntax:
function AGLGetOptions: Long; stdcall; external 'AGLink.DLL';

LabVIEW syntax:

Parameters: no parameters Return value: The available options as bit flag. A set bit means that the option is available. Possible bit masks are: AGL_MASK_MPI, AGL_MASK_TS, AGL_MASK_CIF, AGL_MASK_TCPIP, AGL_MASK_PPI, AGL_MASK_RK, AGL_MASK_S5, AGL_MASK_NL_DRV, AGL_MASK_NL_IP and AGL_MASK_SOFTING.

Industrial PLC-Communication Suite

Seite 149

7.6.4

Determine serial number of the DLL (AGLGetSerialNumber)

This function returns the serial number of AGLink.DLL. C/C++ syntax:


int AGLINK_API AGLGetSerialNumber( void );

Visual Basic syntax:


Declare Function AGLGetSerialNumber Lib "AGLink.DLL" () As Long

Delphi syntax:
function AGLGetSerialNumber: Long; stdcall; external 'AGLink.DLL';

LabVIEW syntax:

Parameters: no parameters Return value: the serial number

Page 150

Industrial PLC-Communication Suite

7.6.5

Determine the licensee of the DLL (AGLGetClientName)

This function returns the licensee of the AGLink.DLL. The function requests a pointer on a string buffer with at least 256 bytes space. C/C++ syntax:
char *AGLINK_API AGLGetClientName( char *Name );

Visual Basic syntax:


Declare Sub AGLGetClientName Lib "AGLink.DLL" (ByVal Name As String)

Delphi syntax:
function AGLGetClientName( Name: PChar ): PChar; stdcall; external 'AGLink.DLL';

LabVIEW syntax:

Parameters: Name Return value: pointer to the returned string for further processing. Pointer to string buffer

Industrial PLC-Communication Suite

Seite 151

Additional functions for VB and VBA

These functions enable you an easier access to the AGLink functions that process a string. These functions are includes in the source code in module AGLink.BAS.

8.1

Returning an error message (AGLErrMsg)

This function returns you an error message from AGLink directly as string. Structure of the implementation:
Private Const Max = 256 Public Function AGLErrMsg(ByVal ErrNo As Long) As String Dim Tmp As String Dim MsgLen As Long Tmp = Space$(Max) MsgLen = AGLGetErrorMsg(ErrNo, Tmp, Max) If MsgLen = 0 Then AGLErrMsg = "unknown error number!" Else AGLErrMsg = Left$(Tmp, MsgLen) End If End Function

Page 152

Industrial PLC-Communication Suite

8.2

Returning entry from the diagnostic buffer (AGLDiagBufferEntry)

This function returns you an entry from the diagnostic buffer from AGLink directly as string. Structure of the implementation:
Private Const Max = 256 Public Function AGLDiagBufferEntry(ByVal Index As Long, pDiagBuff As DIAGBUFF) As String Dim Tmp As String Dim MsgLen As Long Tmp = Space$(Max) MsgLen = AGLReadDiagBufferEntry(Index, pDiagBuff, Tmp, Max) If MsgLen = 0 Then AGLDiagBufferEntry = AGLErrMsg(PARA_ERR) Else AGLDiagBufferEntry = Left$(Tmp, MsgLen) End If End Function

Industrial PLC-Communication Suite

Seite 153

9 Programming reference configuration functions


With the functions in this chapter you can implement the same functionality as it is already contained in the program AGLink_Config.EXE. This can be meaningful e.g. for an individual administration of a phone book etc. The parameters are read when loading the DLL from the registry of the respective PC and also can be written into the registry again, controlled by the program.

9.1

Functions for reading the parameters from the registry

9.1.1

Reading the complete device settings (AGLReadDevice)

With this function the complete device settings of the device will be read once from the registry and filed in an internal memory area. (S7-MPI serial, S7-MPI serial/TS, S7-PB/CIF, S7-PB/NetLinkDrv, S7-PB/Softing, S7-TCP/IP, S7-TCP/NetLinkIP, S7-PPI serial, RK512/3964R, S5 serial as well as the adapted device type) C/C++ syntax:
void AGLINK_API AGLReadDevice( int DevNr );

Visual Basic syntax:


Declare Sub AGLReadDevice Lib "AGLink.DLL" (ByVal DevNr As Long)

Delphi syntax:
procedure AGLReadDevice( DevNr: Long ); stdcall; external 'AGLink.DLL';

LabVIEW syntax:
not implemented

Parameters: DevNr Return values: no return value number of device (0 ... 7)

Page 154

Industrial PLC-Communication Suite

9.1.2

Reading device type (AGLReadDevType)

This function reads the selected device type from the registry and files it in an internal memory area. C/C++ syntax:
void AGLINK_API AGLReadDevType( int DevNr );

Visual Basic syntax:


Declare Sub AGLReadDevType Lib "AGLink.DLL" (ByVal DevNr As Long)

Delphi syntax:
procedure AGLReadDevType( DevNr: Long ); stdcall; external 'AGLink.DLL';

LabVIEW syntax:
not implemented

Parameters: DevNr Return values: no return value number of device (0 ... 7)

Industrial PLC-Communication Suite

Seite 155

9.1.3

Reading port parameters S7-MPI serial (AGLReadIFPMPI)

This function reads the port settings for ACCON-AGLink S7-MPI serial of the selected device from the registry and files it in an internal memory area. C/C++ syntax:
void AGLINK_API AGLReadIFPMPI( int DevNr );

Visual Basic syntax:


Declare Sub AGLReadIFPMPI Lib "AGLink.DLL" (ByVal DevNr As Long)

Delphi syntax:
procedure AGLReadIFPMPI( DevNr: Long ); stdcall; external 'AGLink.DLL';

LabVIEW syntax:
not implemented

Parameters: DevNr Return values: no return value number of device (0 ... 7)

Page 156

Industrial PLC-Communication Suite

9.1.4

Reading port parameters S7-MPI serial/TS (AGLReadIFPTS)

This function reads the port settings for ACCON-AGLink S7-MPI serial/TS of the selected device from the registry and files it in an internal memory area. C/C++ syntax:
void AGLINK_API AGLReadIFPTS( int DevNr );

Visual Basic syntax:


Declare Sub AGLReadIFPTS Lib "AGLink.DLL" (ByVal DevNr As Long)

Delphi syntax:
procedure AGLReadIFPTS( DevNr: Long ); stdcall; external 'AGLink.DLL';

LabVIEW syntax:
not implemented

Parameters: DevNr Return values: no return value number of device (0 ... 7)

Industrial PLC-Communication Suite

Seite 157

9.1.5

Reading location parameters S7-MPI serial/TS (AGLReadLPTS)

This function reads the location settings for ACCON-AGLink S7-MPI serial/TS of the selected device from the registry and files it in an internal memory area. C/C++ syntax:
void AGLINK_API AGLReadLPTS( int DevNr );

Visual Basic syntax:


Declare Sub AGLReadLPTS Lib "AGLink.DLL" (ByVal DevNr As Long)

Delphi syntax:
procedure AGLReadLPTS( DevNr: Long ); stdcall; external 'AGLink.DLL';

LabVIEW syntax:
not implemented

Parameters: DevNr Return values: no return value number of device (0 ... 7)

Page 158

Industrial PLC-Communication Suite

9.1.6

Reading dial number parameters S7-MPI serial/TS (AGLReadDPTS)

This function reads the dial number settings for ACCON-AGLink S7-MPI serial/TS of the selected device from the registry and files it in an internal memory area.

C/C++ syntax:
void AGLINK_API AGLReadDPTS( int DevNr );

Visual Basic syntax:


Declare Sub AGLReadDPTS Lib "AGLink.DLL" (ByVal DevNr As Long)

Delphi syntax:
procedure AGLReadDPTS( DevNr: Long ); stdcall; external 'AGLink.DLL';

LabVIEW syntax:
not implemented

Parameters: DevNr Return values: no return value number of device (0 ... 7)

Industrial PLC-Communication Suite

Seite 159

9.1.7

Reading port parameters S7-PB/CIF (AGLReadIFPCIF)

This function reads the port settings for ACCON-AGLink S7-PB/CIF of the selected device from the registry and files it in an internal memory area. C/C++ syntax:
void AGLINK_API AGLReadIFPCIF( int DevNr );

Visual Basic syntax:


Declare Sub AGLReadIFPCIF Lib "AGLink.DLL" (ByVal DevNr As Long)

Delphi syntax:
procedure AGLReadIFPCIF( DevNr: Long ); stdcall; external 'AGLink.DLL';

LabVIEW syntax:
not implemented

Parameters: DevNr Return values: no return value number of device (0 ... 7)

Page 160

Industrial PLC-Communication Suite

9.1.8

Reading port parameters S7-PB/NetLinkDrv (AGLReadIFPNLDRV)

This function reads the port settings for ACCON-AGLink S7-PB/NetLinkDrv of the selected device from the registry and files it in an internal memory area. C/C++ syntax:
void AGLINK_API AGLReadIFPNLDRV( int DevNr );

Visual Basic syntax:


Declare Sub AGLReadIFPNLDRV Lib "AGLink.DLL" (ByVal DevNr As Long)

Delphi syntax:
procedure AGLReadIFPNLDRV( DevNr: Long ); stdcall; external 'AGLink.DLL';

LabVIEW syntax:
not implemented

Parameters: DevNr Return values: no return value number of device (0 ... 7)

Industrial PLC-Communication Suite

Seite 161

9.1.9

Reading port parameters S7-PB/Softing (AGLReadIFPSOFTING)

This function reads the port settings for ACCON-AGLink S7-PB/Softing of the selected device from the registry and files it in an internal memory area. C/C++ syntax:
void AGLINK_API AGLReadIFPSOFTING( int DevNr );

Visual Basic syntax:


Declare Sub AGLReadIFPSOFTING Lib "AGLink.DLL" (ByVal DevNr As Long)

Delphi syntax:
procedure AGLReadIFPSOFTING( DevNr: Long ); stdcall; external 'AGLink.DLL';

LabVIEW syntax:
not implemented

Parameters: DevNr Return values: no return value number of device (0 ... 7)

Page 162

Industrial PLC-Communication Suite

9.1.10

Reading port parameters S7-TCP/IP (AGLReadIFPTCPIP)

This function reads the port settings for ACCON-AGLink S7-TCP/IP of the selected device from the registry and files it in an internal memory area. C/C++ syntax:
void AGLINK_API AGLReadIFPTCPIP( int DevNr );

Visual Basic syntax:


Declare Sub AGLReadIFPTCPIP Lib "AGLink.DLL" (ByVal DevNr As Long)

Delphi syntax:
procedure AGLReadIFPTCPIP( DevNr: Long ); stdcall; external 'AGLink.DLL';

LabVIEW syntax:
not implemented

Parameters: DevNr Return values: no return value number of device (0 ... 7)

Industrial PLC-Communication Suite

Seite 163

9.1.11

Reading port parameters S7-TCP/NetLinkIP (AGLReadIFPNLIP)

This function reads the port settings for ACCON-AGLink S7-TCP/NetLinkIP of the selected device from the registry and files it in an internal memory area. C/C++ syntax:
void AGLINK_API AGLReadIFPNLIP( int DevNr );

Visual Basic syntax:


Declare Sub AGLReadIFPNLIP Lib "AGLink.DLL" (ByVal DevNr As Long)

Delphi syntax:
procedure AGLReadIFPNLIP( DevNr: Long ); stdcall; external 'AGLink.DLL';

LabVIEW syntax:
not implemented

Parameters: DevNr Return values: no return value number of device (0 ... 7)

Page 164

Industrial PLC-Communication Suite

9.1.12

Reading port parameters S7-PPI serial (AGLReadIFPPPI)

This function reads the port settings for ACCON-AGLink S7-PPI serial of the selected device from the registry and files it in an internal memory area. C/C++ syntax:
void AGLINK_API AGLReadIFPPPI( int DevNr );

Visual Basic syntax:


Declare Sub AGLReadIFPPPI Lib "AGLink.DLL" (ByVal DevNr As Long)

Delphi syntax:
procedure AGLReadIFPPPI( DevNr: Long ); stdcall; external 'AGLink.DLL';

LabVIEW syntax:
not implemented

Parameters: DevNr Return values: no return value number of device (0 ... 7)

Industrial PLC-Communication Suite

Seite 165

9.1.13

Reading port parameters RK512/3964R (AGLReadIFPRK)

This function reads the port settings for ACCON-AGLink RK512/3964R of the selected device from the registry and files it in an internal memory area. C/C++ syntax:
void AGLINK_API AGLReadIFPRK( int DevNr );

Visual Basic syntax:


Declare Sub AGLReadIFPRK Lib "AGLink.DLL" (ByVal DevNr As Long)

Delphi syntax:
procedure AGLReadIFPRK( DevNr: Long ); stdcall; external 'AGLink.DLL';

LabVIEW syntax:
not implemented

Parameters: DevNr Return values: no return value number of device (0 ... 7)

Page 166

Industrial PLC-Communication Suite

9.1.14

Reading port parameters S5 serial (AGLReadIFPS5)

This function reads the port settings for ACCON-AGLink S5 serial of the selected device from the registry and files it in an internal memory area. C/C++ syntax:
void AGLINK_API AGLReadIFPS5( int DevNr );

Visual Basic syntax:


Declare Sub AGLReadIFPS5 Lib "AGLink.DLL" (ByVal DevNr As Long)

Delphi syntax:
procedure AGLReadIFPS5( DevNr: Long ); stdcall; external 'AGLink.DLL';

LabVIEW syntax:
not implemented

Parameters: DevNr Return values: no return value number of device (0 ... 7)

Industrial PLC-Communication Suite

Seite 167

9.2

Functions for writing the parameters into the registry

9.2.1

Writing the complete device settings (AGLWriteDevice)

With this function the complete device settings of the device will be written once from the internal memory area into the registry. (S7-MPI serial, S7-MPI serial/TS, S7-PB/CIF, S7PB/NetLinkDrv, S7-PB/Softing, S7-TCP/IP, S7-TCP/NetLinkIP, S7-PPI serial, RK512/3964R, S5 serial as well as the adapted device type) C/C++ syntax:
void AGLINK_API AGLWriteDevice( int DevNr );

Visual Basic syntax:


Declare Sub AGLWriteDevice Lib "AGLink.DLL" (ByVal DevNr As Long)

Delphi syntax:
procedure AGLWriteDevice( DevNr: Long ); stdcall; external 'AGLink.DLL';

LabVIEW syntax:
not implemented

Parameters: DevNr Return values: no return value number of device (0 ... 7)

Page 168

Industrial PLC-Communication Suite

9.2.2

Writing device type (AGLWriteDevType)

This function writes the selected device type from the internal memory area into the registry C/C++ syntax:
void AGLINK_API AGLWriteDevType( int DevNr );

Visual Basic syntax:


Declare Sub AGLWriteDevType Lib "AGLink.DLL" (ByVal DevNr As Long)

Delphi syntax:
procedure AGLWriteDevType( DevNr: Long ); stdcall; external 'AGLink.DLL';

LabVIEW syntax:
not implemented

Parameters: DevNr Return values: no return value number of device (0 ... 7)

Industrial PLC-Communication Suite

Seite 169

9.2.3

Writing port parameters S7-MPI serial (AGLWriteIFPMPI)

This function writes the port settings for ACCON-AGLink S7-MPI serial of the selected device from the internal memory area into the registry. C/C++ syntax:
void AGLINK_API AGLWriteIFPMPI( int DevNr );

Visual Basic syntax:


Declare Sub AGLWriteIFPMPI Lib "AGLink.DLL" (ByVal DevNr As Long)

Delphi syntax:
procedure AGLWriteIFPMPI( DevNr: Long ); stdcall; external 'AGLink.DLL';

LabVIEW syntax:
not implemented

Parameters: DevNr Return values: no return value number of device (0 ... 7)

Page 170

Industrial PLC-Communication Suite

9.2.4

Writing port parameters S7-MPI serial/TS (AGLWriteIFPTS)

This function writes the port settings for ACCON-AGLink S7-MPI serial/TS of the selected device from the internal memory area into the registry. C/C++ syntax:
void AGLINK_API AGLWriteIFPTS( int DevNr );

Visual Basic syntax:


Declare Sub AGLWriteIFPTS Lib "AGLink.DLL" (ByVal DevNr As Long)

Delphi syntax:
procedure AGLWriteIFPTS( DevNr: Long ); stdcall; external 'AGLink.DLL';

LabVIEW syntax:
not implemented

Parameters: DevNr Return values: no return value number of device (0 ... 7)

Industrial PLC-Communication Suite

Seite 171

9.2.5

Writing location parameters S7-MPI serial/TS (AGLWriteLPTS)

This function writes the location settings for ACCON-AGLink S7-MPI serial/TS of the selected device from the internal memory area into the registry. C/C++ syntax:
void AGLINK_API AGLWriteLPTS( int DevNr );

Visual Basic syntax:


Declare Sub AGLWriteLPTS Lib "AGLink.DLL" (ByVal DevNr As Long)

Delphi syntax:
procedure AGLWriteLPTS( DevNr: Long ); stdcall; external 'AGLink.DLL';

LabVIEW syntax:
not implemented

Parameters: DevNr Return values: no return value number of device (0 ... 7)

Page 172

Industrial PLC-Communication Suite

9.2.6

Writing dial number parameters S7-MPI serial/TS (AGLWriteDPTS)

This function writes the dial number settings for ACCON-AGLink S7-MPI serial/TS of the selected device from the internal memory area into the registry. C/C++ syntax:
void AGLINK_API AGLWriteDPTS( int DevNr );

Visual Basic syntax:


Declare Sub AGLWriteDPTS Lib "AGLink.DLL" (ByVal DevNr As Long)

Delphi syntax:
procedure AGLWriteDPTS( DevNr: Long ); stdcall; external 'AGLink.DLL';

LabVIEW syntax:
not implemented

Parameters: DevNr Return values: no return value number of device (0 ... 7)

Industrial PLC-Communication Suite

Seite 173

9.2.7

Writing port parameters S7-PB/CIF (AGLWriteIFPCIF)

This function writes the port settings for ACCON-AGLink S7-PB/CIF of the selected device from the internal memory area into the registry. C/C++ syntax:
void AGLINK_API AGLWriteIFPCIF( int DevNr );

Visual Basic syntax:


Declare Sub AGLWriteIFPCIF Lib "AGLink.DLL" (ByVal DevNr As Long)

Delphi syntax:
procedure AGLWriteIFPCIF( DevNr: Long ); stdcall; external 'AGLink.DLL';

LabVIEW syntax:
not implemented

Parameters: DevNr Return values: no return value number of device (0 ... 7)

Page 174

Industrial PLC-Communication Suite

9.2.8

Writing port parameters S7-PB/NetLinkDrv (AGLWriteIFPNLDRV)

This function writes the port settings for ACCON-AGLink S7-PB/NetLinkDrv of the selected device from the internal memory area into the registry. C/C++ syntax:
void AGLINK_API AGLWriteIFPNLDRV( int DevNr );

Visual Basic syntax:


Declare Sub AGLWriteIFPNLDRV Lib "AGLink.DLL" (ByVal DevNr As Long)

Delphi syntax:
procedure AGLWriteIFPNLDRV( DevNr: Long ); stdcall; external 'AGLink.DLL';

LabVIEW syntax:
not implemented

Parameters: DevNr Return values: no return value number of device (0 ... 7)

Industrial PLC-Communication Suite

Seite 175

9.2.9

Writing port parameters S7-PB/Softing (AGLWriteIFPSOFTING)

This function writes the port settings for ACCON-AGLink S7-PB/Softing of the selected device from the internal memory area into the registry. C/C++ syntax:
void AGLINK_API AGLWriteIFPSOFTING( int DevNr );

Visual Basic syntax:


Declare Sub AGLWriteIFPSOFTING Lib "AGLink.DLL" (ByVal DevNr As Long)

Delphi syntax:
procedure AGLWriteIFPSOFTING( DevNr: Long ); stdcall; external 'AGLink.DLL';

LabVIEW syntax:
not implemented

Parameters: DevNr Return values: no return value number of device (0 ... 7)

Page 176

Industrial PLC-Communication Suite

9.2.10 Writing port parameters S7-TCP/IP (AGLWriteIFPTCPIP)


This function writes the port settings for ACCON-AGLink S7-TCP/IP of the selected device from the internal memory area into the registry. C/C++ syntax:
void AGLINK_API AGLWriteIFPTCPIP( int DevNr );

Visual Basic syntax:


Declare Sub AGLWriteIFPTCPIP Lib "AGLink.DLL" (ByVal DevNr As Long)

Delphi syntax:
procedure AGLWriteIFPTCPIP( DevNr: Long ); stdcall; external 'AGLink.DLL';

LabVIEW syntax:
not implemented

Parameters: DevNr Return values: no return value number of device (0 ... 7)

Industrial PLC-Communication Suite

Seite 177

9.2.11

Writing port parameters S7-TCP/NetLinkIP (AGLWriteIFPNLIP)

This function writes the port settings for ACCON-AGLink S7-TCP/NetLinkIP of the selected device from the internal memory area into the registry. C/C++ syntax:
void AGLINK_API AGLWriteIFPNLIP( int DevNr );

Visual Basic syntax:


Declare Sub AGLWriteIFPNLIP Lib "AGLink.DLL" (ByVal DevNr As Long)

Delphi syntax:
procedure AGLWriteIFPNLIP( DevNr: Long ); stdcall; external 'AGLink.DLL';

LabVIEW syntax:
not implemented

Parameters: DevNr Return values: no return value number of device (0 ... 7)

Page 178

Industrial PLC-Communication Suite

9.2.12

Writing port parameters S7-PPI serial (AGLWriteIFPPPI)

This function writes the port settings for ACCON-AGLink S7-PPI serial of the selected device from the internal memory area into the registry. C/C++ syntax:
void AGLINK_API AGLWriteIFPPPI( int DevNr );

Visual Basic syntax:


Declare Sub AGLWriteIFPPPI Lib "AGLink.DLL" (ByVal DevNr As Long)

Delphi syntax:
procedure AGLWriteIFPPPI( DevNr: Long ); stdcall; external 'AGLink.DLL';

LabVIEW syntax:
not implemented

Parameters: DevNr Return values: no return value number of device (0 ... 7)

Industrial PLC-Communication Suite

Seite 179

9.2.13

Writing port parameters RK512/3964R (AGLWriteIFPRK)

This function writes the port settings for ACCON-AGLink RK512/3964R of the selected device from the internal memory area into the registry. C/C++ syntax:
void AGLINK_API AGLWriteIFPRK( int DevNr );

Visual Basic syntax:


Declare Sub AGLWriteIFPRK Lib "AGLink.DLL" (ByVal DevNr As Long)

Delphi syntax:
procedure AGLWriteIFPRK( DevNr: Long ); stdcall; external 'AGLink.DLL';

LabVIEW syntax:
not implemented

Parameters: DevNr Return values: no return value number of device (0 ... 7)

Page 180

Industrial PLC-Communication Suite

9.2.14

Writing port parameters S5 serial (AGLWriteIFPS5)

This function writes the port settings for ACCON-AGLink S5 serial of the selected device from the internal memory area into the registry. C/C++ syntax:
void AGLINK_API AGLWriteIFPS5( int DevNr );

Visual Basic syntax:


Declare Sub AGLWriteIFPS5 Lib "AGLink.DLL" (ByVal DevNr As Long)

Delphi syntax:
procedure AGLWriteIFPS5( DevNr: Long ); stdcall; external 'AGLink.DLL';

LabVIEW syntax:
not implemented

Parameters: DevNr Return values: no return value number of device (0 ... 7)

Industrial PLC-Communication Suite

Seite 181

9.3

Functions for querying the parameters

9.3.1

Querying the device type (AGLGetDevType)

This function returns the currently set device type of the requested device. C/C++ syntax:
int AGLINK_API AGLGetDevType( int DevNr );

Visual Basic syntax:


Declare Function AGLGetDevType Lib "AGLink.DLL" (ByVal DevNr As Long) As Long

Delphi syntax:
function AGLGetDevType( DevNr: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW syntax:

Parameters: DevNr Return values: >= 0 <0 currently selected AGL_DEVTYPE_TS, ...) type (AGL_DEVTYPE_MPI, number of device (0 ... 7)

an error code (see AGLink.H, AGLink.BAS or AGLink.PAS)

Page 182

Industrial PLC-Communication Suite

9.3.2

Querying the port parameters for S7-MPI serial (AGLGetIFPMPI)

This function selects the port settings for ACCON-AGLink S7 MPI serial from the internal memory area and writes it into the selected parameter structure. C/C++ syntax:
int AGLINK_API AGLGetIFPMPI( int DevNr, LPIFPARA_MPI Para, int Len );

Visual Basic syntax:


Declare Function AGLGetIFPMPI Lib "AGLink.DLL" (ByVal DevNr As Long, Para As IFPARA_MPI, ByVal ParaLen As Long) As Long

Delphi syntax:
function AGLGetIFPMPI( DevNr: Long; var Para: IFPARA_MPI; Len: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW syntax:
not implemented

Parameters: DevNr Para Len Return values: AGL_SUCCESS <0 in case of success an error code (see AGLink.H, AGLink.BAS or AGLink.PAS) number of device (0 ... 7) parameter structure length of structure

Industrial PLC-Communication Suite

Seite 183

9.3.3

Querying the port parameters for S7-MPI serial/TS (AGLGetIFPTS)

This function selects the port settings for ACCON-AGLink S7 MPI serial/TS from the internal memory area and writes it into the selected parameter structure. C/C++ syntax:
int AGLINK_API AGLGetIFPTS( int DevNr, LPIFPARA_TS Para, int Len );

Visual Basic syntax:


Declare Function AGLGetIFPTS Lib "AGLink.DLL" (ByVal DevNr As Long, Para As IFPARA_TS, ByVal ParaLen As Long) As Long

Delphi syntax:
function AGLGetIFPTS( DevNr: Long; var Para: IFPARA_TS; Len: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW syntax:
not implemented

Parameters: DevNr Para Len Return values: AGL_SUCCESS <0 In case of success an error code (see AGLink.H, AGLink.BAS or AGLink.PAS) number of device (0 ... 7) parameter structure length of structure

Page 184

Industrial PLC-Communication Suite

9.3.4

Querying the location parameters for S7-MPI serial/TS (AGLGetLPTS)

This function selects the location settings for ACCON-AGLink S7 MPI serial/TS from the internal memory area and writes it into the selected parameter structure. C/C++ syntax:
int AGLINK_API AGLGetLPTS( int DevNr, LPLOCPARA_TS Para, int Len );

Visual Basic syntax:


Declare Function AGLGetLPTS Lib "AGLink.DLL" (ByVal DevNr As Long, Para As LOCPARA_TS, ByVal ParaLen As Long) As Long

Delphi syntax:
function AGLGetLPTS( DevNr: Long; var Para: LOCPARA_TS; Len: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW syntax:
not implemented

Parameters: DevNr Para Len Return values: AGL_SUCCESS <0 In case of success an error code (see AGLink.H, AGLink.BAS or AGLink.PAS) number of device (0 ... 7) parameter structure length of structure

Industrial PLC-Communication Suite

Seite 185

9.3.5

Querying the dial number parameters for S7-MPI serial/TS (AGLGetDPTS)

This function selects the dial number settings for ACCON-AGLink S7 MPI serial/TS from the internal memory area and writes it into the selected parameter structure. C/C++ syntax:
int AGLINK_API AGLGetDPTS( int DevNr, LPDPARA_TS Para, int Len );

Visual Basic syntax:


Declare Function AGLGetDPTS Lib "AGLink.DLL" (ByVal DevNr As Long, Para As DPARA_TS, ByVal ParaLen As Long) As Long

Delphi syntax:
function AGLGetDPTS( DevNr: Long; var Para: DPARA_TS; Len: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW syntax:
not implemented

Parameters: DevNr Para Len Return values: AGL_SUCCESS <0 In case of success an error code (see AGLink.H, AGLink.BAS or AGLink.PAS) number of device (0 ... 7) parameter structure length of structure

Page 186

Industrial PLC-Communication Suite

9.3.6

Querying the port parameters for S7-PB/CIF (AGLGetIFPCIF)

This function selects the port settings for ACCON-AGLink S7-PB/CIF from the internal memory area and writes it into the selected parameter structure. C/C++ syntax:
int AGLINK_API AGLGetIFPCIF( int DevNr, LPIFPARA_CIF Para, int Len );

Visual Basic syntax:


Declare Function AGLGetIFPCIF Lib "AGLink.DLL" (ByVal DevNr As Long, Para As IFPARA_CIF, ByVal ParaLen As Long) As Long

Delphi syntax:
function AGLGetIFPCIF( DevNr: Long; var Para: IFPARA_CIF; Len: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW syntax:
not implemented

Parameters: DevNr Para Len Return values: AGL_SUCCESS <0 In case of success an error code (see AGLink.H, AGLink.BAS or AGLink.PAS) number of device (0 ... 7) parameter structure length of structure

Industrial PLC-Communication Suite

Seite 187

9.3.7

Querying the port parameters for S7-PB/NetLinkDrv (AGLGetIFPNLDRV)

This function selects the port settings for ACCON-AGLink S7-PB/NetLinkDrv from the internal memory area and writes it into the selected parameter structure.

C/C++ syntax:
int AGLINK_API AGLGetIFPNLDRV( int DevNr, LPIFPARA_NL_DRV Para, int Len );

Visual Basic syntax:


Declare Function AGLGetIFPNLDRV Lib "AGLink.DLL" (ByVal DevNr As Long, Para As IFPARA_NL_DRV, ByVal ParaLen As Long) As Long

Delphi syntax:
function AGLGetIFPNLDRV( DevNr: Long; var Para: IFPARA_NL_DRV; Len: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW syntax:
not implemented

Parameters: DevNr Para Len Return values: AGL_SUCCESS <0 In case of success an error code (see AGLink.H, AGLink.BAS or AGLink.PAS) number of device (0 ... 7) parameter structure length of structure

Page 188

Industrial PLC-Communication Suite

9.3.8

Querying the port parameters for S7-PB/Softing (AGLGetIFPSOFTING)

This function selects the port settings for ACCON-AGLink S7-PB/Softing from the internal memory area and writes it into the selected parameter structure. C/C++ syntax:
int AGLINK_API AGLGetIFPSOFTING( int DevNr, LPIFPARA_SOFTING Para, int Len );

Visual Basic syntax:


Declare Function AGLGetIFPSOFTING Lib "AGLink.DLL" (ByVal DevNr As Long, Para As IFPARA_SOFTING, ByVal ParaLen As Long) As Long

Delphi syntax:
function AGLGetIFPSOFTING( DevNr: Long; var Para: IFPARA_SOFTING; Len: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW syntax:
not implemented

Parameters: DevNr Para Len Return values: AGL_SUCCESS <0 In case of success an error code (see AGLink.H, AGLink.BAS or AGLink.PAS) number of device (0 ... 7) parameter structure length of structure

Industrial PLC-Communication Suite

Seite 189

9.3.9

Querying the port parameters for S7-TCP/IP (AGLGetIFPTCPIP)

This function selects the port settings for ACCON-AGLink S7-TCP/IP from the internal memory area and writes it into the selected parameter structure. C/C++ syntax:
int AGLINK_API AGLGetIFPTCPIP( int DevNr, LPIFPARA_TCPIP Para, int Len );

Visual Basic syntax:


Declare Function AGLGetIFPTCPIP Lib "AGLink.DLL" (ByVal DevNr As Long, Para As IFPARA_TCPIP, ByVal ParaLen As Long) As Long

Delphi syntax:
function AGLGetIFPTCPIP( DevNr: Long; var Para: IFPARA_TCPIP; Len: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW syntax:
not implemented

Parameters: DevNr Para Len Return values: AGL_SUCCESS <0 In case of success an error code (see AGLink.H, AGLink.BAS or AGLink.PAS) number of device (0 ... 7) parameter structure length of structure

Page 190

Industrial PLC-Communication Suite

9.3.10 Querying the port parameters for S7-TCP/NetLinkIP (AGLGetIFPNLIP)


This function selects the port settings for ACCON-AGLink S7-TCP/NetLinkIP from the internal memory area and writes it into the selected parameter structure C/C++ syntax:
int AGLINK_API AGLGetIFPNLIP( int DevNr, LPIFPARA_NL_IP Para, int Len );

Visual Basic syntax:


Declare Function AGLGetIFPNLIP Lib "AGLink.DLL" (ByVal DevNr As Long, Para As IFPARA_NL_IP, ByVal ParaLen As Long) As Long

Delphi syntax:
function AGLGetIFPNLIP( DevNr: Long; var Para: IFPARA_NL_IP; Len: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW syntax:
not implemented

Parameters: DevNr Para Len Return values: AGL_SUCCESS <0 In case of success an error code (see AGLink.H, AGLink.BAS or AGLink.PAS) number of device (0 ... 7) parameter structure length of structure

Industrial PLC-Communication Suite

Seite 191

9.3.11

Querying the port parameters for S7-PPI serial (AGLGetIFPPPI)

This function selects the port settings for ACCON-AGLink S7-PPI serial from the internal memory area and writes it into the selected parameter structure. C/C++ syntax:
int AGLINK_API AGLGetIFPPPI( int DevNr, LPIFPARA_PPI Para, int Len );

Visual Basic syntax:


Declare Function AGLGetIFPPPI Lib "AGLink.DLL" (ByVal DevNr As Long, Para As IFPARA_PPI, ByVal ParaLen As Long) As Long

Delphi syntax:
function AGLGetIFPPPI( DevNr: Long; var Para: IFPARA_PPI; Len: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW syntax:
not implemented

Parameters: DevNr Para Len Return values: AGL_SUCCESS <0 In case of success an error code (see AGLink.H, AGLink.BAS or AGLink.PAS) number of device (0 ... 7) parameter structure length of structure

Page 192

Industrial PLC-Communication Suite

9.3.12

Querying the port parameters for RK512/3964R (AGLGetIFPRK)

This function selects the port settings for ACCON-AGLink RK512/3964R from the internal memory area and writes it into the selected parameter structure. C/C++ syntax:
int AGLINK_API AGLGetIFPRK( int DevNr, LPIFPARA_RK Para, int Len );

Visual Basic syntax:


Declare Function AGLGetIFPRK Lib "AGLink.DLL" (ByVal DevNr As Long, Para As IFPARA_RK, ByVal ParaLen As Long) As Long

Delphi syntax:
function AGLGetIFPRK( DevNr: Long; var Para: IFPARA_RK; Len: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW syntax:
not implemented

Parameters: DevNr Para Len Return values: AGL_SUCCESS <0 In case of success an error code (see AGLink.H, AGLink.BAS or AGLink.PAS) number of device (0 ... 7) parameter structure length of structure

Industrial PLC-Communication Suite

Seite 193

9.3.13

Querying the port parameters for S5 serial (AGLGetIFPS5)

This function selects the port settings for ACCON-AGLink S5 serial from the internal memory area and writes it into the selected parameter structure. C/C++ syntax:
int AGLINK_API AGLGetIFPS5( int DevNr, LPIFPARA_S5 Para, int Len );

Visual Basic syntax:


Declare Function AGLGetIFPS5 Lib "AGLink.DLL" (ByVal DevNr As Long, Para As IFPARA_S5, ByVal ParaLen As Long) As Long

Delphi syntax:
function AGLGetIFPS5( DevNr: Long; var Para: IFPARA_S5; Len: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW syntax:
not implemented

Parameters: DevNr Para Len Return values: AGL_SUCCESS <0 In case of success an error code (see AGLink.H, AGLink.BAS or AGLink.PAS) number of device (0 ... 7) parameter structure length of structure

Page 194

Industrial PLC-Communication Suite

9.4 Functions for setting the parameters

9.4.1

Setting device type (AGLSetDevType)

This function sets the device type of the selected device on the current value. C/C++ syntax:
int AGLINK_API AGLSetDevType( int DevNr, int DevType );

Visual Basic syntax:


Declare Function AGLSetDevType Lib "AGLink.DLL" (ByVal DevNr As Long, ByVal DevType As Long) As Long

Delphi syntax:
function AGLSetDevType( DevNr, DevType: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW syntax:

Parameters: DevNr DevType number of device (0 ... 7) device type to be set (AGL_DEVTYPE_MPI, AGL_DEVTYPE_TS, ...)

Return values: AGL_SUCCESS <0 In case of success an error code (see AGLink.H, AGLink.BAS or AGLink.PAS)

Industrial PLC-Communication Suite

Seite 195

9.4.2

Setting port parameters S7-MPI serial (AGLSetIFPMPI)

This function changes the port settings for ACCON-AGLink S7 MPI serial to the values submitted in the parameter structure, provided that this is permitted. C/C++ syntax:
int AGLINK_API AGLSetIFPMPI( int DevNr, LPIFPARA_MPI Para, int Len );

Visual Basic syntax:


Declare Function AGLSetIFPMPI Lib "AGLink.DLL" (ByVal DevNr As Long, Para As IFPARA_MPI, ByVal ParaLen As Long) As Long

Delphi syntax:
function AGLSetIFPMPI( DevNr: Long; var Para: IFPARA_MPI; Len: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW syntax:
not implemented

Parameters: DevNr Para Len Return values: AGL_SUCCESS <0 In case of success an error code (see AGLink.H, AGLink.BAS or AGLink.PAS) number of device (0 ... 7) parameter structure length of structure

Page 196

Industrial PLC-Communication Suite

9.4.3

Setting port parameters S7-MPI serial/TS (AGLSetIFPTS)

This function changes the port settings for ACCON-AGLink S7 MPI serial/TS to the values submitted in the parameter structure, provided that this is permitted. C/C++ syntax:
int AGLINK_API AGLSetIFPTS( int DevNr, LPIFPARA_TS Para, int Len );

Visual Basic syntax:


Declare Function AGLSetIFPTS Lib "AGLink.DLL" (ByVal DevNr As Long, Para As IFPARA_TS, ByVal ParaLen As Long) As Long

Delphi syntax:
function AGLSetIFPTS( DevNr: Long; var Para: IFPARA_TS; Len: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW syntax:
not implemented

Parameters: DevNr Para Len Return values: AGL_SUCCESS <0 In case of success an error code (see AGLink.H, AGLink.BAS or AGLink.PAS) number of device (0 ... 7) parameter structure length of structure

Industrial PLC-Communication Suite

Seite 197

9.4.4

Setting location parameters S7-MPI serial/TS (AGLSetLPTS)

This function changes the location settings for ACCON-AGLink S7 MPI serial/TS to the values submitted in the parameter structure, provided that this is permitted. C/C++ syntax:
int AGLINK_API AGLSetLPTS( int DevNr, LPLOCPARA_TS Para, int Len );

Visual Basic syntax:


Declare Function AGLSetLPTS Lib "AGLink.DLL" (ByVal DevNr As Long, Para As LOCPARA_TS, ByVal ParaLen As Long) As Long

Delphi syntax:
function AGLSetLPTS( DevNr: Long; var Para: LOCPARA_TS; Len: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW syntax:
not implemented

Parameters: DevNr Para Len Return values: AGL_SUCCESS <0 In case of success an error code (see AGLink.H, AGLink.BAS or AGLink.PAS) number of device (0 ... 7) parameter structure length of structure

Page 198

Industrial PLC-Communication Suite

9.4.5

Setting dial number parameters S7-MPI serial/TS (AGLSetDPTS)

This function changes the dial number settings for ACCON-AGLink S7 MPI serial/TS to the values submitted in the parameter structure, provided that this is permitted. C/C++ syntax:
int AGLINK_API AGLSetDPTS( int DevNr, LPDPARA_TS Para, int Len );

Visual Basic syntax:


Declare Function AGLSetDPTS Lib "AGLink.DLL" (ByVal DevNr As Long, Para As DPARA_TS, ByVal ParaLen As Long) As Long

Delphi syntax:
function AGLSetDPTS( DevNr: Long; var Para: DPARA_TS; Len: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW syntax:
not implemented

Parameters: DevNr Para Len Return values: AGL_SUCCESS <0 In case of success an error code (see AGLink.H, AGLink.BAS or AGLink.PAS) number of device (0 ... 7) parameter structure length of structure

Industrial PLC-Communication Suite

Seite 199

9.4.6

Setting port parameters S7-PB/CIF (AGLSetIFPCIF)

This function changes the port settings for ACCON-AGLink S7-PB/CIF to the values submitted in the parameter structure, provided that this is permitted. C/C++ syntax:
int AGLINK_API AGLSetIFPCIF( int DevNr, LPIFPARA_CIF Para, int Len );

Visual Basic syntax:


Declare Function AGLSetIFPCIF Lib "AGLink.DLL" (ByVal DevNr As Long, Para As IFPARA_CIF, ByVal ParaLen As Long) As Long

Delphi syntax:
function AGLSetIFPCIF( DevNr: Long; var Para: IFPARA_CIF; Len: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW syntax:
not implemented

Parameters: DevNr Para Len Return values: AGL_SUCCESS <0 In case of success an error code (see AGLink.H, AGLink.BAS or AGLink.PAS) number of device (0 ... 7) parameter structure length of structure

Page 200

Industrial PLC-Communication Suite

9.4.7

Setting port parameters S7-PB/NetLinkDrv (AGLSetIFPNLDRV)

This function changes the port settings for ACCON-AGLink S7-PB/NetLinkDrv to the values submitted in the parameter structure, provided that this is permitted. C/C++ syntax:
int AGLINK_API AGLSetIFPNLDRV( int DevNr, LPIFPARA_NL_DRV Para, int Len );

Visual Basic syntax:


Declare Function AGLSetIFPNLDRV Lib "AGLink.DLL" (ByVal DevNr As Long, Para As IFPARA_NL_DRV, ByVal ParaLen As Long) As Long

Delphi syntax:
function AGLSetIFPNLDRV( DevNr: Long; var Para: IFPARA_NL_DRV; Len: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW syntax:
not implemented

Parameters: DevNr Para Len Return values: AGL_SUCCESS <0 In case of success an error code (see AGLink.H, AGLink.BAS or AGLink.PAS) number of device (0 ... 7) parameter structure length of structure

Industrial PLC-Communication Suite

Seite 201

9.4.8

Setting port parameters S7-PB/Softing (AGLSetIFPSOFTING)

This function changes the port settings for ACCON-AGLink S7-PB/Softing to the values submitted in the parameter structure, provided that this is permitted. C/C++ syntax:
int AGLINK_API AGLSetIFPSOFTING( int DevNr, LPIFPARA_SOFTING Para, int Len );

Visual Basic syntax:


Declare Function AGLSetIFPSOFTING Lib "AGLink.DLL" (ByVal DevNr As Long, Para As IFPARA_SOFTING, ByVal ParaLen As Long) As Long

Delphi syntax:
function AGLSetIFPSOFTING( DevNr: Long; var Para: IFPARA_SOFTING; Len: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW syntax:
not implemented

Parameters: DevNr Para Len Return values: AGL_SUCCESS <0 In case of success an error code (see AGLink.H, AGLink.BAS or AGLink.PAS) number of device (0 ... 7) parameter structure length of structure

Page 202

Industrial PLC-Communication Suite

9.4.9

Setting port parameters S7-TCP/IP (AGLSetIFPTCPIP)

This function changes the port settings for ACCON-AGLink S7-TCP/IP to the values submitted in the parameter structure, provided that this is permitted.

C/C++ syntax:
int AGLINK_API AGLSetIFPTCPIP( int DevNr, LPIFPARA_TCPIP Para, int Len );

Visual Basic syntax:


Declare Function AGLSetIFPTCPIP Lib "AGLink.DLL" (ByVal DevNr As Long, Para As IFPARA_TCPIP, ByVal ParaLen As Long) As Long

Delphi syntax:
function AGLSetIFPTCPIP( DevNr: Long; var Para: IFPARA_TCPIP; Len: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW syntax:
not implemented

Parameters: DevNr Para Len Return values: AGL_SUCCESS <0 In case of success an error code (see AGLink.H, AGLink.BAS or AGLink.PAS) number of device (0 ... 7) parameter structure length of structure

Industrial PLC-Communication Suite

Seite 203

9.4.10 Setting port parameters S7-TCP/NetLinkIP (AGLSetIFPNLIP)


This function changes the port settings for ACCON-AGLink S7-TCP/NetLinkIP to the values submitted in the parameter structure, provided that this is permitted. C/C++ syntax:
int AGLINK_API AGLSetIFPNLIP( int DevNr, LPIFPARA_NL_IP Para, int Len );

Visual Basic syntax:


Declare Function AGLSetIFPNLIP Lib "AGLink.DLL" (ByVal DevNr As Long, Para As IFPARA_NL_IP, ByVal ParaLen As Long) As Long

Delphi syntax:
function AGLSetIFPNLIP( DevNr: Long; var Para: IFPARA_NL_IP; Len: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW syntax:
not implemented

Parameters: DevNr Para Len Return values: AGL_SUCCESS <0 In case of success an error code (see AGLink.H, AGLink.BAS or AGLink.PAS) number of device (0 ... 7) parameter structure length of structure

Page 204

Industrial PLC-Communication Suite

9.4.11

Setting port parameters S7-PPI serial (AGLSetIFPPPI)

This function changes the port settings for ACCON-AGLink S7-PPI serial to the values submitted in the parameter structure, provided that this is permitted. C/C++ syntax:
int AGLINK_API AGLSetIFPPPI( int DevNr, LPIFPARA_PPI Para, int Len );

Visual Basic syntax:


Declare Function AGLSetIFPPPI Lib "AGLink.DLL" (ByVal DevNr As Long, Para As IFPARA_PPI, ByVal ParaLen As Long) As Long

Delphi syntax:
function AGLSetIFPPPI( DevNr: Long; var Para: IFPARA_PPI; Len: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW syntax:
not implemented

Parameters: DevNr Para Len Return values: AGL_SUCCESS <0 In case of success an error code (see AGLink.H, AGLink.BAS or AGLink.PAS) number of device (0 ... 7) parameter structure length of structure

Industrial PLC-Communication Suite

Seite 205

9.4.12

Setting port parameters RK512/3964R (AGLSetIFPRK)

This function changes the port settings for ACCON-AGLink RK512/3964R to the values submitted in the parameter structure, provided that this is permitted. C/C++ syntax:
int AGLINK_API AGLSetIFPRK( int DevNr, LPIFPARA_RK Para, int Len );

Visual Basic syntax:


Declare Function AGLSetIFPRK Lib "AGLink.DLL" (ByVal DevNr As Long, Para As IFPARA_RK, ByVal ParaLen As Long) As Long

Delphi syntax:
function AGLSetIFPRK( DevNr: Long; var Para: IFPARA_RK; Len: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW syntax:
not implemented

Parameters: DevNr Para Len Return values: AGL_SUCCESS <0 In case of success an error code (see AGLink.H, AGLink.BAS or AGLink.PAS) number of device (0 ... 7) parameter structure length of structure

Page 206

Industrial PLC-Communication Suite

9.4.13 Setting port parameters S5 serial (AGLSetIFPS5)


This function changes the port settings for ACCON-AGLink S5 serial to the values submitted in the parameter structure, provided that this is permitted. C/C++ syntax:
int AGLINK_API AGLSetIFPS5( int DevNr, LPIFPARA_S5 Para, int Len );

Visual Basic syntax:


Declare Function AGLSetIFPS5 Lib "AGLink.DLL" (ByVal DevNr As Long, Para As IFPARA_S5, ByVal ParaLen As Long) As Long

Delphi syntax:
function AGLSetIFPS5( DevNr: Long; var Para: IFPARA_S5; Len: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW syntax:
not implemented

Parameters: DevNr Para Len Return values: AGL_SUCCESS <0 In case of success an error code (see AGLink.H, AGLink.BAS or AGLink.PAS) number of device (0 ... 7) parameter structure length of structure

Industrial PLC-Communication Suite

Seite 207

9.5

Additional functions

9.5.1

Calling external configuration program (AGLConfig)

This function calls the program "AGLink_Config.EXE". This must be filed in the search path or in the current work directory of your application. C/C++ syntax:
int AGLINK_API AGLConfig( int DevNr );

Visual Basic syntax:


Declare Function AGLConfig Lib "AGLink.DLL" (ByVal DevNr As Long) As Long

Delphi syntax:
function AGLConfig( DevNr: Long ): Long; stdcall; external 'AGLink.DLL';

LabVIEW syntax:

Parameters: DevNr Number of device (0 ... 7 if only a specific device shall be configured or -1 if all devices shall be configured)

Return values: AGL_SUCCESS <0 In case of success an error code (see AGLink.H, AGLink.BAS or AGLink.PAS)

Page 208

Industrial PLC-Communication Suite

Industrial PLC-Communication Suite

Seite 209

10 Appendix A
10.1 Q&A list for ACCON-AGLink

10.1.1

Whats about the transmission speed of ACCON-AGLink ?

This depends on which hardware components and which transmission paths are used. In internal tests we determined the following approximated values for reading of 16 data bytes: Tested hardware components S7 315-2 DP with Siemens PC adapter V5.0 S7 412-1 with Siemens PC adapter V5.0 S7 315-2 DP with ACCON-MPI adapter S7 412-1 with ACCON-MPI adapter S7 315-2 DP with ACCON-PB/MP card on MPI board with 187,5 kBaud S7 412-1 with ACCON-PB/MPI card on MPI board with 187,5 kBaud S7 318-2 with ACCON-PB/MPI card on MPI board with 187,5 kBaud S7 318-2 with ACCON-PB/MPI card on MPI board with 1500 kBaud S7 416-2 with ACCON-PB/MPI card on MPI board with 1500 kBaud S7 315-2 DP with CP 343-1 S7 318-2 with CP 343-1 S7 414-3 with CP 443-1 S7 416-2 with CP 443-1 IT S7 2xx with 9,6 kBaud S7 2xx with 19,2 kBaud Used ACCON-AGLink module S7-MPI serial S7-MPI serial S7-MPI serial S7-MPI serial S7-PB S7-PB S7-PB S7-PB S7-PB S7-TCP/IP S7-TCP/IP S7-TCP/IP S7-TCP/IP S7-PPI serial S7-PPI serial Averaged time per transmission in ms 100 100 54 52 35 26 21 10 10 36 18 9 9 106 54

The listed times can vary depending on the PLC load and the data traffic on the bus. When more data are transmitted, then up to the packet size (approx. 220 bytes for S7 300 and 460 bytes for S7 400) the pure data transmission time has to be added.

Page 210

Industrial PLC-Communication Suite

10.1.2

Do I have to change my program, when I need an additional module?

No, because of the uniform software interface of ACCON-AGLink it is possible, only to implement the new DLL and to adjust the parameters with the program AGLink_Config.EXE. The new hardware components can be used immediately. That's all.

10.1.3

When I need e.g. MPI serial and TCP/IP, do I obtain two different DLL versions?

No. All hardware supports purchased by you are in one DLL and are always at your disposal. A version administration (on which customer computer is which hardware DLL) is not necessary.

10.1.4

Which advantages offer ACCON-AGLink to me?

ACCON-AGLink is fast, compact and easy to use. All files needed for the customer match comfortably on a floppy disk. These can be copied simply on the target computer. An expensive installing is not necessary. ACCON-AGLink is on the one hand multithread safe and on the other hand permits an asynchronous communication at all modules. In the foreground you can react fast to user inputs while the communication is treated unnoticeably in the background. In addition offers ACCON-AGLink a uniform software interface for all modules. When customers need further hardware support, you don't have to change your programs. It suffices to implement the new DLL and to configure the interface according to the used hardware components. ACCON-AGLink is free of runtime charges. Every developer that implements programs with ACCON-AGLink needs his own license. Also see the complete license agreement to this subject in appendix C.

10.1.5

What happens when there appear new hardware components, which were not yet supported from my ACCON-AGLink release?

ACCON-AGLink is permanently developed further and adapted to new hardware components. To ensure that you are always up to date, we offer for ACCON-AGLink a maintenance agreement. The agreement includes that you receive automatically all new releases of your DLL sent by e-mail. The most comfortable way to remain up to date.

10.1.6

Whats about a demo version of ACCON-AGLink?

Of course. You can get the demo version simply from the Internet www.deltalogic.de. We are also glad to send you our current software CD-ROM by mail. Please call us or send us a fax or a e-mail.

Industrial PLC-Communication Suite

Seite 211

10.1.7

What is the scope of the demo version of ACCON-AGLink?

With the demo version you can test the full scope of ACCON-AGLink. The communication is stopped merely every five minutes and an indication appears on the screen that you use a demo version of ACCON-AGLink.

10.1.8

Do I have to pay runtime charges for programs that are developed with ACCON-AGLink?

No. You acquire only one license of ACCON-AGLink per developer place. No further charges appear for the developed programs made by you in accordance with the license agreement. Please see the complete license agreement to this subject in appendix C.

10.1.9

Do I need for ACCON-AGLink S7-MPI serial/TS the TS software from Siemens?

No. All functions for the administration of the phone numbers, for the connection set-up and for the data transmission are completely dealt with by ACCON-AGLink S7 MPI serial/TS.

10.1.10 What happens when the cable is removed using ACCON-AGLink S7- MPI serial?
You receive a corresponding error message. De-initialize in this case the interface complete with the functions AGLPLCDisconnect, AGLExitAdapter and AGLHangUp. Try now to restart the communication with the functions AGLDialUp and AGLInitAdapter. As soon as the adapter is plugged in again, you receive with the function AGLInitAdapter no more error message. Now you can execute the function AGLPLCConnect and continue the communication.

10.1.11 How large can the requested data packets be?


In principle arbitrarily large. ACCON-AGLink splits automatically in wholesome bits for the PLC. Both are considered, the transmission medium and the PLC family. You need to care about nothing and e.g. also can make an enquiry about 8192 data bytes at the piece. If the block size is too large for the PLC because perhaps the requested inputs are not available, you receive a corresponding error message from the PLC.

10.1.12 Can I also read double words with ACCON-AGLink?


In the case of block operations ACCON-AGLink always reads byte by byte. AGLReadMix and AGLWriteMix are efficient functions at the disposal that can process besides bytes also words, double words and even bits. When a read data block contains words, double words,

Page 212

Industrial PLC-Communication Suite

real numbers etc. ACCON-AGLink contains conversion functions for reading or writing access to the corresponding buffer.

10.1.13 For accessing the PLC do I have to change the S7 program?


No. You only must know which control data are important for you. Then you can completely transparent access with ACCON-AGLink to the data, input, and output and flag bytes as well as to the timer and counter words of the PLC.

10.1.14 Can I access with ACCON-AGLink S7-MPI the PLC also via Profibus?
Yes. For you no difference is recognizable. It is important for the Profibus access that you have selected the correct bus baud rate for the communication in the function AGLink_Config.EXE (or program-controlled).

10.1.15 What can I do, when the communication via PC adapter is too slow?
You most simply use our MPI-/Profibus card in such cases. It offers a higher data throughput with moderate costs PLC-sided is no CP necessary.

10.1.16 Does every arbitrary Profibus card works with ACCON-AGLink S7-PB?
No. At present we support besides the Profibus cards also the ACCON-PB/MPI card of the company Softing. This is identically constructed with the Profibus cards of the company Hilscher. Whether and when further cards will be supported, it depends on the customer demand and the manufacturer support.

10.1.17 How can I access to the S7 with a PC adapter, when the MPI port is occupied from a OP?
MPI is a bus. You simply need a corresponding bus plug with feed-through input for the connection of the OP. It is important that the power supplies are looped through, otherwise the adapter remains dark.

10.1.18 How can I access with ACCON-AGLink multiple PLCs simultaneous?


Very simple. You enter with the function call, on which PLC you want to access. A couple of hardware restrictions still have to be taken into account for parallel access. Depending on the used hardware components the number of simultaneous connections is limited on 2 (MPI adapter), 4 (PC adapter), 8 (for ACCON AGLink version 2.x) or 16 (for ACCON AGLink version 3.0). For not exceeding the maximum number you can disconnect from one PLC and

Industrial PLC-Communication Suite

Seite 213

connect to the next one. You can alternatively also split your bus system into corresponding smaller segments and then use one communication adapter per segment (applies to MPI or Profibus). ACCON-AGLink supports up to eight simultaneous devices with each respectively up to 16 simultaneous PLCs (version 3.0), i.e. you have at most 128 PLCs directly in the access. When you use TCP/IP, it suffices to parameterize and use another additional device than TCP/IP. For the 128 PLCs no additional hardware components are necessary on the PC side.

10.1.19 Can I connect the PPI cable only to one series 200 PLC?
No. You can connect several series 200 controls with a Profibus wiring to a network. You only have to take care that every PLC receives its own and unique address. You can adjust this with the programming system. With ACCON-AGLink S7 PPI serial you list the number of the selected PLC with the function call.

10.1.20 The function AGLPLCConnect of ACCON AGLink S7 TCP/IP is successful, however the reading of the data provides an error code. What's wrong?
In the parameter setting with the function AGLink_Config (or in the program code) you have presumably typed the rack and slot number of the CP and not the requested CPU. Please take the correct values from the hardware configuration and insert these with the function AGLink_Config or in the parameters.

10.1.21 Why appears under Windows 95 an error message during processing a with ACCON-AGLink developed program ?
ACCON-AGLink is not released for Windows 95, as described in the documentation. When some prerequisites are given, the program can execute. The following descriptions are given without guarantee, we dont ensure functionality. First, it is necessary to install the network protocol TCP/IP. This is even necessary when neither the extended function scope (ACCON-AGLink S7-TCP/IP) nor the corresponding communication function is used. In addition the release number of the network protocol is important. Per default for the versions of Windows 95 Winsock V1 (Winsock.dll) was delivered , but ACCON-AGLink needs Winsock V2 (WS2_32.dll). On the website of the company Microsoft is an update available, please take into account their hints and information.

10.1.22 Why are the device settings not permanently stored under Windows 2000/XP ?
When the parameter settings of the program AGLink_Config (or via program code) are not stored under Windows 2000/XP, you have presumably limited user authority. ACCON-AGLink stores these parameters in the registry data base (Registry) in the directory HKLM. With Windows 2000/XP only the user group Hauptbenutzer has the necessary access in this directory. With Windows NT the access as user is sufficient.

Page 214

Industrial PLC-Communication Suite

Take care that you have access in the needed group and the parameter settings can be stored permanently.

Industrial PLC-Communication Suite Appendix B

Seite 215

10.2 Documentation of updates release 2.x

10.2.1

Release 2.1
description Release 2.1 approved

date who 05.04.2001 RH

10.2.2

Release 2.2
description For reasons of compatibility towards AGLink release 1.x the result structure changed from Typedef struct tagRESULT { long State; long ErrCode; long SError; SYSTEMTIME SysTime; } RESULT, *LPRESULT; to typedef struct tagRESULT { long State; long ErrCode; SYSTEMTIME SysTime; Long SError; } RESULT, *LPRESULT;

date who 06.04.2001 RH

06.04.2001 RH 06.04.2001 RH

AGLink_Config.EXE changed, that no source code of the AGLink.DLL is used in the project, AGLink.DLL is called directly.. DLL info functions added. These are in detail: AGLGetDLLVersion AGLGetOptions AGLGetSerialNumber AGLGetClientName determine the version of DLL determine the available options determine the serial number of DLL determine the registered user

06.04.2001 RH 06.04.2001 RH 14.04.2001 RH

AGLink_Info.EXE created. This console application finds the information of the DLL out with above functions and returns these values. Correction made in AGLPLCDisconnect. the module S7-MPI/CIF in the function

The functions of the AGLink.DLL are exported in addition with fixed numbers. Thereby additional functions can be inserted without changing the order of the functions. Else the adding of new functions and use of the old programs can lead otherwise to a protection injury (GP). NOTICE: All programs that use the AGLink-DLL as LoadOnStart

Page 216

Industrial PLC-Communication Suite (statically), must be linked again. This affects BCB and MSVC.

20.04.2001 RH

The module S7-MPI/CIF changed that several jobs can be worked off completely parallel on different controls. Up to 8 controls can be addressed at the same time. Release 2.2 approved

23.04.2001 RH

10.2.3

Release 2.3
description Demo limitation changed. A call number dependent indication replaced by a time-dependent indication. Every 5 minutes appears now the indication that it is a demo version of ACCON-AGLink (instead after every 512 calls). A restriction in the number of bytes per job doesn't exist any more. This corresponds now to the complete version. In module S7-MPI/TS support for TS adapter version 3.2 integrated. TCP/IP module finished. TCP/IP parameterization in AGLink_Config.EXE integrated. Release 2.3 approved.

date who 22.06.2001 RH

22.06.2001 RH 25.06.2001 RH 27.06.2001 RH 27.06.2001 RH

10.2.4 Release 2.3.1


date who 05.07.2001 RH description AGLUseSystemTime implemented. Usually the time is determined with the function GetLocalTime in the result structure. With this call the time inquiry can be switched over to the function GetSystemTime. Comfortable functions for Test, Set and Reset of bits implemented. These are in detail AGLGetBit, AGLSetBit, AGLResetBit and AGLSetBitVal.

16.07.2001 RH

Industrial PLC-Communication Suite

Seite 217

10.2.5

Release 2.4
Description Implementation of LabView support in ACCON-AGLink. The functions to access via PPI cable to S7 series 200 implemented. Therefore the structure of the interface parameters for PPI changed. For the use of the new DLL, the configuration program must be re-called once and the interface parameters stored again, if PPI was already selected. AGLink_Config.EXE adapted to implementation of version check. the changed structure and

Date who 08.02.2002 RH 12.02.2002 RH

12.02.2002 RH 16.02.2002 RH

Additional functions to access to the additional areas of the S7 series 200 implemented. These are in particular: AGLReadSFlagBytes, AGLReadVarBytes, AGLWriteSFlagBytes, AGLWriteVarBytes. As an alternative to these functions the compatible functions (see the corresponding chapter of the function reference) can be used for the development hardware-independent programs.

16.02.2002 RH 18.02.2002 RH

Internal error handling (messages from the PLC) improved. This affects all modules. Release 2.4 approved.

Page 218

Industrial PLC-Communication Suite

10.3 Documentation of updates release 3.x

10.3.1

Release 3.0
Description Error in function AGLReadS5Time eliminated. ACCON-AGLink S7 TCP/IP adapted to the peculiarities of the old CPs in case of large data packets. If required, "Fast Acknowledge" is used automatically now. The functions AGLReadPLCInfo adapted to the memory areas of the "great" PLCs. The function AGLActivate implemented. ACCON-AGLink must be now activated first with an enclosed key before you can communicate. Every DLL can therefore only be used by the specific licensee. The number of simultaneously usable PLCs per device increased from 8 to 16. With the modules ACCON-AGLink S7 PB and ACCON-AGLink S7 TCP/IP 16 open connections can be used simultaneously, for the other modules the hardware isn't suitable. The modules ACCON-AGLink S7-MPI serial and ACCON-AGLink S7PB/CIF prepared for the expansion of profiles and type of connection. Therefore a change of structure was necessary. Is also in the current release downward compatible implemented. For ACCON-AGLink S7 TCP/IP the expansion capabilities are also considered in the structure. For the use of the new DLL, the configuration program must be re-called once and the interface parameters must be stored again if one of the listed modules was already selected. Change of name for the module ACCON-AGLink S7 MPI/CIF in new name ACCON-AGLink S7 PB/CIF. The further modules ACCON-AGLink S7 PB/NetLinkDrv, ACCON-AGLink S7 PB/Softing and ACCON-AGLink S7 TCP/NetLinkIP already fixed by name. In module ACCON-AGLink S7 TCP/IP problem at renewed connection set-up after pulled network cable under W2K solved. The functions for the access with ACCON-NetLink and device driver to the S7 series 300 and S7 series 400 implemented. Structures already prepared for the access to the S7 series 300 and S7 series 400 with ACCON-NetLink and TCP/IP. The functions implemented for the access to the S7 series 300 and S7 series 400 via the Profibus cards of the company Softing. Additional functions for storing, loading, reading and writing of parameters of the news modules implemented. Function AGLink_Config.EXE adapted to the changed structures and latest supported communication hardware and release check implemented. An additional function AGLGetDLLVersionEx implemented. This also provides besides the principal and secondary release number also the

date who 22.04.2002 RH 06.05.2002 RH

15.05.2002 RH 23.05.2002 RH

04.06.2002 RH

13.06.2002 RH

14.06.2002 RH

19.06.2002 RH 21.07.2002 RH 21.07.2002 RH 01.07.2002 RH 04.07.2002 RH 05.07.2002 RH

05.07.2002 RH

Industrial PLC-Communication Suite

Seite 219

provides besides the principal and secondary release number also the build number and the creation date.. 06.07.2002 RH An additional support program AGLink_Performance.EXE written. This program is in the directory AGLink_Tools and determines the data throughput based on the selected communication hardware. It is looking in the attached PLC for the respectively largest data block and then consults it for the measuring of the reading throughput. Optionally the writing throughput also can be determined. Release 3.0 approved.

08.07.2002 RH

10.3.2

Version 3.1
Was Improvement of error handling series S7-200.

Datum Wer 26.09.2002 RH

15.11.2002 UWa Implementation of AGLink for DotNet with corresponding example programs in C# and VB.net 15.11.2002 AE 18.11.2002 Hre 11.12.2002 RH 12.12.2002 RH English version of file AGLink_Error.TXT. LabVIEW-syntax implementation completed. problem (TCP/IP version) for AGLPLCConnect immediately after AGLPLCDisconnect solved. Change of function AGLGetErrorMsg. the error file is no longer expected in the directory of the EXE but in the directory AGLink.DLL. In the past this constellation caused problems especially in the development environment (VB, LabVIEW). Change of function AGLConfig. the program AGLink_Config.EXE is searched first in the directory AGLink.DLL. If not found there, it will be searched in the path. New functions implemented for copying of strings into a Byte buffer (AGLString2Buff) and for copying of a Byte buffer into a string (AGLBuff2String). This simplifies the handling under e.g. VB. New function implemented for returning a signed 16 bit integer from a byte buffer (AGLReadInt16). New function implemented for accessing to a control with e.g. a separate Profibus-CP with information of rack and slot number of the CPU (AGLPLCConnectEx). Complete implementation of in release 3.0 prepared connection types (PG, OP and Others). Complete implementation of in release 3.0 prepared connection profiles (MPI, DP, standard and universal (DP/FMS)). New function implemented for loading the error text (AGLLoadErrorFile) especially for changing the message language. file

12.12.2002 RH

12.12.2002 RH

12.12.2002 RH 18.12.2002 RH

18.12.2002 RH 18.12.2002 RH 18.12.2002 RH 23.12.2002 RH

New function implemented for accessing the peripherical area These functions are AGLReadPInBytes for reading from the peripherical input area and AGLWritePOutBytes for writing to the peripherical output area. Additional type (TYPE_PERIPHERIE) implemented for the functions AGLReadMix and AGLWriteMix, this enables the access to the

23.12.2002 RH

Page 220

Industrial PLC-Communication Suite peripherical areas. CAUTION: the use of the size constant SIZE_BIT is not supported in these cases and leads to an error code (PARA_ERR).

23.12.2002 RH 27.12.2002 RH

PB/NetLinkDRV support improved and function AGLInitAdapter for PB/NetLinkDRV optimized. New function implemented for returning the diagnostic buffer of a control (AGLReadDiagBuffer) and translation of the binary content in plain text (AGLReadDiagBufferEntry). Examples for Microsoft Office implemented. Change of installation because of size and number of DotNet-examples. Files that are used for all example programs (AGLink.DLL, AGLink_Config.EXE, AGLink_Error.TXT, AGLink_Error.ENG) are listed only in the directory AGLink_Redist. We recommend to copy these files in the Windows system directory or in the directory of the corresponding example. Please consider the notes in the DotNet subdirectory. Error during reading of timer and counter words corrected. Handling of initialization errors in the modules S7-MPI serial and S7-MPI serial/TS improved. Release 3.1 approved.

08.01.2003 HRe 09.01.2003 KB

10.01.2003 RH 18.01.2003 RH 20.01.2003 RH

Industrial PLC-Communication Suite

Seite 221

Page 222

Industrial PLC-Communication Suite

11 Appendix C
11.1 Software license agreement Terms and conditions for the software cession of individual user licenses version 2000-12-08
1.
1.1

Object of the contract


Object of the contract is the cession of computer programs (among others: source and object codes, byte codes, dynamic link libraries, shared libraries, static libraries, header files, executables), the manufacturer documentation, user manuals as well as all additional written or on-line documents with serves as explanation (product documentation). The following definitions are component of the object of the contract: a) Licenser is Deltalogic Automatisierungstechnik GmbH, located in 73557 Mutlangen, Germany. b) Licensee is the individual user of a license or the copy of a license. c) Software: source and object code, byte code, dynamic link libraries, shared libraries, static libraries, header files, executables, manufacturer documentation, user manuals as well as all additional written documents which serve the explanation (product documentation ) are called summarizing software . d) License: As license is the software defined which was purchased by the licensee. e) Software Application Programming Interface (API): As Software Application Programming Interface (API) is the software component defined - either delivered by the licenser or developed by the licensee - , that enables the access to the functionality of the license. As software components are defined: header files, executables for event services and network communication, macro- and/or scriptprogramming interfaces, components as COM or Java Beans and distributed components as CORBA, DCOM or Java RMI. f) Value-Added Interface: As Value-Added Interface is a programmatic interface defined which enables to use the functionality of the license direct or indirect via a Software Application Programming Interface. g) Software product: The application developed by the licensee making use of the license is as software product defined.

1.2

1.3

Object of the contract is the use of the license that is listed in the order confirmation and/or in the delivery note.

2.
2.1

License grants
For the contract duration the licenser gives the licensee the non-exclusive and non-transferable cash right to use the Software Application Programming Interface, inclusive of the functionality of one license on a single computer, summarizing called platform, and used by a single individual user. A use of the copy of a license by more or different persons is not permitted unless something else is particularly agreed in these terms and conditions. If multiple copies have been purchased the licensee is authorized to install the license on one computer. The licensee is entitled under consideration of section 2.1 to make the use of the license possible for the number of persons in accordance with the number of acquired copies of a license. For data saving and disaster-recovery purposes the licensee is also authorized to make (a) a backup copy of the license or (b) to transfer the license to a hard disk and to keep the original copy solely. Applying to the distribution of software products which have been created with Java libraries or libraries of the licenser: The licensee is entitled to distribute software products which have been developed with the license and are not appointed as software development tool, in this respect that the access to the functionality of the license by means of Software Application Programming Interface and Value-Added interface - direct and indirect- is not able.

2.2

2.3 2.4

Industrial PLC-Communication Suite 3.


3.1 3.2 3.3

Seite 223

License restrictions
The software is in the property of the licenser or his suppliers. It is on copyright, civil law and criminal protected and the licensee may use it only according to the available terms and conditions for licensees. The license is granted neither exclusive nor a transferable usufruct. The licensee is not entitled to the external distribution a) of any components of the Software Application Programming Interface b) of any components of the Value-Added interface and c) any executable delivered with the software unless other conditions are particularly agreed in these terms and conditions.

3.4

Furthermore the licensee is not authorized to: a) decompile, disassemble or reverse engineer any object code form of any part of the software b) rent or lend the software, c) disclose the source code of the software to any person or entity d) copy the product documentation including all on-line available documentation.

4.0
4.1

License protection duties


The licensee commits to prevent the unauthorized access of third parties to the software by suitable measures, to point out the retention of the terms and conditions on hand and the copyright to his employees firmly. The licensee will particularly ask his employees to make no unauthorized copies of the software. If an employee of the licensee or a third party violates the copyright on the left software, the licensee is obliged to do his best to assist the clearing up of the copyright injury and advise the licenser about the corresponding injury action particularly immediately. This is also necessary when the licensee has violated the copyright by an own action. The licenser can carry out an audit at the licensee based on a well-founded opportunity to convince him of the use of the license in accordance with these terms and conditions. At termination of the contract relationship the licensee is obliged to the return or destruction of all original data mediums and the product documentation as well as possible copies. Place of performance for the return is the respective residence of the licenser.

4.2

4.3 4.4

5.0
5.1

Limited warranty
It is pointed out that it is not possible for the current developments in technology to develop computer software that works error-free in all conceivable combinations and applications. Object of the contract and object of the warranty is therefore a in principle useable software according to the product documentation. The software requires the application by a software programmer with experience in the application of development tools and class libraries. The software isn't designed to the application of laymen like private consumers or for the private domestic use. The licenser ensures that the after delivery unchanged software under normal operating conditions and normal maintenance fulfils all functions essentially which arise from the product documentation. The warranty period starts with delivery and is 6 months. Defects have to be immediately announced to the licenser in writing and described in detail. At first the warranty right is restricted to improvement. After this the licenser makes all reasonable efforts for the remedying of considerable, proved and lasting defects of the unchanged software. If the defect isn't cleared by the licenser within an adequate time period by improvement or by substitute delivery, then the licensee can reduce the license fee adequately or demand redhibition of the contract. In the case of a substitute delivery or the redhibition of the contract the scheduled obligations of the licensee in paragraphs 2, 3 and 4 remain valid. The licensee can agree on further-reaching maintenance and help performances at the use of the left software on the basis of a maintenance agreement to be compensated separately on the respectively applicable maintenance terms of the licenser. If the licensee has used improvement although there was not a defect then he has to compensate adequately the service of the licenser for the check of the facts.

5.2 5.3 5.4 5.5 5.6

5.7

5.8

Page 224 6.0


6.1

Industrial PLC-Communication Suite

Liability of the licenser


The licenser is liable independently of the legal justification for damages that were caused by culpable injury of an essential contractual duty to be represented by him in a way endangering reaching the contract purpose liable. The liability is restricted to the contract typical damage that the licenser had to calculate at completion of a contract due to the circumstances confessed at this time for him. A liability for lost profit, ceased savings, indirect damages and resultant damages is excluded. The liability for loss of data is excluded. The licensee is obliged to make corresponding backup copies. The mentioned limitations of liability don't apply to damages based on firm intention, gross negligence or the lack of assured qualities or for possible claims due to the product liability law. There is an assurance of qualities only when it was particularly and in writing explained to the respective licensee by a representative who is authorized to give of such assurances particularly and in writing by the licenser opposite.

6.2 6.3

7.0
7.1 7.2

Contract duration, cancellation and license fee


The license is granted on the basis of single charges on a permanent time period unless the licenser and the licensee have agreed on something else particularly and in writing. The licenser can terminate the contract relationship in liberal estimation with monthly period if the licensee has violated the terms and conditions. The right to cancellation without notice for important reasons remains untouched. The licensee can terminate the contract relationship with an immediate effect any time when he stops the use of the software simultaneously and returns it as well as destroys possible copies to the licenser. The termination of contract doesn't touch the obligations of the licensee according paragraphs 2., 3. and 4.. When the contract is terminated , there is no refund of the license fee charges.

7.3 7.4 7.5

8.0
8.1 8.2

Miscellaneous
Place of performance is the respective residence of the licenser. Supplementary agreements or contract changes and additions require the in writing. The terms and conditions regulated here are more important than contrary conditions which can appear at the call of the software over display. Other general terms and Conditions, particularly those of the licensee do not become contract contents even when the licenser doesn't contradict particularly. Place of jurisdiction is Schwbisch Gmnd provided that the licensee is full merchant. This contract is subject to the right of the Federal Republic of Germany. If a regulation of these terms and conditions should be trivial, ineffective or impracticable, then this does not touch the effectiveness of the contract in the whole. The legal regulation takes the place of the trivial, ineffective or impracticable determination that corresponds the most to the intended.

8.3 8.4 8.4

Vous aimerez peut-être aussi