mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-22 03:43:35 +08:00
Control lib update.
This commit is contained in:
@@ -58,8 +58,8 @@ static const uint16_t maxPublicationsPerBlock = 100;
|
||||
static const uint8_t blockNameLengthMax = 80;
|
||||
|
||||
// forward declaration
|
||||
class SuperBlock;
|
||||
class BlockParamBase;
|
||||
class SuperBlock;
|
||||
|
||||
/**
|
||||
*/
|
||||
@@ -81,9 +81,9 @@ public:
|
||||
protected:
|
||||
// accessors
|
||||
SuperBlock *getParent() { return _parent; }
|
||||
List<uORB::SubscriptionNode *> & getSubscriptions() { return _subscriptions; }
|
||||
List<uORB::PublicationNode *> & getPublications() { return _publications; }
|
||||
List<BlockParamBase *> & getParams() { return _params; }
|
||||
List<uORB::SubscriptionNode *> &getSubscriptions() { return _subscriptions; }
|
||||
List<uORB::PublicationNode *> &getPublications() { return _publications; }
|
||||
List<BlockParamBase *> &getParams() { return _params; }
|
||||
// attributes
|
||||
const char *_name;
|
||||
SuperBlock *_parent;
|
||||
@@ -94,8 +94,8 @@ protected:
|
||||
|
||||
private:
|
||||
/* this class has pointer data members and should not be copied (private constructor) */
|
||||
Block(const control::Block&);
|
||||
Block operator=(const control::Block&);
|
||||
Block(const control::Block &);
|
||||
Block operator=(const control::Block &);
|
||||
};
|
||||
|
||||
class __EXPORT SuperBlock :
|
||||
@@ -106,28 +106,32 @@ public:
|
||||
// methods
|
||||
SuperBlock(SuperBlock *parent, const char *name) :
|
||||
Block(parent, name),
|
||||
_children() {
|
||||
_children()
|
||||
{
|
||||
}
|
||||
virtual ~SuperBlock() {};
|
||||
virtual void setDt(float dt);
|
||||
virtual void updateParams() {
|
||||
virtual void updateParams()
|
||||
{
|
||||
Block::updateParams();
|
||||
|
||||
if (getChildren().getHead() != NULL) updateChildParams();
|
||||
if (getChildren().getHead() != NULL) { updateChildParams(); }
|
||||
}
|
||||
virtual void updateSubscriptions() {
|
||||
virtual void updateSubscriptions()
|
||||
{
|
||||
Block::updateSubscriptions();
|
||||
|
||||
if (getChildren().getHead() != NULL) updateChildSubscriptions();
|
||||
if (getChildren().getHead() != NULL) { updateChildSubscriptions(); }
|
||||
}
|
||||
virtual void updatePublications() {
|
||||
virtual void updatePublications()
|
||||
{
|
||||
Block::updatePublications();
|
||||
|
||||
if (getChildren().getHead() != NULL) updateChildPublications();
|
||||
if (getChildren().getHead() != NULL) { updateChildPublications(); }
|
||||
}
|
||||
protected:
|
||||
// methods
|
||||
List<Block *> & getChildren() { return _children; }
|
||||
List<Block *> &getChildren() { return _children; }
|
||||
void updateChildParams();
|
||||
void updateChildSubscriptions();
|
||||
void updateChildPublications();
|
||||
|
||||
@@ -65,6 +65,7 @@ BlockParamBase::BlockParamBase(Block *parent, const char *name, bool parent_pref
|
||||
|
||||
} else if (parent_prefix) {
|
||||
snprintf(fullname, blockNameLengthMax, "%s_%s", parentName, name);
|
||||
|
||||
} else {
|
||||
strncpy(fullname, name, blockNameLengthMax);
|
||||
}
|
||||
@@ -74,15 +75,17 @@ BlockParamBase::BlockParamBase(Block *parent, const char *name, bool parent_pref
|
||||
|
||||
_handle = param_find(fullname);
|
||||
|
||||
if (_handle == PARAM_INVALID)
|
||||
if (_handle == PARAM_INVALID) {
|
||||
printf("error finding param: %s\n", fullname);
|
||||
}
|
||||
};
|
||||
|
||||
template <class T>
|
||||
BlockParam<T>::BlockParam(Block *block, const char *name,
|
||||
bool parent_prefix) :
|
||||
bool parent_prefix) :
|
||||
BlockParamBase(block, name, parent_prefix),
|
||||
_val() {
|
||||
_val()
|
||||
{
|
||||
update();
|
||||
}
|
||||
|
||||
@@ -93,13 +96,15 @@ template <class T>
|
||||
void BlockParam<T>::set(T val) { _val = val; }
|
||||
|
||||
template <class T>
|
||||
void BlockParam<T>::update() {
|
||||
if (_handle != PARAM_INVALID) param_get(_handle, &_val);
|
||||
void BlockParam<T>::update()
|
||||
{
|
||||
if (_handle != PARAM_INVALID) { param_get(_handle, &_val); }
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void BlockParam<T>::commit() {
|
||||
if (_handle != PARAM_INVALID) param_set(_handle, &_val);
|
||||
void BlockParam<T>::commit()
|
||||
{
|
||||
if (_handle != PARAM_INVALID) { param_set(_handle, &_val); }
|
||||
}
|
||||
|
||||
template <class T>
|
||||
|
||||
Reference in New Issue
Block a user