Blower.cpp
/** * (c)2017 CDP Technologies AS */ #include "Blower.h" using namespace TankControlLib; Blower::Blower() { } Blower::~Blower() { } void Blower::Create(const char* fullName) { CDPComponent:: Create(fullName); DelayTime.Create("DelayTime",this); FeedingActiveTank1.Create("FeedingActiveTank1",this); FeedingActiveTank2.Create("FeedingActiveTank2",this); BlowerActive.Create("BlowerActive",this); } void Blower::Destroy() { DelayTime.Destroy(); CDPComponent::Destroy(); } void Blower::CreateModel() { CDPComponent::CreateModel(); RegisterStateProcess("Null",(CDPCOMPONENT_STATEPROCESS)&Blower::ProcessNull,"Initial Null state"); RegisterStateProcess("Running",(CDPCOMPONENT_STATEPROCESS)&Blower::ProcessRunning,"Blower running"); RegisterStateProcess("Stop",(CDPCOMPONENT_STATEPROCESS)&Blower::ProcessStop,"Blower is turned off after a time delay"); RegisterStateTransitionHandler("Running","Stop",(CDPCOMPONENT_STATETRANSITIONHANDLER)&Blower::TransitionRunningToStop,""); RegisterStateTransitionHandler("Stop","Running",(CDPCOMPONENT_STATETRANSITIONHANDLER)&Blower::TransitionStopToRunning,""); RegisterStateTransitionHandler("Null","Stop",(CDPCOMPONENT_STATETRANSITIONHANDLER)&Blower::TransitionNullToStop,""); } void Blower::Configure(const char* componentXML) { CDPComponent::Configure(componentXML); } void Blower::ProcessNull() { } void Blower::ProcessRunning() { BlowerActive = true; if (FeedingActiveTank1 || FeedingActiveTank2) DelayTime.Restart(); else if(DelayTime.TimeElapsed() > 15.0) requestedState = "Stop"; } void Blower::ProcessStop() { BlowerActive = false; if (FeedingActiveTank1 || FeedingActiveTank2) requestedState = "Running"; } bool Blower::TransitionRunningToStop() { return requestedState=="Stop"; } bool Blower::TransitionStopToRunning() { return requestedState=="Running"; } bool Blower::TransitionNullToStop() { return true; }
Get started with CDP Studio today
Let us help you take your great ideas and turn them into the products your customer will love.