Giter Site home page Giter Site logo

waunbroderick / areg-sdk Goto Github PK

View Code? Open in Web Editor NEW

This project forked from aregtech/areg-sdk

0.0 1.0 0.0 12.62 MB

Automated real-time communication engine to develop multitasking Embedded, IoT Edge, CLI and Desktop applications with services, which act like ultra-thin distributed servers.

Home Page: https://www.aregtech.com

License: Apache License 2.0

Shell 0.04% C++ 97.64% C 1.23% Makefile 0.50% CMake 0.45% Batchfile 0.14%

areg-sdk's Introduction

AREG SDK Home

AREG SDK

Latest release


Project Status

C++ compiltation MS Build
C++ solution Operating systems CPU Architect

Introduction

AREG SDK is an interface-centric real-time asynchronous communication engine to enable distributed- and mist-computing, where connected Things interact and provide services as if they act like thin distributed servers. The communication engine of AREG SDK is based on Object Remote Procedure Call (ORPC) protocol.


Table of contents

  1. Motivation
  2. More than embedded
  3. Composition
  4. Roadmap
  5. Software build
  6. Software integration
  7. Use cases and benefits
  8. Examples
  9. Licensing
  10. Call for action

Motivation

Traditionally, devices act as connected clients to stream data to the cloud or fog servers for further processing.

IoT-to-Cloud (Nebula) network

Since data is generated and collected at the edge of the network (mist network), it makes sense to change the role of connected Things and provide network-accessible (Public) services directly on devices. This extends Cloud to the extreme edge and it is a good foothold for robust solutions such as:

  • Increase data privacy, which is an important factor for sensitive data.
  • Decrease data streaming, which is a fundamental condition to optimize network communication.
  • Autonomous, intelligent and self-aware devices with services directly in the environment of data origin.

More than embedded

When we were designing AREG SDK, the guiding principle was to provide a homogeneous solution for Multithreading, Multiprocessing and Internet communication wrapped in services appropriately having Local, Public and Internet categories. These services are neither processes nor tasks managed by the operating system, they are software components with a predefined interface, in which methods are invoked remotely.
AREG SDK distributed services

๐Ÿ’ก In current version, the AREG communication engine supports Local (multithreading) and Public (multiprocessing) service categories. The Internet (web) service category is in development pipeline.

The AREG engine forms a fault-tolerant system and does not require process startup priority. It automatically discovers services, automates communications, enables distributed service programming, and helps developers to focus on application business logic as if they would program a single process application with one thread where methods of objects are event-driven. The engine guarantees that:

  • The crash of one application does not cause the crash of the system.
  • The service clients automatically receive service availability status notifications.
  • The requests, response and notifications are automatically invoked and run in thread-safe mode.

Composition

Currently AREG SDK consists of:

  1. Multicast router (mcrouter) for IPC that runs either as a service managed by the OS or as a console application.
  2. AREG framework (or engine) is a (shared or static) library to link with every application.
  3. Code generator tool to create client and server base objects from a service prototype document.

The network communication model of AREG framework is based on multicast router and service architecture is interface-centric, which in combination of both enable to comprise all features of action-centric architecture (Client-Server / Request-Reply model) and data-centric architecture (Publisher-Subscriber / PubSub model).

๐Ÿ’ก The examples of AREG SDK contain multiple projects to demonstrate the features and fault tolerant behavior of AREG communication engine.


Roadmap

The aim of AREG SDK is a lightweight self-sufficient system, which consist of an intelligent framework and multiple tools that help developers to create complex Desktop, Embedded and/or IoT edge applications in shorter time (reduce development and testing time 50-30%).

  • Planned framework features:
    • Multi-channel and multi-protocol communication.
    • Logging service (separate process) to collect logs in the network.
    • Internet (web) category service.
  • Planned tools:
    • Service interface designer.
    • Interactive log viewer.
    • Service testing and Data simulation tool.

Software build

๐Ÿ’ก Chek the Wiki page of AREG SDK for mode details. We change the content and add more details.

The source codes of AREG framework and examples support following platform, CPU and compilers:

OS Linux (list of POSIX API), Windows 8 and higher.
CPU x86, x86_64, arm and aarch64.
Compilers GCC, g++, clang, MSVC and cygwin CC.

The tools to use to compile sources:

Solution Platforms API Quick actions to compile
CMakeLists.txt Linux, Windows POSIX, Win32 Make one of these actions:
ย ย  - Call cmake in command line.
ย ย  - Configure and build in Visual Studio Code;
ย ย  - Configure and build in Microsoft Visual Studio.
Makefile Linux POSIX Call make in command line.
areg-sdk.sln Windows Win32 Open and build in Microsoft Visual Studio.
.project Linux, Windows POSIX Import and build projects in Eclipse.

