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
3558e53c
Commit
3558e53c
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 more data statistics
parent
3b322b93
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
4 deletions
+40
-4
controller.cpp
sw/diot-sw/gui_demo/controller.cpp
+35
-2
controller.h
sw/diot-sw/gui_demo/controller.h
+5
-2
No files found.
sw/diot-sw/gui_demo/controller.cpp
View file @
3558e53c
...
...
@@ -23,6 +23,16 @@
#include <QStatusBar>
#include "controller.h"
// Register custom type for Qt signals
static
struct
registerMetatypes
{
registerMetatypes
()
{
qRegisterMetaType
<
nanoFIP
::
DataStatusMap
>
(
"nanoFIP::DataStatusMap"
);
qRegisterMetaType
<
mstrfip_data_status
>
(
"mstrfip_data_status"
);
}
}
_registerMetatypes
;
DiotHardware
::
DiotHardware
(
int
address
,
int
slots_nr
)
{
// Configure MasterFIP
...
...
@@ -46,8 +56,9 @@ DiotHardware::DiotHardware(int address, int slots_nr)
crate
->
AddVariables
(
cycle
->
GetPeriodicVarWindow
());
crate
->
SetConsVarCb
([
&
](
nanoFIP
&
nf
,
mstrfip_data
*
data
)
{
emit
StatusChanged
(
data
->
status
);
emit
StatusChanged
(
data
->
status
,
nf
.
GetDataStats
()
);
// No more updates if the data is invalid
if
(
data
->
status
!=
MSTRFIP_DATA_OK
)
return
;
...
...
@@ -292,6 +303,20 @@ DiotDiag::DiotDiag(QWidget* parent, const DiotHardware& hw)
voltBox
->
setTitle
(
"Voltages"
);
voltBox
->
setLayout
(
voltLayout
);
statsLayout
->
addWidget
(
voltBox
);
// Data statistics
QGroupBox
*
statBox
=
new
QGroupBox
(
this
);
QVBoxLayout
*
statLayout
=
new
QVBoxLayout
();
for
(
const
auto
&
statType
:
hw
.
GetCrate
()
->
GetDataStats
())
{
auto
statWidget
=
new
QLabel
(
QString
(
"%1: 0"
)
.
arg
(
QString
::
fromStdString
(
nanoFIP
::
GetDataStatDesc
(
statType
.
first
))));
statLayout
->
addWidget
(
statWidget
);
stat_lbl
.
push_back
(
statWidget
);
}
statBox
->
setTitle
(
"Data statistics"
);
statBox
->
setLayout
(
statLayout
);
statsLayout
->
addWidget
(
statBox
);
mainLayout
->
addLayout
(
statsLayout
,
1
);
statusBar
=
new
QStatusBar
(
this
);
...
...
@@ -328,7 +353,8 @@ void DiotDiag::UpdateVoltage(unsigned int volt, bool state)
}
void
DiotDiag
::
UpdateStatus
(
int
status
)
void
DiotDiag
::
UpdateStatus
(
mstrfip_data_status
status
,
const
nanoFIP
::
DataStatusMap
&
stats
)
{
qDebug
()
<<
"status: "
<<
status
;
...
...
@@ -359,6 +385,13 @@ void DiotDiag::UpdateStatus(int status)
statusBar
->
setStyleSheet
(
"color: red"
);
parentWidget
()
->
setEnabled
(
false
);
}
for
(
const
auto
&
stat
:
stats
)
{
stat_lbl
[
static_cast
<
int
>
(
stat
.
first
)]
->
setText
(
QString
(
"%1: %2"
)
.
arg
(
QString
::
fromStdString
(
nanoFIP
::
GetDataStatDesc
(
stat
.
first
)))
.
arg
(
stat
.
second
));
}
}
...
...
sw/diot-sw/gui_demo/controller.h
View file @
3558e53c
...
...
@@ -107,9 +107,11 @@ signals:
/**
* Signal emitted to update the data status.
* @param status is the new data status.
* @param stats contains statistics.
* @see enum mstrfip_data_status
*/
void
StatusChanged
(
int
status
);
void
StatusChanged
(
mstrfip_data_status
status
,
const
nanoFIP
::
DataStatusMap
&
stats
);
private
:
std
::
unique_ptr
<
MasterFIP
>
mfip
;
...
...
@@ -208,7 +210,7 @@ public slots:
void
UpdateVoltage
(
unsigned
int
volt
,
bool
state
);
void
UpdateStatus
(
int
statu
s
);
void
UpdateStatus
(
mstrfip_data_status
status
,
const
nanoFIP
::
DataStatusMap
&
stat
s
);
private
:
// Helper function to update labels
...
...
@@ -218,6 +220,7 @@ private:
std
::
vector
<
QLabel
*>
fan_lbl
;
std
::
vector
<
QLabel
*>
temp_lbl
;
std
::
vector
<
QLabel
*>
volt_lbl
;
std
::
vector
<
QLabel
*>
stat_lbl
;
QStatusBar
*
statusBar
;
};
...
...
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