Premise using invokeproperty method

Motorola Premise

etc6849

Senior Member
I was able to get invokeproperty to work right, but I had to use the getobject method first. Why can't I just use this:
devices.CustomDevices.HD_XA2.InvokeProperty 9, sys.Schema.Device.Power.PowerState, sys.Schema.System.Boolean.On

instead of this:

devices.CustomDevices.HD_XA2.InvokeProperty 9, sys.GetObject("sys://Schema/Device/Power/PowerState"), sys.GetObject("sys://Schema/System/Boolean/On")
 
I believe the InvokeProperty method is a generic way of acting on an object's properties. It provides a degree of programming flexibility that, in my experience, is rarely needed.

The documentation seems to suggest that both forms, Schema.Device.Blah.Blah and sys.getobject("sys://Schema/Device/Blah/Blah"), are valid. However, the docs supply only one example and it uses the sys.GetObjectform. I suspect that using sys.GetObject is mandatory and they meant to say that the following usages are valid:
  • sys.GetObject("sys://Schema/Device/Blah/Blah")
  • sys.GetObject(Schema.Device.Blah.Blah)
Rather that use InvokeProperty, you can use this: Devices.CustomDevices.HD_XA2.PowerState=true

Is there a reason you are acting on the Driver object's PowerState property? Normally one acts on the Home object: Home.Mediazone.Receiver.PowerState=true and binding (i.e. binding Receiver to HD_XA2) will take care of the rest. By keeping all programming logic at the Home level, it will be effective regardless of the driver you bind to Receiver. A device-independent logic-layer is Premise's core strength.

On the other hand, if you are writing a Device driver, then you will have to directly affect the Driver object ... but then the code usually looks like: this.PowerState=true.
 
i'm using invokeaction because i want to force the command. i'm going to change the object to the home object as you recommend. thanks for the explanation, it really helps :)
 
forgot to mention: i was putting this code in the device driver for my rx, whenever a person selects dvd or the rx says its in dvd mode, i want the dvd player to always come on.
 
... i want to force the command ...
Check the documentation for the SetValueForced method. Its syntax is identical to the SetValue method except it forces a state change.

Devices.CustomDevices.HD_XA2.SetValueForced "PowerState", true
or
Home.Mediazone.Receiver.SetValueForced "PowerState", true
or
this.SetValueForced "PowerState", true

Far easier to read than InvokeProperty!
 
thanks 123! i'm wondering if placing this kind of code in the rx module is apprpriate. i think i should look into logic diagrams?
 
There's always more than one way to do something! :) Some things are more easily accomplished with scripting and others with logic diagrams. I tend to lean towards scripting but I've found logic diagrams useful as well (see this post).
 
So how would I force an input on the tv to video2 from an on change property within a receiver module? My non working line of code is in bold...

Description of my issue: I have the PC hooked directly to my TV, but the PCs audio goes to the receiver. How does premise handle something like that (I'm guessing it can't without code)?
My problem is my PC is my PVR and my mp3 player are used for msense. This would mean the PVR and soundcard objects must share the same input on the receiver for msense to select the correct input right? If I play a DVD, the tv needs to switch to the receivers video output on VideoIn1. If I use the PVR the TV must switch to VideoIn2...

I thought I could solve most of my problems by hard coding commands on how to switch the TV within the receivers module.

OnChangeOnNewData would have code like this for the receiver as the receiver does 2 way communication:

'When new data is received
If sysevent.newVal = True Then
'store received code
this.lastRx = this.RxTextLine
this.lastRxLen = len(this.RxTextLine)
'Read incoming ascii data line by line
For i = 0 To this.RxLinesRemaining
If len(this.RxTextLine) < 12 then
'Read queued command
Select Case this.RxTextLine
'If received command matches any of these...Case "!1SLI03": 'Input1 - AUX1 - HTPC - PVR
'make sure PVR is always on when input is selected.
Home.LivingRoom.PVR.SetValueForced "PowerState", true
'make sure the TV input is set correctly
Home.LivingRoom.Television.SetValueForced "CurrentSource", "VideoIn2"
....

