Please login or register.

Login with username, password and session length
Advanced search  

News:

The Buster PiX10Hub is here! Created by the Community, for the Community.:)% #:)

Author Topic: Using SDK with VB 2005 Under Windows XP  (Read 8736 times)

George_Fish

  • Newbie
  • Helpful Post Rating: 0
  • Posts: 2
Using SDK with VB 2005 Under Windows XP
« on: June 03, 2007, 06:26:21 PM »

Can someone help me make this work?

Everything appears to run, no Errors reported; however, nothing works.  Can't turn modules on/off, and no X10 Power Line or RF Activity is reported.

When sending commands, I get the same positive returns whether or not the CM15a is connected.

I have included the test project code below - please advise.

*********************************************************
' VBScript source code

Imports ActiveHomeScriptLib

Imports System


Public Class FishTankTestX10Heater

    Dim WithEvents ActiveHomeObj As ActiveHome
    '
    'Valid/Supported Commands:
    '   ON: <X10 address (range A1 to P16)> on
    '       Examples:   "sendplc", "a3 dim 75"
    '                   "sendrf", "a1 on"   (NOTE: refer to command constants in "Radio Frequency Command Reference"
    '   OFF: <X10 address> off
    '   DIM: <X10 address> dim <dim percentage of 100%)>
    '   BRIGHT: <X10 address> bright <bright percentage of 100%>
    '   All Lights ON: <X10 address (must include Unit Code)> alllightson
    '   All Units OFF: <X10 address (must include Unit Code)> allunitsoff
    '   Extended Code Command: <X10 address> <command> <value> (command and value specified in hex)
    '
    Private Sub FishTankTestX10Heater_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        'create ActiveHome object
        Try
            ActiveHomeObj = CreateObject("X10.ActiveHome")
        Catch exc As Exception
            MsgBox("Initialize X10 err num: " & Str(Err.Number) & " '" & exc.ToString & "'")
        Finally
        End Try
        '
        Select Case SendPLCcmd("f1", "off")
            Case Is = -1
                MsgBox("PLC Command Failed")
            Case Is = 1
                MsgBox("PLC Command Succeeded")
        End Select

        Select Case SendPLCcmd("f1", "on")
            Case Is = -1
                MsgBox("PLC Command Failed")
            Case Is = 1
                MsgBox("PLC Command Succeeded")
        End Select

        Select Case SendPLCcmd("f1", "dim 50")
            Case Is = -1
                MsgBox("PLC Command Failed")
            Case Is = 1
                MsgBox("PLC Command Succeeded")
        End Select

        Select Case CheckOnSTATUS("f1")
            Case Is = 0
                MsgBox("OFF")
            Case Is = 1
                MsgBox("ON")
            Case Is = -1
                MsgBox("Status Unknown")
        End Select


    End Sub
    '
    Function SendPLCcmd(ByVal X10addr As String, ByVal X10cmd As String, Optional ByVal DimPcnt As String = "", Optional ByVal ExtdCmdVal As String = "") As Integer
        '
        'send a1 on
        Try
            ActiveHomeObj.SendAction("sendplc", X10addr & " " & X10cmd)
        Catch exc As Exception
            MsgBox("X10 PLC Command err num: " & Str(Err.Number) & " '" & exc.ToString & "'")
            Return -1
        Finally
        End Try
        '
        Return 1
        '
    End Function
    '
    Function SendRFcmd(ByVal X10addr As String, ByVal X10cmd As String, Optional ByVal DimPcnt As String = "", Optional ByVal ExtdCmdVal As String = "") As Integer
        '
        'send a1 on
        Try
            ActiveHomeObj.SendAction("sendrf", "a1 on")
        Catch exc As Exception
            MsgBox("X10 RF Command err num: " & Str(Err.Number) & " '" & exc.ToString & "'")
        Finally
        End Try
        '
    End Function
    '
    Function CheckOnSTATUS(ByVal X10addr As String) As Integer
        '
        '"queryplc", "a1 on"    Returns: 0 if Off, 1 if on, or -1 if not known
        '
        Dim DeviceOnStatus As Integer
        '
        DeviceOnStatus = ActiveHomeObj.SendAction("queryplc", X10addr & " on")
        Select Case DeviceOnStatus
            Case Is = -1    'ON Status NOT Known
                Return DeviceOnStatus
            Case Else
                Return DeviceOnStatus
        End Select
        '
    End Function

    Function CheckDimSTATUS(ByVal X10addr As String) As Integer
        '
        '"queryplc", "a1 dim"   Returns Percentage of Full Brightness, or -1 if not known
        '
        Dim DeviceDimStatus As Integer
        '
        DeviceDimStatus = ActiveHomeObj.SendAction("queryplc", X10addr & " dim")
        Select Case DeviceDimStatus
            Case Is = -1    'DIM Status NOT Known
                Return DeviceDimStatus
            Case Else
                Return DeviceDimStatus
        End Select
        '
    End Function

    'events from ActiveHome: write out received event
    Sub ActiveHome_RecvAction(ByVal bszRecv As Object _
                            , ByVal vParm1 As Object _
                            , ByVal vParm2 As Object _
                            , ByVal vParm3 As Object _
                            , ByVal vParm4 As Object _
                            , ByVal vParm5 As Object _
                            , ByVal vReserved As Object) Handles ActiveHomeObj.RecvAction

        MsgBox("RecvAction: " & bszRecv & " " & vParm1 & " " & vParm2 & " " & vParm3 & " " & vParm4 & " " & vParm5)

        Dim _bszRecv As String = DirectCast(bszRecv, String)
        Dim _DevAddr As String = DirectCast(vParm1, String)
        Dim _Command As String = DirectCast(vParm2, String)
        Dim _CmdData As String = DirectCast(vParm3, String)
        Dim _rfTimeStamp As String = DirectCast(vParm4, String)
        Dim _vParm5 As String = DirectCast(vParm5, String)
        Dim _vReserved As String = DirectCast(vReserved, String)
        Dim PercentDIM As Integer

        Dim SysTimeStamp As DateTime = Now

        Select Case _bszRecv
            '
            Case Is = "recvpld" 'From the Power Line
                '
                '"receive source", "X10 Address", "PLC command", "additional data"
                'Like:
                '   A1 On = "recvplc", "a1", "on"
                '   B3 dimmed 30% = "recvplc", "e1", "dim", "30"
                '
                Select Case UCase(_DevAddr)
                    Case Is = "F1"

                        Select Case UCase(_Command)

                            Case Is = "ON"

                            Case Is = "OFF"

                            Case Is = "DIM"

                                PercentDIM = CInt(_CmdData) 'Whole Percent Only

                        End Select
                End Select

            Case Is = "recvrf"  'From an RF Device
                '
                '"receive source", "X10 Address", "RF command", "key status", "time stamp"
                'Like:
                'User Presess A2 On with a PalmPad
                '   1st return: "recvrf", "a2", "On", "0", "timestamp"
                '   Followed by: "recrf", "a2", "On", "-1", "timestamp"
                '
                Select Case UCase(_DevAddr)
                    Case Is = "F1"

                        Select Case UCase(_Command)

                            Case Is = "ON"

                            Case Is = "OFF"

                            Case Is = "DIM"

                                PercentDIM = CInt(_CmdData) 'Whole Percent Only

                        End Select
                End Select

        End Select
        '
    End Sub
    '
