.. _algorithms_development: Algorithms Development ************************ Huxon Platform decouples the logic of the algorithms from how they are implemented on the target architecture. You are in charge of defining the logic of the algorithms without worrying of the target architecture, while Huxon automatically partitions your code, decides which hardware suites best for each code portion and deploys each code portion on nodes of the target architecture by taking into account resource and communication constraints. Algorithms can be developed and simulated on your local machine using `Huxon Language `_. Once algorithms are ready, you need to upload them on Huxon to make them available for deployment. Code development ================= .. image:: ../img/algorithms_00.png :width: 600px :alt: Algorithms Page Algorithms needs to be developed using Huxon Language based on C++. To ease the process of developing algorithms on your local machine, it is possible to download a development kit from Huxon. The DevKit comes with a development container for Visual Studio Code with all the needed software installed. You can download the DevKit from `here `_ or inside Huxon by clicking on **DOWNLOAD DEVKIT**. To develop using the DevKit: - Decompress the archive. - Install Visual Studio Code on your computer and follow the `instructions to setup Visual Studio Code to work with dev containers `_. - Open the folder inside Visual Studio Code, and it will automatically recognize the Development Container. .. image:: ../img/algorithms_01_vs.png :width: 600px :alt: Algorithms development in Visual Studio Code - Click on **Reopen in Container** in the lower right part of the screen. Visual Studio Code will reopen, and by clicking on the popup you can see the progress of the setup. .. image:: ../img/algorithms_03_vs.png :width: 600px :alt: DevContainer Build - When the build is over, you can open a new terminal to use a development tool available inside the container called *huxc*. *huxc* provides commands to *create, simulate* and *delete* your project. The structure of the command for *huxc* is: .. code:: bash huxc create | simulate | delete -n .. note:: *huxc* also provides the `arff2hpp` command can be used to train a decision tree starting from a ARFF dataset and generate a corresponding header file that can be used inside your algorithm to run the decision tree when needed. This is especially useful for classifying patterns from features extracted from the sensor's data. For more information on the command run `huxc arff2hpp -h` Upon project creation, the tool creates a folder with name *huxapp_* and automatically generates an example code that you can use as a starting point. The DevKit contains also a **docs** folder containing the full documentation of the language. .. image:: ../img/algorithms_07_vs_huxc_create_01.png :width: 600px :alt: DevContainer Build Once the code is ready for deployment, you can use the *package* functionality to create an archive that can be uploaded to Huxon. .. note:: Remember to simulate locally the correctness of the code to validate its functionality. Algorithms Upload ================== .. image:: ../img/algorithms_12_code_upload.png :width: 600px :alt: algorithm upload The archive of the algorithms can be directly uploaded to Huxon by clicking on **NEW ALGORITHM UPLOAD** and providing the archive, and the name of the algorithm (this is the name that will be showed in the internal library of algorithms). Optionally, you can also specify a description for the algorithm. By clicking on **SUBMIT** the code is uploaded, and Huxon starts analyzing the code to determine performance requirements and various metrics that will be necessary to Huxon to execute this code on any defined target architecture. .. image:: ../img/algorithms_13_code_upload.png :width: 600px :alt: algorithm upload Once the algorithm is ready, its status turns green and become visible in the *Virtual Sensor Development* section of Huxon. .. _az_central_algorithm_interaction: Interaction with Azure Central ================================= Among the various analysis performed by Huxon on the algorithm, Huxon interfaces with the *Azure Central Application* specified during project setup, and creates a Device Template corresponding to your algorithm using the Digital Twin Definition Language (DTDL). This operation allows to interface with the meaningful data generated by your algorithm directly inside *Azure Central*, or to connect to a third-party software to export data or to generate data visualizations. .. image:: ../img/device_templates.png :width: 600px :alt: algorithm upload You will be able to see the generated DTDL directly from the Device Templates of your *Azure Central Application*.