-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[dmx] Refactor common behaviour across a base class
- Loading branch information
Showing
10 changed files
with
180 additions
and
247 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#include "dmx_protocol_base.hpp" | ||
|
||
#include <ossia/detail/fmt.hpp> | ||
#include <ossia/protocols/artnet/dmx_parameter.hpp> | ||
|
||
namespace ossia::net | ||
{ | ||
|
||
dmx_protocol_base::dmx_protocol_base( | ||
ossia::net::network_context_ptr ctx, const dmx_config& conf) | ||
: protocol_base{flags{}} | ||
, m_context{ctx} | ||
, m_timer{ctx->context} | ||
, m_conf{conf} | ||
{ | ||
} | ||
|
||
dmx_protocol_base::~dmx_protocol_base() { } | ||
bool dmx_protocol_base::pull(net::parameter_base& param) | ||
{ | ||
return true; | ||
} | ||
|
||
bool dmx_protocol_base::push(const net::parameter_base& param, const ossia::value& v) | ||
{ | ||
return true; | ||
} | ||
|
||
bool dmx_protocol_base::observe(net::parameter_base& param, bool enable) | ||
{ | ||
return false; | ||
} | ||
|
||
bool dmx_protocol_base::push_raw(const ossia::net::full_parameter_data& data) | ||
{ | ||
return false; | ||
} | ||
|
||
bool dmx_protocol_base::update(ossia::net::node_base&) | ||
{ | ||
return true; | ||
} | ||
|
||
void dmx_protocol_base::stop_processing() | ||
{ | ||
m_timer.stop(); | ||
} | ||
|
||
void dmx_protocol_base::set_device(ossia::net::device_base& dev) | ||
{ | ||
m_device = &dev; | ||
|
||
if(m_conf.autocreate != m_conf.no_auto) | ||
{ | ||
auto& root = dev.get_root_node(); | ||
for(unsigned int i = 0; i < DMX_CHANNEL_COUNT; ++i) | ||
{ | ||
auto name = m_conf.autocreate == m_conf.channel_index | ||
? fmt::format("Channel-{}", i + 1) | ||
: std::to_string(i + 1); | ||
|
||
device_parameter::create_device_parameter<dmx_parameter>( | ||
root, name, 0, m_buffer, i); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#pragma once | ||
#include <ossia/detail/config.hpp> | ||
|
||
#include <ossia/detail/timer.hpp> | ||
#include <ossia/network/base/protocol.hpp> | ||
#include <ossia/network/common/complex_type.hpp> | ||
#include <ossia/network/context.hpp> | ||
#include <ossia/network/domain/domain.hpp> | ||
#include <ossia/protocols/artnet/dmx_buffer.hpp> | ||
|
||
#include <array> | ||
#include <cstdint> | ||
|
||
namespace ossia::net | ||
{ | ||
struct dmx_config; | ||
class OSSIA_EXPORT dmx_protocol_base : public ossia::net::protocol_base | ||
{ | ||
public: | ||
dmx_protocol_base(ossia::net::network_context_ptr, const dmx_config& conf); | ||
~dmx_protocol_base(); | ||
|
||
void set_device(ossia::net::device_base& dev) override; | ||
|
||
bool pull(ossia::net::parameter_base& param) override; | ||
bool push(const ossia::net::parameter_base& param, const ossia::value& v) override; | ||
bool push_raw(const ossia::net::full_parameter_data&) override; | ||
bool observe(ossia::net::parameter_base& param, bool enable) override; | ||
|
||
bool update(ossia::net::node_base&) override; | ||
|
||
dmx_buffer& buffer() noexcept { return m_buffer; } | ||
void stop_processing(); | ||
|
||
protected: | ||
ossia::net::network_context_ptr m_context; | ||
|
||
ossia::timer m_timer; | ||
dmx_buffer m_buffer; | ||
|
||
ossia::net::device_base* m_device{}; | ||
dmx_config m_conf{}; | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.