X10 Community Forum

🖥️ActiveHome Pro => SDK => Topic started by: EL34 on October 22, 2008, 10:30:30 AM

Title: Query plc does work, but.................
Post by: EL34 on October 22, 2008, 10:30:30 AM
Quote
I have emailed X10 about this problem.  There has been no response so far, but this might explain your problem:

The issue with the SDK is that the ahscript.dll file supplied in the SDK is version 3.0.0.183 while the version supplied with AHP is 3.0.0.200.  The most obvious problem with this is that software that uses the SDK version of the file gets erroneous results when attempting to use the “queryplc” command.  Many that have tried to develop software using the SDK have complained that the “queryplc” command always returns a result of 0.  Granted this is only an issue if the developer or end user doesn’t have AHP installed, or the developed software accesses a local copy of ahscript.dll instead of the one installed by AHP, but it does lead to a lot of frustration when trying to develop software and the “queryplc” command doesn’t appear to work.

Bill's info is above is correct.

I could not remember why query plc was working for me, so I did a test just now.
I am able to make query plc work only if the module I am inquiring about is actually installed in AHP.
I don't use AHP and it is not running at the time I do my queries, but I do have it installed on the PC that is doing the queries with my VB 2008 express program.

If I do a query on a module that is not set up in AHP, I get a zero on the query, even if the module is actually on.

This does not help developers who want to distribute their software to people who do not have AHP installed.

If you do have AHP installed on your PC and are only doing personal stuff with your own programs, go ahead and add the modules to AHP that you need to query.
Test this and see if it works for you after doing that.

Here's a screen shot of me doing my test on G16 module.
I have the G16 module installed in AHP, but AHP is not running.

I am turning G16 on and off with the buttons at the bottom of the form.
I am doing the query with the button at the bottom of the form after turning the module on or off.
The lines below each query are an x10 traffic monitor reporting what x10 traffic has been received.
Title: Re: Query plc does work, but.................
Post by: EL34 on October 23, 2008, 10:28:42 PM
Anyone test this to see if it works?
Title: Re: Query plc does work, but.................
Post by: -Bill- (of wgjohns.com) on October 24, 2008, 12:39:22 AM
Sorry, I haven't had time to test if it requires all the modules to be registered in AHP or not.

My first impression, based on earlier tests with my own software makes me think that the issue is the version of the ahscript.dll file and not AHP registration of the modules, but I may be wrong.

I will try to get around to testing both possibilities soon.

 >!
Title: Re: Query plc does work, but.................
Post by: EL34 on October 24, 2008, 08:20:49 AM
I only use AHP to turn a module on and off at dusk and dawn.
Easier than me programming dusk and dawn in my program.

I wonder if the modules are registered in the cm15a when I download the macro?

I cannot get any non AHP modules to respond to query but installed modules do just fine.
Title: Re: Query plc does work, but.................
Post by: TDawg on October 31, 2008, 11:22:17 PM
Hi,

I have the same problem with queryplc always returning 0. Sendplc works fine. I have the CM15U from Marmitek. The module(s) in question are all registered in AHP. The problem occurs whether AHP is running or not. The CM15 is of course connected and powered. Modules are active.

What do you mean "the version [of ahscript.dll] supplied with AHP is 3.0.0.200"? - the ahscript.dll only comes with the SDK surely? I have only one version on my system that's for sure...and it's the 183 version from the SDK... ???

Here's my VB6 code:
-----
Option Explicit
Dim WithEvents ActiveHomeObj As ActiveHomeScriptLib.ActiveHome
Dim dump, res

Private Sub Form_Load()
   Set ActiveHomeObj = New ActiveHome
   dump = ActiveHomeObj.SendAction("sendplc", "h4 on")
    res = ActiveHomeObj.SendAction("queryplc", "h4 on")
   dump = MsgBox("H4 Status: " & res)

End Sub
-----
I always get the message "H4 Status: 0"

Help! 
Title: Re: Query plc does work, but.................
Post by: -Bill- (of wgjohns.com) on November 01, 2008, 01:56:30 AM
Quote
I have emailed X10 about this problem.  There has been no response so far, but this might explain your problem:

