mirror of
https://github.com/binary-kitchen/doorlockd
synced 2024-12-22 10:24:26 +01:00
Removed Door State from Logic
Signed-off-by: Ralf Ramsauer <ralf@ramses-pyramidenbau.de>
This commit is contained in:
parent
a17fb4930f
commit
e884dd87c4
@ -32,6 +32,11 @@ Door &Door::get()
|
||||
return d;
|
||||
}
|
||||
|
||||
const Door::State &Door::state() const
|
||||
{
|
||||
return _state;
|
||||
}
|
||||
|
||||
void Door::lock()
|
||||
{
|
||||
_l(LogLevel::notice, "Executing Pre Lock Script");
|
||||
|
@ -28,6 +28,9 @@ public:
|
||||
|
||||
enum class State {Locked, Unlocked};
|
||||
|
||||
// Current state of the door
|
||||
const State &state() const;
|
||||
|
||||
// Lock the door
|
||||
void lock();
|
||||
// Unlock the door
|
||||
|
@ -117,14 +117,13 @@ out:
|
||||
|
||||
Logic::Response Logic::_lock()
|
||||
{
|
||||
if (_state == Door::State::Locked)
|
||||
if (_door.state() == Door::State::Locked)
|
||||
{
|
||||
_logger(LogLevel::warning, "Unable to lock: already closed");
|
||||
return AlreadyLocked;
|
||||
}
|
||||
|
||||
_door.lock();
|
||||
_state = Door::State::Locked;
|
||||
_createNewToken(false);
|
||||
|
||||
return Success;
|
||||
@ -132,15 +131,14 @@ Logic::Response Logic::_lock()
|
||||
|
||||
Logic::Response Logic::_unlock()
|
||||
{
|
||||
const auto state = _door.state();
|
||||
_door.unlock();
|
||||
_createNewToken(false);
|
||||
|
||||
if (_state == Door::State::Unlocked)
|
||||
if (state == Door::State::Unlocked)
|
||||
{
|
||||
_logger(LogLevel::warning, "Unable to unlock: already unlocked");
|
||||
return AlreadyUnlocked;
|
||||
} else {
|
||||
_state = Door::State::Unlocked;
|
||||
}
|
||||
|
||||
return Success;
|
||||
|
@ -97,8 +97,6 @@ private:
|
||||
const std::string _bindDN;
|
||||
// Prefix of the website
|
||||
const std::string _webPrefix;
|
||||
|
||||
Door::State _state = { Door::State::Locked };
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user