Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Links or function calls to code: A Good Programming Practice advise
#1
I'm looking for a consistent way to use a good programming practice to implement schemes such as a PowerOFF code for a DVD where the activity is: Play, delay of 0.5sec, Toggle power (the first 2 make sure power is On).

I would like to implement it in one place and call it from various places such as the "Play DVD", "Play CD" commands.

Another example is turning On the AV receiver (Logic is: if it's already On - return, otherwise turn it On and wait a delay before you return so next commands will take effect). Like in this case we don't want to drag the whole logic to every place we might need to turn On the AV Receiver (can be 15 places!).

Can I create hidden (or not hidden for testing/manual control) buttons at some place at the root with the desired action and later on access them and issue commands to execute their action list?
or their must be a much cleaner way.
Reply
#2
New beta CQC versions allow a page to have stored actions like that, which you can reference within the page.

You can also write it as a CML Macro which any part of CQC can then access with no need to duplicate across pages.

Chris.
Reply
#3
Bodshal Wrote:New beta CQC versions allow a page to have stored actions like that, which you can reference within the page.
Chris.
IntViewr:RunTempAction( action) can be invoked from only from the same template/page. I would like to invoke it from any template!

Bodshal Wrote:You can also write it as a CML Macro which any part of CQC can then access with no need to duplicate across pages.
Chris.
Writing macro for such a need are too heavy weight vehicles.



*** Still looking for another alternative for my original posting ***

..
Reply
#4
Actually a macro isn't too heavy weight for that. You'd be suprised. CML is designed as a single pass language. It can be downloaded and compiled and run in a twinkling of an eye as long as your system is running as it should.
Dean Roddey
Explorans limites defectum
Reply
#5
Dean Roddey Wrote:Actually a macro isn't too heavy weight for that. You'd be suprised. CML is designed as a single pass language. It can be downloaded and compiled and run in a twinkling of an eye as long as your system is running as it should.

Dean,

A CML macro is still a programming effort outside the editor and requires a a few steps.
If I need to experiment with different delay, i don't want to recompile each time

I like the implementation of Universal Remote Control MX3000 (or even Pronto) where you specify an action to be a command or a link to another button on another page (this page doesn't have to be instantiate at all). So, when I create the pages for the device with all the commands I create also the power page that has the ON/OFF macros - it a typical logic this page never display.


I don't want to even guess your internal implementation, but can you think about a creative solution such as IV action list or even action the ablity to execute an action of the root template (if in your architecture the template must be "alive" in order to invoke its actions).

Rocker
Reply
#6
You can just test the macro within the test harness and prove it works, and it's a better debugging environment than the Intf Editor in that sense, because you have full debugging. So it's not a bad way to work if you are comfortable with CML.

Now, you can't interact with interface widgets from a CML macro, so that's something that wouldn't work going that route.
Dean Roddey
Explorans limites defectum
Reply
#7
Dean Roddey Wrote:You can just test the macro within the test harness and prove it works, and it's a better debugging environment than the Intf Editor in that sense, because you have full debugging. So it's not a bad way to work if you are comfortable with CML.

Now, you can't interact with interface widgets from a CML macro, so that's something that wouldn't work going that route.

Dean, I assume my point didn't pass well. Most of the time the entire sequence is one or two simple commands (such as power on a device) and I just want to invoke it from various places within the IV.

It's a hustle to deal with CML for this trivial usage. I don't need any debugging ability, and I don't want to recompile each time it changes.

Other environments have it and I hopping it can be a simple addition to CQC.

You currently have:
IntfViewer::RunTmplAction( action )

It will be great if you can extend it to:
IntfViewer::RunAction( template, action )

Thank you,

Rocker
Reply
#8
Quote:IntfViewer::RunAction( template, action )

Sure, I understand the interest in that. The reason it wasn't do so far is that there's no such thing as 'template'. The same template can be loaded multiple times because of overlays. That's always the issue. There's no good way to target another template. If it's done, it would likely have to be some sort of syntax that indicates levels upwards or something like that, but of course that would make it position dependent which could be an issue.

The simplest thing might be just allow for some at the root template that everyone can call througha RunRootTmplAction() command, and otherwise it has to be with the immediate parent. Most folks do end up witha single root template that everything else exists with the context of.
Dean Roddey
Explorans limites defectum
Reply
#9
rocker Wrote:Dean, I assume my point didn't pass well. Most of the time the entire sequence is one or two simple commands (such as power on a device) and I just want to invoke it from various places within the IV.

It's a hustle to deal with CML for this trivial usage. I don't need any debugging ability, and I don't want to recompile each time it changes.

Other environments have it and I hopping it can be a simple addition to CQC.

You currently have:
IntfViewer::RunTmplAction( action )

It will be great if you can extend it to:
IntfViewer::RunAction( template, action )

Thank you,

Rocker

I like it.
Reply
#10
tbh, that pronto-approach always seemed like a poor kludge to bolt on something useful to a flawed model, but generally fails. action execution is linked to buttons, irrespective of whether you intend the button to be pressed. The stupid thing is this is all based on javascript, a class-savvy interpreter - and they don't use classes for what screams to have it.

Dean: Consider where people have different root templates for different devices/users - resolution differences etc. Is there any logic to defining some sort of 'library' template just for the purpose of defining actions? (perhaps even disabling all the UI related gubbins). That way you can guarantee no dependencies on context etc.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Configure Elk Function Keys kblagron 2 1,582 12-29-2019, 11:30 PM
Last Post: kblagron
  I've open sourced my general purpose code Dean Roddey 0 1,120 03-09-2019, 06:53 PM
Last Post: Dean Roddey
  Is it possible to pass onto CQC what user code was used on the ELK? ghurty 9 4,669 01-23-2015, 12:53 PM
Last Post: wuench
  General CML/Programming Question standon 4 1,945 12-13-2012, 01:30 PM
Last Post: Dean Roddey
  simple CQC programming question js19707 1 1,478 08-14-2012, 10:09 PM
Last Post: Dean Roddey
  CQC Logic programming w/ movie watch list rtarver 2 1,589 05-21-2012, 07:50 AM
Last Post: rtarver
  How do you spelunk what Ajax calls are doing? Dean Roddey 4 2,081 11-30-2010, 10:33 AM
Last Post: Dean Roddey
  using a pronto hex ir code... pjwinstalls 6 2,798 11-06-2010, 09:01 PM
Last Post: pjwinstalls
  Repeating Code??? damian.flynn 5 1,816 02-24-2010, 11:48 AM
Last Post: Dean Roddey
  Good Practices Question (for driver's development) rocker 5 2,228 08-04-2009, 12:12 AM
Last Post: Dean Roddey

Forum Jump:


Users browsing this thread: 1 Guest(s)