Browse Source

Probes added

emulator-with-probes
miladS 10 months ago
parent
commit
ab9fcdd18b
  1. 0
      ConsoleEmulatorAddProbes.pro
  2. 30
      logic/include/model/ButtonHelper.h
  3. 7
      logic/include/model/Console.h
  4. 29
      logic/include/model/DropDown.h
  5. 10
      logic/include/model/FunctionCodes.h
  6. 12
      logic/include/viewModel/MainViewModel.h
  7. 10
      logic/include/viewModel/utils/Property.h
  8. 6
      logic/logic.pro
  9. 5
      logic/src/model/Console.cpp
  10. 38
      logic/src/model/DropDown.cpp
  11. 6
      logic/src/viewModel/MainViewModel.cpp

0
consoleEmulator.pro → ConsoleEmulatorAddProbes.pro

30
logic/include/model/ButtonHelper.h

@ -7,7 +7,8 @@
void init ## CAPITAL_NAME() \ void init ## CAPITAL_NAME() \
{ \ { \
connect(this, &Console::dataReady, _ ## SMALL_NAME.getLed(), &Led::newData); \ connect(this, &Console::dataReady, _ ## SMALL_NAME.getLed(), &Led::newData); \
connect(_ ## SMALL_NAME.getLed(), SIGNAL(ledChanged(char)), this, SIGNAL(SMALL_NAME ## LedChanged(char)));\ connect(_ ## SMALL_NAME.getLed(), SIGNAL(ledChanged(char)), this, \
SIGNAL(SMALL_NAME ## LedChanged(char))); \
} \ } \
public: \ public: \
void press ## CAPITAL_NAME() \ void press ## CAPITAL_NAME() \
@ -29,7 +30,8 @@
void init ## CAPITAL_NAME() \ void init ## CAPITAL_NAME() \
{ \ { \
connect(this, &Console::dataReady, _ ## SMALL_NAME.getLed(), &Led::newData); \ connect(this, &Console::dataReady, _ ## SMALL_NAME.getLed(), &Led::newData); \
connect(_ ## SMALL_NAME.getLed(), SIGNAL(ledChanged(char)), this, SIGNAL(SMALL_NAME ## LedChanged(char)));\ connect(_ ## SMALL_NAME.getLed(), SIGNAL(ledChanged(char)), this, \
SIGNAL(SMALL_NAME ## LedChanged(char))); \
} \ } \
public: \ public: \
void press ## CAPITAL_NAME() \ void press ## CAPITAL_NAME() \
@ -51,7 +53,8 @@
void init ## CAPITAL_NAME() \ void init ## CAPITAL_NAME() \
{ \ { \
connect(this, &Console::dataReady, _ ## SMALL_NAME.getLed(), &Led::newData); \ connect(this, &Console::dataReady, _ ## SMALL_NAME.getLed(), &Led::newData); \
connect(_ ## SMALL_NAME.getLed(), SIGNAL(ledChanged(char)), this, SIGNAL(SMALL_NAME ## LedChanged(char)));\ connect(_ ## SMALL_NAME.getLed(), SIGNAL(ledChanged(char)), this, \
SIGNAL(SMALL_NAME ## LedChanged(char))); \
} \ } \
public: \ public: \
void rotate ## CAPITAL_NAME(int value) \ void rotate ## CAPITAL_NAME(int value) \
@ -68,7 +71,8 @@
void init ## CAPITAL_NAME() \ void init ## CAPITAL_NAME() \
{ \ { \
connect(this, &Console::dataReady, _ ## SMALL_NAME.getLed(), &Led::newData); \ connect(this, &Console::dataReady, _ ## SMALL_NAME.getLed(), &Led::newData); \
connect(_ ## SMALL_NAME.getLed(), SIGNAL(ledChanged(char)), this, SIGNAL(SMALL_NAME ## LedChanged(char)));\ connect(_ ## SMALL_NAME.getLed(), SIGNAL(ledChanged(char)), this, \
SIGNAL(SMALL_NAME ## LedChanged(char))); \
} \ } \
public: \ public: \
void rotate ## CAPITAL_NAME(int value) \ void rotate ## CAPITAL_NAME(int value) \
@ -78,4 +82,22 @@
} \ } \
Q_SIGNAL void SMALL_NAME ## LedChanged(char value) 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)
#endif //BUTTONHELPER_H #endif //BUTTONHELPER_H

7
logic/include/model/Console.h

@ -14,6 +14,7 @@
#include "FunctionCodes.h" #include "FunctionCodes.h"
#include "PushButton.h" #include "PushButton.h"
#include "RotaryButton.h" #include "RotaryButton.h"
#include "DropDown.h"
#include "DataSender.h" #include "DataSender.h"
#include "Logger.h" #include "Logger.h"
@ -22,6 +23,12 @@ class Console : public QObject
{ {
Q_OBJECT Q_OBJECT
//Slotes
DROP_DOWN(Slot1, slot1, SLOT1_FC, static_cast<char>(SLOT1_LED_FC));
DROP_DOWN(Slot2, slot2, SLOT2_FC, static_cast<char>(SLOT2_LED_FC));
DROP_DOWN(Slot3, slot3, SLOT3_FC, static_cast<char>(SLOT3_LED_FC));
DROP_DOWN(Slot4, slot4, SLOT4_FC, static_cast<char>(SLOT4_LED_FC));
//PushButton with LED //PushButton with LED
PUSH_BUTTON(Dual, dual, DUAL_FC, static_cast<char>(DUAL_LED_FC)); PUSH_BUTTON(Dual, dual, DUAL_FC, static_cast<char>(DUAL_LED_FC));
PUSH_BUTTON(Quad, quad, QUAD_FC, static_cast<char>(QUAD_LED_FC)); PUSH_BUTTON(Quad, quad, QUAD_FC, static_cast<char>(QUAD_LED_FC));

29
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

10
logic/include/model/FunctionCodes.h

@ -1,6 +1,16 @@
#ifndef FUNCTIONCODES_H #ifndef FUNCTIONCODES_H
#define 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 //Buttons
#define DUAL_FC 0x1D #define DUAL_FC 0x1D
#define QUAD_FC 0x1C #define QUAD_FC 0x1C

12
logic/include/viewModel/MainViewModel.h

@ -19,6 +19,12 @@ class MainViewModel : public QtMvvm::ViewModel
MVVM_PROPERTY(int, stepInc, 1) MVVM_PROPERTY(int, stepInc, 1)
MVVM_PROPERTY(int, stepDec, -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 //Top Left
BUTTON_LED_PROPERTY(patient, Patient, false, LED_OFF) BUTTON_LED_PROPERTY(patient, Patient, false, LED_OFF)
BUTTON_LED_PROPERTY(utils, Utils, false, LED_COLOR_WHITE) BUTTON_LED_PROPERTY(utils, Utils, false, LED_COLOR_WHITE)
@ -144,6 +150,12 @@ signals:
//uncrustify off //uncrustify off
public slots: public slots:
//Probes
// LED_SLOT(slot1)
// LED_SLOT(slot2)
// LED_SLOT(slot3)
// LED_SLOT(slot4)
//Top Left //Top Left
LED_SLOT(patient) LED_SLOT(patient)
LED_SLOT(utils) LED_SLOT(utils)

10
logic/include/viewModel/utils/Property.h

@ -77,6 +77,16 @@
NAME ## Led(static_cast<int>(value)); \ NAME ## Led(static_cast<int>(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 //uncrustify on
#endif //PROPERTY_H #endif //PROPERTY_H

6
logic/logic.pro

@ -8,9 +8,11 @@ TARGET = logic
DEFINES += QT_DEPRECATED_WARNINGS 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/ INCLUDEPATH += $$PWD/include/

5
logic/src/model/Console.cpp

@ -84,6 +84,11 @@ bool Console::isEchoPacket(const QByteArray& data)
/*************************************************************************************************/ /*************************************************************************************************/
void Console::initializeButtons() void Console::initializeButtons()
{ {
initSlot1();
initSlot2();
initSlot3();
initSlot4();
initDual(); initDual();
initQuad(); initQuad();
initSingle(); initSingle();

38
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<char>(value >> PROTOCOL_LENGTH);
arr[5] = static_cast<char>(value);
arr[6] = TIME_TAG;
arr[7] = TIME_TAG;
return arr;
}

6
logic/src/viewModel/MainViewModel.cpp

@ -20,6 +20,12 @@ MainViewModel::MainViewModel(QObject* parent) :
connect(network, &UdpDataSender::dataReady, panel, &Console::newData); 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 //Top Left
CONNECT_LED(patient) CONNECT_LED(patient)
CONNECT_LED(utils) CONNECT_LED(utils)

Loading…
Cancel
Save