Re: How to - multiple instances of similar systems / objects

Sunday, January 29, 2012
If I have a class "MyDevice" and I create a couple instances of it (say
myDevice1 and myDevice2) can I make calls, from buttons, like:

myDevice1("play");

or do I have to use a singleton pattern and only have one class object
to call on?

I've been trying different non-singleton things with no luck so far...

Thanks

Heath Volmer
Digital Domain Systems
303-517-9714


On 1/28/12 7:09 PM, Jarrod Bell wrote:
> You can assign JS calls directly to buttons, no need to use join
> numbers unless showing real feedback.
>
> So you could have one system defined, and then change what device it
> is talking to by modifying its IP address/port at runtime using
> CF.setSystemProperties.
>
> The button that you use to change what device you want to control
> could have JS attached to it to perform the system properties changes,
> then each button could just have something like:
>
> myDevice.command("play");
>
> With JavaScript it's really capable of doing pretty much anything you
> like - just up to you to program it in a way that suits your
> requirements.
>
> You could even use the same join numbers for each system, and just
> make sure to set the joins to a default state when changing systems,
> and then request the new data from the system each time you change.
>
> Jarrod
>
> On 29/01/12 10:22 AM, Heath Volmer wrote:
>> Going to ramble a tad here:
>>
>> I have a JS file designed to talk to a media server. I could have
>> multiple media servers, so I might need multiple systems and multiple
>> JS objects to handle them. My JS is building the multiple instances
>> with no problem, but now that I'm to the point of connecting the
>> buttons on the server's gui page to the JS objects that talk to the
>> system, I realize that I have no idea how to access a given object
>> from a button and call a function on it.
>>
>> One method (which I don't like) is to watch joins and route them to
>> the currently-selected system.
>>
>> Another way is to route different ranges of joins to different
>> systems (I like this even less, being a big proponent of reusing
>> things.)
>>
>> Either way, I'm assuming that I have to do this routing to the
>> appropriate object outside of my objects.
>>
>> My main questions:
>> Please tell me there is a better way that gets me out of
>> join-number-ville. I'd like to say command("Play") on a button press
>> and have that button talk to the server it's supposed to. Do I need
>> to have a central catcher of commands that says "He pressed play, and
>> he's on media server 4. Send the command to that one"? That might
>> not be too messy.
>>
>> Is there a way to attach a JS object to a subpage or page? It's
>> buttons would refer to a certain instance. (Venturing into
>> Mac-Xcode land here again folks) Like a page built in Interface
>> Builder has a controller object attached to it.
>>
>> Thanks
>>
>

--
You received this message because you are subscribed to the Google Groups "CommandFusion" group.
To post to this group, send email to commandfusion@googlegroups.com.
To unsubscribe from this group, send email to commandfusion+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/commandfusion?hl=en.

0 comments:

Post a Comment