SITL: create SITL tonealarm files to hold enable parameter

This commit is contained in:
Peter Barker 2019-10-09 11:00:53 +11:00 committed by Andrew Tridgell
parent 438c29e924
commit a94b1ed65e
4 changed files with 100 additions and 2 deletions

View File

@ -0,0 +1,45 @@
/*
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
simple tonealarm simulator class
*/
#include <GCS_MAVLink/GCS.h>
#include <SITL/SITL.h>
#include "SIM_ToneAlarm.h"
using namespace SITL;
// table of user settable parameters
const AP_Param::GroupInfo ToneAlarm::var_info[] = {
// @Param: ENABLE
// @DisplayName: ToneAlarm enable/disable
// @Description: Allows you to enable (1) or disable (0) the simulated tonealarm
// @Values: 0:Disabled,1:Enabled
// @User: Advanced
AP_GROUPINFO("ENABLE", 0, ToneAlarm, _enable, 1),
AP_GROUPEND
};
/*
update tonealarm state
*/
void ToneAlarm::update(const struct sitl_input &input)
{
// currently all of the simulated buzzer logic is within AP_HAL_SITL
}

View File

@ -0,0 +1,48 @@
/*
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
simple tonealarm simulation class; note that the bulk of this is
actuall in AP_HAL_SITL at the moment in ToneAlarm_SF.h and
ToneAlarm_SF.cpp
*/
#pragma once
#include <AP_Param/AP_Param.h>
#include "SITL_Input.h"
#include "stdint.h"
namespace SITL {
class ToneAlarm {
public:
ToneAlarm() {
AP_Param::setup_object_defaults(this, var_info);
};
void update(const struct sitl_input &input);
static const struct AP_Param::GroupInfo var_info[];
bool is_enabled() const {return static_cast<bool>(_enable);}
private:
AP_Int8 _enable; // enable buzzer sim
};
}

View File

@ -192,6 +192,9 @@ const AP_Param::GroupInfo SITL::var_info2[] = {
// @Path: ./SIM_Buzzer.cpp // @Path: ./SIM_Buzzer.cpp
AP_SUBGROUPINFO(buzzer_sim, "BZ_", 56, SITL, Buzzer), AP_SUBGROUPINFO(buzzer_sim, "BZ_", 56, SITL, Buzzer),
// @Path: ./SIM_ToneAlarm.cpp
AP_SUBGROUPINFO(tonealarm_sim, "TA_", 57, SITL, ToneAlarm),
AP_GROUPINFO("MAG_SCALING", 60, SITL, mag_scaling, 1), AP_GROUPINFO("MAG_SCALING", 60, SITL, mag_scaling, 1),
AP_GROUPEND AP_GROUPEND

View File

@ -5,11 +5,12 @@
#include <AP_Common/Location.h> #include <AP_Common/Location.h>
#include "SIM_Buzzer.h" #include "SIM_Buzzer.h"
#include "SIM_Sprayer.h"
#include "SIM_Gripper_Servo.h"
#include "SIM_Gripper_EPM.h" #include "SIM_Gripper_EPM.h"
#include "SIM_Gripper_Servo.h"
#include "SIM_Parachute.h" #include "SIM_Parachute.h"
#include "SIM_Precland.h" #include "SIM_Precland.h"
#include "SIM_Sprayer.h"
#include "SIM_ToneAlarm.h"
namespace SITL { namespace SITL {
@ -300,6 +301,7 @@ public:
Parachute parachute_sim; Parachute parachute_sim;
Buzzer buzzer_sim; Buzzer buzzer_sim;
ToneAlarm tonealarm_sim;
SIM_Precland precland_sim; SIM_Precland precland_sim;
}; };