文件名称:
工业以太网技术在船舶自动化领域的应用.pdf
开发工具:
文件大小: 263kb
下载次数: 0
上传时间: 2019-10-13
详细说明:工业以太网技术在船舶自动化领域的应用pdf,工业以太网技术在船舶自动化领域的应用118
2008
2
vO
OPC
MODBU S
TCP
OPC
MODBUSTCP
OPC
2 MODBUS TCP
MODBUS TCP
VB
VC
MODBUS TCP
VB6.0
2.1 MODBUS TCP
MODBU S
MODBUS/IDA
MODBUS
MODBU STCPIIP
MODBUS TCP) MODBUS TCP
TCP/IP
MODBUS
M ODBUS TCP
MODBUS TCP PDU
MBAP报文头
功能代码
数据
PDU
2 MODBUS TCP
MAP
(MBAP MODBUS Application Protocol MOdBUS
I MBAP
(byte)
MODBU S
/
222
O= MODBUS
I= UNI-TE
MODBUS TCP
MODBUS. org
65~72100~110,
3
03
C1994-2010ChinaAcademicJournalElectronicPublishingHouseAllrightsreservedhttp://www.cnki.net
119
2 MODBUS TCP
02
02
01
01
05
15
OF
04
03
03
06
16
10
/
23
17
16
20
14
21
6
15
43
4
2B
2.2
VB6
Winsock
M ODBU S
设置 Winsock控件参数
TCP
Winsock
向服务器发出数据请求命令
IP
TCP
等待数据
I000
I002
Connect
M OD BUS TCP
调用 Winsock GETDATA方法获取数据
Send at a
DataA rrival
去除 MODBUS MBAP报文头,解包
Get dat a
M ODBUS TCP
MBAP
对接收的数据进
行校验,正确?
存放到指定的位置
VB6.0
3 winsock
Winsock
kCl
Form load
IP
F
orm
U
loa
Private sub fe
orr lodo
Sock cl. remotehost =127.0.0.1"
p
IP
Sock cl remote port 2000
1000
Sockcl Co nnect
oIgEndSubchinaacademicjournalelectronicpublishinghouse.Allrightsreserved.http:/wwwcnkinet
120
2008
2
Private Sub Form_ U load( cancel As Integer)
Sockcl. close
End sub
Sock ci dataarrival
Private Sub sockCl_D at arrival( By v al by tes Total a s long
Dir
Im s As String
Sockcl Get data s
Call deal_m ess age( s)
Call mod_Response(gstrFC, gstrUnit
g int RegStarta ddr, gintDtLen
SockCl SendData gstrDt
End sub
Dealmessage(
MODBUS TCP
Deal_Message byv al strDat a As String), strD at a-TCP
es pons
M od_Response( byval strFC as str ing,
by val str Unit as string, by val int RegStart a ddr as integer, byv al int Dt L en as in teger
Deal
Message
Senddata
M od_Response()
7
Send at a
Public Sub mod_response( byval strFC as string, byval strU nit as str ing, by val int RegStartA ddr as
integer, by val intDtLen as integer)
Select srfC
Case 3
Case else
End select
End sub
3 PC
3.1 OPC
OPC
OPC
OPC
OPC
OPC
OPC
OPC
OPC
3.2 OPC
oP59-2010ChinaacademicjournalElectronicPublishingHouse.AllrighOPCerved.http:/wwwcnk,net
121
OPC
OPC
OPC
OPC
OPC Group
OPC ITem
TAG)
2.0PC
OPC
T/IP
OPC
OPC
3. OPC
OPC
OPC
OPC
OPC
OPCserver OPCGroup Enum OPCltemAttributes
OPCServer
1OPCCom mon IOP CServer IOPCItem Properties
Connection point container
OPCGroup
lOPCSynclo IOP CGroupstateMg
IOP CAsynclO2 1O PCItemgt Iconnect ion Po int Cont ainer
EnumoPciten attributes
EnumoPCitema ttributes
OPCDa. idl
OPC
IDE
Micros oft v isualc++
oPCServer
OP CGro up
CO M
ATL(Active Template Library
3.3 OPC
OPC
OPC
OPC
Custom
Interface
Automation Interf ace)
C++
VB DELPHI
OPC
OPC
OPC
OPC
OPC
OPC Group
IOP CSynclO
IoPCSynclo2
TOP CSYnclo
1OPCASy ncl02
IOPCAsynclo3
OPC
OPC
OPC
IO PCDat callback
VB
OPC
OPC
OPC
OPC
DLL
OPC
3.3.1建立OPC对象
OPC
Option base 1
Dim Wit h Events serverObj As OPCServer
OPC Server
OPC
Dim Groupsobj As OPCGroup
OPC Groups
OPC
Dim With Events groupobj As OPCGroup
OPC Group
Dim Items Obj as oPcltems
OPC Item
Dim Server andles()
As long
OPC Item
DimClienthandLes()daslongrnalElectronicPublishingHouse.AvrightsnesErved.http://ww.cnki.net
122
2008
2
Dim Itemld( 2) as String
Dim Errors as long
If ServerObj Is Not hing T hen Set Server Obj= New OPCServer
OPC
If ServerObj. Server St ate OPC Disconnected Then?
Serverobj. Connect (OPC. SimatiCNET
OPC
End if
If Gro upsobj Is Nothing Then Set Groupsobj= Serverobj OPCG ups
If Group obj ls nothing then Set group obj= groupsObj add
If Items Obj Is nothing Then Set Itemsobj=GroupObj. OPCItems
Groupobj Is active= True
ItemId(1)="S7: [S7 connection_-IJIBOW
8
ItemId(2)="S7: [ S7 connection_1]QB0
Client andles( 1)
Client andles( 2)=2
Servere andles
OPC Item
Client andles
OPC Item
Call Items Obj. A ddltems( 2, ItemId, Client H andles, Server andles, Errors
3.3.2异步数据读取方式的实现
OPC Item
OPC Item
Dim TempServerH andles( 1 )as lo ng
OnRead Complete
Dim transaction as lon
Dim Canceled as long
OPC Item
Dim ErrorNr( As long
Temp ServerHandles( 1)= Server andles( 1)
OPC Item
Groupobj. AsyncRead 1, Tem pServer andles, ErrorNr, Transaction ID, CancelID
OPC Item
OPC Item
OPC
Icon nection point container
IOPCDat a Cal lback
Private Sub groupobj_ asyncReadCom plete( By Val Transaction ID As Long, By Val NumItems As
Long, ClientH andles()As long, Item Values() As Variant, Q ualities()As long, Time Stamps( As
Date, Errors( As long)
Client andles addItem s
Client andles
OPC Item
Transaction:
Numitems
OPC Item
Item values(
OPC It em
Variant
Qualities(: OPC Item
TimeSt am ps()
Errors
3.3.3。0异步数据写入方式的
inaacademieournalelEctronicPublishingHouseAllrightsreservedhttp://www.cnki.net
123
Dim Temp ServerHandles(1) As long
Dim V value( 1) as variant
Dim Errornr( as long
Dim transactionid as lon
Dim Cancelldas long
Temp Serv erH andles( 1)=ServerHandles( 2)
vValue(1)=1′
Client andle 2 OPC Item
Groupobj. AsyncWrite 1, Temp Server andles, vValue, Error Nr, Transaction ID, Cancell
Asy nc Write
Private Sub group obj_AsyncWrite Complete( By V al Trans actionID As Long, By Val NumItems as
Long, Client andles()As Long, Errors( As long)
AsuncReadComplete
3.3.4断开与服务器的连接
ItemsObj. Remove Items]. Count, ServerH andles, Errors OPC Item
Set Itemsobi= nothing?
If n ot groupobi is not hing t hen
GroupsObj. Remove? Groupobj Server H andle?
End if
If n ot groups obj is nothing then
Set Groupsobj= Not hing
End if
If Not Serverobj Is Nothing Then
If ServerOb. Server State<>oPC Dis connect ed then
Serverobj. Dis
sconnect
End If
Set Serverobj= Nothing
End if
4
2000
100M
10
100M
20
5
FCS
100 bitls
MODBUS
TCP
100M
500000
(70000
0.14
20
2.8s
CSMA/CD
[1
2005
[M]
2003
VXWorks
[M]
2004
o1994-2010ChinaAcademicJournalElectronicPublishingHouse.Allrightsreservedhttp://www.cnki.net
(系统自动生成,下载前可以参看下载内容)
下载文件列表
相关说明
- 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
- 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度。
- 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
- 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
- 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
- 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.