End Class
Logged

Tuicemen

  • Administrator
  • Hero Member
  • ****
  • Helpful Post Rating: 271
  • Posts: 10016
  • I don't work for X10, I use it successfuly!
    • Tuicemen Forum
Re: Using SDK with VB 2005 Under Windows XP
« Reply #1 on: June 03, 2007, 06:48:05 PM »

Try this change:
Dim WithEvents ActiveHomeObj As ActiveHome
to
 Dim WithEvents ActiveHomeObj As ActiveHomeScriptLib.ActiveHome
also
      Try
            ActiveHomeObj = CreateObject("X10.ActiveHome")
        Catch exc As Exception
            MsgBox("Initialize X10 err num: " & Str(Err.Number) & " '" & exc.ToString & "'")
        Finaly
        End Try
       
to
        Try
            ActiveHomeObj = New ActiveHome
        Catch exc As Exception
            MsgBox("Initialize X10 err num: " & Str(Err.Number) & " '" & exc.ToString & "'")
        Finally
        End Try
« Last Edit: June 03, 2007, 06:49:42 PM by Tuicemen »
Logged
Please Read Topic:
General Forum Etiquette
Before you post!

Find extra info @ My forum

George_Fish

  • Newbie
  • Helpful Post Rating: 0
  • Posts: 2
