71 lines
2.3 KiB
C++
71 lines
2.3 KiB
C++
/*
|
|
controller.h
|
|
|
|
Copyright (c) 2022 Kevin Matz (kevin.matz@gmail.com)
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
in the Software without restriction, including without limitation the rights
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
The above copyright notice and this permission notice shall be included in all
|
|
copies or substantial portions of the Software.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
SOFTWARE.
|
|
*/
|
|
#pragma once
|
|
|
|
#include "device.h"
|
|
#include "gateway.h"
|
|
#include <atomic>
|
|
#include <condition_variable>
|
|
#include <shared_mutex>
|
|
#include <thread>
|
|
|
|
namespace ARTNET {
|
|
|
|
/**
|
|
* @brief \cite ARTNET A generic term describing an Art-Net device with the
|
|
* primary task of generating control data.
|
|
*
|
|
* \cite ARTNET Controllers emulate the operation of Input Gateways.
|
|
*/
|
|
class Controller
|
|
: public Device
|
|
, public InputGateway
|
|
{
|
|
public:
|
|
explicit Controller();
|
|
virtual ~Controller();
|
|
|
|
void setTalkToMeRequest(TalkToMe);
|
|
void setPriorityRequest(Priority);
|
|
|
|
protected:
|
|
virtual void txArtPoll();
|
|
|
|
private:
|
|
const std::chrono::milliseconds minimum_polling_interval;
|
|
mutable std::shared_mutex _mtx_poll_control;
|
|
mutable std::mutex _mtx_poll_thread;
|
|
std::atomic<bool> _periodic_polling_enabled;
|
|
std::condition_variable_any _poll_request;
|
|
std::thread _pollster;
|
|
void _periodic_polling();
|
|
|
|
mutable std::shared_mutex _mtx_control_data;
|
|
std::chrono::system_clock::time_point last_poll;
|
|
TalkToMe _talktome_request; //!< TalkToMe to be uses in the ArtPoll
|
|
Priority _priority_request; //!< Priority to be used in the ArtPoll
|
|
};
|
|
|
|
} // namespace ARTNET
|