We have a program that transfers data from iFIX to another system. The other system is not in iFIX, only way to talk to the other system is via TCP connection using their proprietary protocol. I wrote a program many years ago in VB6 that pulls the data from iFIX and sends it to the other system and vice versa. Since VB6 is obsolete, I want to update the program a .Net version.
I have all of the data types updated to the .NET equivalents. The define_group and define_ntf both work correct. eda_get_ascii works correctly, but eda_get_float does not.
I have created the below as an example to show the problem I'm running into. I can convert it to C# if that's easier to work with.
The red is the section I'm having trouble with. Everything looks correct to me, but it keeps giving error 8700
Can you take a look and let me know what I'm missing? I'm sure it's simple.
Module iFIX_Data
'Is FIX running
Private Declare Function FixIsFixRunning Lib "fixtools.dll" Alias "FixIsFixRunning@0" () As Int32
' Note define_group returns (VB6 Long, .NET Int32)
Private Declare Function eda_define_group Lib "vdba.dll" (ByVal Count As Int16, ByVal Detect As Int16) As Int32
Private Declare Sub eda_delete_group Lib "vdba.dll" (ByVal Handle As Int32)
' You should always pass 0 for vsp
Private Declare Function eda_define_ntf% Lib "vdba.dll" (ByVal Handle As Int32, ByVal enode As String, ByVal etag As String, ByVal efield As String, ByVal vsp As Int32)
Private Declare Sub eda_delete_ntf Lib "vdba.dll" (ByVal Handle As Int32, ByVal ntf As Int32)
Private Declare Sub eda_lookup Lib "vdba.dll" (ByVal Handle As Int32)
Private Declare Sub eda_wait Lib "vdba.dll" (ByVal Handle As Int32)
Private Declare Sub eda_read Lib "vdba.dll" (ByVal Handle As Int32)
Private Declare Sub eda_write Lib "vdba.dll" (ByVal Handle As Int32)
Private Declare Function eda_write1 Lib "vdba.dll" (ByVal Handle As Int32, ByVal ntf As Int32) As Int16
'Errors
Private Declare Function eda_get_error Lib "vdba.dll" (ByVal Handle As Int32, ByVal ntf As Int32) As Int16
Private Declare Function NlsGetText Lib "fixtools.dll" Alias "NlsGetText@12" (ByVal ErrCode As Int32, ByVal MsgString As String, ByVal MaxLength As Int32) As Int32
'ASCII data
Private Declare Function eda_get_ascii Lib "vdba.dll" (ByVal Handle As Int32, ByVal ntf As Int32, ByVal Value As String, ByVal MaxLen As Int16) As Int16
Private Declare Function eda_set_ascii Lib "vdba.dll" (ByVal Handle As Int32, ByVal ntf As Int32, ByVal Value As String) As Int16
'Float data
Private Declare Function eda_get_float Lib "vdba.dll" (ByVal Handle As Int32, ByVal ntf As Int32, ByVal Value As Single) As Int16
Private Declare Function eda_set_float Lib "vdba.dll" (ByVal Handle As Int32, ByVal ntf As Int32, ByVal Value As Single) As Int16
Public Sub GetDataFromIFIX()
'Create new group
Dim rGroupID As Int32 : rGroupID = eda_define_group(1, 0)
'Add a String and Number point to the group
Dim rPointID_String As Int32 : rPointID_String = eda_define_ntf(rGroupID, "SHE01", "LG_1_MATERIAL", "A_DESC", 0)
Dim rPointID_Number As Int32 : rPointID_Number = eda_define_ntf(rGroupID, "SHE01", "LG_1_LAST_WEIGHT", "F_CV", 0)
'Check if tags actually exist
Call eda_lookup(rGroupID)
Call eda_wait(rGroupID)
'Is the string tag ok?
Dim rErrNum_String As Short : rErrNum_String = eda_get_error(rGroupID, rPointID_String)
MessageBox.Show("Type: String" & vbCrLf & "ErrNum: " & rErrNum_String.ToString & vbCrLf & "ErrStr: " & GetErrorText(rErrNum_String))
'rErrNum_String returns 0, indicating everything is good.
'Is the string tag ok?
Dim rErrNum_Number As Short : rErrNum_Number = eda_get_error(rGroupID, rPointID_Number)
MessageBox.Show("Type: Number" & vbCrLf & "ErrNum: " & rErrNum_Number.ToString & vbCrLf & "ErrStr: " & GetErrorText(rErrNum_Number))
'rErrNum_Number returns 0, indicating everything is good.
'Let's Read the tags and display the data
Call eda_read(rGroupID)
Call eda_wait(rGroupID)
Dim rValue_String As String = New String(" ", 256)
rErrNum_String = eda_get_ascii(rGroupID, rPointID_String, rValue_String, 79)
MessageBox.Show("Type: String" & vbCrLf & "ErrNum: " & rErrNum_String.ToString & vbCrLf & "ErrStr: " & GetErrorText(rErrNum_String) & vbCrLf & "Value: " & Trim(Replace(rValue_String, Chr(0), "")))
'rErrNum_String returns 0, indicating everything is good. Value from iFIX is displayed
Dim rValue_Number As Single = 0
rErrNum_Number = eda_get_float(rGroupID, rPointID_Number, rValue_Number)
MessageBox.Show("Type: Number" & vbCrLf & "ErrNum: " & rErrNum_Number.ToString & vbCrLf & "ErrStr: " & GetErrorText(rErrNum_Number) & vbCrLf & "Value: " & rValue_Number.ToString)
'rErrNum_Number returns 8700 (Bad parameter in function call)
Call eda_delete_group(rGroupID)
End Sub
Private Function GetErrorText(ByVal zErrNum As Int32) As String
If zErrNum = 0 Then
Return "OK"
Else
Dim rErrString As String = New String(" ", 256)
Call NlsGetText(zErrNum, rErrString, 79)
Return Trim(Replace(rErrString, Chr(0), ""))
End If
End Function
End Module
I have all of the data types updated to the .NET equivalents. The define_group and define_ntf both work correct. eda_get_ascii works correctly, but eda_get_float does not.
I have created the below as an example to show the problem I'm running into. I can convert it to C# if that's easier to work with.
The red is the section I'm having trouble with. Everything looks correct to me, but it keeps giving error 8700
Can you take a look and let me know what I'm missing? I'm sure it's simple.
Module iFIX_Data
'Is FIX running
Private Declare Function FixIsFixRunning Lib "fixtools.dll" Alias "FixIsFixRunning@0" () As Int32
' Note define_group returns (VB6 Long, .NET Int32)
Private Declare Function eda_define_group Lib "vdba.dll" (ByVal Count As Int16, ByVal Detect As Int16) As Int32
Private Declare Sub eda_delete_group Lib "vdba.dll" (ByVal Handle As Int32)
' You should always pass 0 for vsp
Private Declare Function eda_define_ntf% Lib "vdba.dll" (ByVal Handle As Int32, ByVal enode As String, ByVal etag As String, ByVal efield As String, ByVal vsp As Int32)
Private Declare Sub eda_delete_ntf Lib "vdba.dll" (ByVal Handle As Int32, ByVal ntf As Int32)
Private Declare Sub eda_lookup Lib "vdba.dll" (ByVal Handle As Int32)
Private Declare Sub eda_wait Lib "vdba.dll" (ByVal Handle As Int32)
Private Declare Sub eda_read Lib "vdba.dll" (ByVal Handle As Int32)
Private Declare Sub eda_write Lib "vdba.dll" (ByVal Handle As Int32)
Private Declare Function eda_write1 Lib "vdba.dll" (ByVal Handle As Int32, ByVal ntf As Int32) As Int16
'Errors
Private Declare Function eda_get_error Lib "vdba.dll" (ByVal Handle As Int32, ByVal ntf As Int32) As Int16
Private Declare Function NlsGetText Lib "fixtools.dll" Alias "NlsGetText@12" (ByVal ErrCode As Int32, ByVal MsgString As String, ByVal MaxLength As Int32) As Int32
'ASCII data
Private Declare Function eda_get_ascii Lib "vdba.dll" (ByVal Handle As Int32, ByVal ntf As Int32, ByVal Value As String, ByVal MaxLen As Int16) As Int16
Private Declare Function eda_set_ascii Lib "vdba.dll" (ByVal Handle As Int32, ByVal ntf As Int32, ByVal Value As String) As Int16
'Float data
Private Declare Function eda_get_float Lib "vdba.dll" (ByVal Handle As Int32, ByVal ntf As Int32, ByVal Value As Single) As Int16
Private Declare Function eda_set_float Lib "vdba.dll" (ByVal Handle As Int32, ByVal ntf As Int32, ByVal Value As Single) As Int16
Public Sub GetDataFromIFIX()
'Create new group
Dim rGroupID As Int32 : rGroupID = eda_define_group(1, 0)
'Add a String and Number point to the group
Dim rPointID_String As Int32 : rPointID_String = eda_define_ntf(rGroupID, "SHE01", "LG_1_MATERIAL", "A_DESC", 0)
Dim rPointID_Number As Int32 : rPointID_Number = eda_define_ntf(rGroupID, "SHE01", "LG_1_LAST_WEIGHT", "F_CV", 0)
'Check if tags actually exist
Call eda_lookup(rGroupID)
Call eda_wait(rGroupID)
'Is the string tag ok?
Dim rErrNum_String As Short : rErrNum_String = eda_get_error(rGroupID, rPointID_String)
MessageBox.Show("Type: String" & vbCrLf & "ErrNum: " & rErrNum_String.ToString & vbCrLf & "ErrStr: " & GetErrorText(rErrNum_String))
'rErrNum_String returns 0, indicating everything is good.
'Is the string tag ok?
Dim rErrNum_Number As Short : rErrNum_Number = eda_get_error(rGroupID, rPointID_Number)
MessageBox.Show("Type: Number" & vbCrLf & "ErrNum: " & rErrNum_Number.ToString & vbCrLf & "ErrStr: " & GetErrorText(rErrNum_Number))
'rErrNum_Number returns 0, indicating everything is good.
'Let's Read the tags and display the data
Call eda_read(rGroupID)
Call eda_wait(rGroupID)
Dim rValue_String As String = New String(" ", 256)
rErrNum_String = eda_get_ascii(rGroupID, rPointID_String, rValue_String, 79)
MessageBox.Show("Type: String" & vbCrLf & "ErrNum: " & rErrNum_String.ToString & vbCrLf & "ErrStr: " & GetErrorText(rErrNum_String) & vbCrLf & "Value: " & Trim(Replace(rValue_String, Chr(0), "")))
'rErrNum_String returns 0, indicating everything is good. Value from iFIX is displayed
Dim rValue_Number As Single = 0
rErrNum_Number = eda_get_float(rGroupID, rPointID_Number, rValue_Number)
MessageBox.Show("Type: Number" & vbCrLf & "ErrNum: " & rErrNum_Number.ToString & vbCrLf & "ErrStr: " & GetErrorText(rErrNum_Number) & vbCrLf & "Value: " & rValue_Number.ToString)
'rErrNum_Number returns 8700 (Bad parameter in function call)
Call eda_delete_group(rGroupID)
End Sub
Private Function GetErrorText(ByVal zErrNum As Int32) As String
If zErrNum = 0 Then
Return "OK"
Else
Dim rErrString As String = New String(" ", 256)
Call NlsGetText(zErrNum, rErrString, 79)
Return Trim(Replace(rErrString, Chr(0), ""))
End If
End Function
End Module