The issue with the SDK is that the ahscript.dll file supplied in the SDK is version 3.0.0.183 while the version supplied with AHP is 3.0.0.200.  The most obvious problem with this is that software that uses the SDK version of the file gets erroneous results when attempting to use the “queryplc” command.  Many that have tried to develop software using the SDK have complained that the “queryplc” command always returns a result of 0.  Granted this is only an issue if the developer or end user doesn’t have AHP installed, or the developed software accesses a local copy of ahscript.dll instead of the one installed by AHP, but it does lead to a lot of frustration when trying to develop software and the “queryplc” command doesn’t appear to work.

Bill's info is above is correct.

I could not remember why query plc was working for me, so I did a test just now.
I am able to make query plc work only if the module I am inquiring about is actually installed in AHP.
I don't use AHP and it is not running at the time I do my queries, but I do have it installed on the PC that is doing the queries with my VB 2008 express program.

If I do a query on a module that is not set up in AHP, I get a zero on the query, even if the module is actually on.

This does not help developers who want to distribute their software to people who do not have AHP installed.

If you do have AHP installed on your PC and are only doing personal stuff with your own programs, go ahead and add the modules to AHP that you need to query.
Test this and see if it works for you after doing that.

Here's a screen shot of me doing my test on G16 module.
I have the G16 module installed in AHP, but AHP is not running.

I am turning G16 on and off with the buttons at the bottom of the form.
I am doing the query with the button at the bottom of the form after turning the module on or off.
The lines below each query are an x10 traffic monitor reporting what x10 traffic has been received.


I finally got around to doing a proper test on this theory.

I renamed my .ahx file and forced AHP to start with a new empty file, i.e. no rooms, modules or macros defined.

I cleared the interface and then downloaded the empty .ahx setup.

In the downloaded setup, the "Monitored House Code" was "L" and I changed the transceived house code selections so that all house codes are transceived.

I then ran a JScript program I had written some time back that uses queryplc to show the status of modules.

The "Monitored House Code" (house code "L") modules jumped right up with their status.

The other addresses came up as "undefined".

As a test, I used a plug-in stand-alone X10 controller to send "P2 On" and "P2 Off" commands (pressing the "Refresh Staus" button in my program after each command).

The "Non-Monitored" P2 address changed appropriately from "undefined" to "On" then "Off" ad infinitum, as expected.

My conclusion is that, as I believed, queryplc reports the correct module status even if the module is not defined in AHP or the CM15A.

Only modules assigned to the "Monitored House Code" will be tracked by the CM15A when the computer is off.

When the computer is on, the X10 service will track all module states, but once turned off and restarted, the X10 service will report "unknown" as the module state of any module that is not on the "Monitored House Code" until it sees a command for the non-monitored module.

Clear as mud?  ;)

 >!
Title: Re: Query plc does work, but.................
Post by: EL34 on November 01, 2008, 08:26:08 AM
Ah, ok, that splains why I am able to get good queries from that G16 module in my test above.
I have AHP set to automatically detect the monitored house codes
G code is one of 5 house codes that is being monitored in AHP.

I only use AHP for one macro, a dusk and dawn macro
1) The AHP macro works fine and
2) It's way more effort to write the code for a dusk and dawn module on/off to replace that macro.

When I download that one macro to the CM15A, the monitored house codes must also be downloadeded into the CM15A???

After I download that macro, I don't use AHP.
Title: Re: Query plc does work, but.................
Post by: -Bill- (of wgjohns.com) on November 02, 2008, 12:22:53 AM
Ah, ok, that splains why I am able to get good queries from that G16 module in my test above.
I have AHP set to automatically detect the monitored house codes
G code is one of 5 house codes that is being monitored in AHP.

I only use AHP for one macro, a dusk and dawn macro
1) The AHP macro works fine and
2) It's way more effort to write the code for a dusk and dawn module on/off to replace that macro.

When I download that one macro to the CM15A, the monitored house codes must also be downloadeded into the CM15A???

After I download that macro, I don't use AHP.

Yes, downloading timers and macros also downloads the monitored house code setting.

However, what I was really saying above is that queryplc works to retrieve the last known status of any module whether defined in AHP or not.

