Premise How do you execute server-side code?

Motorola Premise

123

Senior Member
I need to be able to send data to Premise from a non-Windows machine ... so that rules out using MiniBroker. The goal is to have my 3COM Audreys report their operating status to Premise. I'm hoping Premise can do some sort of CGI-like operation and allow for this:

http://PremiseServer/MyProgram?var1=MyData&var2=MoreData

where "MyProgram" is a method that updates the properties of a Premise object. I'm hoping some Premise gurus know exactly what I'm after and can explain how to do this!


PS
Damon Dean's Jukebox example apparently relies on "server-side VBScript" to manipulate playlists ... but I think it does this via MiniBroker. I need a way to execute server-side scripting without the use of MiniBroker. I've looked for clues in his code but its design is beyond my current skilll level.
 
I've seen URLS with the following syntax:

http://PremiseServer/sys/{38DDEFB2-4FFC-41...}?d??RenderPage

The brace-enclosed string is the GUID of a Premise object. The ?d is a mystery to me as is the double ?? syntax. I recognize Renderpage as being a method. So this URL is executing some object's Renderpage method ... or in plain English, show me the object's web page!

I dumped the entire datastore out and searched the raw XML code for the GUID. It refers to an object in the AutomationBrowser (naturally).

OK, so I see you can call an object's methods but can you pass parameters to the method?
Does anyone know more about the ?d?? syntax?
 
For the two other Premise users in the world (that many!?!) who are following this thread, I've made a little bit of progress.

I studied how xBrowser works (it doesn't use sysconnector) and confirmed that a URL containing an object's GUID followed by a method name will execute the method. So if KitchenLight's GUID is ABC678 and it has a method called PowerON then this URL will turn on KitchenLight:
http://PremiseServer/sys/{ABC678}?d??PowerON

There's more I need to learn because this technique is a quick way to crash Premise's web-server! I got this far by poking around in xBrowser's code but I must be corrupting a web-session, or something, because after executing the URL once or twice, the web-server becomes unresponsive. The Premise Server service isn't completely dead but the web-server portion is unhappy ... so there's more research needed.

It's at times like these that I wish some of the old hands could drop by this forum ...
 
http://PremiseServer/sys/{ABC678}?d??PowerON

This is pretty complex. In the case you list, the 'd' indicates an InvokeMethod call. Question marks are used to delimit the parts of the request. The ?? just means that the "target" is not specified. The target is the object that receives the response and is really geared to the automation browser model and is oriented around returning responses.

The simplest way to do what you want is to run a command, which does not return anything. However, you will probably need to add commands to the objects you want to deal with.

Add a "Command" to an object's class in SYS. For instance, you could add a "TogglePower" command to the light class. Add a light object in the home. In the properties window, hold down ctrl and double-click on the "Type" property. This navigates you to the light class. Right click on the light class object in the explorer pane and add a new command. Call it "TogglePower". In the property window, click the "Property" property. Select the "Schema\Device\Power\PowerState" property. For the "Action" property select "Toggle". You don't need to specify a "Value".

The URL http://PremiseServer/sys/{ABC678}?g?TogglePower will run the command and toggle the powerstate of the light specified by the GUID.

Note: there is an URL syntax for setting a property value, but that uses an HTTP POST (not a GET) and the value is in the message body, not in the URL itself, so that is tricky.

I hope this helps.
--jim
 
Jim,

Man, I hope you have the time to shed even more light on this undocumented subject!

I've been learning Premise scripting from the available examples but there aren't that many dealing with web-development ... and the few I've found focus on using SYSConnector/AutomationBrowser. Everything I know is based on Rob Brun's XBrowser module and that is a derivative of Premise's MiniBrowser.

I've created a picture-frame application ("PhotoFrame.xdo") that does not use SYSConnector because it must work with non-Windows-based Internet Appliances (i.e. 3COM Audrey). Although PhotoFrame works, based on your revelations, I'm concerned I might be using Premise's web server incorrectly!

PhotoFrame's URLs look like this: PremiseServer/sys/{GUID}?d??SelectPhoto(1)

SelectPhoto is a ClassFunction and it takes one parameter to indicate the sequence of displayed photos (-1=Previous, 0=Pause, 1=Next). Your example opened my eyes to new possibilities (I've never seen the "?g?" command) but it is important that I can pass parameters (via the URL).

... the 'd' indicates an InvokeMethod call. Question marks are used to delimit the parts of the request. The ?? just means that the "target" is not specified. The target is the object that receives the response and is really geared to the automation browser model and is oriented around returning responses.

Question 1: Proper Syntax
Based on your explanation, I've used the URL syntax designed for AutomationBrowser. What is the proper URL for non-AutoBrowser purposes?

Question 2: Detailed Syntax Explanation
You indicated that "??" simply meant that the target object is missing (i.e. something can go between the two question marks). I guess the full URL syntax looks something like this: "{GUID}?MysteryLetterCode?TargetObject?Method".
Is that correct?

Question 3: Letter Codes
So "d" in "?d??" means InvokeMethod. Your example used "?g?". What is this Mystery Letter Code "g" and what other letter codes are understood by the web server? There's no double-question mark used in your example. Does this mean that "g" cannot specify a target object?

Question 4: Target Object
I don't understand the purpose of the "target object" you've described. My simple brain says, SelectPhoto is a method of the object identified by GUID ... isn't this the "target"?

Question 5: GetUniqueID
In XBrowser and MiniBrowser, there's a curious URL usage that makes no sense to me. Here's an excerpt from mbRenderColorPicker:
Code:
<A href = ""/sys/" & this.ObjectID & "?d??mbSelectColor(" & system.GetUniqueId() & ", 'aliceblue')"">
mbSelectColor is a ClassFunction that takes two parameters but it does absolutely nothing with the first one ... this funky GetUniqueID value! What's weirder is that this UniqueID is force-fed to functions even if they don't take parameters! Most URLS are generated using the mbGetAnchor function where the mysterious Unique ID is included. What's that all about?
Code:
Function mbGetAnchor(func, img)
	mbGetAnchor = "<A href=""/sys/" & this.ObjectID & "?d??" & func & "(" & system.GetUniqueId() & ")""><IMG class=""ImageButton"" src=""/Plugins/Images/" & img & """></A>"
End Function

Question 6: HTTP POST Usage
Note: there is an URL syntax for setting a property value, but that uses an HTTP POST (not a GET) and the value is in the message body, not in the URL itself, so that is tricky.
Please, please, please explain how this is done! I want to use the <FORM> tag in my web pages but I don't know what to specify for the FORM's "action=" parameter. Using "method=post", I have no idea how to process the results posted back to the web-server. I'm assuming the URI specified in "action" will contain the name of a method ... but how does it receive the results (as a passed parameter?) and what do they look like? Maybe something like this: "name=JimSpr&joined=03.09.08&posts=8".


Thanks for your help ... let me know where to ship the beer! :)
Taras
 
Back
Top