Here's some VB6 code for an example of how to use the queryplc and the sendplc with the CM15A
This was used with the CM15a and the AM14A two way appliance module.
You'll need the ahscript.dll component added to the project along with the Microsoft Windows Common Controls (SP6) for the status bar.
What's needed:
- 1 Form
- 1 Command Button
cmdExecute
- 2 Option Buttons with Index values of 0 and 1
optPLC(0)
optPLC(1)
- 1 Status Bar
stbX10
- 1 TextBox
txtHouseCode
-1 Check Box
chbOn
' ****************************************************
Option Explicit
Private Sub ActiveHome1_RecvAction(ByVal bszAction As Variant, _
ByVal bszParm1 As Variant, ByVal bszParm2 As Variant, ByVal bszParm3 As Variant, _
ByVal bszParm4 As Variant, ByVal bszParm5 As Variant, ByVal bszReserved As Variant)
Debug.Print bszAction, bszParm1, bszParm2
End Sub
Private Sub cmdExecute_Click()
Dim strX10command As String
Dim strOnOff As String
Dim lngReturn As Long
' What are we requesting? On or off?
If chbOn.Value = 1 Then
strOnOff = " on"
Else
strOnOff = " off"
End If
' Determine if sendplc or queryplc was sent and execute command
If optPLC(0).Value = True Then
strX10command = "sendplc"
ActiveHome1.SendAction strX10command, txtHouseCode.Text & strOnOff
Else
strX10command = "queryplc"
lngReturn = ActiveHome1.SendAction(strX10command, txtHouseCode.Text & " on")
End If
' Determine if queryplc was sent and return the status
' the queryplc returns 1 is the status is on, 0 if the status is off, and possibly -1 for other returns.
If optPLC(1).Value = True Then
If lngReturn = 1 Then
stbX10.Panels(1).Text = "Status " & txtHouseCode.Text & " is " & "ON"
ElseIf lngReturn = 0 Then
stbX10.Panels(1).Text = "Status " & txtHouseCode.Text & " is " & "OFF"
Else
stbX10.Panels(1).Text = "Status " & txtHouseCode.Text & " is " & lngReturn
End If
End If
'
End Sub
'***************************************
This was run with the latest SDK.
Responses came back correct. Did have to reboot. As first try was getting incorrect responses.
regards,
Hank