DLL TUT-0014 Ver. 3.3 www.interface.co.jp
Ver. 1.0 200212 2.0 2003 3 Visual Basic.NET (GPC-2000) (GPC-3100) (GPC-3300) 2.1 20035 () hdevicehandle = DioOpen(lpszName, FBIDIO_FLAG_SHARE) () hdevicehandle = IFCDio.DioOpen(lpszName, FBIDIO_FLAG_SHARE) 3.0 20037 GPIB(GPC-4301)Visual Basic.NET Visual C#.NET (GPC-2000) (GPC-3100) (GPC-3300)G PIBGPC-4301 3.1 20041 3.2 20048 3.3 20059 (,), Web site( ) - 1 - Interface Corporation
/ () Interface Corporation - 2 -
5 1 Visual Studio.NET 7 2 Visual Basic.NET 8 2.1...9 2.1.1GPC-2000...11 2.1.2 (GPC-3100)...14 2.1.3 (GPC-3300)...21 2.1.4GPIB (GPC-4301 DLL)...27 2.1.5GPIB (GPC-4301 DLL)...34 2.2...43 2.2.1 (1 )...43 2.2.2 (AD )...46 2.2.3 (DA )...48 2.2.4GPIB ( DLL )...50 2.2.5GPIB ( DLL )...55 2.3...61 2.3.1...61 2.3.2...64 3 Visual C#.NET 66 3.1...66 3.2...67 3.3...70 3.4...77 3.5...77 3.5.1GPC-2000...78 3.5.2GPC-3100...79 3.5.3GPC-3300...82 3.5.4GPC-4301 DLL...85 3.5.5GPC-4301 DLL...88 3.6...92-3 - Interface Corporation
4.NET 93 4.1DLL...93 4.1.1...93 4.1.2...94 4.2DLL...95 4.2.1DLL DLL...95 4.2.2DLL...96 4.2.3...96 4.2.4DLL...99 4.3...100 4.3.1Declare As Any...100 4.3.2...100 4.3.3...101 4.3.4 (GPC-3100 )...104 4.3.5...107 4.3.6...108 4.3.7...110 4.3.8...113 4.3.9...116 4.3.10...117 4.3.11Visual C++.NET...119 122 124 125 Interface Corporation - 4 -
はじめに Visual Studio 6.0Visual Studio.NET WindowsGPC Visual Studio.NETVisual Basic.NETVisual C#.NETVisual C++.NET Visual Studio.NETVisual Studio 6.0Visual Studio.NET Microsoft Visual Studio 6.0Microsoft Visual Studio.NET Visual Basic.NETVisual C#.NET Visual C++.NET MicrosoftMSDN PCI/CompactPCI/CardBusWindows GPC PCI/CompactPCI/CardBusWindows GPC www.interface.co.jp E-mailsupport@interface.co.jp - 5 - Interface Corporation
Visual Studio Visual Studio.NET Visual Studio.NET Enterprise Architect Visual Studio.NET Enterprise Developer Visual Studio.NET Professional Visual Studio.NET Academic Visual Basic.NET Standard Visual C#.NET Standard Visual C++.NET Standard Windows XP ProfessionalVisual Studio.NET Professional PCI/CompactPCI/CardBusWindowsGPC (BPC-0818) Web sitewww.interface.co.jp PDF PDF Web sitewww.interface.co.jp Visual Basic, Visual C++ Visual Basic, Visual C++ Web site Interface Corporation - 6 -
第 1 章 Visual Studio.NET とは? Visual Studio.NETMicrosoftXML Web Visual Basic 6.0 Visual Basic 6.0Visual Basic.NETVisual C++ 6.0 Visual C++.NETC++ C/C ++ Visual C#.NET WindowsGPC Visual Studio.NETVisual Basic.NETVisual C#.NET Visual C++.NET Visual Studio.NETMicrosoft MSDN Visual Studio 6.0Visual Studio.NET - 7 - Interface Corporation
第 2 章 Visual Basic.NET への移行 Visual Basic.NET(GPC) Visual Basic.NET Visual Basic.NET Visual Basic 6.0Visual Basic.NET Visual Basic.NETMicrosoft MSDN Interface Corporation - 8 -
2.1 関数定義ファイルのインポート Visual Basic.NET 1. Visual Studio.NET 2. -- Visual Basic OK 2-1 3. - 2-2 - 9 - Interface Corporation
4. BPC-0818Visual Basic.NET GPC-2000 GPC-3100 GPC-3300 GPC-4301 DLL GPC-4301 DLL 2-1 Visual Basic.NET Visual Basic.NET < > Interface BPC0818 GPC2000 include FbiDio.vb < > Interface BPC0818 GPC3100 include FbiAd.vb < > Interface BPC0818 GPC3300 include FbiDa.vb < > Interface BPC0818 GPC4301 include GPC4301Std.vb < > Interface BPC0818 GPC4301 include GPC4301Ex.vb 2-3 Visual Basic.NET Visual Basic 6.0 Visual Basic.NET Interface Corporation - 10 -
2.1.1 デジタル入出力ボード (GPC-2000) Visual Basic.NETVisual Basic 6.0 Visual Basic 6.0 Visual Basic.NET GPC-2000 FbiDio.bas < > Interface GPC2000 include FbiDio.bas BPC-0818 FbiDio.vb < > Interface BPC0818 GPC2000 include FbiDio.vb Visual Basic 6.0Visual Basic.NET Visual Basic.NET 2-2 () FBIDIO_RSTIN_MASK DioInputHandShake Any Declare DioInputHandShakeEx Any As Any DioOutputHandShake Any DioOutputHandShakeEx Any - 11 - Interface Corporation
List2-1,List2-2Visual Basic 6.0Visual Basic.NETFBIDIO_RSTIN_MASK Visual Basic.NET List2-1 Visual Basic 6.0FBIDIO_RSTIN_MASK Public Const FBIDIO_RSTIN_MASK = 1 List2-2Visual Basic.NETFBIDIO_RSTIN_MASK Public Const FBIDIO_RSTIN_MASK As Integer = 1 Visual Basic 6.0 Visual Basic.NET Any Visual Basic.NET 2-2Any DioInputHandShake Visual Basic.NET Interface Corporation - 12 -
List2-3,List2-4Visual Basic 6.0Visual Basic.NETDioInputHandShake List2-3Visual Basic 6.0DioInputHandShake Declare Function DioInputHandShake Lib "FbiDio.DLL" (ByVal hdevicehandle As Long, ByRef lpbuffer As Any, ByVal nnumofbytestoread As Long, ByRef lpnumofbytesread As Long, ByRef lpoverlapped As OVERLAPPED) As Long List2-4Visual Basic.NETDioInputHandShake Declare Function DioInputHandShake Lib "FbiDio.DLL" (ByVal hdevicehandle As Integer, ByRef lpbuffer As Byte, ByVal nnumofbytestoread As Integer, ByRef lpnumofbytesread As Integer, ByRef lpoverlapped As OVERLAPPED) As Integer Declare Function DioInputHandShake Lib "FbiDio.DLL" (ByVal hdevicehandle As Integer, ByRef lpbuffer As Short, ByVal nnumofbytestoread As Integer, ByRef lpnumofbytesread As Integer, ByRef lpoverlapped As OVERLAPPED) As Integer Declare Function DioInputHandShake Lib "FbiDio.DLL" (ByVal hdevicehandle As Integer, ByRef lpbuffer As Integer, ByVal nnumofbytestoread As Integer, ByRef lpnumofbytesread As Integer, ByRef lpoverlapped As OVERLAPPED) As Integer Declare Function DioInputHandShake Lib "FbiDio.DLL" (ByVal hdevicehandle As Integer, ByVal lpbuffer() As Byte, ByVal nnumofbytestoread As Integer, ByRef lpnumofbytesread As Integer, ByRef lpoverlapped As OVERLAPPED) As Integer Declare Function DioInputHandShake Lib "FbiDio.DLL" (ByVal hdevicehandle As Integer, ByVal lpbuffer() As Short, ByVal nnumofbytestoread As Integer, ByRef lpnumofbytesread As Integer, ByRef lpoverlapped As OVERLAPPED) As Integer Declare Function DioInputHandShake Lib "FbiDio.DLL" (ByVal hdevicehandle As Integer, ByVal lpbuffer() As Integer, ByVal nnumofbytestoread As Integer, ByRef lpnumofbytesread As Integer, ByRef lpoverlapped As OVERLAPPED) As Integer AnyDeclare As Any APIVisual Basic 6.0 APIGPC-2000Help - 13 - Interface Corporation
2.1.2 アナログ入力ボード (GPC-3100) Visual Basic.NETVisual Basic 6.0 Visual Basic 6.0 Visual Basic.NET GPC-3100 FbiAd.bas <> Interface GPC3100 include FbiAd.bas BPC-0818 FbiAd.vb <> Interface BPC0818 GPC3100 include FbiAd.vb Visual Basic 6.0Visual Basic.NET Visual Basic.NET 2-3 () FLAG_SYNC AdInputAD Any Declare AdGetSamplingData Any AdDataConv Any As Any AdReadFile Any AdBmGetSamplingData Any AdLvGetSamplingData Any AdReadSamplingBuffer Any AdFifoGetSamplingData Any Interface Corporation - 14 -
ADSMPLCHREQ ADTRIGCHREQ ADSMPLREQ ADBMSMPLREQ ADBOARDSPEC - 15 - Interface Corporation
2-3 List2-5, List2-6Visual Basic 6.0Visual Basic.NETFLAG_SYNC List2-5 Visual Basic 6.0FLAG_SYNC Public Const FLAG_SYNC = 1 List2-6 Visual Basic.NETFLAG_SYNC Public Const FLAG_SYNC As Integer = 1 Visual Basic 6.0Visual Basic.NET Any Visual Basic.NET 2-3Any AdInputAD Visual Basic.NET Interface Corporation - 16 -
List2-7,2-8Visual Basic 6.0Visual Basic.NETAdInputAD List2-7 Visual Basic 6.0AdInputAD Declare Function AdInputAD Lib "fbiad.dll" (ByVal hdevicehandle As Long, ByVal ulch As Long, ByVal ulsinglediff As Long, ByRef lpadsmplchreq As ADSMPLCHREQ, ByRef lpdata As Any) As Long List2-8 Visual Basic.NETAdInputAD Declare Function AdInputAD Lib "fbiad.dll" (ByVal hdevicehandle As Integer, ByVal ulch As Integer, ByVal ulsinglediff As Integer, ByRef lpadsmplchreq As ADSMPLCHREQ, ByRef lpdata As Byte) As Integer Declare Function AdInputAD Lib "fbiad.dll" (ByVal hdevicehandle As Integer, ByVal ulch As Integer, ByVal ulsinglediff As Integer, ByRef lpadsmplchreq As ADSMPLCHREQ, ByRef lpdata As Short) As Integer Declare Function AdInputAD Lib "fbiad.dll" (ByVal hdevicehandle As Integer, ByVal ulch As Integer, ByVal ulsinglediff As Integer, ByRef lpadsmplchreq As ADSMPLCHREQ, ByRef lpdata As Integer) As Integer Declare Function AdInputAD Lib "fbiad.dll" (ByVal hdevicehandle As Integer, ByVal ulch As Integer, ByVal ulsinglediff As Integer, ByVal lpadsmplchreq() As ADSMPLCHREQ, ByVal lpdata() As Byte) As Integer Declare Function AdInputAD Lib "fbiad.dll" (ByVal hdevicehandle As Integer, ByVal ulch As Integer, ByVal ulsinglediff As Integer, ByVal lpadsmplchreq() As ADSMPLCHREQ, ByVal lpdata() As Short) As Integer Declare Function AdInputAD Lib "fbiad.dll" (ByVal hdevicehandle As Integer, ByVal ulch As Integer, ByVal ulsinglediff As Integer, ByVal lpadsmplchreq() As ADSMPLCHREQ, ByVal lpdata() As Integer) As Integer AnyDeclare As Any - 17 - Interface Corporation
2-3 List2-1-9, 2-1-10Visual Basic 6.0Visual Basic.NETADSMPLCHREQ List 2-9 Visual Basic 6.0ADSMPLCHREQ Type ADSMPLCHREQ UlChNo As Long UlRange As Long End Type List 2-10 Visual Basic.NETADSMPLCHREQ Option Strict Off Option Explicit On Imports System.Runtime.InteropServices Module FbiAd <StructLayout(LayoutKind.Sequential)> _Structure ADSMPLCHREQ Dim ulchno As Integer Dim ulrange As Integer End Structure Interface Corporation - 18 -
2-3 List2-11,2-12Visual Basic 6.0Visual Basic.NETADSMPLREQ List 2-11 Visual Basic 6.0ADSMPLREQ Type ADSMPLREQ UlChCount As Long SmplChReq(0 To 255) As ADSMPLCHREQ UlSamplingMode As Long UlSingleDiff As Long UlSmplNum As Long UlSmplEventNum As Long FSmplFreq As Single UlTrigPoint As Long UlTrigMode As Long LTrigDelay As Long UlTrigCh As Long FTrigLevel1 As Single FTrigLevel2 As Single UlEClkEdge As Long UlATrgPulse As Long UlTrigEdge As Long UlTrigDI As Long UlFastMode As Long End Type - 19 - Interface Corporation
List 2-12 Visual Basic.NETADSMPLREQ <StructLayout(LayoutKind.Sequential)> _ Structure ADSMPLREQ Dim ulchcount As Integer <MarshalAs(UnmanagedType.ByValArray, SizeConst:=512)> _ Dim ulchnorange() As Integer Dim ulsamplingmode As Integer Dim ulsinglediff As Integer Dim ulsmplnum As Integer Dim ulsmpleventnum As Integer Dim fsmplfreq As Single Dim ultrigpoint As Integer Dim ultrigmode As Integer Dim ltrigdelay As Integer Dim ultrigch As Integer Dim ftriglevel1 As Single Dim ftriglevel2 As Single Dim uleclkedge As Integer Dim ulatrgpulse As Integer Dim ultrigedge As Integer Dim ultrigdi As Integer Dim ulfastmode As Integer Public Sub New(ByVal Dummy As Integer) ReDim ulchnorange(511) End Sub Public Sub SetChNo(ByVal ulindex As Integer, ByVal ulnumber As Integer) ulchnorange(ulindex * 2) = ulnumber End Sub Public Function GetChNo(ByVal ulindex As Integer) GetChNo = ulchnorange(ulindex * 2) End Function Public Sub SetChRange(ByVal ulindex As Integer, ByVal ulrange As Integer) ulchnorange((ulindex * 2) + 1) = ulrange End Sub Public Function GetChRange(ByVal ulindex As Integer) GetChRange = ulchnorange((ulindex * 2) + 1) End Function End Structure SetChNoGetChNoSetRangeNoGetRangeNo Interface Corporation - 20 -
GPC-3100 APIVisual Basic 6.0 APIGPC-3100Help 2.1.3 アナログ出力ボード (GPC-3300) Visual Basic.NETVisual Basic 6.0 Visual Basic 6.0 Visual Basic.NET GPC-3300 FbiDa.bas <> Interface GPC3300 include FbiDa.bas BPC-0818 FbiDa.vb < > Interface BPC0818 GPC3300 include FbiDa.vb Visual Basic 6.0Visual Basic.NET Visual Basic.NET - 21 - Interface Corporation
2-4 () FLAG_SYNC DaSetSamplingData Any Declare DaOutputDA Any DaDataConv Any As Any DaWriteFile Any DASMPLCHREQ DASMPLREQ DABOARDSPEC DAMODECHREQ DAMODEREQ DAFIFOREQ Interface Corporation - 22 -
2-4 List 2-13, List2-14Visual Basic 6.0Visual Basic.NETFLAG_SYNC List 2-13 Visual Basic 6.0FLAG_SYNC Public Const FLAG_SYNC = 1 List 2-14 Visual Basic.NETFLAG_SYNC Public Const FLAG_SYNC As Integer = 1 Visual Basic 6.0Visual Basic.NET Any Visual Basic.NET 2-4Any DaSetSamplingData Visual Basic.NET - 23 - Interface Corporation
List2-15,List2-16Visual Basic 6.0Visual Basic.NETDaSetSamplingData List 2-15 Visual Basic 6.0DaSetSamplingData Declare Function DaSetSamplingData Lib "FbiDa.DLL" (ByVal hdevicehandle As Long, ByRef psmpldata As Any, ByVal ulsmpldatanum As Long) As Long List 2-16 Visual Basic.NETDaSetSamplingData Declare Function DaSetSamplingData Lib "FbiDa.DLL" (ByVal hdevicehandle As Integer, ByRef psmpldata As Byte, ByVal ulsmpldatanum As Integer) As Integer Declare Function DaSetSamplingData Lib "FbiDa.DLL" (ByVal hdevicehandle As Integer, ByRef psmpldata As Short, ByVal ulsmpldatanum As Integer) As Integer Declare Function DaSetSamplingData Lib "FbiDa.DLL" (ByVal hdevicehandle As Integer, ByRef psmpldata As Integer, ByVal ulsmpldatanum As Integer) As Integer Declare Function DaSetSamplingData Lib "FbiDa.DLL" (ByVal hdevicehandle As Integer, ByVal psmpldata() As Byte, ByVal ulsmpldatanum As Integer) As Integer Declare Function DaSetSamplingData Lib "FbiDa.DLL" (ByVal hdevicehandle As Integer, ByVal psmpldata() As Short, ByVal ulsmpldatanum As Integer) As Integer Declare Function DaSetSamplingData Lib "FbiDa.DLL" (ByVal hdevicehandle As Integer, ByVal psmpldata() As Integer, ByVal ulsmpldatanum As Integer) As Integer AnyDeclare As Any 2-4 List2-17,List2-18Visual Basic 6.0Visual Basic.NETADSMPLCHREQ List 2-17 Visual Basic 6.0DASMPLCHREQ Type DASMPLCHREQ ulchno As Long ulrange As Long End Type Interface Corporation - 24 -
List 2-18 Visual Basic.NETDASMPLCHREQ Option Strict Off Option Explicit On Imports System.Runtime.InteropServices Module FbiDa <StructLayout(LayoutKind.Sequential)> _ Structure DASMPLCHREQ Dim ulchno As Integer Dim ulrange As Integer End Structure 2-4 List2-19,List2-20Visual Basic 6.0Visual Basic.NETADSMPLREQ List 2-19 Visual Basic 6.0DASMPLREQ Type DASMPLREQ ulchcount As Long SmplChReq(0 To 255) As DASMPLCHREQ ulsamplingmode As Long fsmplfreq As Single ulsmplrepeat As Long ultrigmode As Long ultrigpoint As Long ultrigdelay As Long uleclkedge As Long ultrigedge As Long ultrigdi As Long End Type - 25 - Interface Corporation
List 2-20 Visual Basic.NETDASMPLREQ <StructLayout(LayoutKind.Sequential)> _ Structure DASMPLREQ Dim ulchcount As Integer <MarshalAs(UnmanagedType.ByValArray, SizeConst:=512)> _ Dim ulchnorange() As Integer Dim ulsamplingmode As Integer Dim fsmplfreq As Single Dim ulsmplrepeat As Integer Dim ultrigmode As Integer Dim ultrigpoint As Integer Dim ultrigdelay As Integer Dim uleclkedge As Integer Dim ultrigedge As Integer Dim ultrigdi As Integer Public Sub New(ByVal Dummy As Integer) ReDim ulchnorange(511) End Sub Public Sub SetChNo(ByVal ulindex As Integer, ByVal ulnumber As Integer) ulchnorange(ulindex * 2) = ulnumber End Sub Public Function GetChNo(ByVal ulindex As Integer) GetChNo = ulchnorange(ulindex * 2) End Function Public Sub SetChRange(ByVal ulindex As Integer, ByVal ulrange As Integer) ulchnorange((ulindex * 2) + 1) = ulrange End Sub Public Function GetChRange(ByVal ulindex As Integer) GetChRange = ulchnorange((ulindex * 2) + 1) End Function End Structure SetChNoGetChNoSetRangeNoGetRangeNo GPC-3100 APIVisual Basic 6.0API GPC-3100Help Interface Corporation - 26 -
2.1.4 GPIB ボード (GPC-4301 標準版 DLL) GPIB GPC-4301DLL Visual Basic.NETVisual Basic 6.0 Visual Basic 6.0 Visual Basic.NET GPC-4301 GPC43042.bas <> Interface GPC4301 include GPC43042.bas BPC-0818 GPC4301std.vb <> Interface BPC0818 GPC4301 include GPC4301std.vb Visual Basic 6.0Visual Basic.NET 2-5 (GPIB GPC-4301) GPIB_SUCCESS_NOT_ACTI VE_SRQ - 27 - Interface Corporation
GpibReceive GpibSend GpibSetSrqEvent Any Declare As Any delegate PLPSRQCALLBACK delegate GpibSetSrqEvent Interface Corporation - 28 -
2- List2-21, List2-22 Visual Basic 6.0Visual Basic.NET GPIB_SUCCESS_NOT_ACTIVE_SRQ List 2-21 Visual Basic 6.0GPIB_SUCCESS_NOT_ACTIVE_SRQ Public Const GPIB_SUCCESS_NOT_ACTIVE_SRQ = 5 List 2-22 Visual Basic.NETGPIB_SUCCESS_NOT_ACTIVE_SRQ Public Const GPIB_SUCCESS_NOT_ACTIVE_SRQ As Integer = 5 Visual Basic 6.0Visual Basic.NET Any Visual Basic.NET GpibSend GpibSetnd IntPtr [] 4 GpibSend Visual Basic.NET - 29 - Interface Corporation
Byte Byte String IntPtr 2-6 GpibSend 1 List 2-23 Visual Basic 6.0GpibSend Declare Function GpibSend Lib "GPC43042.DLL" (ByVal ulboardno As Long, ByRef lpadrstbl As Long, ByVal ulplength As Long, ByVal vpbuffer As String) As Long List 2-24 Visual Basic.NETGpibSendByte Declare Function GpibSend Lib "GPC43042.DLL" (ByVal ulboardno As Integer, ByVal lpadrstbl() As Integer, ByVal ulplength As Integer, ByRef vpbuffer As Byte) As Integer List 2-25 Visual Basic.NETGpibSendByte Declare Function GpibSend Lib "GPC43042.DLL" (ByVal ulboardno As Integer, ByVal lpadrstbl() As Integer, ByVal ulplength As Integer, ByVal vpbuffer() As Byte) As Integer List 2-26 Visual Basic.NETGpibSendString Declare Function GpibSend Lib "GPC43042.DLL" (ByVal ulboardno As Integer, ByVal lpadrstbl() As Integer, ByVal ulplength As Integer, ByVal vpbuffer As String) As Integer List 2-27 Visual Basic.NETGpibSendIntPtr Declare Function GpibSend Lib "GPC43042.DLL" (ByVal ulboardno As Integer, ByVal lpadrstbl() As Integer, ByVal ulplength As Integer, ByVal vpbuffer As IntPtr) As Integer GpibReceive GpibReceive IntPtr [] 4 GpibReceive Visual Basic.NET Interface Corporation - 30 -
2-7 GpibReceive Byte Byte String IntPtr 1 List 2-28 Visual Basic 6.0GpibReceive Declare Function GpibReceive Lib "GPC43042.DLL" (ByVal ulboardno As Long, ByRef lpadrstbl As Long, ByRef ulplength As Long, ByVal vpbuffer As String) As Long List 2-29 Visual Basic.NETGpibReceiveByte Declare Function GpibReceive Lib "GPC43042.DLL" (ByVal ulboardno As Integer, ByVal lpadrstbl() As Integer, ByRef ulplength As Integer, ByRef vpbuffer As Byte) As Integer List 2-30 Visual Basic.NETGpibReceiveByte Declare Function GpibReceive Lib "GPC43042.DLL" (ByVal ulboardno As Integer, ByVal lpadrstbl() As Integer, ByRef ulplength As Integer, ByVal vpbuffer() As Byte) As Integer List 2-31 Visual Basic.NETGpibReceiveString Function GpibReceive(ByVal ulboardno As Integer, ByVal lpadrstbl() As Integer, ByRef ulplength As Integer, ByRef vpbuffer As String) As Integer Dim nlength As Integer Dim nret As Integer Dim e As ASCIIEncoding = New ASCIIEncoding() Dim szdata(ulplength - 1) As Byte vpbuffer = "" nlength = ulplength nret = GpibReceive(ulBoardNo, lpadrstbl, nlength, szdata) If (nret = 0) Then vpbuffer = e.getstring(szdata, 0, nlength) ulplength = vpbuffer.length End If GpibReceive = nret End Function - 31 - Interface Corporation
StringGpibReceiveByte StringFunctionGpibReceive NULLByte List 2-32 Visual Basic.NETGpibReceiveIntPtr Declare Function GpibReceive Lib "GPC43042.DLL" (ByVal ulboardno As Integer, ByVal lpadrstbl() As Integer, ByRef ulplength As Integer, ByVal vpbuffer As IntPtr) As Integer GpibSetSrqEvent 2-5Any List2-33,2-34Visual Basic 6.0Visual Basic.NETGpibSetSrqEvent List 2-33 Visual Basic 6.0GpibSetSrqEvent Declare Function GpibSetSrqEvent Lib "GPC43042.DLL" (ByVal ulboardno As Long, ByVal lponsrqproc As Any, ByVal dwuser As Long) As Long List 2-34 Visual Basic.NETGpibSetSrqEvent Declare Function GpibSetSrqEvent Lib "GPC43042.DLL" (ByVal ulboardno As Integer, ByVal lponsrqproc As PLPSRQCALLBACK, ByVal dwuser As Integer) As Integer PLPSRQCALLBACK GpibSetSrqEventlpOnSrqProcSRQ Visual Basic.NETDLL PLPSRQCALLBACK Interface Corporation - 32 -
List 2-35 Visual Basic.NETPLPSRQCALLBACK Delegate Sub PLPSRQCALLBACK(ByVal nboardno As Integer, ByVal dwuser As Integer) PLPSRQCALLBACK List 2-36 Visual Basic.NET PLPSRQCALLBACK Public osp As PLPSRQCALLBACK PLPSRQCALLBACK New AddressOf List 2-37 Visual Basic.NET PLPSRQCALLBACK osp = New PLPSRQCALLBACK(AddressOf lponsrqproc) nret = GpibSetSrqEvent(nBoardNo, osp, UserData) List 2-38 Visual Basic.NET lponsrqproc Sub lponsrqproc(byval dwboardno As Integer, ByVal dwuser As Integer) End Sub ' SRQ ' AnyDeclare As Any APIVisual Basic 6.0 APIGPC-4301Help DLL - 33 - Interface Corporation
2.1.5 GPIB ボード (GPC-4301 高機能版 DLL) GPIBGPC-4301DLL Visual Basic.NETVisual Basic 6.0 Visual Basic 6.0 Visual Basic.NET GPC-4301 GPC4304.bas <> Interface GPC4301 include GPC4304.bas BPC-0818 GPC4301Ex.bas <> Interface BPC0818 GPC4301 include GPC4301Ex.vb Visual Basic 6.0Visual Basic.NET 2-8 (GPC4301 DLL) GPIB_SUCCESS_NOT_FOU ND_LISTENER Interface Corporation - 34 -
PciGpibExMastSendData PciGpibExMastRecvData PciGpibExSlavSendData PciGpibExSlavRecvData PciGpibExSetSrqEvent Any Declare As Any delegate PLPSRQCALLBACK delegate PciGpibExSetSrqEvent - 35 - Interface Corporation
2-8 List2-39,2-40Visual Basic 6.0Visual Basic.NET GPIB_SUCCESS_NOT_FOUND_LISTENER List 2-39 Visual Basic 6.0GPIB_SUCCESS_NOT_FOUND_LISTENER Public Const GPIB_SUCCESS_NOT_FOUND_LISTENER = 11 List 2-40 Visual Basic.NETGPIB_SUCCESS_NOT_FOUND_LISTENER Public Const GPIB_SUCCESS_NOT_FOUND_LISTENER As Integer = 11 Visual Basic 6.0 Visual Basic.NET Any Visual Basic.NET PciGpibExMastSendData PciGpibExMastSendData IntPtr Interface Corporation - 36 -
[] 4 PciGpibExMastSendData Visual Basic.NET 2-9 PciGpibExMastSendData Byte Byte String IntPtr 1 List 2-41 Visual Basic 6.0PciGpibExMastSendData Declare Function PciGpibExMastSendData Lib "GPC4304.DLL" (ByVal nboardno As Long, ByRef npadrstbl As Long, ByVal dwlength As Long, ByVal pvbuffer As String, ByVal umsg As Long) As Long List 2-42 Visual Basic.NETPciGpibExMastSendDataByte Declare Function PciGpibExMastSendData Lib "GPC4304.DLL" (ByVal nboardno As Integer, ByVal npadrstbl() As Integer, ByVal dwlength As Integer, ByRef pvbuffer As Byte, ByVal umsg As Integer) As Integer List 2-43 Visual Basic.NETPciGpibExMastSendDataByte Declare Function PciGpibExMastSendData Lib "GPC4304.DLL" (ByVal nboardno As Integer, ByVal npadrstbl() As Integer, ByVal dwlength As Integer, ByVal pvbuffer() As Byte, ByVal umsg As Integer) As Integer List 2-44 Visual Basic.NETPciGpibExMastSendDataString Declare Function PciGpibExMastSendData Lib "GPC4304.DLL" (ByVal nboardno As Integer, ByVal npadrstbl() As Integer, ByVal dwlength As Integer, ByVal pvbuffer As String, ByVal umsg As Integer) As Integer List 2-45 Visual Basic.NETPciGpibExMastSendDataIntPtr Declare Function PciGpibExMastSendData Lib "GPC4304.DLL" (ByVal nboardno As Integer, ByVal npadrstbl() As Integer, ByVal dwlength As Integer, ByVal pvbuffer As IntPtr, ByVal umsg As Integer) As Integer - 37 - Interface Corporation
PciGpibExMastRecvData PciGpibExMastRecvData IntPtr [] 4 PciGpibExMastRecvData Visual Basic.NET 2-10 PciGpibExMastRecvData Byte Byte String IntPtr 1 List 2-46 Visual Basic 6.0PciGpibExMastRecvData Declare Function PciGpibExMastRecvData Lib "GPC4304.DLL" (ByVal nboardno As Long, ByRef npadrstbl As Long, ByRef dwplength As Long, ByVal pvbuffer As String, ByVal umsg As Long) As Long List 2-47 Visual Basic.NETPciGpibExMastRecvData Byte Declare Function PciGpibExMastRecvData Lib "GPC4304.DLL" (ByVal nboardno As Integer, ByVal npadrstbl() As Integer, ByRef dwplength As Integer, ByRef pvbuffer As Byte, ByVal umsg As Integer) As Integer List 2-48 Visual Basic.NETPciGpibExMastRecvDataByte Declare Function PciGpibExMastRecvData Lib "GPC4304.DLL" (ByVal nboardno As Integer, ByVal npadrstbl() As Integer, ByRef dwplength As Integer, ByVal pvbuffer() As Byte, ByVal umsg As Integer) As Integer Interface Corporation - 38 -
List 2-49 Visual Basic.NETPciGpibExMastRecvDataString Function PciGpibExMastRecvData(ByVal nboardno As Integer, ByVal npadrstbl() As Integer, ByRef dwplength As Integer, ByRef pvbuffer As String, ByVal umsg As Integer) As Integer Dim nlength As Integer Dim nret As Integer Dim e As ASCIIEncoding = New ASCIIEncoding() Dim szdata(dwplength - 1) As Byte pvbuffer = "" nlength = dwplength nret = PciGpibExMastRecvData(nBoardNo, npadrstbl, nlength, szdata, umsg) If (nret = 0) Then pvbuffer = e.getstring(szdata, 0, nlength) dwplength = pvbuffer.length End If PciGpibExMastRecvData = nret End Function StringPciGpibExMastRecvDataByte StringFunction PciGpibExMastRecvDataNULL Byte List 2-50 Visual Basic.NETPciGpibExMastRecvDataIntPtr Declare Function PciGpibExMastRecvData Lib "GPC4304.DLL" (ByVal nboardno As Integer, ByVal npadrstbl() As Integer, ByRef dwplength As Integer, ByVal pvbuffer As IntPtr, ByVal umsg As Integer) As Integer PciGpibExSlavSendDataPciGpibExSlavRecvData PciGpibExSlavSendDataPciGpibExSlavRecvData PciGpibExMastSendDataPciGpibExMastRecvData List 2-51 Visual Basic 6.0PciGpibExSlavSendData Declare Function PciGpibExSlavSendData Lib "GPC4304.DLL" (ByVal nboardno As Long, ByVal dwlength As Long, ByVal pvbuffer As String, ByVal umsg As Long) As Long List 2-52 Visual Basic.NETPciGpibExSlavSendData Byte Declare Function PciGpibExSlavSendData Lib "GPC4304.DLL" (ByVal nboardno As Integer, ByVal dwlength As Integer, ByRef pvbuffer As Byte, ByVal umsg As Integer) As Integer - 39 - Interface Corporation
List 2-53 Visual Basic.NETPciGpibExSlavSendData Byte Declare Function PciGpibExSlavSendData Lib "GPC4304.DLL" (ByVal nboardno As Integer, ByVal dwlength As Integer, ByVal pvbuffer() As Byte, ByVal umsg As Integer) As Integer List 2-54 Visual Basic.NETPciGpibExSlavSendData String Declare Function PciGpibExSlavSendData Lib "GPC4304.DLL" (ByVal nboardno As Integer, ByVal dwlength As Integer, ByVal pvbuffer As String, ByVal umsg As Integer) As Integer List 2-55 Visual Basic.NETPciGpibExSlavSendData IntPtr Declare Function PciGpibExSlavSendData Lib "GPC4304.DLL" (ByVal nboardno As Integer, ByVal dwlength As Integer, ByVal pvbuffer As IntPtr, ByVal umsg As Integer) As Integer List 2-56 Visual Basic 6.0PciGpibExSlavRecvData Declare Function PciGpibExSlavRecvData Lib "GPC4304.DLL" (ByVal nboardno As Long, ByRef dwplength As Long, ByVal pvbuffer As String, ByVal umsg As Long) As Long List 2-57 Visual Basic.NETPciGpibExSlavRecvData Byte Declare Function PciGpibExSlavRecvData Lib "GPC4304.DLL" (ByVal nboardno As Integer, ByRef dwplength As Integer, ByRef pvbuffer As Byte, ByVal umsg As Integer) As Integer List 2-58 Visual Basic.NETPciGpibExSlavRecvData Byte Declare Function PciGpibExSlavRecvData Lib "GPC4304.DLL" (ByVal nboardno As Integer, ByRef dwplength As Integer, ByVal pvbuffer() As Byte, ByVal umsg As Integer) As Integer Interface Corporation - 40 -
List 2-59 Visual Basic.NETPciGpibExSlavRecvData String Function PciGpibExSlavRecvData(ByVal nboardno As Integer, ByRef dwplength As Integer, ByRef pvbuffer As String, ByVal umsg As Integer) As Integer Dim nlength As Integer Dim nret As Integer Dim e As ASCIIEncoding = New ASCIIEncoding() Dim szdata(dwplength - 1) As Byte pvbuffer = "" nlength = dwplength nret = PciGpibExSlavRecvData(nBoardNo, nlength, szdata, umsg) If (nret = 0) Then pvbuffer = e.getstring(szdata, 0, nlength) dwplength = pvbuffer.length End If PciGpibExSlavRecvData = nret End Function List 2-60 Visual Basic.NETPciGpibExSlavRecvData IntPtr Declare Function PciGpibExSlavRecvData Lib "GPC4304.DLL" (ByVal nboardno As Integer, ByRef dwplength As Integer, ByVal pvbuffer As IntPtr, ByVal umsg As Integer) As Integer PciGpibExSetSrqEvent 2-8Any List2-61,2-62Visual Basic 6.0Visual Basic.NETPciGpibExSetSrqEvent List 2-61 Visual Basic 6.0PciGpibExSetSrqEvent Declare Function PciGpibExSetSrqEvent Lib "GPC4304.DLL" (ByVal nboardno As Long, ByVal lponsrqproc As Long, ByVal dwuser As Long) As Long List 2-62 Visual Basic.NETPciGpibExSetSrqEvent Declare Function PciGpibExSetSrqEvent Lib "GPC4304.DLL" (ByVal ulboardno As Integer, ByVal lponsrqproc As PLPSRQCALLBACK, ByVal dwuser As Integer) As Integer PLPSRQCALLBACK PciGpibExSetSrqEventlpOnSrqProcSRQ Visual Basic.NET - 41 - Interface Corporation
PLPSRQCALLBACK PLPSRQCALLBACK List 2-63 Visual Basic.NETPLPSRQCALLBACK Public Delegate Sub PLPSRQCALLBACK(ByVal nboardno As Integer, ByVal dwuser As Integer) PLPSRQCALLBACK List 2-64 Visual Basic.NET PLPSRQCALLBACK Public osp As PLPSRQCALLBACK List 2-65 Visual Basic.NET PLPSRQCALLBACK osp = New PLPSRQCALLBACK(AddressOf lponsrqproc) nret = PciGpibExSetSrqEvent(nBoardNo, osp, &H55) List 2-66 Visual Basic.NET lponsrqproc Sub lponsrqproc(byval dwboardno As Integer, ByVal dwuser As Integer) ' SRQ ' End Sub AnyDeclare As Any APIVisual Basic 6.0 APIGPC-4301Help DLL Interface Corporation - 42 -
2.2 サンプルプログラム 2.2.1 デジタル入出力 (1 点入力 1 点出力 ) (PCI-2994CV) GPC-2000 (Visual Basic 6.0) Visual Basic.NET Visual BasicDIO PCI-2994CV Visual Basic 6.0 1 GPC-2000 Inpoint.vbp <> Interface GPC2000 samples vb Inpoint Visual Basic.NET 1 BPC-0818 Inpoint.vbproj <> Interface BPC0818 GPC2000 samples vb Inpoint Visual Basic 6.0 1 GPC-2000 Outpoint.vbp <> Interface GPC2000 samples vb Outpoint Visual Basic.NET 1 BPC-0818 Outpoint.vbproj <> Interface BPC0818 GPC2000 samples vb Outpoint Visual Basic 6.0Visual Basic.NET - 43 - Interface Corporation
2-11 Visual Basic 6.0Visual Basic.NET Visual Basic 6.0 Visual Basic.NET OVERLAPPED Module1.frm Module1.vb List2-67 List2-68 1. Visual Studio.NET 2. -- 3. 2-11 4. 2-11Visual Basic 6.0Visual Basic.NET List 2-67 Visual Basic 6.0Module.frm Type OVERLAPPED Internal As Long InternalHigh As Long offset As Long OffsetHigh As Long hevent As Long End Type Type SECURITY_ATTRIBUTES nlength As Long lpsecuritydescriptor As Long binherithandle As Long End Type Interface Corporation - 44 -
List 2-68 Visual Basic.NETModule.vb Option Strict Off Option Explicit On Imports System.Runtime.InteropServices Module Module1 <StructLayOut(LayoutKind.Sequential)> Structure OVERLAPPED Dim Internal As Integer Dim InternalHigh As Integer Dim offset As Integer Dim OffsetHigh As Integer Dim hevent As Integer End Structure <StructLayout(LayoutKind.Sequential)> Structure SECURITY_ATTRIBUTES Dim nlength As Integer Dim lpsecuritydescriptor As Integer Dim binherithandle As Integer End Structure Visual Basic 6.0Visual Basic.NET - 45 - Interface Corporation
2.2.2 アナログ入力 (AD ボードによるサンプリング ) AD (PCI-3133) GPC-3100 (Visual Basic 6.0 ) Visual Basic.NET Visual BasicAD PCI-3133 Visual Basic 6.0 AD GPC-3100 AdSmpl_B.vbp <> Interface GPC3100 samples vb Ad_Smpl_B Visual Basic.NET AD BPC-0818 AdSmpl_B.vbproj <> Interface BPC0818 GPC3100 samples vb Ad_Smpl_B Visual Basic 6.0Visual Basic.NET Interface Corporation - 46 -
2-12 Visual Basic 6.0Visual Basic.NET Visual Basic 6.0 Visual Basic.NET gconfig Module1.frm Module1.vb List2-69,2-71 List2-70,2-72 1. Visual Studio.NET 2. -- 3. 2-12 4. 2-12Visual Basic 6.0Visual Basic.NET List 2-69 Visual Basic 6.0Module1.bas Public gconfig As ADSMPLREQ List 2-70 Visual Basic.NETModule1.vb Public gconfig As ADSMPLREQ = New ADSMPLREQ(0) (Nothing) List 2-71 Visual Basic 6.0ADSMPLREQ Public gconfig As ADSMPLREQ gconfig.smplchreq(0).ulchno =... gconfig.smplchreq(0).ulrange =...... = gconfig.smplchreq(0).ulchno... = gconfig.smplchreq(0).ulrange - 47 - Interface Corporation
List 2-72 Visual Basic.NETADSMPLREQ Public gconfig As New ADSMPLREQ(0) gconfig.setchno(0,...) gconfig.setchrange(0,...)... = gconfig.getchno(0)... = gconfig.getchrange(0) Visual Basic 6.0Visual Basic.NET 2.2.3 アナログ出力 (DA ボードによる出力更新 ) DA (PCI-3329) DA GPC-3300 (Visual Basic 6.0) Visual Basic.NET Visual BasicDA PCI-3329 Visual Basic 6.0 DA GPC-3300 DaSmpl_B.vbp <> Interface GPC3300 samples vb Da_Smpl_B Visual Basic.NET DA BPC-0818 DaSmpl_B.vbproj <> Interface BPC0818 GPC3300 samples vb Da_Smpl_B Interface Corporation - 48 -
Visual Basic 6.0Visual Basic.NET 2-13 Visual Basic 6.0Visual Basic.NET Visual Basic 6.0 Visual Basic.NET gconfig Module1.frm Module1.vb List2-73,2-75 List2-74,2-76 1. Visual Studio.NET 2. -- 3. 0-1 4. 2-13Visual Basic 6.0Visual Basic.NET List 2-73 Visual Basic 6.0Module1.bas Public gconfig As DASMPLREQ List 2-74 Visual Basic.NETModule1.vb Public gconfig As DASMPLREQ = New DASMPLREQ(0) (Nothing) - 49 - Interface Corporation
List 2-75 Visual Basic 6.0DASMPLREQ Public gconfig As DASMPLREQ gconfig.smplchreq(0).ulchno =... gconfig.smplchreq(0).ulrange =...... = gconfig.smplchreq(0).ulchno... = gconfig.smplchreq(0).ulrange List 2-76 Visual Basic.NETDASMPLREQ Public gconfig As New DASMPLREQ(0) gconfig.setchno(0,...) gconfig.setchrange(0,...)... = gconfig.getchno(0)... = gconfig.getchrange(0) Visual Basic 6.0Visual Basic.NET 2.2.4 GPIB 機器制御 ( 標準版 DLL を使用した制御 ) GPIB (PCI-4302) GPIBGPC-4301 (Visual Basic 6.0) Visual Basic.NET GPIB Interface Corporation - 50 -
PCI-4302 GPIB CAB-2220 GPIB Agilent Technologies HP 34401A Visual Basic 6.0 GPIB GPC-4301 Ctrl_B2.vbp <> Interface GPC4301 Smpl_DllStandard vb Ctrl_B2 Visual Basic.NET GPIB BPC-0818 Ctrl_B2.vbproj <> Interface BPC0818 GPC4301 samples_std vb Ctrl_B2 Visual Basic 6.0Visual Basic.NET 2-14 Visual Basic 6.0Visual Basic.NET Visual Basic 6.0 Visual Basic.NET SetPrmRecvBufferGpibSend GpibReceive Ctrl_B2.bas CtrlSendForm.frm CtrlRecvForm.frm Ctrl_B2.vb CtrlSendForm.vb CtrlRecvForm.vb List2-77,2-78,2-79 List2-78,2-80,2-82 1. Visual Studio.NET 2. -- 3. 2-14 4. 2-14Visual Basic 6.0Visual Basic.NET - 51 - Interface Corporation
StringVisual Basic.NET List 2-77 Visual Basic 6.0Ctrl_B2.bas Public SetPrm As String * 128 Public RecvBuffer As String * 32 ' ' List 2-78 Visual Basic.NETCtrl_B2.vb Public SetPrm As String ' Public RecvBuffer As String ' StringGpibSend Visual Basic.NET TextBoxTextBoxTblTextBox For List 2-79 Visual Basic 6.0CtrlSendForm.frm Private Sub CmdSend_Click() Dim nret As Long Dim szdata As String Dim nlen As Long Dim i As Long ' DevAdrsTbl(0) = DevAdrs DevAdrsTbl(1) = -1 ' For i = 1 To 5 szdata = TxtSendData(i).Text szdata = StrConv(szData, vbfromunicode) nlen = LenB(szData) If nlen = 0 Then Exit For szdata = StrConv(szData, vbunicode) nret = GpibSend(nBoardNo, DevAdrsTbl(0), nlen, szdata) If nret Then Exit For Next Call DsplyErrMessage(nRet) End Sub Interface Corporation - 52 -
List 2-80 Visual Basic.NETCtrlSendForm.vb Private Sub CmdSend_Click(ByVal eventsender As System.Object, ByVal eventargs As System.EventArgs) Handles CmdSend.Click Dim nret As Integer Dim szdata As String Dim nlen As Integer Dim i As Integer Dim TextBoxTbl() As TextBox = New TextBox() {TextBox1, TextBox2, TextBox3, TextBox4, TextBox5} ' DevAdrsTbl(0) = DevAdrs DevAdrsTbl(1) = -1 ' For i = 0 To (TextBoxTbl.Length - 1) szdata = TextBoxTbl(i).Text nlen = szdata.length If nlen <> 0 Then nret = GpibSend(nBoardNo, DevAdrsTbl, nlen, szdata) If nret Then Exit For End If End If Next Call DsplyErrMessage(nRet) End Sub StringGpibReceive GpibReceive2 GpibReceive4String 2Byte StringGPC4301Std.vb GpibReceive - 53 - Interface Corporation
List 2-81 Visual Basic 6.0CtrlRecvForm.frm Private Sub CmdRecv_Click() Dim nret As Long Dim nlen As Long ' DevAdrsTbl(0) = DevAdrs DevAdrsTbl(1) = -1 ' Dim RecvLen As Long RecvLen = 64 nret = GpibReceive(nBoardNo, DevAdrsTbl, RecvLen, RecvBuffer) If nret Then Call DsplyErrMessage(nRet) Unload CtrlRecvForm End If Call DsplyErrMessage(nRet) LblRecvData.Caption = Left(RecvBuffer, RecvLen) End Sub List 2-82 Visual Basic.NETCtrlRecvForm.vb Private Sub CmdRecv_Click(ByVal eventsender As System.Object, ByVal eventargs As System.EventArgs) Handles CmdRecv.Click Dim nret As Integer Dim nlen As Integer ' DevAdrsTbl(0) = DevAdrs DevAdrsTbl(1) = -1 ' Dim RecvLen As Integer RecvLen = 64 nret = GpibReceive(nBoardNo, DevAdrsTbl, RecvLen, RecvBuffer) If nret Then Call DsplyErrMessage(nRet) CtrlRecvForm.DefInstance.Close() End If Call DsplyErrMessage(nRet) LblRecvData.Text = RecvBuffer End Sub Visual Basic 6.0Visual Basic.NET Interface Corporation - 54 -
2.2.5 GPIB 機器制御 ( 高機能版 DLL を使用した制御 ) GPIB (PCI-4302) GPIBGPC-4301 (Visual Basic 6.0) Visual Basic.NET GPIB PCI-4302 GPIB CAB-2220 GPIB Agilent Technologies HP 34401A Visual Basic 6.0 GPC-4301 Ctrl_B.vbp <> Interface GPC4301 samples vb Ctrl_B Visual Basic.NET BPC-0818 Ctrl_B.vbproj <> Interface BPC0818 GPC4301 samples_adv Ctrl_B - 55 - Interface Corporation
Visual Basic 6.0Visual Basic.NET 2-15 Visual Basic 6.0Visual Basic.NET Visual Basic 6.0 Visual Basic.NET SetPrmRecvBufferPciGpibExMastSendData PciGpibExMastRecvData Ctrl_B.bas CtrlSendForm.frm CtrlRecvForm.frm Ctrl_B.vb CtrlSendForm.vb CtrlRecvForm.vb List2-83,2-85,2-87 List2-84,2-86,2-88 1. Visual Studio.NET 2. -- 3. 2-4. 2-15Visual Basic 6.0Visual Basic.NET StringVisual Basic.NET List 2-83 Visual Basic 6.0Ctrl_B.bas Public SetPrm As String * 128 ' Parameter Public RecvBuffer As String * 32 ' Receive buffer List 2-84 Visual Basic.NETCtrl_B.vb Public SetPrm As String ' Parameter Public RecvBuffer As String ' Receive buffer Interface Corporation - 56 -
StringPciGpibExMastSendData Visual Basic.NET TextBoxTextBoxTblTextBox For List 2-85 Visual Basic 6.0CtrlSendForm.frm Private Sub CmdSend_Click() Dim nret As Long Dim szdata As String Dim nlen As Long Dim i As Long ' Configures the device address table. DevAdrsTbl(0) = DevAdrs DevAdrsTbl(1) = -1 ' Sends data to specified device. For i = 1 To 5 szdata = TxtSendData(i).Text szdata = StrConv(szData, vbfromunicode) nlen = LenB(szData) If nlen = 0 Then Exit For szdata = StrConv(szData, vbunicode) nret = PciGpibExMastSendData(nBoardNo, DevAdrsTbl(0), nlen, szdata, 0) If nret Then Exit For Next Call DsplyErrMessage(nRet) End Sub - 57 - Interface Corporation
List 2-86 Visual Basic.NETCtrlSendForm.vb Private Sub CmdSend_Click(ByVal eventsender As System.Object, ByVal eventargs As System.EventArgs) Handles CmdSend.Click Dim nret As Integer Dim szdata As String Dim nlen As Integer Dim i As Integer Dim TextBoxTbl() As TextBox = New TextBox() {TextBox1, TextBox2, TextBox3, TextBox4, TextBox5} ' Configures the device address table. DevAdrsTbl(0) = DevAdrs DevAdrsTbl(1) = -1 ' Sends data to specified device. For i = 0 To (TextBoxTbl.Length - 1) szdata = TextBoxTbl(i).Text nlen = szdata.length If nlen <> 0 Then nret = PciGpibExMastSendData(nBoardNo, DevAdrsTbl, nlen, szdata, 0) If nret Then Exit For End If End If Next Call DsplyErrMessage(nRet) End Sub StringPciGpibExMastRecvData PciGpibExMastRecvData2 PciGpibExMastRecvData4String 2Byte StringGPC4301Ex.vb PciGpibExMastRecvData Interface Corporation - 58 -
List 2-87 Visual Basic 6.0CtrlRecvForm.frm Private Sub CmdRecv_Click() Dim nret As Long Dim nlen As Long ' Configures the device address table. DevAdrsTbl(0) = DevAdrs DevAdrsTbl(1) = -1 ' Sends data to specified device. Dim RecvLen As Long RecvLen = 64 nret = PciGpibExMastRecvData(nBoardNo, DevAdrsTbl(0), RecvLen, RecvBuffer, 0) If nret Then Call DsplyErrMessage(nRet) Unload CtrlRecvForm End If Call DsplyErrMessage(nRet) LblRecvData.Caption = Left(RecvBuffer, RecvLen) End Sub List 2-88 Visual Basic.NETCtrlRecvForm.vb Private Sub CmdRecv_Click(ByVal eventsender As System.Object, ByVal eventargs As System.EventArgs) Handles CmdRecv.Click Dim nret As Integer Dim nlen As Integer ' Configures the device address table. DevAdrsTbl(0) = DevAdrs DevAdrsTbl(1) = -1 ' Sends data to specified device. Dim RecvLen As Integer RecvLen = 64 nret = PciGpibExMastRecvData(nBoardNo, DevAdrsTbl, RecvLen, RecvBuffer, 0) If nret Then Call DsplyErrMessage(nRet) CtrlRecvForm.DefInstance.Close() End If Call DsplyErrMessage(nRet) LblRecvData.Text = RecvBuffer End Sub Visual Basic 6.0Visual Basic.NET Ctrl_BGPIBGPC-4301 BPC-0818-59 - Interface Corporation
Visual Basic 6.0Visual Basic.NET Visual Basic 6.0 YOKOGAWA7561, HP3458A GPC-4301 Device_B.vbp <> Interface GPC4301 samples vb Device_B Visual Basic.NET YOKOGAWA7561, HP3458A BPC-0818 Device_B.vbproj <> Interface BPC0818 GPC4301 samples_adv vb Device_B Visual Basic 6.0 GPC-4301 Binary_B.vbp <> Interface GPC4301 samples vb Binary_B Visual Basic.NET BPC-0818 Binary_B.vbproj <> Interface BPC0818 GPC4301 samples_adv vb Binary_B Visual Basic 6.0 GPC-4301 Async_B.vbp <> Interface GPC4301 samples vb Async_B Visual Basic.NET BPC-0818 Async_B.vbproj <> Interface BPC0818 GPC4301 samples_adv vb Async_B Interface Corporation - 60 -
2.3 アップグレードウィザード Visual Studio.NETVisual Basic 6.0Visual Basic.NET Visual Basic.NET Visual Basic.NET Visual Basic 6.0Visual Basic.NET 2.3.1 アップグレード手順 1.Visual Studio.NET 2.--(.vbp) 2-4 - 61 - Interface Corporation
Visual Basic 6.0 Visual Basic 6.0Visual Basic 6.0 2-5 3. 2-6 4. _UpgradeReport.htm Interface Corporation - 62 -
2-7 Visual Basic Visual Basic 4.0Visual Studio.NET Visual Basic Visual BasicVisual C#.NETStandard Edition DLL.NET Framework Visual Basic 6.0-63 - Interface Corporation
Visual Basic 6.0 MicrosoftMSDN 2.3.2 アップグレードウィザードのエラー Visual Basic 6.0 Visual Basic 6.0 2-8 1.Visual Basic 6.0 2.- 2-9 Interface Corporation - 64 -
COMCTRL32.OCXDBCRID32.OCX Microsoft Windows Common Controls 5.0(SP2) Microsoft Data Bound Grid Control 5.0(SP3) 3.OK Visual Basic 6.0 Visual Studio.NET - 65 - Interface Corporation
第 3 章 Visual C#.NET への移行 BPC-0818C# Visual C#.NET Visual Basic.NET Visual Basic.NET MSDN C#DLL C# BPC-0818 BPC-0818 3.1 クラスライブラリ BPC-0818 3-1 DLL GPC-2000 IFCDIOIFCDIO.DLL GPC-3100 IFCADIFCAD.DLL GPC-3300 IFCDAIFCDA.DLL GPIBGPC-4301 DLL IFCGPIBIFCGPIB.DLL GPIBGPC-4301 DLL IFCGPIBEXIFCGPIBEX.DLL Interface Corporation - 66 -
3.2 クラスライブラリの参照設定 C# 1.Visual Studio.NET 2.-- 3.Visual C# Windows OK 3-1 - 67 - Interface Corporation
4.- 3-2 5. DLL BPC-0818DLL DLL 3-2 GPC-2000 GPC-3100 GPC-3300 GPIB GPC-4301 GPIB GPC-4301 DLL Interface BPC0818 GPC2000 CLASS DLL IFCDIO.DLL Interface BPC0818 GPC3100 CLASS DLL IFCAD.DLL Interface BPC0818 GPC3300 CLASS DLL IFCDA.DLL Interface BPC0818 GPC4301 CLASS DLL IFCGPIB.DLL Interface BPC0818 GPC4301 CLASS DLL IFCGPIBEX.DLL DLL OK Interface Corporation - 68 -
3-3 DLL 6. DLL 3-4 C# - 69 - Interface Corporation
3.3 クラスライブラリの関数を呼び出す BPC-0818 3-3 namespace GPC-2000 InterfaceCorpDllWrap IFCDIO GPC-3100 InterfaceCorpDllWrap IFCAD GPC-3300 InterfaceCorpDllWrap IFCDA GPC-4301DLL InterfaceCorpDllWrap IFCGPIB GPC-4301DLL InterfaceCorpDllWrap IFCGPIBEX using BPC-0818InterfaceCorpDllWrap List 3-1 using InterfaceCorpDllWrap;. List 3-2 GPC-2000 InputPoint IFCDIO.DioInputPoint(hSavedDevice,out nbuffer,dwstartnum,1); List 3-3 GPC-3100 AdInputAD IFCAD.AdInputAD(ghDeviceHandle,ulCh, gconfig.ulsinglediff, SmplChInf, wsmpdata); List 3-4 GPC-3300 DaOutputDA IFCDA.DaOutputDA(ghDeviceHandle, ulch, SmplChInf, wdata); List 3-5 GPC-4301 DLL GpibReceive IFCGPIB.GpibReceive(nBoardNo, DevAdrsTbl, ref RecvLen, out RecvBuffer); List 3-6 GPC-4301 DLL PciGpibExMastRecvData IFCGPIBEX.PciGpibExMastRecvData(nBoardNo, DevAdrsTbl, ref RecvLen, out RecvBuffer, 0); GPC GPC Interface Corporation - 70 -
. List 3-7 GPC-2000 IFCDIO.FBIDIO_ERROR_SUCCESS List 3-8 GPC-3100 IFCAD.ADSMPLCHREQ[ ] SmplChInf = new IFCAD.ADSMPLCHREQ[2]; List 3-9 GPC-3100 IFCAD.AD_ERROR_SUCCESS List 3-10 GPC-3300 IFCDA.DASMPLCHREQ[ ] SmplChInf = new IFCDA.DASMPLCHREQ[2]; List 3-11 GPC-3300 IFCDA.DA_ERROR_SUCCESS List 3-12 GPC-4301DLL IFCGPIB.GPIB_SUCCESS List 3-13 GPC-4301DLL IFCGPIBEX.GPIB_SUCCESS - 71 - Interface Corporation
1 List 3-14 GPC-2000DioInputPoint InpointInBox.cs using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using InterfaceCorpDllWrap; namespace InPoint { public class InBox : System.Windows.Forms.Form { private System.Windows.Forms.Button button1; private System.Windows.Forms.Button button2; private void button1_click(object sender, System.EventArgs e) { int nret; int nbuffer; uint dwstartnum; } nret = IFCDIO.DioInputPoint(hSavedDevice,out nbuffer,dwstartnum,1); if (nret!= IFCDIO.FBIDIO_ERROR_SUCCESS) { MessageBox.Show("Failed to input the data.", "InPoint_Cs",MessageBoxButtons.OK,MessageBoxIcon.Error); } } } Interface Corporation - 72 -
List 3-15 GPC-3100AdInputAD AdSmpl_CsSamplingForm.cs using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using InterfaceCorpDllWrap; namespace AdSmpl_Cs { public class SamplingForm : System.Windows.Forms.Form { private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label2; private void button1_click(object sender, System.EventArgs e) { uint[ ] ghchannel = new uint[2]; IFCAD.ADSMPLCHREQ[ ] SmplChInf = new IFCAD.ADSMPLCHREQ[2]; byte[ ] bsmpdata = new byte[2]; ushort[ ] wsmpdata = new ushort[2]; gnerrcode = IFCAD.AdInputAD(ghDeviceHandle, ulch, gconfig.ulsinglediff, SmplChInf, wsmpdata); if (gnerrcode == IFCAD.AD_ERROR_SUCCESS) { } } } } - 73 - Interface Corporation
List 3-16 GPC-3300DAOutputDA DaSmpl_CsSamplingForm.cs using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using InterfaceCorpDllWrap; namespace DaSmpl_Cs { public class SamplingForm : System.Windows.Forms.Form { private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label2; private void buttonstart_click(object sender, System.EventArgs e) { uint[ ] ghchannel = new uint[2]; IFCDA.DASMPLCHREQ[ ] SmplChInf = new IFCDA.DASMPLCHREQ[2]; ushort[ ] wdata = new ushort[2]; uint ulch; } // Output one analog data on the board. gnerrcode = IFCDA.DaOutputDA(ghDeviceHandle, ulch, SmplChInf, wdata); if (gnerrcode!= IFCDA.DA_ERROR_SUCCESS) { } } } Interface Corporation - 74 -
List 3-17 GPC-4301 DLLGpibReceive Ctrl_Cs2ReceiveForm.cs using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using InterfaceCorpDllWrap; namespace Ctrl_Cs2 { public class ReceiveForm : System.Windows.Forms.Form { private System.Windows.Forms.Label label1; private System.Windows.Forms.TextBox textboxdata; private void buttonreceive_click(object sender, System.EventArgs e) { int nret; string RecvBuffer = ""; int[ ] DevAdrsTbl = new int [2]; uint RecvLen; // DevAdrsTbl[0] = DevAdrs; DevAdrsTbl[1] = -1; // RecvLen = 64; nret = IFCGPIB.GpibReceive(nBoardNo, DevAdrsTbl, ref RecvLen, out RecvBuffer); if(nret!= 0) { CtrlCs2Form.DsplyErrMessage(nRet); return; } } CtrlCs2Form.DsplyErrMessage(nRet); textboxdata.text = RecvBuffer; } } - 75 - Interface Corporation
List 3-18 GPC-4301 DLLPciGpibExMastRecvData Ctrl_CsReceiveForm.cs using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using InterfaceCorpDllWrap; namespace Ctrl_Cs { public class ReceiveForm : System.Windows.Forms.Form { private System.Windows.Forms.Label label1; private System.Windows.Forms.TextBox textboxdata; private void buttonreceive_click(object sender, System.EventArgs e) { int nret; string RecvBuffer = ""; uint RecvLen; int[ ] DevAdrsTbl = new int[2]; // Configures the device address table. DevAdrsTbl[0] = DevAdrs; DevAdrsTbl[1] = -1; } // Sends data to specified device. RecvLen = 64; nret = IFCGPIBEX.PciGpibExMastRecvData(nBoardNo, DevAdrsTbl, ref RecvLen, out RecvBuffer, 0); CtrlCsForm.DsplyErrMessage(nRet); if(nret!= 0) { return; } textboxdata.text = RecvBuffer; } } Interface Corporation - 76 -
3.4 クラスライブラリのソースファイル BPC-0818 3-4 GPC-2000 GPC-3100 GPC-3300 GPIB GPC-4301 DLL GPIB GPC-4301 DLL Interface BPC0818 GPC2000 CLASS IFCDIO Interface BPC0818 GPC3100 CLASS IFCAD Interface BPC0818 GPC3300 CLASS IFCDA Interface BPC0818 GPC4301 CLASS IFCGPIB Interface BPC0818 GPC4301 CLASS IFCGPIBEX Visual Studio.NET-- C#.csproj 3.5 カテゴリ別プログラム作成方法 BPC-0818 using - 77 - Interface Corporation
3.5.1 GPC-2000 List 3-19 DioOpen [DllImport("fbidio.dll")] public static extern uint DioOpen( string lpszname, uint fdwflags ); List 3-20 DioOpen uint hdevice; hdevice = IFCDIO.DioOpen( FBIDIO1,IFCDIO.FBIDIO_FLAG_SHARE); 1 DioInputPointint int2 intint List 3-21 DioInputPoint [DllImport("fbidio.dll")] public static extern int DioInputPoint( uint hdevice, out int pbuffer, uint dwstartnum, uint dwnum ); [DllImport("fbidio.dll")] public static extern int DioInputPoint( uint hdevice, int[ ] pbuffer, uint dwstartnum, uint dwnum ); List 3-22 DioInputPoint1 int nret; int nbuffer; nret = IFCDIO.DioInputPoint(hDevice,out nbuffer,1,1); List 3-23 DioInputPoint int nret; int[ ] nbuffer = new int[64]; nret = IFCDIO.DioInputPoint(hDevice,nBuffer,1,64); List 3-24 DioClose [DllImport("fbidio.dll")] public static extern int DioClose( uint hdevice ); Interface Corporation - 78 -
List 3-25 DioClose int nret; nret = IFCDIO.DioClose(hDevice); 3.5.2 GPC-3100 ADSMPLREQ ADSMPLREQ SetChNo GetChNoSetRangeNoGetRangeNo InitializeArray List 3-26 ADSMPLREQ [StructLayout(LayoutKind.Sequential)] public struct ADSMPLREQ { public uint ulchcount; [MarshalAs(UnmanagedType.ByValArray, SizeConst=512)] public uint[ ] ulchnorange; public uint ulsamplingmode; public uint ulsinglediff; public uint ulsmplnum; public uint ulsmpleventnum; public float fsmplfreq; public uint ultrigpoint; public uint ultrigmode; public int ltrigdelay; public uint ultrigch; public float ftriglevel1; public float ftriglevel2; public uint uleclkedge; public uint ulatrgpulse; public uint ultrigedge; public uint ultrigdi; public uint ulfastmode; public void InitializeArray() - 79 - Interface Corporation
{ } ulchnorange = new uint [512]; public void SetChNo(uint ulindex, uint ulnumber) { ulchnorange[ulindex * 2] = ulnumber; } public uint GetChNo(uint ulindex) { return(ulchnorange[ulindex * 2]); } public void SetChRange(uint ulindex, uint ulrange) { ulchnorange[(ulindex * 2) + 1] = ulrange; } public uint GetChRange(uint ulindex) { return(ulchnorange[(ulindex * 2) + 1]); } } ADSMPLREQInitializeArray List 3-27 ADSMPLREQ ADSMPLREQ gconfig; gconfig.initializearray(); List 3-28 AdOpen [DllImport("fbiad.dll")] public static extern uint AdOpen(string szname); List 3-29 AdOpen uint hdevice; hdevice = IFCAD.AdOpen( FBIAD1 ); 1 AdInputADByte ushortuint Interface Corporation - 80 -
Visual C#.NET List 3-30 AdInputAD [DllImport("fbiad.dll")] public static extern int AdInputAD(uint hdevice, uint ulch, uint ulsinglediff, ref ADSMPLCHREQ AdSmplChReq, out byte lpdata); [DllImport("fbiad.dll")] public static extern int AdInputAD(uint hdevice, uint ulch, uint ulsinglediff, ref ADSMPLCHREQ AdSmplChReq, out ushort lpdata); [DllImport("fbiad.dll")] public static extern int AdInputAD(uint hdevice, uint ulch, uint ulsinglediff, ref ADSMPLCHREQ AdSmplChReq, out uint lpdata); [DllImport("fbiad.dll")] public static extern int AdInputAD(uint hdevice, uint ulch, uint ulsinglediff, ADSMPLCHREQ[ ] AdSmplChReq, byte[ ] lpdata); [DllImport("fbiad.dll")] public static extern int AdInputAD(uint hdevice, uint ulch, uint ulsinglediff, ADSMPLCHREQ[ ] AdSmplChReq, ushort[ ] lpdata); [DllImport("fbiad.dll")] public static extern int AdInputAD(uint hdevice, uint ulch, uint ulsinglediff, ADSMPLCHREQ[ ] AdSmplChReq, uint[ ] lpdata); List 3-31 AdInputAD uint[ ] ghchannel = new uint[2]; IFCAD.ADSMPLCHREQ[ ] SmplChInf = new IFCAD.ADSMPLCHREQ[2]; ushort[ ] wsmpdata = new ushort[2]; uint ulch; int nerrcode = -1; nerrcode = IFCAD.AdInputAD(hDevice, ulch, gconfig.ulsinglediff, SmplChInf, wsmpdata); List 3-32AdClose [DllImport("fbiad.dll")] public static extern int AdClose(uint hdevice); List 3-33 AdClose uint nret; nret = IFCAD.AdClose(hDevice); - 81 - Interface Corporation
3.5.3 GPC-3300 DASMPLREQ DASMPLREQ SetChNo GetChNoSetRangeNoGetRangeNo InitializeArray List 3-34 DASMPLREQ [StructLayout(LayoutKind.Sequential)] public struct DASMPLREQ { public uint ulchcount; [MarshalAs(UnmanagedType.ByValArray, SizeConst=512)] public uint[ ] ulchnorange; public uint ulsamplingmode; public float fsmplfreq; public uint ulsmplrepeat; public uint ultrigmode; public uint ultrigpoint; public uint ultrigdelay; public uint uleclkedge; public uint ultrigedge; public uint ultrigdi; public void InitializeArray() { ulchnorange = new uint [512]; } public void SetChNo(uint ulindex, uint ulnumber) { ulchnorange[ulindex * 2] = ulnumber; } public uint GetChNo(uint ulindex) { return(ulchnorange[ulindex * 2]); Interface Corporation - 82 -
} } public void SetChRange(uint ulindex, uint ulrange) { ulchnorange[(ulindex * 2) + 1] = ulrange; } public uint GetChRange(uint ulindex) { return(ulchnorange[(ulindex * 2) + 1]); } DASMPLREQInitializeArray List 3-35 DASMPLREQ DASMPLREQ gconfig; gconfig.initializearray(); List 3-36 DaOpen [DllImport("fbida.dll")] public static extern uint DaOpen(string szdevice); List 3-37 DaOpen uint hdevice; hdevice = IFCDA.DaOpen( FBIDA1 ); 1 DaOutputDA Byteushortuint Visual C#.NET - 83 - Interface Corporation
List 3-38 DaOutputDA [DllImport("fbida.dll")] public static extern int DaOutputDA(uint hdevice, uint nch, ref DASMPLCHREQ DaSmplChReq, ref byte pdata); [DllImport("fbida.dll")] public static extern int DaOutputDA(uint hdevice, uint nch, ref DASMPLCHREQ DaSmplChReq, ref ushort pdata); [DllImport("fbida.dll")] public static extern int DaOutputDA(uint hdevice, uint nch, ref DASMPLCHREQ DaSmplChReq, ref uint pdata); [DllImport("fbida.dll")] public static extern int DaOutputDA(uint hdevice, uint nch, DASMPLCHREQ[ ] DaSmplChReq, byte[ ] pdata); [DllImport("fbida.dll")] public static extern int DaOutputDA(uint hdevice, uint nch, DASMPLCHREQ[ ] DaSmplChReq, ushort[ ] pdata); [DllImport("fbida.dll")] public static extern int DaOutputDA(uint hdevice, uint nch, DASMPLCHREQ[ ] DaSmplChReq, uint[ ] pdata); List 3-39 DaOutputDA uint[ ] ghchannel = new uint[2]; IFCDA.DASMPLCHREQ[ ] SmplChInf = new IFCDA.DASMPLCHREQ[2]; ushort[ ] wdata = new ushort[2]; uint ulch; int nerrcode = -1; nerrcode = IFCDA.DaOutputDA(hDevice, ulch, SmplChInf, wdata); List 3-40 DaClose [DllImport("fbida.dll")] public static extern int DaClose(uint hdevice); List 3-41 DaClose int nret; nret = IFCDA.DaClose(hDevice); Interface Corporation - 84 -
3.5.4 GPC-4301 標準版 DLL List 3-42 GpibOpen [DllImport("gpc43042.dll")] public static extern int GpibOpen(uint ulboardno); List 3-43 GpibOpen int nret; nret = IFCGPIB.GpibOpen(1); GpibSetConfigGpibSetIfcGpibSetRen List 3-44 GpibSetConfigGpibSetIfcGpibSetRen [DllImport("gpc43042.dll")] public static extern int GpibSetConfig(uint ulboardno, string pparam); [DllImport("gpc43042.dll")] public static extern int GpibSetIfc(uint ulboardno); [DllImport("gpc43042.dll")] public static extern int GpibSetRen(uint ulboardno); List 3-45 GpibSetConfigGpibSetIfcGpibSetRen int nret; string szsetprm; // szsetprm = "/SRT=600 /TMO=600 /SDELIM=CRLF+EOI /RDELIM= CRLF+EOI ; nret = IFCGPIB.GpibSetConfig(1, szsetprm); if (nret!= 0) { return; } // IFC nret = IFCGPIB.GpibSetIfc(1); if (nret!= 0) { return; } // REN nret = IFCGPIB.GpibSetRen(1); if(nret!= 0) { - 85 - Interface Corporation
} return; GpibSendByteByte StringIntPtr List 3-46 GpibSend [DllImport("gpc43042.dll")] public static extern int GpibSend(uint ulboardno, int[ ] lpadrstbl, uint dwlength, pvbuffer); ref byte [DllImport("gpc43042.dll")] public static extern int GpibSend(uint ulboardno, int[ ] lpadrstbl, uint dwlength, byte[ ] pvbuffer); [DllImport("gpc43042.dll")] public static extern int GpibSend(uint ulboardno, int[ ] lpadrstbl, uint dwlength, string pvbuffer); [DllImport("gpc43042.dll")] public static extern int GpibSend(uint ulboardno, int[ ] lpadrstbl, uint dwlength, IntPtr pvbuffer); List 3-47 GpibSendString int nret = 0; string szdata = "*RST"; uint ulen; int[ ] DevAdrsTbl = new int [2]; // DevAdrsTbl[0] = 22; DevAdrsTbl[1] = -1; // ulen = (uint)szdata.length; nret = IFCGPIB.GpibSend(1, DevAdrsTbl,uLen, szdata); GpibReceiveByteByte StringIntPtr StringGpibReceiveByteString Interface Corporation - 86 -
List 3-48 GpibReceive [DllImport("gpc43042.dll")] public static extern int GpibReceive(uint ulboardno, int[ ] lpadrstbl, ref uint dwplength, ref byte pvbuffer); [DllImport("gpc43042.dll")] public static extern int GpibReceive(uint ulboardno, int[ ] lpadrstbl, ref uint dwplength, byte[ ] pvbuffer); public static int GpibReceive(uint ulboardno, int[ ] lpadrstbl, ref uint dwplength, ref string pvbuffer) { uint nlength = dwplength; int nret; ASCIIEncoding e = new ASCIIEncoding(); byte[ ] szdata= new byte [dwplength]; } pvbuffer = ""; nret = GpibReceive(ulBoardNo, lpadrstbl, ref nlength, szdata); if(nret == 0) { pvbuffer = e.getstring(szdata,0,(int)nlength); dwplength = (uint)pvbuffer.length; } return nret; [DllImport("gpc43042.dll")] public static extern int GpibReceive(uint ulboardno, int[ ] lpadrstbl, ref uint dwplength, IntPtr pvbuffer); List 3-49 GpibReceiveString int nret = 0; string RecvBuffer = ""; int[ ] DevAdrsTbl = new int [2]; uint RecvLen; // DevAdrsTbl[0] = 22; DevAdrsTbl[1] = -1; // RecvLen = 64; nret = IFCGPIB.GpibReceive(1, DevAdrsTbl, ref RecvLen, out RecvBuffer); if(nret!= 0) { return; } - 87 - Interface Corporation
List 3-50 GpibClose [DllImport("gpc43042.dll")] public static extern int GpibClose(uint ulboardno); List 3-51 GpibClose int nret; nret = IFCGPIB.GpibClose(1); 3.5.5 GPC-4301 高機能版 DLL List 3-52 PciGpibExInitBoard [DllImport("gpc4304.dll")] public static extern int PciGpibExInitBoard(int nboardno, uint hwnd); List 3-53 PciGpibExInitBoard int nret; nret = IFCGPIBEX.PciGpibExInitBoard(1, 0); PciGpibExSetConfigPciGpibExSetIfcPciGpibExSetRen List 3-54 PciGpibExSetConfigPciGpibExSetIfcPciGpibExSetRen [DllImport("gpc4304.dll")] public static extern int PciGpibExSetConfig(int nboardno, string szprm); [DllImport("gpc4304.dll")] public static extern int PciGpibExSetIfc(int nboardno, int ntime); [DllImport("gpc4304.dll")] public static extern int PciGpibExSetRen(int nboardno); Interface Corporation - 88 -
List 3-55 PciGpibExSetConfigPciGpibExSetIfcPciGpibExSetRen int nret; string szsetprm; // szsetprm = "/STM=600 /SRT=600 /TMO=600 /SDELIM=CRLF+EOI /RDELIM=CRLF+EOI ; nret = IFCGPIBEX.PciGpibExSetConfig(1, szsetprm); if( nret!= 0) { return; } // IFC nret = IFCGPIBEX.PciGpibExSetIfc(1, 1); if( nret!= 0) { return; } // REN nret = IFCGPIBEX.PciGpibExSetRen(1); if( nret!= 0) { return; } PciGpibExMastSendData ByteByteStringIntPtr List 3-56 PciGpibExMastSendData [DllImport("gpc4304.dll")] public static extern int PciGpibExMastSendData(int nboardno, int[ ] npadrstbl, uint dwlength, ref byte pvbuffer, uint umsg); [DllImport("gpc4304.dll")] public static extern int PciGpibExMastSendData(int nboardno, int[ ] npadrstbl, uint dwlength, byte[ ] pvbuffer, uint umsg); [DllImport("gpc4304.dll")] public static extern int PciGpibExMastSendData(int nboardno, int[ ] npadrstbl, uint dwlength, string pvbuffer, uint umsg); [DllImport("gpc4304.dll")] public static extern int PciGpibExMastSendData(int nboardno, int[ ] npadrstbl, uint dwlength, IntPtr pvbuffer, uint umsg); - 89 - Interface Corporation
List 3-57 PciGpibExMastSendDataString int nret = 0; string szdata = *RST ; uint ulen; int[ ] DevAdrsTbl = new int [2]; // Configures the device address table. DevAdrsTbl[0] = 22; DevAdrsTbl[1] = -1; // Sends data to specified device. ulen = (uint)szdata.length; nret = IFCGPIBEX.PciGpibExMastSendData(1, DevAdrsTbl, ulen, szdata, 0); PciGpibExMastRecvData ByteByteStringIntPtr StringGpibReceiveByteString List 3-58 PciGpibExMastRecvData [DllImport("gpc4304.dll")] public static extern int PciGpibExMastRecvData(int nboardno, int[ ] npadrstbl, ref uint dwplength, ref byte pvbuffer, uint umsg); [DllImport("gpc4304.dll")] public static extern int PciGpibExMastRecvData(int nboardno, int[ ] npadrstbl, ref uint dwplength, byte[ ] pvbuffer, uint umsg); public static int PciGpibExMastRecvData(int nboardno, int[ ] npadrstbl, ref uint dwplength, out string pvbuffer, uint umsg) { uint nlength = dwplength; int nret; ASCIIEncoding e = new ASCIIEncoding(); byte[ ] szdata= new byte [dwplength]; pvbuffer = ""; nret = PciGpibExMastRecvData(nBoardNo, npadrstbl, ref nlength, szdata, umsg); Interface Corporation - 90 -
} if(nret == 0) { pvbuffer = e.getstring(szdata,0,(int)nlength); dwplength = (uint)pvbuffer.length; } return nret; [DllImport("gpc4304.dll")] public static extern int PciGpibExMastRecvData(int nboardno, int[ ] npadrstbl, ref uint dwplength, IntPtr pvbuffer, uint umsg); List 3-59 PciGpibExMastRecvDataString int nret = 0; string RecvBuffer = ""; uint RecvLen; int[ ] DevAdrsTbl = new int[2]; // DevAdrsTbl[0] = 22; DevAdrsTbl[1] = -1; // RecvLen = 64; nret = IFCGPIBEX.PciGpibExMastRecvData(1, DevAdrsTbl, ref RecvLen, out RecvBuffer, 0); CtrlCsForm.DsplyErrMessage(nRet); if(nret!= 0) { return; } List 3-60 PciGpibExFinishBoard [DllImport("gpc4304.dll")] public static extern int PciGpibExFinishBoard(int nboardno); List 3-61 PciGpibExFinishBoard int nret; nret = IFCGPIBEX.PciGpibExFinishBoard(nBoardNo); - 91 - Interface Corporation
3.6 サンプルプログラム一覧 BPC-0818C# 3-5 GPC-2000 Inpoint 1 Outpoint 1 GPC-3100 AdSmpl_Cs GPC-3300 DaSmpl_Cs GPC-4301 Ctrl_Cs2 DLL GPC-4301 Ctrl_Cs DLL Device_Cs YOKOGAWA7561, HP3458A Manualop MultiDevice Visual Studio.NET-- C#.csproj Interface Corporation - 92 -
第 4 章.NET 技術情報 4.1 DLL 呼び出しの概要 DLLVisual Studio.NET Visual Studio.NETDLL 4.1.1 マネージコードとアンマネージコード Microsoft.NET Framework Visual Basic.NETVisual C#.NET.NET Framework COM ActiveX Win32 API DLL Visual Basic.NET Visual C#.NET Visual Basic 6.0.NET Framework DLL ActiveX 4-1 - 93 - Interface Corporation
4.1.2 プラットフォーム呼び出し DLLVisual Basic.NETVisual C#.NET Win32APIDLL DLL DLL DLL 4-2 Interface Corporation - 94 -
4.2 DLL 関数呼び出し方法 DLL [Step1] DLLDLL [Step2] DLL [Step3] DLL DLL DLL [Step4]DLL 4.2.1 DLL およびその DLL が提供する関数を識別するための情報 DLL DLL PCI/CompactPCI/CardBusWindowsGPC DLL Visual BasicVisual Basic DLL List 4-1 Visual Basic 6.0 GPC-2000 Declare Function DioInputPoint Lib "FbiDio.DLL" (ByVal hdevicehandle As Long, _ ByRef pbuffer As Long, ByVal dwstartnum As Long, ByVal dwnum As Long) As Long 1) DLL Visual Basic.NET DLL Visual Basic - 95 - Interface Corporation
4.2.2 DLL 関数を保持するクラスを作成します C# Visual Basic DLL Visual Basic DLLDLL DLL List 4-2 Visual Basic.NET Imports System.Runtime.InteropServices Public Class IFCDio Declare Function DioOpen Lib "FbiDio.DLL" (ByVal lpszname As String,_ End Class ByVal fdwattrs As Integer) As Integer DLL DLL DLL 1 4.2.3 マネージコードでのプロトタイプ宣言の記述 DLL.NET Framework Visual Basic.NETVisual Basic 6.0 Interface Corporation - 96 -
4-1 Visual Basic 6.0 Visual Basic.NET C# C++ 16 Integer Short short short 32 Long Integer int int 64 (none) Long Long _int64 [Visual Basic] Declare Function Lib GPC-2000 GPC-2000FbiDio.DLL List 4-3 Visual Basic.NET Imports System.Runtime.InteropServices Declare Function DioOpen Lib "FbiDio.DLL" (ByVal lpszname As String,_ ByVal fdwattrs As Integer) As Integer Declare Function DioClose Lib "FbiDio.DLL" (ByVal hdevicehandle As Integer)_ As Integer Declare Function DioInputPoint Lib "FbiDio.DLL" (ByVal hdevicehandle As Integer,_ ByRef pbuffer As Integer, ByVal dwstartnum As Integer,_ ByVal dwnum As Integer) As Integer DllImportAttribute Shared Function Visual Basic.NETDllImportAttributeMicrosoft - 97 - Interface Corporation
[C#] DllImportAttribute DLL static extern List 4-4 Visual C#.NET using System.Runtime.InteropServices; [DllImport("fbidio.dll")] public static extern int DioOpen( string lpszname, uint fdwflags ); [C++] DllImportAttribute DLL extern "C" List 4-5 Visual C++.NET using namespace System::Runtime::InteropServices; [DllImport("fbidio.dll")] extern "C" HANDLE DioOpen( LPCTSTR lpszname, DWORD fdwflags ); Visual C++.NET DllImportAttributeVisual C++ 6.0 DLL Interface Corporation - 98 -
4.2.4 DLL 関数の呼び出し DLL [Visual Basic] List 4-6 DLL Imports System.Runtime.InteropServices Public Const FBIDIO_FLAG_SHARE As Integer = &H2 Imports System.Runtime.InteropServices Public Class IFCDio Declare Function DioOpen Lib "FbiDio.DLL" (ByVal lpszname As String,_ ByVal fdwattrs As Integer) As Integer Declare Function DioClose Lib "FbiDio.DLL" (ByVal hdevicehandle As Integer)_ As Integer Declare Function DioInputPoint Lib "FbiDio.DLL" (ByVal hdevicehandle As Integer,_ ByRef pbuffer As Integer, ByVal dwstartnum As Integer,_ ByVal dwnum As Integer) As Integer End Class Public Class DigitalInput Public Shared Sub Main() Dim nret As Integer Dim hdevicehandle As Integer Dim lpszname As String hdevicehandle = IFCDio.DioOpen(lpszName, FBIDIO_FLAG_SHARE) If hdevicehandle = -1 Then nret = MessageBox.Show ("Failed to open the device.", _ "DioOpen",MessageBoxButtons.OK,MessageBoxIcon.Error) EndIf End Sub End Class - 99 - Interface Corporation
4.3 その他の注意事項と追加情報 Visual Basic.NET 4.3.1 Declare ステートメントは As Any 型のパラメータをサポートしない Visual Basic 6.0 Declare As Any As Any Visual Basic.NET As Any Visual Basic 6.0 As Any As Any Visual Basic.NET MSDN 4.3.2 明示的なマーシャリングが必要となる場合 MSDN Interface Corporation - 100 -
1 4.3.3 構造体を使用する場合の注意点 DLL StructLayoutAttribute StructLayoutAttribute AutomaticSequential Explicit 4-2 LayoutKind.Automatic LayoutKind.Explicit LayoutKind.Sequential FieldOffset MSDN StructLayoutAttribute FieldOffsetAttribute - 101 - Interface Corporation
StructLayoutAttribute MYSTRUC MyLib.dll MyFunc typedef struct _mystruc { int a; int b; }MYSTRUC; BOOL MyFunc(MYSTRUC *lpmystc); MYSTRUC [Visual Basic] List 4-7 Visual Basic.NET Imports System.Runtime.InteropServices <StructLayout(LayoutKind.Sequential)> Public Structure MyStruc Public a As Integer Public b As Integer End Structure Class MyAPI Declare Auto Function MyFunc Lib " MyLib.dll" _ (ByRef lpmystc As MYSTRUC) As Boolean End Class MyStrucLayoutKind.Explicit List 4-8 Explicit Visual Basic.NET <StructLayout(LayoutKind.Explicit)> Public Structure MyStruc <FieldOffset(0)> Public a As Integer <FieldOffset(4)> Public b As Integer End Structure Interface Corporation - 102 -
[C#] List 4-9 Visual C#.NET using System.Runtime.InteropServices; [StructLayout(LayoutKind.Sequential)] public struct MYSTRUC { public int a; public int b; } class MyAPI { [DllImport("MyLib.dll")] public static extern Bool PtInRect(ref MYSTRUC lpmystc); } MyStrucLayoutKind.Explicit List 4-10 Explicit Visual C#.NET [StructLayout(LayoutKind. Explicit)] public struct MYSTRUC { } [FieldOffset(0)] public int a; [FieldOffset(4)] public int b; - 103 - Interface Corporation
4.3.4 構造体の中の構造体配列 (GPC-3100 の例 ) GPC-3100ADSMPLREQ ADSMPLREQADSMPLCHREQ256 2 1 2 1 GPC-3100ADSMPLREQADSMPLCHREQ256 2 ADSMPLCHREQ32bit List 4-11 ADSMPLCHREQ <StructLayout(LayoutKind.Sequential)> Structure ADSMPLCHREQ Dim ulchno As Integer Dim ulrange As Integer End Structure Interface Corporation - 104 -
ADSMPLCHREQ2ADSMPLREQ List 4-12 ADSMPLREQ <StructLayout(LayoutKind.Sequential)> Structure ADSMPLREQ Dim ulchcount As Integer Dim ulchno1 As Integer Dim ulrange1 As Integer Dim ulchno2 As Integer Dim ulrange2 As Integer <MarshalAs(UnmanagedType.ByValArray, SizeConst:=508)> _ Dim dummy() As Integer Dim ulsamplingmode As Integer Dim ulsinglediff As Integer Dim ulsmplnum As Integer Dim ulsmpleventnum As Integer Dim fsmplfreq As Single Dim ultrigpoint As Integer Dim ultrigmode As Integer Dim ltrigdelay As Integer Dim ultrigch As Integer Dim ftriglevel1 As Single Dim ftriglevel2 As Single Dim uleclkedge As Integer Dim ulatrgpulse As Integer Dim ultrigedge As Integer Dim ultrigdi As Integer Dim ulfastmode As Integer End Structure List 4-13 ADSMPLREQ gconfig.ulchno1 = 1 gconfig.ulrange1 = AD_1V gconfig.ulchno2 = 2 gconfig.ulrange2 = AD_1V nret = AdSetSamplingConfig(ghDeviceHandle, gconfig) - 105 - Interface Corporation
2 Visual Basic.NET ADSMPLREQ List 4-14 ADSMPLREQ <StructLayout(LayoutKind.Sequential)> Structure ADSMPLREQ Dim ulchcount As Integer <MarshalAs(UnmanagedType.ByValArray, SizeConst:=512)> _ Dim ulchnorange() As Integer Dim ulsamplingmode As Integer Dim ulsinglediff As Integer Dim ulsmplnum As Integer Dim ulsmpleventnum As Integer Dim fsmplfreq As Single Dim ultrigpoint As Integer Dim ultrigmode As Integer Dim ltrigdelay As Integer Dim ultrigch As Integer Dim ftriglevel1 As Single Dim ftriglevel2 As Single Dim uleclkedge As Integer Dim ulatrgpulse As Integer Dim ultrigedge As Integer Dim ultrigdi As Integer Dim ulfastmode As Integer Public Sub New(ByVal Dummy As Integer) ReDim ulchnorange(511) End Sub Public Sub SetChNo(ByVal ulindex As Integer, ByVal ulnumber As Integer) End Sub ulchnorange(ulindex * 2) = ulnumber Public Function GetChNo(ByVal ulindex As Integer) As Integer GetChNo = ulchnorange(ulindex * 2) End Function Public Sub SetRange(ByVal ulindex As Integer, ByVal ulrange As Integer) Interface Corporation - 106 -
End Sub ulchnorange((ulindex * 2) + 1) = ulrange Public Function GetRange(ByVal ulindex As Integer) As Integer GetRange = ulchnorange((ulindex * 2) + 1) End Function End Structure List 4-15ADSMPLREQ gconfig.setchno(0, 1) gconfig.setchno(1, 2) gconfig.setrange(0, AD_1V) gconfig.setrange(1, AD_1V) nret = AdSetSamplingConfig(ghDeviceHandle, gconfig) 4.3.5 固定長文字列 Visual Basic.NET DLL StringBuilder DLLNULLStringBuilder StringBuilderMicrosoft GPIBGPC-4301GpibReceive PciGpibExMastRecvDataPciGpibExSlavRecvData NULL StringBuilder Byte - 107 - Interface Corporation
4.3.6 文字エンコード.NET FrameworkUnicode Unicode1216.NET Framework Unicode Unicode ASCIIEncoding CodePageEncoding UnicodeEncoding UTF7Encoding UTF8Encoding DLLByteASCII Unicode Visual Basic.NETVisual C#.NETASCIIEncoding ASCIIUnicode GPC-4301 DLL GpibReceive GpibReceiveGPIB ByteASCII.NET FrameworkUnicode ASCIIEncoding Interface Corporation - 108 -
[Visual Basic] List 4-16 GpibReceiveByte Declare Function GpibReceive Lib "GPC43042.DLL" (ByVal ulboardno As Integer, ByVal lpadrstbl() As Integer, ByRef ulplength As Integer, ByVal vpbuffer() As Byte) As Integer ASCIIUnicodeString List 4-17 Visual Basic Dim nlength As Integer Dim nret As Integer Dim szbuffer As String Dim e As ASCIIEncoding = New ASCIIEncoding() Dim bdata(63) As Byte int[ ] DevAdrsTbl = new int [2]; szbuffer = "" DevAdrsTbl(0) = 22 DevAdrsTbl(1) = -1 nlength = 64 nret = GpibReceive(1, DevAdrsTbl, nlength, bdata) If (nret = 0) Then szbuffer = e.getstring(bdata, 0, nlength) End If [C#] List 4-18 GpibReceiveByte [DllImport("gpc43042.dll")] public static extern int GpibReceive(uint ulboardno, int[ ] lpadrstbl, ref uint dwplength, byte[ ] pvbuffer); ASCIIUnicodeString List 4-19 C# uint ulength = 64; int nret; string szbuffer = ; ASCIIEncoding e = new ASCIIEncoding(); byte[ ] bdata= new byte [64]; int[ ] DevAdrsTbl = new int [2]; DevAdrsTbl[0] = 22; DevAdrsTbl[1] = -1; nret = GpibReceive(1, DevAdrsTbl, ref ulength, bdata); if(nret == 0) { szbuffer = e.getstring(bdata,0,(int)ulength); } - 109 - Interface Corporation
4.3.7 デリゲートオブジェクトを使用したコールバック処理 DLL DLL DLL Visual Basic.NETC#.NET DLL.NET Framework DLL Step1DLL DLL Step2 Step3DLL DLL DLL DLL Interface Corporation - 110 -
[Visual Basic] GPC-4301 DLLGpibSetSrqEvent Step1DLL CGpibSetSrqEvent List 4-20 #define LPSRQCALLBACK VOID WINAPI typedef void (WINAPI *PLPSRQCALLBACK)(int nboardno, DWORD dwuser); List 4-21 GpibSetSrqEvent int GpibSetSrqEvent(ULONG ulboardno, PLPSRQCALLBACK lponsrqproc, DWORD dwuser); Visual Basic.NET PLPSRQCALLBACK List 4-22 Delegate Sub PLPSRQCALLBACK(ByVal nboardno As Integer, ByVal dwuser As Integer) List 4-23 GpibSetSrqEvent Declare Function GpibSetSrqEvent Lib "GPC43042.DLL" (ByVal ulboardno As Integer, ByVal lponsrqproc As PLPSRQCALLBACK, ByVal dwuser As Integer) As Integer Step2 lpsrqproc PLPSRQCALLBACK PLPSRQCALLBACK List 4-24 Module Module1 Public osp As PLPSRQCALLBACK Sub lponsrqproc(byval dwboardno As Integer, ByVal dwuser As Integer) End Sub End Module - 111 - Interface Corporation
Step3DLL lponsrqprocplpsrqcallback GpibSetSrqEvent2 List 4-25 GpibSetSrqEvent osp = New PLPSRQCALLBACK(AddressOf lponsrqproc) nret = GpibSetSrqEvent(1, osp, 0x55) [C#] GPC-4301 DLLGpibSetSrqEvent Step1DLL CGpibSetSrqEvent List 4-26 #define LPSRQCALLBACK VOID WINAPI typedef void (WINAPI *PLPSRQCALLBACK)(int nboardno, DWORD dwuser); List 4-27 GpibSetSrqEvent int GpibSetSrqEvent(ULONG ulboardno, PLPSRQCALLBACK lponsrqproc, DWORD dwuser); C# PLPSRQCALLBACK List 4-28 public delegate void PLPSRQCALLBACK(int nboardno, uint dwuser); List 4-29 GpibSetSrqEvent [DllImport("gpc43042.dll")] public static extern int GpibSetSrqEvent(uint ulboardno, PLPSRQCALLBACK lponsrqproc, uint dwuser); Step2 lpsrqproc PLPSRQCALLBACK List 4-30 void lponsrqproc(int dwboardno, uint dwuser) { } Interface Corporation - 112 -
Step3DLL PLPSRQCALLBACK List 4-31 IFCGPIB.PLPSRQCALLBACK osp; lponsrqprocplpsrqcallback GpibSetSrqEvent2 List 4-32 GpibSetSrqEvent osp = new IFCGPIB.PLPSRQCALLBACK (lponsrqproc); nret = IFCGPIB.GpibSetSrqEvent(1, osp, 0x55); 4.3.8 イベントオブジェクト DLL.NET Framework Win32APICreateEvent Win32APIKernel32.dllDLL Win32APIDLL.NET Framework [Visual Basic] List 4-33 CreateEventWaitForSingleObjectCloseHandleResetEvent Declare Function CreateEvent Lib "kernel32" Alias "CreateEventA" (ByVal lpeventattributes As Integer, ByVal ManualReset As Integer, ByVal binitialstate As Integer, ByVal lpname As String) As Integer Declare Function WaitForSingleObject Lib "kernel32" (ByVal hhandle As Integer, ByVal dwmilliseconds As Integer) As Integer Declare Function CloseHandle Lib "kernel32" (ByVal hobject As Integer) As Integer Declare Function ResetEvent Lib "kernel32" (ByVal hevent As Integer) As Integer - 113 - Interface Corporation
List 4-34 GPC-3100 GPC-3100AdSmpl_BForm5.vb Dim hevent As Integer hevent = CreateEvent(0, True, False, CStr(0)) nret = AdSetBoardConfig(ghDeviceHandle, hevent, 0, 0) nret = AdSetSamplingConfig(ghDeviceHandle, gconfig) nret = AdStartSampling(ghDeviceHandle, FLAG_ASYNC) nret = WaitForSingleObject(hEvent, 5000) nret = ResetEvent(hEvent) nret = CloseHandle(hEvent) [C#] List 4-35 CreateEventWaitForSingleObjectCloseHandleResetEvent [DllImport("kernel32.dll",EntryPoint="CreateEventA")] public static extern uint CreateEvent(uint lpeventattributes, bool ManualReset, bool binitialstate, string lpname); [DllImport("kernel32.dll")] public static extern uint WaitForSingleObject(uint hhandle, uint dwmilliseconds); [DllImport("kernel32.dll")] public static extern bool CloseHandle(uint hobject); [DllImport("kernel32.dll")] public static extern bool ResetEvent(uint hevent); Interface Corporation - 114 -
List 4-36 GPC-3100 GPC-3100 AdSmpl_Cs ESamplingForm.cs uint hevent; hevent =CreateEvent(0, true, false, null); gnerrcode = IFCAD.AdSetBoardConfig( ghdevicehandle, hevent, null, 0 ); gnerrcode = IFCAD.AdSetSamplingConfig(ghDeviceHandle, ref gconfig); gnerrcode = IFCAD.AdStartSampling(ghDeviceHandle, IFCAD.FLAG_ASYNC); WaitForSingleObject(hEvent, 5000); ResetEvent(hEvent); CloseHandle(hEvent); - 115 - Interface Corporation
4.3.9 関数のオーバーロード GPC-4301GpibSend GpibSendIntPtrByteByteString BPC-08018C# [Visual Basic] List 4-37 Visual Basic Declare Function GpibSend Lib "GPC43042.DLL" (ByVal ulboardno As Integer, ByVal lpadrstbl() As Integer, ByVal ulplength As Integer, ByRef vpbuffer As Byte) As Integer Declare Function GpibSend Lib "GPC43042.DLL" (ByVal ulboardno As Integer, ByVal lpadrstbl() As Integer, ByVal ulplength As Integer, ByVal vpbuffer() As Byte) As Integer Declare Function GpibSend Lib "GPC43042.DLL" (ByVal ulboardno As Integer, ByVal lpadrstbl() As Integer, ByVal ulplength As Integer, ByVal vpbuffer As String) As Integer Declare Function GpibSend Lib "GPC43042.DLL" (ByVal ulboardno As Integer, ByVal lpadrstbl() As Integer, ByVal ulplength As Integer, ByVal vpbuffer As IntPtr) As Integer [C#] List 4-38 C# [DllImport("gpc43042.dll")] public static extern int GpibSend(uint ulboardno, int[ ] lpadrstbl, uint dwlength, ref byte pvbuffer); [DllImport("gpc43042.dll")] public static extern int GpibSend(uint ulboardno, int[ ] lpadrstbl, uint dwlength, byte[ ] pvbuffer); [DllImport("gpc43042.dll")] public static extern int GpibSend(uint ulboardno, int[ ] lpadrstbl, uint dwlength, string pvbuffer); [DllImport("gpc43042.dll")] public static extern int GpibSend(uint ulboardno, int[ ] lpadrstbl, uint dwlength, IntPtr pvbuffer); Interface Corporation - 116 -
4.3.10 クラスライブラリの参照先が未解決になった場合 DLL 4-3 1. Windows Apprication 1- Windows Apprication 1-117 - Interface Corporation
2. DLL 4-4 3.OK Interface Corporation - 118 -
4.3.11 Visual C++.NET の補足情報 Visual C++.NET DllImportAttributeVisual C++ 6.0 DLL Visual C++MFC Win32 4-5 Visual C++Windows DLL 1. C/C++- - 119 - Interface Corporation
H: work interface GPC2000 include 4-6 2. - H: work Interface GPC2000 lib 4-7 Interface Corporation - 120 -
3. - fbidio.lib 4-8 4.DLL DLL - 121 - Interface Corporation
用語集 Unicode Unicode.NET Framework ASCIIEncoding CodePageEncoding UnicodeEncoding UTF7Encoding UTF8Encoding.NET Framework (Delegate) DLL.NET Framework Interface Corporation - 122 -
.NET Framework ImportsVisual Basicusing C# Imports usingc#include "" Microsoft Intermediate Language (MSIL) - 123 - Interface Corporation
Web site(www.interface.co.jp) PRM-0061 PRM-0062 PRM-0063 TUT-0056 TUT-0055 TUT-0054 TUT-0053 TUT-0050 TUT-0048 TUT-0044 TUT-0043 TUT-0041 TUT-0040 TUT-0039 TUT-0038 TUT-0037 TUT-0036 TUT-0034 TUT-0033 TUT-0032 TUT-0031 TUT-0030 TUT-0029 TUT-0028 TUT-0027 TUT-0026 TUT-0025 TUT-0024 TUT-0023 TUT-0022 TUT-0021 TUT-0020 TUT-0019 TUT-0018 TUT-0017 TUT-0016 TUT-0015 TUT-0014 TUT-0008 TUT-0007 TUT-0006 TUT-0005 TUT-0004 TUT-0003 TUT-0002 TUT-0001 CPZ() PCI() CSI() XP Embedded OS CAN RTLinux (GPG-7400) RTLinux RTLinux RTLinux RTLinuxGP-IB RTLinuxDA RTLinuxAD RTLinuxDIO - RTLinuxHDLC RTLinuxPCI/CompactPCI/CardBus() Visual C++PPI Visual Basic Visual C++ Visual Basic Visual C++ Visual BasicHDLC Visual C++HDLC Visual BasicGP-IB Visual C++GP-IB Visual BasicDIO Visual C++DIO Visual BasicDA Visual C++DA Visual BasicAD Visual C++AD Visual Basic Visual C++ Visual BasicPPI Microsoft Visual Studio.NET () () C(98)/ISAPCI/CompactPCI(DOS) DOSLAP-B DOSAD LinuxPCI/CompactPCI/CardBus PCI-ISA PCI-C CAN Linux, Linux(SH-4) LinuxPCI/CompactPCI ActiveX CompactPCI+/ MS-DOSPCI/CompactPCI Interface Corporation - 124 -
参考文献 Microsoft MSDN 200210 Microsft Visual Studio.NET Professional C#BP - 125 - Interface Corporation
Microsoft Visual Studio.NET 2005 9 Ver. 3.3 732-0828 10-21 TEL 082-262-7777 FAX 082-262-5066 ISD-7078-33 2,100 ( 2,000 + 100) 2002, 2005 Interface Corporation. All rights reserved.
DLL Microsoft Visual Studio.NET TUT-0014Ver. 3.3 www.interface.co.jp