mirror of
https://gitee.com/xiaohuolufeihua/bizhang_-obav.git
synced 2026-05-22 01:12:31 +00:00
Added parameters for enabling/disabling specific event tasks
This commit is contained in:
committed by
Beat Küng
parent
1982957bef
commit
df257c6555
72
src/modules/events/events_params.c
Normal file
72
src/modules/events/events_params.c
Normal file
@@ -0,0 +1,72 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2018 PX4 Development Team. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name PX4 nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/**
|
||||
* @file events_params.c
|
||||
*
|
||||
* Parameters defined by the events module.
|
||||
*/
|
||||
|
||||
#include <px4_config.h>
|
||||
#include <parameters/param.h>
|
||||
|
||||
/**
|
||||
* Status Display
|
||||
*
|
||||
* Enable/disable event task for displaying the vehicle status using arm-mounted
|
||||
* LEDs. When enabled and if the vehicle supports it, LEDs will flash
|
||||
* indicating various vehicle status changes. Currently PX4 has not implemented
|
||||
* any specific status events.
|
||||
* -
|
||||
*
|
||||
* @group Events
|
||||
* @boolean
|
||||
* @reboot_required true
|
||||
* @value 0 OFF
|
||||
* @value 1 ON
|
||||
*/
|
||||
PARAM_DEFINE_INT32(EV_TSK_STAT_DIS, 0);
|
||||
|
||||
/**
|
||||
* RC Loss Alarm
|
||||
*
|
||||
* Enable/disable event task for RC Loss. When enabled, an alarm tune will be
|
||||
* played via buzzer or ESCs, if supported.
|
||||
*
|
||||
* @group Events
|
||||
* @boolean
|
||||
* @reboot_required true
|
||||
* @value 0 OFF
|
||||
* @value 1 ON
|
||||
*/
|
||||
PARAM_DEFINE_INT32(EV_TSK_RC_LOSS, 0);
|
||||
@@ -66,9 +66,26 @@ int SendEvent::task_spawn(int argc, char *argv[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
SendEvent::SendEvent()
|
||||
: _status_display(_subscriber_handler), _rc_loss_alarm(_subscriber_handler)
|
||||
SendEvent::SendEvent() : ModuleParams(nullptr)
|
||||
{
|
||||
if (_param_status_display.get()) {
|
||||
_status_display = new status::StatusDisplay(_subscriber_handler);
|
||||
}
|
||||
|
||||
if (_param_rc_loss.get()) {
|
||||
_rc_loss_alarm = new rc_loss::RC_Loss_Alarm(_subscriber_handler);
|
||||
}
|
||||
}
|
||||
|
||||
SendEvent::~SendEvent()
|
||||
{
|
||||
if (_status_display != nullptr) {
|
||||
delete _status_display;
|
||||
}
|
||||
|
||||
if (_rc_loss_alarm != nullptr) {
|
||||
delete _rc_loss_alarm;
|
||||
}
|
||||
}
|
||||
|
||||
int SendEvent::start()
|
||||
@@ -119,8 +136,13 @@ void SendEvent::cycle()
|
||||
|
||||
process_commands();
|
||||
|
||||
_status_display.process();
|
||||
_rc_loss_alarm.process();
|
||||
if (_status_display != nullptr) {
|
||||
_status_display->process();
|
||||
}
|
||||
|
||||
if (_rc_loss_alarm != nullptr) {
|
||||
_rc_loss_alarm->process();
|
||||
}
|
||||
|
||||
work_queue(LPWORK, &_work, (worker_t)&SendEvent::cycle_trampoline, this,
|
||||
USEC2TICK(SEND_EVENT_INTERVAL_US));
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
|
||||
#include <px4_workqueue.h>
|
||||
#include <px4_module.h>
|
||||
#include <px4_module_params.h>
|
||||
#include <uORB/topics/vehicle_command.h>
|
||||
#include <uORB/topics/vehicle_command_ack.h>
|
||||
|
||||
@@ -47,10 +48,11 @@ namespace events
|
||||
|
||||
extern "C" __EXPORT int send_event_main(int argc, char *argv[]);
|
||||
|
||||
class SendEvent : public ModuleBase<SendEvent>
|
||||
class SendEvent : public ModuleBase<SendEvent>, public ModuleParams
|
||||
{
|
||||
public:
|
||||
SendEvent();
|
||||
~SendEvent();
|
||||
|
||||
/**
|
||||
* Initialize class in the same context as the work queue. And start the background listener.
|
||||
@@ -87,9 +89,14 @@ private:
|
||||
|
||||
static struct work_s _work;
|
||||
SubscriberHandler _subscriber_handler;
|
||||
status::StatusDisplay _status_display;
|
||||
rc_loss::RC_Loss_Alarm _rc_loss_alarm;
|
||||
status::StatusDisplay *_status_display = nullptr;
|
||||
rc_loss::RC_Loss_Alarm *_rc_loss_alarm = nullptr;
|
||||
orb_advert_t _command_ack_pub = nullptr;
|
||||
|
||||
DEFINE_PARAMETERS(
|
||||
(ParamBool<px4::params::EV_TSK_STAT_DIS>) _param_status_display,
|
||||
(ParamBool<px4::params::EV_TSK_RC_LOSS>) _param_rc_loss
|
||||
)
|
||||
};
|
||||
|
||||
} /* namespace events */
|
||||
|
||||
Reference in New Issue
Block a user