mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-24 04:53:34 +08:00
PanicBroadcaster
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <uavcan/node/publisher.hpp>
|
||||
#include <uavcan/node/timer.hpp>
|
||||
#include <uavcan/protocol/Panic.hpp>
|
||||
|
||||
namespace uavcan
|
||||
{
|
||||
|
||||
class PanicBroadcaster : private Timer
|
||||
{
|
||||
Publisher<protocol::Panic> pub_;
|
||||
protocol::Panic msg_;
|
||||
|
||||
void publishOnce();
|
||||
|
||||
void handleTimerEvent(const TimerEvent&);
|
||||
|
||||
public:
|
||||
PanicBroadcaster(INode& node)
|
||||
: Timer(node)
|
||||
, pub_(node)
|
||||
{
|
||||
pub_.setTxTimeout(MonotonicDuration::fromMSec(protocol::Panic::BROADCASTING_INTERVAL_MS - 10));
|
||||
}
|
||||
|
||||
void panic(const char* short_reason);
|
||||
|
||||
void dontPanic(); // Where's my towel
|
||||
|
||||
bool isPanicking() const;
|
||||
|
||||
const typename protocol::Panic::FieldTypes::reason_text& getReason() const;
|
||||
};
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user