There's always more than one way to do something! :) Some things are more easily accomplished with scripting and others with logic diagrams. I tend to lean towards scripting but I've found logic diagrams useful as well (see this post).
 
The bolded line of code doesn't work because the CurrentSource property should point to an AudioVideoStream object and not a text string. You can confirm this yourself by locating the Television's CurrentSource property (in Builder's Properties window) and clicking its browse button (...). A form will open allowing you to select an object; look at the very bottom of the form and you'll see "Items of type: AudioVideoStream". I haven't dabbled with A/V devices so I don't know the correct syntax for defining the AudioVideoStream object.

Without a diagram, I don't have a firm grasp of how all of your A/V gear is interconnected and how mSense could control it. I do know that controlling Home objects, like generic PVRs and Televisions, from within a Receiver driver is oddball stuff. Normally, one would try to get mSense to handle the A/V gear by binding things together in the right order. But hey, if you can get it to work this way then that's all that matters.
 
rookie mistake :) I just had to point to the VideoIn2 object like this:

'make sure the TV input is set correctly
Home.LivingRoom.Television.SetValueForced "CurrentSource", devices.CustomDevices.LNT4665f.VideoIn1

I'll attach a picture of my set up shortly. I want to put the soundcard on Input1 of the TXNR905, but I also want to have Vista Media Center on that input too. So the main issue is connecting two sources to the same input within Premise?

Surely, there is some software trick that will let you do this? Right now, there is no soundcard connected to VCR. I was thinking about putting in a second soundcard to hook to VCR just to play music through msense, but this seems like it shouldn't be necessary...

So how would I force an input on the tv to video2 from an on change property within a receiver module? My non working line of code is in bold...

Description of my issue: I have the PC hooked directly to my TV, but the PCs audio goes to the receiver. How does premise handle something like that (I'm guessing it can't without code)?
My problem is my PC is my PVR and my mp3 player are used for msense. This would mean the PVR and soundcard objects must share the same input on the receiver for msense to select the correct input right? If I play a DVD, the tv needs to switch to the receivers video output on VideoIn1. If I use the PVR the TV must switch to VideoIn2...

I thought I could solve most of my problems by hard coding commands on how to switch the TV within the receivers module.

OnChangeOnNewData would have code like this for the receiver as the receiver does 2 way communication:

'When new data is received
If sysevent.newVal = True Then
'store received code
this.lastRx = this.RxTextLine
this.lastRxLen = len(this.RxTextLine)
'Read incoming ascii data line by line
For i = 0 To this.RxLinesRemaining
If len(this.RxTextLine) < 12 then
'Read queued command
Select Case this.RxTextLine
'If received command matches any of these...Case "!1SLI03": 'Input1 - AUX1 - HTPC - PVR
'make sure PVR is always on when input is selected.
Home.LivingRoom.PVR.SetValueForced "PowerState", true
'make sure the TV input is set correctly
Home.LivingRoom.Television.SetValueForced "CurrentSource", "VideoIn2"
....

There's always more than one way to do something! :) Some things are more easily accomplished with scripting and others with logic diagrams. I tend to lean towards scripting but I've found logic diagrams useful as well (see this post).
 
... I want to put the soundcard on Input1 of the TXNR905, but I also want to have Vista Media Center on that input too.
I'm having difficulty understanding how you can have the output of a sound card plus the output of a PVR (Media Center) connected to the same Receiver input.
 
the pvr is mediacenter, but mediacenter also uses the soundcard. msense/premise don't realize they are really the same object. when you create a pvr object here is no way to include a soundcard.
 
thus, to premise, my pvr and computer sound will always be seperate, and this affects msense as i use msense with mp3s and a tv provider (pvr)
 
Back
Top