书签 分享 收藏 举报 版权申诉 / 7
上传文档赚钱

类型大学精品课件:VB接口方法举例.doc

  • 上传人(卖家):金钥匙文档
  • 文档编号:428590
  • 上传时间:2020-04-03
  • 格式:DOC
  • 页数:7
  • 大小:109.50KB
  • 【下载声明】
    1. 本站全部试题类文档,若标题没写含答案,则无答案;标题注明含答案的文档,主观题也可能无答案。请谨慎下单,一旦售出,不予退换。
    2. 本站全部PPT文档均不含视频和音频,PPT中出现的音频或视频标识(或文字)仅表示流程,实际无音频或视频文件。请谨慎下单,一旦售出,不予退换。
    3. 本页资料《大学精品课件:VB接口方法举例.doc》由用户(金钥匙文档)主动上传,其收益全归该用户。163文库仅提供信息存储空间,仅对该用户上传内容的表现方式做保护处理,对上传内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知163文库(点击联系客服),我们立即给予删除!
    4. 请根据预览情况,自愿下载本文。本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
    5. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007及以上版本和PDF阅读器,压缩文件请下载最新的WinRAR软件解压。
    配套讲稿:

    如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。

    特殊限制:

    部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。

    关 键  词:
    大学 精品 课件 VB 接口 方法 举例
    资源描述:

    1、11.211.2 VBVB 接口方法举例接口方法举例 参照提供的 VB 程序源码,在Product_PCI6011 Samples SourceVB6011 用户编程时,在程序中包含接口说明文件 PCI6011.BAS。在其中定义了 VB 调用 的接口,说明如下: AD 控制接口数据结构说明 Public Type AD6011_WINCTRL_STRUCT m_ADType As Integer m_StartType As Integer m_StartChn As Integer m_EndChn As Integer m_IETFlag As Integer m_Timer0Val A

    2、s Integer m_Timer1Val As Integer m_Timer2Val As Integer m_ClkSrc As Integer m_BufferBlock As Integer m_TransFlag As Byte m_hWnd As Long End Type API 接口函数说明 Public Declare Function Pci6011_IsOpen Lib “PCI6011dll.dll“ _ (ByVal mDev As Long) As Boolean Public Declare Function Pci6011_Open Lib “PCI6011d

    3、ll.dll“ _ (ByVal mDev As Long) As Boolean Public Declare Function Pci6011_Close Lib “PCI6011dll.dll“ _ (ByVal mDev As Long) As Boolean Public Declare Function Pci6011_GetVersion Lib “PCI6011dll.dll“ _ (ByVal mDev As Long, ByVal sVersion As String) As Boolean Public Declare Function Pci6011_WriteIO L

    4、ib “PCI6011dll.dll“ _ (ByVal mDev As Long, ByVal mVal As Integer) As Boolean Public Declare Function Pci6011_ReadIO Lib “PCI6011dll.dll“ _ (ByVal mDev As Long, ByRef mVal As Integer) As Boolean Public Declare Function Pci6011_InitTimer2 Lib “PCI6011dll.dll“ _ (ByVal mDev As Long, ByVal mType As Inte

    5、ger, ByVal mVal As Integer, _ ByVal mIntFlag As Boolean, ByVal mWnd As Long) As Boolean Public Declare Function Pci6011_StartTimer2 Lib “PCI6011dll.dll“ _ (ByVal mDev As Long) As Boolean Public Declare Function Pci6011_ReadTimer2 Lib “PCI6011dll.dll“ _ (ByVal mDev As Long, ByRef mVal As Integer) As

    6、Boolean Public Declare Function Pci6011_StopTimer2 Lib “PCI6011dll.dll“ _ (ByVal mDev As Long) As Boolean Public Declare Function Pci6011_SoftADSetChn Lib “PCI6011dll.dll“ _ (ByVal mDev As Long, ByVal mChn As Long) As Boolean Public Declare Function Pci6011_SoftADStart Lib “PCI6011dll.dll“ _ (ByVal

    7、mDev As Long) As Boolean Public Declare Function Pci6011_SoftADRead Lib “PCI6011dll.dll“ _ (ByVal mDev As Long, ByRef mVal As Integer) As Boolean Public Declare Function Pci6011_SoftADGetVal Lib “PCI6011dll.dll“ _ (ByVal mDev As Long, ByVal mChn As Long, ByRef mVal As Integer) As Boolean public Decl

    8、are Function Pci6011_ADCtrlEx Lib “PCI6011dll.dll“ _ (ByVal mDev As Long, ByRef pCtrlStru As AD6011_CTRL_STRUCT)As Boolean public Declare Function Pci6011_ADCtrl Lib “PCI6011dll.dll“ _ (ByVal mDev As Long,ByRef pCtrlStru As AD6011_WINCTRL_STRUCT)As Boolean Public Declare Function Pci6011_ReadADBuffe

    9、r Lib “PCI6011dll.dll“ _ (ByVal mDev As Long, ByRef mVal As Integer, ByVal mDataLength As Long) As Long Public Declare Function Pci6011_StopAD Lib “PCI6011dll.dll“ _ (ByVal mDev As Long) As Boolean Public Declare Function Pci6011_StartAD Lib “PCI6011dll.dll“ _ (ByVal mDev As Long) As Boolean Public

    10、Declare Function Pci6011_DAout Lib “PCI6011dll.dll“ _ (ByVal mDev As Long, ByVal mChn As Integer, ByVal mVal As Integer) As Boolean 使用 VB 编程时,中断事件通过提供的 PCI6011OCX 控件,来实现。一个控件对应一个中断 源,设置接收控件窗口来确定事件的发生,举例如下: 初始化设备 0 的定时器中断,m_Ocx1 为控制控件对象 Pci6011_InitTimer2(0,2,2000,1, m_Ocx1.mhWnd) 初始化设备 0 的采集中断,m_Ocx

    11、2 为控制控件对象 m_Ctrl. (设置采集参数) m_Ctrl.m_hWnd = m_Ocx2.m_hWnd Pci6011_InitTimer2(0,2,2000,1, m_Ocx1.mhWnd) 这样 m_Ocx1 响应定时器中断,m_Ocx2 响应采集中断 Dim InDriverName As String Dim mDevHandle As Long Dim sVersion As String Dim pval1(0 To 128) As Integer Dim pval2(0 To 128) As Long Dim ADdata As Long Dim mTest, mMsg

    12、 As Boolean Private Sub Command1_Click() If Pci6011_IsOpen(0) Then mMsg = MsgBox(“设备已成功打开“, vbOKOnly) Else mMsg = MsgBox(“设备没有打开“, vbOKOnly) GoTo 100 End If mTest = Pci6011_GetVersion(0, sVersion) If mTest Then mMsg = MsgBox(sVersion, vbOKOnly) Else mMsg = MsgBox(“读取版本出错“, vbOKOnly) End If mTest = P

    13、ci6011_WriteIO(mDevHandle, 1234) If mTest Then mMsg = MsgBox(“输出开关量值为 1234“, vbOKOnly) Else mMsg = MsgBox(“输出开关量值出错“, vbOKOnly) End If pval1(0) = 0 mTest = Pci6011_ReadIO(mDevHandle, pval1(0) If mTest Then mMsg = MsgBox(pval1(0), vbOKOnly) Else mMsg = MsgBox(“输入开关量值出错“, vbOKOnly) End If mTest = Pci6

    14、011_DAout(mDevHandle, 0, 4095) If mTest Then mMsg = MsgBox(“通道 0 输出模拟量值为 4095“, vbOKOnly) Else mMsg = MsgBox(“通道 0 输出模拟量值出错“, vbOKOnly) End If mTest = Pci6011_DAout(mDevHandle, 1, 4095) If mTest Then mMsg = MsgBox(“通道 1 输出模拟量值为 4095“, vbOKOnly) Else mMsg = MsgBox(“通道 1 输出模拟量值出错“, vbOKOnly) End If mT

    15、est = Pci6011_SoftADGetVal(0, 0, pval1(0) If mTest Then mMsg = MsgBox(“软件中断方式启动 AD 并得到采样值正确“, vbOKOnly) Else mMsg = MsgBox(“软件启动 AD 出错“, vbOKOnly) End If mTest = Pci6011_SoftADSetChn(0, 0) If mTest Then mMsg = MsgBox(“设置模拟输入通道正确“) Else mMsg = MsgBox(“设置模拟输入通道出错“, vbOKOnly) End If mTest = Pci6011_Sof

    16、tADStart(0) If mTest Then mMsg = MsgBox(“软件启动 AD 正确“) Else mMsg = MsgBox(“软件启动 AD 出错“, vbOKOnly) End If mTest = Pci6011_SoftADRead(0, pval1(0) If mTest Then mMsg = MsgBox(pval1(0), vbOKOnly) Else mMsg = MsgBox(“软件启动方式读取 AD 值出错“, vbOKOnly) End If 100 End Sub Private Sub Command2_Click() mTest = Pci60

    17、11_Open(0) If mTest Then mMsg = MsgBox(“设备成功的被打开“, vbOKOnly) Else mMsg = MsgBox(“打开设备出错“, vbOKOnly) End If End Sub Private Sub Command3_Click() If Pci6011_IsOpen(0) Then mMsg = MsgBox(“设备已成功打开“, vbOKOnly) Else mMsg = MsgBox(“设备没有打开“, vbOKOnly) GoTo 200 End If mTest = Pci6011_Close(mDevHandle) If mTe

    18、st Then mMsg = MsgBox(“设备关闭正确“, vbOKOnly) Else mMsg = MsgBox(“设备关闭出错“, vbOKOnly) End If 200 End Sub Private Sub Command4_Click() If Pci6011_IsOpen(0) Then mMsg = MsgBox(“设备已成功打开“, vbOKOnly) Else mMsg = MsgBox(“设备没有打开“, vbOKOnly) GoTo 300 End If 定时器测试 方式 2 mTest = Pci6011_InitTimer2(0, 4, 4000, 1, PC

    19、I6011OCX1.hWnd) If mTest Then mMsg = MsgBox(“定时器初始化正确“, vbOKOnly) Else mMsg = MsgBox(“定时器初始化失败“, vbOKOnly) GoTo 300 End If mTest = Pci6011_StartTimer2(0) If mTest Then mMsg = MsgBox(“启动正确“) Else mMsg = MsgBox(“启动出错“, vbOKOnly) GoTo 300 End If 300 End Sub Private Sub Command5_Click() Dim ddd As AD601

    20、1_WINCTRL_STRUCT ddd.m_ADType = 1 ddd.m_BufferBlock = 4 ddd.m_ClkSrc = 0 ddd.m_EndChn = 15 ddd.m_hWnd = PCI6011OCX2.hWnd ddd.m_StartChn = 0 ddd.m_StartType = 0 ddd.m_Timer0Val = 2 ddd.m_Timer1Val = 20 ddd.m_TransFlag = 0 If Pci6011_IsOpen(0) Then mMsg = MsgBox(“设备已成功打开“, vbOKOnly) Else mMsg = MsgBox

    21、(“设备没有打开“, vbOKOnly) GoTo 400 中断采集测试 End If mTest = Pci6011_ADCtrl(0, ddd) If mTest Then mMsg = MsgBox(“初始化正确“, vbOKOnly) Else mMsg = MsgBox(“初始化失败“, vbOKOnly) GoTo 400 End If Pci6011_StartAD (0) 400 End Sub Private Sub Command6_Click() Pci6011_TestMsg (0) End Sub Private Sub Form_Load() sVersion = “1234567890abcdefg “ End Sub Private Sub PCI6011OCX1_DevINTArrived() Pci6011_StopTimer2 (0) mMsg = MsgBox(“收到定时器中断“, vbOKOnly) End Sub Private Sub PCI6011OCX2_DevINTArrived() Pci6011_StopAD (0) mMsg = MsgBox(“收到 AD 中断“, vbOKOnly) End Sub

    展开阅读全文
    提示  163文库所有资源均是用户自行上传分享,仅供网友学习交流,未经上传用户书面授权,请勿作他用。
    关于本文
    本文标题:大学精品课件:VB接口方法举例.doc
    链接地址:https://www.163wenku.com/p-428590.html

    Copyright@ 2017-2037 Www.163WenKu.Com  网站版权所有  |  资源地图   
    IPC备案号:蜀ICP备2021032737号  | 川公网安备 51099002000191号


    侵权投诉QQ:3464097650  资料上传QQ:3464097650
       


    【声明】本站为“文档C2C交易模式”,即用户上传的文档直接卖给(下载)用户,本站只是网络空间服务平台,本站所有原创文档下载所得归上传人所有,如您发现上传作品侵犯了您的版权,请立刻联系我们并提供证据,我们将在3个工作日内予以改正。

    163文库