Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome Programming
 PowerHome Messageboard : PowerHome Programming
Subject Topic: General Question Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
mustangcoupe
Super User
Super User
Avatar

Joined: August 08 2003
Location: United States
Online Status: Offline
Posts: 308
Posted: May 05 2006 at 10:07 | IP Logged Quote mustangcoupe

I have noticed in other threads that Dave recommends not running immediate but to put the items in to the que. What is the advantage of this? What are the drawback of running them innediate?

Dave with my database you are analyzing (SDM thread) you should see I am running a few of them immediate. What are your recomendations before my system grows?



__________________
Todd Hannemann

HA newbie

   PowerHome - UPB - ELK    
Back to Top View mustangcoupe's Profile Search for other posts by mustangcoupe Visit mustangcoupe's Homepage
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: May 05 2006 at 13:55 | IP Logged Quote TonyNo

I'm sure Dave can come up with others, but off the top of my head, here is one example...

X10 comms work in two phases: addressing then command (i.e. A3, On). If the system processes an Immediate command, it could happen bewteen those two parts and cause unexpected results.

Dave: If this is not true, please correct me.

As Dave has mentioned, there are times when Immediate is appropriate.
Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: May 07 2006 at 13:46 | IP Logged Quote dhoward

A classic "bad" time to use "immediate" is a typical trigger where incoming X10 is received and you send a corresponding X10. In this case, the controller serial buffer is being processed. X10 commands have been received (usually more than one) and they are being processed. As the command is processed, triggers are checked for. If a trigger is fired, then it's action will be performed. If the action is sending another X10 command and is action type immediate, that command is sent to the X10 controller immediately. The result is that the X10 receive process that was currently going on is now totally corrupted as outgoing X10 data is overwriting it.

So....generally, the proper way is to always use "Queued" as the action type. What happens here is the same as "Immediate". Incoming commands are processed and triggers are fired. The resulting actions though instead of being processed immediately are instead sent to the execution queue. This is a "first in, first out" structure that turns all parallel tasks within PowerHome into a single stream with everything happening in the order in which it occurred.

In normal processing, you won't see any difference in execution speed (which I think is the reason most people tend to choose "immediate" over "queued") because as soon as the trigger is done, the execution queue is processed.

In certain situations though, you may want to bypass this "first in first out" process or you need to effect a change before the next trigger is processed. As long as certain rules are followed, you can use "immediate" to your advantage. The main thing you want to be careful of is concerning "controllers". You never want to send a command to a controller while processing a trigger from the same controller. You can probably get away with it if the trigger action is on a different controller than what fired the trigger, you would have to test it. If PowerHome locks up or doesnt perform as expected, then change the action style back to "queued".

Sometimes though, you need to both perform an action immediately and violate the above rules. In this case, you can use "immediate" to perform the required immediate action and then "post" the part of the action that violates the rules. You can use the ph_postformula function for this or certain macro commands have a "post" option.

Ive also taken a first look at your database. I havent analyzed your triggers yet, but will do so. Whats more interesting are your SDM logs. Something appears to be seriously wrong with your PLC. I don't have the data in front of me at the moment, so will post to the appropriate thread my finding when I get back to my main computer.

Dave.
Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: May 08 2006 at 18:10 | IP Logged Quote dhoward

Todd,

I checked out your triggers and the immediate ones (A2 ON, A5 OFF, A6 OFF, A6 ON) all should be ok since they just set a global variable (and you don't have any triggers on GV change) and then do a TTS.

However, several of the ones having to do with the ALARM are triggered by incoming Insteon commands and then contain lines to send Insteon commands. I would think these would give you trouble. If they work for you, then something in the timing must be preventing a lockup but I would change these to queued or at least make the Insteon commands be posted to the execution queue.

Dave.
Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: May 08 2006 at 18:12 | IP Logged Quote dhoward

All,

Ive come up with another trick to use in the trigger "Immediate" vs "Queued" debate. If you have a trigger action that has items that must be done in an "Immediate" fashion and items that violate the rules requiring them to be performed in a "Queued" fashion, in addition to using the ph_postformula and the specific macro commands that support queueing you can also use the macro "Wait" command. Simply create a macro containing all of your actions. Place the immediate actions at the top of the macro that dont violate the rules. Then perform a "Wait" with a wait time of 0. Then perform all of the actions that can be queued or would violate the immediate rules. You can now set your trigger to have an action style of "Immediate" and call your macro. The items at the top will be executed immediately and then will hit the "Wait" command which will place the rest of the macro into the execution queue. It will come up as soon as possible since the wait is 0 (it will be after other queued actions though). Using this technique will simplify you having to use the ph_postformula or queueing specific macro commands.

Keep in mind that for most purposes, just use the "Queued" command and you'll have no worries. Only use the "Immediate" action style in those rare instances where something needs to be updated in a time critical fashion that other triggers may be dependant upon. In normal circumstances, you will see no difference in speed between "Queued" and "Immediate"

Dave.
Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward'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