SlideShare a Scribd company logo
1 of 27
Hexagonal
Architecture:
The Standard
for Qt
Embedded
HMIs
Burkhard Stubert
Good, Right and Successful Architectures
All architectures
Good architectures
Technically sound
Right architectures
Meeting stakeholder needs
Successful architectures
Delivering value
Hexagonal
Architecture
Start with de-facto standard
architecture and adapt it!
2021/07/08 (C) Burkhard Stubert 2
Ports-and-Adapters
Architecture
About the Importance of Architecture
2021/11/04 (C) Burkhard Stubert 3
2012
2021?
Architecture is like an iceberg. Only 1/10 is visible.
The Titanic disaster teaches us what happens
when we ignore the other 9/10.
Yours truly
Agenda
• Ports-and-Adapters Architecture
• Significant Requirements
• Machine Component
• Business Logic
• GUI Component
• Creating the Hexagon
• Conclusion
2021/11/04 (C) Burkhard Stubert 4
Ports-And-Adapters Architecture: Idea
USB
CAN
RS232
UART
(W)LAN
HDMI
PC
Port
Adapters
• Standardised USB Port
• Many USB-to-X adapters
• Different companies can build
different adapters
2021/11/04 (C) Burkhard Stubert 5
Ports-And-Adapters Architecture: Pattern
• Port = Interface between BL
(inside) and Adapters (outside)
• Adapter = Uses or implements
Port
• 1 Port has N Adapters
• Port same for all adapters
• Code from inside must not leak
to outside and vice versa
• Inside: models, connections
• Outside: Qt SerialBus, SQL, IPC
2021/11/04 (C) Burkhard Stubert 6
Business Logic
(BL)
GuiPort
MachinePort
GUI Test
Machine Simulator Mock
CLI
Product Versions over Time
2021/11/04 (C) Burkhard Stubert 7
Business
Logic
GUI
Machine
CAN
Business
Logic
GUI
Machine
Ethernet
Business
Logic
GUI
Machine
(IPC)
Product v0 Product v1 Product v2
• OTA Updates
• Ethernet instead of CAN
• Remote diagnostic
and support
• Message processing
in separate process
Development and Test Versions
2021/11/04 (C) Burkhard Stubert 8
Business
Logic
GUI
Test
Machine
Mock
Development Testing GUI
in system context
Business
Logic
GUI
Machine
Simulator
Business
Logic
GUI
Mock
Machine
Mock
Testing Updates
in system context
Agenda
• Ports-and-Adapters Architecture
• Significant Requirements
• Machine Component
• Business Logic
• GUI Component
• Creating the Hexagon
• Conclusion
2021/11/04 (C) Burkhard Stubert 9
Application Hexagon
Architecturally Significant Requirements
2021/11/04 (C) Burkhard Stubert 10
Engine
ECU
Machine
EngineTwin
BL
MainModel
GUI
MainView
Driver
CAN
Frame
Quantity
Object
Quantity 930 rpm
• Requirement
• GUI shows current engine speed.
• Constraints
• Neither GUI nor BL know that
Machine uses CAN
• BL provides C++ models for QML GUI
• GUI must not depend on Machine
Agenda
• Ports-and-Adapters Architecture
• Significant Requirements
• Machine Component
• Business Logic
• GUI Component
• Creating the Hexagon
• Conclusion
2021/11/04 (C) Burkhard Stubert 11
Machine Port with Product Adapter (CAN)
2021/11/04 (C) Burkhard Stubert 12
In product_machine.h:
QCanBusDevice *m_canBus{QCanBus::instance()
->createDevice("socketcan", "can0")};
CanBusRouter m_router{m_canBus};
EngineTwin m_engine;
In product_machine.cpp:
ProductMachine::ProductMachine()
: Machine{}
{
QObject::connect(
&m_router, &CanBusRouter::newEngineQuantities,
&m_engine, &EngineTwin::updateQuantities);
In BusinessLogic:
Machine::engine()
Engine ECU
QCanBusDevice
CanBusRouter
EngineTwin
Business Logic
can0
Machine
SocketCAN frame
QCanBusFrame
Quantity
Quantity
Quantity
Machine Port with Simulator Adapter
2021/11/04 (C) Burkhard Stubert 13
In simulator_machine.h:
CanBusSimulator m_simulator;
MockCanBusDevice m_canBus;
CanBusRouter m_router{&m_canBus};
EngineTwin m_engine;
In simulator_machine.cpp:
SimulatorMachine::SimulatorMachine()
: Machine{}
{
QObject::connect(
&m_simulator, &CanBusSimulator::newIncomingFrames,
&m_canBus, &EngineTwin::appendIncomingFrames);
QObject::connect(
&m_router, &CanBusRouter::newEngineQuantities,
&m_engine, &EngineTwin::updateQuantities);
In BusinessLogic:
Machine::engine()
CanBusSimulator
MockCanBusDevice
CanBusRouter
EngineTwin
Business Logic
Machine
QCanBusFrame
QCanBusFrame
Quantity
Quantity
Quantity
Test Adapter
2021/11/04 (C) Burkhard Stubert 14
In Machine Test:
Machine::engine()
MockCanBusDevice
CanBusRouter
EngineTwin
Machine Test
Machine
QCanBusFrame
QCanBusFrame
Quantity
Quantity
Quantity
Product Adapter (MQTT)
In BusinessLogic:
Machine::engine()
Engine ECU
QNetworkInterface
MqttRouter
EngineTwin
Business Logic
eth0
Machine
MQTT frame
QMqttMessage
Quantity
Quantity
Quantity
Creating the Machine Component
2021/11/04 (C) Burkhard Stubert 15
In machine_creator.cpp:
Machine *createMachine(Machine::Configuration conf)
{
switch (conf) {
case Machine::Configuration::Product:
return new ProductMachine{};
case Machine::Configuration::Simulator:
return new SimulatorMachine{};
...
Use createMachine in main()
Running Adapter in Thread, Process, MCU
Business Logic
MachinePort
Qt CanBus
can0 can1
Business Logic
MachinePort
Qt CanBus
can0 can1
Thread
CAN0
Thread
CAN1
Qt Signal-Slot Conn.
Business Logic
MachinePort
CAN Bus
can0 can1
Thread
CAN0
Thread
CAN1
Qt Remote
Objects
Task
CAN0
Task
CAN1
RPMsg
Process
1
on
A53
Process
1
on
A53
Process
2
on
A53
Process
1
on
A53
2
Tasks
on
M4
2021/11/04 (C) Burkhard Stubert 16
Agenda
• Ports-and-Adapters Architecture
• Significant Requirements
• Machine Component
• Business Logic
• GUI Component
• Creating the Hexagon
• Conclusion
2021/11/04 (C) Burkhard Stubert 17
Business Logic
2021/11/04 (C) Burkhard Stubert 18
In business_logic.h:
Q_PROPERTY(MainModel *mainModel READ mainModel CONSTANT)
BusinessLogic(std::shared_ptr<Machine> machine, ...
, m_machine{machine}
In business_logic.cpp:
MainModel *BusinessLogic::mainModel()
{
if (m_mainModel == nullptr) {
m_mainModel = new MainModel{this};
connect(m_machine->engine(), &EngineTwin::engineSpeed,
m_mainModel, &MainModel::setEngineSpeed);
}
return m_mainModel;
}
In MainView.qml:
BusinessLogic.mainModel
GUI
Business Logic
Machine
EngineTwin
MainModel
BusinessLogic available
as singleton in GUI
with models as properties
if (m_mainModel == nullptr) { m_mainModel = new MainModel{this}; connect(m_machine->engine(), &EngineTwin::engineSpeed, m_mainModel, &MainModel::setEngineSpeed); } return m_mainModel;
Agenda
• Ports-and-Adapters Architecture
• Significant Requirements
• Machine Component
• Business Logic
• GUI Component
• Creating the Hexagon
• Conclusion
2021/11/04 (C) Burkhard Stubert 19
GUI with Product Adapter (QML GUI)
2021/11/04 (C) Burkhard Stubert 20
In MainView.qml:
import EmUse.Models
Pane
{
property MainModel model: BusinessLogic.mainModel
Text
{
text: Number(model.engineSpeed.value).toFixed(0)
}
Text
{
text: model.engineSpeed.unit
}
MainView
Business Logic
Machine
EngineTwin
MainModel
GUI Port with Test Adapter
2021/11/04 (C) Burkhard Stubert 21
void TestMainView::init()
{
m_machine = std::make_shared<Machine>(
createMachine(Machine::Configuration::Mock));
m_businessLogic = new BusinessLogic{m_machine};
m_model = m_businessLogic->mainModel();
}
void TestMainView::testEngineSpeed()
{
Quantity rpm{930.0, "rpm"};
emit m_machine->engine()->engineSpeed(rpm);
QCOMPARE(m_model->engineSpeed()->quantity(), rpm);
}
TestMainView
Business Logic
Machine
EngineTwin
MainModel
Testing GUI in system context
• with actual BusinessLogic
• with mocks for Machine objects
Mocks reused from unit tests of
Machine and EngineTwin
Agenda
• Ports-and-Adapters Architecture
• Significant Requirements
• Machine Component
• Business Logic
• GUI Component
• Creating the Hexagon
• Conclusion
2021/11/04 (C) Burkhard Stubert 22
Composition Root main()
2021/11/04 (C) Burkhard Stubert 23
int main(int argc, char *argv[])
{
std::shared_ptr<Machine> machine{
createMachine(Machine::Configuration::Product);
};
std::shared_ptr<BusinessLogic> businessLogic{
new BusinessLogic{machine}
};
QQmlApplicationEngine appEngine;
appEngine.load(u"qrc:/main.qml"_qs);
return app.exec();
}
Agenda
• Ports-and-Adapters Architecture
• Significant Requirements
• Machine Component
• Business Logic
• GUI Component
• Creating the Hexagon
• Conclusion
2021/11/04 (C) Burkhard Stubert 24
Pros and Cons of Hexagonal Architecture
• High testability
• High modularity
• High modifiability
• High maintainability
2021/11/04 (C) Burkhard Stubert 25
Pros
• Additional complexity
Cons
Succesful architecture for Qt embedded HMIs:
Hexagonal Architecture
Resources
• Alistair Cockburn: Hexagonal Architecture. Original description of the
Hexagonal Architecture pattern.
• Juan Manuel Garrido de Paz: Ports and Adapters Pattern (Hexagonal
Architecture). Detailed explanation of the pattern.
• Burkhard Stubert: A Successful Architecture for Qt Embedded
Systems. My talk at QtDay Italy 2021.
• Burkhard Stubert: Source code for this talk.
2021/11/04 (C) Burkhard Stubert 26
🙏 Thank You 🙏
Mail: burkhard.stubert@embeddeduse.com
Web: https://embeddeduse.com
Newsletter: http://eepurl.com/gOMQoX

More Related Content

Similar to Hexagonal Architecture: The Standard for Qt Embedded HMIs

CURRICULUM VITAE_Balu
CURRICULUM VITAE_BaluCURRICULUM VITAE_Balu
CURRICULUM VITAE_Balubalakrishna H
 
CADISON world Issue-1-2013
CADISON world Issue-1-2013CADISON world Issue-1-2013
CADISON world Issue-1-2013CADISON
 
Bikram Jeet (Achievements from 2006 - 2013)
Bikram Jeet (Achievements from 2006 - 2013)Bikram Jeet (Achievements from 2006 - 2013)
Bikram Jeet (Achievements from 2006 - 2013)Bikram Jeet
 
Cadison world-issue-01-2013
Cadison world-issue-01-2013Cadison world-issue-01-2013
Cadison world-issue-01-2013CADISON
 
OpenMP-OpenACC-Offload-Cauldron2022-1.pdf
OpenMP-OpenACC-Offload-Cauldron2022-1.pdfOpenMP-OpenACC-Offload-Cauldron2022-1.pdf
OpenMP-OpenACC-Offload-Cauldron2022-1.pdfssuser866937
 
ECAD-MCAD Presentation 2011
ECAD-MCAD Presentation 2011ECAD-MCAD Presentation 2011
ECAD-MCAD Presentation 2011Altium
 
A Browser for the Automotive: Introduction to WebKit for Wayland (Automotive ...
A Browser for the Automotive: Introduction to WebKit for Wayland (Automotive ...A Browser for the Automotive: Introduction to WebKit for Wayland (Automotive ...
A Browser for the Automotive: Introduction to WebKit for Wayland (Automotive ...Igalia
 
Basic Cmake for Qt Users
Basic Cmake for Qt UsersBasic Cmake for Qt Users
Basic Cmake for Qt UsersICS
 
Modeling presentation
Modeling presentationModeling presentation
Modeling presentationAditya Dahal
 
Cad automation of electrical busbar
Cad automation of electrical busbarCad automation of electrical busbar
Cad automation of electrical busbarParthiban Kannan
 
Bertrandt | Automotive Best Practice: How to Design, Review, Approve, and Eff...
Bertrandt | Automotive Best Practice: How to Design, Review, Approve, and Eff...Bertrandt | Automotive Best Practice: How to Design, Review, Approve, and Eff...
Bertrandt | Automotive Best Practice: How to Design, Review, Approve, and Eff...Intland Software GmbH
 
Sprint 140
Sprint 140Sprint 140
Sprint 140ManageIQ
 
Realize 2022 MINO 7 year of implementation v0.1.pptx
Realize 2022 MINO 7 year of implementation v0.1.pptxRealize 2022 MINO 7 year of implementation v0.1.pptx
Realize 2022 MINO 7 year of implementation v0.1.pptxjakobkuhn
 
汽車協同平台簡報
汽車協同平台簡報汽車協同平台簡報
汽車協同平台簡報Jimmy Chang
 

Similar to Hexagonal Architecture: The Standard for Qt Embedded HMIs (20)

CURRICULUM VITAE_Balu
CURRICULUM VITAE_BaluCURRICULUM VITAE_Balu
CURRICULUM VITAE_Balu
 
UNIT 1.pdf
UNIT 1.pdfUNIT 1.pdf
UNIT 1.pdf
 
UNIT 1.pptx
UNIT 1.pptxUNIT 1.pptx
UNIT 1.pptx
 
CADISON world Issue-1-2013
CADISON world Issue-1-2013CADISON world Issue-1-2013
CADISON world Issue-1-2013
 
Bikram Jeet (Achievements from 2006 - 2013)
Bikram Jeet (Achievements from 2006 - 2013)Bikram Jeet (Achievements from 2006 - 2013)
Bikram Jeet (Achievements from 2006 - 2013)
 
Mechatronics engineer
Mechatronics engineerMechatronics engineer
Mechatronics engineer
 
Cadison world-issue-01-2013
Cadison world-issue-01-2013Cadison world-issue-01-2013
Cadison world-issue-01-2013
 
GPGPU using CUDA Thrust
GPGPU using CUDA ThrustGPGPU using CUDA Thrust
GPGPU using CUDA Thrust
 
OpenMP-OpenACC-Offload-Cauldron2022-1.pdf
OpenMP-OpenACC-Offload-Cauldron2022-1.pdfOpenMP-OpenACC-Offload-Cauldron2022-1.pdf
OpenMP-OpenACC-Offload-Cauldron2022-1.pdf
 
ECAD-MCAD Presentation 2011
ECAD-MCAD Presentation 2011ECAD-MCAD Presentation 2011
ECAD-MCAD Presentation 2011
 
A Browser for the Automotive: Introduction to WebKit for Wayland (Automotive ...
A Browser for the Automotive: Introduction to WebKit for Wayland (Automotive ...A Browser for the Automotive: Introduction to WebKit for Wayland (Automotive ...
A Browser for the Automotive: Introduction to WebKit for Wayland (Automotive ...
 
Basic Cmake for Qt Users
Basic Cmake for Qt UsersBasic Cmake for Qt Users
Basic Cmake for Qt Users
 
JAYACHANDRA RESUME
JAYACHANDRA RESUMEJAYACHANDRA RESUME
JAYACHANDRA RESUME
 
Modeling presentation
Modeling presentationModeling presentation
Modeling presentation
 
Cad automation of electrical busbar
Cad automation of electrical busbarCad automation of electrical busbar
Cad automation of electrical busbar
 
Bertrandt | Automotive Best Practice: How to Design, Review, Approve, and Eff...
Bertrandt | Automotive Best Practice: How to Design, Review, Approve, and Eff...Bertrandt | Automotive Best Practice: How to Design, Review, Approve, and Eff...
Bertrandt | Automotive Best Practice: How to Design, Review, Approve, and Eff...
 
Sprint 140
Sprint 140Sprint 140
Sprint 140
 
Realize 2022 MINO 7 year of implementation v0.1.pptx
Realize 2022 MINO 7 year of implementation v0.1.pptxRealize 2022 MINO 7 year of implementation v0.1.pptx
Realize 2022 MINO 7 year of implementation v0.1.pptx
 
汽車協同平台簡報
汽車協同平台簡報汽車協同平台簡報
汽車協同平台簡報
 
sairam_CV
sairam_CVsairam_CV
sairam_CV
 

Recently uploaded

Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
How to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfHow to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfLivetecs LLC
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Matt Ray
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 

Recently uploaded (20)

Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
How to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfHow to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdf
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 

Hexagonal Architecture: The Standard for Qt Embedded HMIs

  • 2. Good, Right and Successful Architectures All architectures Good architectures Technically sound Right architectures Meeting stakeholder needs Successful architectures Delivering value Hexagonal Architecture Start with de-facto standard architecture and adapt it! 2021/07/08 (C) Burkhard Stubert 2 Ports-and-Adapters Architecture
  • 3. About the Importance of Architecture 2021/11/04 (C) Burkhard Stubert 3 2012 2021? Architecture is like an iceberg. Only 1/10 is visible. The Titanic disaster teaches us what happens when we ignore the other 9/10. Yours truly
  • 4. Agenda • Ports-and-Adapters Architecture • Significant Requirements • Machine Component • Business Logic • GUI Component • Creating the Hexagon • Conclusion 2021/11/04 (C) Burkhard Stubert 4
  • 5. Ports-And-Adapters Architecture: Idea USB CAN RS232 UART (W)LAN HDMI PC Port Adapters • Standardised USB Port • Many USB-to-X adapters • Different companies can build different adapters 2021/11/04 (C) Burkhard Stubert 5
  • 6. Ports-And-Adapters Architecture: Pattern • Port = Interface between BL (inside) and Adapters (outside) • Adapter = Uses or implements Port • 1 Port has N Adapters • Port same for all adapters • Code from inside must not leak to outside and vice versa • Inside: models, connections • Outside: Qt SerialBus, SQL, IPC 2021/11/04 (C) Burkhard Stubert 6 Business Logic (BL) GuiPort MachinePort GUI Test Machine Simulator Mock CLI
  • 7. Product Versions over Time 2021/11/04 (C) Burkhard Stubert 7 Business Logic GUI Machine CAN Business Logic GUI Machine Ethernet Business Logic GUI Machine (IPC) Product v0 Product v1 Product v2 • OTA Updates • Ethernet instead of CAN • Remote diagnostic and support • Message processing in separate process
  • 8. Development and Test Versions 2021/11/04 (C) Burkhard Stubert 8 Business Logic GUI Test Machine Mock Development Testing GUI in system context Business Logic GUI Machine Simulator Business Logic GUI Mock Machine Mock Testing Updates in system context
  • 9. Agenda • Ports-and-Adapters Architecture • Significant Requirements • Machine Component • Business Logic • GUI Component • Creating the Hexagon • Conclusion 2021/11/04 (C) Burkhard Stubert 9
  • 10. Application Hexagon Architecturally Significant Requirements 2021/11/04 (C) Burkhard Stubert 10 Engine ECU Machine EngineTwin BL MainModel GUI MainView Driver CAN Frame Quantity Object Quantity 930 rpm • Requirement • GUI shows current engine speed. • Constraints • Neither GUI nor BL know that Machine uses CAN • BL provides C++ models for QML GUI • GUI must not depend on Machine
  • 11. Agenda • Ports-and-Adapters Architecture • Significant Requirements • Machine Component • Business Logic • GUI Component • Creating the Hexagon • Conclusion 2021/11/04 (C) Burkhard Stubert 11
  • 12. Machine Port with Product Adapter (CAN) 2021/11/04 (C) Burkhard Stubert 12 In product_machine.h: QCanBusDevice *m_canBus{QCanBus::instance() ->createDevice("socketcan", "can0")}; CanBusRouter m_router{m_canBus}; EngineTwin m_engine; In product_machine.cpp: ProductMachine::ProductMachine() : Machine{} { QObject::connect( &m_router, &CanBusRouter::newEngineQuantities, &m_engine, &EngineTwin::updateQuantities); In BusinessLogic: Machine::engine() Engine ECU QCanBusDevice CanBusRouter EngineTwin Business Logic can0 Machine SocketCAN frame QCanBusFrame Quantity Quantity Quantity
  • 13. Machine Port with Simulator Adapter 2021/11/04 (C) Burkhard Stubert 13 In simulator_machine.h: CanBusSimulator m_simulator; MockCanBusDevice m_canBus; CanBusRouter m_router{&m_canBus}; EngineTwin m_engine; In simulator_machine.cpp: SimulatorMachine::SimulatorMachine() : Machine{} { QObject::connect( &m_simulator, &CanBusSimulator::newIncomingFrames, &m_canBus, &EngineTwin::appendIncomingFrames); QObject::connect( &m_router, &CanBusRouter::newEngineQuantities, &m_engine, &EngineTwin::updateQuantities); In BusinessLogic: Machine::engine() CanBusSimulator MockCanBusDevice CanBusRouter EngineTwin Business Logic Machine QCanBusFrame QCanBusFrame Quantity Quantity Quantity
  • 14. Test Adapter 2021/11/04 (C) Burkhard Stubert 14 In Machine Test: Machine::engine() MockCanBusDevice CanBusRouter EngineTwin Machine Test Machine QCanBusFrame QCanBusFrame Quantity Quantity Quantity Product Adapter (MQTT) In BusinessLogic: Machine::engine() Engine ECU QNetworkInterface MqttRouter EngineTwin Business Logic eth0 Machine MQTT frame QMqttMessage Quantity Quantity Quantity
  • 15. Creating the Machine Component 2021/11/04 (C) Burkhard Stubert 15 In machine_creator.cpp: Machine *createMachine(Machine::Configuration conf) { switch (conf) { case Machine::Configuration::Product: return new ProductMachine{}; case Machine::Configuration::Simulator: return new SimulatorMachine{}; ... Use createMachine in main()
  • 16. Running Adapter in Thread, Process, MCU Business Logic MachinePort Qt CanBus can0 can1 Business Logic MachinePort Qt CanBus can0 can1 Thread CAN0 Thread CAN1 Qt Signal-Slot Conn. Business Logic MachinePort CAN Bus can0 can1 Thread CAN0 Thread CAN1 Qt Remote Objects Task CAN0 Task CAN1 RPMsg Process 1 on A53 Process 1 on A53 Process 2 on A53 Process 1 on A53 2 Tasks on M4 2021/11/04 (C) Burkhard Stubert 16
  • 17. Agenda • Ports-and-Adapters Architecture • Significant Requirements • Machine Component • Business Logic • GUI Component • Creating the Hexagon • Conclusion 2021/11/04 (C) Burkhard Stubert 17
  • 18. Business Logic 2021/11/04 (C) Burkhard Stubert 18 In business_logic.h: Q_PROPERTY(MainModel *mainModel READ mainModel CONSTANT) BusinessLogic(std::shared_ptr<Machine> machine, ... , m_machine{machine} In business_logic.cpp: MainModel *BusinessLogic::mainModel() { if (m_mainModel == nullptr) { m_mainModel = new MainModel{this}; connect(m_machine->engine(), &EngineTwin::engineSpeed, m_mainModel, &MainModel::setEngineSpeed); } return m_mainModel; } In MainView.qml: BusinessLogic.mainModel GUI Business Logic Machine EngineTwin MainModel BusinessLogic available as singleton in GUI with models as properties if (m_mainModel == nullptr) { m_mainModel = new MainModel{this}; connect(m_machine->engine(), &EngineTwin::engineSpeed, m_mainModel, &MainModel::setEngineSpeed); } return m_mainModel;
  • 19. Agenda • Ports-and-Adapters Architecture • Significant Requirements • Machine Component • Business Logic • GUI Component • Creating the Hexagon • Conclusion 2021/11/04 (C) Burkhard Stubert 19
  • 20. GUI with Product Adapter (QML GUI) 2021/11/04 (C) Burkhard Stubert 20 In MainView.qml: import EmUse.Models Pane { property MainModel model: BusinessLogic.mainModel Text { text: Number(model.engineSpeed.value).toFixed(0) } Text { text: model.engineSpeed.unit } MainView Business Logic Machine EngineTwin MainModel
  • 21. GUI Port with Test Adapter 2021/11/04 (C) Burkhard Stubert 21 void TestMainView::init() { m_machine = std::make_shared<Machine>( createMachine(Machine::Configuration::Mock)); m_businessLogic = new BusinessLogic{m_machine}; m_model = m_businessLogic->mainModel(); } void TestMainView::testEngineSpeed() { Quantity rpm{930.0, "rpm"}; emit m_machine->engine()->engineSpeed(rpm); QCOMPARE(m_model->engineSpeed()->quantity(), rpm); } TestMainView Business Logic Machine EngineTwin MainModel Testing GUI in system context • with actual BusinessLogic • with mocks for Machine objects Mocks reused from unit tests of Machine and EngineTwin
  • 22. Agenda • Ports-and-Adapters Architecture • Significant Requirements • Machine Component • Business Logic • GUI Component • Creating the Hexagon • Conclusion 2021/11/04 (C) Burkhard Stubert 22
  • 23. Composition Root main() 2021/11/04 (C) Burkhard Stubert 23 int main(int argc, char *argv[]) { std::shared_ptr<Machine> machine{ createMachine(Machine::Configuration::Product); }; std::shared_ptr<BusinessLogic> businessLogic{ new BusinessLogic{machine} }; QQmlApplicationEngine appEngine; appEngine.load(u"qrc:/main.qml"_qs); return app.exec(); }
  • 24. Agenda • Ports-and-Adapters Architecture • Significant Requirements • Machine Component • Business Logic • GUI Component • Creating the Hexagon • Conclusion 2021/11/04 (C) Burkhard Stubert 24
  • 25. Pros and Cons of Hexagonal Architecture • High testability • High modularity • High modifiability • High maintainability 2021/11/04 (C) Burkhard Stubert 25 Pros • Additional complexity Cons Succesful architecture for Qt embedded HMIs: Hexagonal Architecture
  • 26. Resources • Alistair Cockburn: Hexagonal Architecture. Original description of the Hexagonal Architecture pattern. • Juan Manuel Garrido de Paz: Ports and Adapters Pattern (Hexagonal Architecture). Detailed explanation of the pattern. • Burkhard Stubert: A Successful Architecture for Qt Embedded Systems. My talk at QtDay Italy 2021. • Burkhard Stubert: Source code for this talk. 2021/11/04 (C) Burkhard Stubert 26
  • 27. 🙏 Thank You 🙏 Mail: burkhard.stubert@embeddeduse.com Web: https://embeddeduse.com Newsletter: http://eepurl.com/gOMQoX

Editor's Notes

  1. Fairbanks: “Presumptive architectures are usually successful.” Good = efficient Right = effective Successful = valuable
  2. Lets transfer the hardware idea into software
  3. The PC with its USB ports becomes the business logic with several APIs or ports If we unfold the adapter-BL-adapter paths of the hexagon, we get multiple instances of 3-layer architecture
  4. The rest of the application does not notice that different ways of communications are used with machine. Remote Diagnostic/Support is just a remote GUI. Remote diagnostic could be mirrored on-board (in the GUI).
  5. This single requirement drives the architecture. Abstraction increases from left to right.
  6. ProductMachine implements the Machine interface CanBusRouter - routes messages to correct ECU twins - decodes/encodes CAN frames to/from Quantities
  7. SimulatorMachine implements the Machine interface Can be used for playing back recorded CAN traces
  8. Use #ifdef’s to get non-product relevant code out the application binary.
  9. Motivation: Avoid GUI freezes & stuttering, avoid buffer overflows How and where CAN adapters run does not matter! MachineAPI is always the same!
  10. The dependency Machine is injected in the constructor. Remove dependency on Machine, if we create ALL models in advance (none on the fly). Performance penalty!
  11. If we start reimplementing parts of MainView.qml in the test, we are violating the model-view pattern!!! Create CLI in similar way!
  12. High testability: “built-in” system and component tests based on unit tests Everything else follows from this!!! High modularity: Different teams develop different components High modifiability: Change adapters without rest of system knowing. Follows open-closed principle High maintainability: Bugs are local to component.