Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
DIOT WIC Gateware
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
DIOT WIC Gateware
Commits
71f1f8f9
Commit
71f1f8f9
authored
Sep 25, 2018
by
Projects
Committed by
Grzegorz Daniluk
Nov 27, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
GUI demo: display data status
parent
23e450ab
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
4 deletions
+58
-4
controller.cpp
sw/diot-sw/gui_demo/controller.cpp
+47
-4
controller.h
sw/diot-sw/gui_demo/controller.h
+11
-0
No files found.
sw/diot-sw/gui_demo/controller.cpp
View file @
71f1f8f9
...
...
@@ -20,6 +20,7 @@
#include <QtWidgets/QGroupBox>
#include <QBoxLayout>
#include <QLabel>
#include <QStatusBar>
#include "controller.h"
DiotHardware
::
DiotHardware
(
int
address
,
int
slots_nr
)
...
...
@@ -45,6 +46,11 @@ DiotHardware::DiotHardware(int address, int slots_nr)
crate
->
AddVariables
(
cycle
->
GetPeriodicVarWindow
());
crate
->
SetConsVarCb
([
&
](
nanoFIP
&
nf
,
mstrfip_data
*
data
)
{
emit
StatusChanged
(
data
->
status
);
if
(
data
->
status
!=
MSTRFIP_DATA_OK
)
return
;
// Report the crate state
DIOT_Crate
*
crate
=
static_cast
<
DIOT_Crate
*>
(
&
nf
);
...
...
@@ -247,7 +253,8 @@ DiotDiag::DiotDiag(QWidget* parent, DiotHardware& hw)
:
QFrame
(
parent
)
{
DIOT_Crate
*
crate
=
hw
.
GetCrate
();
QHBoxLayout
*
mainLayout
=
new
QHBoxLayout
();
QVBoxLayout
*
mainLayout
=
new
QVBoxLayout
();
QHBoxLayout
*
statsLayout
=
new
QHBoxLayout
();
// Fans
QGroupBox
*
fanBox
=
new
QGroupBox
(
this
);
...
...
@@ -259,7 +266,7 @@ DiotDiag::DiotDiag(QWidget* parent, DiotHardware& hw)
}
fanBox
->
setTitle
(
"Fans"
);
fanBox
->
setLayout
(
fanLayout
);
main
Layout
->
addWidget
(
fanBox
);
stats
Layout
->
addWidget
(
fanBox
);
// Temperature sensors
QGroupBox
*
tempBox
=
new
QGroupBox
(
this
);
...
...
@@ -271,7 +278,7 @@ DiotDiag::DiotDiag(QWidget* parent, DiotHardware& hw)
}
tempBox
->
setTitle
(
"Temperature"
);
tempBox
->
setLayout
(
tempLayout
);
main
Layout
->
addWidget
(
tempBox
);
stats
Layout
->
addWidget
(
tempBox
);
// Voltages
QGroupBox
*
voltBox
=
new
QGroupBox
(
this
);
...
...
@@ -284,7 +291,11 @@ DiotDiag::DiotDiag(QWidget* parent, DiotHardware& hw)
}
voltBox
->
setTitle
(
"Voltages"
);
voltBox
->
setLayout
(
voltLayout
);
mainLayout
->
addWidget
(
voltBox
);
statsLayout
->
addWidget
(
voltBox
);
mainLayout
->
addLayout
(
statsLayout
,
1
);
statusBar
=
new
QStatusBar
(
this
);
mainLayout
->
addWidget
(
statusBar
);
setLayout
(
mainLayout
);
...
...
@@ -294,6 +305,8 @@ DiotDiag::DiotDiag(QWidget* parent, DiotHardware& hw)
this
,
&
DiotDiag
::
UpdateTemperature
);
QObject
::
connect
(
&
hw
,
&
DiotHardware
::
VoltageChanged
,
this
,
&
DiotDiag
::
UpdateVoltage
);
QObject
::
connect
(
&
hw
,
&
DiotHardware
::
StatusChanged
,
this
,
&
DiotDiag
::
UpdateStatus
);
}
...
...
@@ -315,6 +328,36 @@ void DiotDiag::UpdateVoltage(unsigned int volt, bool state)
}
void
DiotDiag
::
UpdateStatus
(
int
status
)
{
qDebug
()
<<
"status: "
<<
status
;
switch
(
status
)
{
case
MSTRFIP_DATA_OK
:
statusBar
->
showMessage
(
"Status: data OK"
);
break
;
case
MSTRFIP_DATA_FRAME_ERROR
:
statusBar
->
showMessage
(
"Status: frame error"
);
break
;
case
MSTRFIP_DATA_PAYLOAD_ERROR
:
statusBar
->
showMessage
(
"Status: payload error"
);
break
;
case
MSTRFIP_DATA_NOT_RECEIVED
:
statusBar
->
showMessage
(
"Status: data not received"
);
break
;
}
if
(
status
==
MSTRFIP_DATA_OK
)
statusBar
->
setStyleSheet
(
"color: green"
);
else
statusBar
->
setStyleSheet
(
"color: red"
);
}
void
DiotDiag
::
updateLabel
(
std
::
vector
<
QLabel
*>
labels
,
unsigned
int
idx
,
bool
state
,
const
QString
&
desc
,
int
val
)
{
...
...
sw/diot-sw/gui_demo/controller.h
View file @
71f1f8f9
...
...
@@ -30,6 +30,7 @@
class
DiotIOController
;
class
QLabel
;
class
QPushButton
;
class
QStatusBar
;
/**
* Class representing the DIOT crate hardware in the Qt world.
...
...
@@ -103,6 +104,13 @@ signals:
*/
void
VoltageChanged
(
unsigned
int
volt
,
bool
state
);
/**
* Signal emitted to update the data status.
* @param status is the new data status.
* @see enum mstrfip_data_status
*/
void
StatusChanged
(
int
status
);
private
:
std
::
unique_ptr
<
MasterFIP
>
mfip
;
std
::
unique_ptr
<
CycleSimple
>
cycle
;
...
...
@@ -200,6 +208,8 @@ public slots:
void
UpdateVoltage
(
unsigned
int
volt
,
bool
state
);
void
UpdateStatus
(
int
status
);
private
:
// Helper function to update labels
void
updateLabel
(
std
::
vector
<
QLabel
*>
labels
,
...
...
@@ -208,6 +218,7 @@ private:
std
::
vector
<
QLabel
*>
fan_lbl
;
std
::
vector
<
QLabel
*>
temp_lbl
;
std
::
vector
<
QLabel
*>
volt_lbl
;
QStatusBar
*
statusBar
;
};
#endif
/* CONTROLLER_H */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment