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
59cfc426
Commit
59cfc426
authored
Aug 13, 2018
by
Projects
Committed by
Grzegorz Daniluk
Aug 16, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Display diagnostic data
parent
6224aa4b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
145 additions
and
1 deletion
+145
-1
controller.cpp
sw/diot-sw/gui_demo/controller.cpp
+101
-1
controller.h
sw/diot-sw/gui_demo/controller.h
+41
-0
main.cpp
sw/diot-sw/gui_demo/main.cpp
+3
-0
No files found.
sw/diot-sw/gui_demo/controller.cpp
View file @
59cfc426
...
...
@@ -20,6 +20,7 @@
#include <QtWidgets/QDialog>
#include <QtWidgets/QGroupBox>
#include <QBoxLayout>
#include <QLabel>
#include "controller.h"
DiotSlot
::
DiotSlot
(
QDialog
*
parent
,
DiotController
&
controller
,
int
num
,
int
idx
)
...
...
@@ -121,6 +122,93 @@ bool DiotSlot::int_to_vec(unsigned int integer, std::vector<bool>& vec)
}
DiotDiag
::
DiotDiag
(
QDialog
*
parent
,
DiotController
&
controller
)
:
QFrame
(
parent
)
{
DIOT_Crate
*
crate
=
controller
.
GetCrate
();
QHBoxLayout
*
mainLayout
=
new
QHBoxLayout
();
// Fans
QGroupBox
*
fanBox
=
new
QGroupBox
(
this
);
QVBoxLayout
*
fanLayout
=
new
QVBoxLayout
();
for
(
unsigned
int
i
=
0
;
i
<
crate
->
GetFanCount
();
++
i
)
{
auto
fanWidget
=
new
QLabel
(
QString
(
"Fan %1"
).
arg
(
i
+
1
),
fanBox
);
fanLayout
->
addWidget
(
fanWidget
);
fan_lbl
.
push_back
(
fanWidget
);
}
fanBox
->
setTitle
(
"Fans"
);
fanBox
->
setLayout
(
fanLayout
);
mainLayout
->
addWidget
(
fanBox
);
// Temperature sensors
QGroupBox
*
tempBox
=
new
QGroupBox
(
this
);
QVBoxLayout
*
tempLayout
=
new
QVBoxLayout
();
for
(
unsigned
int
i
=
0
;
i
<
crate
->
GetTempCount
();
++
i
)
{
auto
tempWidget
=
new
QLabel
(
QString
(
"Temperature %1"
).
arg
(
i
+
1
),
tempBox
);
tempLayout
->
addWidget
(
tempWidget
);
temp_lbl
.
push_back
(
tempWidget
);
}
tempBox
->
setTitle
(
"Temperature"
);
tempBox
->
setLayout
(
tempLayout
);
mainLayout
->
addWidget
(
tempBox
);
// Voltages
QGroupBox
*
voltBox
=
new
QGroupBox
(
this
);
QVBoxLayout
*
voltLayout
=
new
QVBoxLayout
();
const
auto
&
voltages
=
crate
->
GetVoltages
();
for
(
unsigned
int
i
=
0
;
i
<
voltages
.
size
();
++
i
)
{
auto
voltageWidget
=
new
QLabel
(
QString
::
fromStdString
(
voltages
[
i
].
second
),
voltBox
);
voltLayout
->
addWidget
(
voltageWidget
);
volt_lbl
.
push_back
(
voltageWidget
);
}
voltBox
->
setTitle
(
"Voltages"
);
voltBox
->
setLayout
(
voltLayout
);
mainLayout
->
addWidget
(
voltBox
);
setLayout
(
mainLayout
);
QObject
::
connect
(
&
controller
,
&
DiotController
::
FanChanged
,
this
,
&
DiotDiag
::
UpdateFan
);
QObject
::
connect
(
&
controller
,
&
DiotController
::
TemperatureChanged
,
this
,
&
DiotDiag
::
UpdateTemperature
);
QObject
::
connect
(
&
controller
,
&
DiotController
::
VoltageChanged
,
this
,
&
DiotDiag
::
UpdateVoltage
);
}
void
DiotDiag
::
UpdateVoltage
(
unsigned
int
volt
,
bool
state
)
{
QLabel
*
label
=
volt_lbl
[
volt
];
auto
volt_enum
=
DIOT_Crate
::
GetVoltEnum
(
volt
);
if
(
state
)
{
label
->
setStyleSheet
(
"color: green"
);
label
->
setText
(
QString
(
"%1 OK"
).
arg
(
QString
::
fromStdString
(
DIOT_Crate
::
GetVoltName
(
volt_enum
))));
}
else
{
label
->
setStyleSheet
(
"color: red"
);
label
->
setText
(
QString
(
"%1 ERR"
).
arg
(
QString
::
fromStdString
(
DIOT_Crate
::
GetVoltName
(
volt_enum
))));
}
}
void
DiotDiag
::
updateLabel
(
std
::
vector
<
QLabel
*>
labels
,
unsigned
int
idx
,
bool
state
,
const
QString
&
desc
,
int
val
)
{
if
(
idx
>=
labels
.
size
())
return
;
// TODO assert?
QLabel
*
label
=
labels
[
idx
];
if
(
state
)
{
label
->
setStyleSheet
(
"color: green"
);
label
->
setText
(
QString
(
"%1 %2 OK: %3"
).
arg
(
desc
).
arg
(
idx
+
1
).
arg
(
val
));
}
else
{
label
->
setStyleSheet
(
"color: red"
);
label
->
setText
(
QString
(
"%1 %2 ERR: %3"
).
arg
(
desc
).
arg
(
idx
+
1
).
arg
(
val
));
}
}
DiotController
::
DiotController
(
QDialog
*
dialog
,
int
address
,
int
slots_nr
)
:
QFrame
(
dialog
)
{
...
...
@@ -155,12 +243,24 @@ DiotController::DiotController(QDialog* dialog, int address, int slots_nr)
crate
->
AddVariables
(
cycle
->
GetPeriodicVarWindow
());
crate
->
SetConsVarCb
([
&
](
nanoFIP
&
nf
)
{
// Report the
inputs
state
// Report the
crate
state
DIOT_Crate
*
crate
=
static_cast
<
DIOT_Crate
*>
(
&
nf
);
for
(
int
i
=
0
;
i
<
crate
->
GetCardCount
();
++
i
)
{
emit
InputChanged
(
i
,
crate
->
GetSlotInputs
(
i
));
}
for
(
unsigned
int
i
=
0
;
i
<
crate
->
GetFanCount
();
++
i
)
{
emit
FanChanged
(
i
,
crate
->
GetFanStatus
(
i
),
crate
->
GetFanRPM
(
i
));
}
for
(
unsigned
int
i
=
0
;
i
<
crate
->
GetTempCount
();
++
i
)
{
emit
TemperatureChanged
(
i
,
crate
->
GetTempStatus
(
i
),
crate
->
GetTemp
(
i
));
}
for
(
unsigned
int
i
=
0
;
i
<
crate
->
GetVoltages
().
size
();
++
i
)
{
emit
VoltageChanged
(
i
,
crate
->
GetVoltStatus
(
crate
->
GetVoltEnum
(
i
)));
}
}
);
QObject
::
connect
(
this
,
&
DiotController
::
InputChanged
,
...
...
sw/diot-sw/gui_demo/controller.h
View file @
59cfc426
...
...
@@ -29,6 +29,7 @@
class
DiotController
;
class
QDialog
;
class
QLabel
;
class
QPushButton
;
class
DiotSlot
:
public
QFrame
{
...
...
@@ -70,6 +71,36 @@ protected:
};
class
DiotDiag
:
public
QFrame
{
Q_OBJECT
public
:
DiotDiag
(
QDialog
*
parent
,
DiotController
&
controller
);
virtual
~
DiotDiag
()
{}
public
slots
:
void
UpdateFan
(
unsigned
int
fan
,
bool
state
,
int
rpm
)
{
updateLabel
(
fan_lbl
,
fan
,
state
,
"Fan"
,
rpm
);
}
void
UpdateTemperature
(
unsigned
int
sensor
,
bool
state
,
int
temp
)
{
updateLabel
(
temp_lbl
,
sensor
,
state
,
"Temperature"
,
temp
);
}
void
UpdateVoltage
(
unsigned
int
volt
,
bool
state
);
private
:
void
updateLabel
(
std
::
vector
<
QLabel
*>
labels
,
unsigned
int
idx
,
bool
state
,
const
QString
&
desc
,
int
val
);
std
::
vector
<
QLabel
*>
fan_lbl
;
std
::
vector
<
QLabel
*>
temp_lbl
;
std
::
vector
<
QLabel
*>
volt_lbl
;
};
class
DiotController
:
public
QFrame
{
Q_OBJECT
...
...
@@ -77,15 +108,25 @@ public:
DiotController
(
QDialog
*
dialog
,
int
address
,
int
slots_nr
);
void
Start
();
DIOT_Crate
*
GetCrate
()
const
{
return
crate
.
get
();
}
public
slots
:
void
UpdateInput
(
int
slot
,
unsigned
int
state
);
void
SetOutput
(
int
slot
,
unsigned
int
state
);
signals
:
void
InputChanged
(
int
slot
,
unsigned
int
state
);
void
FanChanged
(
unsigned
int
fan
,
bool
state
,
int
rpm
);
void
TemperatureChanged
(
unsigned
int
sensor
,
bool
state
,
int
temp
);
void
VoltageChanged
(
unsigned
int
volt
,
bool
state
);
private
:
std
::
vector
<
std
::
unique_ptr
<
DiotSlot
>>
io_slots
;
// TODO DIOT_Crate related classes should be moved out of this class
std
::
unique_ptr
<
MasterFIP
>
mfip
;
std
::
unique_ptr
<
CycleSimple
>
cycle
;
std
::
unique_ptr
<
DIOT_Crate
>
crate
;
...
...
sw/diot-sw/gui_demo/main.cpp
View file @
59cfc426
...
...
@@ -74,6 +74,9 @@ int main( int argc, char **argv ) {
DiotController
*
controller
=
new
DiotController
(
&
w
,
address
,
slots_nr
);
mainLayout
->
addWidget
(
controller
);
DiotDiag
*
diag
=
new
DiotDiag
(
&
w
,
*
controller
);
mainLayout
->
addWidget
(
diag
);
w
.
setLayout
(
mainLayout
);
w
.
show
();
controller
->
Start
();
...
...
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