Test and Measurement Forum

I have no access to humidiprobe.dll data from vb.net

Post your .Net discussions here

I have no access to humidiprobe.dll data from vb.net

Postby cccsaih » Tue Nov 22, 2011 11:55 am

I am using the sample code from sdk VB6.0, VB6.0 both as updated. Net and so not able to access data HumidiProbe, I always return false and 0 in the output parameters. If call to HumiditiProbeOpenUnit() always return false.

Neither i can not register the dll with regsvr32 or add it as a reference to the project as COM. Is it necessary?

How to fix it? My picolog installation works fine.

Thanks.
cccsaih
Newbie
 
Posts: 0
Joined: Tue Nov 22, 2011 11:09 am

Re: I have no access to humidiprobe.dll data from vb.net

Postby Martyn » Tue Nov 22, 2011 1:11 pm

Can you post your code, particularly the dll imports, so that we can check this out for you.

Please use the Code button just above the edit box.
Martyn
Technical Specialist
Martyn
Site Admin
Site Admin
 
Posts: 2287
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: I have no access to humidiprobe.dll data from vb.net

Postby cccsaih » Tue Nov 22, 2011 3:40 pm

Martyn wrote:Can you post your code, particularly the dll imports, so that we can check this out for you.

Please use the Code button just above the edit box.


The code (Upgraded version to .Net, of the sdk of sample VB6.0. Without changes on vb6.0, i get the same result.):

