SageTV Community  

Go Back   SageTV Community > SageTV Development and Customizations > SageTV Studio
Forum Rules FAQs Community Downloads Today's Posts Search

Notices

SageTV Studio Discussion related to the SageTV Studio application produced by SageTV. Questions, issues, problems, suggestions, etc. relating to the Studio software application should be posted here.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 06-30-2009, 11:24 AM
PLUCKYHD PLUCKYHD is offline
SageTVaholic
 
Join Date: Dec 2007
Posts: 6,257
Question about loop coding

See the attached jpg is this the current way to do a loop? (I will set property's and the such to stop the loop at a given time) just wanting to make sure I am looping correctly.

cheers

codehttp://babgvant.com/downloads/pluckyhd/loop%20code.jpg
Reply With Quote
  #2  
Old 06-30-2009, 11:34 AM
MeInMaui's Avatar
MeInMaui MeInMaui is offline
SageTVaholic
 
Join Date: Feb 2005
Location: Maui. HI
Posts: 4,203
With that setup, you will spawn a new infinite loop every time the Up command is executed. I'm not sure what you're trying to accomplish, but the Up listener may not be the best place to do this. Also, if you would like the loop to ever stop, then you will have to add a way to break out of it. This is usually done with an If statement.

Aloha,
Mike
__________________
"Everything doesn't exist. I'm thirsty." ...later... "No, it's real!!! I'm full."
- Nikolaus (4yrs old)
Reply With Quote
  #3  
Old 06-30-2009, 11:49 AM
PLUCKYHD PLUCKYHD is offline
SageTVaholic
 
Join Date: Dec 2007
Posts: 6,257
Quote:
Originally Posted by MeInMaui View Post
With that setup, you will spawn a new infinite loop every time the Up command is executed. I'm not sure what you're trying to accomplish, but the Up listener may not be the best place to do this. Also, if you would like the loop to ever stop, then you will have to add a way to break out of it. This is usually done with an If statement.

Aloha,
Mike
Right That is what I am wanting is an infinite loop when up is pressed (I will add if statements to break out of it) Just making sure I am doing the looping part correct by backreferencing to the fork?
Reply With Quote
  #4  
Old 06-30-2009, 12:56 PM
MeInMaui's Avatar
MeInMaui MeInMaui is offline
SageTVaholic
 
Join Date: Feb 2005
Location: Maui. HI
Posts: 4,203
If you reference the Fork(), then you will spawn a new thread every time you loop. You should reference the widget after the Fork().

Aloha,
Mike
__________________
"Everything doesn't exist. I'm thirsty." ...later... "No, it's real!!! I'm full."
- Nikolaus (4yrs old)
Reply With Quote
  #5  
Old 06-30-2009, 01:00 PM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
You definitely don't want to loop back to the Fork() call, since that will spawn a new thread every time around the loop. Presumably what you want is to fork just once, and then loop within the forked thread. Typically the place you want to jump back to is your loop exit test, so you can't really have a correct loop structure without that.

Although as Mike said, it's not clear why you want a new thread every the user clicks Up. What if he clicks Up twice in quick succession, before the first loop finishes? What effect are you trying to achieve with this?
__________________
-- Greg
Reply With Quote
  #6  
Old 06-30-2009, 01:48 PM
PLUCKYHD PLUCKYHD is offline
SageTVaholic
 
Join Date: Dec 2007
Posts: 6,257
Quote:
Originally Posted by GKusnick View Post
You definitely don't want to loop back to the Fork() call, since that will spawn a new thread every time around the loop. Presumably what you want is to fork just once, and then loop within the forked thread. Typically the place you want to jump back to is your loop exit test, so you can't really have a correct loop structure without that.

Although as Mike said, it's not clear why you want a new thread every the user clicks Up. What if he clicks Up twice in quick succession, before the first loop finishes? What effect are you trying to achieve with this?
Greg,

Thanks that makes more sense. As for why I am putting this in up it would probably be better placed in focus gained (although I don't care if it finishes or not) it is increasing a counter like you see there and that counter is changing pictures rapidly to create animation effect that I have come up with. It seems to work very well so far in testing.

cheers
Reply With Quote
  #7  
Old 06-30-2009, 02:03 PM
MeInMaui's Avatar
MeInMaui MeInMaui is offline
SageTVaholic
 
Join Date: Feb 2005
Location: Maui. HI
Posts: 4,203
When you do those kinds of animations, make sure you pull up Task Manager to see what your CPU usage is. Also make sure you try it out on an extender. I think you'll find that your CPU usage will spike and it will be painfully slow on extenders.

Aloha,
Mike
__________________
"Everything doesn't exist. I'm thirsty." ...later... "No, it's real!!! I'm full."
- Nikolaus (4yrs old)
Reply With Quote
  #8  
Old 06-30-2009, 02:06 PM
PLUCKYHD PLUCKYHD is offline
SageTVaholic
 
Join Date: Dec 2007
Posts: 6,257
Quote:
Originally Posted by MeInMaui View Post
When you do those kinds of animations, make sure you pull up Task Manager to see what your CPU usage is. Also make sure you try it out on an extender. I think you'll find that your CPU usage will spike and it will be painfully slow on extenders.

Aloha,
Mike
So far my cpu usage is low (10 to 15%) and hd200 has worked well with it. I keep the images small and make sure they will all fit in the cache. But yes it does require a larger java heap.

Thanks for the advice I always try and watch the cpu and test on extenders,clients. (got to make sure it works for everyone )
Reply With Quote
  #9  
Old 06-30-2009, 02:18 PM
PLUCKYHD PLUCKYHD is offline
SageTVaholic
 
Join Date: Dec 2007
Posts: 6,257
I moved to focus gained and have my if evaluation now. Wanted to run by you guys again and make sure I am on the right train of thought.

TIA for all you comments/help

code2

(the fork looks like it is referenced somewhere else but that is a delete that I haven't gotten rid of on the side menu yet so it really isn't)

EDIT link now good

Last edited by PLUCKYHD; 06-30-2009 at 02:22 PM.
Reply With Quote
  #10  
Old 06-30-2009, 04:07 PM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
Generally speaking, calling Refresh() in a loop is not recommended as a way to do animation. You're usually better off using dynamic animation using the Animate widget property. Set this to some expression that evaluates to true when you want the animation to happen, and false when you don't. So for instance your Image widget could be set to animate when CurrentPic >= 0. Your FocusGained code could then set CurrentPic = 0 to start the animation. Each redraw cycle would increment the counter, and ultimately set it back to -1 to stop the animation.

There's a fairly detailed discussion of this starting on p. 148 of the Studio manual, plus the Property-Based Animation tutorial on p. 126.
__________________
-- Greg
Reply With Quote
  #11  
Old 06-30-2009, 06:47 PM
PLUCKYHD PLUCKYHD is offline
SageTVaholic
 
Join Date: Dec 2007
Posts: 6,257
Quote:
Originally Posted by GKusnick View Post
Generally speaking, calling Refresh() in a loop is not recommended as a way to do animation. You're usually better off using dynamic animation using the Animate widget property. Set this to some expression that evaluates to true when you want the animation to happen, and false when you don't. So for instance your Image widget could be set to animate when CurrentPic >= 0. Your FocusGained code could then set CurrentPic = 0 to start the animation. Each redraw cycle would increment the counter, and ultimately set it back to -1 to stop the animation.

There's a fairly detailed discussion of this starting on p. 148 of the Studio manual, plus the Property-Based Animation tutorial on p. 126.
Write but I am not performing animations in th sense you think I am.. I am really just chaning pictures fast to make it look like an animation is happening.

Also I thought andy had always said to make sure I call refreshs after animations so i do (but those aren't in loops like this)

Hopefully I make sense.
Reply With Quote
  #12  
Old 06-30-2009, 07:02 PM
PLUCKYHD PLUCKYHD is offline
SageTVaholic
 
Join Date: Dec 2007
Posts: 6,257
Also meant to say you know more than me It has been a couple of months or longer sense I went through the animation tutorial I will have a look as I would probably understand it allot better now

I am still confused as I don't think what I am doing is an actual animation
Reply With Quote
  #13  
Old 06-30-2009, 07:22 PM
PLUCKYHD PLUCKYHD is offline
SageTVaholic
 
Join Date: Dec 2007
Posts: 6,257
Quote:
Originally Posted by GKusnick View Post
Generally speaking, calling Refresh() in a loop is not recommended as a way to do animation. You're usually better off using dynamic animation using the Animate widget property. Set this to some expression that evaluates to true when you want the animation to happen, and false when you don't. So for instance your Image widget could be set to animate when CurrentPic >= 0. Your FocusGained code could then set CurrentPic = 0 to start the animation. Each redraw cycle would increment the counter, and ultimately set it back to -1 to stop the animation.

There's a fairly detailed discussion of this starting on p. 148 of the Studio manual, plus the Property-Based Animation tutorial on p. 126.
Greg,

Thanks a million again the tutorials make more sense everytime I go through them the first time i don't think I understand what "property" based animations meant. A much more efficient way.
Reply With Quote
  #14  
Old 06-30-2009, 08:58 PM
Opus4's Avatar
Opus4 Opus4 is offline
Administrator
 
Join Date: Sep 2003
Location: NJ
Posts: 19,624
Quote:
Originally Posted by PLUCKYHD View Post
Also I thought andy had always said to make sure I call refreshs after animations so i do (but those aren't in loops like this)
I was referring to calling Refresh() after calling one of the Animate() series of API calls so that the animation will occur.

- Andy
__________________
SageTV Open Source v9 is available.
- Read the SageTV FAQ. Older PDF User's Guides mostly still apply: SageTV V7.0 & SageTV Studio v7.1.
- Hauppauge remote help: 1) Basics/Extending it 2) Replace it 3) Use it w/o needing focus
- HD Extenders: A) FAQs B) URC MX-700 remote setup
Note: This is a users' forum; see the Rules. For official tech support fill out a Support Request.
Reply With Quote
  #15  
Old 07-01-2009, 05:18 AM
PLUCKYHD PLUCKYHD is offline
SageTVaholic
 
Join Date: Dec 2007
Posts: 6,257
Quote:
Originally Posted by Opus4 View Post
I was referring to calling Refresh() after calling one of the Animate() series of API calls so that the animation will occur.

- Andy
Yeah I was confused when he said property based animations the last time through the tuturial I didn't understand that part fully (obviously)
Reply With Quote
  #16  
Old 07-02-2009, 08:22 AM
PLUCKYHD PLUCKYHD is offline
SageTVaholic
 
Join Date: Dec 2007
Posts: 6,257
Okay I made changes and wanted to check my looping code by you guys again it works great but I like to make sure I am doing it correctly/efficiently

loopcode

The first one goes on to set a property in another area if true

The second it setting an animate property to animate my property animations.

I am only wanting to perform this if the user has stayed focused on a item for the set period of time. That is what the waits are for

TIA

I also have another question about property based animations from the studio manual
"Timed Animation
In this menu, examine the “Timed Animation” panel’s widget tree. That panel defines a
time period for the Animation property of “0,1000,0”, which causes this entire section of
the screen to be updated every second. When that panel updates, the displayed text is
positioned according to the random position defined in the “Random location” panel.
(This is the basic technique used for the SageTV screen saver – see the “Screen Saver”
menu in the default STV.)"

I get what the 1000 respresents but what are the first and last number for?

Last edited by PLUCKYHD; 07-02-2009 at 08:33 AM.
Reply With Quote
  #17  
Old 07-02-2009, 08:59 AM
Opus4's Avatar
Opus4 Opus4 is offline
Administrator
 
Join Date: Sep 2003
Location: NJ
Posts: 19,624
Quote:
Originally Posted by PLUCKYHD View Post
Okay I made changes and wanted to check my looping code by you guys again it works great but I like to make sure I am doing it correctly/efficiently

loopcode

The first one goes on to set a property in another area if true
My first question is: are the animations doing what you want? The first one seems to do something if ActorMenuLoaded is false.

Quote:
The second it setting an animate property to animate my property animations.
This one doesn't check to see if focus is still on the item in question, and it may be setting a variable to cause a panel to animate PLUS call Refresh. One of the goals of using a variable to force a panel to animate is to prevent having to use Refresh, which causes the entire menu to refresh itself.

In your code, you could change focus several times and end up having several of those forked threads active & waiting to go off. You should probably have a variable local to the item that says whether focus is still actively on it.

Quote:
I also have another question about property based animations from the studio manual
"Timed Animation
In this menu, examine the “Timed Animation” panel’s widget tree. That panel defines a
time period for the Animation property of “0,1000,0”, which causes this entire section of
the screen to be updated every second. When that panel updates, the displayed text is
positioned according to the random position defined in the “Random location” panel.
(This is the basic technique used for the SageTV screen saver – see the “Screen Saver”
menu in the default STV.)"

I get what the 1000 respresents but what are the first and last number for?
Did you see and review the property mentioned directly above your quote from the Studio manual? That links to the explanation of the property & is why I suggested reviewing the property before continuing.
Quote:
Originally Posted by Studio manual
Before continuing, you may wish to review the Animation property in the Properties Common to Many Widgets reference
- Andy
__________________
SageTV Open Source v9 is available.
- Read the SageTV FAQ. Older PDF User's Guides mostly still apply: SageTV V7.0 & SageTV Studio v7.1.
- Hauppauge remote help: 1) Basics/Extending it 2) Replace it 3) Use it w/o needing focus
- HD Extenders: A) FAQs B) URC MX-700 remote setup
Note: This is a users' forum; see the Rules. For official tech support fill out a Support Request.
Reply With Quote
  #18  
Old 07-02-2009, 09:05 AM
PLUCKYHD PLUCKYHD is offline
SageTVaholic
 
Join Date: Dec 2007
Posts: 6,257
Quote:
Originally Posted by Opus4 View Post
My first question is: are the animations doing what you want? The first one seems to do something if ActorMenuLoaded is false.
Yes they are doing what I want.

Quote:
Originally Posted by Opus4 View Post
This one doesn't check to see if focus is still on the item in question, and it may be setting a variable to cause a panel to animate PLUS call Refresh. One of the goals of using a variable to force a panel to animate is to prevent having to use Refresh, which causes the entire menu to refresh itself.
.
Okay so when you set the variable how do you get it refreshed in the area with the variable you want to animate without refreshing?

Quote:
Originally Posted by Opus4 View Post
In your code, you could change focus several times and end up having several of those forked threads active & waiting to go off. You should probably have a variable local to the item that says whether focus is still actively on it.
That is my concern but I guess I don't understand/see another way to do this. What about putting it back in the up/down listeners and not having a false only a true therefor not having a loop?

Quote:
Originally Posted by Opus4 View Post
Did you see and review the property mentioned directly above your quote from the Studio manual? That links to the explanation of the property & is why I suggested reviewing the property before continuing.
I missed that suggestion sorry
Reply With Quote
  #19  
Old 07-02-2009, 11:52 AM
Opus4's Avatar
Opus4 Opus4 is offline
Administrator
 
Join Date: Sep 2003
Location: NJ
Posts: 19,624
Quote:
Originally Posted by PLUCKYHD View Post
Okay so when you set the variable how do you get it refreshed in the area with the variable you want to animate without refreshing?
?? If I understand your question, the answer is in the paragraph below your previous quote from the Studio manual & is in the tutorial STV. Alternately, you could consider the LayoutStarted or RenderingStarted hooks to reset the variable.

- Andy
__________________
SageTV Open Source v9 is available.
- Read the SageTV FAQ. Older PDF User's Guides mostly still apply: SageTV V7.0 & SageTV Studio v7.1.
- Hauppauge remote help: 1) Basics/Extending it 2) Replace it 3) Use it w/o needing focus
- HD Extenders: A) FAQs B) URC MX-700 remote setup
Note: This is a users' forum; see the Rules. For official tech support fill out a Support Request.
Reply With Quote
  #20  
Old 07-02-2009, 12:29 PM
PLUCKYHD PLUCKYHD is offline
SageTVaholic
 
Join Date: Dec 2007
Posts: 6,257
Quote:
Originally Posted by Opus4 View Post
?? If I understand your question, the answer is in the paragraph below your previous quote from the Studio manual & is in the tutorial STV. Alternately, you could consider the LayoutStarted or RenderingStarted hooks to reset the variable.

- Andy
I am confused I think because I set the variable to animate in focus gained after a set given time of inactivity (I don't want the animation occuring while they are scrolling the table) the animation occurs outside the table in a different panel widget altogether so I have to somehow refresh that animate property in the other panel widget

Hopefully that made more sense.



Deleted question below figured it out.

Last edited by PLUCKYHD; 07-02-2009 at 02:26 PM.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
SageTV Alarm Clock - Who's up to coding one for a kickback? chris123 SageTV Customizations 19 05-28-2009 12:50 PM
Some coding questions Ikarius SageTV Studio 1 02-18-2009 12:47 PM
coding help sundansx SageTV Studio 8 07-22-2006 09:20 PM


All times are GMT -6. The time now is 02:27 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2023, vBulletin Solutions Inc.
Copyright 2003-2005 SageTV, LLC. All rights reserved.