add interface to allow for night mode control (#2)
This commit is contained in:
parent
5f8d5f4f6a
commit
464da85686
@ -33,7 +33,7 @@ namespace service
|
|||||||
class SensorService: public aasdk::channel::sensor::ISensorServiceChannelEventHandler, public IService, public std::enable_shared_from_this<SensorService>
|
class SensorService: public aasdk::channel::sensor::ISensorServiceChannelEventHandler, public IService, public std::enable_shared_from_this<SensorService>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SensorService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger);
|
SensorService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, bool nightMode = false);
|
||||||
|
|
||||||
void start() override;
|
void start() override;
|
||||||
void stop() override;
|
void stop() override;
|
||||||
@ -41,6 +41,7 @@ public:
|
|||||||
void onChannelOpenRequest(const aasdk::proto::messages::ChannelOpenRequest& request) override;
|
void onChannelOpenRequest(const aasdk::proto::messages::ChannelOpenRequest& request) override;
|
||||||
void onSensorStartRequest(const aasdk::proto::messages::SensorStartRequestMessage& request) override;
|
void onSensorStartRequest(const aasdk::proto::messages::SensorStartRequestMessage& request) override;
|
||||||
void onChannelError(const aasdk::error::Error& e) override;
|
void onChannelError(const aasdk::error::Error& e) override;
|
||||||
|
void setNightMode(bool nightMode);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
using std::enable_shared_from_this<SensorService>::shared_from_this;
|
using std::enable_shared_from_this<SensorService>::shared_from_this;
|
||||||
@ -49,6 +50,7 @@ private:
|
|||||||
|
|
||||||
boost::asio::io_service::strand strand_;
|
boost::asio::io_service::strand strand_;
|
||||||
aasdk::channel::sensor::SensorServiceChannel::Pointer channel_;
|
aasdk::channel::sensor::SensorServiceChannel::Pointer channel_;
|
||||||
|
bool nightMode_;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include <f1x/openauto/autoapp/Projection/InputDevice.hpp>
|
#include <f1x/openauto/autoapp/Projection/InputDevice.hpp>
|
||||||
#include <f1x/openauto/autoapp/Projection/OMXVideoOutput.hpp>
|
#include <f1x/openauto/autoapp/Projection/OMXVideoOutput.hpp>
|
||||||
#include <f1x/openauto/autoapp/Projection/QtVideoOutput.hpp>
|
#include <f1x/openauto/autoapp/Projection/QtVideoOutput.hpp>
|
||||||
|
#include <f1x/openauto/autoapp/Service/SensorService.hpp>
|
||||||
|
|
||||||
namespace f1x
|
namespace f1x
|
||||||
{
|
{
|
||||||
@ -36,10 +37,11 @@ namespace service
|
|||||||
class ServiceFactory: public IServiceFactory
|
class ServiceFactory: public IServiceFactory
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ServiceFactory(boost::asio::io_service& ioService, configuration::IConfiguration::Pointer configuration, QWidget* activeArea=nullptr, std::function<void(bool)> activeCallback=nullptr);
|
ServiceFactory(boost::asio::io_service& ioService, configuration::IConfiguration::Pointer configuration, QWidget* activeArea=nullptr, std::function<void(bool)> activeCallback=nullptr, bool nightMode = false);
|
||||||
ServiceList create(aasdk::messenger::IMessenger::Pointer messenger) override;
|
ServiceList create(aasdk::messenger::IMessenger::Pointer messenger) override;
|
||||||
void setOpacity(unsigned int alpha);
|
void setOpacity(unsigned int alpha);
|
||||||
void resize();
|
void resize();
|
||||||
|
void setNightMode(bool nightMode);
|
||||||
static QRect mapActiveAreaToGlobal(QWidget* activeArea);
|
static QRect mapActiveAreaToGlobal(QWidget* activeArea);
|
||||||
#ifdef USE_OMX
|
#ifdef USE_OMX
|
||||||
static projection::DestRect QRectToDestRect(QRect rect);
|
static projection::DestRect QRectToDestRect(QRect rect);
|
||||||
@ -62,6 +64,8 @@ private:
|
|||||||
#else
|
#else
|
||||||
projection::QtVideoOutput *qtVideoOutput_;
|
projection::QtVideoOutput *qtVideoOutput_;
|
||||||
#endif
|
#endif
|
||||||
|
bool nightMode_;
|
||||||
|
std::shared_ptr<SensorService> sensorService_;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -29,9 +29,10 @@ namespace autoapp
|
|||||||
namespace service
|
namespace service
|
||||||
{
|
{
|
||||||
|
|
||||||
SensorService::SensorService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger)
|
SensorService::SensorService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, bool nightMode)
|
||||||
: strand_(ioService)
|
: strand_(ioService)
|
||||||
, channel_(std::make_shared<aasdk::channel::sensor::SensorServiceChannel>(strand_, std::move(messenger)))
|
, channel_(std::make_shared<aasdk::channel::sensor::SensorServiceChannel>(strand_, std::move(messenger)))
|
||||||
|
, nightMode_(nightMode)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -121,7 +122,7 @@ void SensorService::sendDrivingStatusUnrestricted()
|
|||||||
void SensorService::sendNightData()
|
void SensorService::sendNightData()
|
||||||
{
|
{
|
||||||
aasdk::proto::messages::SensorEventIndication indication;
|
aasdk::proto::messages::SensorEventIndication indication;
|
||||||
indication.add_night_mode()->set_is_night(false);
|
indication.add_night_mode()->set_is_night(nightMode_);
|
||||||
|
|
||||||
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||||
promise->then([]() {}, std::bind(&SensorService::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
promise->then([]() {}, std::bind(&SensorService::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
||||||
@ -133,6 +134,12 @@ void SensorService::onChannelError(const aasdk::error::Error& e)
|
|||||||
OPENAUTO_LOG(error) << "[SensorService] channel error: " << e.what();
|
OPENAUTO_LOG(error) << "[SensorService] channel error: " << e.what();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SensorService::setNightMode(bool nightMode)
|
||||||
|
{
|
||||||
|
nightMode_ = nightMode;
|
||||||
|
this->sendNightData();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ namespace autoapp
|
|||||||
namespace service
|
namespace service
|
||||||
{
|
{
|
||||||
|
|
||||||
ServiceFactory::ServiceFactory(boost::asio::io_service& ioService, configuration::IConfiguration::Pointer configuration, QWidget *activeArea, std::function<void(bool)> activeCallback)
|
ServiceFactory::ServiceFactory(boost::asio::io_service& ioService, configuration::IConfiguration::Pointer configuration, QWidget *activeArea, std::function<void(bool)> activeCallback, bool nightMode)
|
||||||
: ioService_(ioService)
|
: ioService_(ioService)
|
||||||
, configuration_(std::move(configuration))
|
, configuration_(std::move(configuration))
|
||||||
, activeArea_(activeArea)
|
, activeArea_(activeArea)
|
||||||
@ -58,6 +58,7 @@ ServiceFactory::ServiceFactory(boost::asio::io_service& ioService, configuration
|
|||||||
#ifdef USE_OMX
|
#ifdef USE_OMX
|
||||||
, omxVideoOutput_(std::make_shared<projection::OMXVideoOutput>(configuration_, this->QRectToDestRect(screenGeometry_), activeCallback_))
|
, omxVideoOutput_(std::make_shared<projection::OMXVideoOutput>(configuration_, this->QRectToDestRect(screenGeometry_), activeCallback_))
|
||||||
#endif
|
#endif
|
||||||
|
, nightMode_(nightMode)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -69,7 +70,8 @@ ServiceList ServiceFactory::create(aasdk::messenger::IMessenger::Pointer messeng
|
|||||||
projection::IAudioInput::Pointer audioInput(new projection::QtAudioInput(1, 16, 16000), std::bind(&QObject::deleteLater, std::placeholders::_1));
|
projection::IAudioInput::Pointer audioInput(new projection::QtAudioInput(1, 16, 16000), std::bind(&QObject::deleteLater, std::placeholders::_1));
|
||||||
serviceList.emplace_back(std::make_shared<AudioInputService>(ioService_, messenger, std::move(audioInput)));
|
serviceList.emplace_back(std::make_shared<AudioInputService>(ioService_, messenger, std::move(audioInput)));
|
||||||
this->createAudioServices(serviceList, messenger);
|
this->createAudioServices(serviceList, messenger);
|
||||||
serviceList.emplace_back(std::make_shared<SensorService>(ioService_, messenger));
|
sensorService_ = std::make_shared<SensorService>(ioService_, messenger, nightMode_);
|
||||||
|
serviceList.emplace_back(sensorService_);
|
||||||
serviceList.emplace_back(this->createVideoService(messenger));
|
serviceList.emplace_back(this->createVideoService(messenger));
|
||||||
serviceList.emplace_back(this->createBluetoothService(messenger));
|
serviceList.emplace_back(this->createBluetoothService(messenger));
|
||||||
serviceList.emplace_back(this->createInputService(messenger));
|
serviceList.emplace_back(this->createInputService(messenger));
|
||||||
@ -182,6 +184,12 @@ void ServiceFactory::resize()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ServiceFactory::setNightMode(bool nightMode)
|
||||||
|
{
|
||||||
|
nightMode_ = nightMode;
|
||||||
|
if (sensorService_ != nullptr) sensorService_->setNightMode(nightMode_);
|
||||||
|
}
|
||||||
|
|
||||||
QRect ServiceFactory::mapActiveAreaToGlobal(QWidget* activeArea)
|
QRect ServiceFactory::mapActiveAreaToGlobal(QWidget* activeArea)
|
||||||
{
|
{
|
||||||
if (activeArea == nullptr)
|
if (activeArea == nullptr)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user