Event.cpp 1.03 KB
Newer Older
Ulrich Kemloh's avatar
Ulrich Kemloh committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/*
 * Event.cpp
 *
 *  Created on: Jul 21, 2015
 *      Author: piccolo
 */

#include "Event.h"

Event::Event(int id, double time, const std::string& type,
          const std::string& state)
{
     _id=id;
     _time=time;
     _type=type;
16
     _state= StringToDoorState(state);
Ulrich Kemloh's avatar
Ulrich Kemloh committed
17 18 19 20 21 22 23 24 25 26 27
}

Event::~Event()
{
}

int Event::GetId() const
{
     return _id;
}

Ozaq's avatar
Ozaq committed
28
const DoorState& Event::GetState() const
Ulrich Kemloh's avatar
Ulrich Kemloh committed
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
{
     return _state;
}

double Event::GetTime() const
{
     return _time;
}

const std::string& Event::GetType() const
{
     return _type;
}

const std::string Event::GetDescription() const
{
     char tmp[1024];
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
     std::string state;
     switch (_state){
     case DoorState::OPEN:
          state = "open";
          break;
     case DoorState::CLOSE:
          state = "close";
          break;
     case DoorState::TEMP_CLOSE:
          state = "temp_close";
          break;
     default:
          state = "error";
          break;
     }
     sprintf(tmp,"After %.2f sec, %s door %d", _time, state.c_str(), _id);
Ulrich Kemloh's avatar
Ulrich Kemloh committed
62 63
     return std::string(tmp);
}