Author Topic: Just a bit of help needed  (Read 2713 times)

DaveB

  • Sr. Member
  • ****
  • Posts: 260
    • View Profile
Just a bit of help needed
« on: June 19, 2010, 10:08:53 am »
I am setting out to try to establish an irrigation timer.  FOr now, I am just attempting to set up a simple zone test button.  The button will make the zone run for one minute.  See below for the script under my scene called "Test Zone 1";

IRR_Timer.StartTimer(@"zone1test", 60000);   {starts timer - BTW; the countdown timer needs the ability to select the UOM.  Milliseconds are less than desirable}
System.Log(@"Zone 1 test");    {Log Event}
omni.TurnOnOutput(9);  {turn on the pump}
omni.TurnOnOutput(22);  {turn on the zone}

Ok, now what.  I am having a tough time writing the next line or two.  When the countdown timer hits zero, I want the outputs to turn off.  The IF statement setup is not as intuitive as I think it should be and I can not figure out a way to write this;

When IRR_Timer = 0  (or If IRR_Timer = 0)
omni.TurnOffOutput(9);
Omni.TurnOffOutput(22);

What very simple thing am I missing? 
« Last Edit: June 19, 2010, 10:13:49 am by DaveB »
Thanks!
Dave

John Hughes

  • Administrator
  • Hero Member
  • *****
  • Posts: 2852
    • View Profile
    • Codecore Technologies
Re: Just a bit of help needed
« Reply #1 on: June 19, 2010, 11:55:35 am »
You need to create a second rule for your Timer driver's Elapsed event.  In the rule's whenever filter, set the timer name to "zone1test".

PS: If you are manually writing the script you don't need to prefix strings with @ unless your string qualifies... which it does not in this case.

Also what is "UOM"?
John Hughes
Codecore Technologies

DaveB

  • Sr. Member
  • ****
  • Posts: 260
    • View Profile
Re: Just a bit of help needed
« Reply #2 on: June 19, 2010, 12:30:56 pm »
First - UOM = Unit of measure.  Second/Min/Hour/and so on
 
I am not wrotong the script manually, so this is what I got when using the system. 
 
I will look at making a second rule.  I do not understand why I need to do that, but do see that it would work.  It just will get to be a mess when you have 16 zones, grouped differently, all with different start times and different run times.  I see 125 rules just to get it all to work.  I am attempting to avoid that. 
 
In HAI speak, it is easy;  Start Zone 1 for xxx minutes then start zone 2 and so on.  I was trying to duplicate that very simple logic outside of HAI. It is called Timed level with code like this;  TimedLevel!100!Minutes!6!296 (turn unit 296 on at a level of 100 for 6 minutes).  If you expose more features on HAI, the rules will get very easy to create and manage. 
 
 
 
Thanks!
Dave

John Hughes

  • Administrator
  • Hero Member
  • *****
  • Posts: 2852
    • View Profile
    • Codecore Technologies
Re: Just a bit of help needed
« Reply #3 on: June 19, 2010, 01:06:52 pm »
Yes this is a known issue and we have been trying to come up with an elegant solution. There is a much simpler way to accomplish what you want, see C below.

There are several situations where you may want to use this same pattern:

A couple off the top of my head are:

1. Turn on output for X minutes.
2. Turn on light or set light level for X minutes and then turn off.

The Elk M1 has the feature built in, so you can actually run elkm1.TurnOnOutput(2, 25) where 25 is seconds.

A. So one option would be to identify the most common uses of this pattern and enhance the drivers.

B. The other solution would be to use some way to generically say "Do this, wait 10 minutes, then do that".  This can be done with timers now but as you mention this is tedious, cumbersum and confusing when you get have a lot of them.

C. You can just let the rule sleep for X seconds. For example:

Code: [Select]
omni.TurnOnOutput(9);  {turn on the pump}
omni.TurnOnOutput(22);  {turn on the zone}
System.Sleep(60000);
omni.TurnOffOutput(9);
Omni.TurnOffOutput(22);

