/
toktservext.cpp
130 lines (112 loc) · 4.53 KB
/
toktservext.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#include "toktservext.h"
int TOktServExt::server_count=0;
QMainWindow *TOktServExt::RegSetup_MainWindow=NULL;
xTabWidget *TOktServExt::RegSetup_tabWidget=NULL;
QPixmap *TOktServExt::wait_qp[4]={NULL, NULL, NULL, NULL};
QMainWindow *TOktServExt::GetBlocksID_MainWindow=NULL;
xTabWidget *TOktServExt::GetBlocksID_tabWidget=NULL;
TOktServExt::TOktServExt(QGroupBox *PortSettings_GroupBox
#ifdef __linux__
, const char *port_name, QLabel *RegState_Label) : TOktServ(PortSettings_GroupBox, port_name)
#else
, QLabel *RegState_Label) : TOktServ(PortSettings_GroupBox)
#endif
{
server_index=server_count++;
this->RegState_Label=(RegState_Label==NULL)?new QLabel():RegState_Label;
connect(this, SIGNAL(DataUpdate(TOscDataWithIndic &)), this, SLOT(GetDataOktServ(TOscDataWithIndic &)));
connect(this, SIGNAL(ErrorCallback()), this, SLOT(CatchError()));
//Сервисы осциллограмм
OscList_MainWindow = new QMainWindow();
OscList_MainWindow->setWindowIcon(QIcon(":/images/stocks.png"));
ParametersView_MainWindow = new QMainWindow();
ParametersView_MainWindow->setWindowIcon(QIcon(":/images/meter3.png"));
OscService=new TOscService(OscList_MainWindow, ParametersView_MainWindow, (server_index==0));
//Иконки для индикатора данных
for(int i=0;i<4;i++) { wait_qp[i]=new QPixmap(tr(":/images/Wait%1_24.png").arg(i)); }
//Окно настроек регулятора
if(RegSetup_MainWindow==NULL)
{
RegSetup_MainWindow = new QMainWindow();
RegSetup_MainWindow->setWindowIcon(QIcon(":/images/advancedsettings.png"));
}
//Виджет закладок
if(RegSetup_tabWidget==NULL)
{
RegSetup_tabWidget = new xTabWidget(RegSetup_MainWindow);
RegSetup_tabWidget->setStyleSheet(xTabWidgetStyleSheet.arg(24).arg(180).arg(36));
RegSetup_MainWindow->setCentralWidget(RegSetup_tabWidget);
RegSetup_tabWidget->setVisible(true);
}
RegSetup_Tab = new QWidget(RegSetup_MainWindow); //Закладка
RegSetup_tabWidget->addTab(RegSetup_Tab/*, QIcon(":/images/advancedsettings.png")*/, "");
//Окно списка блоков
if(GetBlocksID_MainWindow==NULL)
{
GetBlocksID_MainWindow = new QMainWindow();
GetBlocksID_MainWindow->setWindowIcon(QIcon(":/images/memory.png"));
}
//Виджет закладок
if(GetBlocksID_tabWidget==NULL)
{
GetBlocksID_tabWidget = new xTabWidget(GetBlocksID_MainWindow);
GetBlocksID_tabWidget->setStyleSheet(xTabWidgetStyleSheet.arg(24).arg(180).arg(36));
GetBlocksID_MainWindow->setCentralWidget(GetBlocksID_tabWidget);
}
GetBlocksID_Tab = new QWidget(GetBlocksID_MainWindow); //Закладка
GetBlocksID_tabWidget->addTab(GetBlocksID_Tab/*, QIcon(":/images/memory.png")*/, "");
//Создание сервиса работы с настройками регулятора и получения списка блоков
RegSetup_GetBlocksID = new TOktServRegSetup(RegSetup_Tab, GetBlocksID_Tab, this);
connect(RegSetup_GetBlocksID, SIGNAL(RegSetup_CloseSignal()), this, SLOT(RegSetup_CloseSlotExternal()));
connect(RegSetup_GetBlocksID, SIGNAL(GetBlocksID_CloseSignal()), this, SLOT(GetBlocksID_CloseSlotExternal()));
Master=false;
FirstDataAsquired=false;
okt_serv_other=NULL;
Retranslate();
}
void TOktServExt::Retranslate()
{
Name=(server_index==0)?tr("ОСНОВНОЙ"):tr("РЕЗЕРВНЫЙ");
OscList_MainWindow->setWindowTitle(tr("ОСЦИЛЛОГРАММЫ -")+Name);
ParametersView_MainWindow->setWindowTitle(tr("ПАРАМЕТРЫ -")+Name);
RegSetup_MainWindow->setWindowTitle(tr("НАСТРОЙКИ РЕГУЛЯТОРА"));
RegSetup_tabWidget->setTabText(server_index, Name);
GetBlocksID_MainWindow->setWindowTitle(tr("СПИСОК БЛОКОВ"));
GetBlocksID_tabWidget->setTabText(server_index, Name);
}
//Слот обработки данных
void TOktServExt::GetDataOktServ(TOscDataWithIndic &od)
{
bool print=false;
if((++PktCntPrescale&0x0F)==0)
{
//RegState_Label->setText(tr("Пакеты: %1").arg(PktCnt));
RegState_Label->setText(tr("На связи"));
print=true;
}
DataProcessLocal(od, previous_od, this, 0, print);
}
void TOktServExt::CatchError()
{
if(ErrorFlags & OKTSERVERR_TIMEOUT_FLAG)
{
RegState_Label->setText(tr("Таймаут"));
}
else
{
RegState_Label->setText(QString("Err: 0x%1").arg(ErrorFlags, 4, 16, QLatin1Char('0')).toUpper());
}
DataProcessLocal(previous_od, previous_od, this, ErrorFlags, true);
}
void TOktServExt::StartStop(bool StateOn)
{
TOktServ::StartStop(StateOn);
if(StateOn)
{
RegSetup_GetBlocksID->Start_Service();
}
else
{
RegSetup_GetBlocksID->StopService();
}
}