|
STAR
Cal STAR — firmware, DAQ server, and engine design
|
Sends ABORT / ABORT_DONE / CLEAR_ABORT UDP broadcast packets (PacketHeader only — 6 bytes) to the configured broadcast address and port. More...
#include <AbortBroadcaster.hpp>
Classes | |
| struct | dest_addr_ |
Public Member Functions | |
| AbortBroadcaster (uint16_t port=5005, uint32_t abort_done_delay_ms=3000) | |
| ~AbortBroadcaster () | |
| bool | configure (const std::string &broadcast_ip, uint16_t port, uint32_t done_delay_ms, const std::string &bind_address) |
| Adopt the destination and source NIC from config. | |
| void | triggerAbort () |
| Send ABORT broadcast and schedule ABORT_DONE after abort_done_delay_ms. | |
| void | sendClearAbort () |
| Send CLEAR_ABORT broadcast (called when leaving abort states). | |
Private Member Functions | |
| void | sendPacket (uint8_t packet_type) |
| void | waitAndSendAbortDone () |
Private Attributes | |
| uint16_t | port_ |
| uint32_t | abort_done_delay_ms_ |
| std::string | dest_ip_ {"255.255.255.255"} |
| std::string | bind_address_ {"0.0.0.0"} |
| std::atomic< bool > | done_thread_running_ {false} |
| std::thread | done_thread_ |
| std::mutex | done_thread_mutex_ |
Static Private Attributes | |
| static constexpr int | kBroadcastRepeats = 4 |
| How many times each broadcast is repeated, and the gap between repeats. | |
| static constexpr int | kBroadcastGapUs = 2000 |
Sends ABORT / ABORT_DONE / CLEAR_ABORT UDP broadcast packets (PacketHeader only — 6 bytes) to the configured broadcast address and port.
On abort entry:
Thread-safe.
Definition at line 23 of file AbortBroadcaster.hpp.
|
explicit |
Definition at line 31 of file AbortBroadcaster.cpp.
References abort_done_delay_ms_, port, and port_.
| sequencer::AbortBroadcaster::~AbortBroadcaster | ( | ) |
Definition at line 66 of file AbortBroadcaster.cpp.
References done_thread_, done_thread_mutex_, done_thread_running_, and lk.
| bool sequencer::AbortBroadcaster::configure | ( | const std::string & | broadcast_ip, |
| uint16_t | port, | ||
| uint32_t | done_delay_ms, | ||
| const std::string & | bind_address ) |
Adopt the destination and source NIC from config.
Call once, before anything can abort.
This class used to be default-constructed and never told anything: port 5005 by ctor default, destination hardcoded to the limited broadcast 255.255.255.255, source interface left to the kernel. Every other sender in the system takes its destination from config, and a limited broadcast is the one destination that does not resolve to a single route — so on a host with more than one NIC all four repeats could leave on the wrong wire together.
| broadcast_ip | Subnet-directed broadcast for the board LAN, e.g. 192.168.2.255. |
| port | Board listen port. |
| done_delay_ms | Delay before ABORT_DONE. |
| bind_address | Local address to send from, or "0.0.0.0" to leave unpinned. |
Definition at line 36 of file AbortBroadcaster.cpp.
References abort_done_delay_ms_, bind_address_, dest_ip_, port, and port_.
| void sequencer::AbortBroadcaster::sendClearAbort | ( | ) |
Send CLEAR_ABORT broadcast (called when leaving abort states).
Definition at line 175 of file AbortBroadcaster.cpp.
References daq::CLEAR_ABORT, and sendPacket().
|
private |
Definition at line 74 of file AbortBroadcaster.cpp.
References bind_address_, fsw::net::bindToDaqInterface(), dest_ip_, kBroadcastGapUs, kBroadcastRepeats, and port_.
Referenced by sendClearAbort(), triggerAbort(), and waitAndSendAbortDone().
| void sequencer::AbortBroadcaster::triggerAbort | ( | ) |
Send ABORT broadcast and schedule ABORT_DONE after abort_done_delay_ms.
Definition at line 137 of file AbortBroadcaster.cpp.
References daq::ABORT, done_thread_, done_thread_mutex_, done_thread_running_, lk, sendPacket(), and waitAndSendAbortDone().
|
private |
Definition at line 162 of file AbortBroadcaster.cpp.
References daq::ABORT_DONE, abort_done_delay_ms_, delay(), done_thread_running_, elapsed(), and sendPacket().
Referenced by triggerAbort().
|
private |
Definition at line 54 of file AbortBroadcaster.hpp.
Referenced by AbortBroadcaster(), configure(), and waitAndSendAbortDone().
|
private |
Definition at line 59 of file AbortBroadcaster.hpp.
Referenced by configure(), and sendPacket().
|
private |
Definition at line 58 of file AbortBroadcaster.hpp.
Referenced by configure(), and sendPacket().
|
private |
Definition at line 61 of file AbortBroadcaster.hpp.
Referenced by triggerAbort(), and ~AbortBroadcaster().
|
private |
Definition at line 67 of file AbortBroadcaster.hpp.
Referenced by triggerAbort(), and ~AbortBroadcaster().
|
private |
Definition at line 60 of file AbortBroadcaster.hpp.
Referenced by triggerAbort(), waitAndSendAbortDone(), and ~AbortBroadcaster().
|
staticconstexprprivate |
Definition at line 75 of file AbortBroadcaster.hpp.
Referenced by sendPacket().
|
staticconstexprprivate |
How many times each broadcast is repeated, and the gap between repeats.
A single UDP datagram is not a delivery guarantee: one dropped frame on a congested field network and no board hears the abort. ActuatorCommander::sendBatch already sends ordinary state changes 3x for exactly this reason — the abort path must not be weaker than the routine one.
Definition at line 74 of file AbortBroadcaster.hpp.
Referenced by sendPacket().
|
private |
Definition at line 53 of file AbortBroadcaster.hpp.
Referenced by AbortBroadcaster(), configure(), and sendPacket().