回复:opc、kepserver、c#写的上位机程序

lf184452

  • 帖子

    449
  • 精华

    6
  • 被关注

    17

论坛等级:侠圣

注册时间:2015-01-29

普通 普通 如何晋级?

发布于 2018-11-23 21:51:17

4楼

 PRODAVE 就行

以前做的VB.NET封装

    Public Const TYPE_BYTE As Byte = 2
    Public Const TYPE_WORD As Byte = 4
    Public Const TYPE_DWORD As Byte = 6

    Public Const BKTYPE_OB As UInt16 = &H8
    Public Const BKTYPE_DB As UInt16 = &HA
    Public Const BKTYPE_FC As UInt16 = &HC
    Public Const BKTYPE_FB As UInt16 = &HE

    '连接S7PLC的函数声明,成功返回0,失败返回错误代码
    'ConNr:连接号,0-64;
    'AccessPoint:连接点,应为"S7ONLINE";
    'ConTableLen:连接表大小,应为9;
    'pConTable:指向连接表的首个元素的地址;
    '          0-3:IP地址;
    '          6:地址类型,=2为IP地址;
    '          7:PLC槽号;
    '          8:PLC机架号;
    Public Declare Function LoadConnection_ex6 Lib "Prodave6.dll" (ByVal ConNr As UInt16, _
                                                                   ByVal AccessPoint As String, _
                                                                   ByVal ConTableLen As UInt16, _
                                                                   ByRef pConTable As Byte) As UInt32

    '关闭S7PLC连接的函数,成功返回0,失败返回错误代码
    'ConNr:已打开的连接号,0-64;
    Public Declare Function UnloadConnection_ex6 Lib "Prodave6.dll" (ByVal ConNr As UInt32) As UInt32

    '读S7PLC DB块的函数,成功返回0,失败返回错误代码
    'blknr:DB块号;
    'DatType:读类型,=2为BYTE,=4为WORD,=6为DWORD;
    'StartNr:读的起始地址;
    'Amount:总共要读的数量;
    'BufLen:缓冲区大小;
    'pBuchBuffer:指向缓冲区首地址;
    'pDatLen:实际读出的数据大小
    Public Declare Function db_read_ex6 Lib "Prodave6.dll" (ByVal blknr As UInt16, _
                                                            ByVal DatType As Byte, _
                                                            ByVal StartNr As UInt16, _
                                                            ByRef Amount As UInt32, _
                                                            ByVal BufLen As UInt32, _
                                                            ByRef pBuchBuffer As Byte, _
                                                            ByRef pDatLen As UInt32) As UInt32

    '写S7PLC DB块的函数,成功返回0,失败返回错误代码
    'blknr:DB块号;
    'DatType:读类型,=2为BYTE,=4为WORD,=6为DWORD;
    'StartNr:读的起始地址;
    'Amount:总共要读的数量;
    'BufLen:缓冲区大小;
    'pBuchBuffer:指向缓冲区首地址;
    Public Declare Function db_write_ex6 Lib "Prodave6.dll" (ByVal blknr As UInt16, _
                                                             ByVal DatType As Byte, _
                                                             ByVal StartNr As UInt16, _
                                                             ByRef Amount As UInt32, _
                                                             ByVal BufLen As UInt32, _
                                                             ByRef pWriteBuffer As Byte) As UInt32

    '读S7PLC块信息的函数,成功返回0,失败返回错误代码;
    'blkType:块类型,=0x8 OB块,=0xA DB块, =0xC FC块, =0xE FB块;
    'BufLen:缓冲区长度;
    'pReadBuffer:指向缓冲区,具体信息细节参见PRODAVE手册
    'pDatLen:实际读出的数据大小;
    Declare Function bst_read_ex6 Lib "Prodave6.dll" (ByVal blkType As UInt16, _
                                                      ByVal blknr As UInt16, _
                                                      ByVal BufLen As UInt32, _
                                                      ByRef pReadBuffer As Byte, _
                                                      ByRef pDatLen As UInt32) As UInt32


    '读S7PLC所有块信息的函数,成功返回0,失败返回错误代码
    'blkType:块类型,=0x8 OB块,=0xA DB块, =0xC FC块, =0xE FB块;
    ''BufLen:缓冲区长度;
    'pReadBuffer:指向缓冲区,每块大小96字节
    '            0-1:指出该块的类型
    '            2-3:指出该块号
    '            其余的参见PRODAVE手册;
    'pDatLen:实际读出的数据大小;
    Declare Function bst_read_stat_ex6 Lib "Prodave6.dll" (ByVal blkType As UInt32, _
                                                           ByVal BufLen As UInt32, _
                                                           ByRef pStatBuffer As Byte, _
                                                           ByRef pDatLen As UInt32) As UInt32


更多的功能函数参见PRODAVE手册。

 

评论
编辑推荐: 关闭

请填写推广理由:

本版热门话题

SIMATIC S7-300/400

共有54616条技术帖

相关推荐

热门标签

相关帖子推荐

guzhang

恭喜,你发布的帖子

评为精华帖!

快扫描右侧二维码晒一晒吧!

再发帖或跟帖交流2条,就能晋升VIP啦!开启更多专属权限!

  • 分享

  • 只看
    楼主

top
您收到0封站内信:
×
×
信息提示
很抱歉!您所访问的页面不存在,或网址发生了变化,请稍后再试。