Skip to content

philipzellweger/SmartFactory_Messages

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SmartFactory_Messages

The core of the SmartFactory is the Communication amongst the participants, i.e. receiving and sending messages by using the MQTT technology. The callback function have to dynamically decide which message type is involved to correctly interpret the message and store it in the correct memory. For this requirement a library was created which can serialize messages through the design pattern Factory. The purpose of the SmartFactory_Messages concept is to define all message types and their handling in one place to ensure a straightforward communication process. This principle ensures an easy handling of the different message types and standardizes the handling of messages throughout the SmartFactory project.

The used desing pattern is the Factory. The principle is based on the polymorphism in which virtual functions of the parent class are overwritten in the child class. A createfunction refers the message type to the correct specific class to serialise the received message.

Table of contents

Tools and technologies

The source code is implemented in the programming language C++. In the following, the tools for editing the project are listed.

Visual Studio Code

The development environment used is Visual Studio Code with the PlatformIO extension. The development environment can be downloaded open sourced. For an installation guide look here.

Doxygen

Doxygen was used for documenting the source code. For using Doxygen in Visual Studio code, the Doxygen Documentation Generator extension is available.

Shared pointer

Shared pointers are used to transfer dynamically created objects. The advantage of shared pointers is that you do not need direct control over deleting dynamically created objects. As soon as no pointer points to the created object, the object is automatically deleted. This tool makes the Factory design pattern very powerful. An explanation of shared pointer can be found here.

Software

Factory

The structure of the Factory design pattern consists a parent class which has a creatfunction and at least one purely virtual function. In addition, it has several child classes, which overwrite and thus define the purely virtual function of the element class. In the createfunction an object of the child class is dynamically created under the condition of a criterion (in our case by the message type). The necessary overwritten functions are executed and finally a pointer with the type of the parent class returns the dynamically created object. One of the advantages of the design pattern is its modularity. If a new message type is created in the project, it can easily be defined as a child class and added into the createfunction. This principle makes handling of different message types easy and modular. Here is a detailed explanation of the design pattern Factory.

factory [Image: Developer-Blog FACTORY DESIGN PATTERN]

UML

The figure below shows the data model in UML notation. In the Factory implemented in SmartFactory, the function "translateJsonToStruct" is the creat function and "parseJSONToStruct" is the virtual function which is overwritten.

Click on the image to open doxygen-documentation.

Include Graph

The figure below shows the include graph of the Message interface.

Click on the image to open doxygen-documentation.

ToDo's

All the ToDo's are documented in the source code with Doxygen.

Contributors

Changelog

V 1.0 - Release SA HS20 - Philip Zellweger

License

MIT License

Links to SmartFactory

Releases

No releases published

Packages

No packages published

Languages