Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ Changelog {#changelog}

* [202](https://github.com/BlueBrain/Tide/pull/202):
Fixed incorrect count of open windows reported at tide/stats HTTP endpoint.
* [201](https://github.com/BlueBrain/Tide/pull/201):
The interface unlocks when the screens are turned off.
* [200](https://github.com/BlueBrain/Tide/pull/200):
Xml configuration simplification:
- replaced screenWidth/Height with displayWidht/Height, which refers
Expand Down
4 changes: 2 additions & 2 deletions tide/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,14 @@ list(APPEND TIDECORE_PUBLIC_HEADERS
CommandLineParameters.h
CommandLineParser.h
Configuration.h
CountdownStatus.h
data/Image.h
data/QtImage.h
data/SVG.h
data/SVGBackend.h
data/SVGQtGpuBackend.h
data/YUVImage.h
geometry.h
InactivityTimer.h
log.h
network/LocalBarrier.h
network/MPIChannel.h
Expand Down Expand Up @@ -177,12 +177,12 @@ list(APPEND TIDECORE_SOURCES
CommandLineParameters.cpp
CommandLineParser.cpp
Configuration.cpp
CountdownStatus.cpp
data/QtImage.cpp
data/SVG.cpp
data/SVGQtGpuBackend.cpp
data/YUVImage.cpp
geometry.cpp
InactivityTimer.cpp
log.cpp
MetaTypeRegistration.cpp
network/LocalBarrier.cpp
Expand Down
56 changes: 56 additions & 0 deletions tide/core/CountdownStatus.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*********************************************************************/
/* Copyright (c) 2017, EPFL/Blue Brain Project */
/* Raphael Dumusc <raphael.dumusc@epfl.ch> */
/* All rights reserved. */
/* */
/* Redistribution and use in source and binary forms, with or */
/* without modification, are permitted provided that the following */
/* conditions are met: */
/* */
/* 1. Redistributions of source code must retain the above */
/* copyright notice, this list of conditions and the following */
/* disclaimer. */
/* */
/* 2. Redistributions in binary form must reproduce the above */
/* copyright notice, this list of conditions and the following */
/* disclaimer in the documentation and/or other materials */
/* provided with the distribution. */
/* */
/* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY OF TEXAS AT */
/* AUSTIN ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, */
/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */
/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
/* DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OF TEXAS AT */
/* AUSTIN OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
/* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */
/* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE */
/* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR */
/* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF */
/* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */
/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
/* POSSIBILITY OF SUCH DAMAGE. */
/* */
/* The views and conclusions contained in the software and */
/* documentation are those of the authors and should not be */
/* interpreted as representing official policies, either expressed */
/* or implied, of Ecole polytechnique federale de Lausanne. */
/*********************************************************************/

#include "CountdownStatus.h"

CountdownStatus::CountdownStatus(const bool active, const uint duration)
: _active{active}
, _duration{duration}
{
}

bool CountdownStatus::isActive() const
{
return _active;
}

uint CountdownStatus::getDuration() const
{
return _duration;
}
87 changes: 87 additions & 0 deletions tide/core/CountdownStatus.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/*********************************************************************/
/* Copyright (c) 2017, EPFL/Blue Brain Project */
/* Raphael Dumusc <raphael.dumusc@epfl.ch> */
/* All rights reserved. */
/* */
/* Redistribution and use in source and binary forms, with or */
/* without modification, are permitted provided that the following */
/* conditions are met: */
/* */
/* 1. Redistributions of source code must retain the above */
/* copyright notice, this list of conditions and the following */
/* disclaimer. */
/* */
/* 2. Redistributions in binary form must reproduce the above */
/* copyright notice, this list of conditions and the following */
/* disclaimer in the documentation and/or other materials */
/* provided with the distribution. */
/* */
/* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY OF TEXAS AT */
/* AUSTIN ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, */
/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */
/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
/* DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OF TEXAS AT */
/* AUSTIN OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
/* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */
/* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE */
/* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR */
/* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF */
/* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */
/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
/* POSSIBILITY OF SUCH DAMAGE. */
/* */
/* The views and conclusions contained in the software and */
/* documentation are those of the authors and should not be */
/* interpreted as representing official policies, either expressed */
/* or implied, of Ecole polytechnique federale de Lausanne. */
/*********************************************************************/

#ifndef COUNTDOWN_STATUS_H
#define COUNTDOWN_STATUS_H

#include "serialization/includes.h"

#include <QObject>

/**
* The status of the inactivity countdown, to be displayed on the wall.
*/
class CountdownStatus : public QObject
{
Q_OBJECT
Q_DISABLE_COPY(CountdownStatus)

Q_PROPERTY(bool active READ isActive)
Q_PROPERTY(uint duration READ getDuration)

public:
/** Default constructor for use on wall processes. */
CountdownStatus() = default;

/** Constructor. */
CountdownStatus(bool active, uint duration);

/** Check if countdown timer is active. */
bool isActive() const;

/** Get the duration of the countdown for transition in qml. */
uint getDuration() const;

private:
friend class boost::serialization::access;

template <class Archive>
void serialize(Archive& ar, const unsigned int)
{
// clang-format off
ar & _active;
ar & _duration;
// clang-format on
}

bool _active = false;
uint _duration = 0u;
};

#endif
2 changes: 1 addition & 1 deletion tide/core/MetaTypeRegistration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ struct MetaTypeRegistration
"ContentWindow::WindowState");
qRegisterMetaType<ContentSynchronizerSharedPtr>(
"ContentSynchronizerSharedPtr");
qRegisterMetaType<CountdownStatusPtr>("CountdownStatusPtr");
qRegisterMetaType<DisplayGroupPtr>("DisplayGroupPtr");
qRegisterMetaType<DisplayGroupConstPtr>("DisplayGroupConstPtr");
qRegisterMetaType<ImagePtr>("ImagePtr");
Expand All @@ -72,7 +73,6 @@ struct MetaTypeRegistration
qRegisterMetaType<TilePtr>("TilePtr");
qRegisterMetaType<TileWeakPtr>("TileWeakPtr");
qRegisterMetaTypeStreamOperators<QUuid>("QUuid");
qRegisterMetaType<InactivityTimerPtr>("InactivityTimerPtr");
}
};

Expand Down
2 changes: 1 addition & 1 deletion tide/core/network/MPIHeader.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ enum class MPIMessageType
TIMESTAMP,
START_PROCESS,
IMAGE,
TIMER,
COUNTDOWN_STATUS,
PIXELSTREAM_CLOSE,
LOCK
};
Expand Down
3 changes: 2 additions & 1 deletion tide/core/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ class Configuration;
class Content;
class ContentSynchronizer;
class ContentWindow;
class CountdownStatus;
class DataProvider;
class DataSource;
class DisplayGroup;
Expand Down Expand Up @@ -145,10 +146,10 @@ class WebbrowserContent;
typedef boost::shared_ptr<Content> ContentPtr;
typedef std::shared_ptr<ContentSynchronizer> ContentSynchronizerSharedPtr;
typedef boost::shared_ptr<ContentWindow> ContentWindowPtr;
typedef boost::shared_ptr<CountdownStatus> CountdownStatusPtr;
typedef boost::shared_ptr<DisplayGroup> DisplayGroupPtr;
typedef boost::shared_ptr<const DisplayGroup> DisplayGroupConstPtr;
typedef std::shared_ptr<Image> ImagePtr;
typedef boost::shared_ptr<InactivityTimer> InactivityTimerPtr;
typedef std::shared_ptr<FFMPEGPicture> PicturePtr;
typedef boost::shared_ptr<Markers> MarkersPtr;
typedef boost::shared_ptr<MPIChannel> MPIChannelPtr;
Expand Down
2 changes: 2 additions & 0 deletions tide/master/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ list(APPEND TIDEMASTER_PUBLIC_HEADERS
control/PixelStreamController.h
control/ZoomController.h
FileInfoHelper.h
InactivityTimer.h
localstreamer/HtmlSelectReplacer.h
localstreamer/CommandLineOptions.h
localstreamer/PixelStreamerLauncher.h
Expand Down Expand Up @@ -71,6 +72,7 @@ list(APPEND TIDEMASTER_SOURCES
control/LayoutPolicy.cpp
control/PixelStreamController.cpp
control/ZoomController.cpp
InactivityTimer.cpp
localstreamer/HtmlSelectReplacer.cpp
localstreamer/CommandLineOptions.cpp
localstreamer/PixelStreamerLauncher.cpp
Expand Down
72 changes: 31 additions & 41 deletions tide/core/InactivityTimer.cpp → tide/master/InactivityTimer.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*********************************************************************/
/* Copyright (c) 2017, EPFL/Blue Brain Project */
/* Pawel Podhajski <pawel.podhajski@epfl.ch> */
/* Raphael Dumusc <raphael.dumusc@epfl.ch> */
/* All rights reserved. */
/* */
/* Redistribution and use in source and binary forms, with or */
Expand Down Expand Up @@ -39,73 +40,62 @@

#include "InactivityTimer.h"

#include "CountdownStatus.h"
#include "log.h"

namespace
{
const int COUNTDOWNTIMER = 15000; // ms
const auto COUNTDOWNTIMER_MS = 15000;
const auto MS_PER_MIN = 60000;
}

InactivityTimer::InactivityTimer()
InactivityTimer::InactivityTimer(const uint timeoutInMinutes)
{
}
_inactivityTimer.setInterval(timeoutInMinutes * MS_PER_MIN);
_inactivityTimer.setSingleShot(true);
_inactivityTimer.start();

InactivityTimer::InactivityTimer(const int timeout)
: _timeout(timeout * 60000) // from ms to minute
, _countDownTimer(new QTimer())
, _inactivityTimer(new QTimer())
{
_inactivityTimer->setInterval(_timeout);
_inactivityTimer->setSingleShot(true);
_inactivityTimer->start();
_countDownTimer->setSingleShot(true);
_countDownTimer->setInterval(COUNTDOWNTIMER);
_countdownTimer.setInterval(COUNTDOWNTIMER_MS);
_countdownTimer.setSingleShot(true);

connect(_inactivityTimer.get(), &QTimer::timeout, [this]() {
if (!_countDownTimer->isActive())
connect(&_inactivityTimer, &QTimer::timeout, [this]() {
if (!_countdownTimer.isActive())
{
_countdownActive = true;
_countDownTimer->start();
emit updated(shared_from_this());
_countdownTimer.start();
_sendCountdownStatus();
}
});
connect(_countDownTimer.get(), &QTimer::timeout, [this]() {
connect(&_countdownTimer, &QTimer::timeout, [this]() {
emit poweroff();
_countdownActive = false;
emit updated(shared_from_this());
_sendCountdownStatus();
});
}

int InactivityTimer::getCountdownTimeout()
{
return COUNTDOWNTIMER;
}

bool InactivityTimer::isCountdownActive()
{
return _countdownActive;
}

void InactivityTimer::stop()
{
_inactivityTimer->stop();
if (_countdownActive)
_inactivityTimer.stop();
if (_countdownTimer.isActive())
{
_countdownActive = false;
_countDownTimer->stop();
emit updated(shared_from_this());
_countdownTimer.stop();
_sendCountdownStatus();
}
}

void InactivityTimer::restart()
{
_inactivityTimer->start();
if (_countdownActive)
_inactivityTimer.start();
if (_countdownTimer.isActive())
{
print_log(LOG_INFO, LOG_POWER,
"Prevented powering off the screens during countdown");
_countDownTimer->stop();
_countdownActive = false;
emit updated(shared_from_this());
_countdownTimer.stop();
_sendCountdownStatus();
}
}

void InactivityTimer::_sendCountdownStatus()
{
emit countdownUpdated(
boost::make_shared<CountdownStatus>(_countdownTimer.isActive(),
(uint)_countdownTimer.interval()));
}
Loading