diff --git a/consoleEmulator.pro b/ConsoleEmulatorAddProbes.pro similarity index 100% rename from consoleEmulator.pro rename to ConsoleEmulatorAddProbes.pro diff --git a/logic/include/model/ButtonHelper.h b/logic/include/model/ButtonHelper.h index 98cb5df..a85ade7 100644 --- a/logic/include/model/ButtonHelper.h +++ b/logic/include/model/ButtonHelper.h @@ -2,79 +2,101 @@ #define BUTTONHELPER_H #define PUSH_BUTTON(CAPITAL_NAME, SMALL_NAME, FUNC_CODE, LED_FUNC_CODE) \ - private: \ +private: \ PushButton _ ## SMALL_NAME{FUNC_CODE, LED_FUNC_CODE}; \ void init ## CAPITAL_NAME() \ { \ - connect(this, &Console::dataReady, _ ## SMALL_NAME.getLed(), &Led::newData);\ - connect(_ ## SMALL_NAME.getLed(), SIGNAL(ledChanged(char)), this, SIGNAL(SMALL_NAME ## LedChanged(char)));\ + connect(this, &Console::dataReady, _ ## SMALL_NAME.getLed(), &Led::newData); \ + connect(_ ## SMALL_NAME.getLed(), SIGNAL(ledChanged(char)), this, \ + SIGNAL(SMALL_NAME ## LedChanged(char))); \ } \ - public: \ +public: \ void press ## CAPITAL_NAME() \ { \ - auto arr = _ ## SMALL_NAME.press(); \ - _dataSender->send(arr); \ + auto arr = _ ## SMALL_NAME.press(); \ + _dataSender->send(arr); \ } \ void release ## CAPITAL_NAME() \ { \ - auto arr = _ ## SMALL_NAME.release(); \ - _dataSender->send(arr); \ + auto arr = _ ## SMALL_NAME.release(); \ + _dataSender->send(arr); \ } \ Q_SIGNAL void SMALL_NAME ## LedChanged(char value) /*************************************************************************************************/ #define PUSH_BUTTON_NO_LED(CAPITAL_NAME, SMALL_NAME, FUNC_CODE) \ - private: \ +private: \ PushButton _ ## SMALL_NAME{FUNC_CODE}; \ void init ## CAPITAL_NAME() \ { \ - connect(this, &Console::dataReady, _ ## SMALL_NAME.getLed(), &Led::newData);\ - connect(_ ## SMALL_NAME.getLed(), SIGNAL(ledChanged(char)), this, SIGNAL(SMALL_NAME ## LedChanged(char)));\ + connect(this, &Console::dataReady, _ ## SMALL_NAME.getLed(), &Led::newData); \ + connect(_ ## SMALL_NAME.getLed(), SIGNAL(ledChanged(char)), this, \ + SIGNAL(SMALL_NAME ## LedChanged(char))); \ } \ - public: \ +public: \ void press ## CAPITAL_NAME() \ { \ - auto arr = _ ## SMALL_NAME.press(); \ - _dataSender->send(arr); \ + auto arr = _ ## SMALL_NAME.press(); \ + _dataSender->send(arr); \ } \ void release ## CAPITAL_NAME() \ { \ - auto arr = _ ## SMALL_NAME.release(); \ - _dataSender->send(arr); \ + auto arr = _ ## SMALL_NAME.release(); \ + _dataSender->send(arr); \ } \ Q_SIGNAL void SMALL_NAME ## LedChanged(char value) /*************************************************************************************************/ #define ROTARY_BUTTON(CAPITAL_NAME, SMALL_NAME, FUNC_CODE, LED_FUNC_CODE) \ - private: \ +private: \ RotaryButton _ ## SMALL_NAME{FUNC_CODE, LED_FUNC_CODE}; \ void init ## CAPITAL_NAME() \ { \ - connect(this, &Console::dataReady, _ ## SMALL_NAME.getLed(), &Led::newData);\ - connect(_ ## SMALL_NAME.getLed(), SIGNAL(ledChanged(char)), this, SIGNAL(SMALL_NAME ## LedChanged(char)));\ + connect(this, &Console::dataReady, _ ## SMALL_NAME.getLed(), &Led::newData); \ + connect(_ ## SMALL_NAME.getLed(), SIGNAL(ledChanged(char)), this, \ + SIGNAL(SMALL_NAME ## LedChanged(char))); \ } \ - public: \ +public: \ void rotate ## CAPITAL_NAME(int value) \ { \ - auto arr = _ ## SMALL_NAME.rotate(value); \ - _dataSender->send(arr); \ + auto arr = _ ## SMALL_NAME.rotate(value); \ + _dataSender->send(arr); \ } \ Q_SIGNAL void SMALL_NAME ## LedChanged(char value) /*************************************************************************************************/ #define ROTARY_BUTTON_NO_LED(CAPITAL_NAME, SMALL_NAME, FUNC_CODE) \ - private: \ +private: \ RotaryButton _ ## SMALL_NAME{FUNC_CODE}; \ void init ## CAPITAL_NAME() \ { \ - connect(this, &Console::dataReady, _ ## SMALL_NAME.getLed(), &Led::newData);\ - connect(_ ## SMALL_NAME.getLed(), SIGNAL(ledChanged(char)), this, SIGNAL(SMALL_NAME ## LedChanged(char)));\ + connect(this, &Console::dataReady, _ ## SMALL_NAME.getLed(), &Led::newData); \ + connect(_ ## SMALL_NAME.getLed(), SIGNAL(ledChanged(char)), this, \ + SIGNAL(SMALL_NAME ## LedChanged(char))); \ } \ - public: \ +public: \ void rotate ## CAPITAL_NAME(int value) \ { \ - auto arr = _ ## SMALL_NAME.rotate(value); \ - _dataSender->send(arr); \ + auto arr = _ ## SMALL_NAME.rotate(value); \ + _dataSender->send(arr); \ + } \ + Q_SIGNAL void SMALL_NAME ## LedChanged(char value) + +/*************************************************************************************************/ +#define DROP_DOWN(CAPITAL_NAME, SMALL_NAME, FUNC_CODE, LED_FUNC_CODE) \ +private: \ + DropDown _ ## SMALL_NAME{FUNC_CODE, LED_FUNC_CODE}; \ + void init ## CAPITAL_NAME() \ + { \ + connect(this, &Console::dataReady, _ ## SMALL_NAME.getLed(), &Led::newData); \ + connect(_ ## SMALL_NAME.getLed(), SIGNAL(ledChanged(char)), this, \ + SIGNAL(SMALL_NAME ## LedChanged(char))); \ + } \ +public: \ + void select ## CAPITAL_NAME(int value) \ + { \ + auto arr = _ ## SMALL_NAME.select(value); \ + _dataSender->send(arr); \ } \ Q_SIGNAL void SMALL_NAME ## LedChanged(char value) diff --git a/logic/include/model/Console.h b/logic/include/model/Console.h index 0bbd51e..4846fc0 100644 --- a/logic/include/model/Console.h +++ b/logic/include/model/Console.h @@ -14,6 +14,7 @@ #include "FunctionCodes.h" #include "PushButton.h" #include "RotaryButton.h" +#include "DropDown.h" #include "DataSender.h" #include "Logger.h" @@ -22,6 +23,12 @@ class Console : public QObject { Q_OBJECT + //Slotes + DROP_DOWN(Slot1, slot1, SLOT1_FC, static_cast(SLOT1_LED_FC)); + DROP_DOWN(Slot2, slot2, SLOT2_FC, static_cast(SLOT2_LED_FC)); + DROP_DOWN(Slot3, slot3, SLOT3_FC, static_cast(SLOT3_LED_FC)); + DROP_DOWN(Slot4, slot4, SLOT4_FC, static_cast(SLOT4_LED_FC)); + //PushButton with LED PUSH_BUTTON(Dual, dual, DUAL_FC, static_cast(DUAL_LED_FC)); PUSH_BUTTON(Quad, quad, QUAD_FC, static_cast(QUAD_LED_FC)); diff --git a/logic/include/model/DropDown.h b/logic/include/model/DropDown.h new file mode 100644 index 0000000..7415fe1 --- /dev/null +++ b/logic/include/model/DropDown.h @@ -0,0 +1,29 @@ +#ifndef DropDown_H +#define DropDown_H + +#define PROTOCOL_LENGTH 8 +#define MESSAGE_DIRECTION 0x00 +#define DropDownDataLength 0x02 +#define DropDownType 0x03 +#define ProbA 0x00 +#define ProbB 0x01 +#define ProbNC 0x02 +#define TIME_TAG 0x00 + +#include "Led.h" + +class DropDown +{ +private: + char _functionCode; + Led _led; + +public: + DropDown(char functionCode); + DropDown(char functionCode, char ledFunctionCode); + + Led* getLed(); + QByteArray select(int value); +}; + +#endif //DropDown_H diff --git a/logic/include/model/FunctionCodes.h b/logic/include/model/FunctionCodes.h index ac2dd94..cfad5dc 100644 --- a/logic/include/model/FunctionCodes.h +++ b/logic/include/model/FunctionCodes.h @@ -1,6 +1,16 @@ #ifndef FUNCTIONCODES_H #define FUNCTIONCODES_H +//Probes and LED of probes +#define SLOT1_FC 0x01 +#define SLOT2_FC 0x09 +#define SLOT3_FC 0x19 +#define SLOT4_FC 0x18 +#define SLOT1_LED_FC 0x20 +#define SLOT2_LED_FC 0x27 +#define SLOT3_LED_FC 0x30 +#define SLOT4_LED_FC 0x48 + //Buttons #define DUAL_FC 0x1D #define QUAD_FC 0x1C diff --git a/logic/include/viewModel/MainViewModel.h b/logic/include/viewModel/MainViewModel.h index 6dc7ed9..5cacb67 100644 --- a/logic/include/viewModel/MainViewModel.h +++ b/logic/include/viewModel/MainViewModel.h @@ -19,6 +19,12 @@ class MainViewModel : public QtMvvm::ViewModel MVVM_PROPERTY(int, stepInc, 1) MVVM_PROPERTY(int, stepDec, -1) + //Slots + DROP_DOWN_PROPERTY(slot1, Slot1, LED_OFF) + DROP_DOWN_PROPERTY(slot2, Slot2, LED_OFF) + DROP_DOWN_PROPERTY(slot3, Slot3, LED_OFF) + DROP_DOWN_PROPERTY(slot4, Slot4, LED_OFF) + //Top Left BUTTON_LED_PROPERTY(patient, Patient, false, LED_OFF) BUTTON_LED_PROPERTY(utils, Utils, false, LED_COLOR_WHITE) @@ -144,6 +150,12 @@ signals: //uncrustify off public slots: + //Probes +// LED_SLOT(slot1) +// LED_SLOT(slot2) +// LED_SLOT(slot3) +// LED_SLOT(slot4) + //Top Left LED_SLOT(patient) LED_SLOT(utils) diff --git a/logic/include/viewModel/utils/Property.h b/logic/include/viewModel/utils/Property.h index c6c861a..459de35 100644 --- a/logic/include/viewModel/utils/Property.h +++ b/logic/include/viewModel/utils/Property.h @@ -77,6 +77,16 @@ NAME ## Led(static_cast(value)); \ } \ +/**************************************************************************************************/ +#define DROP_DOWN_PROPERTY(NAME, CAP_NAME, LED_DEF_VAL) \ + MVVM_PROPERTY_CUSTOM(bool, NAME, false) \ + void NAME ## Handle() { \ + if(NAME()) \ + { \ + panel->select ## CAP_NAME('stepDec()'); \ + } \ + } \ + //uncrustify on #endif //PROPERTY_H diff --git a/logic/logic.pro b/logic/logic.pro index 80531c3..eef9d5b 100644 --- a/logic/logic.pro +++ b/logic/logic.pro @@ -8,9 +8,11 @@ TARGET = logic DEFINES += QT_DEPRECATED_WARNINGS -SOURCES += $$files(src/*.cpp, true) +SOURCES += $$files(src/*.cpp, true) \ + src/model/DropDown.cpp -HEADERS += $$files(include/*.h, true) +HEADERS += $$files(include/*.h, true) \ + include/model/DropDown.h INCLUDEPATH += $$PWD/include/ diff --git a/logic/src/model/Console.cpp b/logic/src/model/Console.cpp index 72c5ac7..3f26475 100644 --- a/logic/src/model/Console.cpp +++ b/logic/src/model/Console.cpp @@ -84,6 +84,11 @@ bool Console::isEchoPacket(const QByteArray& data) /*************************************************************************************************/ void Console::initializeButtons() { + initSlot1(); + initSlot2(); + initSlot3(); + initSlot4(); + initDual(); initQuad(); initSingle(); diff --git a/logic/src/model/DropDown.cpp b/logic/src/model/DropDown.cpp new file mode 100644 index 0000000..a453977 --- /dev/null +++ b/logic/src/model/DropDown.cpp @@ -0,0 +1,38 @@ +#include "model/DropDown.h" + +/*************************************************************************************************/ +DropDown::DropDown(char functionCode) +{ + _functionCode = functionCode; +} + +/*************************************************************************************************/ +DropDown::DropDown(char functionCode, char ledFunctionCode) : + _led(ledFunctionCode) +{ + _functionCode = functionCode; +} + +/*************************************************************************************************/ +Led* DropDown::getLed() +{ + return &_led; +} + +/*************************************************************************************************/ +QByteArray DropDown::select(int value) +{ + QByteArray arr; + + arr.resize(PROTOCOL_LENGTH); + arr[0] = MESSAGE_DIRECTION; + arr[1] = DropDownDataLength; + arr[2] = DropDownType; + arr[3] = _functionCode; + arr[4] = static_cast(value >> PROTOCOL_LENGTH); + arr[5] = static_cast(value); + arr[6] = TIME_TAG; + arr[7] = TIME_TAG; + + return arr; +} diff --git a/logic/src/viewModel/MainViewModel.cpp b/logic/src/viewModel/MainViewModel.cpp index 0b3c689..71601d7 100644 --- a/logic/src/viewModel/MainViewModel.cpp +++ b/logic/src/viewModel/MainViewModel.cpp @@ -20,6 +20,12 @@ MainViewModel::MainViewModel(QObject* parent) : connect(network, &UdpDataSender::dataReady, panel, &Console::newData); + //Add Probes in 4 Slots +//CONNECT_LED(slot1) +//CONNECT_LED(slot2) +//CONNECT_LED(slot3) +//CONNECT_LED(slot4) + //Top Left CONNECT_LED(patient) CONNECT_LED(utils)