mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-06 14:28:54 +08:00
blockparam: added support for external parameter copy
This commit is contained in:
@@ -82,9 +82,10 @@ BlockParamBase::BlockParamBase(Block *parent, const char *name, bool parent_pref
|
||||
|
||||
template <class T>
|
||||
BlockParam<T>::BlockParam(Block *block, const char *name,
|
||||
bool parent_prefix) :
|
||||
bool parent_prefix, T *extern_address) :
|
||||
BlockParamBase(block, name, parent_prefix),
|
||||
_val()
|
||||
_val(),
|
||||
_extern_address(extern_address)
|
||||
{
|
||||
update();
|
||||
}
|
||||
@@ -93,12 +94,25 @@ template <class T>
|
||||
T BlockParam<T>::get() { return _val; }
|
||||
|
||||
template <class T>
|
||||
void BlockParam<T>::set(T val) { _val = val; }
|
||||
void BlockParam<T>::set(T val)
|
||||
{
|
||||
_val = val;
|
||||
|
||||
if (_extern_address != NULL) {
|
||||
*_extern_address = val;
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void BlockParam<T>::update()
|
||||
{
|
||||
if (_handle != PARAM_INVALID) { param_get(_handle, &_val); }
|
||||
if (_handle != PARAM_INVALID) {
|
||||
param_get(_handle, &_val);
|
||||
|
||||
if (_extern_address != NULL) {
|
||||
*_extern_address = _val;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
|
||||
@@ -77,7 +77,7 @@ class BlockParam : public BlockParamBase
|
||||
{
|
||||
public:
|
||||
BlockParam(Block *block, const char *name,
|
||||
bool parent_prefix = true);
|
||||
bool parent_prefix = true, T *extern_address = NULL);
|
||||
T get();
|
||||
void commit();
|
||||
void set(T val);
|
||||
@@ -85,6 +85,7 @@ public:
|
||||
virtual ~BlockParam();
|
||||
protected:
|
||||
T _val;
|
||||
T *_extern_address;
|
||||
};
|
||||
|
||||
typedef BlockParam<float> BlockParamFloat;
|
||||
|
||||
Reference in New Issue
Block a user