E2PRO2 / Mbed OS e2pro2-rfid-house

room.hpp

Committer:
janusboandersen
Date:
2019-05-03
Revision:
14:0480ed7efd7f
Parent:
13:af3d7d8d77fc

File content as of revision 14:0480ed7efd7f:

////////////////////////////////////////////////////////////////////////////////
//  Source File :  Room.cpp
//  Author      :  Daniel K. Vinther Wolf
//  Date        :  02 may 2019
//  Version     :  0.1
//
//  Description :  Rooms, Class Definition
///////////////////////////////////////80///////////////////////////////////////

// Standard IO lib (cin,cout,cerr,clog,wcout)
#include <iostream>

class Room {
public:
    bool RoomCall(unsigned KeyID) {

        Action = Whereabout(KeyID);

        if (Action == 1) {
            cout << "Let there be light!" << "\r\n";
            return 1; // Sender tÊnd-signal
        } else {
            cout << "Checkin out.." << "\r\n";
            return 0; // Sender sluk-signal
        }
    }

private:
    unsigned KeyReg[8], i;
    bool Action;
    bool Whereabout(unsigned KeyID) {

        for(i = 0; i < 8; i++) {
            if(KeyID == KeyReg[i]) {
                KeyReg[i] = 0;
                return 0; // Return 0 for going out of Room
            }
        }
        for(i = 0; i < 8; i++) {
            if(KeyReg[i] != 0)
            continue;
            KeyReg[i] = KeyID;
            break;
        }
        return 1; // Return 1 for going into Room
    }

}; // End Room (Class)