Re: Using SDK with VB 2005 Under Windows XP
« Reply #2 on: June 04, 2007, 08:36:29 PM »

Thank you!

Your suggested changes worked.  I'll continue with my experiments to make sure I have all the functionality needed for the application.

The ON, OFF, and DIM work.

The "CheckOnStatus" appears to always return a zero.  I have seen several notes in the forum suggesting that this sporadically works depending on software version.

Can you comment

Again, any help would be greatly appreciated.
Logged

Tuicemen

  • Administrator
  • Hero Member
  • ****
  • Helpful Post Rating: 271
  • Posts: 10016
  • I don't work for X10, I use it successfuly!
    • Tuicemen Forum
Re: Using SDK with VB 2005 Under Windows XP
« Reply #3 on: June 05, 2007, 03:07:52 PM »

Glad the suggested changes were "Helpful"!  ;)
The "checkonstatus" I'm told only works with 2 way modules :(. If you don't have any then that is why you keep getting the same responce.
I don't have any two way modules so I can't help with that! :-[
Logged
Please Read Topic:
General Forum Etiquette
Before you post!

Find extra info @ My forum

technobabble

  • Newbie
  • Helpful Post Rating: 0
  • Posts: 2
Re: Using SDK with VB 2005 Under Windows XP
« Reply #4 on: October 26, 2007, 04:57:45 PM »

I am running VB 2005 on WinXP SP2 and downloaded SDK last week. The following snippet of code works. It returns the status of some very old X10 lamp modules as best AHPro can remember them. I believe the X10nets service keeps track of commands sent??

' queryplc
        Dim DeviceOnStatus As Integer
        DeviceOnStatus = ActiveHomeObj.SendAction("queryplc", "b5 on")
Logged

-Bill- (of wgjohns.com)

  • Advanced Member
  • Hero Member
  • ******
  • Helpful Post Rating: 81
  • Posts: 1340
  • He's just this guy. You know?
    • wgjohns.com
Re: Using SDK with VB 2005 Under Windows XP
« Reply #5 on: October 26, 2007, 11:24:40 PM »

I am running VB 2005 on WinXP SP2 and downloaded SDK last week. The following snippet of code works. It returns the status of some very old X10 lamp modules as best AHPro can remember them. I believe the X10nets service keeps track of commands sent??

' queryplc
        Dim DeviceOnStatus As Integer
        DeviceOnStatus = ActiveHomeObj.SendAction("queryplc", "b5 on")


Basically correct.  The CM15A keeps track of the 16 devices on the "Monitored House Code" (as set in AHP) and is polled on startup of the service, so those devices status will be more frequently accurate.

Other (non-monitored) house codes will return what the X10 service "remembers" about them.
Logged
-Bill- (of wgjohns.com)
bill@wgjohns.com

In the real world, the only constant is change.

When I'm online you can find me in the Home Automation Chat Room!
 

X10.com | About X10 | X10 Security Systems | Cameras| Package Deals
© Copyright 2014-2016 X10.com All rights reserved.