You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
129 lines
4.3 KiB
129 lines
4.3 KiB
#ifndef ICONTROL_H
|
|
#define ICONTROL_H
|
|
|
|
#include <QObject>
|
|
#include <QMap>
|
|
|
|
#include "model/ultrasoundModule/type/ECommandType.h"
|
|
#include "model/csm/type/EConsole.h"
|
|
#include "model/csm/dto/CommandControl.h"
|
|
|
|
/*****************************************************************************/
|
|
/**
|
|
* @brief this is an abtract of controls, like buttons and rotaries
|
|
* @author Mohammad Mohsen Talaie
|
|
* @details
|
|
* @date 12 jan 2021
|
|
*/
|
|
/*****************************************************************************/
|
|
class ControlAbstract : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
protected:
|
|
bool _exist = false;
|
|
bool _enable;
|
|
|
|
quint8 _functionCode = 0;
|
|
quint8 _ledFunctionCode;
|
|
|
|
//This dictionary that store commands depend on csm state
|
|
QMap<EConsole::eConsoleState, QList<CommandControl_t> > _commandList;
|
|
|
|
/*****************************************************************************/
|
|
/**
|
|
* @brief Dtor
|
|
*/
|
|
/*****************************************************************************/
|
|
virtual ~ControlAbstract()
|
|
{
|
|
}
|
|
|
|
public:
|
|
/*****************************************************************************/
|
|
/**
|
|
* @brief this fuction return existance of an ControlAbstract.
|
|
* @details in detaile this fuction is use full for console button to check its chield is exist
|
|
* or not.
|
|
* @return existance of ControlAbstract
|
|
*/
|
|
/*****************************************************************************/
|
|
bool isExist() const
|
|
{
|
|
return _exist;
|
|
}
|
|
|
|
/*****************************************************************************/
|
|
/**
|
|
* @brief this fuction return enable situation of an ControlAbstract.
|
|
* @details in detaile this fuction is use full for console button to check its chield is enable
|
|
* or not.
|
|
* @return enable situation of ControlAbstract
|
|
*/
|
|
/*****************************************************************************/
|
|
bool isEnable() const
|
|
{
|
|
return _enable;
|
|
}
|
|
|
|
/*****************************************************************************/
|
|
/**
|
|
* @brief this function append command to command list of object.
|
|
*/
|
|
/*****************************************************************************/
|
|
void appendCommandList(const QString& csmState, const CommandControl_t& commandControl)
|
|
{
|
|
QList<CommandControl_t> temp;
|
|
if(!_commandList.contains(EConsole::stringToEConsoleEnum<EConsole::eConsoleState>(csmState)))
|
|
{
|
|
temp.append(commandControl);
|
|
_commandList.insert(EConsole::stringToEConsoleEnum<EConsole::eConsoleState>(csmState),
|
|
temp);
|
|
}
|
|
else
|
|
{
|
|
temp = _commandList[EConsole::stringToEConsoleEnum<EConsole::eConsoleState>(csmState)];
|
|
temp.append(commandControl);
|
|
_commandList[EConsole::stringToEConsoleEnum<EConsole::eConsoleState>(csmState)] = temp;
|
|
}
|
|
}
|
|
|
|
/*****************************************************************************/
|
|
/**
|
|
* @brief this fuction sets the function code and led function code of Icontrol.
|
|
*/
|
|
/*****************************************************************************/
|
|
void setFunctionCodes(const quint8& functionCode, const quint8& ledFunctionCode)
|
|
{
|
|
_functionCode = functionCode;
|
|
_ledFunctionCode = ledFunctionCode;
|
|
_exist = true;
|
|
}
|
|
|
|
/*****************************************************************************/
|
|
/**
|
|
* @brief return the function code of ControlAbstract
|
|
*/
|
|
/*****************************************************************************/
|
|
quint8 getFunctionCode() const
|
|
{
|
|
return _functionCode;
|
|
}
|
|
|
|
/*****************************************************************************/
|
|
/**
|
|
* @brief return the led's function code of ControlAbstract
|
|
*/
|
|
/*****************************************************************************/
|
|
quint8 getLedFunctionCode()
|
|
{
|
|
return _ledFunctionCode;
|
|
}
|
|
|
|
virtual QList<CommandControl_t> getCommandList(const EConsole::eConsoleState& csmState) = 0;
|
|
virtual void enable() = 0;
|
|
virtual void disable() = 0;
|
|
virtual EConsole::eControlType getType() const = 0;
|
|
};
|
|
|
|
#endif //ICONTROL_H
|
|
|