Sounds like you would use the ReefAngel.IO.GetChannel() for each of the three reservoirs.
Roberto's example incorporates all three into one.
Here's an example that checks all 3 reservoirs inside the MyCustomATO and only activates the ATO's that the pumps are not dry and alerts for the 3.
I got a little carried away with this function. I added a CheckReservoirStatus function that monitors the IO port for the level of the reservoir. I used this function to check whether we can start the port while topping. Now, if the timeout exceeds, this function will continue to try to turn on the pumps because the IsTopping is still enabled/set (same logic).
You will have to test this out to see if it works for you. You may need to remove the block that I marked "might need to remove this check here". I added that section in as another safeguard to prevent the pump from running if the reservoir goes empty while topping.
Code: Select all
void CheckReservoirStatus(byte channel, byte pump)
{
if ( ReefAngel.IO.GetChannel(channel) )
{
// If empty, shutoff the port, trigger alert
ReefAngel.CustomVar[0] = 1;
ReefAngel.Relay.Off(Port5);
}
else
{
// If not empty, turn on the port, clear alert
ReefAngel.CustomVar[0] = 0;
ReefAngel.Relay.On(Port5);
}
}
void MyCustomATO(int ATOTimeout)
{
/*
This function works as follows:
When it's time to topoff the system, we check the levels of each
of the three reservoirs. If a reservoir is empty, we set a custom
flag to indicate it's empty on the portal and we do not start that
pump. Otherwise, we clear the custom flag for the reservoir and
start the pump.
The function monitors the switch levels like normal.
Monitor the status of the reservoirs while topping off.
When the high switch is triggered (aka, finished topping off),
ALL ports are turned off regardless of status (doesn't hurt to do this).
If the timeout occurs, the LED light comes on and all ports are
turned off just like when we finish topping off.
*/
unsigned long TempTimeout = ATOTimeout;
TempTimeout *= 1000;
if ( ReefAngel.LowATO.IsActive() && ( !ReefAngel.LowATO.IsTopping()) )
{
ReefAngel.LowATO.Timer = millis();
ReefAngel.LowATO.StartTopping();
// Check the level of each reservoir
// If empty, set the alert and don't start topping off
// otherwise if not empty, clear the alert and start topping
CheckReservoirStatus(0, Port5);
CheckReservoirStatus(1, Port6);
CheckReservoirStatus(2, Box1_Port5);
}
// Monitor levels while topping off, to prevent a reservoir from running dry
// Might need to remove this check here
if ( ReefAngel.LowATO.IsTopping() )
{
CheckReservoirStatus(0, Port5);
CheckReservoirStatus(1, Port6);
CheckReservoirStatus(2, Box1_Port5);
}
if ( ReefAngel.HighATO.IsActive() )
{
ReefAngel.LowATO.StopTopping(); // stop the low ato timer
ReefAngel.Relay.Off(Port5);
ReefAngel.Relay.Off(Port6);
ReefAngel.Relay.Off(Box1_Port5);
}
if ( (millis()-ReefAngel.LowATO.Timer > TempTimeout) && ReefAngel.LowATO.IsTopping() )
{
ReefAngel.LED.On();
#ifdef ENABLE_EXCEED_FLAGS
InternalMemory.write(ATO_Exceed_Flag, 1);
#endif // ENABLE_EXCEED_FLAGS
ReefAngel.Relay.Off(Port5);
ReefAngel.Relay.Off(Port6);
ReefAngel.Relay.Off(Box1_Port5);
#ifdef ENABLE_ATO_LOGGING
// bump the counter if a timeout occurs
AtoEventCount++;
if ( AtoEventCount >= MAX_ATO_LOG_EVENTS ) { AtoEventCount = 0; }
#endif // ENABLE_ATO_LOGGING
}
}
Anyways, this should be another good example for you to work from.