diff --git a/src/vscp/common/mdf.cpp b/src/vscp/common/mdf.cpp index eb367b4dc..3e7e0c8da 100644 --- a/src/vscp/common/mdf.cpp +++ b/src/vscp/common/mdf.cpp @@ -611,7 +611,7 @@ CMDF_ActionParameter::CMDF_ActionParameter() m_name.clear(); m_offset = 0; m_min = 0; - m_max = 0; + m_max = 255; } CMDF_ActionParameter::~CMDF_ActionParameter() @@ -703,6 +703,24 @@ CMDF_Action::clearStorage(void) m_mapInfoURL.clear(); } +/////////////////////////////////////////////////////////////////////////////// +// getAction +// + +CMDF_ActionParameter * +CMDF_Action::getActionParam(uint16_t offset) +{ + std::deque::iterator it; + for (it = m_list_ActionParameter.begin(); it != m_list_ActionParameter.end(); ++it) { + CMDF_ActionParameter *pActionParam = *it; + printf("offset=%d\n", pActionParam->getOffset()); + if ((nullptr != pActionParam) && (offset == pActionParam->getOffset())) { + return pActionParam; + } + } + return nullptr; +} + /////////////////////////////////////////////////////////////////////////////// // Constructor/Destructor // @@ -738,6 +756,24 @@ CMDF_DecisionMatrix::clearStorage() m_list_action.clear(); } +/////////////////////////////////////////////////////////////////////////////// +// getAction +// + +CMDF_Action * +CMDF_DecisionMatrix::getAction(uint16_t code) +{ + std::deque::iterator it; + for (it = m_list_action.begin(); it != m_list_action.end(); ++it) { + CMDF_Action *pAction = *it; + printf("code=%d\n", pAction->getCode()); + if ((nullptr != pAction) && (code == pAction->getCode())) { + return pAction; + } + } + return nullptr; +} + /////////////////////////////////////////////////////////////////////////////// // Constructor/Destructor // diff --git a/src/vscp/common/mdf.h b/src/vscp/common/mdf.h index 3b35acaed..49f5c6d94 100644 --- a/src/vscp/common/mdf.h +++ b/src/vscp/common/mdf.h @@ -118,10 +118,12 @@ typedef enum mdf_record_type { mdf_type_remotevar_item, mdf_type_remotevar_sub_item, mdf_type_decision_matrix, + mdf_type_decision_matrix_item, mdf_type_action, mdf_type_action_item, mdf_type_action_sub_item, mdf_type_action_param, + mdf_type_action_param_item, mdf_type_event, mdf_type_event_item, mdf_type_event_data, @@ -1262,6 +1264,13 @@ class CMDF_Action : public CMDF_Object { */ void setCode(uint16_t code) { m_code = code; }; + /*! + Get pointer to action parameter object from its offset + @param code Offset for action parameter to fetch + @return Pointer to action parameter object or nullptr if no action parameter with that offset is found. + */ + CMDF_ActionParameter *getActionParam(uint16_t offset); + /*! Get action parameter list @return Action parameter list @@ -1382,6 +1391,13 @@ class CMDF_DecisionMatrix : public CMDF_Object { */ std::deque *getActionList(void) { return &m_list_action; }; + /*! + Get pointer to action object from its code + @param code Code for action to fetch + @return Pointer to action or nullptr if no action with that code is found. + */ + CMDF_Action *getAction(uint16_t code); + // int getRegister(uint8_t row, CMDF_DecisionMatrix__dmindex idx); private: