[Message Prev][Message
Next][Thread Prev][Thread Next][Message
Index][Thread Index]
RE: setting/reading global variables from another app
Hi,
> i'm instantiating xpl inside another app running vbscript:
>
> Set xPL = WScript.CreateObject("xPL.xPLCtl")
>
> the app shows up in xpl hal & configures & sends heartbeats.
>
> can i read and set xplhal globals from here? what is the
> syntax? thanks!
There are currently two ways to get a global's value from xPLHal.
The first way is to use XHCP. This is how the xPLHal Manager connects to
xPLHal. It is a custom TCP-based protocol on port 3865.
The protocol is similar to other Telnet-based protocols like SMTP.
You open a connection on port 3865 and send commands to the xPLHal
server, and it replies with the appropriate responses.
E.g. try firing up a Telnet session and connecting to port 3865 on your
xPLHal server - below is a sample conversation of how to retrieve a
variable called Cbus_Hall.
(lines beginning with "C" are the bits you type in (client), and
lines
beginning with "S" are the responses from xPLHal (server)).
S: 200 XPL-XPLHAL.MERCURY (Version 1.44.1907.31912)
C: getglobal cbus_hall
S: 291 Global value follows
S: 255
S: .
C: quit
S: 221 Closing transmission channel - goodbye.
Of course, this approach requires that you write some custom code, but
it will give you maximum flexibility in terms of your interactions with
xPLHal.
(BTW, the full protocol for communicating with xPLHal is available on
www.xplproject.org.uk - just look for the XHCP specification)
An easier approach may be to use xPL messages to communicate the value
of a global, as follows:
Write your self a simple sub routine in xPLHal, like this:
Sub GetMyGlobal()
call
xpl.SendMsg("xpl-stat","*","sensor.basic","device=myglobal"
&
vbLf & "type=global" & vbLf & "current="
& sys.value("myglobal"))
End Sub
Then, from within your xPL app, just send a message to your xPLHal
server like this:
Xpl-cmnd
{
Hop=1
Source=your_xpl_app
Target=your_xplhal_server (cannot be *)
}
Control.basic
{
Device=GetMyGlobal
Type=sub
Current=execute
}
xPLHal will then run your GetMyGlobal sub, and this will then cause an
xPL message to be sent out containing the current value of your global,
which your xPL app can watch for, and store.
Hope that helps,
Regards,
John
xPL Links: http://www.xplproject.org.uk http://www.xplhal.com http://www.xpl.myby.co.uk
To Post a Message: ukha_xpl@xxxxxxx
To Subscribe: ukha_xpl-subscribe@xxxxxxx
To Unsubscribe: ukha_xpl-unsubscribe@xxxxxxx
xPL Main Index |
xPL Thread Index |
xPL Home |
Archives Home
|