๐Ÿ’ก The other POSIX-compliant OS and compilers are not tested yet.
๐Ÿ’ก Make user specific changes (like switch compiler or output folder) only in appropriate user files:

After compilation, normally binaries are located in <areg-sdk>/product/build/<compiler-platform-path>/bin folder. Details on how to change compiler, load and compile sources for various targets are described in HOWTO document. The next are quick overviews.

Build with cmake

To build with cmake, open Terminal in your projects folder and take the steps:

# Step 1: Get sources from GitHub
$ git clone https://github.com/aregtech/areg-sdk.git
$ cd areg-sdk

# Step 2: Initialize cache and build configuration in folder './build' folder.
#         The switch 'BUILD_EXAMPLES' enable or disables examples. By default, it is enabled.
#         Example: cmake -B ./build -DBUILD_EXAMPLES=OFF
$ cmake -B ./build

# Step 3: Compile sources by calling: cmake --build ./build [-j [concurrent jobs]]
$ cmake --build ./build -j8

Build with make

To build with make, open Terminal in your projects folder and take the steps:

# Step 1: Get sources from GitHub
$ git clone https://github.com/aregtech/areg-sdk.git
$ cd areg-sdk

# Step 2: Compile sources by calling: make [all] [framework] [examples]
$ make

Build with IDE

Open Terminal or preferred IDE to clone source codes like this:

$ git clone https://github.com/aregtech/areg-sdk.git
$ cd areg-sdk

Depending on IDE or preferences make one of following:

  1. Open areg-sdk.sln file in MSVS (2019 or higher) and compile solution.
  2. Open areg-sdk folder in MSVC (2019 or higher), select CMakeLists.txt in areg-sdk root, configure and build.
  3. Open areg-sdk folder in VS Code, select CMakeLists.txt in areg-sdk root, configure and build.
  4. Open Eclipse, import all projects from areg-sdk root, select projects and build.

๐Ÿ’ก Compilation with Eclipse under Windows might require to change the Toolchain.


Software integration

Multicast router

Configure router.init file to set the IP-address and the port of multicast router (mcrouter):

connection.address.tcpip    = 127.0.0.1	# the address of mcrouter host
connection.port.tcpip       = 8181      # the connection port of mcrouter

The multicast router is a process that can run as a system service or application to form the network, and it can run on any device like PC, gateway or even a small router. In case of multithreading application, there is no need to configure and start mcrouter.

Logging service

Configure log.init to set scopes, priorities and file name for logging:

log.file        = %home%/logs/%appname%_%time%.log # create logs in 'log' subfolder of user home 
scope.mcrouter.*= NOTSET ;                         # disable logs for mcrouter.

scope.my_app.*                   = DEBUG | SCOPE ; # enable all logs of my_app
scope.my_app.ignore_this_scope   = NOTSET ;        # disable logs of certain scopes in my_app
scope.my_app.ignore_this_group_* = NOTSET ;        # disable logs of certain scope group in my_app

๐Ÿ’ก By default, the router.init and log.init files are located in the config subfolder of binaries.
๐Ÿ’ก To enable all logs of all applications, use scope.* = DEBUG | SCOPE ; .
๐Ÿ’ก Currently logging is possible only in file.

Development

The development guidance and step-by-step example to create a simple service-enabled application are described in DEVELOP. See Hello Service! as an example to create service. More details are in the Wiki page of AREG SDK.


Use cases and benefits

AREG SDK can be used in a very large scope of multithreading and multiprocessing application development.

๐Ÿ’ก Expand each section to see the details.

Distributed solution

Click to show / hide distributed solution.

AREG SDK is a solution of distributed services that can run on any node of the network and because of automations and transparent communication interact as if the components are located in one process. To distribute services in the processes and define relationships, developers create model to load during runtime.

The following is a demonstration of a static model to start and stop services:

// Defines static model with 2 services
BEGIN_MODEL("MyModel")

  BEGIN_REGISTER_THREAD( "Thread1" )
    BEGIN_REGISTER_COMPONENT( "SystemShutdown", SystemShutdownService )
      REGISTER_IMPLEMENT_SERVICE( NESystemShutdown::ServiceName, NESystemShutdown::InterfaceVersion )
    END_REGISTER_COMPONENT( "SystemShutdown" )
  END_REGISTER_THREAD( "Thread1" )

  BEGIN_REGISTER_THREAD( "Thread2" )
    BEGIN_REGISTER_COMPONENT( "RemoteRegistry", RemoteRegistryService )
      REGISTER_IMPLEMENT_SERVICE( NERemoteRegistry::ServiceName, NERemoteRegistry::InterfaceVersion )
      REGISTER_DEPENDENCY("SystemShutdown")
    END_REGISTER_COMPONENT( "RemoteRegistry" )
  END_REGISTER_THREAD( "Thread2" )

