Cortex run command

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • Paul_B
    Automated Home Legend
    • Jul 2006
    • 608

    Cortex run command

    Does anyone know if it is possible to call out from Cortex to a batch file? If not could I accomplish the same through XAP?

    What I want to do at the end of the day is send magic packets to a more powerful server that I will be using for video streaming. Plus my NAS and Gigabit switch could be turned off from a SSH script.

    Paul
  • Simon George
    Automated Home Jr Member
    • Apr 2008
    • 28

    #2
    Could you not use scripting (eg. VBScript) to do this ?

    Comment

    • Paul_B
      Automated Home Legend
      • Jul 2006
      • 608

      #3
      I could but I need Cortex to signal the end of the day (i.e remote control action, all lights off, etc) Cortex does offer an interface and registration to the Windows Messgaing API. But that API isn't particuliarly well documented or pleasaent to deal with in VB / VBS

      Paul

      Comment

      • Simon George
        Automated Home Jr Member
        • Apr 2008
        • 28

        #4
        I was thinking of the Cortex script object itself (Cortex logic objects -> Logic only in the help) but I'm new to Cortex so it was just a guess.

        I will be very keen to work with the Cortex external API (in C#) once I've setup my system (I want a much simpler phone/Windows Media Center interface to drive some Cortex functions) and so I'll be getting to grips with it documentation or not Hopefully I can put the fruits of this work back into the community on an open-source basis...

        Comment

        • Paul_B
          Automated Home Legend
          • Jul 2006
          • 608

          #5
          Simon,

          Look forward to that.

          Cortex is not very demanding and seems to run quite happily with other software. Myself and a few others use low power Mini-ITX motherboards with VIA CPU's of less than 1.5GHz and 1GB of RAM.

          The script object in Cortex requires an additional license which I don't have. However, as of release v22 of Cortex the API interaction was re-worked to use the Windows Messaging system. The Help information describes its usage under Advanced. Whilst an example project has been provided under the installation point of Cortex, i.e:

          "C:\Program Files\Idratek\Cortex\Cortex API\Examples\Visual C# 2005 Express"

          Welcome to Idratek

          Paul

          Comment

          • Kevin
            Moderator
            • Jan 2004
            • 558

            #6
            Originally posted by Paul_B View Post
            Does anyone know if it is possible to call out from Cortex to a batch file? If not could I accomplish the same through XAP?

            Paul
            I haven't investigated the script/API options at all yet and it's likely they may well be the best solution for this...The optional script object being ideal I guess....however.. as you asked ;-) From a xAP perspective you can construct and send xAP messages within Cortex very easily. You would then just have a Cortex connection to the xAP control object that triggered it being sent

            What you would then need is a xAP listener somewhere else (likely on your server) to action the message once it's heard. There are many such listeners available for different purposes including standalone control applications but that seems a bit of an overkill/duplication and you obviously need one that has the capabilities to action your request, turn the things on/off etc. I feel sure there's something already that can launch files or run named batch files on demand for example .

            If you have some script / programming language familiarity with anything that can use an Active X control then there is the free xAP OCX which is really easy to use. If you use .Net there is the xFX Framework. On Linux there are some Java, Perl and even Ruby examples I believe.

            Using your language/script of choice you would just create a small listening application that heard your xAP message from Cortex and actioned whatever you needed. Turned the things on or off , ran other scripts or sent special packets etc.

            I have posted an example of a couple of xAP message below just so you can see how simple yet powerful they are. These are the actual messages that are sent on Ethernet - yes human readable :-) , and the included parameters are customisable by you. Certain message types have predefined parameters and these are called xAP schema. The schema are identified by the class= parameter.

            This could be an example using the existing BSC (Basic Status and Control) xAP schema to turn on your Gigabit switch. The key things in this message are the class, the target address (what you are controlling) and the command itself (state=on).

            xap-header
            {
            v=13
            hop=1
            uid=FF.1212:00F7
            class=xAPBSC.cmd
            source=Idratek.Cortex.Sony:World.House.Room.Device
            target=PaulB.Server.Video:GigaBit Switch
            }
            output.state.1
            {
            ID=*
            State=On
            }


            or you could create your own custom message class

            xap-header
            {
            v=13
            hop=1
            uid=FF.1212:00F7
            class=PaulsClass
            source=Idratek.Cortex.Sony:World.House.Room.Device
            target=PaulB.Server.Video
            }
            Action
            {
            Device=GigabitSwitch
            Command=TurnOff
            Delay=60 seconds
            }

            or even , as you originally requested have a command to just run a named script / batch file , or even launch an application on your server. (xAP can link to Girder too btw)

            Action
            {
            Command=RunScript
            Name=C:\shutdown.bat
            }

            Happy to help anyone here that ventures into xAP. As ever there's a few ways of approaching doing things and usually involving as few steps as possible increases speed and reliability as there are less steps and dependencies involved. If you can do this within Cortex's script/API it's probably preferable ...

            Kevin
            Last edited by Kevin; 13 April 2008, 01:20 PM.

            Comment

            • Kevin
              Moderator
              • Jan 2004
              • 558

              #7
              Originally posted by Kevin View Post
              I feel sure there's something already that can launch files or run named batch files on demand for example .
              I have now checked and we do already have an application that will do this :-) It's an older xAP application called xAP Watcher available from
              http://www.mi4.biz/modules.php?name=...howpage&pid=37 . It runs as a service or a tray icon & offers a schema like this that could run a batch file or launch an application... (on any networked PC)

              Class=PC.Control

              Run
              {
              Command=[Command to run]
              Window=[normal|normalnofocus|maximised|minimised] - optional
              }

              you could also run a script file using

              Command=cscript //B myvbsfile.vbs

              Also supports several other useful schema including PC status enquiries and sending keys commands to running applications.....

              Class=PC.Control

              Keys
              {
              App=[Title bar text of application to send keys to]
              Keys=[Keys to send, some special keys are {enter},{tab},{left},{right},{up},{down},{F1},{F12 } and there are many more]
              }

              Full schema detail here


              Kevin

              PS If you would like me to provide some walk through instructions on how to set this up I'd be happy to do so ..
              Last edited by Kevin; 13 April 2008, 04:56 PM.

              Comment

              • Paul_B
                Automated Home Legend
                • Jul 2006
                • 608

                #8
                Thanks Kevin I'll have a look at this later. Currently cooking and tidying up from an afternoon in the garden

                Paul

                Comment

                • Paul_B
                  Automated Home Legend
                  • Jul 2006
                  • 608

                  #9
                  Kevin,

                  I've looked at xAP before and with Cortex support would like to learn more. My background is very much scripting for admin functions i.e WMI, ADSI, ADO in the Windows arena.

                  I would like to use and learn more about the OCX interface. I have placed it into my system32 directory. Normal I use a IDE called Primalscript for scripting. How would I go about loading the OCX into the browsing library?

                  The example that comes with the OCX download uses VB6, I have Visual Studio 2008 but it fails trying to upgrade the project. Doesn't help that I don't really know what I am doing with VS.

                  Should I download anything else with xAP to enable easier debugging?

                  Many thanks

                  Paul

                  Comment

                  • Kevin
                    Moderator
                    • Jan 2004
                    • 558

                    #10
                    Hi Paul,

                    We're a little bit on two sides here - I have only familiarity with VB6 and I haven't got VS2008. Let me ask a possibly stupid question. Does VS2008 support only VB.Net or does it support creating executables that don't need the .Net runtime ?

                    I can't really help either on the inclusion of the OCX in your other environment - I assume you have registered the file with Windows using regsvr32 ?

                    I can however help with the actual usage of the OCX (via VB6 at least) and it's methods/properties as I have used it in some of my own applications. It would be most useful if the demo application would convert correctly - which demo app is it - and what sort of errors does it show in conversion ?

                    The other thing I can do is ask people who would know more - or if you are into VB.Net then I can get you an example xAP application with source code... however that will use the xFX Framework - a .Net framework for xAP (which again I haven't used) .

                    Kevin
                    Last edited by Kevin; 15 April 2008, 12:09 AM.

                    Comment

                    • Viv
                      Automated Home Ninja
                      • Dec 2004
                      • 284

                      #11
                      Originally posted by Paul_B View Post
                      Does anyone know if it is possible to call out from Cortex to a batch file? If not could I accomplish the same through XAP?
                      Paul
                      Cortex Release 23.1.1 can execute a standard windows shell command from a macro object.

                      Viv

                      Comment

                      • Kevin
                        Moderator
                        • Jan 2004
                        • 558

                        #12
                        It's great having a developer who responds so quickly to user requests - well done Idratek/Viv :-)

                        Kevin

                        Comment

                        • Paul_B
                          Automated Home Legend
                          • Jul 2006
                          • 608

                          #13
                          It really is amazing and what sets Idratek apart. I know this may not last for ever as the product grows. But for now it is wonderful.

                          Many thanks,

                          Paul

                          Comment

                          • jcmiguel
                            Automated Home Jr Member
                            • Apr 2008
                            • 38

                            #14
                            Media center control

                            Hello all, I am thinking about IDRATEK as my automation solution and I agree that a user interface away from the net is needed. I would think that a windows media center or vista media center like the one available fro HAI should be interesting. I would prefer to go linux as my media center will be mythtv and that is open source. I am no progammer but I like to try things. The Ideal situation is having the media center sending commands via network to Cortex server. Any suggestion where to start?
                            Carlos

                            Comment

                            • Kevin
                              Moderator
                              • Jan 2004
                              • 558

                              #15
                              Hi Carlos,

                              Well I'm loving my IDRANet bits so far :-)

                              I have a very diverse range of things from many manufacturers that I've integrated into my HA system - part out of planning and part as an exercise in just proving it can be done.

                              I've played a lot with graphic front ends ranging from costly AMX/Crestron down to free PC based software applications, but so far it's just playing as getting things visually attractive takes a lot of time. I don't want to harp on about xAP too much but as a feature within Cortex it allows you to create two way realtime interaction between Cortex objects and external mechanisms - over Ethernet.

                              You could use this with a some programming expertise to achieve what you are after or you could use an existing graphic/touch screen application that has xAP capabilities (there are a few of these) . I already use some of these with my other xAP applications and I will be putting together some screen shots shortly of their use with IDRANet, I'll post them here if there's interest.

                              These commercial/free applications allow you to design screens either as web pages (with realtime updates) or they are standalone Windows applications , that also work on Windows PPC (CE) devices. So you can already create nice front ends for an IDRANet HA setup - and for very low cost :-) Unfortunately I don't know of one that is xAP enabled and runs on Linux though.

                              Kevin
                              Last edited by Kevin; 6 May 2008, 10:44 PM.

                              Comment

                              Working...
                              X