TwinCat 的API函数
更新时间:2023-10-07 10:38:01 阅读量: 综合文库 文档下载
- twincat推荐度:
- 相关推荐
AdsGetDllVersion
Returns the version number, revision number and build number of the ADS-DLL.
LONG AdsGetDllVersion( void );
Parameter
-
Return value
The return value, which is of type long, contains in coded form these three items related to the ADS-DLL.
AdsPortOpen
Establishes a connection (communication port) to the TwinCAT message router.
LONG AdsPortOpen( void );
Parameter
-
Return value
A port number that has been assigned to the program by the ADS router is returned.
AdsPortClose
The connection (communication port) to the TwinCAT message router is closed.
LONG AdsPortClose( void );
Parameter
-
Return value
Returns the function's error status.
AdsGetLocalAddress
Returns the local NetId and port number.
LONG AdsGetLocalAddress( PAmsAddr pAddr );
Parameter
pAddr
[out] Pointer to the structure of type AmsAddr.
Return value
Returns the function's error status.
AdsSyncWriteReq
Writes data synchronously to an ADS device.
LONG AdsSyncWriteReq( PAmsAddr pAddr, ULONG nIndexGroup, ULONG nIndexOffset, ULONG nLength, PVOID pData );
Parameter
pAddr
[in] Structure with NetId and port number of the ADS server. nIndexGroup [in] Index Group. nIndexOffset [in] Index Offset. nLength
[in] Length of the data, in bytes, written to the ADS server. pData
[in] Pointer to the data written to the ADS server.
Return value
Returns the function's error status.
AdsSyncReadReq
Reads data synchronously from an ADS server.
LONG AdsSyncReadReq( PAmsAddr pAddr, ULONG nIndexGroup, ULONG nIndexOffset, ULONG nLength, PVOID pData );
Parameter
pAddr
[in] Structure with NetId and port number of the ADS server. nIndexGroup [in] Index Group. nIndexOffset [in] Index Offset. nLength
[in] Length of the data in bytes. pData
[out] Pointer to a data buffer that will receive the data.
Return value
Returns the function's error status.
AdsSyncReadReqEx
Reads data synchronously from an ADS server.
LONG AdsSyncReadReq( PAmsAddr pAddr, ULONG nIndexGroup, ULONG nIndexOffset, ULONG nLength, PVOID pData, ULONG* pcbReturn );
Parameter
pAddr
[in] Structure with NetId and port number of the ADS server. nIndexGroup [in] Index Group. nIndexOffset [in] Index Offset. nLength
[in] Length of the data in bytes. pData
[out] Pointer to a data buffer that will receive the data. pcbReturn
[out] Pointer to a variable. This variable returns the number of succesfully read data bytes.
Return value
Returns the function's error status.
AdsSyncReadWriteReq
Writes data synchronously into an ADS server and receives data back from the ADS device.
LONG AdsSyncReadWriteReq( PAmsAddr pAddr, ULONG nIndexGroup, ULONG nIndexOffset, ULONG nReadLength, PVOID pReadData, ULONG nWriteLength, PVOID pWriteData );
Parameter
pAddr
[in] Structure with NetId and port number of the ADS server. nIndexGroup [in] Index Group. nIndexOffset [in] Index Offset. nReadLength
[in] Length of the data, in bytes, returned by the ADS device. pReadData
[out] Buffer with data returned by the ADS device. nWriteLength
[in] Length of the data, in bytes, written to the ADS device. pWriteData
[out] Buffer with data written to the ADS device.
Return value
Returns the function's error status.
AdsSyncReadWriteReqEx
Writes data synchronously into an ADS server and receives data back from the ADS device.
LONG AdsSyncReadWriteReq( PAmsAddr pAddr, ULONG nIndexGroup, ULONG nIndexOffset, ULONG nReadLength, PVOID pReadData, ULONG nWriteLength, PVOID pWriteData, ULONG* pcbReturn );
Parameter
pAddr
[in] Structure with NetId and port number of the ADS server. nIndexGroup [in] Index Group. nIndexOffset [in] Index Offset. nReadLength
[in] Length of the data, in bytes, returned by the ADS device. pReadData
[out] Buffer with data returned by the ADS device. nWriteLength
[in] Length of the data, in bytes, written to the ADS device. pWriteData
[out] Buffer with data written to the ADS device. pcbReturn
[out] Pointer to a variable. This variable returns the number of succesfully read data bytes.
AdsSyncReadDeviceInfoReq
Reads the identification and version number of an ADS server.
LONG AdsSyncReadDeviceInfoReq( PAmsAddr pAddr, PCHAR pDevName,
PAdsVersion pVersion );
Parameter
pAddr
[in] Structure with NetId and port number of the ADS server. pDevName
[out] Pointer to a character string that will receive the name of the ADS device. pVersion
[out] Address of a variable of type AdsVersion, which will receive the version number, revision number and the build number.
Return value
Returns the function's error status.
AdsSyncWriteControlReq
Changes the ADS status and the device status of an ADS server.
LONG AdsSyncWriteControlReq( PAmsAddr pAddr, USHORT nAdsState, USHORT nDeviceState, ULONG nLength, PVOID pData );
Parameter
pAddr
[in] Structure with NetId and port number of the ADS server. nAdsState
[in] New ADS status. nDeviceState
[in] New device status. nLength
[in] Length of the data in bytes. pData
[in] Pointer to data sent additionally to the ADS device.
Return value
Returns the function's error status.
Comments
In addition to changing the ADS status and the device status, it is also possible to send data to the ADS server in order to transfer further information. In the current ADS devices (PLC, NC, ...) this data has no further effect. Any ADS device can inform another ADS device of its current state. A distinction is drawn here between the status of the device itself (DeviceState) and the status of the ADS interface of the ADS device (AdsState). The states that the ADS interface can adopt are laid down in the ADS specification.
AdsSyncReadStateReq
Reads the ADS status and the device status from an ADS server.
LONG AdsSyncReadStateReq( PAmsAddr pAddr, USHORT *pAdsState, PUSHORT pDeviceState );
Parameter
pAddr
[in] Structure with NetId and port number of the ADS server. pAdsState
[out] Address of a variable that will receive the ADS status (see data type ADSSTATE). pDeviceState
[out] Address of a variable that will receive the device status.
Return value
Returns the function's error status.
Remarks
Any ADS device can inform another ADS device of its current state. A distinction is drawn here between the status of the device itself (DeviceState) and the status of the ADS interface of the ADS device (AdsState). The states that the ADS interface can adopt are laid down in the ADS specification.
AdsSyncAddDeviceNotificationReq
A notification is defined within an ADS server (e.g. PLC). When a certain event occurs a function (the callback function) is invoked in the ADS client (C program).
LONG AdsSyncAddDeviceNotificationReq( PAmsAddr pAddr, ULONG nIndexGroup, ULONG nIndexOffset, PAdsNotificationAttrib pNoteAttrib, PAdsNotificationFuncEx pNoteFunc, ULONG hUser, PULONG pNotification );
Parameter
pAddr
[in] Structure with NetId and port number of the ADS server. nIndexGroup [in] IndexGroup. nIndexOffset [in] IndexOffset. pNoteAttrib
[in] Pointer to the structure that contains further information. pNoteFunc
[in] Name of the callback function. hUser
[in] 32-bit value that is passed to the callback function. pNotification
[out] Address of the variable that will receive the handle of the notification.
Return value
Returns the function's error status.
Limitation:
Per ADS-Port a limitted number of 550 notifications are available.
AdsSyncDelDeviceNotificationReq
A notification defined previously is deleted from an ADS server.
LONG AdsSyncDelDeviceNotificationReq( PAmsAddr pAddr, ULONG hNotification );
Parameter
pAddr
[in] Structure with NetId and port number of the ADS server. hNotification
[out] Address of the variable that contains the handle of the notification.
Return value
Returns the function's error status.
AdsSyncSetTimeout
Alters the timeout for the ADS functions. The standard value is 5000 ms.
LONG AdsSyncSetTimeout( LONG nMs, );
Parameter
nMs
[in] Timeout in ms.
Return value
Returns the function's error status.
AdsAmsRegisterRouterNotification
The AdsAmsRegisterNotificationReq() function can be used to detect a change in the status of the TwinCAT router. The given callback function is invoked each time the status changes. Monitoring of the router's status is ended once more by the AdsAmsUnRegisterNotification() function.
LONG AdsAmsRegisterRouterNotification(
PAmsRouterNotificationFuncEx pNoteFunc );
Parameter
pNoteFunc
[in] Name of the callback function
Return value
Returns the function's error status. Hints:
? Implemented from TcAdsDLL File Version: 2.8.0.21 ( delivered with TwinCAT 2.9 Build > 941). ? A connection to the TwinCAT-Router can be done, if TwinCAT has been installed on the local
PC. The function delivers an error on a system without TwinCAT.
AdsAmsUnRegisterRouterNotification
Monitoring the router's status is ended by the AdsAmsUnRegisterNotification() function. See also AdsAmsRegisterNotificationReq().
LONG AdsAmsUnRegisterRouterNotification( void );
Parameter
-
Return value
Returns the function's error status. Hints:
? Implemented from TcAdsDLL File Version: 2.8.0.21 ( delivered with TwinCAT 2.9 Build > 941). ? A connection to the TwinCAT-Router can be done, if TwinCAT has been installed on the local
PC. The function delivers an error on a system without TwinCAT.
PAmsRouterNotificationFuncEx
Type definition of the callback function required by the AdsAmsRegisterRouterNotification function.
typedef void ( __stdcall *PAmsRouterNotificationFuncEx)( long nEvent );
PAdsNotificationFuncEx
Type definition of the callback function required by the AdsSyncAddDeviceNotificationReq function.
typedef void (__stdcall *PAdsNotificationFuncEx)(AmsAddr* pAddr, AdsNotificationHeader* pNotification, unsigned long hUser );
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
AdsPortOpenEx
Establishes a connection (communication port) to the TwinCAT message router. Unlike with
AdsPortOpen, a new ADS port is opened each time. The extended Ads functions have to be used for communicating with this port. The port number returned by AdsPortOpenEx is transferred as parameter to these functions. If no TwinCAT MessageRouter is present, the AdsPortOpenEx function will fail.
LONG AdsPortOpenEx( void );
Parameters
-
Return value
Port number of the opened Ads port. A return value of 0 means the call has failed.
AdsPortCloseEx
The connection (communication port) to the TwinCAT message router is closed. The port to be closed must previously have been opened via an AdsPortOpenEx call.
LONG AdsPortCloseEx( long nPort );
Parameters
port
[in] port number of an Ads port that had previously been opened with AdsPortOpenEx.
Return value
Returns the function's error status.
AdsGetLocalAddressEx
Returns the local NetId and port number.
LONG AdsGetLocalAddressEx( long port PAmsAddr pAddr );
Parameters
port
[in] port number of an Ads port that had previously been opened with AdsPortOpenEx or AdsPortOpen. pAddr
[out] Pointer to the structure of type AmsAddr.
Return value
Returns the function's error status.
AdsSyncWriteReqEx
Writes data synchronously to an ADS device.
LONG AdsSyncWriteReqEx( LONG port, PAmsAddr pAddr, ULONG nIndexGroup, ULONG nIndexOffset, ULONG nLength, PVOID pData );
Parameters
port
[in] port number of an Ads port that had previously been opened with AdsPortOpenEx or AdsPortOpen. pAddr
[in] Structure with NetId and port number of the ADS server. nIndexGroup [in] Index Group. nIndexOffset [in] Index Offset.
nLength
[in] Length of the data, in bytes, written to the ADS server. pData
[in] Pointer to the data written to the ADS server.
Return value
Returns the function's error status.
AdsSyncReadReqEx2
Reads data synchronously from an ADS server.
LONG AdsSyncReadReqEx2( LONG port, PAmsAddr pAddr, ULONG nIndexGroup, ULONG nIndexOffset, ULONG nLength, PVOID pData, ULONG* pcbReturn );
Parameters
port
[in] port number of an Ads port that had previously been opened with AdsPortOpenEx or AdsPortOpen. pAddr
[in] Structure with NetId and port number of the ADS server. nIndexGroup [in] Index Group. nIndexOffset [in] Index Offset. nLength
[in] Length of the data in bytes. pData
[out] Pointer to a data buffer that will receive the data. pcbReturn
[out] pointer to a variable. If successful, this variable will return the number of actually read data bytes.
AdsSyncReadWriteReqEx2
Writes data synchronously into an ADS server and receives data back from the ADS device.
LONG AdsSyncReadWriteReqEx2( LONG port, PAmsAddr pAddr, ULONG nIndexGroup, ULONG nIndexOffset, ULONG nReadLength, PVOID pReadData, ULONG nWriteLength, PVOID pWriteData, ULONG* pcbReturn );
Parameters
port
[in] port number of an Ads port that had previously been opened with AdsPortOpenEx or AdsPortOpen. pAddr
[in] Structure with NetId and port number of the ADS server. nIndexGroup [in] Index Group. nIndexOffset [in] Index Offset. nReadLength
[in] Length of the data, in bytes, returned by the ADS device. pReadData
[out] Buffer with data returned by the ADS device. nWriteLength
[in] Length of the data, in bytes, written to the ADS device. pWriteData
[out] Buffer with data written to the ADS device. pcbReturn
[out] pointer to a variable. If successful, this variable will return the number of actually read data bytes.
AdsSyncReadDeviceInfoReqEx
Reads the identification and version number of an ADS server.
正在阅读:
TwinCat 的API函数10-07
在职研究生公共管理讲义11-22
《深刻领会习主席关于党和法高度统一关系的重要论述》下83.75分09-21
北师大版七下《父亲的退休生活》教案04-29
安徽大学计算机基础B作业11-02
纳税服务规范测试题二(有答案)12-05
第九讲图形的变换09-23
注册会计师考试《税法》预习:税务管理每日一练(2014.11.18)05-10
柴油铲运机安全操作规程示范文本03-20
- 多层物业服务方案
- (审判实务)习惯法与少数民族地区民间纠纷解决问题(孙 潋)
- 人教版新课标六年级下册语文全册教案
- 词语打卡
- photoshop实习报告
- 钢结构设计原理综合测试2
- 2014年期末练习题
- 高中数学中的逆向思维解题方法探讨
- 名师原创 全国通用2014-2015学年高二寒假作业 政治(一)Word版
- 北航《建筑结构检测鉴定与加固》在线作业三
- XX县卫生监督所工程建设项目可行性研究报告
- 小学四年级观察作文经典评语
- 浅谈110KV变电站电气一次设计-程泉焱(1)
- 安全员考试题库
- 国家电网公司变电运维管理规定(试行)
- 义务教育课程标准稿征求意见提纲
- 教学秘书面试技巧
- 钢结构工程施工组织设计
- 水利工程概论论文
- 09届九年级数学第四次模拟试卷
- 函数
- TwinCat
- API
- 安全保卫考试试题1
- 北航操作系统答案作业4
- 湖大硕士研究生入学考试中级财务会计j考题分析
- 《猪病学》网上作业与课程考试复习资料(全)
- 石家庄铁道大学 第二十九届运动会代表队报名册
- 2014-2015-1微观经济学A卷
- 中国平安并购深发展案例分析
- 最新SI.SIR.SIS 模型资料
- 党支部在基层组织建设年活动中存在的问题及整改措施
- unit 12 第一课时导学案
- 工程力学试题
- 人教版二年级下册语文第七单元一学四管五法导学案
- 电视专题片笔记以及影片分析
- 东莞市主城区城市发展战略规划研究 - 图文
- 聋部五年级自然常识第六册教案
- 国际酒店集团管理期末试卷及答案
- 机电单片机课程设计 4乘4矩阵键盘 汇编语言 - 图文
- 中国移动TD-LTE无线参数设置指导优化手册-华为分册 - 图文
- 楼梯练习题
- 2018新部编本二年级下册语文二下语文第一单元教案 - 图文