⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dcon_pc.bas

📁 通过vb与鸿格7000系列模块进行通讯
💻 BAS
📖 第 1 页 / 共 2 页
字号:
Attribute VB_Name = "Lib"
 Option Explicit
'------------------------ Error Message ------------------
Global Const NoError = 0
Global Const FunctionError = 1
Global Const PortError = 2
Global Const BaudRateError = 3
Global Const DataError = 4
Global Const StopError = 5
Global Const ParityError = 6
Global Const CheckSumError = 7
Global Const ComPortNotOpen = 8
Global Const SendThreadCreateError = 9
Global Const SendCmdError = 10
Global Const ReadComStatusError = 11
Global Const ResultStrCheckError = 12
Global Const CmdError = 13
Global Const TimeOut = 15
Global Const ModuleIdError = 17
Global Const AdChannelError = 18
Global Const UnderInputRange = 19
Global Const ExceedInputRange = 20
Global Const InvalidateCounterNo = 21
Global Const InvalidateCounterValue = 22

'----------------------  UART.DLL -----------------------------------------------
Declare Function Get_Uart_Version Lib "uart.dll" () As Integer

Declare Function Open_Com Lib "uart.dll" (ByVal port As Integer, ByVal BaudRate As Long, ByVal cData As Byte, ByVal cParity As Byte, ByVal cStop As Byte) As Integer

Declare Function Change_Baudrate Lib "uart.dll" (ByVal port As Integer, ByVal lBaudrate As Long) As Integer

Declare Function Change_Config Lib "uart.dll" (ByVal port As Integer, ByVal BaudRate As Long, ByVal cData As Byte, ByVal cParity As Byte, ByVal cStop As Byte) As Integer

Declare Function Get_Com_Status Lib "uart.dll" (ByVal port As Integer) As Integer

Declare Function Close_Com Lib "uart.dll" (ByVal port As Integer) As Boolean

Declare Function Send_Binary Lib "uart.dll" (ByVal port As Integer, ByRef szBuf As Byte, ByVal length As Integer) As Integer

Declare Function Receive_Binary Lib "uart.dll" (ByVal port As Integer, ByRef szResult As Byte, ByVal TimeOut As Integer, ByVal length As Integer, wT As Integer) As Integer
        
'Receive_Binary(unsigned char cPort, char szResult[], WORD wTimeOut, WORD wLen, WORD *wT)

Declare Function Send_Cmd Lib "uart.dll" (ByVal port As Integer, ByVal Cmd As String, ByVal wChkSum As Integer) As Integer

Declare Function Receive_Cmd Lib "uart.dll" (ByVal port As Integer, ByVal szResult As String, ByVal TimeOut As Integer, ByVal Checksum As Integer, wT As Integer) As Integer


Declare Function Send_Receive_Cmd Lib "uart.dll" (ByVal port As Integer, ByVal szCmd As String, ByVal szResult As String, ByVal TimeOut As Integer, ByVal Checksum As Integer, wT As Integer) As Integer

'----------------------------DCONPC.DLL-------------------------------------------
Declare Function DCON_Write_DO Lib "DCON_PC.dll" (ByVal cComPort As Byte, ByVal iAddress As Integer, _
    ByVal iSlot As Integer, ByVal iDO_TotalCh As Integer, ByVal lDO_Value As Long, _
    ByVal iCheckSum As Integer, ByVal iTimeOut As Integer) As Integer
'/****************************************************************************
'    iComPort: 1 ~ 255
'    iAddress: 0 ~ 255: the RS-485 Address of module
'    iSlot: 0~7: for 8K and 87K series on i-8000 system
'            -1: 7K and 87K (on 87K IO Expansion bus)
'    iDO_TotalCh: 1~32. total DO channels
'    lDO_Value: DO value.
'                for example: 0x32==> ch5=1, ch4=1, ch1=1,
'                                     others are 0.
'    iCheckSum: 0: disabled
'1:                Enabled
'    iTimeOut: timeout value to wait response. unit= ms.
'
'    return: 0 = No Error
'            other = error code.
'****************************************************************************/

Declare Function DCON_Write_DO_Bit Lib "DCON_PC.dll" (ByVal cComPort As Byte, ByVal iAddress As Integer, _
        ByVal iSlot As Integer, ByVal iChannel As Integer, ByVal iDO_TotalCh As Integer, _
        ByVal iBitValue As Integer, ByVal iCheckSum As Integer, ByVal iTimeOut As Integer) As Integer
