opc server

Join Date
Jun 2002
Posts
24
I use Automated solutions 2.7 as my OPC server to connect modbus. With MSAccess2003 it works fine with no errors, but now I'm trying to jump to visual studio 2005 (vb 2005 to be more precise) but the problems begin because vb2005 have some differences with vba 6. One problem resides with "QueryAvailableProperties" method wich needs int16 array variable that vb2005 don´t recognize and convert. One message is "unable to cast int16
[*] to int[16]. very strange. If anyone can help me I appreciate very mutch.
Bye . agmac
 
There is a difference between vb6 and vb.net. The opc automation object was good for vb6. Since then there is a new object out good for .net. You must get it from the opc foundation after joining as a member, or use a third party go between. I use www.metadynamics.com
 
reply OPC server with visual basic 2005

automan. there is the code. I´m using access 20033 as database and ADODB to access and qork qith tables.
As I said before the problem lies in the "queryAvailableProperties" and with DataTypes argument.


Dim tbl_name_OPCv As String = "t_OPCv"
Dim tbl_name_OPCg As String = "t_OPCg"
Dim camSTR, cnnSTR As String
Dim cnnADO As New ADODB.Connection
Dim rs_OPCg As New ADODB.Recordset
Dim rs_OPCv As New ADODB.Recordset

camSTR = "C:\spv_fscam\spv_fscam.mdb"
cnnSTR = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & camSTR & ";"
cnnADO.Open(cnnSTR)
rs_OPCg.Open("select * from t_OPCg", cnnADO, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic)
rs_OPCv.Open("select * from t_OPCv", cnnADO, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic)


Dim itemID As String
Dim itemCount As Int32
Dim propIDs(6) As Int32
Dim desc(6) As String
Dim dataT(6) As Short
Dim itemDat(6) As Object
Dim Errors(6) As Int32

Dim X As Integer 'apontador do número de grupos
Dim Y As Integer 'apontador do número de itens por grupo

Dim varNomeGrupo As String 'var que guarda o nome do grupo em causa
Dim varNome As String 'var que guarda o nome completo do item ou var em causa

Dim vTipo As Int16 'itemData(1)
Dim vValor As Int16 'itemData(2)
Dim vQualid As Int16 'itemData(3)
Dim vTempo As Date 'itemData(4)
Dim vDireit As Int16 'itemData(5)
Dim vDesc As String 'itemData(6)

Dim numGrupos As Integer 'nº de grupos existentes no servidor
Dim numItens As Integer 'nº de itens ou variáveis existentes no servidor para o grupo em causa

Dim str_len As String 'comprimento do campo descrição
numItens = 0
servBrowser = myServer.CreateBrowser
servBrowser.MoveToRoot()
servBrowser.ShowBranches()
numGrupos = servBrowser.Count 'conta o nº de grupos existentes no servidor
For X = 1 To numGrupos
varNomeGrupo = servBrowser.Item(X) 'nome do grupo
servBrowser.MoveDown(varNomeGrupo)
servBrowser.ShowLeafs()
numItens = servBrowser.Count 'número de itens no grupo
rs_OPCg.AddNew() 'acrescenta novos registos
rs_OPCg.Fields("gOPC").Value = varNomeGrupo
rs_OPCg.Fields("qt_v").Value = numItens
rs_OPCg.Update()
For Y = 1 To numItens
varNome = varNomeGrupo & "." & servBrowser.Item(Y)
itemID = varNome
'Try
myServer.QueryAvailableProperties(itemID, itemCount, propIDs, desc, dataT)
myServer.GetItemProperties(itemID, itemCount, propIDs, itemDat, Errors)
'Catch ex As Exception
'MsgBox(ex.Message)
'End Try
vTipo = itemDat(1)
vValor = itemDat(2)
vQualid = itemDat(3)
vTempo = itemDat(4)
vDireit = itemDat(5)
vDesc = itemDat(6)
str_len = Len(vDesc)
rs_OPCv.AddNew() 'acrescenta novos registos
rs_OPCv.Fields("gOPC").Value = varNomeGrupo
rs_OPCv.Fields("vOPC").Value = varNome
rs_OPCv.Fields("valor").Value = vValor
rs_OPCv.Fields("desc").Value = Microsoft.VisualBasic.Left(vDesc, str_len - 4)
rs_OPCv.Fields("un").Value = Microsoft.VisualBasic.Right(vDesc, 3)
rs_OPCv.Fields("tipo").Value = vTipo
rs_OPCv.Fields("qualid").Value = vQualid
rs_OPCv.Fields("tempo").Value = vTempo
rs_OPCv.Fields("direit").Value = vDireit
rs_OPCv.Update()
Next Y
servBrowser.MoveUp()
servBrowser.ShowBranches()
Next X
 
Hi,
Here is a quote from the help file:
"CAST or CONVERT: invalid attributes specified for type '%.*ls'"

int16
[*] to int[16]

Seems to me that VB.Net is not able to convert the data that was returned from the query into the variable declared. Like a 32 bit variable is bieng stuffed into a 16 bit variable space depending what the "*" means. Or maybe some other type of data mis-match, such as ASCII results bieng directed into an integer variable.

Or maybe I'm not even close since I'm not an expert. Hope this helps though.
BD
 
opc object

opc object
Gerry M said:
There is a difference between vb6 and vb.net. The opc automation object was good for vb6. Since then there is a new object out good for .net. You must get it from the opc foundation after joining as a member, or use a third party go between. I use www.metadynamics.com

what you mean as "use a thirdy party go between". Do you mean buying another opc server just to get an .net ugrade for the opc object. Don´t exist any another way to get it, with a demo opc server, ... .
I´m just testing my solution, before commercialize it.

agmac
 
OPC uses COM (Common Object Model), from VB6 timeframe, to communicate between objects and stuff(a little above my head). The OPC Automation Object it was you are programming with in vb6 to make an OPC Client. The OPC Automation Object is not directly compatible with .Net

.Net uses a different mechanism. .Net has classes to handle old COM stuff. The third party stuff takes care of all that.

The opc foundation has since come out with a new OPC Automation Object that is .net compatible. You have to join their club and then you can download the new implementation.

So either join the OPC Foundation or buy a third party implementation.
 

Similar Topics

I am running CCW 13 trying to upload to a micro 820 vers.12 I get an output message OPC server is unable to load project controller. Please help!
Replies
5
Views
285
If anyone has a crack for IBH OPC Server, please send it to: [email protected] Urgently. Thanks in advance!
Replies
1
Views
147
Folks, I have a client with an old ABB Advant / MOD300 system (v14.4). Around y2k I installed the ABB Industrial IT MOD300 OPC Server 1.1/2...
Replies
1
Views
202
Hello everyone, I wanted to share my findings with getting the new OPC UA server working (I think you might be interested in this JeremyM :lolis:)...
Replies
8
Views
2,192
I have a Win10 64 bit host for my OPC DA server, which is Indusoft (Studio,Scada.OPC.3). Locally OPC works, Matrikon OPC Explorer. On my Win7...
Replies
5
Views
1,207
Back
Top Bottom