40#include <boost/lockfree/spsc_value.hpp>
81 std::ignore = port_number;
97 std::ignore = ptp_stats;
108 boost::lockfree::spsc_value<LocalClock> local_clock_buffer_;
117 explicit Instance(boost::asio::io_context& io_context);
154 [[nodiscard]] tl::expected<void, Error>
add_port(uint16_t port_number,
const boost::asio::ip::address_v4& interface_address);
163 [[nodiscard]] tl::expected<void, Error>
add_or_update_port(uint16_t port_number,
const boost::asio::ip::address_v4& interface_address);
171 [[nodiscard]] tl::expected<void, Error>
update_ports(
const std::vector<ip_address_v4>& ports);
177 [[nodiscard]]
bool has_port(uint16_t port_number)
const;
198 [[nodiscard]]
bool set_port_interface(uint16_t port_number,
const boost::asio::ip::address_v4& interface_address)
const;
254 boost::asio::io_context& io_context_;
256 boost::asio::steady_timer state_decision_timer_;
261 std::vector<std::unique_ptr<Port>> ports_;
264 Throttle<void> stats_callback_throttle_ {std::chrono::seconds(5)};
267 [[nodiscard]] uint16_t get_next_available_port_number()
const;
268 void schedule_state_decision_timer();
Super basic list of subscribers.
A class that throttles a value to a given interval.
virtual void ptp_port_changed_state(const Port &port)
Called when the state of a port changes.
virtual void ptp_parent_changed(const ParentDs &parent)
Called when the parent of the PTP instance changes.
virtual void ptp_stats_updated(const Stats &ptp_stats)
Called at a regular interval when the PTP stats are updated.
virtual void ptp_port_removed(const uint16_t port_number)
Called when a port was removed.
const LocalClock & get_local_clock()
virtual ~Subscriber()=default
virtual void ptp_configuration_updated(const Configuration &config)
Called when the configuration was updated.
bool subscribe(Subscriber *subscriber)
Adds a subscriber to the PTP instance.
const ParentDs & get_parent_ds() const
Instance(boost::asio::io_context &io_context)
Constructs a PTP instance.
bool set_port_interface(uint16_t port_number, const boost::asio::ip::address_v4 &interface_address) const
Sets the network interface for port with given port number.
tl::expected< void, Error > add_port(uint16_t port_number, const boost::asio::ip::address_v4 &interface_address)
Adds a port to the PTP instance.
const Configuration & get_configuration() const
State get_state_for_decision_code(StateDecisionCode code) const
Determines what the state of a port should be based on the state decision code and the internal state...
void update_local_ptp_clock(const Measurement< double > &measurement)
Adjusts the PTP clock of the PTP instance based on the mean delay and offset from the master.
bool should_process_ptp_messages(const MessageHeader &header) const
Determines whether the PTP instance should process the given PTP message.
const DefaultDs & get_default_ds() const
Timestamp get_local_ptp_time() const
tl::expected< void, std::string > set_configuration(Configuration config)
Updates the configuration of the sender.
bool has_port(uint16_t port_number) const
void execute_state_decision_event()
Execute a state decision event on all ports in the PTP instance.
bool remove_port(uint16_t port_number)
Removes a port from the PTP instance.
tl::expected< void, Error > update_ports(const std::vector< ip_address_v4 > &ports)
Updates the ports to match the entries in given array.
bool unsubscribe(const Subscriber *subscriber)
Removes a subscriber from the PTP instance.
size_t get_port_count() const
tl::expected< void, Error > add_or_update_port(uint16_t port_number, const boost::asio::ip::address_v4 &interface_address)
Adds or updates a port.
bool set_recommended_state(StateDecisionCode state_decision_code, const std::optional< AnnounceMessage > &announce_message)
Updates the data sets of the PTP instance based on the state decision code.
const TimePropertiesDs & get_time_properties_ds() const
Maintains a local clock corrected to the timebase of another time source, most likely a PTP master cl...
void tag_invoke(const boost::json::value_from_tag &, boost::json::value &jv, const Instance::Configuration &config)
StateDecisionCode
State decision codes.
Represents the data set as described in IEEE1588-2019: 8.2.2.
Represents the default data set as described in IEEE1588-2019: 8.2.1.
Defines the configuration of the PTP instance (of parameters which need to be persisted).
Represents the parent data set as described in IEEE1588-2019: 8.2.3.
Holds different statistics of PTP measurements.
Represents the time properties data set as described in IEEE1588-2019: 8.2.4.
A PTP timestamp, consisting of a seconds and nanoseconds part.