How to set a conditional port status?

Do you have a question on how to do something.
Ask in here.
Post Reply
btorrenga
Posts: 100
Joined: Mon Apr 16, 2012 10:22 pm

How to set a conditional port status?

Post by btorrenga »

I am having trouble coming up with two lines of code. The solution is simple, but I cannot figure out the proper syntax. Could someone please point out how to:

Turn on port 1 of the main relay IF port 4 of the main relay is off AND the time is NOT between midnight and 7:00am?

Secondly, how can I turn on port 7 of the main relay IF port 4 of the main relay is off OR the time is between 9:00pm and 11:00am?
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: How to set a conditional port status?

Post by rimai »

Try this:

Code: Select all

  ReefAngel.Relay.Set(Port1, !ReefAngel.Relay.Status(Port4) && hour()>7);
  ReefAngel.Relay.Set(Port7, !ReefAngel.Relay.Status(Port4) || hour()>=21 || hour()<11);
Roberto.
btorrenga
Posts: 100
Joined: Mon Apr 16, 2012 10:22 pm

Re: How to set a conditional port status?

Post by btorrenga »

Awesome, thanks again. Testing it today. I learned a lot from those two lines.
btorrenga
Posts: 100
Joined: Mon Apr 16, 2012 10:22 pm

Re: How to set a conditional port status?

Post by btorrenga »

Can this behavior also be used for the dosing pump port? For example, I do not want to dose vinegar if the metal halides are off. In other words, if my dosing pump is located at expansion relay 1, port 6, is it possible to only allow the dosing to occur if Main relay port 4 is on?
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: How to set a conditional port status?

Post by rimai »

You would need to do like this:

Code: Select all

  if (ReefAngel.Relay.Status(Port4))
    ReefAngel.DosingPumpRepeat(Box1_Port6,0,60,5);
  else
    ReefAngel.Relay.Off(Box1_Port6)
Roberto.
Post Reply