That will work but it has a limitation... what if you want to preemptively cancel it or even extend it? In your case canceling it is easy since you can turn off the outputs at any time... but then if you want to turn them back on before the 60 seconds is up, they will be soon be turned off unexpectedly since the rule is still running in the background.

I suppose I could add a terminate rule function, but what if you end up killing it between the last 2 statements?

Anyway, we are certainly looking for feedback and suggestions in this area.
John Hughes
Codecore Technologies

DaveB

  • Sr. Member
  • ****
  • Posts: 260
    • View Profile
Re: Just a bit of help needed
« Reply #4 on: June 19, 2010, 01:59:47 pm »
HAI has that same capability as the Elk M1, you just need to figure out how to expose it to the driver. 

I will think through this a bit and let you know. 

Thanks for the feedback!  It is appreciated. 
Thanks!
Dave

John Hughes

  • Administrator
  • Hero Member
  • *****
  • Posts: 2852
    • View Profile
    • Codecore Technologies
Re: Just a bit of help needed
« Reply #5 on: July 11, 2010, 11:31:28 pm »
BTW; the countdown timer needs the ability to select the UOM.  Milliseconds are less than desirable}

The StartTimer() method now also accepts the TimeSpan datatype when scripting.
John Hughes
Codecore Technologies

DaveB

  • Sr. Member
  • ****
  • Posts: 260
    • View Profile
Re: Just a bit of help needed
« Reply #6 on: July 12, 2010, 03:26:15 pm »
Great - I will try it out. 
 
 
Thanks!
Dave

John Hughes

  • Administrator
  • Hero Member
  • *****
  • Posts: 2852
    • View Profile
    • Codecore Technologies
Re: Just a bit of help needed
« Reply #7 on: July 12, 2010, 08:50:57 pm »
I also changed the milliseconds override to seconds... which is a breaking change.
John Hughes
Codecore Technologies

John Hughes

  • Administrator
  • Hero Member
  • *****
  • Posts: 2852
    • View Profile
    • Codecore Technologies
Re: Just a bit of help needed
« Reply #8 on: July 13, 2010, 12:12:32 am »
HAI has that same capability as the Elk M1, you just need to figure out how to expose it to the driver. 

I found it but it is a little awkward.  HAI supports one of the following time ranges:

1-99 seconds
1-99 minutes
1-18 hours
or a user setting

I may just not use the HAI solution and provide a custom solution which allows for any duration.
« Last Edit: July 13, 2010, 07:31:43 am by John Hughes »
John Hughes
Codecore Technologies

DaveB

  • Sr. Member
  • ****
  • Posts: 260
    • View Profile
Re: Just a bit of help needed
« Reply #9 on: July 13, 2010, 06:00:09 pm »
Yea - I would agree that a custom solution would be better as long as the panel would work with the solution. 
Thanks!
Dave

John Hughes

  • Administrator
  • Hero Member
  • *****
  • Posts: 2852
    • View Profile
    • Codecore Technologies
Re: Just a bit of help needed
« Reply #10 on: July 18, 2010, 12:27:02 pm »
This feature will be available in v0.25.

You can now set any property to a value for a specified duration of time and then have it set to another value.
There are also specialized methods for lighting and outputs.

The associated methods are named:

* SetLightLevelForDuration
* TurnOnLightForDuration
* TurnOnOutputForDuration
* SetPropertyForDuration <- this can be used for any property.
« Last Edit: July 18, 2010, 02:21:24 pm by John Hughes »
John Hughes
Codecore Technologies

DaveB

  • Sr. Member
  • ****
  • Posts: 260
    • View Profile
Re: Just a bit of help needed
« Reply #11 on: July 18, 2010, 06:44:39 pm »
Perfect.  This will work great with an irrigation solution or for "follow-me" lighting that I use at night.  After in night mode, my pathway lighting is brought on by my motion sensors, and then off after a time out. 
 
 
Thanks!
Dave