parent
4594792f77
commit
39634860b2
@ -1,15 +0,0 @@
|
||||
#ifndef _HEATER_HPP_
|
||||
#define _HEATER_HPP_
|
||||
|
||||
class Heater
|
||||
{
|
||||
public:
|
||||
Heater();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // _HEATER_HPP_
|
@ -1 +0,0 @@
|
||||
#include "heaterCtrl.hpp"
|
@ -1,21 +0,0 @@
|
||||
#ifndef _HEATERCTRL_HPP_
|
||||
#define _HEATERCTRL_HPP_
|
||||
|
||||
class HeaterController
|
||||
{
|
||||
public:
|
||||
|
||||
enum Event{
|
||||
|
||||
};
|
||||
|
||||
HeaterController();
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // _HEATERCTRL_HPP_
|
@ -0,0 +1,46 @@
|
||||
#include "oven.hpp"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
Oven::Oven()
|
||||
{
|
||||
turnEverythingOff();
|
||||
}
|
||||
|
||||
|
||||
void Oven::setHeaterDutyCycle()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Oven::turnOnHeater()
|
||||
{
|
||||
std::cout << "Oven::turnOnHeateri()" << std::endl;
|
||||
}
|
||||
|
||||
void Oven::turnOffHeater()
|
||||
{
|
||||
std::cout << "Oven::turnOffHeater()" << std::endl;
|
||||
}
|
||||
|
||||
float Oven::getTemperature_C()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Oven::turnOnAirCirculation()
|
||||
{
|
||||
std::cout << "Oven::turnOnAirCirculation()" << std::endl;
|
||||
}
|
||||
|
||||
void Oven::turnOffAirCirculation()
|
||||
{
|
||||
std::cout << "Oven::turnOnffAirCirculation()" << std::endl;
|
||||
}
|
||||
|
||||
void Oven::turnEverythingOff()
|
||||
{
|
||||
turnOffHeater();
|
||||
turnOffAirCirculation();
|
||||
}
|
||||
|
@ -0,0 +1,19 @@
|
||||
#include "ovenCtrl.hpp"
|
||||
|
||||
OvenControll::OvenControll() :
|
||||
entity(),
|
||||
pState(OvenState::init(entity))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void OvenControll::process(Event e)
|
||||
{
|
||||
pState = pState->handle(entity, e);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,48 @@
|
||||
#ifndef _OVENSTATE_HPP_
|
||||
#define _OVENSTATE_HPP_
|
||||
|
||||
#include "oven.hpp"
|
||||
#include "ovenCtrl.hpp"
|
||||
|
||||
class OvenState
|
||||
{
|
||||
public:
|
||||
static OvenState* init(Oven& entity);
|
||||
|
||||
virtual handle(Oven& entity,
|
||||
OvenController::Event e) = 0;
|
||||
|
||||
protected:
|
||||
virtual void entryAction(Oven& Entity);
|
||||
virtual void exitAction(Oven& Entity);
|
||||
|
||||
typedef void (Oven::State::*Action)(Oven& entity);
|
||||
|
||||
OvenState* changeState(Oven& entity,
|
||||
Action pTransitAction,
|
||||
OvenState* pNewState);
|
||||
|
||||
// transition Actions
|
||||
|
||||
void emptyAction() {};
|
||||
};
|
||||
|
||||
|
||||
class IdleState : public OvenState
|
||||
{
|
||||
public:
|
||||
static IdleState* getInstatnce():
|
||||
virtual OvenState* handle(Oven& entity,
|
||||
OvenControll::Event e);
|
||||
|
||||
protected:
|
||||
virtual void entryAction(Oven& entity);
|
||||
virtual void exitAction(Oven& entity);
|
||||
private:
|
||||
IdleState() {};
|
||||
static IdleState instance;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // _OVENSTATE_HPP_
|
Loading…
Reference in new issue