2021-05-27 10:59:22 -04:00
|
|
|
/*
|
|
|
|
universe.h
|
|
|
|
|
|
|
|
Copyright (c) 2020 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
|
|
|
|
|
2021-08-28 14:47:30 -04:00
|
|
|
#include "data.h"
|
2022-12-08 17:50:29 -05:00
|
|
|
#include "dmp/component.h"
|
2022-11-28 15:57:52 -05:00
|
|
|
#include "../dmx/universe.h"
|
2022-11-28 15:06:48 -05:00
|
|
|
#include "sacn.h"
|
2022-12-12 13:39:10 -05:00
|
|
|
#include "universearbitrator.h"
|
2022-12-08 19:09:39 -05:00
|
|
|
#include "universesender.h"
|
2021-08-15 23:36:29 -04:00
|
|
|
|
2021-08-24 18:10:20 -04:00
|
|
|
#include <cstdint>
|
|
|
|
#include <vector>
|
2021-05-27 10:59:22 -04:00
|
|
|
|
2021-08-28 09:01:33 -04:00
|
|
|
namespace sACN {
|
|
|
|
|
2022-12-12 13:39:10 -05:00
|
|
|
class Receiver;
|
|
|
|
class Source;
|
|
|
|
|
|
|
|
|
2021-05-27 10:59:22 -04:00
|
|
|
/**
|
2021-08-28 09:01:33 -04:00
|
|
|
* @brief \cite sACN 3.2 Universe
|
|
|
|
*
|
2021-08-28 12:54:26 -04:00
|
|
|
* > A set of up to 512 data slots identified by universe number.
|
|
|
|
* > Note: In E1.31 there may be multiple sources for a universe. See also: Slot.
|
2021-08-02 10:09:14 -04:00
|
|
|
*/
|
2021-05-27 10:59:22 -04:00
|
|
|
class Universe
|
2021-08-24 18:10:20 -04:00
|
|
|
: public DMX::Universe
|
2022-12-08 17:50:29 -05:00
|
|
|
, public ACN::DMP::Component
|
2021-09-10 12:00:50 -04:00
|
|
|
, public std::enable_shared_from_this<Universe>
|
2021-05-27 10:59:22 -04:00
|
|
|
{
|
|
|
|
public:
|
2022-12-12 13:39:10 -05:00
|
|
|
explicit Universe(Source* = nullptr, Receiver* = nullptr);
|
2022-12-10 11:07:13 -05:00
|
|
|
virtual ~Universe();
|
2021-08-02 10:09:14 -04:00
|
|
|
|
2022-12-12 13:39:10 -05:00
|
|
|
/// Merging and Arbitration capabilities of the unverse
|
|
|
|
/// are implimented in the helper class sACN::UniverseSender
|
|
|
|
friend class UniverseArbitrator;
|
2022-12-12 11:31:29 -05:00
|
|
|
/// The Tx capabilities of the universe are impimented
|
|
|
|
/// in the helper class sACN::UniverseSender.
|
2022-12-08 19:09:39 -05:00
|
|
|
friend class UniverseSender;
|
|
|
|
|
2022-12-12 13:39:10 -05:00
|
|
|
// DMX::Universe overrides
|
|
|
|
virtual long age() const override;
|
|
|
|
virtual double rxRate() override;
|
|
|
|
virtual uint8_t status() const override;
|
|
|
|
virtual uint8_t slot(const uint16_t) const override;
|
|
|
|
|
|
|
|
virtual void setStatus(uint8_t) override;
|
|
|
|
virtual void setValue (const uint16_t start, const uint16_t footprint,
|
|
|
|
const uint8_t* data) override;
|
|
|
|
|
|
|
|
// metadata
|
2022-12-10 11:12:44 -05:00
|
|
|
virtual std::shared_ptr<DATA::data_header> metadata() const;
|
2022-12-08 17:47:37 -05:00
|
|
|
virtual void setMetadata(std::shared_ptr<DATA::data_header>);
|
2021-05-27 10:59:22 -04:00
|
|
|
|
2022-12-12 13:39:10 -05:00
|
|
|
// synchronization
|
2022-12-10 11:12:44 -05:00
|
|
|
virtual bool isSyncronized() const;
|
2021-08-29 01:12:11 -04:00
|
|
|
virtual void synchronize(uint8_t = 0);
|
2022-12-08 18:02:43 -05:00
|
|
|
virtual void resetSynchronization();
|
|
|
|
virtual void setSyncData(const std::vector<uint8_t> &);
|
2021-08-06 12:36:04 -04:00
|
|
|
|
2021-09-10 12:00:50 -04:00
|
|
|
|
2022-12-12 13:39:10 -05:00
|
|
|
virtual bool isEditable() const;
|
2022-12-10 11:12:44 -05:00
|
|
|
virtual uint16_t activeSlots() const;
|
2022-12-12 13:39:10 -05:00
|
|
|
virtual bool hasSources() const;
|
2021-09-10 12:00:50 -04:00
|
|
|
virtual const std::vector<DATA::data_header> sources() const;
|
2022-12-12 13:39:10 -05:00
|
|
|
UniverseArbitrator* arbitrator() const;
|
2022-11-21 17:41:28 -05:00
|
|
|
|
2021-08-30 10:00:54 -04:00
|
|
|
/**
|
|
|
|
* @brief destination IP address
|
|
|
|
*
|
|
|
|
* Setting type to ACN::SDT::SDT_ADDR_NULL will send on the multicast group.
|
|
|
|
*/
|
|
|
|
ipAddress destination;
|
|
|
|
|
2022-11-21 12:41:59 -05:00
|
|
|
/**
|
2022-11-30 09:54:01 -05:00
|
|
|
* @brief Extend DMX::Universe::Status with the additional states of sACN.
|
2022-11-21 12:41:59 -05:00
|
|
|
*/
|
|
|
|
enum Status : uint8_t {
|
|
|
|
DMX_NULL = DMX::Universe::DMX_NULL, //!< uninitialized
|
|
|
|
DMX_ACTIVE = DMX::Universe::DMX_ACTIVE, //!< actively sending/receiving data
|
|
|
|
DMX_LOST = DMX::Universe::DMX_LOST, //!< no activity in E111_DATA_LOSS_TIMEOUT
|
2022-11-21 14:37:02 -05:00
|
|
|
sACN_TERMINATED = 11, //!< stream has been terminated or no activity in E131_NETWORK_DATA_LOSS_TIMEOUT
|
2022-12-02 13:04:06 -05:00
|
|
|
RX_TIMEOUT = DMX::Universe::RX_TIMEOUT //!< no activity in the constructed timeout period
|
2022-11-21 12:41:59 -05:00
|
|
|
};
|
|
|
|
|
2021-09-03 17:43:50 -04:00
|
|
|
protected:
|
2022-12-08 18:05:33 -05:00
|
|
|
// ACN::DMP::Component overrides
|
|
|
|
virtual void rxDmpGetProperty(ACN::PDU::Message<ACN::DMP::Pdu>) override;
|
|
|
|
virtual void rxDmpSetProperty(ACN::PDU::Message<ACN::DMP::Pdu>) override;
|
|
|
|
virtual void rxDmpSubscribe(ACN::PDU::Message<ACN::DMP::Pdu>) override;
|
2021-08-31 10:27:30 -04:00
|
|
|
|
2022-11-23 14:28:27 -05:00
|
|
|
private:
|
2022-12-12 13:39:10 -05:00
|
|
|
UniverseArbitrator * arbitrator_;
|
2022-12-09 15:16:03 -05:00
|
|
|
UniverseSender * sender_;
|
2022-12-08 10:12:25 -05:00
|
|
|
std::shared_ptr<DATA::data_header> metadata_;
|
2022-12-10 11:12:44 -05:00
|
|
|
std::vector<uint8_t> * sync_data_;
|
2022-11-23 14:28:27 -05:00
|
|
|
|
|
|
|
/**
|
2022-11-30 09:54:01 -05:00
|
|
|
* @brief \cite sACN 3.7 Active Data Slots
|
|
|
|
*
|
|
|
|
* > When translating ANSI E1.11 DMX512-A \cite DMX to E1.31, the active data
|
|
|
|
* > slots are defined as ranging from data slot 1 to the maximum data slot in
|
|
|
|
* > the most recently received packet with the corresponding START Code.
|
|
|
|
* >
|
|
|
|
* > Devices originating E1.31 shall define their active data slots using
|
|
|
|
* > the DMP First Property Address and DMP Property Count fields shown in
|
|
|
|
* > Table 4-1.
|
|
|
|
*/
|
2022-11-23 14:28:27 -05:00
|
|
|
uint16_t active_data_slots_;
|
2021-09-01 12:41:15 -04:00
|
|
|
|
2022-11-30 09:54:01 -05:00
|
|
|
/**
|
|
|
|
* > \cite sACN 6.3.2 E1.31 Synchronization Packet: Sequence Number
|
|
|
|
* >
|
|
|
|
* > Sources shall maintain a sequence for each universe they transmit.
|
|
|
|
* > The sequence number for a universe shall be incremented by one for
|
|
|
|
* > every packet sent on that universe. There is no implied relationship
|
|
|
|
* > between the sequence number of an E1.31 Synchronization Packet and
|
|
|
|
* > the sequence number of an E1.31 Data Packet on that same universe.
|
|
|
|
*/
|
2022-11-23 14:27:40 -05:00
|
|
|
uint8_t sync_sequence_;
|
2021-05-27 10:59:22 -04:00
|
|
|
};
|
|
|
|
|
2021-08-02 10:09:14 -04:00
|
|
|
} // SACN namespace
|