.NET with sensor

Moderator: Telldus

.NET with sensor

Postby weekendowel » Sat Nov 17, 2012 2:32 pm

I am using this code to get value from a temperature sensor:

Code: Select all
 private void Form1_Load(object sender, EventArgs e)
        {
             TelldusNETWrapper t = new TelldusNETWrapper();
           
            t.tdRegisterRawDeviceEvent(EventCallbackFunction, null);

        }
        public int EventCallbackFunction(string data, int controllerId, int callbackId, Object obj)
        {
            listBox1.Items.Add(DateTime.Now + data);
         


           

            return 0;
        }


It works and as soon as the temp sensor sends it value it shows up in the listbox. But it works only once, then it stops. What am I doing wrong?
weekendowel
 
Posts: 3
Joined: Sat Nov 17, 2012 2:28 pm

Re: .NET with sensor

Postby weekendowel » Sun Nov 18, 2012 4:05 pm

I wrote the code in VB.NET instead and for anybody interested here it is:

Code: Select all
 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load


        Dim t As New TelldusNETWrapper()

        Dim k As New RawListeningCallbackFunction(AddressOf eventhappened)




        t.tdRegisterRawDeviceEvent(k, Nothing)


    End Sub

    Function eventhappened(ByVal data As String, ByVal controllerId As Integer, ByVal callbackid As Integer, ByVal obj As Object) As Integer

        ListBox1.Items.Add(data)


    End Function


And it is working great. Values keep coming in :-)
weekendowel
 
Posts: 3
Joined: Sat Nov 17, 2012 2:28 pm

Re: .NET with sensor

Postby Brungle » Thu Dec 13, 2012 4:38 pm

hi,
thanks for the code, which temp sensor are you using?
thanks
Brungle
 
Posts: 1
Joined: Thu Dec 13, 2012 4:36 pm

Re: .NET with sensor

Postby weekendowel » Thu Dec 20, 2012 6:08 pm

I´m using a jenkinsbird sensor, but the code should be valid for any sensor
weekendowel
 
Posts: 3
Joined: Sat Nov 17, 2012 2:28 pm


Return to Windows

Who is online

Users browsing this forum: Bing [Bot] and 1 guest