END_MODEL("MyModel")

int main()
{
    // Initialize application, enable logging, servicing, routing, timer and watchdog.
    // Use default settings.
    Application::initApplication( );
    // load model to start service components
    Application::loadModel("MyModel");
    // wait until Application quit signal is set.
    Application::waitAppQuit(NECommon::WAIT_INFINITE);
    // stop and unload service components
    Application::unloadModel("MyModel");
    // release and cleanup resources of application.
    Application::releaseApplication();

    return 0;
}

This example uses MACRO to create a model "MyModel" with two services:

  1. Service with the role "SystemShutdown" is registered in the thread "Thread1" and provides an interface with name NESystemShutdown::ServiceName.
  2. Service with the role "RemoteRegistry" is registered in the thread "Thread2", provides an interface with name NERemoteRegistry::ServiceName and has dependency (i.e. is a client) of service with role "SystemShutdown".

The services are started when load model by calling function Application::loadModel("MyModel"), and stopped when call function Application::unloadModel("MyModel"). When define a model, these two services can be registered in the same thread or distributed in 2 processes. In all cases, the physical location of service components remain transparent, so that the architectures have more flexibility to distribute computing power. An example of developing a service and a client in one and multiple processes is in Hello Service! project described in the development guide.

Driverless devices

Click to show / hide driverless devices.

Normally, the devices are supplied with the drivers to install in the system and with the header files to integrate in the application(s). The drivers often run in Kernel mode and the crash of the driver crashes the entire system. Driver development requires a special technique, which is different for each operating system, and it is hard to debug.
Kkernel-mode driver solution
Our proposal is to deliver driverless service-enabled devices, where device-specific services are described in the interface prototype documents.
AREG SDK driverless solution
In contrast to drivers, the service development does not differ from user mode application development, it is faster to develop, easily serves multiple applications (service clients), contains fewer risks and the code generator helps to generate client object from service interface document.

Real-time solutions

Click to show / hide real-time solutions.

When a remote method of the service interface is called, the engine of AREG SDK automatically generates and delivers messages to the target and automatically invokes the exact methods of the exact target objects. This makes communication real-time with ultra-low networking latency. Such solutions are highly required to develop time-sensitive applications for automotive, flock of drones, medtech, real-time manufacturing, real-time monitoring and other projects.
AREG SDK and multicast features

Digital twin

Click to show / hide digital twin.

Often, the digital twin applications use client-server architecture, where the middleware server collects the data of external devices and the UI application virtualizes them. In such solutions, devices interact either through server or UI client applications. The event-driven and the service-oriented architecture, and the real-time communication of AREG framework is a good solution to develop digital twin applications to virtualize, monitor and control external devices, and immediately react to environment or device state change in real-time mode. External devices may also communicate without additional layers, which is an important factor for emergency, security and safety cases.

Simulation and tests

Click to show / hide simulation and tests.

When hardware provisioning to all employees is impossible, testing and checking unexpected phenomena of rapidly changing software in a simulated environment is the most rational solution. If unit tests are for testing a small portion of code and the tests may contain bugs, the simulation is used by developers and testers to check functionality and stability of the system. Simulations are portable and accessible to everyone, help to optimize solutions and avoid unnecessary risks. Projects using simulations are better prepared for remote work and easier to outsource.
Software application 4 layers
The software components in applications normally are split into Data, Controller, Business and the optional Presentation layers. Distributed and service-oriented solution of AREG framework can ease system testing in a simulated environment, where the Simulation application provides an implementation of Data layer services, so that the rest of the application can be tested without any change.

The same technique of simulating data can be used to create API-driven test automations.


Examples

There are various examples to demonstrate features of the AREG SDK. The examples are listed in the examples/README.md document.


Licensing

AREG SDK is under free open source Apache License Version 2.0. However, AREG SDK can be commercially licensed, which includes the commercial support, full rights to create and distribute software without open source license obligations. For commercial license, support or additional information, please visit Aregtech website or contact info[at]aregtech[dot]com.


Call for action

We look for help and welcome to join the project:

  • See the list of open issues where we look for help.
  • If you need new features, please open new issue or start new discussion.
  • Please submit your pull requests in the candidate branch, which is our branch with latest sources.
  • When create a pull request, please understand that reviewing and testing takes time, and we as well pay attention on coding style.
  • If you look for invoiced commercial support or trainings, or if your project has possibility commercially support AREG SDK, please contact info[at]aregtech[dot]com.

Did we help your project? Have you learned something new? Have we inspired you for new great ideas? Then we ask not to be indifferent and star AREG SDK. This small thank inspires contributors and help us to expand our community. Please also share the project with your network at Twitter and other social media platforms.


Follow us
Follow us on twitter Follow us on LinkedIn Join the chat at https://gitter.im/areg-sdk/community


Viewers

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.