'/***********************************************************************
'    iComPort: 1 ~ 255
'    iAddress: 0 ~ 255: the RS-485 Address of module
'    iSlot: 0~7: for 8K and 87K series on i-8000 system
'            -1: 7K and 87K (on 87K IO Expansion bus)0
'    iChannel: 0~31
'    iDO_TotalCh: 1~32, Total DO channels
'    iBitValue: 0   = Off
'               <>0 = On
'    iCheckSum: 0: disabled
'1:                Enabled
'    iTimeOut: timeout value to wait response. unit= ms.
'
'    return: 0 = No Error
'            other = error code.
'*************************************************************************/

Declare Function DCON_Read_DI_Counter Lib "DCON_PC.dll" (ByVal cComPort As Byte, ByVal iAddress As Integer, _
        ByVal iSlot As Integer, ByVal iChannel As Integer, ByVal iDI_TotalCh As Integer, ByVal iCheckSum As Integer, _
        ByVal iTimeOut As Integer, ByRef lCounter_Value As Long) As Integer
'/*******************************************************************
'    iComPort: 1 ~ 255
'    iAddress: 0 ~ 255: the RS-485 Address of module
'    iSlot: 0~7: for 87K series on i-8000 system
'            -1: 7K and 87K (on 87K IO Expansion bus)
'    iChannel: 0~15
'    iCheckSum: 0: disabled
'1:                Enabled
'    iTimeOut: timeout value to wait response. unit= ms.
'    *lCounter_Value: counter value.
'
'    return: 0 = No Error
'            other = error code.
'**********************************************************************/

Declare Function DCON_Clear_DI_Counter Lib "DCON_PC.dll" (ByVal cComPort As Byte, ByVal iAddress As Integer, _
        ByVal iSlot As Integer, ByVal iChannel As Integer, ByVal iDI_TotalCh As Integer, _
        ByVal iCheckSum As Integer, ByVal iTimeOut As Integer) As Integer
'/******************************************************************
'iComPort: 1 ~ 255
'iAddress: 0 ~ 255: the RS-485 Address of module
'iSlot: 0~7: for 8K and 87K series on i-8000 system
'        -1: 7K and 87K (on 87K IO Expansion bus)
'iChannel: 0~15
'iDI_TotalCh: 1~32. total DI channels
'iCheckSum: 0: disabled
'1:            Enabled
'iTimeOut: timeout value to wait response. unit= ms.
'
'return: 0 = No Error
'        other = error code.
'******************************************************************/

Declare Function DCON_Write_AO Lib "DCON_PC.dll" (ByVal cComPort As Byte, ByVal iAddress As Integer, _
        ByVal iSlot As Integer, ByVal iChannel As Integer, ByVal iAO_TotalCh As Integer, _
        ByVal fValue As Single, ByVal iCheckSum As Integer, ByVal iTimeOut As Integer) As Integer
'/***************************************************************************
'    iComPort: 1 ~ 255
'    iAddress: 0 ~ 255: the RS-485 Address of module
'    iSlot: 0~7: for 8K and 87K series on i-8000 system
'            -1: 7K and 87K (on 87K IO Expansion bus)
'    iChannel: 0~3
'    iAO_TotalCh: 1~4. total AO channels
'fValue:     AO Value
'    iCheckSum: 0: disabled
'1:                Enabled
'    iTimeOut: timeout value to wait response. unit= ms.
'
'    return: 0 = No Error
'            other = error code.
'*****************************************************************************/

Declare Function DCON_Read_AO Lib "DCON_PC.dll" (ByVal cComPort As Byte, ByVal iAddress As Integer, _
        ByVal iSlot As Integer, ByVal iChannel As Integer, ByVal iAO_TotalCh As Integer, _
        ByVal iCheckSum As Integer, ByVal iTimeOut As Integer, ByRef fValue As Single) As Integer
'/***********************************************************************************
'   iComPort: 1 ~ 255
'   iAddress: 0 ~ 255: the RS-485 Address of module
'   iSlot: 0~7: for 8K and 87K series on i-8000 system
'           -1: 7K and 87K (on 87K IO Expansion bus)
'   iAO_TotalCh: 1~4. total AO channels,used to define command and response
'
'   iCheckSum: 0: disabled
'1:               Enabled
'   iTimeOut: timeout value to wait response. unit= ms.
'
'   iDataFormat: 0: Engineering format
'1:                  Percent Format
'2:                  Hex Format
'
'iValue:    Hex Format
'fValue:    Float Format
'
'   return: 0 = No Error
'           15= timeout (No response)
'
'
'    Note: user can readback AO output in either float value or hex format ,
'          according to the data format of module.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -