Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome Programming
 PowerHome Messageboard : PowerHome Programming
Subject Topic: getting level real time in Macros Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
bhlonewolf
Senior Member
Senior Member


Joined: March 29 2007
Online Status: Offline
Posts: 198
Posted: June 08 2007 at 12:40 | IP Logged Quote bhlonewolf

Not so much a direct question, just wondering what others have done:

I set up a few macros that will essentially turn off devices after a timeout -- so if the macro gets fired multiple times, it checks if the macro is currently waiting and adds time to the timeout as necessary.

I was running into a few bugs and I think the reason is that I run several checks to verify levels of the device in real time before entering a wait. My hunch is that the first execution of the macro may take some time to actually enter a wait state because it's checking all of the levels, so if other macros come in within a few moments (an edge case but a possibility), the macro isn't waiting. (It is _running_, though.)

So, in situations like this I'm wondering if people avoid checking device status in real time (or other lengthy command) before entering a wait? In a more classic programming sense we'd just use a lock or monitor, but wondering what others are doing...

Is there a way to check if the macro is running? I could put that at the top to queue up pending executions...
Back to Top View bhlonewolf's Profile Search for other posts by bhlonewolf
 
bhlonewolf
Senior Member
Senior Member


Joined: March 29 2007
Online Status: Offline
Posts: 198
Posted: June 08 2007 at 13:09 | IP Logged Quote bhlonewolf

OK -- I think I figured out at least part of the problem -- the traffic should be all insteon, but I noticed my controlinc was sending out X-10 signals as well. (Going no where, though.)

I believe PH processes these immediately instead of in a queue, when I removed the x10 addresses from the buttons, it seems to work much better.
Back to Top View bhlonewolf's Profile Search for other posts by bhlonewolf
 
nadler
Super User
Super User


Joined: February 25 2006
Location: United States
Online Status: Offline
Posts: 354
Posted: June 08 2007 at 15:40 | IP Logged Quote nadler

I have had some issues with macros stalling in the queue when they contained "wait" commands. Is your issue similar or are you describing something else? Dave is aware of the 'wait' issue and it should be addressed in the next release.
Back to Top View nadler's Profile Search for other posts by nadler
 
onhiatus
Senior Member
Senior Member
Avatar

Joined: May 12 2004
Location: United States
Online Status: Offline
Posts: 279
Posted: June 08 2007 at 16:30 | IP Logged Quote onhiatus

I'm curious as to how your logic works. I have been playing with this type of functionality.

My first idea was to keep a global variable that would be incremented by multiple triggers, and a check loop that would take an action once the variable had "expired". But this gets very ugly when you want ot be able to do it for every device.

Second idea was to create a single fire timed event deleteing the existing timed event (if there is one) from the db. I haven't tried to implement this yet, but I think it's the way I'll go. It seems the more elegant and clean solution.

Thoughts?
Back to Top View onhiatus's Profile Search for other posts by onhiatus Visit onhiatus's Homepage
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: June 08 2007 at 19:04 | IP Logged Quote TonyNo

I think I am doing what you mention without issue. Five-minute wait until no motion...


FOYER MOTION
10 Jump if( ph_getinsteonstat("FOYER LIGHT") = 2, 7, 1)      
20 Macro FOYER LIGHT ON
30 Jump if( ph_ismacrowaiting("FOYER MOTION") > 0, 1, 3)      
40 Wait ph_extendmacrowait("FOYER MOTION", 300, 0)      
50 Jump 999      
60 Wait 300      
70 Macro FOYER LIGHT OFF
Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
bhlonewolf
Senior Member
Senior Member


Joined: March 29 2007
Online Status: Offline
Posts: 198
Posted: June 08 2007 at 19:08 | IP Logged Quote bhlonewolf

Yep, what Tony has done is pretty much what I've done. Having everything "queued" is certainly key if the macros get complicated and there's a potential for duplicate signals. Onhiatus, the ph_ismacrowaiting and ph_extendmacrowait functions are key -- no need to do the syncronization stuff yourself :)

EDIT: Actually, one change to mine is:
40 Wait ph_extendmacrowait("FOYER MOTION", 300, 1)

In my case, I wanted to extend the time, not "reset" it ... I think I got that tip from another one of your posts, Tony :)

Edited by bhlonewolf - June 08 2007 at 19:11
Back to Top View bhlonewolf's Profile Search for other posts by bhlonewolf
 
onhiatus
Senior Member
Senior Member
Avatar

Joined: May 12 2004
Location: United States
Online Status: Offline
Posts: 279
Posted: June 21 2007 at 20:09 | IP Logged Quote onhiatus

Whoops, this does make a lot more sense. Thanks.

Rumor has it we're getting new docs...

Thanks, Tony(Onhiatus)
Back to Top View onhiatus's Profile Search for other posts by onhiatus Visit onhiatus's Homepage
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum