LOGIN  |  REGISTER
Smart Living Made Brilliant!
CASTLEOS FORUM

HomeScripting

A forum for information about scripting with CastleOS. Get samples, suggestions, and other help here

Couple of Quick Scripting Questions Messages in this topic - RSS

Assistive Tech Dad
Assistive Tech Dad
Posts: 114


4/14/2015
Assistive Tech Dad
Assistive Tech Dad
Posts: 114
I am looking to play around with scripting while waiting for my Hub to arrive. I have run into two quick questions in my dive into scripting:
1. Where is the scripting object model stored? I would love to look at that in an object browser (call me crazy, but this is far more useful to me than actual documentation in regards to understanding the capability of something like this). I see the demo script calls a Speak method on a ScriptingAPI object inside the CastleOSKinectService namespace. Before I start doing some raw hex searches of the binary files included in CastleOS I thought I would ask here. smile
2. Where do the custom scripts actually get executed in the network topography of CastleOS? Are they executed on the machine running the Core Services (i.e. the hub), or are they executed on the machine running the Kinect Service that detected the command? Right now in my demo environment those are the same machine, but when I eventually deploy to my house they may not be the same.
0 link
Assistive Tech Dad
Assistive Tech Dad
Posts: 114


4/14/2015
Assistive Tech Dad
Assistive Tech Dad
Posts: 114
I answered my first question. It appears the CastleOS ScriptingAPI class only support the Speak() method (which is async for any interested). It looks like the intent for the scripting extensibility is to run C# code that performs actions external to CastleOS. I am still curious about the second question though.
0 link
MrMxyzptlk
MrMxyzptlk
Posts: 18


4/14/2015
MrMxyzptlk
MrMxyzptlk
Posts: 18
Assistive Tech Dad wrote:
I answered my first question. It appears the CastleOS ScriptingAPI class only support the Speak() method (which is async for any interested). It looks like the intent for the scripting extensibility is to run C# code that performs actions external to CastleOS. I am still curious about the second question though.



I believe that the scripting engine will be added to the events and actions in the GUI in release 2.0. This is supposedly with the hub release.
0 link
Assistive Tech Dad
Assistive Tech Dad
Posts: 114


4/14/2015
Assistive Tech Dad
Assistive Tech Dad
Posts: 114
I believe you mean the core services. Making it run in the GUI would mean that an arbitrary client would have to be connected to the service at the time a custom script was requested to run and then you really would have no idea where that thing would run. ;-)
0 link
Assistive Tech Dad
Assistive Tech Dad
Posts: 114


4/14/2015
Assistive Tech Dad
Assistive Tech Dad
Posts: 114
Btw, I don't know if there is a single right architecture here. I can see reasons to run everything centralized at the hub (e.g. solutions that want to avoid synchronizing data across multiple locations). Since I am hoping to work out a way to gain access to the local Kinect audio stream to allow for additional voice interaction with the spawned process, it would be beneficial for my purposes to execute the scripts locally on the machine running the Kinect service. Maybe that could be an advanced option per custom script? Default to run at the hub, but allow setting to run local.
0 link
Tommy Long
Tommy Long
Posts: 218


4/14/2015
Tommy Long
Tommy Long
Posts: 218
Hi ATD, The scripts are run on the machine that Kinect is running on. I run my Kinect and my scripts on the same machine; the core services are on another machine.
0 link
Chris Cicchitelli
Chris Cicchitelli
Administrator
Posts: 3390


4/15/2015
Chris Cicchitelli
Chris Cicchitelli
Administrator
Posts: 3390
Hey Everyone! Just to clarify some of the questions raised. Scripts are run in the service selected - Core or Kinect. Not in the GUI. They are run locally where the service is running, BUT that doesn't mean they can't call a remote service to do anything you want. That's the beauty of using C#, the sky is the limit.

For the API, the web service API which our internal GUIs now use (and ATD your eye reader app could use), is exposed via the Core Service and discoverable via WSDL. http://localhost/castleos/service?wsdl and http://localhost/castleos/service2?wsdl

Once you're ready to really tackle it, let's chat and I'd be happy to walk you through it.

Regarding the scripting API, the only internal method offered in the first release was the speak method. Once the new API is complete and the new device classes are implemented, those will all be exposed. To implement a device based on the skeleton class you'll just need to override a few key methods and drop the C# file in a designated folder, and CastleOS will load the driver.

Let us know if you have other questions!!
0 link
MrMxyzptlk
MrMxyzptlk
Posts: 18


4/15/2015
MrMxyzptlk
MrMxyzptlk
Posts: 18
Perhaps 1 short example script for showing using the core service and another short example for the Kinect service?
Visualizing would help myself understand this better...
0 link
Mark Gabarra
Mark Gabarra
Posts: 3


4/15/2015
Mark Gabarra
Mark Gabarra
Posts: 3
@MrMxyzptlk - I could be wrong but I believe it is a configuration choice and not a coding difference. In other words, if you launch the Kinect Service wizard to configure when the script executes, then you are selecting the Kinect service and the script will execute on the machine running the Kinect service. If you launch the Core Service wizard to configure when the script will execute, then you are selecting the Core service.

@Chris - That is great! I will take a closer look at the WSDL. When I get more time to play with code I will reach out to you. I already can see something I will need either in client API or scripting API that will get me access to the Kinect audio stream. More specifically, I would need the scripting API to give me some sort of ID token for what Kinect Service launched the script (an ID token I can pass outside the service process). I would then like to use that ID to ask CastleOS to use the identified Kinect service for both TTS output and voice recognition input. Like I said, when I get closer I will reach out.
0 link
MrMxyzptlk
MrMxyzptlk
Posts: 18


4/16/2015
MrMxyzptlk
MrMxyzptlk
Posts: 18
@Mark - I don't have a CoreServiceConfigurator executable, only a KinectServiceConfigurator exe.
Let me know if you have both?
0 link
Brandon Doskocil
Brandon Doskocil
Posts: 1


10/9/2015
I also have a script question. I would like to be able to turn on my Denon receiver using Kinect voice control. The command to do it is http://192.168.0.120/MainZone/index.put.asp?cmd0=PutZone_OnOff%2FON. Is there an easy way to make Castle OS send this command with a script??
0 link
Chris Cicchitelli
Chris Cicchitelli
Administrator
Posts: 3390


10/10/2015
Chris Cicchitelli
Chris Cicchitelli
Administrator
Posts: 3390
Brandon Doskocil wrote:
I also have a script question. I would like to be able to turn on my Denon receiver using Kinect voice control. The command to do it is http://192.168.0.120/MainZone/index.put.asp?cmd0=PutZone_OnOff%2FON. Is there an easy way to make Castle OS send this command with a script??



Hey Brandon! You'll want to use the WebRequest class from C# in your script. More info here:

https://msdn.microsoft.com/en-us/library/system.net.webrequest(v=vs.110).aspx
0 link