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;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Door::State &Door::state() const
|
||||||
|
{
|
||||||
|
return _state;
|
||||||
|
}
|
||||||
|
|
||||||
void Door::lock()
|
void Door::lock()
|
||||||
{
|
{
|
||||||
_l(LogLevel::notice, "Executing Pre Lock Script");
|
_l(LogLevel::notice, "Executing Pre Lock Script");
|
||||||
|
@ -28,6 +28,9 @@ public:
|
|||||||
|
|
||||||
enum class State {Locked, Unlocked};
|
enum class State {Locked, Unlocked};
|
||||||
|
|
||||||
|
// Current state of the door
|
||||||
|
const State &state() const;
|
||||||
|
|
||||||
// Lock the door
|
// Lock the door
|
||||||
void lock();
|
void lock();
|
||||||
// Unlock the door
|
// Unlock the door
|
||||||
|
@ -117,14 +117,13 @@ out:
|
|||||||
|
|
||||||
Logic::Response Logic::_lock()
|
Logic::Response Logic::_lock()
|
||||||
{
|
{
|
||||||
if (_state == Door::State::Locked)
|
if (_door.state() == Door::State::Locked)
|
||||||
{
|
{
|
||||||
_logger(LogLevel::warning, "Unable to lock: already closed");
|
_logger(LogLevel::warning, "Unable to lock: already closed");
|
||||||
return AlreadyLocked;
|
return AlreadyLocked;
|
||||||
}
|
}
|
||||||
|
|
||||||
_door.lock();
|
_door.lock();
|
||||||
_state = Door::State::Locked;
|
|
||||||
_createNewToken(false);
|
_createNewToken(false);
|
||||||
|
|
||||||
return Success;
|
return Success;
|
||||||
@ -132,18 +131,17 @@ Logic::Response Logic::_lock()
|
|||||||
|
|
||||||
Logic::Response Logic::_unlock()
|
Logic::Response Logic::_unlock()
|
||||||
{
|
{
|
||||||
_door.unlock();
|
const auto state = _door.state();
|
||||||
_createNewToken(false);
|
_door.unlock();
|
||||||
|
_createNewToken(false);
|
||||||
|
|
||||||
if (_state == Door::State::Unlocked)
|
if (state == Door::State::Unlocked)
|
||||||
{
|
{
|
||||||
_logger(LogLevel::warning, "Unable to unlock: already unlocked");
|
_logger(LogLevel::warning, "Unable to unlock: already unlocked");
|
||||||
return AlreadyUnlocked;
|
return AlreadyUnlocked;
|
||||||
} else {
|
}
|
||||||
_state = Door::State::Unlocked;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Success;
|
return Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Logic::_checkToken(const string &strToken)
|
bool Logic::_checkToken(const string &strToken)
|
||||||
|
@ -97,8 +97,6 @@ private:
|
|||||||
const std::string _bindDN;
|
const std::string _bindDN;
|
||||||
// Prefix of the website
|
// Prefix of the website
|
||||||
const std::string _webPrefix;
|
const std::string _webPrefix;
|
||||||
|
|
||||||
Door::State _state = { Door::State::Locked };
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user