At work, we have one of those nasty communal urinals. There is no flush handle. Rather, it has a motion sensor that sometimes triggers when you stand in front of it and sometimes doesn't. When it triggers, a tank fills, which when full is used to flush the urinal.
In my many trips before this nastraption, I have pondered both what the algorithm is the box uses to determine when to turn on and what would be the optimal algorithm, in terms of conserving water while still maintaining a relatively pleasant urinal experience.
I'll share my answer once folks have had a chance to share their ideas.
OnUserEnter()
{
if (UsersDetected == 0)
{
FirstDetectionTime = Now();
}
UsersDetected++;
CurrentlyInUse = true;
}
OnUserExit()
{
CurrentlyInUse = false;
if (UsersDetected >= MaxUsersBetweenFlushes ||
Now() - FirstDetectionTime > StinkInterval)
{
Flush();
}
}
OnTimer()
{
if (!CurrentlyInUse &&
UsersDetected > 0 &&
Now() - FirstDetectionTime > StinkInterval)
{
Flush();
}
}
Flush()
{
FlushTheUrinal();
UsersDetected = 0;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With