GuiInterface.cpp

/**
 * (c)2017 CDP Technologies AS
 */

#include "GuiInterface.h"

using namespace TankControlLib;

GuiInterface::GuiInterface()
{
}

GuiInterface::~GuiInterface()
{
}

void GuiInterface::Create(const char* fullName)
{
    CDPComponent:: Create(fullName);
    Pause.Create("Pause",this);
    FishTank1.Create("FishTank1",this);
    FishTank2.Create("FishTank2",this);
}

void GuiInterface::CreateModel()
{
    CDPComponent::CreateModel();

    RegisterStateProcess("Null",(CDPCOMPONENT_STATEPROCESS)&GuiInterface::ProcessNull,"Initial Null state");
    RegisterMessage(CM_TEXTCOMMAND,"StartFeeding","",(CDPOBJECT_MESSAGEHANDLER)&GuiInterface::MessageForwardMessage);
    RegisterMessage(CM_TEXTCOMMAND,"Stop","",(CDPOBJECT_MESSAGEHANDLER)&GuiInterface::MessageForwardMessage);
    RegisterMessage(CM_TEXTCOMMAND,"StartFilling","",(CDPOBJECT_MESSAGEHANDLER)&GuiInterface::MessageForwardMessage);
    RegisterMessage(CM_TEXTCOMMAND,"AutoStartFeeding","",(CDPOBJECT_MESSAGEHANDLER)&GuiInterface::MessageForwardMessage);
}

void GuiInterface::Configure(const char* componentXML)
{
    CDPComponent::Configure(componentXML);
    FishTank1.ConnectTo("FishTankControlApp.FishTank1");
    FishTank2.ConnectTo("FishTankControlApp.FishTank2");
}

void GuiInterface::ProcessNull()
{
}

int GuiInterface::MessageForwardMessage(void* message)
{
    FishTank1.SendMessage(static_cast<MessageTextCommand*>(message)->textCommand);
    FishTank2.SendMessage(static_cast<MessageTextCommand*>(message)->textCommand);
    return 1;
}

© CDP Technologies AS - All rights reserved