#include "SprinklerMgr.h"
#include "SprinklerDevice.h"

CSprinklerMgr::CSprinklerMgr(QObject *parent) : QObject(parent)
{
    mProgramHandle = 0;
}

int CSprinklerMgr::NewSprinklerDeviceCreated(CSprinklerDevice *Device)
{
    mSprinklersList.append(Device);
    return RET_OK;
}

CSprinklerDevice* CSprinklerMgr::GetSprinkler(int SprinklerNetworkAddress)
{
    if(mSprinklersList.isEmpty())
    {
        return 0;
    }

    for(int i = 0; i < mSprinklersList.size(); i++)
    {
        if(mSprinklersList.at(i)->mDeviceAddress == SprinklerNetworkAddress)
        {
            return mSprinklersList.at(i);
        }
    }

    return 0;
}
