Please login or register.

Login with username, password and session length

Author Topic: Can variables be passed into ahscript using xml-rpc?  (Read 6893 times)

jpnoon

  • Newbie
  • Helpful Post Rating: 0
  • Posts: 2
Can variables be passed into ahscript using xml-rpc?
« on: September 07, 2010, 02:18:41 PM »

I would like to turn a particular lamp module on or off depending on the value (0 or 1) of a parameter in another program resident on the same WindowsXP server.  I can pass two strings values, i.e. (1) the lamp module address (e.g. A1) and (2) the lamp value (on or off) in an xml-rpc.  Can ahscript read the xml-rpc and pass the appropriate information to AHP?
Logged

dbemowsk

  • Hero Member
  • *****
  • Helpful Post Rating: 21
  • Posts: 428
    • PHP Web Scripting
Re: Can variables be passed into ahscript using xml-rpc?
« Reply #1 on: September 07, 2010, 06:38:49 PM »

I would like to turn a particular lamp module on or off depending on the value (0 or 1) of a parameter in another program resident on the same WindowsXP server.  I can pass two strings values, i.e. (1) the lamp module address (e.g. A1) and (2) the lamp value (on or off) in an xml-rpc.  Can ahscript read the xml-rpc and pass the appropriate information to AHP?

What are you using to create the XML-rpc file?  The ahscript.dll file is used to send and receive commands from AHP but uses a set of parameters to perform the action.  For example, the VBscript below (ahscript.vbs) functions like the ahcmd.exe file, but uses the ahscript.dll.

Dim ActiveHomeObj
Dim Output

Set ActiveHomeObj 
CreateObject("X10.ActiveHome")
Output ""

Sub parseArgs()
    If (
WScript.Arguments.count 3Then
        WScript
.Echo "Incorrect number of arguments passed to the script"
    
Else
        
Output ActiveHomeObj.SendAction(WScript.Arguments(0), WScript.Arguments(1) & " " WScript.Arguments(2))

        While 
Output ""
        
Wend
        WScript
.Echo OutputOutput ActiveHomeObj.SendAction(WScript.Arguments(0), WScript.Arguments(1) & " " WScript.Arguments(2))
    
End If
End Sub

Call parseArgs
()


The line

Output 
ActiveHomeObj.SendAction(WScript.Arguments(0), WScript.Arguments(1) & " " WScript.Arguments(2))

is what does the work.  You can call "cscript ahscript.vbs sendplc A5 ON" from a command prompt and it will turn module A5 on. 

So to answer your question, ahscript has no idea how to parse an xml file and cannot do what you want directly.  You will need some other script or compiled executable to parse the XML and send the commands USING the ahscript.dll.  The reason I asked what you were using to create the XML-rpc file is that maybe you can modify that program or script to send the commands directly.  I might be able to tell you more with more information.

This has been your beginners lesson into the SDK...  rofl
Logged
Dan Bemowski
Owner of PHP Web Scripting LLC
Programmer of RemoteWatch X10
User of any X10 products I can get my hands on.

jpnoon

  • Newbie
  • Helpful Post Rating: 0
  • Posts: 2
Re: Can variables be passed into ahscript using xml-rpc?
« Reply #2 on: September 08, 2010, 12:06:42 PM »

I have been outed. :(  Thanks for the beginner's lesson.

I am a retired engineer and First Lego League team mentor.  This past spring (in the post season), members of our team designed a primitive "one on one" soccer game for Mindstorms NXT robots.  Here's how it works:  When the whistle blows, the opposing robots scramble for a lighted ball using a light homing program, and eventually one of them captures it.  Now what?  How to find the goal?  This is what we came up with.  When the capture event occurs, that robot sends a signal, via Bluetooth, to LabVIEW Education Edition (LVEE) on that robot's computer, and LVEE sends a signal to ActiveHomePro (AHP) to turn on the light at the appropriate goal.  The robot with the ball then heads for that goal.  If the defending robot manages to recapture the ball, the light in his goal goes on and the light in the other goal goes out.

Well, we built the robots and the capture event works, but we never did get the "light up the goal" part of it going, and now, I am trying to solve the problem of how to get the signal from LVEE to AHP.  I have no experience with desktop programming, but I have a little experience with web business application development.  LVEE supports a number of communication schemes including TCP/IP, so I can, in theory at least, send parameters (via SOAP or RPC) from LVEE another web program.  AHP and ahscript have minimum documentation, so I am not sure how to proceed at the AHP end.  I threw up my question just to start a conversation with people who know what they are doing in the AHP world.
Logged

EL34

  • Hero Member
  • *****
  • Helpful Post Rating: 21
  • Posts: 278
    • My X-10 projects
Re: Can variables be passed into ahscript using xml-rpc?
« Reply #3 on: September 10, 2010, 11:41:48 AM »

Hi JP,

I turn things on and off from several different Non X10 programs that are not used as X10 control software.

Instead of the Non X10 program passing a value on to some other program, I just add the simple X10 control code to the program and let it control the x10 device.

For example, I have a security camera program that controls cameras, take snapshots when movement is detected, etc
In that program I turn a light on and off if I am not at home.
It only controls one X10 device, the main program is camera related.

Another example is that I have a greenhouse monitoring program
It's job is to monitor a bunch of One Wire temp, humity, etc sensors
In that program I control one X10 appliance module that turns on overheads fans.

This assumes that you wrote the program and are able to modify it for simple X10 commands
All the programs I write and use are VB2008 .net programs

Not sure if this is what you were asking, but I can help further if this sounds like something you can do.
Logged
W10 - CM15A - AHP 3.301 - i Witness - MyHouse online - Smart Macros - SDK using Visual Basic express 2008
My X10 page-> http://www.el34world.com/Misc/home/X10_0.htm
 

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