Browse Source

Check data received from fake relay board to sync with changes

develop
miladS 10 months ago
parent
commit
06228358f4
  1. 8
      logic/include/model/ButtonHelper.h
  2. 7
      logic/include/viewModel/MainViewModel.h
  3. 30
      logic/src/model/Console.cpp
  4. 75
      logic/src/viewModel/MainViewModel.cpp

8
logic/include/model/ButtonHelper.h

@ -49,7 +49,7 @@ public: \
/*************************************************************************************************/
#define PUSH_BUTTON_PROBE_SLOT(CAPITAL_NAME, SMALL_NAME, SLOT_NUMBER) \
private: \
PushButton _ ## SMALL_NAME{SLOT_NUMBER}; \
PushButton _ ## SMALL_NAME{SLOT_NUMBER, SLOT_NUMBER}; \
void init ## CAPITAL_NAME() \
{ \
connect(this, &Console::dataReady, _ ## SMALL_NAME.getLed(), &Led::newData); \
@ -57,19 +57,17 @@ private: \
SIGNAL(SMALL_NAME ## LedChanged(char))); \
} \
public: \
void press ## CAPITAL_NAME(bool isEnable1) \
void press ## CAPITAL_NAME() \
{ \
auto arr = _ ## SMALL_NAME.press(); \
arr[5] = static_cast<char>(this->selectedProbe ## SLOT_NUMBER); \
arr[6] = isEnable1 ? 1 : 0; \
_dataSender->sendProbeSlots(arr); \
emit changeProbeSelectionEnable ## SLOT_NUMBER(); \
} \
void release ## CAPITAL_NAME() \
{ \
} \
Q_SIGNAL void SMALL_NAME ## LedChanged(char value); \
Q_SIGNAL void changeProbeSelectionEnable ## SLOT_NUMBER()
Q_SIGNAL void changeProbeSelectionEnable ## SLOT_NUMBER(bool value)
/*************************************************************************************************/
#define PUSH_BUTTON_NO_LED(CAPITAL_NAME, SMALL_NAME, FUNC_CODE) \

7
logic/include/viewModel/MainViewModel.h

@ -167,6 +167,12 @@ signals:
void ledChanged(char value);
//uncrustify off
private slots:
void setProbeSelectionEnable1(bool value);
void setProbeSelectionEnable2(bool value);
void setProbeSelectionEnable3(bool value);
void setProbeSelectionEnable4(bool value);
public slots:
//Probes
LED_SLOT(slot1)
@ -241,6 +247,7 @@ public slots:
LED_SLOT(focusBottom)
LED_SLOT(frameRateCenter)
//uncrustify on
};

30
logic/src/model/Console.cpp

@ -34,6 +34,36 @@ void Console::newData(QByteArray data)
{
emit dataReady(data, _logger);
}
switch(data[FUNCTION_CODE])
{
case 1:
{
emit changeProbeSelectionEnable1(!data[1]);
}
break;
case 2:
{
emit changeProbeSelectionEnable2(!data[1]);
}
break;
case 3:
{
emit changeProbeSelectionEnable3(!data[1]);
}
break;
case 4:
{
emit changeProbeSelectionEnable4(!data[1]);
}
break;
default:
break;
}
}
catch(const std::exception& e)
{

75
logic/src/viewModel/MainViewModel.cpp

@ -10,6 +10,11 @@
#define US_HOME_PATH "US_HOME"
#define CONNECT_LED(NAME) \
connect(panel, SIGNAL(NAME ## LedChanged(char)), this, SLOT(NAME ## LedHandle(char)));
#define CONNECT_PROBE_SELECTION(NAME) \
connect(panel, \
&Console::changeProbeSelectionEnable ## NAME, \
this, \
&MainViewModel::setProbeSelectionEnable ## NAME);
MainViewModel::MainViewModel(QObject* parent) : ViewModel(parent)
{
@ -48,31 +53,37 @@ MainViewModel::MainViewModel(QObject* parent) : ViewModel(parent)
});
//Enable and disable changes in probe selection box
connect(panel, &Console::changeProbeSelectionEnable1, [ = ]()
{
this->isProbeSelectionEnable1(!this->isProbeSelectionEnable1());
this->slot1Led(this->isProbeSelectionEnable1() ? LED_COLOR_WHITE : LED_COLOR_GREEN);
});
connect(panel, &Console::changeProbeSelectionEnable2, [ = ]()
{
this->isProbeSelectionEnable2(!this->isProbeSelectionEnable2());
this->slot2Led(this->isProbeSelectionEnable2() ? LED_COLOR_WHITE : LED_COLOR_GREEN);
});
connect(panel, &Console::changeProbeSelectionEnable3, [ = ]()
{
this->isProbeSelectionEnable3(!this->isProbeSelectionEnable3());
this->slot3Led(this->isProbeSelectionEnable3() ? LED_COLOR_WHITE : LED_COLOR_GREEN);
});
//connect(panel, &Console::changeProbeSelectionEnable1, [ = ]()
//{
//this->isProbeSelectionEnable1(!this->isProbeSelectionEnable1());
////this->slot1Led(this->isProbeSelectionEnable1() ? LED_COLOR_WHITE : LED_COLOR_GREEN);
//});
//connect(panel, &Console::changeProbeSelectionEnable2, [ = ]()
//{
//this->isProbeSelectionEnable2(!this->isProbeSelectionEnable2());
////this->slot2Led(this->isProbeSelectionEnable2() ? LED_COLOR_WHITE : LED_COLOR_GREEN);
//});
//connect(panel, &Console::changeProbeSelectionEnable3, [ = ]()
//{
//this->isProbeSelectionEnable3(!this->isProbeSelectionEnable3());
////this->slot3Led(this->isProbeSelectionEnable3() ? LED_COLOR_WHITE : LED_COLOR_GREEN);
//});
//connect(panel, &Console::changeProbeSelectionEnable4, [ = ]()
//{
//this->isProbeSelectionEnable4(!this->isProbeSelectionEnable4());
////this->slot4Led(this->isProbeSelectionEnable4() ? LED_COLOR_WHITE : LED_COLOR_GREEN);
//});
connect(panel, &Console::changeProbeSelectionEnable4, [ = ]()
{
this->isProbeSelectionEnable4(!this->isProbeSelectionEnable4());
this->slot4Led(this->isProbeSelectionEnable4() ? LED_COLOR_WHITE : LED_COLOR_GREEN);
});
//connect(this, );
CONNECT_PROBE_SELECTION(1)
CONNECT_PROBE_SELECTION(2)
CONNECT_PROBE_SELECTION(3)
CONNECT_PROBE_SELECTION(4)
//Add Probes in 4 Slots
CONNECT_LED(slot1)
CONNECT_LED(slot2)
@ -145,3 +156,23 @@ MainViewModel::MainViewModel(QObject* parent) : ViewModel(parent)
CONNECT_LED(depthBottom)
CONNECT_LED(focusBottom)
}
void MainViewModel::setProbeSelectionEnable1(bool value)
{
isProbeSelectionEnable1(value);
}
void MainViewModel::setProbeSelectionEnable2(bool value)
{
isProbeSelectionEnable2(value);
}
void MainViewModel::setProbeSelectionEnable3(bool value)
{
isProbeSelectionEnable3(value);
}
void MainViewModel::setProbeSelectionEnable4(bool value)
{
isProbeSelectionEnable4(value);
}

Loading…
Cancel
Save