2012-07-14 23:26:17 -03:00
|
|
|
// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
|
|
|
|
|
|
|
|
2012-10-11 22:35:35 -03:00
|
|
|
/// @brief Imposes limits on location (geofence), altitude and other parameters
|
|
|
|
/// Each breach will trigger an action or set of actions to recover.
|
|
|
|
/// Adapted from geofence.
|
2012-07-14 23:26:17 -03:00
|
|
|
/// @author Andrew Tridgell
|
|
|
|
/// Andreas Antonopoulos
|
|
|
|
|
|
|
|
|
2015-08-11 03:28:44 -03:00
|
|
|
#include "AP_Limit_Module.h"
|
2012-07-14 23:26:17 -03:00
|
|
|
|
2015-10-26 08:25:44 -03:00
|
|
|
extern const char *get_module_name(enum moduleid i) {
|
2012-07-14 23:26:17 -03:00
|
|
|
|
2012-08-17 03:20:05 -03:00
|
|
|
switch (i) {
|
|
|
|
case AP_LIMITS_GPSLOCK:
|
2015-10-24 18:45:41 -03:00
|
|
|
return "GPSLock Limit";
|
2012-08-17 03:20:05 -03:00
|
|
|
break;
|
|
|
|
case AP_LIMITS_GEOFENCE:
|
2015-10-24 18:45:41 -03:00
|
|
|
return "Geofence Limit";
|
2012-08-17 03:20:05 -03:00
|
|
|
break;
|
|
|
|
case AP_LIMITS_ALTITUDE:
|
2015-10-24 18:45:41 -03:00
|
|
|
return "Altitude Limit";
|
2012-08-17 03:20:05 -03:00
|
|
|
break;
|
|
|
|
default:
|
2015-10-24 18:45:41 -03:00
|
|
|
return "ERROR";
|
2012-08-17 03:20:05 -03:00
|
|
|
break;
|
|
|
|
}
|
2012-07-14 23:26:17 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
AP_Limit_Module::AP_Limit_Module(enum moduleid i) {
|
2012-08-17 03:20:05 -03:00
|
|
|
_id = i;
|
|
|
|
_next = NULL;
|
2012-07-14 23:26:17 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool AP_Limit_Module::init() {
|
|
|
|
|
2012-08-17 03:20:05 -03:00
|
|
|
_triggered = false;
|
|
|
|
return true;
|
2012-07-14 23:26:17 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
moduleid AP_Limit_Module::get_module_id() {
|
2012-08-17 03:20:05 -03:00
|
|
|
return(_id);
|
2012-07-14 23:26:17 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool AP_Limit_Module::enabled() {
|
2012-08-17 03:20:05 -03:00
|
|
|
return(_enabled);
|
2012-07-14 23:26:17 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool AP_Limit_Module::required() {
|
2012-08-17 03:20:05 -03:00
|
|
|
return(_required);
|
2012-07-14 23:26:17 -03:00
|
|
|
}
|
|
|
|
|
2012-08-17 03:20:05 -03:00
|
|
|
AP_Limit_Module *AP_Limit_Module::next() {
|
|
|
|
return(_next);
|
2012-07-14 23:26:17 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
void AP_Limit_Module::link(AP_Limit_Module *m) {
|
2012-08-17 03:20:05 -03:00
|
|
|
_next = m;
|
2012-07-14 23:26:17 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool AP_Limit_Module::triggered() {
|
2012-08-17 03:20:05 -03:00
|
|
|
return(_triggered);
|
2012-07-14 23:26:17 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
void AP_Limit_Module::action() {
|
2012-08-17 03:20:05 -03:00
|
|
|
// do nothing
|
2012-07-14 23:26:17 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|