Code: Select all
Option Strict Off
Option Explicit On
Friend Class Form1
    Inherits System.Windows.Forms.Form
    Declare Function HumidiProbeOpenUnit Lib "HumidiProbe.dll" () As Boolean
    Declare Function HumidiProbeGetUnitInfo Lib "HumidiProbe.dll" (ByVal handle As Short, ByRef str_Renamed As String, ByVal stringLength As Short, ByVal info As Short) As Short
    Declare Function HumidiProbeGetSingleValue Lib "HumidiProbe.dll" (ByVal handle As Short, ByRef temp As Single, ByVal filterTemp As Short, ByRef humidity As Single, ByVal filterHumidity As Short) As Short
    Declare Function HumidiProbeCloseUnit Lib "HumidiProbe.dll" (ByVal handle As Short) As Short
    Dim handle_Renamed As Short
    Dim temp As Single
    Dim humidity As Single
    Public obj As New Object
    Private Sub Close_Renamed_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Close_Renamed.Click
        Call HumidiProbeCloseUnit(handle_Renamed)
        Text3.Text = "HumidiProbe closed"
    End Sub
    Private Sub Open_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Open.Click
        Text3.Text = "Opening HumidiProbe" & "..."
        Text3.Refresh()
        handle_Renamed = HumidiProbeOpenUnit()
        If handle_Renamed > 0 Then
            Text3.Text = "HumidiProbe opened"
        Else
            Text3.Text = "Unable to open HumidiProbe"
        End If
    End Sub
    Private Sub Timer1_Tick(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Timer1.Tick
        Dim ok As Object
        Dim Value As Integer
        Dim tempFilter As Short
        Dim humidityFilter As Short
        tempFilter = 0
        humidityFilter = 0
        If handle_Renamed > 0 Then
            ok = HumidiProbeGetSingleValue(handle_Renamed, temp, tempFilter, humidity, humidityFilter)
            If ok > 0 Then
                Text1.Text = CStr(temp)
                Text2.Text = CStr(humidity)
            Else
                Text1.Text = "****"
                Text2.Text = "****"
            End If
        End If
    End Sub
End Class


The result is the same with relative or absolute path of humiditiprobe.dll. I copied humiditiprobe.dll to the solution directory. I have also tried the absolute path PicoLog installation directory.
cccsaih
Newbie
 
Posts: 0
Joined: Tue Nov 22, 2011 11:09 am

Re: I have no access to humidiprobe.dll data from vb.net

Postby Martyn » Wed Nov 23, 2011 11:20 am

Can you try changing the return value for OpenUnit to Short
Martyn
Technical Specialist
Martyn
Site Admin
Site Admin
 
Posts: 2287
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: I have no access to humidiprobe.dll data from vb.net

Postby cccsaih » Wed Nov 23, 2011 12:19 pm

Martyn wrote:Can you try changing the return value for OpenUnit to Short


Yes but, the output of OpenUnit remains 0. HumidiProbeGetSingleValue returns all params to 0.0.
cccsaih
Newbie
 
Posts: 0
Joined: Tue Nov 22, 2011 11:09 am

Re: I have no access to humidiprobe.dll data from vb.net

Postby Martyn » Fri Nov 25, 2011 12:55 pm

Replace
Code: Select all
    Private Sub Timer1_Tick(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Timer1.Tick
        Dim ok As Object
        Dim Value As Integer
        Dim tempFilter As Short
        Dim humidityFilter As Short
        tempFilter = 0
        humidityFilter = 0
        If handle_Renamed > 0 Then
            ok = HumidiProbeGetSingleValue(handle_Renamed, temp, tempFilter, humidity, humidityFilter)
            If ok > 0 Then
                Text1.Text = CStr(temp)
                Text2.Text = CStr(humidity)
            Else
                Text1.Text = "****"
                Text2.Text = "****"
            End If
        End If
    End Sub

with
Code: Select all
    Private Sub Timer1_Tick(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Timer1.Tick
        Dim status As Integer
        Dim tempFilter As Short
        Dim humidityFilter As Short
        tempFilter = 0
        humidityFilter = 0
        If handle_Renamed > 0 Then
            status = HumidiProbeGetSingleValue(handle_Renamed, temp, tempFilter, humidity, humidityFilter)
            If status > 0 Then
                Text1.Text = CStr(temp)
                Text2.Text = CStr(humidity)
            Else
                Text1.Text = "****"
                Text2.Text = "****"
            End If
        End If
    End Sub


and it should then work.
Martyn
Technical Specialist
Martyn
Site Admin
Site Admin
 
Posts: 2287
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: I have no access to humidiprobe.dll data from vb.net

Postby cccsaih » Mon Dec 19, 2011 5:04 pm

I replaced the code, and still does not work. I think the problem is that it does not create the instance of access to the drive with handle_Renamed = HumidiProbeOpenUnit(), which always returns 0.
cccsaih
Newbie
 
Posts: 0
Joined: Tue Nov 22, 2011 11:09 am

Re: I have no access to humidiprobe.dll data from vb.net

Postby Martyn » Tue Dec 20, 2011 9:41 am

Attached is the code I have just used to verify this, it hasn't been tidied but hopefully it will help.
Attachments
humidiProbe.zip
Simple Form
(77.95 KiB) Downloaded 194 times
Martyn
Technical Specialist
Martyn
Site Admin
Site Admin
 
Posts: 2287
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: I have no access to humidiprobe.dll data from vb.net

Postby cccsaih » Thu Dec 22, 2011 4:22 pm

I read the first reply of: http://www.picotech.com/support/topic10205.html, and the problem is there. When I closed Picorecorder, the code works. :roll:
cccsaih
Newbie
 
Posts: 0
Joined: Tue Nov 22, 2011 11:09 am

Re: I have no access to humidiprobe.dll data from vb.net

Postby cccsaih » Tue Jan 17, 2012 5:13 pm

Hi again,

Now i have programed a dll (which call to humidiprobe.dll) for attach to a webservice in a distrubuted server-client application. The problem is that in the frist read, it can open the sensor and take the data, but in a second pass cant open the sensor.

I have been trying to get info about call to functions how HumidiProbeGetUnitInfo, but i can't find documentation for this.

My code:

Code: Select all
Public Class PicoDLL
    Declare Function HumidiProbeOpenUnit Lib "HumidiProbe.dll" () As Short 'Boolean
    Declare Function HumidiProbeGetUnitInfo Lib "HumidiProbe.dll" (ByVal handle As Short, ByRef str_Renamed As String, ByVal stringLength As Short, ByVal info As Short) As Short
    Declare Function HumidiProbeGetSingleValue Lib "HumidiProbe.dll" (ByVal handle As Short, ByRef temp As Single, ByVal filterTemp As Short, ByRef humidity As Single, ByVal filterHumidity As Short) As Short
    Declare Function HumidiProbeCloseUnit Lib "HumidiProbe.dll" (ByVal handle As Short) As Short
    Dim handle_Renamed As Short
    Dim temp As Single
    Dim humidity As Single
    Public obj As New Object
    Public Function PicoDatos(ByRef temperatura As Single, ByRef humedad As Single) As Short
        Dim status As Short
        Dim tempFilter As Short
        Dim humidityFilter As Short
        Try
            If handle_Renamed > 0 Then
                tempFilter = 0
                humidityFilter = 0
                status = HumidiProbeGetSingleValue(handle_Renamed, temp, tempFilter, humidity, humidityFilter)
                If status > 0 Then
                    temperatura = CSng(temp)
                    humedad = CSng(humidity)
                    Return 1
                Else
                    tempFilter = 0
                    humidityFilter = 0
                    Call HumidiProbeCloseUnit(handle_Renamed)
                    Return 0
                End If
            Else
                tempFilter = 0
                humidityFilter = 0
                Call HumidiProbeCloseUnit(handle_Renamed)
                Return 0
            End If
        Catch ex As Exception
            Call HumidiProbeCloseUnit(handle_Renamed)
            Return 0
        End Try
    End Function
    Public Function iniciar_pico() As Short
        Try
            handle_Renamed = HumidiProbeOpenUnit()
            Return handle_Renamed
        Catch ex As Exception
            Return 0
        End Try
    End Function
    Public Function cerrar_pico() As Short
        Try
            handle_Renamed = HumidiProbeCloseUnit(handle_Renamed)
            Return handle_Renamed
        Catch ex As Exception
            Return 0
        End Try
    End Function

End Class

'Webservice

Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports PicoDLL.PicoDLL
<WebService(Namespace:="http://localhost/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Public Class Service
   
    <WebMethod()> _
    Public Function TemperaturaHumedad(ByRef temperatura As Short, ByRef humedad As Short) As Short
        Dim objDLL As New PicoDLL.PicoDLL
        Try

            If objDLL.iniciar_pico() <> 0 Then
                If objDLL.PicoDatos(temperatura, humedad) <> 0 Then
                    objDLL.cerrar_pico()
                    Return 0
                Else
                    temperatura = 0
                    humedad = 0
                    objDLL.cerrar_pico()
                    Return 1
                End If
            Else
                temperatura = 0
                humedad = 0
                objDLL.cerrar_pico()
                Return 1
            End If
        Catch ex As Exception
            temperatura = 0
            humedad = 0
            objDLL.cerrar_pico()
            Return 1
        End Try
    End Function

End Class

'Call to webservice:

Dim WS As New localhost.Service()
WS.Credentials = System.Net.CredentialCache.DefaultCredentials
Dim items As Short = WS.TemperaturaHumedad(temp, humidity)


Any ideas? Thank you
cccsaih
Newbie
 
Posts: 0
Joined: Tue Nov 22, 2011 11:09 am

Re: I have no access to humidiprobe.dll data from vb.net

Postby Martyn » Thu Jan 19, 2012 11:03 am

Details about the API, including HumidiProbeGetUnitInfo, can be found in the manual which can be downloaded from http://www.picotech.com/document/brochures.html?id=34

If you are unable to open the device on the second, or subsequent passes, then it suggests that the device is still open in the application. I would suggest trying the existing handle to get data.
Martyn
Technical Specialist
Martyn
Site Admin
Site Admin
 
Posts: 2287
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots


Return to .Net Languages (C#, VB.Net, .)

Who is online

Users browsing this forum: No registered users and 0 guests