{"id":4469,"date":"2018-10-24T10:05:02","date_gmt":"2018-10-24T08:05:02","guid":{"rendered":"https:\/\/zen-cori.138-201-132-86.plesk.page\/?p=4469"},"modified":"2022-09-28T16:31:39","modified_gmt":"2022-09-28T07:31:39","slug":"how-to-efficiently-handle-external-variables-in-a-targetlink-unit-test","status":"publish","type":"post","link":"https:\/\/www.btc-embedded.jp\/ja\/how-to-efficiently-handle-external-variables-in-a-targetlink-unit-test\/","title":{"rendered":"How to efficiently handle external variables in a TargetLink Unit Test"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"4469\" class=\"elementor elementor-4469\" data-elementor-post-type=\"post\">\n\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-3b5f0493 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"3b5f0493\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-559a247a\" data-id=\"559a247a\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-d83c847 elementor-widget elementor-widget-text-editor\" data-id=\"d83c847\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t<style>\/*! elementor - v3.20.0 - 26-03-2024 *\/\n.elementor-widget-text-editor.elementor-drop-cap-view-stacked .elementor-drop-cap{background-color:#69727d;color:#fff}.elementor-widget-text-editor.elementor-drop-cap-view-framed .elementor-drop-cap{color:#69727d;border:3px solid;background-color:transparent}.elementor-widget-text-editor:not(.elementor-drop-cap-view-default) .elementor-drop-cap{margin-top:8px}.elementor-widget-text-editor:not(.elementor-drop-cap-view-default) .elementor-drop-cap-letter{width:1em;height:1em}.elementor-widget-text-editor .elementor-drop-cap{float:left;text-align:center;line-height:1;font-size:50px}.elementor-widget-text-editor .elementor-drop-cap-letter{display:inline-block}<\/style>\t\t\t\t<p>IIn the last decade, Model-based development (MBD) has considerably improved the development of embedded software in the automotive industry. Although the MBD methodology increases the efficiency of the development process, there are some technical challenges which function developers experience. One example is the handling of external variables during the software unit test.<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-7c099a8 elementor-widget elementor-widget-heading\" data-id=\"7c099a8\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t<style>\/*! elementor - v3.20.0 - 26-03-2024 *\/\n.elementor-heading-title{padding:0;margin:0;line-height:1}.elementor-widget-heading .elementor-heading-title[class*=elementor-size-]>a{color:inherit;font-size:inherit;line-height:inherit}.elementor-widget-heading .elementor-heading-title.elementor-size-small{font-size:15px}.elementor-widget-heading .elementor-heading-title.elementor-size-medium{font-size:19px}.elementor-widget-heading .elementor-heading-title.elementor-size-large{font-size:29px}.elementor-widget-heading .elementor-heading-title.elementor-size-xl{font-size:39px}.elementor-widget-heading .elementor-heading-title.elementor-size-xxl{font-size:59px}<\/style><h2 class=\"elementor-heading-title elementor-size-default\">Motivation and challenges<\/h2>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-a1ff07f elementor-widget elementor-widget-text-editor\" data-id=\"a1ff07f\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p>Complex software applications often require to have a modular software architecture as recommended by standards like ISO 26262. While splitting the software architecture into smaller units, the ownership of interface variable definitions becomes distributed across the units. Maybe one unit is responsible for the definition of its own output variables or in some cases the definition of the interface variables is delegated to one specific component (e.g. shared Calibrations variables or IO variables of all units). This type of architectural design is even more prominent in distributed development process (e.g. with supplier) where one party is responsible for the data it provides.<\/p><p>For a software unit test and Back-to-Back Test, this can lead to big challenges: For compilation purpose, the definition of the non-owned variable is of course needed. One solution could be, to include the real external production code file in the unit test compilation process. But this often leads to problems, as this file can again have other dependencies and headers which are either not available or hardware dependent. Another issue is the fact, that tests are usually executed on model level (MIL) and code level (SIL\/PIL). By including external files with variable definitions and init values, it becomes a challenge to ensure that we have the same values for MIL and SIL.<\/p><p>Another solution could be, to let our code generator generate these variables together with the production code. But then we have an error prone process to get rid of these variables before the software integration phase.<\/p><p>In the development tool dSPACE TargetLink, the external variables can be automatically generated by the code generator, but without becoming part of the production code. Let\u2019s have a look at how this is done.<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-27e953f elementor-widget elementor-widget-heading\" data-id=\"27e953f\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">Create a dedicated variable class and a module<\/h2>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<section class=\"elementor-section elementor-inner-section elementor-element elementor-element-b30d8c3 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"b30d8c3\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-50 elementor-inner-column elementor-element elementor-element-c82a083\" data-id=\"c82a083\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-0e39cda elementor-widget elementor-widget-text-editor\" data-id=\"0e39cda\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p>Let\u2019s consider a model that contains shared calibration variables defined in another component and simply used in this function. In the TargetLink Data Dictionary, we will first create a dedicated variable class:<\/p><ol><li>Start by duplicating the existing \u201cCAL\u201d class and renaming it however you like<\/li><li>Reference this variable class for all shared calibration variables<\/li><li>Create a module object which has the name of the \u201creal\u201d external file that holds the variable definitions.<\/li><li>Reference this module in your variable class<br \/><br \/><\/li><\/ol><p>With this configuration, the model generates the c-code which uses these variables and the code includes the right header file for the declarations. However, the \u201cexternal\u201d code files will also be generated in the production code folder, which is something we don\u2019t want.<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t<div class=\"elementor-column elementor-col-50 elementor-inner-column elementor-element elementor-element-f6fa2f1\" data-id=\"f6fa2f1\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-d6bcfb8 elementor-widget elementor-widget-image\" data-id=\"d6bcfb8\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t<style>\/*! elementor - v3.20.0 - 26-03-2024 *\/\n.elementor-widget-image{text-align:center}.elementor-widget-image a{display:inline-block}.elementor-widget-image a img[src$=\".svg\"]{width:48px}.elementor-widget-image img{vertical-align:middle;display:inline-block}<\/style>\t\t\t\t\t\t\t\t\t\t<img fetchpriority=\"high\" decoding=\"async\" width=\"586\" height=\"593\" src=\"https:\/\/www.btc-embedded.jp\/wp-content\/uploads\/2018\/10\/variable_class-586x-545.png\" class=\"attachment-large size-large wp-image-4471\" alt=\"\" \/>\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<div class=\"elementor-element elementor-element-8f3060b elementor-widget elementor-widget-heading\" data-id=\"8f3060b\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">Define a module ownership<\/h2>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<section class=\"elementor-section elementor-inner-section elementor-element elementor-element-06f9547 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"06f9547\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-50 elementor-inner-column elementor-element elementor-element-64069d1\" data-id=\"64069d1\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-313a2a0 elementor-widget elementor-widget-text-editor\" data-id=\"313a2a0\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p>Using the \u201cmodule ownership\u201d feature, we can solve this:<\/p><ol><li>Create a \u201cmodule owner\u201d element<\/li><li>Specify a system name for the module ownership. This can basically be any string but not the name of your TargetLink code generation unit. For a Data Dictionary which is shared across the project, it might be the name of the TargetLink model which is actually responsible for these variables<\/li><li>Reference the module that you created before<\/li><\/ol>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t<div class=\"elementor-column elementor-col-50 elementor-inner-column elementor-element elementor-element-02f9fec\" data-id=\"02f9fec\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-e26cbd5 elementor-widget elementor-widget-image\" data-id=\"e26cbd5\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t<img decoding=\"async\" width=\"631\" height=\"504\" src=\"https:\/\/www.btc-embedded.jp\/wp-content\/uploads\/2018\/10\/module_owner-1920x1920-388.png\" class=\"attachment-large size-large wp-image-4474\" alt=\"\" \/>\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<div class=\"elementor-element elementor-element-6ec190f elementor-widget elementor-widget-text-editor\" data-id=\"6ec190f\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p>As an outcome of this configuration, TargetLink creates a different folder to store these files instead of putting them in the actual production code folder. The files are so-called stub code and they are differentiated from the actual source files . It is interesting to notice that the production code hasn\u2019t changed after this configuration and the software unit is ready to be tested.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0 \u00a0\u00a0\u00a0\u00a0<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-da6f93a elementor-widget elementor-widget-heading\" data-id=\"da6f93a\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">Conclusion<\/h2>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<section class=\"elementor-section elementor-inner-section elementor-element elementor-element-e03a146 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"e03a146\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-50 elementor-inner-column elementor-element elementor-element-498ad8f\" data-id=\"498ad8f\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-66ca282 elementor-widget elementor-widget-text-editor\" data-id=\"66ca282\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p>Configuring TargetLink with the \u201cModuleOwnerShip\u201d mechanism enables an efficient and automated handling of external variables. The unit source code and the stub code are created automatically in seperate folders and becomes ready to be compiled for the unit test. MIL and SIL simulations can use synchronized data properties such as datatype and init value. Thus, the user can focus on the actual testing activities, for example with BTC EmbeddedTester, and finally after the unit test, get rid of the stub code to integrate the unit source code with the actual external variables source code during the software integration phase.<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t<div class=\"elementor-column elementor-col-50 elementor-inner-column elementor-element elementor-element-36e7cb3\" data-id=\"36e7cb3\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-4a7aa1e elementor-widget elementor-widget-image\" data-id=\"4a7aa1e\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t<img decoding=\"async\" width=\"800\" height=\"510\" src=\"https:\/\/www.btc-embedded.jp\/wp-content\/uploads\/2018\/10\/files-1920x1920-59d.png\" class=\"attachment-large size-large wp-image-4477\" alt=\"\" srcset=\"https:\/\/www.btc-embedded.jp\/wp-content\/uploads\/2018\/10\/files-1920x1920-59d.png 1058w, https:\/\/www.btc-embedded.jp\/wp-content\/uploads\/2018\/10\/files-1920x1920-59d-768x489.png 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/>\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<div class=\"elementor-element elementor-element-fa217fc elementor-widget elementor-widget-text-editor\" data-id=\"fa217fc\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p>It\u2019s good to notice that AUTOSAR compliant software considerably reduces the need of external variables. Indeed, as all AUTOSAR interfaces are managed (i.e. defined) in the AUTOSAR Run-Time Environment (RTE), the user can rely on the development tools to handle the AUTOSAR semantics automatically. For instance, TargetLink provides a self-contained RTE frame which can be appropriately tested in BTC EmbeddedTester.<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>IIn the last decade, Model-based development (MBD) has considerably improved the development of embedded softw [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"elementor_theme","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[1],"tags":[50,49,51],"product":[],"use_cases":[],"class_list":["post-4469","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-automatic-code-generation","tag-model-based-development","tag-targetlink"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.btc-embedded.jp\/ja\/wp-json\/wp\/v2\/posts\/4469","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.btc-embedded.jp\/ja\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.btc-embedded.jp\/ja\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.btc-embedded.jp\/ja\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.btc-embedded.jp\/ja\/wp-json\/wp\/v2\/comments?post=4469"}],"version-history":[{"count":9,"href":"https:\/\/www.btc-embedded.jp\/ja\/wp-json\/wp\/v2\/posts\/4469\/revisions"}],"predecessor-version":[{"id":5763,"href":"https:\/\/www.btc-embedded.jp\/ja\/wp-json\/wp\/v2\/posts\/4469\/revisions\/5763"}],"wp:attachment":[{"href":"https:\/\/www.btc-embedded.jp\/ja\/wp-json\/wp\/v2\/media?parent=4469"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.btc-embedded.jp\/ja\/wp-json\/wp\/v2\/categories?post=4469"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.btc-embedded.jp\/ja\/wp-json\/wp\/v2\/tags?post=4469"},{"taxonomy":"product","embeddable":true,"href":"https:\/\/www.btc-embedded.jp\/ja\/wp-json\/wp\/v2\/product?post=4469"},{"taxonomy":"use_cases","embeddable":true,"href":"https:\/\/www.btc-embedded.jp\/ja\/wp-json\/wp\/v2\/use_cases?post=4469"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}