From: Rick R. <ric...@sa...> - 2014-01-03 02:45:22
|
I'm working on a touchscreen interface using Command Fusion's iViewer. Since CF uses javascript, and I need some sort of means for transferring state changes to reflect things like volume, receiver input, light levels, etc... I've decided that JSON would probably be the best bet. I found that I could execute: 'curl " http://localhost:8080/sub?json(objects=receiver,fields=state)"' and get: "{ "objects" : { "receiver" : { "state" : "inputwii" } } }" So far, so good. Now if I run a voice command to check the powerstatus of my receiver, and run the curl command, I get: "{ "objects" : { "receiver" : { "state" : "on" } } }" The problem here is that I cannot get both the power state and the input state in the same query. Full output of the receiver object shows: { "objects" : { "receiver" : { "states" : { "6" : "volup", "11" : "inputfios", "3" : "pwrstate", "7" : "mutestate", "9" : "inputstate", "12" : "inputfront", "2" : "inputroku", "8" : "voldown", "1" : "inputwii", "4" : "off", "0" : "inputps3", "13" : "muteon", "10" : "muteoff", "5" : "on" }, "state" : "inputwii", "filename" : "init-receiver", "html" : "<![CDATA[<FORM action=\"/SET;html_list(Generic_Item)?\" method=\"get\">\n<INPUT type=\"hidden\" name=\"select_item\" value=\"receiver\">\n<td align=\"right\"><a href='SET;html_state_log(receiver)' target='speech'>inputwii</a>nbsp</td>\n<td align=\"left\"><b><SELECT name=\"select_state\" onChange=\"form.submit()\">\n<option value=\"pick_a_state_msg\" SELECTED> \n<option value=\"inputps3\">inputps3\n<option value=\"inputwii\">inputwii\n<option value=\"inputroku\">inputroku\n<option value=\"pwrstate\">pwrstate\n<option value=\"off\">off\n<option value=\"on\">on\n<option value=\"volup\">volup\n<option value=\"mutestate\">mutestate\n<option value=\"voldown\">voldown\n<option value=\"inputstate\">inputstate\n<option value=\"muteoff\">muteoff\n<option value=\"inputfios\">inputfios\n<option value=\"inputfront\">inputfront\n<option value=\"muteon\">muteon\n</SELECT>\n<a href='SET;html_list(Generic_Item)?receiver=on'>Receiver</a></b></td></FORM>\n]]>", "idle_time" : "465", "state_log" : { "6" : "12/31/13 04:30:38 PM off set_by=", "3" : "01/02/14 08:25:55 PM on set_by=", "7" : "12/31/13 04:29:26 PM inputfios set_by=", "9" : "12/31/13 04:27:53 PM inputfios set_by=", "2" : "01/02/14 08:28:35 PM inputwii set_by=", "8" : "12/31/13 04:28:10 PM inputfios set_by=", "1" : "01/02/14 08:30:13 PM on set_by=", "4" : "01/02/14 08:25:46 PM on set_by=", "0" : "01/02/14 08:30:22 PM inputwii set_by=", "5" : "01/02/14 08:25:46 PM inputfios set_by=" }, "category" : "Entertainment", "type" : "Generic_Item" } } } Is it possible to have the receiver "state" always be just "on|off", and something other than "state" show status of inputs, volume, etc...? Something like: { "objects" : { "receiver" : { "state" : "on", "source" : "inputwii", "volume" : "45", "mute" : "off" } } } |
From: Kevin R. K. <ke...@kr...> - 2014-01-13 17:49:18
|
Rick, I noticed that this was still unanswered, not sure if this is still an issue for you. The problem arises because of what I would consider a bad design in whatever module is controlling your receiver. Ideally, the module would define two different objects a "receiver_input" object and a "receiver_power" object, that way the state value would be accurate. Alternatively it would need some sort of new schema that we have been talking about recently. You can hack together your own solution in the mean time. The following is psuedo-code off the top of my head, but it should get you in the right direction. $receiver_power = new Generic_Item(); $receiver_input = new Generic_Item(); $receiver->tie_event('receiver_children($State);'); sub receiver_children { my ($state) = @_; if (grep(/$state/i, @{['on', 'off']})) { $receiver_power->set($state); } elsif (grep(/$state/i, @{['inputfios','inputstate','inputfront',' inputroku','inputwii','inputps3']})) { $receiver_input->set($state); } } Each of these sub/child objects will represent only the limited states you desire. On Thu, Jan 2, 2014 at 6:44 PM, Rick Reed <ric...@sa...> wrote: > I'm working on a touchscreen interface using Command Fusion's iViewer. > Since CF uses javascript, and I need some sort of means for transferring > state changes to reflect things like volume, receiver input, light levels, > etc... I've decided that JSON would probably be the best bet. I found that > I could execute: 'curl " > http://localhost:8080/sub?json(objects=receiver,fields=state)"' and get: > "{ > "objects" : { > "receiver" : { > "state" : "inputwii" > } > } > }" > > So far, so good. Now if I run a voice command to check the powerstatus of > my receiver, and run the curl command, I get: > > "{ > "objects" : { > "receiver" : { > "state" : "on" > } > } > }" > > The problem here is that I cannot get both the power state and the input > state in the same query. Full output of the receiver object shows: > > { > "objects" : { > "receiver" : { > "states" : { > "6" : "volup", > "11" : "inputfios", > "3" : "pwrstate", > "7" : "mutestate", > "9" : "inputstate", > "12" : "inputfront", > "2" : "inputroku", > "8" : "voldown", > "1" : "inputwii", > "4" : "off", > "0" : "inputps3", > "13" : "muteon", > "10" : "muteoff", > "5" : "on" > }, > "state" : "inputwii", > "filename" : "init-receiver", > "html" : "<![CDATA[<FORM action=\"/SET;html_list(Generic_Item)?\" > method=\"get\">\n<INPUT type=\"hidden\" name=\"select_item\" > value=\"receiver\">\n<td align=\"right\"><a > href='SET;html_state_log(receiver)' > target='speech'>inputwii</a>nbsp</td>\n<td align=\"left\"><b><SELECT > name=\"select_state\" onChange=\"form.submit()\">\n<option > value=\"pick_a_state_msg\" SELECTED> \n<option > value=\"inputps3\">inputps3\n<option value=\"inputwii\">inputwii\n<option > value=\"inputroku\">inputroku\n<option value=\"pwrstate\">pwrstate\n<option > value=\"off\">off\n<option value=\"on\">on\n<option > value=\"volup\">volup\n<option value=\"mutestate\">mutestate\n<option > value=\"voldown\">voldown\n<option value=\"inputstate\">inputstate\n<option > value=\"muteoff\">muteoff\n<option value=\"inputfios\">inputfios\n<option > value=\"inputfront\">inputfront\n<option > value=\"muteon\">muteon\n</SELECT>\n<a > href='SET;html_list(Generic_Item)?receiver=on'>Receiver</a></b></td></FORM>\n]]>", > "idle_time" : "465", > "state_log" : { > "6" : "12/31/13 04:30:38 PM off set_by=", > "3" : "01/02/14 08:25:55 PM on set_by=", > "7" : "12/31/13 04:29:26 PM inputfios set_by=", > "9" : "12/31/13 04:27:53 PM inputfios set_by=", > "2" : "01/02/14 08:28:35 PM inputwii set_by=", > "8" : "12/31/13 04:28:10 PM inputfios set_by=", > "1" : "01/02/14 08:30:13 PM on set_by=", > "4" : "01/02/14 08:25:46 PM on set_by=", > "0" : "01/02/14 08:30:22 PM inputwii set_by=", > "5" : "01/02/14 08:25:46 PM inputfios set_by=" > }, > "category" : "Entertainment", > "type" : "Generic_Item" > } > } > } > > > Is it possible to have the receiver "state" always be just "on|off", and > something other than "state" show status of inputs, volume, etc...? > Something like: > > { > "objects" : { > "receiver" : { > "state" : "on", > "source" : "inputwii", > "volume" : "45", > "mute" : "off" > } > } > } > > > > ------------------------------------------------------------------------------ > Rapidly troubleshoot problems before they affect your business. Most IT > organizations don't have a clear picture of how application performance > affects their revenue. With AppDynamics, you get 100% visibility into your > Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics > Pro! > http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk > ________________________________________________________ > To unsubscribe from this list, go to: > http://sourceforge.net/mail/?group_id=1365 > > > |
From: Joel D. <jr...@pr...> - 2014-01-13 17:58:08
|
Kevin- I'm not Rick, but I have some interest in this as I'd like to couple my Onkyo receiver more closely to mh. When I read your pseudo-code, I don't understant how receiver_children gets called. Is it a result of any change to $receiver (because of the tie_event)? I've never used tie in any of my code because I've never quite understood how it works. Time to change that... Thanks. Joel On Mon, 13 Jan 2014, it would appear that Kevin Robert Keegan wrote: > Rick, > > I noticed that this was still unanswered, not sure if this is still an > issue for you. > > The problem arises because of what I would consider a bad design in > whatever module is controlling your receiver. Ideally, the module would > define two different objects a "receiver_input" object and a > "receiver_power" object, that way the state value would be accurate. > Alternatively it would need some sort of new schema that we have been > talking about recently. > > You can hack together your own solution in the mean time. The following is > psuedo-code off the top of my head, but it should get you in the right > direction. > > $receiver_power = new Generic_Item(); > $receiver_input = new Generic_Item(); > > $receiver->tie_event('receiver_children($State);'); > > sub receiver_children { > my ($state) = @_; > if (grep(/$state/i, @{['on', 'off']})) { > $receiver_power->set($state); > } > elsif (grep(/$state/i, @{['inputfios','inputstate','inputfront',' > inputroku','inputwii','inputps3']})) { > $receiver_input->set($state); > } > } > > Each of these sub/child objects will represent only the limited states you > desire. > > > > On Thu, Jan 2, 2014 at 6:44 PM, Rick Reed <ric...@sa...> wrote: > >> I'm working on a touchscreen interface using Command Fusion's iViewer. >> Since CF uses javascript, and I need some sort of means for transferring >> state changes to reflect things like volume, receiver input, light levels, >> etc... I've decided that JSON would probably be the best bet. I found that >> I could execute: 'curl " >> http://localhost:8080/sub?json(objects=receiver,fields=state)"' and get: >> "{ >> "objects" : { >> "receiver" : { >> "state" : "inputwii" >> } >> } >> }" >> >> So far, so good. Now if I run a voice command to check the powerstatus of >> my receiver, and run the curl command, I get: >> >> "{ >> "objects" : { >> "receiver" : { >> "state" : "on" >> } >> } >> }" >> >> The problem here is that I cannot get both the power state and the input >> state in the same query. Full output of the receiver object shows: >> >> { >> "objects" : { >> "receiver" : { >> "states" : { >> "6" : "volup", >> "11" : "inputfios", >> "3" : "pwrstate", >> "7" : "mutestate", >> "9" : "inputstate", >> "12" : "inputfront", >> "2" : "inputroku", >> "8" : "voldown", >> "1" : "inputwii", >> "4" : "off", >> "0" : "inputps3", >> "13" : "muteon", >> "10" : "muteoff", >> "5" : "on" >> }, >> "state" : "inputwii", >> "filename" : "init-receiver", >> "html" : "<![CDATA[<FORM action=\"/SET;html_list(Generic_Item)?\" >> method=\"get\">\n<INPUT type=\"hidden\" name=\"select_item\" >> value=\"receiver\">\n<td align=\"right\"><a >> href='SET;html_state_log(receiver)' >> target='speech'>inputwii</a>nbsp</td>\n<td align=\"left\"><b><SELECT >> name=\"select_state\" onChange=\"form.submit()\">\n<option >> value=\"pick_a_state_msg\" SELECTED> \n<option >> value=\"inputps3\">inputps3\n<option value=\"inputwii\">inputwii\n<option >> value=\"inputroku\">inputroku\n<option value=\"pwrstate\">pwrstate\n<option >> value=\"off\">off\n<option value=\"on\">on\n<option >> value=\"volup\">volup\n<option value=\"mutestate\">mutestate\n<option >> value=\"voldown\">voldown\n<option value=\"inputstate\">inputstate\n<option >> value=\"muteoff\">muteoff\n<option value=\"inputfios\">inputfios\n<option >> value=\"inputfront\">inputfront\n<option >> value=\"muteon\">muteon\n</SELECT>\n<a >> href='SET;html_list(Generic_Item)?receiver=on'>Receiver</a></b></td></FORM>\n]]>", >> "idle_time" : "465", >> "state_log" : { >> "6" : "12/31/13 04:30:38 PM off set_by=", >> "3" : "01/02/14 08:25:55 PM on set_by=", >> "7" : "12/31/13 04:29:26 PM inputfios set_by=", >> "9" : "12/31/13 04:27:53 PM inputfios set_by=", >> "2" : "01/02/14 08:28:35 PM inputwii set_by=", >> "8" : "12/31/13 04:28:10 PM inputfios set_by=", >> "1" : "01/02/14 08:30:13 PM on set_by=", >> "4" : "01/02/14 08:25:46 PM on set_by=", >> "0" : "01/02/14 08:30:22 PM inputwii set_by=", >> "5" : "01/02/14 08:25:46 PM inputfios set_by=" >> }, >> "category" : "Entertainment", >> "type" : "Generic_Item" >> } >> } >> } >> >> >> Is it possible to have the receiver "state" always be just "on|off", and >> something other than "state" show status of inputs, volume, etc...? >> Something like: >> >> { >> "objects" : { >> "receiver" : { >> "state" : "on", >> "source" : "inputwii", >> "volume" : "45", >> "mute" : "off" >> } >> } >> } |
From: Kevin R. K. <ke...@kr...> - 2014-01-13 21:40:43
|
Yup, Generic_Item, which should be inherited by practically every MH object is very powerful. You should read the POD documentation for Generic_Item, here are a few notable exerpts: See C<mh/code/examples/generic_item.pl> for more examples, C<test_tie.pl> for more examples on how to tie/untie items/events =item C<tie_event(code, state, log_msg)> If the state of the generic_item changes, then code will trigger, with the lexical variables $state and $object getting set. The code is a string that will be eval'd and the variables are available to it, but not to any subroutines called by it unless you pass them. You can also set the state variable explicitly since you usually know the item. The code is a string that will be eval'd. (optional) Setting state limits this tied code to run only when the given state is set. (optional) Setting log_msg causes the message to be logged when this tied code is run. =cut On Mon, Jan 13, 2014 at 9:57 AM, Joel Davidson <jr...@pr...> wrote: > Kevin- > > I'm not Rick, but I have some interest in this as I'd like to couple my > Onkyo receiver more closely to mh. When I read your pseudo-code, I > don't understant how receiver_children gets called. Is it a result of > any change to $receiver (because of the tie_event)? I've never used > tie in any of my code because I've never quite understood how it works. > Time to change that... > > Thanks. > > Joel > > > On Mon, 13 Jan 2014, it would appear that Kevin Robert Keegan wrote: > > > Rick, > > > > I noticed that this was still unanswered, not sure if this is still an > > issue for you. > > > > The problem arises because of what I would consider a bad design in > > whatever module is controlling your receiver. Ideally, the module would > > define two different objects a "receiver_input" object and a > > "receiver_power" object, that way the state value would be accurate. > > Alternatively it would need some sort of new schema that we have been > > talking about recently. > > > > You can hack together your own solution in the mean time. The following > is > > psuedo-code off the top of my head, but it should get you in the right > > direction. > > > > $receiver_power = new Generic_Item(); > > $receiver_input = new Generic_Item(); > > > > $receiver->tie_event('receiver_children($State);'); > > > > sub receiver_children { > > my ($state) = @_; > > if (grep(/$state/i, @{['on', 'off']})) { > > $receiver_power->set($state); > > } > > elsif (grep(/$state/i, @{['inputfios','inputstate','inputfront',' > > inputroku','inputwii','inputps3']})) { > > $receiver_input->set($state); > > } > > } > > > > Each of these sub/child objects will represent only the limited states > you > > desire. > > > > > > > > On Thu, Jan 2, 2014 at 6:44 PM, Rick Reed <ric...@sa...> wrote: > > > >> I'm working on a touchscreen interface using Command Fusion's iViewer. > >> Since CF uses javascript, and I need some sort of means for transferring > >> state changes to reflect things like volume, receiver input, light > levels, > >> etc... I've decided that JSON would probably be the best bet. I found > that > >> I could execute: 'curl " > >> http://localhost:8080/sub?json(objects=receiver,fields=state)"' and > get: > >> "{ > >> "objects" : { > >> "receiver" : { > >> "state" : "inputwii" > >> } > >> } > >> }" > >> > >> So far, so good. Now if I run a voice command to check the powerstatus > of > >> my receiver, and run the curl command, I get: > >> > >> "{ > >> "objects" : { > >> "receiver" : { > >> "state" : "on" > >> } > >> } > >> }" > >> > >> The problem here is that I cannot get both the power state and the input > >> state in the same query. Full output of the receiver object shows: > >> > >> { > >> "objects" : { > >> "receiver" : { > >> "states" : { > >> "6" : "volup", > >> "11" : "inputfios", > >> "3" : "pwrstate", > >> "7" : "mutestate", > >> "9" : "inputstate", > >> "12" : "inputfront", > >> "2" : "inputroku", > >> "8" : "voldown", > >> "1" : "inputwii", > >> "4" : "off", > >> "0" : "inputps3", > >> "13" : "muteon", > >> "10" : "muteoff", > >> "5" : "on" > >> }, > >> "state" : "inputwii", > >> "filename" : "init-receiver", > >> "html" : "<![CDATA[<FORM > action=\"/SET;html_list(Generic_Item)?\" > >> method=\"get\">\n<INPUT type=\"hidden\" name=\"select_item\" > >> value=\"receiver\">\n<td align=\"right\"><a > >> href='SET;html_state_log(receiver)' > >> target='speech'>inputwii</a>nbsp</td>\n<td align=\"left\"><b><SELECT > >> name=\"select_state\" onChange=\"form.submit()\">\n<option > >> value=\"pick_a_state_msg\" SELECTED> \n<option > >> value=\"inputps3\">inputps3\n<option > value=\"inputwii\">inputwii\n<option > >> value=\"inputroku\">inputroku\n<option > value=\"pwrstate\">pwrstate\n<option > >> value=\"off\">off\n<option value=\"on\">on\n<option > >> value=\"volup\">volup\n<option value=\"mutestate\">mutestate\n<option > >> value=\"voldown\">voldown\n<option > value=\"inputstate\">inputstate\n<option > >> value=\"muteoff\">muteoff\n<option > value=\"inputfios\">inputfios\n<option > >> value=\"inputfront\">inputfront\n<option > >> value=\"muteon\">muteon\n</SELECT>\n<a > >> > href='SET;html_list(Generic_Item)?receiver=on'>Receiver</a></b></td></FORM>\n]]>", > >> "idle_time" : "465", > >> "state_log" : { > >> "6" : "12/31/13 04:30:38 PM off set_by=", > >> "3" : "01/02/14 08:25:55 PM on set_by=", > >> "7" : "12/31/13 04:29:26 PM inputfios set_by=", > >> "9" : "12/31/13 04:27:53 PM inputfios set_by=", > >> "2" : "01/02/14 08:28:35 PM inputwii set_by=", > >> "8" : "12/31/13 04:28:10 PM inputfios set_by=", > >> "1" : "01/02/14 08:30:13 PM on set_by=", > >> "4" : "01/02/14 08:25:46 PM on set_by=", > >> "0" : "01/02/14 08:30:22 PM inputwii set_by=", > >> "5" : "01/02/14 08:25:46 PM inputfios set_by=" > >> }, > >> "category" : "Entertainment", > >> "type" : "Generic_Item" > >> } > >> } > >> } > >> > >> > >> Is it possible to have the receiver "state" always be just "on|off", and > >> something other than "state" show status of inputs, volume, etc...? > >> Something like: > >> > >> { > >> "objects" : { > >> "receiver" : { > >> "state" : "on", > >> "source" : "inputwii", > >> "volume" : "45", > >> "mute" : "off" > >> } > >> } > >> } > > > ------------------------------------------------------------------------------ > CenturyLink Cloud: The Leader in Enterprise Cloud Services. > Learn Why More Businesses Are Choosing CenturyLink Cloud For > Critical Workloads, Development Environments & Everything In Between. > Get a Quote or Start a Free Trial Today. > > http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk > ________________________________________________________ > To unsubscribe from this list, go to: > http://sourceforge.net/mail/?group_id=1365 > > |
From: Rick R. <ric...@sa...> - 2014-01-16 15:52:57
|
Kevin, I actually implemented a solution very similar to what you recommend. However, I hadn't thought of using a subroutine with tie_event. I may adopt that in my code since it's a good bit tidier than what I wrote. Thanks for the idea! Regarding a new object model... do you think such a thing will come to fruition? Would implementing such a change require a large overhaul of MH? On Mon, Jan 13, 2014 at 11:49 AM, Kevin Robert Keegan <ke...@kr...>wrote: > Rick, > > I noticed that this was still unanswered, not sure if this is still an > issue for you. > > The problem arises because of what I would consider a bad design in > whatever module is controlling your receiver. Ideally, the module would > define two different objects a "receiver_input" object and a > "receiver_power" object, that way the state value would be accurate. > Alternatively it would need some sort of new schema that we have been > talking about recently. > > You can hack together your own solution in the mean time. The following > is psuedo-code off the top of my head, but it should get you in the right > direction. > > $receiver_power = new Generic_Item(); > $receiver_input = new Generic_Item(); > > $receiver->tie_event('receiver_children($State);'); > > sub receiver_children { > my ($state) = @_; > if (grep(/$state/i, @{['on', 'off']})) { > $receiver_power->set($state); > } > elsif (grep(/$state/i, @{['inputfios','inputstate','inputfront',' > inputroku','inputwii','inputps3']})) { > $receiver_input->set($state); > } > } > > Each of these sub/child objects will represent only the limited states you > desire. > > > > On Thu, Jan 2, 2014 at 6:44 PM, Rick Reed <ric...@sa...> wrote: > >> I'm working on a touchscreen interface using Command Fusion's iViewer. >> Since CF uses javascript, and I need some sort of means for transferring >> state changes to reflect things like volume, receiver input, light levels, >> etc... I've decided that JSON would probably be the best bet. I found that >> I could execute: 'curl " >> http://localhost:8080/sub?json(objects=receiver,fields=state)"' and get: >> "{ >> "objects" : { >> "receiver" : { >> "state" : "inputwii" >> } >> } >> }" >> >> So far, so good. Now if I run a voice command to check the powerstatus of >> my receiver, and run the curl command, I get: >> >> "{ >> "objects" : { >> "receiver" : { >> "state" : "on" >> } >> } >> }" >> >> The problem here is that I cannot get both the power state and the input >> state in the same query. Full output of the receiver object shows: >> >> { >> "objects" : { >> "receiver" : { >> "states" : { >> "6" : "volup", >> "11" : "inputfios", >> "3" : "pwrstate", >> "7" : "mutestate", >> "9" : "inputstate", >> "12" : "inputfront", >> "2" : "inputroku", >> "8" : "voldown", >> "1" : "inputwii", >> "4" : "off", >> "0" : "inputps3", >> "13" : "muteon", >> "10" : "muteoff", >> "5" : "on" >> }, >> "state" : "inputwii", >> "filename" : "init-receiver", >> "html" : "<![CDATA[<FORM >> action=\"/SET;html_list(Generic_Item)?\" method=\"get\">\n<INPUT >> type=\"hidden\" name=\"select_item\" value=\"receiver\">\n<td >> align=\"right\"><a href='SET;html_state_log(receiver)' >> target='speech'>inputwii</a>nbsp</td>\n<td align=\"left\"><b><SELECT >> name=\"select_state\" onChange=\"form.submit()\">\n<option >> value=\"pick_a_state_msg\" SELECTED> \n<option >> value=\"inputps3\">inputps3\n<option value=\"inputwii\">inputwii\n<option >> value=\"inputroku\">inputroku\n<option value=\"pwrstate\">pwrstate\n<option >> value=\"off\">off\n<option value=\"on\">on\n<option >> value=\"volup\">volup\n<option value=\"mutestate\">mutestate\n<option >> value=\"voldown\">voldown\n<option value=\"inputstate\">inputstate\n<option >> value=\"muteoff\">muteoff\n<option value=\"inputfios\">inputfios\n<option >> value=\"inputfront\">inputfront\n<option >> value=\"muteon\">muteon\n</SELECT>\n<a >> href='SET;html_list(Generic_Item)?receiver=on'>Receiver</a></b></td></FORM>\n]]>", >> "idle_time" : "465", >> "state_log" : { >> "6" : "12/31/13 04:30:38 PM off set_by=", >> "3" : "01/02/14 08:25:55 PM on set_by=", >> "7" : "12/31/13 04:29:26 PM inputfios set_by=", >> "9" : "12/31/13 04:27:53 PM inputfios set_by=", >> "2" : "01/02/14 08:28:35 PM inputwii set_by=", >> "8" : "12/31/13 04:28:10 PM inputfios set_by=", >> "1" : "01/02/14 08:30:13 PM on set_by=", >> "4" : "01/02/14 08:25:46 PM on set_by=", >> "0" : "01/02/14 08:30:22 PM inputwii set_by=", >> "5" : "01/02/14 08:25:46 PM inputfios set_by=" >> }, >> "category" : "Entertainment", >> "type" : "Generic_Item" >> } >> } >> } >> >> >> Is it possible to have the receiver "state" always be just "on|off", and >> something other than "state" show status of inputs, volume, etc...? >> Something like: >> >> { >> "objects" : { >> "receiver" : { >> "state" : "on", >> "source" : "inputwii", >> "volume" : "45", >> "mute" : "off" >> } >> } >> } >> >> >> >> ------------------------------------------------------------------------------ >> Rapidly troubleshoot problems before they affect your business. Most IT >> organizations don't have a clear picture of how application performance >> affects their revenue. With AppDynamics, you get 100% visibility into your >> Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics >> Pro! >> >> http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk >> ________________________________________________________ >> To unsubscribe from this list, go to: >> http://sourceforge.net/mail/?group_id=1365 >> >> >> > |
From: Kevin R. K. <ke...@kr...> - 2014-01-16 18:32:03
|
Rick, as to the new object model..., there are a couple of ideas floating around for how to deal with this. I don't know when something like this will be implemented, the nature of our community type development is that things just kinda happen or don't happen. On Thu, Jan 16, 2014 at 7:52 AM, Rick Reed <ric...@sa...> wrote: > Kevin, > > I actually implemented a solution very similar to what you recommend. > However, I hadn't thought of using a subroutine with tie_event. I may adopt > that in my code since it's a good bit tidier than what I wrote. Thanks for > the idea! > > Regarding a new object model... do you think such a thing will come to > fruition? Would implementing such a change require a large overhaul of MH? > > > On Mon, Jan 13, 2014 at 11:49 AM, Kevin Robert Keegan <ke...@kr...>wrote: > >> Rick, >> >> I noticed that this was still unanswered, not sure if this is still an >> issue for you. >> >> The problem arises because of what I would consider a bad design in >> whatever module is controlling your receiver. Ideally, the module would >> define two different objects a "receiver_input" object and a >> "receiver_power" object, that way the state value would be accurate. >> Alternatively it would need some sort of new schema that we have been >> talking about recently. >> >> You can hack together your own solution in the mean time. The following >> is psuedo-code off the top of my head, but it should get you in the right >> direction. >> >> $receiver_power = new Generic_Item(); >> $receiver_input = new Generic_Item(); >> >> $receiver->tie_event('receiver_children($State);'); >> >> sub receiver_children { >> my ($state) = @_; >> if (grep(/$state/i, @{['on', 'off']})) { >> $receiver_power->set($state); >> } >> elsif (grep(/$state/i, @{['inputfios','inputstate','inputfront',' >> inputroku','inputwii','inputps3']})) { >> $receiver_input->set($state); >> } >> } >> >> Each of these sub/child objects will represent only the limited states >> you desire. >> >> >> >> On Thu, Jan 2, 2014 at 6:44 PM, Rick Reed <ric...@sa...> wrote: >> >>> I'm working on a touchscreen interface using Command Fusion's iViewer. >>> Since CF uses javascript, and I need some sort of means for transferring >>> state changes to reflect things like volume, receiver input, light levels, >>> etc... I've decided that JSON would probably be the best bet. I found that >>> I could execute: 'curl " >>> http://localhost:8080/sub?json(objects=receiver,fields=state)"' and get: >>> "{ >>> "objects" : { >>> "receiver" : { >>> "state" : "inputwii" >>> } >>> } >>> }" >>> >>> So far, so good. Now if I run a voice command to check the powerstatus >>> of my receiver, and run the curl command, I get: >>> >>> "{ >>> "objects" : { >>> "receiver" : { >>> "state" : "on" >>> } >>> } >>> }" >>> >>> The problem here is that I cannot get both the power state and the input >>> state in the same query. Full output of the receiver object shows: >>> >>> { >>> "objects" : { >>> "receiver" : { >>> "states" : { >>> "6" : "volup", >>> "11" : "inputfios", >>> "3" : "pwrstate", >>> "7" : "mutestate", >>> "9" : "inputstate", >>> "12" : "inputfront", >>> "2" : "inputroku", >>> "8" : "voldown", >>> "1" : "inputwii", >>> "4" : "off", >>> "0" : "inputps3", >>> "13" : "muteon", >>> "10" : "muteoff", >>> "5" : "on" >>> }, >>> "state" : "inputwii", >>> "filename" : "init-receiver", >>> "html" : "<![CDATA[<FORM >>> action=\"/SET;html_list(Generic_Item)?\" method=\"get\">\n<INPUT >>> type=\"hidden\" name=\"select_item\" value=\"receiver\">\n<td >>> align=\"right\"><a href='SET;html_state_log(receiver)' >>> target='speech'>inputwii</a>nbsp</td>\n<td align=\"left\"><b><SELECT >>> name=\"select_state\" onChange=\"form.submit()\">\n<option >>> value=\"pick_a_state_msg\" SELECTED> \n<option >>> value=\"inputps3\">inputps3\n<option value=\"inputwii\">inputwii\n<option >>> value=\"inputroku\">inputroku\n<option value=\"pwrstate\">pwrstate\n<option >>> value=\"off\">off\n<option value=\"on\">on\n<option >>> value=\"volup\">volup\n<option value=\"mutestate\">mutestate\n<option >>> value=\"voldown\">voldown\n<option value=\"inputstate\">inputstate\n<option >>> value=\"muteoff\">muteoff\n<option value=\"inputfios\">inputfios\n<option >>> value=\"inputfront\">inputfront\n<option >>> value=\"muteon\">muteon\n</SELECT>\n<a >>> href='SET;html_list(Generic_Item)?receiver=on'>Receiver</a></b></td></FORM>\n]]>", >>> "idle_time" : "465", >>> "state_log" : { >>> "6" : "12/31/13 04:30:38 PM off set_by=", >>> "3" : "01/02/14 08:25:55 PM on set_by=", >>> "7" : "12/31/13 04:29:26 PM inputfios set_by=", >>> "9" : "12/31/13 04:27:53 PM inputfios set_by=", >>> "2" : "01/02/14 08:28:35 PM inputwii set_by=", >>> "8" : "12/31/13 04:28:10 PM inputfios set_by=", >>> "1" : "01/02/14 08:30:13 PM on set_by=", >>> "4" : "01/02/14 08:25:46 PM on set_by=", >>> "0" : "01/02/14 08:30:22 PM inputwii set_by=", >>> "5" : "01/02/14 08:25:46 PM inputfios set_by=" >>> }, >>> "category" : "Entertainment", >>> "type" : "Generic_Item" >>> } >>> } >>> } >>> >>> >>> Is it possible to have the receiver "state" always be just "on|off", and >>> something other than "state" show status of inputs, volume, etc...? >>> Something like: >>> >>> { >>> "objects" : { >>> "receiver" : { >>> "state" : "on", >>> "source" : "inputwii", >>> "volume" : "45", >>> "mute" : "off" >>> } >>> } >>> } >>> >>> >>> >>> ------------------------------------------------------------------------------ >>> Rapidly troubleshoot problems before they affect your business. Most IT >>> organizations don't have a clear picture of how application performance >>> affects their revenue. With AppDynamics, you get 100% visibility into >>> your >>> Java,.NET, & PHP application. Start your 15-day FREE TRIAL of >>> AppDynamics Pro! >>> >>> http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk >>> ________________________________________________________ >>> To unsubscribe from this list, go to: >>> http://sourceforge.net/mail/?group_id=1365 >>> >>> >>> >> > |