The CM15A itself keeps track of the last known status of modules on the "Monitored House Code" and so queryplc can retrieve their status even if it changes when the computer is off.  The status of other modules is tracked by the X10 service running on the computer and should come up as undefined until the X10 service sends or receives an X10 signal for that module while the computer is running.
Title: Re: Query plc does work, but.................
Post by: EL34 on November 02, 2008, 07:53:24 AM
Ok, thanks Bill
Title: Re: Query plc does work, but.................
Post by: iraj.shafagh on December 12, 2008, 05:50:21 AM
hi
plz chek this code, may be useful

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, bszParm3, , bszParm4, , bszParm5, bszReserved

End Sub

 ;)
Title: Re: Query plc does work, but.................
Post by: USdangerboy on December 28, 2008, 02:55:11 AM
This works fine, but I get '-1' for off and '1' for on.  I used the following function myself so I can call it anytime.

Example to CALL the function
GetUnitStatus("c2")
or more appropriately ...
If GetUnitStatus("c2") = False Then SendCommand("c2 bright 25")

The Function itself
Code: [Select]
   
Public Function GetUnitStatus(ByRef unitID As String) As Boolean
        Dim myStatus
        ActiveHomeObj = New ActiveHome
        myStatus = ActiveHomeObj.SendAction("queryplc", unitID + " on")
        Console.WriteLine("DEBUG: Query of unit " + UCase(unitID) + " returned: " + Convert.ToString(myStatus))
        If myStatus = -1 Then Return False
End Function

Here is the console output when I run this c2 starts out ON, fyi

DEBUG: Query of unit C2 returned: 1
NOTE: Now turning off Family Room Lights (C2)
ACTION->RecvPlc CODE->c2        CMD->Off        PAR3->  PAR4->  PAR5->
------------------------------------------------------------------------------
DEBUG: Query of unit C2 returned: -1
NOTE: Found lights off, now setting Family Room Lights to level 25 (C2)
ACTION->RecvPlc CODE->c2        CMD->Bright     PAR3-> 25       PAR4->  PAR5->
------------------------------------------------------------------------------


Hope this helps :-)
Title: Re: Query plc does work, but.................
Post by: andrey on January 02, 2009, 02:37:12 PM
Hello,

I have the same problem as TDawg. I have only one ahscript.dll in my system and it is the 183. I downloaded the AHC and the SDK this week and reinstalled (December/January) and it is still the 183.

And as him, I had no success with queryplc, I've tried to change the house code, add the module and everything that was mentioned in any of the 5 or 6 previous threads about the queryplc.

Bill, maybe only you has this ahscript version 3.0.0.200. That's why it only works with you! Where did you get it? (btw., I tried the link you provided in other threads and it was the same... 183).

Thanks,

Andrey

Title: Re: Query plc does work, but.................
Post by: -Bill- (of wgjohns.com) on January 03, 2009, 02:11:35 AM
Hello,

I have the same problem as TDawg. I have only one ahscript.dll in my system and it is the 183. I downloaded the AHC and the SDK this week and reinstalled (December/January) and it is still the 183.

And as him, I had no success with queryplc, I've tried to change the house code, add the module and everything that was mentioned in any of the 5 or 6 previous threads about the queryplc.

Bill, maybe only you has this ahscript version 3.0.0.200. That's why it only works with you! Where did you get it? (btw., I tried the link you provided in other threads and it was the same... 183).

Thanks,

Andrey



I honestly can't say where I got 3.0.0.200.  My best guess would be either a very early AHP or AHP update, or an earlier version of the SDK.   ???

