Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Qt CAN - Virtual test-bench tooling
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
5
Issues
5
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Qt CAN 2.0
Qt CAN - Virtual test-bench tooling
Commits
23ce4009
Commit
23ce4009
authored
Oct 05, 2018
by
Thomas BOUTROUE
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement routine for CANopen HB Consumer (plus visual delegate)
parent
69a1cd3f
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
133 additions
and
2 deletions
+133
-2
CanTestBench.qbs
CanTestBench.qbs
+1
-0
Manager.cpp
Manager.cpp
+8
-0
Manager.h
Manager.h
+2
-0
Routine.cpp
Routine.cpp
+51
-1
Routine.h
Routine.h
+32
-1
SharedObject.cpp
SharedObject.cpp
+1
-0
Components.qml
components/Components.qml
+1
-0
DelegateRoutineOnCanOpenHeartbeatConsumer.qml
components/DelegateRoutineOnCanOpenHeartbeatConsumer.qml
+35
-0
ui_testBench.qml
ui_testBench.qml
+2
-0
No files found.
CanTestBench.qbs
View file @
23ce4009
...
@@ -172,6 +172,7 @@ Project {
...
@@ -172,6 +172,7 @@ Project {
"components/DelegateRawNodeTable.qml",
"components/DelegateRawNodeTable.qml",
"components/DelegateRoutineOnCanFrame.qml",
"components/DelegateRoutineOnCanFrame.qml",
"components/DelegateRoutineOnCanOpenBootUp.qml",
"components/DelegateRoutineOnCanOpenBootUp.qml",
"components/DelegateRoutineOnCanOpenHeartbeatConsumer.qml",
"components/DelegateRoutineOnCanOpenNmtStateChange.qml",
"components/DelegateRoutineOnCanOpenNmtStateChange.qml",
"components/DelegateRoutineOnCanOpenObdValChange.qml",
"components/DelegateRoutineOnCanOpenObdValChange.qml",
"components/DelegateRoutineOnCanOpenSdoReadReply.qml",
"components/DelegateRoutineOnCanOpenSdoReadReply.qml",
...
...
Manager.cpp
View file @
23ce4009
...
@@ -289,6 +289,8 @@ void Manager::deinit (void) {
...
@@ -289,6 +289,8 @@ void Manager::deinit (void) {
m_routinesOnCanOpenObdValChange
.
clear
();
m_routinesOnCanOpenObdValChange
.
clear
();
m_routinesOnCanOpenSdoReadReply
.
clear
();
m_routinesOnCanOpenSdoReadReply
.
clear
();
m_routinesOnCanOpenSdoWriteRequest
.
clear
();
m_routinesOnCanOpenSdoWriteRequest
.
clear
();
m_routinesOnCanOpenBootUp
.
clear
();
m_routinesOnCanOpenHeartbeatConsumer
.
clear
();
m_links
.
clear
();
m_links
.
clear
();
m_linksAnalogActuatorToPhysicalValue
.
clear
();
m_linksAnalogActuatorToPhysicalValue
.
clear
();
m_linksAnalogOutputToAnalogActuator
.
clear
();
m_linksAnalogOutputToAnalogActuator
.
clear
();
...
@@ -864,6 +866,12 @@ void Manager::doInitObjects (void) {
...
@@ -864,6 +866,12 @@ void Manager::doInitObjects (void) {
else
if
(
RoutineOnCanOpenSdoWriteRequest
*
routineOnCanOpenSdoWriteRequest
=
routine
->
as
<
RoutineOnCanOpenSdoWriteRequest
>
())
{
else
if
(
RoutineOnCanOpenSdoWriteRequest
*
routineOnCanOpenSdoWriteRequest
=
routine
->
as
<
RoutineOnCanOpenSdoWriteRequest
>
())
{
m_routinesOnCanOpenSdoWriteRequest
.
append
(
routineOnCanOpenSdoWriteRequest
);
m_routinesOnCanOpenSdoWriteRequest
.
append
(
routineOnCanOpenSdoWriteRequest
);
}
}
else
if
(
RoutineOnCanOpenBootUp
*
routineOnCanOpenBootUp
=
routine
->
as
<
RoutineOnCanOpenBootUp
>
())
{
m_routinesOnCanOpenBootUp
.
append
(
routineOnCanOpenBootUp
);
}
else
if
(
RoutineOnCanOpenHeartbeatConsumer
*
routineOnCanOpenHeartbeatConsumer
=
routine
->
as
<
RoutineOnCanOpenHeartbeatConsumer
>
())
{
m_routinesOnCanOpenBootUp
.
append
(
routineOnCanOpenHeartbeatConsumer
);
}
else
{
}
else
{
}
usePath
=
true
;
usePath
=
true
;
}
}
...
...
Manager.h
View file @
23ce4009
...
@@ -98,6 +98,8 @@ class Manager : public QObject {
...
@@ -98,6 +98,8 @@ class Manager : public QObject {
QML_REFLIST_PROPERTY
(
RoutineOnCanOpenObdValChange
,
routinesOnCanOpenObdValChange
,
100
)
QML_REFLIST_PROPERTY
(
RoutineOnCanOpenObdValChange
,
routinesOnCanOpenObdValChange
,
100
)
QML_REFLIST_PROPERTY
(
RoutineOnCanOpenSdoReadReply
,
routinesOnCanOpenSdoReadReply
,
20
)
QML_REFLIST_PROPERTY
(
RoutineOnCanOpenSdoReadReply
,
routinesOnCanOpenSdoReadReply
,
20
)
QML_REFLIST_PROPERTY
(
RoutineOnCanOpenSdoWriteRequest
,
routinesOnCanOpenSdoWriteRequest
,
20
)
QML_REFLIST_PROPERTY
(
RoutineOnCanOpenSdoWriteRequest
,
routinesOnCanOpenSdoWriteRequest
,
20
)
QML_REFLIST_PROPERTY
(
RoutineOnCanOpenBootUp
,
routinesOnCanOpenBootUp
,
5
)
QML_REFLIST_PROPERTY
(
RoutineOnCanOpenHeartbeatConsumer
,
routinesOnCanOpenHeartbeatConsumer
,
5
)
QML_REFLIST_PROPERTY
(
PhysicalValue
,
physicalValues
,
500
)
QML_REFLIST_PROPERTY
(
PhysicalValue
,
physicalValues
,
500
)
QML_REFLIST_PROPERTY
(
PhysicalBlock
,
physicalBlocks
,
10
)
QML_REFLIST_PROPERTY
(
PhysicalBlock
,
physicalBlocks
,
10
)
QML_REFLIST_PROPERTY
(
PhysicalMarker
,
physicalMarkers
,
20
)
QML_REFLIST_PROPERTY
(
PhysicalMarker
,
physicalMarkers
,
20
)
...
...
Routine.cpp
View file @
23ce4009
...
@@ -385,7 +385,7 @@ RoutineOnCanOpenBootUp::~RoutineOnCanOpenBootUp (void) {
...
@@ -385,7 +385,7 @@ RoutineOnCanOpenBootUp::~RoutineOnCanOpenBootUp (void) {
void
RoutineOnCanOpenBootUp
::
prepare
(
void
)
{
void
RoutineOnCanOpenBootUp
::
prepare
(
void
)
{
if
(
get_canOpen
()
&&
!
m_canMgr
)
{
if
(
get_canOpen
()
&&
!
m_canMgr
)
{
if
((
m_canMgr
=
get_canOpen
()
->
getProtocolManager
()))
{
if
((
m_canMgr
=
get_canOpen
()
->
getProtocolManager
()))
{
connect
(
m_canMgr
.
data
(),
&
CanOpenProtocolManager
::
re
cvNodeHeartBeat
,
this
,
&
RoutineOnCanOpenBootUp
::
onRecvHeartbeatState
,
Qt
::
UniqueConnection
);
connect
(
m_canMgr
.
data
(),
&
CanOpenProtocolManager
::
re
moteNodeStateChanged
,
this
,
&
RoutineOnCanOpenBootUp
::
onRecvHeartbeatState
);
}
}
}
}
}
}
...
@@ -442,3 +442,53 @@ void RoutineOnSerialFrame::updateSubscription (void) {
...
@@ -442,3 +442,53 @@ void RoutineOnSerialFrame::updateSubscription (void) {
void
RoutineOnSerialFrame
::
trigger
(
void
)
{
void
RoutineOnSerialFrame
::
trigger
(
void
)
{
emit
triggered
();
emit
triggered
();
}
}
RoutineOnCanOpenHeartbeatConsumer
::
RoutineOnCanOpenHeartbeatConsumer
(
QObject
*
parent
)
:
AbstractCanOpenRoutine
(
Triggers
::
CANOPEN_HB_CONSUMER
,
parent
)
,
m_canMgr
(
Q_NULLPTR
)
,
m_currNodeId
(
0
)
,
m_currState
(
CanOpenHeartBeatStates
::
Initializing
)
,
m_currAlive
(
false
)
{
Manager
::
instance
().
registerObject
(
this
);
}
RoutineOnCanOpenHeartbeatConsumer
::~
RoutineOnCanOpenHeartbeatConsumer
(
void
)
{
Manager
::
instance
().
unregisterObject
(
this
);
}
void
RoutineOnCanOpenHeartbeatConsumer
::
prepare
(
void
)
{
if
(
get_canOpen
()
&&
!
m_canMgr
)
{
if
((
m_canMgr
=
get_canOpen
()
->
getProtocolManager
()))
{
connect
(
m_canMgr
.
data
(),
&
CanOpenProtocolManager
::
remoteNodeAliveChanged
,
this
,
&
RoutineOnCanOpenHeartbeatConsumer
::
onRemoteNodeAliveChanged
);
connect
(
m_canMgr
.
data
(),
&
CanOpenProtocolManager
::
remoteNodeStateChanged
,
this
,
&
RoutineOnCanOpenHeartbeatConsumer
::
onRemoteNodeStateChanged
);
}
}
}
void
RoutineOnCanOpenHeartbeatConsumer
::
cleanup
(
void
)
{
if
(
m_canMgr
)
{
disconnect
(
m_canMgr
.
data
(),
Q_NULLPTR
,
this
,
Q_NULLPTR
);
m_canMgr
.
clear
();
}
}
void
RoutineOnCanOpenHeartbeatConsumer
::
trigger
(
void
)
{
if
(
m_canMgr
)
{
emit
triggered
(
m_currNodeId
,
m_currAlive
,
m_currState
);
}
}
void
RoutineOnCanOpenHeartbeatConsumer
::
onRemoteNodeStateChanged
(
const
CanOpenNodeId
nodeId
,
const
CanOpenHeartBeatState
state
)
{
m_currNodeId
=
nodeId
;
m_currState
=
state
;
execute
();
}
void
RoutineOnCanOpenHeartbeatConsumer
::
onRemoteNodeAliveChanged
(
const
CanOpenNodeId
nodeId
,
const
bool
alive
)
{
m_currNodeId
=
nodeId
;
m_currAlive
=
alive
;
execute
();
}
Routine.h
View file @
23ce4009
...
@@ -24,6 +24,7 @@ QML_ENUM_CLASS (Triggers,
...
@@ -24,6 +24,7 @@ QML_ENUM_CLASS (Triggers,
CANOPEN_SDO_READ_REPLY
,
CANOPEN_SDO_READ_REPLY
,
CANOPEN_SDO_WRITE_REQUEST
,
CANOPEN_SDO_WRITE_REQUEST
,
CANOPEN_BOOTUP
,
CANOPEN_BOOTUP
,
CANOPEN_HB_CONSUMER
,
SERIAL_FRAME_RECV
,
SERIAL_FRAME_RECV
,
NB_TRIGGERS
)
NB_TRIGGERS
)
...
@@ -283,7 +284,7 @@ private:
...
@@ -283,7 +284,7 @@ private:
ByteArrayWrapper
*
m_currBuffer
;
ByteArrayWrapper
*
m_currBuffer
;
};
};
class
RoutineOnCanOpenBootUp
:
public
AbstractCanOpenRoutine
{
class
RoutineOnCanOpenBootUp
:
public
AbstractCanOpenRoutine
{
// DEPRECATED, use RoutineOnCanOpenHeartbeatConsumer
Q_OBJECT
Q_OBJECT
public
:
public
:
...
@@ -307,4 +308,34 @@ private:
...
@@ -307,4 +308,34 @@ private:
QPointer
<
CanOpenProtocolManager
>
m_canMgr
;
QPointer
<
CanOpenProtocolManager
>
m_canMgr
;
CanOpenNodeId
m_currNodeId
;
CanOpenNodeId
m_currNodeId
;
};
};
class
RoutineOnCanOpenHeartbeatConsumer
:
public
AbstractCanOpenRoutine
{
Q_OBJECT
public
:
explicit
RoutineOnCanOpenHeartbeatConsumer
(
QObject
*
parent
=
Q_NULLPTR
);
virtual
~
RoutineOnCanOpenHeartbeatConsumer
(
void
);
void
prepare
(
void
)
Q_DECL_FINAL
;
void
cleanup
(
void
)
Q_DECL_FINAL
;
protected
:
void
trigger
(
void
)
Q_DECL_FINAL
;
signals
:
void
triggered
(
const
int
nodeId
,
const
bool
alive
,
const
int
state
);
protected
slots
:
void
onRemoteNodeStateChanged
(
const
CanOpenNodeId
nodeId
,
const
CanOpenHeartBeatState
state
);
void
onRemoteNodeAliveChanged
(
const
CanOpenNodeId
nodeId
,
const
bool
alive
);
private
:
QPointer
<
CanOpenProtocolManager
>
m_canMgr
;
CanOpenNodeId
m_currNodeId
;
CanOpenHeartBeatState
m_currState
;
bool
m_currAlive
;
};
#endif // ABSTRACTROUTINE_H
#endif // ABSTRACTROUTINE_H
SharedObject.cpp
View file @
23ce4009
...
@@ -209,6 +209,7 @@ void SharedObject::registerQmlTypes (QQmlEngine * qmlEngine) {
...
@@ -209,6 +209,7 @@ void SharedObject::registerQmlTypes (QQmlEngine * qmlEngine) {
qmlRegisterType
<
RoutineOnCanOpenSdoReadReply
>
(
uri
,
maj
,
min
,
"RoutineOnCanOpenSdoReadReply"
);
qmlRegisterType
<
RoutineOnCanOpenSdoReadReply
>
(
uri
,
maj
,
min
,
"RoutineOnCanOpenSdoReadReply"
);
qmlRegisterType
<
RoutineOnCanOpenSdoWriteRequest
>
(
uri
,
maj
,
min
,
"RoutineOnCanOpenSdoWriteRequest"
);
qmlRegisterType
<
RoutineOnCanOpenSdoWriteRequest
>
(
uri
,
maj
,
min
,
"RoutineOnCanOpenSdoWriteRequest"
);
qmlRegisterType
<
RoutineOnCanOpenBootUp
>
(
uri
,
maj
,
min
,
"RoutineOnCanOpenBootUp"
);
qmlRegisterType
<
RoutineOnCanOpenBootUp
>
(
uri
,
maj
,
min
,
"RoutineOnCanOpenBootUp"
);
qmlRegisterType
<
RoutineOnCanOpenHeartbeatConsumer
>
(
uri
,
maj
,
min
,
"RoutineOnCanOpenHeartbeatConsumer"
);
qmlRegisterType
<
SerialBus
>
(
uri
,
maj
,
min
,
"SerialBus"
);
qmlRegisterType
<
SerialBus
>
(
uri
,
maj
,
min
,
"SerialBus"
);
qmlRegisterType
<
AffineTransformer
>
(
uri
,
maj
,
min
,
"AffineTransformer"
);
qmlRegisterType
<
AffineTransformer
>
(
uri
,
maj
,
min
,
"AffineTransformer"
);
qmlRegisterType
<
CustomTransformer
>
(
uri
,
maj
,
min
,
"CustomTransformer"
);
qmlRegisterType
<
CustomTransformer
>
(
uri
,
maj
,
min
,
"CustomTransformer"
);
...
...
components/Components.qml
View file @
23ce4009
...
@@ -31,6 +31,7 @@ QtObject {
...
@@ -31,6 +31,7 @@ QtObject {
readonly
property
Component
delegateRoutineOnCanFrame
:
Component
{
DelegateRoutineOnCanFrame
{
}
}
readonly
property
Component
delegateRoutineOnCanFrame
:
Component
{
DelegateRoutineOnCanFrame
{
}
}
readonly
property
Component
delegateRoutineOnSerialFrame
:
Component
{
DelegateRoutineOnSerialFrame
{
}
}
readonly
property
Component
delegateRoutineOnSerialFrame
:
Component
{
DelegateRoutineOnSerialFrame
{
}
}
readonly
property
Component
delegateRoutineOnCanOpenBootUp
:
Component
{
DelegateRoutineOnCanOpenBootUp
{
}
}
readonly
property
Component
delegateRoutineOnCanOpenBootUp
:
Component
{
DelegateRoutineOnCanOpenBootUp
{
}
}
readonly
property
Component
delegateRoutineOnCanOpenHeartbeatConsumer
:
Component
{
DelegateRoutineOnCanOpenHeartbeatConsumer
{
}
}
readonly
property
Component
delegateRoutineOnCanOpenObdValChange
:
Component
{
DelegateRoutineOnCanOpenObdValChange
{
}
}
readonly
property
Component
delegateRoutineOnCanOpenObdValChange
:
Component
{
DelegateRoutineOnCanOpenObdValChange
{
}
}
readonly
property
Component
delegateRoutineOnCanOpenNmtStateChange
:
Component
{
DelegateRoutineOnCanOpenNmtStateChange
{
}
}
readonly
property
Component
delegateRoutineOnCanOpenNmtStateChange
:
Component
{
DelegateRoutineOnCanOpenNmtStateChange
{
}
}
readonly
property
Component
delegateRoutineOnCanOpenSdoReadReply
:
Component
{
DelegateRoutineOnCanOpenSdoReadReply
{
}
}
readonly
property
Component
delegateRoutineOnCanOpenSdoReadReply
:
Component
{
DelegateRoutineOnCanOpenSdoReadReply
{
}
}
...
...
components/DelegateRoutineOnCanOpenHeartbeatConsumer.qml
0 → 100644
View file @
23ce4009
import
QtQuick
2.1
;
import
QtQmlTricks
.
UiElements
2.0
;
import
QtCAN
.
CanTestBench
2.0
;
AbstractDelegateRoutine
{
id
:
base
;
property
RoutineOnCanOpenHeartbeatConsumer
routineOnCanOpenHeartbeatConsumer
:
null
;
property
alias
routine
:
base
.
routineOnCanOpenHeartbeatConsumer
;
StretchRowContainer
{
spacing
:
Style
.
spacingNormal
;
TextLabel
{
text
:
(
routineOnCanOpenHeartbeatConsumer
?
routineOnCanOpenHeartbeatConsumer
.
uid
:
""
);
emphasis
:
true
;
anchors.verticalCenter
:
parent
.
verticalCenter
;
}
TextLabel
{
text
:
(
routineOnCanOpenHeartbeatConsumer
?
"("
+
routineOnCanOpenHeartbeatConsumer
.
title
+
")"
:
""
);
visible
:
(
text
!==
""
&&
text
!==
"()"
);
anchors.verticalCenter
:
parent
.
verticalCenter
;
}
Stretcher
{
}
}
StretchRowContainer
{
spacing
:
Style
.
spacingNormal
;
TextLabel
{
text
:
qsTr
(
"triggered on CANopen Heartbeat Consumer change"
);
anchors.verticalCenter
:
parent
.
verticalCenter
;
}
}
}
ui_testBench.qml
View file @
23ce4009
...
@@ -1240,6 +1240,8 @@ Item {
...
@@ -1240,6 +1240,8 @@ Item {
return
Components
.
delegateRoutineOnCanOpenSdoWriteRequest
;
return
Components
.
delegateRoutineOnCanOpenSdoWriteRequest
;
case
Triggers.CANOPEN_BOOTUP
:
case
Triggers.CANOPEN_BOOTUP
:
return
Components
.
delegateRoutineOnCanOpenBootUp
;
return
Components
.
delegateRoutineOnCanOpenBootUp
;
case
Triggers.CANOPEN_HB_CONSUMER
:
return
Components
.
delegateRoutineOnCanOpenHeartbeatConsumer
;
}
}
return
null
;
return
null
;
}
}
...
...
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