Simple Arduino FSM
Door.cpp
Go to the documentation of this file.
1 
11 #include "Door.h"
12 
13 //=====PUBLIC====================================================================================
14 Door::Door(int positionClosed, int positionOpen) : pPosClosed(positionClosed), pPosOpen(positionOpen) {
15  DBFUNCCALLln("Door::Door(int positionOpen, int positionClosed)");
16  init();
17 }
18 
22 bool Door::open() {
23  DBFUNCCALLln("Door::open()");
24  if (pActualPos < pPosOpen) {
25  pActualPos += 1;
26  }
27  DBINFO3ln(String("DoorPosition: ") + String(pActualPos));
28  if (pActualPos == pPosOpen) {
29  return true;
30  }
31  return false;
32 }
33 
34 bool Door::close() {
35  DBFUNCCALLln("Door::close()");
36  if (pActualPos > pPosClosed) {
37  pActualPos -= 1;
38  }
39  DBINFO3ln(String("DoorPosition: ") + String(pActualPos));
40  if (pActualPos == pPosClosed) {
41  return true;
42  }
43  return false;
44 }
45 
46 //=====PRIVATE====================================================================================
47 void Door::init() {
48  while (!open()) {
49  };
50 }
int pActualPos
Initial door position somwhere between.
Definition: Door.h:55
void init()
Initialisen the Door in closed Position.
Definition: Door.cpp:47
bool close()
Closes the Door one Step per Function-Call.
Definition: Door.cpp:34
#define DBINFO3ln(x)
const int pPosOpen
Position of the open door.
Definition: Door.h:54
bool open()
Opens the Door one Step per Function-Call.
Definition: Door.cpp:22
#define DBFUNCCALLln(x)
Door(int positionClosed, int positionOpen)
Construct a new Door object.
Definition: Door.cpp:14
const int pPosClosed
Position of the closed door.
Definition: Door.h:53
Implementation of the Door-Class.