I have emailed X10 about the issue, but, so far no reply as to why they reverted to an older version of the file.   :(
Title: Re: Query plc does work, but.................
Post by: rockinthesixstring on June 09, 2009, 12:18:24 AM
I am building a web app and am having some issues with this as well.  For starters it is not allowing me to create an ActiveX object, so I am stuck using the EXE instead of the DLL.

Code: [Select]
    Public Shared Function OnOffStatus(ByVal address As String) As Boolean
        Dim onoff As Boolean
        Dim startInfo As System.Diagnostics.ProcessStartInfo
        Dim proc As System.Diagnostics.Process

        startInfo = New System.Diagnostics.ProcessStartInfo()

        With startInfo
            .FileName = "cmd"
            .Arguments = "/C """ & AHSDK & """ queryplc " & address & " on"
            .LoadUserProfile = True
            .UseShellExecute = False
            .RedirectStandardOutput = True
        End With

        proc = System.Diagnostics.Process.Start(startInfo)

        Select Case proc.StandardOutput.ReadToEnd
            Case "0" : onoff = False
            Case "-1" : onoff = False
            Case "1" : onoff = True
        End Select

        proc.WaitForExit()

        Return onoff
    End Function

The problem is that it is not returning anything (not a 1, not a 0, nothing).  Does anyone know what could be the problem?
Title: Re: Query plc does work, but.................
Post by: rockinthesixstring on June 11, 2009, 04:08:37 PM
I wanted to also mention that I have tried running the exact same command from the command line and am getting no results.

I have run
Code: [Select]
C:\Program Files (x86)\Common Files\X10\Common>ahcmd "queryplc" "a1 on" and nothing is returned, it simply goes down a line without anything returnd in the CMD screen... anything I'm missing?

PS: I am running the 200 version.
Title: Re: Query plc does work, but.................
Post by: abreup on November 23, 2009, 09:22:05 AM

I'm also trying to change from .exe to the .dll on a VB .NET code. Is there any new API compliant whith the .NET platform?

Thank you,

From Brasil:

Abreup
Title: Re: Query plc does work, but.................
Post by: dbemowsk on January 03, 2010, 04:29:23 PM
I was doing a little playing with the SDK today with some PHP.  I wanted to test the sample PHP script just to see what it looked like.  I copied the PHP folder from the SDK under program files over to my web folder, which by the way contained a copy of ahcmd.exe.  When I tried it, it did not work for me.  With some looking, I noticed that the ahcmd.exe file that was in the PHP folder was 9.00Kb in size and was version 3.0.0.159.  The version that was in the c:/.../AHSDK/bin folder was 60.0Kb in size and was version 3.0.0.183.  When I copied that over to my web folder, it worked like a charm.

I have written a little PHP/MySQL script that uses the queryplc command to show me a map of my house with any lights/appliances that are on.  The ahcmd.exe file is what does all the work.  I could be wrong, but I don't think the ahscript.dll file has any interaction with the ahcmd file.  I have seen posts on here that people have changed their ahscript.dll file to version 3.0.0.200 and got things working.  I have tried different versions of the .dll file and have had no change in function with my PHP script.

I did notice though that the highest version of the ahscript.dll that I have is 3.0.0.234, but the highest version of the ahcmd.exe file is 3.0.0.183.  Is there an updated ahcmd file out there somewhere?  Not that it matters that much because this one is working, but if there is one with more features, I am all for new features.

Dan
Title: Re: Query plc does work, but.................
Post by: Martyn on January 24, 2010, 03:36:49 AM
.. not for me Dan...

I too have both versions of ahcmd.exe, but neither of them return anything when I command <ahcmd queryplc "a2 on">

However, i only have the older version of ahscript.dll (3.0.0.183) and can't find 3.0.0.200 or greater anywhere. If anyone has this please can you send it to me?

Still floggin' that dead donkey i'm afraid....     >*<
Title: Re: Query plc does work, but.................
Post by: dbemowsk on January 24, 2010, 04:45:12 AM
martyn,

I am guessing that you are using PHP.  Here is the little code function that I am using that works well.

/*
execute an X-10 command
types : sendplc, queryplc, sendrf

For queryplc command, return[1] will be either -1 (unknown), 0 (off), or 1 (on)
when sending "on" to the $action parameter
*/
function x10cmd($type, $hcode, $ucode, $action, $time="") {
$cmd = $type." ".$hcode.$ucode." ".$action." ".$time;
exec(".\bin\ahcmd ".$cmd, $return[0], $return[1]);
return $return;
} //End function x10cmd


To use this with queryplc on module A1, use:

$status = x10cmd("queryplc", "A", "1", "on");

From there you would check $status[1] for either -1 (unknown), 0 (off), or 1 (on)

Make sure that you point the exec line to the folder that you have ahcmd.exe in.  In my example, I have the file in a folder called bin relative to where the script is executed from.  Also, remember to check that you have version 3.0.0.183 of the ahcmd.exe and that the file size is 60.0kb.

If you need any more assistance with this let me know.

Dan B.
Title: Re: Query plc does work, but.................
Post by: AidinEslami on March 20, 2010, 10:46:39 PM
hi
please mail me version 3.0.0.200
aidin.eslami[at]gmail.com

thank you soooooo much