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
108f37ce
Commit
108f37ce
authored
Aug 15, 2018
by
Projects
Committed by
Grzegorz Daniluk
Aug 20, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
GUI support for input errors
parent
5de76bf4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
9 deletions
+59
-9
controller.cpp
sw/diot-sw/gui_demo/controller.cpp
+47
-8
controller.h
sw/diot-sw/gui_demo/controller.h
+12
-1
No files found.
sw/diot-sw/gui_demo/controller.cpp
View file @
108f37ce
...
...
@@ -51,6 +51,11 @@ DiotHardware::DiotHardware(int address, int slots_nr)
for
(
int
i
=
0
;
i
<
crate
->
GetCardCount
();
++
i
)
{
emit
InputChanged
(
i
,
crate
->
GetSlotInputs
(
i
));
uint32_t
inpError
=
crate
->
GetSlotInputErrs
(
i
);
if
(
inpError
)
{
emit
InputErrChanged
(
i
,
inpError
);
}
}
for
(
unsigned
int
i
=
0
;
i
<
crate
->
GetFanCount
();
++
i
)
{
...
...
@@ -86,9 +91,13 @@ DiotIOCard::DiotIOCard(QDialog* parent, DiotHardware& hw, int num, int idx)
outputs
(
num
,
false
),
slot_nr
(
idx
),
io_count
(
num
)
{
QHBoxLayout
*
mainLayout
=
new
QHBoxLayout
();
QGridLayout
*
grid
=
new
QGridLayout
();
QGroupBox
*
groupBox
=
new
QGroupBox
(
this
);
grid
->
setColumnStretch
(
0
,
0
);
grid
->
setColumnStretch
(
1
,
1
);
grid
->
setColumnStretch
(
2
,
1
);
QGroupBox
*
groupBox
=
new
QGroupBox
(
this
);
groupBox
->
setTitle
(
QString
(
"Slot %1"
).
arg
(
idx
+
1
));
for
(
int
i
=
0
;
i
<
io_count
;
++
i
)
{
...
...
@@ -98,21 +107,32 @@ DiotIOCard::DiotIOCard(QDialog* parent, DiotHardware& hw, int num, int idx)
grid
->
addWidget
(
state
,
i
,
0
);
lbl_state
.
push_back
(
state
);
QPushButton
*
test
=
new
QPushButton
(
groupBox
);
test
->
set
Text
(
"Test"
);
QPushButton
*
test
=
new
QPushButton
(
"Test"
,
groupBox
);
test
->
set
FixedWidth
(
50
);
grid
->
addWidget
(
test
,
i
,
1
);
QObject
::
connect
(
test
,
&
QPushButton
::
clicked
,
[
=
](){
action_click
(
idx
,
i
);
});
[
=
](){
testBtn_click
(
idx
,
i
);
});
QPushButton
*
clearErr
=
new
QPushButton
(
""
,
groupBox
);
clearErr
->
setFixedWidth
(
70
);
clearErr
->
setStyleSheet
(
"color: red"
);
// "Clear Error" button is reenabled when an error occurs
clearErr
->
setEnabled
(
false
);
grid
->
addWidget
(
clearErr
,
i
,
2
);
btn_clrerr
.
push_back
(
clearErr
);
QObject
::
connect
(
clearErr
,
&
QPushButton
::
clicked
,
[
=
](){
clearErr
->
setEnabled
(
false
);
clearErr
->
setText
(
""
);
});
}
groupBox
->
setLayout
(
grid
);
mainLayout
->
addWidget
(
groupBox
);
setLayout
(
mainLayout
);
update_inputs
();
QObject
::
connect
(
this
,
&
DiotIOCard
::
InputChanged
,
[
=
](){
update_inputs
();
});
QObject
::
connect
(
this
,
&
DiotIOCard
::
OutputChanged
,
&
hw
,
&
DiotHardware
::
SetOutput
);
update_inputs
();
QObject
::
connect
(
this
,
&
DiotIOCard
::
OutputChanged
,
&
hw
,
&
DiotHardware
::
SetOutput
);
}
...
...
@@ -122,13 +142,23 @@ void DiotIOCard::SetInput(unsigned int state) {
}
void
DiotIOCard
::
SetInputErr
(
unsigned
int
state
)
{
for
(
unsigned
int
i
=
0
;
i
<
btn_clrerr
.
size
();
++
i
)
{
if
(
state
&
(
1
<<
i
))
{
btn_clrerr
[
i
]
->
setEnabled
(
true
);
btn_clrerr
[
i
]
->
setText
(
"Clear Error"
);
}
}
}
void
DiotIOCard
::
SetOutput
(
unsigned
int
state
)
{
if
(
int_to_vec
(
state
,
outputs
))
emit
OutputChanged
(
slot_nr
,
state
);
}
void
DiotIOCard
::
actio
n_click
(
int
slot
,
int
io
)
{
void
DiotIOCard
::
testBt
n_click
(
int
slot
,
int
io
)
{
qDebug
()
<<
"button test clicked - slot("
<<
slot
<<
") io("
<<
io
<<
")"
;
outputs
[
io
]
=
!
outputs
[
io
];
emit
OutputChanged
(
slot_nr
,
GetOutput
());
...
...
@@ -195,6 +225,8 @@ DiotIOController::DiotIOController(QDialog* dialog, DiotHardware& hw, int slots_
QObject
::
connect
(
&
hw
,
&
DiotHardware
::
InputChanged
,
this
,
&
DiotIOController
::
UpdateInput
);
QObject
::
connect
(
&
hw
,
&
DiotHardware
::
InputErrChanged
,
this
,
&
DiotIOController
::
UpdateInputErr
);
}
...
...
@@ -205,6 +237,13 @@ void DiotIOController::UpdateInput(int slot, unsigned int state)
}
void
DiotIOController
::
UpdateInputErr
(
int
slot
,
unsigned
int
state
)
{
qDebug
()
<<
"received input err update: slot "
<<
slot
<<
"="
<<
state
;
io_slots
[
slot
]
->
SetInputErr
(
state
);
}
DiotDiag
::
DiotDiag
(
QDialog
*
parent
,
DiotHardware
&
hw
)
:
QFrame
(
parent
)
{
...
...
sw/diot-sw/gui_demo/controller.h
View file @
108f37ce
...
...
@@ -73,6 +73,13 @@ signals:
*/
void
InputChanged
(
int
slot
,
unsigned
int
state
);
/**
* Signal emitted whenever an input error occurs.
* @param slot is the card number (indexing from 0).
* @param state is the inputs state.
*/
void
InputErrChanged
(
int
slot
,
unsigned
int
state
);
/**
* Signal emitted on every macrocycle, provides information about fan state.
* @param fan is the fan number (indexing from 0).
...
...
@@ -126,14 +133,16 @@ public:
public
slots
:
void
SetInput
(
unsigned
int
state
);
void
SetInputErr
(
unsigned
int
state
);
void
SetOutput
(
unsigned
int
state
);
signals
:
void
InputChanged
(
int
slot
,
unsigned
int
state
);
void
InputErrChanged
(
int
slot
,
unsigned
int
state
);
void
OutputChanged
(
int
slot
,
unsigned
int
state
);
protected
:
void
actio
n_click
(
int
slot
,
int
io
);
void
testBt
n_click
(
int
slot
,
int
io
);
void
update_inputs
();
void
update_outputs
(
int
slot
);
...
...
@@ -142,6 +151,7 @@ protected:
std
::
vector
<
bool
>
inputs
,
outputs
;
std
::
vector
<
QLabel
*>
lbl_state
;
std
::
vector
<
QPushButton
*>
btn_clrerr
;
const
int
slot_nr
;
const
int
io_count
;
};
...
...
@@ -158,6 +168,7 @@ public:
public
slots
:
void
UpdateInput
(
int
slot
,
unsigned
int
state
);
void
UpdateInputErr
(
int
slot
,
unsigned
int
state
);
private
:
std
::
vector
<
std
::
unique_ptr
<
DiotIOCard
>>
io_slots
;
...
...
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