├── .circleci └── config.yml ├── .flake8 ├── .github └── workflows │ └── codeql-analysis.yml ├── .gitignore ├── .gitlab-ci.yml ├── CHANGELOG ├── Dockerfile ├── LICENSE.txt ├── MANIFEST.in ├── Makefile ├── README.md ├── ac-macros └── revision_utils.m4 ├── acinclude.m4 ├── configure ├── configure.ac ├── dmt ├── A_mappers │ ├── Stubs.py │ ├── __init__.py │ ├── ada_A_mapper.py │ ├── c_A_mapper.py │ ├── learn_CHOICE_enums.py │ ├── module_protos.py │ ├── og_A_mapper.py │ ├── python_A_mapper.py │ ├── qgenada_A_mapper.py │ ├── qgenc_A_mapper.py │ ├── rtds_A_mapper.py │ ├── scade6_A_mapper.py │ ├── simulink_A_mapper.py │ ├── smp2_A_mapper.py │ ├── sql_A_mapper.py │ ├── sqlalchemy_A_mapper.py │ └── vdm_A_mapper.py ├── B_mappers │ ├── Makefile │ ├── PierreToyExampleSystem.aadl │ ├── VHDL-templates.tar.bz2 │ ├── __init__.py │ ├── ada_B_mapper.py │ ├── antlr.main.py │ ├── asynchronousTool.py │ ├── c_B_mapper.py │ ├── gui_B_mapper.py │ ├── micropython_async_B_mapper.py │ ├── module_protos.py │ ├── og_B_mapper.py │ ├── pyside_B_mapper.py │ ├── python_B_mapper.py │ ├── qgenada_B_mapper.py │ ├── qgenc_B_mapper.py │ ├── rtds_B_mapper.py │ ├── scade6_B_mapper.py │ ├── sdl_B_mapper.py │ ├── simulink_B_mapper.py │ ├── synchronousTool.py │ ├── vhdlTemplate.py │ ├── vhdlTemplateZestSC1.py │ ├── vhdl_B_mapper.py │ └── zestSC1_B_mapper.py ├── __init__.py ├── aadl2glueC.py ├── asn2aadlPlus.py ├── asn2dataModel.py ├── badTypes.py ├── commonPy │ ├── __init__.py.in │ ├── aadlAST.py │ ├── asnAST.py │ ├── asnParser.py │ ├── cleanupNodes.py │ ├── commonSMP2.py │ ├── configMT.py │ ├── createInternalTypes.py │ ├── recursiveMapper.py │ ├── utility.py │ └── verify.py ├── commonPy2 │ ├── AadlLexer.py │ ├── AadlParser.py │ ├── AadlParserTokenTypes.txt │ ├── __init__.py │ ├── aadl.g │ ├── aadlAST.py │ ├── configMT.py │ └── utility.py ├── msgPrinter.py ├── msgPrinterASN1.py ├── parse_aadl.py └── smp2asn.py ├── git-commit-hook └── pre-commit ├── pylint.cfg ├── requirements.txt ├── setup.py.in ├── setup_testdb.sh ├── tests-coverage ├── ConcurrencyView.aadl ├── DD_view.aadl ├── D_view.aadl ├── D_view.asn ├── DataTypesSimulink.asn ├── DataTypesSimulink.h ├── DataTypesSimulinkVHDL.asn ├── DataView.aadl ├── DataView.asn ├── DataView.pr ├── DataViewVHDL.aadl ├── Data_types.asn ├── Data_types_choice.asn ├── Makefile ├── Makefile.M2C ├── Makefile.M2M ├── Makefile.SMP2 ├── NoenumInt.aadl ├── NoenumInt.asn ├── NorangeInt.aadl ├── NorangeInt.asn ├── NorangeOct.aadl ├── NorangeOct.asn ├── NorangeReal.aadl ├── NorangeReal.asn ├── NorangeSeqof.aadl ├── NorangeSeqof.asn ├── README ├── checkCoverage.pl ├── common.mk ├── createGUIsection.py ├── gnc.aadl ├── mini_cv.aadl ├── mini_cv_vhdl.aadl ├── model.aadl ├── params └── review.pl └── tests-sqlalchemy ├── .gitignore ├── LotsOfDataTypes.asn ├── Makefile ├── commonTests.py ├── diagram.py └── testSQLengines.py /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | jobs: 3 | build: 4 | machine: true 5 | steps: 6 | - checkout 7 | - restore_cache: 8 | key: docker-{{ checksum "Dockerfile" }} 9 | - run: 10 | command: if [[ -e ~/docker/image.tar ]]; then docker load --input ~/docker/image.tar; else docker build -t dmt . && { mkdir -p ~/docker; docker save dmt > ~/docker/image.tar ; } ; fi 11 | - save_cache: 12 | key: docker-{{ checksum "Dockerfile" }} 13 | paths: 14 | - ~/docker 15 | - run: 16 | command: docker run -it -v $(pwd):/root/tests dmt bash -c 'cd /root/tests ; pip3 uninstall dmt ; ./configure ; pip3 install --upgrade . ; export CIRCLECI=1 ; LANG=C LC_ALL=C PATH=$PATH:/asn1scc make' 17 | -------------------------------------------------------------------------------- /.flake8: -------------------------------------------------------------------------------- 1 | [flake8] 2 | ignore = E501,E225,C103,E722,E252,W504 3 | max-line-length = 160 4 | -------------------------------------------------------------------------------- /.github/workflows/codeql-analysis.yml: -------------------------------------------------------------------------------- 1 | # For most projects, this workflow file will not need changing; you simply need 2 | # to commit it to your repository. 3 | # 4 | # You may wish to alter this file to override the set of languages analyzed, 5 | # or to provide custom queries or build logic. 6 | # 7 | # ******** NOTE ******** 8 | # We have attempted to detect the languages in your repository. Please check 9 | # the `language` matrix defined below to confirm you have the correct set of 10 | # supported CodeQL languages. 11 | # 12 | name: "CodeQL" 13 | 14 | on: 15 | push: 16 | branches: [ master ] 17 | pull_request: 18 | # The branches below must be a subset of the branches above 19 | branches: [ master ] 20 | schedule: 21 | - cron: '18 16 * * 3' 22 | 23 | jobs: 24 | analyze: 25 | name: Analyze 26 | runs-on: ubuntu-latest 27 | permissions: 28 | actions: read 29 | contents: read 30 | security-events: write 31 | 32 | strategy: 33 | fail-fast: false 34 | matrix: 35 | language: [ 'python' ] 36 | # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] 37 | # Learn more: 38 | # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed 39 | 40 | steps: 41 | - name: Checkout repository 42 | uses: actions/checkout@v2 43 | 44 | # Initializes the CodeQL tools for scanning. 45 | - name: Initialize CodeQL 46 | uses: github/codeql-action/init@v1 47 | with: 48 | languages: ${{ matrix.language }} 49 | # If you wish to specify custom queries, you can do so here or in a config file. 50 | # By default, queries listed here will override any specified in a config file. 51 | # Prefix the list here with "+" to use these queries and those in the config file. 52 | # queries: ./path/to/local/query, your-org/your-repo/queries@main 53 | 54 | # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). 55 | # If this step fails, then you should remove it and run the build manually (see below) 56 | - name: Autobuild 57 | uses: github/codeql-action/autobuild@v1 58 | 59 | # ℹ️ Command-line programs to run using the OS shell. 60 | # 📚 https://git.io/JvXDl 61 | 62 | # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines 63 | # and modify them (or add more) to build your code if your project 64 | # uses a compiled language 65 | 66 | #- run: | 67 | # make bootstrap 68 | # make release 69 | 70 | - name: Perform CodeQL Analysis 71 | uses: github/codeql-action/analyze@v1 72 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | *,cover 3 | .coverage 4 | tests-coverage/output 5 | tests-coverage/smp2.asn 6 | tests-coverage/datatypessimulink.cat 7 | tests-coverage/datatypessimulink.pkg 8 | tests-coverage/Simulink_DataView_asn.m 9 | *swp 10 | antlr-2.7.7 11 | asn1scc 12 | tests-sqlalchemy/sql.log 13 | tests-sqlalchemy/test.db 14 | tests-sqlalchemy/verifier/LotsOfDataTypes.asn 15 | tests-sqlalchemy/verifier/asn2dataModel/ 16 | .mypy_cache 17 | env 18 | aclocal.m4 19 | autom4te.cache/ 20 | config.log 21 | config.status 22 | setup.py 23 | dmt/commonPy/__init__.py 24 | -------------------------------------------------------------------------------- /.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | # image: $CI_REGISTRY_IMAGE/taste:latest 2 | image: dmt:latest 3 | 4 | variables: 5 | GIT_SUBMODULE_STRATEGY: recursive 6 | 7 | stages: 8 | - build 9 | - post_build 10 | 11 | build: 12 | stage: build 13 | script: 14 | - ./configure ; pip3 install --upgrade . ; LANG=C LC_ALL=C PATH=$PATH:/asn1scc make 15 | # artifacts: 16 | # paths: 17 | # - 'test/logs/*.err.txt' 18 | # when: on_failure 19 | # expire_in: 2 weeks 20 | -------------------------------------------------------------------------------- /CHANGELOG: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | ## 2.1.2 4 | 5 | - Use Unsigned_32 in Dataview.aadl to support large messages 6 | 7 | ## 2.1.1 8 | 9 | - Moved to statically imported (and verifiable by mypy) A and B mappers 10 | 11 | ## 2.1.0 12 | 13 | - Major update of the PySide B mapper (API updates) 14 | - Bug fix in the Python A mapper 15 | 16 | ## 2.0.0 17 | 18 | - Moved to Python3 19 | - Added type annotations, checked via mypy 20 | - Added git commit hooks to check via flake8 AND pylint 21 | - Configuration files used to customize the checks for the project's 22 | naming conventions. 23 | - Many bugs identified and fixed. 24 | 25 | ## 1.2.3 26 | - ctypes backend: emit all ENUMERATED values in DV.py 27 | 28 | ## 1.2.0 29 | - Not using SWIG anymore for the Python mappers 30 | 31 | ## 1.1.2 32 | - pyside_b_mapper: added combo box for the asn1 value editor 33 | 34 | ## 1.1.1 35 | - support empty SEQUENCEs (MyType ::= SEQUENCE {}) - except for Simulink 36 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM debian:stretch 2 | 3 | RUN bash -c "echo -e 'Acquire::http::Pipeline-Depth 0;\nAcquire::http::No-Cache true;\nAcquire::BrokenProxy true;\n' > /etc/apt/apt.conf.d/99badproxies" 4 | RUN cat /etc/apt/apt.conf.d/99badproxies 5 | RUN apt-get update 6 | RUN apt-get install -y libxslt-dev libxml2-dev python-psycopg2 mono-runtime libmono-system-data4.0-cil libmono-system-web4.0-cil libfsharp-core4.3-cil libpq-dev 7 | RUN apt-get install -y wget python3-pip 8 | RUN wget -O - -q https://github.com/ttsiodras/asn1scc/releases/download/4.2.0.1.f/asn1scc-bin-4.2.0.1f.tar.bz2 | tar jxvf - 9 | RUN apt-get install -y python-pip 10 | RUN wget -O - -q https://github.com/ttsiodras/DataModellingTools/files/335591/antlr-2.7.7.tar.gz | tar zxvf - ; cd antlr-2.7.7/lib/python ; pip2 install . 11 | RUN pip2 install --upgrade SQLAlchemy psycopg2 12 | COPY requirements.txt /tmp/ 13 | RUN pip3 install -r /tmp/requirements.txt 14 | RUN apt-get install less 15 | RUN apt-get install -y postgresql 16 | COPY setup_testdb.sh /tmp/ 17 | RUN /tmp/setup_testdb.sh 18 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | (C) Semantix Information Technologies. 2 | 3 | Semantix Information Technologies is licensing the code of the 4 | Data Modelling Tools (DMT) in the following dual-license mode: 5 | 6 | Commercial Developer License: 7 | The DMT Commercial Developer License is the suggested version 8 | to use for the development of proprietary and/or commercial software. 9 | This version is for developers/companies who do not want to comply 10 | with the terms of the GNU Lesser General Public License version 2.1. 11 | 12 | GNU LGPL v. 2.1: 13 | This version of DMT is the one to use for the development of 14 | applications, when you are willing to comply with the terms of the- 15 | GNU Lesser General Public License version 2.1. 16 | 17 | Note that in both cases, there are no charges (royalties) for the 18 | generated code. 19 | 20 | To purchase a commercial developer license (covering the entire 21 | DMT toolchain), please contact Semantix at: dmt@semantix.gr 22 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include dmt/B_mappers/VHDL-templates.tar.bz2 2 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | PY_SRC:=$(wildcard dmt/asn2dataModel.py dmt/aadl2glueC.py dmt/smp2asn.py dmt/*mappers/[a-zA-Z]*py dmt/commonPy/[a-zA-Z]*py) 2 | PY_SRC:=$(filter-out dmt/B_mappers/antlr.main.py dmt/A_mappers/Stubs.py dmt/B_mappers/micropython_async_B_mapper.py dmt/commonPy/commonSMP2.py, ${PY_SRC}) 3 | 4 | # Python3.5 includes an older version of typing, which by default has priority over 5 | # the one installed in $HOME/.local via setup.py. 6 | # 7 | # To address this, we find where our pip-installed typing lives: 8 | TYPING_FOLDER:=$(shell pip3 show typing 2>/dev/null | grep ^Location | sed 's,^.*: ,,') 9 | export PYTHONPATH=${TYPING_FOLDER} 10 | 11 | all: tests 12 | 13 | tests: flake8 pylint coverage testDB 14 | 15 | configure: 16 | ./configure 17 | 18 | install: configure 19 | pip3 uninstall -y dmt || exit 0 # Uninstall if there, but don't abort if not installed 20 | pip3 install --user . 21 | 22 | flake8: 23 | @echo Performing syntax checks via flake8... 24 | @flake8 ${PY_SRC} || exit 1 25 | 26 | pylint: 27 | @echo Performing static analysis via pylint... 28 | @pylint --disable=I --rcfile=pylint.cfg ${PY_SRC} 29 | 30 | mypy: 31 | @echo Performing type analysis via mypy... 32 | @mypy --disallow-untyped-defs --check-untyped-defs --ignore-missing-imports ${PY_SRC} || exit 1 33 | 34 | coverage: 35 | @echo Performing coverage checks... 36 | @$(MAKE) -C tests-coverage || exit 1 37 | 38 | testDB: 39 | @echo Installing DMT for local user... 40 | @pip3 install . 41 | @echo Performing database tests... 42 | @$(MAKE) -C tests-sqlalchemy || exit 1 43 | 44 | .PHONY: flake8 pylint mypy coverage install configure 45 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Build and Test Status of Data Modelling Tools on Gitlab CI](https://gitrepos.estec.esa.int/taste/dmt/badges/master/pipeline.svg)](https://gitrepos.estec.esa.int/taste/dmt/-/commits/master) 2 | 3 | TASTE Data Modelling Tools 4 | ========================== 5 | 6 | These are the tools used by the European Space Agency's [TASTE toolchain](https://taste.tools/) 7 | to automate handling of the Data Modelling. They include more than two 8 | dozen codegenerators that automatically create the 'glue'; that is, the run-time translation 9 | bridges that allow code generated by modelling tools (Simulink, SCADE, OpenGeode, etc) 10 | to "speak" to one another, via ASN.1 marshalling. 11 | 12 | For the encoders and decoders of the messages 13 | themselves, TASTE uses [ASN1SCC](https://github.com/ttsiodras/asn1scc) - an ASN.1 14 | compiler specifically engineered for safety-critical environments. 15 | 16 | For more details, visit the [TASTE site](https://taste.tools/). 17 | 18 | Installation 19 | ------------ 20 | 21 | For using the tools, this should suffice: 22 | 23 | $ sudo apt-get install libxslt1-dev libxml2-dev zlib1g-dev python3-pip 24 | $ ./configure 25 | $ # Optionally, configure a Python virtual environment (via venv) 26 | $ # to avoid "polluting" your system-level Python with dependencies 27 | $ # you may not want. 28 | # # But whether with an activated venv or not, you end with: 29 | $ pip3 install --user --upgrade . 30 | 31 | For developing the tools, the packaged Makefile allow for easy static-analysis 32 | via the dominant Python static analyzers and syntax checkers: 33 | 34 | $ make flake8 # check for pep8 compliance 35 | $ make pylint # static analysis with pylint 36 | $ make mypy # type analysis with mypy 37 | 38 | Contents 39 | -------- 40 | 41 | What is packaged: 42 | 43 | - **commonPy** (*library*) 44 | 45 | Contains the basic API for parsing ASN.1 (via invocation of 46 | [ASN1SCC](https://github.com/ttsiodras/asn1scc) and simplification 47 | of the generated XML AST representation to the Python classes 48 | inside `asnAST.py`. The class diagram with the AST classes 49 | is [packaged in the code](dmt/commonPy/asnAST.py#L42). 50 | 51 | - **asn2aadlPlus** (*utility*) 52 | 53 | Converts the type declarations inside ASN.1 grammars to AADL 54 | declarations, that are used by [Ocarina](https://github.com/OpenAADL/ocarina) 55 | to generate the executable containers. 56 | 57 | - **asn2dataModel** (*utility*) 58 | 59 | Reads the ASN.1 specification of the exchanged messages, and generates 60 | the semantically equivalent Modeling tool/Modeling language declarations 61 | (e.g. SCADE/Lustre, Matlab/Simulink, etc). 62 | 63 | The actual mapping logic exists in plugins, called *A mappers* 64 | (`simulink_A_mapper.py` handles Simulink/RTW, `scade6_A_mapper.py` 65 | handles SCADE6, `ada_A_mapper.py` generates Ada types, 66 | `sqlalchemy_A_mapper.py`, generates SQL definitions via SQLAlchemy, etc) 67 | 68 | - **aadl2glueC** (*utility*) 69 | 70 | Reads the AADL specification of the system, and then generates the runtime 71 | bridge-code that will map the message data structures from those generated 72 | by [ASN1SCC](https://github.com/ttsiodras/asn1scc) to/from those generated 73 | by the modeling tool (that is used to functionally model the subsystem; 74 | e.g. SCADE, ObjectGeode, Matlab/Simulink, C, Ada, etc). 75 | 76 | Contact 77 | ------- 78 | 79 | For bug reports, please use the Issue Tracker; for any other communication, 80 | contact me at: 81 | 82 | Thanassis Tsiodras 83 | Real-time Embedded Software Engineer 84 | System, Software and Technology Department 85 | European Space Agency 86 | 87 | ESTEC / TEC-SWT 88 | Keplerlaan 1, PO Box 299 89 | NL-2200 AG Noordwijk, The Netherlands 90 | Athanasios.Tsiodras@esa.int | www.esa.int 91 | T +31 71 565 5332 92 | -------------------------------------------------------------------------------- /ac-macros/revision_utils.m4: -------------------------------------------------------------------------------- 1 | # Automake macro to set the revision utils 2 | 3 | # Usage: AM_REVISION_UTILS([directory_name]). 4 | # Directory name must be a litteral string and not the result of a 5 | # command. 6 | 7 | AC_DEFUN([AM_REVISION_UTILS], 8 | [ 9 | # Take the current SVN revision 10 | 11 | AC_MSG_CHECKING(whether this is a SCM working copy) 12 | 13 | temp_scm_output=`(cd $srcdir; git rev-parse --short HEAD)` 14 | 15 | if test x"${temp_scm_output}" = x""; then 16 | # This means we are NOT working on a repository copy, the value of 17 | # SCM_REVISION will not be taken into account. 18 | 19 | SCM_REVISION="" 20 | AC_MSG_RESULT(no.) 21 | else 22 | SCM_REVISION="r${temp_scm_output}" 23 | AC_MSG_RESULT(yes: ${SCM_REVISION}.) 24 | fi 25 | 26 | AC_SUBST(SCM_REVISION) 27 | 28 | # Take the configure full date 29 | 30 | AC_MSG_CHECKING(the configuration full date) 31 | 32 | temp_config_date=`LANG=C date +"%A %d %B %Y, %H:%M:%S"` 33 | 34 | if test x"${temp_config_date}" = x""; then 35 | LAST_CONFIG_DATE="" 36 | AC_MSG_RESULT(empty date.) 37 | else 38 | LAST_CONFIG_DATE="${temp_config_date}" 39 | AC_MSG_RESULT(${LAST_CONFIG_DATE}.) 40 | fi 41 | 42 | AC_SUBST(LAST_CONFIG_DATE) 43 | 44 | # Take the configure year 45 | 46 | AC_MSG_CHECKING(the configuration year) 47 | 48 | temp_config_year=`LANG=C date +"%Y"` 49 | 50 | if test x"${temp_config_year}" = x""; then 51 | LAST_CONFIG_YEAR="2007" 52 | AC_MSG_RESULT(no year found, fall into default: ${LAST_CONFIG_YEAR}.) 53 | else 54 | LAST_CONFIG_YEAR="${temp_config_year}" 55 | AC_MSG_RESULT(${LAST_CONFIG_YEAR}) 56 | fi 57 | 58 | AC_SUBST(LAST_CONFIG_YEAR) 59 | ]) 60 | -------------------------------------------------------------------------------- /acinclude.m4: -------------------------------------------------------------------------------- 1 | m4_include([ac-macros/revision_utils.m4]) 2 | -------------------------------------------------------------------------------- /configure.ac: -------------------------------------------------------------------------------- 1 | AC_INIT([DMT], [2.2], [Thanassis.Tsiodras@esa.int]) 2 | 3 | AC_CONFIG_MACRO_DIR([ac-macros]) 4 | 5 | AM_REVISION_UTILS 6 | 7 | # Finally create all the generated files 8 | AC_CONFIG_FILES([setup.py dmt/commonPy/__init__.py]) 9 | AC_OUTPUT 10 | -------------------------------------------------------------------------------- /dmt/A_mappers/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | """ 5 | asn2dataModel converts ASN.1 modules to a variety of target languages 6 | """ 7 | 8 | from ..commonPy import __version__ 9 | -------------------------------------------------------------------------------- /dmt/A_mappers/ada_A_mapper.py: -------------------------------------------------------------------------------- 1 | # 2 | # (C) Semantix Information Technologies. 3 | # 4 | # Semantix Information Technologies is licensing the code of the 5 | # Data Modelling Tools (DMT) in the following dual-license mode: 6 | # 7 | # Commercial Developer License: 8 | # The DMT Commercial Developer License is the suggested version 9 | # to use for the development of proprietary and/or commercial software. 10 | # This version is for developers/companies who do not want to comply 11 | # with the terms of the GNU Lesser General Public License version 2.1. 12 | # 13 | # GNU LGPL v. 2.1: 14 | # This version of DMT is the one to use for the development of 15 | # applications, when you are willing to comply with the terms of the 16 | # GNU Lesser General Public License version 2.1. 17 | # 18 | # Note that in both cases, there are no charges (royalties) for the 19 | # generated code. 20 | # 21 | '''This contains the implementation of model level mapping 22 | of ASN.1 constructs to C. It is used as a backend of Semantix's 23 | code generator A.''' 24 | 25 | import os 26 | import sys 27 | from distutils import spawn 28 | 29 | from typing import List 30 | from ..commonPy.utility import panic 31 | from ..commonPy.cleanupNodes import SetOfBadTypenames 32 | from ..commonPy.asnAST import AsnBasicNode, AsnSequenceOrSet, AsnSequenceOrSetOf, AsnEnumerated, AsnChoice 33 | from ..commonPy.asnParser import AST_Leaftypes 34 | 35 | 36 | def Version() -> None: 37 | print("Code generator: " + "$Id: ada_A_mapper.py 2382 2012-06-22 08:35:33Z ttsiodras $") # pragma: no cover 38 | 39 | 40 | # Especially for the C mapper, since we need to pass the complete ASN.1 files list to ASN1SCC, 41 | # the second param is not asnFile, it is asnFiles 42 | 43 | 44 | def OnStartup(unused_modelingLanguage: str, asnFiles: List[str], outputDir: str, unused_badTypes: SetOfBadTypenames) -> None: # pylint: disable=invalid-sequence-index 45 | # print "Use ASN1SCC to generate the structures for '%s'" % asnFile 46 | asn1SccPath = spawn.find_executable('asn1.exe') 47 | if not asn1SccPath: 48 | panic("ASN1SCC seems to be missing from your system (asn1.exe not found in PATH).\n") # pragma: no cover 49 | # allow externally-defined flags when calling the asn1 compiler (e.g. to set word size based on target) 50 | extraFlags = os.getenv("ASN1SCC_FLAGS") or "" 51 | os.system( 52 | ("mono " if sys.platform.startswith('linux') else "") + 53 | "\"{}\" -typePrefix asn1Scc -equal -Ada {} -o \"".format(asn1SccPath, extraFlags) + 54 | outputDir + "\" \"" + "\" \"".join(asnFiles) + "\"") 55 | # os.system("rm -f \"" + outputDir + "\"/*.adb") 56 | 57 | 58 | def OnBasic(unused_nodeTypename: str, unused_node: AsnBasicNode, unused_leafTypeDict: AST_Leaftypes) -> None: 59 | pass # pragma: no cover 60 | 61 | 62 | def OnSequence(unused_nodeTypename: str, unused_node: AsnSequenceOrSet, unused_leafTypeDict: AST_Leaftypes) -> None: 63 | pass # pragma: no cover 64 | 65 | 66 | def OnSet(unused_nodeTypename: str, unused_node: AsnSequenceOrSet, unused_leafTypeDict: AST_Leaftypes) -> None: 67 | pass # pragma: no cover 68 | 69 | 70 | def OnEnumerated(unused_nodeTypename: str, unused_node: AsnEnumerated, unused_leafTypeDict: AST_Leaftypes) -> None: 71 | pass # pragma: no cover 72 | 73 | 74 | def OnSequenceOf(unused_nodeTypename: str, unused_node: AsnSequenceOrSetOf, unused_leafTypeDict: AST_Leaftypes) -> None: 75 | pass # pragma: no cover 76 | 77 | 78 | def OnSetOf(unused_nodeTypename: str, unused_node: AsnSequenceOrSetOf, unused_leafTypeDict: AST_Leaftypes) -> None: 79 | pass # pragma: no cover 80 | 81 | 82 | def OnChoice(unused_nodeTypename: str, unused_node: AsnChoice, unused_leafTypeDict: AST_Leaftypes) -> None: 83 | pass # pragma: no cover 84 | 85 | 86 | def OnShutdown(unused_badTypes: SetOfBadTypenames) -> None: 87 | pass # pragma: no cover 88 | -------------------------------------------------------------------------------- /dmt/A_mappers/c_A_mapper.py: -------------------------------------------------------------------------------- 1 | # 2 | # (C) Semantix Information Technologies. 3 | # 4 | # Semantix Information Technologies is licensing the code of the 5 | # Data Modelling Tools (DMT) in the following dual-license mode: 6 | # 7 | # Commercial Developer License: 8 | # The DMT Commercial Developer License is the suggested version 9 | # to use for the development of proprietary and/or commercial software. 10 | # This version is for developers/companies who do not want to comply 11 | # with the terms of the GNU Lesser General Public License version 2.1. 12 | # 13 | # GNU LGPL v. 2.1: 14 | # This version of DMT is the one to use for the development of 15 | # applications, when you are willing to comply with the terms of the 16 | # GNU Lesser General Public License version 2.1. 17 | # 18 | # Note that in both cases, there are no charges (royalties) for the 19 | # generated code. 20 | # 21 | '''This contains the implementation of model level mapping 22 | of ASN.1 constructs to C. It is used as a backend of Semantix's 23 | code generator A.''' 24 | 25 | import os 26 | import sys 27 | from distutils import spawn 28 | from typing import List 29 | 30 | from ..commonPy.utility import panic 31 | from ..commonPy.cleanupNodes import SetOfBadTypenames 32 | from ..commonPy.asnAST import AsnBasicNode, AsnSequenceOrSet, AsnSequenceOrSetOf, AsnEnumerated, AsnChoice 33 | from ..commonPy.asnParser import AST_Leaftypes 34 | 35 | 36 | def Version() -> None: 37 | print("Code generator: " + "$Id: c_A_mapper.py 2382 2012-06-22 08:35:33Z ttsiodras $") # pragma: no cover 38 | 39 | 40 | # Especially for the C mapper, since we need to pass the complete ASN.1 files list to ASN1SCC, 41 | # the second param is not asnFile, it is asnFiles 42 | 43 | def OnStartup(unused_modelingLanguage: str, asnFiles: List[str], outputDir: str, unused_badTypes: SetOfBadTypenames) -> None: # pylint: disable=invalid-sequence-index 44 | # print "Use ASN1SCC to generate the structures for '%s'" % asnFile 45 | asn1SccPath = spawn.find_executable('asn1.exe') 46 | if not asn1SccPath: 47 | panic("ASN1SCC seems to be missing from your system (asn1.exe not found in PATH).\n") # pragma: no cover 48 | os.system( 49 | ("mono " if sys.platform.startswith('linux') else "") + 50 | "\"{}\" -typePrefix asn1Scc -c -uPER -o \"".format(asn1SccPath) + 51 | outputDir + "\" \"" + "\" \"".join(asnFiles) + "\"") 52 | # cmd = 'rm -f ' 53 | # for i in ['real.c', 'asn1crt.c', 'acn.c']: 54 | # cmd += ' "' + outputDir + '"/' + i 55 | # os.system(cmd) 56 | # for tmp in asnFiles: 57 | # os.system("rm -f \"" + outputDir + os.sep + os.path.basename(os.path.splitext(tmp)[0]) + ".c\"") 58 | 59 | 60 | def OnBasic(unused_nodeTypename: str, unused_node: AsnBasicNode, unused_leafTypeDict: AST_Leaftypes) -> None: 61 | pass # pragma: no cover 62 | 63 | 64 | def OnSequence(unused_nodeTypename: str, unused_node: AsnSequenceOrSet, unused_leafTypeDict: AST_Leaftypes) -> None: 65 | pass # pragma: no cover 66 | 67 | 68 | def OnSet(unused_nodeTypename: str, unused_node: AsnSequenceOrSet, unused_leafTypeDict: AST_Leaftypes) -> None: 69 | pass # pragma: no cover 70 | 71 | 72 | def OnEnumerated(unused_nodeTypename: str, unused_node: AsnEnumerated, unused_leafTypeDict: AST_Leaftypes) -> None: 73 | pass # pragma: no cover 74 | 75 | 76 | def OnSequenceOf(unused_nodeTypename: str, unused_node: AsnSequenceOrSetOf, unused_leafTypeDict: AST_Leaftypes) -> None: 77 | pass # pragma: no cover 78 | 79 | 80 | def OnSetOf(unused_nodeTypename: str, unused_node: AsnSequenceOrSetOf, unused_leafTypeDict: AST_Leaftypes) -> None: 81 | pass # pragma: no cover 82 | 83 | 84 | def OnChoice(unused_nodeTypename: str, unused_node: AsnChoice, unused_leafTypeDict: AST_Leaftypes) -> None: 85 | pass # pragma: no cover 86 | 87 | 88 | def OnShutdown(unused_badTypes: SetOfBadTypenames) -> None: 89 | pass # pragma: no cover 90 | -------------------------------------------------------------------------------- /dmt/A_mappers/learn_CHOICE_enums.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2 2 | import os 3 | import sys 4 | choices = [] 5 | enums = [] 6 | bEnum = False 7 | 8 | ''' Parse the ASN.1-generated header file and extract the constants used for 9 | CHOICE determinants (#define det..._PRESENT) and ENUMERATED values 10 | Emit strings that are appended to DV.py from Makefile.python 11 | There is no name clash thanks to the rename policy of the ASN.1 compiler 12 | (a constant cannot be defined twice) 13 | ''' 14 | 15 | for line in open(sys.argv[1] + '.h', 'r'): 16 | if '_PRESENT' in line and not line.startswith('#define'): 17 | choices.append(line.strip().replace(",", "")) 18 | bEnum = False 19 | elif line.strip().startswith('typedef enum {'): 20 | bEnum = True 21 | elif line.strip().startswith('}') and bEnum: 22 | bEnum = False 23 | elif '_NONE' in line or '_PRESENT' in line: 24 | bEnum = False 25 | elif bEnum: 26 | enums.append(line.strip().replace(",", "").split("=")) 27 | 28 | enums_dump = "\n ".join( 29 | 'printf("%s = %%d\\n", %s);' % (e, e) 30 | for e in choices 31 | ) 32 | 33 | enums_dump += "\n ".join( 34 | 'printf("{} = {}\\n");'.format(name.strip(), val.replace('LL', '')) 35 | for name, val in enums 36 | ) 37 | uniq = os.getpid() 38 | extractor_filename = "/tmp/enums_%d" % uniq 39 | f = open(extractor_filename + ".c", 'w') 40 | f.write(""" 41 | #include 42 | #include "%(base)s.h" 43 | 44 | void main() 45 | { 46 | %(enums_dump)s 47 | }""" % {"enums_dump": enums_dump, "base": sys.argv[1]}) 48 | f.close() 49 | cmd = "gcc -o %s -I. %s.c" % (extractor_filename, extractor_filename) 50 | if os.system(cmd) != 0: 51 | print("Failed to extract CHOICE enum values...") 52 | sys.exit(1) 53 | os.system(extractor_filename) 54 | os.unlink(extractor_filename + ".c") 55 | os.unlink(extractor_filename) 56 | -------------------------------------------------------------------------------- /dmt/A_mappers/module_protos.py: -------------------------------------------------------------------------------- 1 | from types import ModuleType 2 | from typing import List, Union 3 | 4 | from ..commonPy.asnAST import AsnNode # NOQA pylint: disable=unused-import 5 | from ..commonPy.asnParser import Filename, Typename, AST_Lookup, AST_TypesOfFile, AST_Leaftypes # NOQA pylint: disable=unused-import 6 | from ..commonPy.cleanupNodes import SetOfBadTypenames 7 | 8 | 9 | Filename_Or_ListOfFilenames = Union[str, List[str]] # pylint: disable=invalid-sequence-index 10 | 11 | 12 | class A_Mapper(ModuleType): 13 | def OnStartup( 14 | self, modelingLanguage: str, asnFile: Filename_Or_ListOfFilenames, 15 | outputDir: str, badTypes: SetOfBadTypenames) -> None: 16 | pass 17 | 18 | def OnBasic(self, nodeTypename: str, node: AsnNode, leafTypeDict: AST_Leaftypes) -> None: 19 | pass 20 | 21 | def OnSequence(self, nodeTypename: str, node: AsnNode, leafTypeDict: AST_Leaftypes) -> None: 22 | pass 23 | 24 | def OnSet(self, nodeTypename: str, node: AsnNode, leafTypeDict: AST_Leaftypes) -> None: 25 | pass 26 | 27 | def OnChoice(self, nodeTypename: str, node: AsnNode, leafTypeDict: AST_Leaftypes) -> None: 28 | pass 29 | 30 | def OnSequenceOf(self, nodeTypename: str, node: AsnNode, leafTypeDict: AST_Leaftypes) -> None: 31 | pass 32 | 33 | def OnSetOf(self, nodeTypename: str, node: AsnNode, leafTypeDict: AST_Leaftypes) -> None: 34 | pass 35 | 36 | def OnEnumerated(self, nodeTypename: str, node: AsnNode, leafTypeDict: AST_Leaftypes) -> None: 37 | pass 38 | 39 | def OnShutdown(self, badTypes: SetOfBadTypenames) -> None: 40 | pass 41 | -------------------------------------------------------------------------------- /dmt/A_mappers/og_A_mapper.py: -------------------------------------------------------------------------------- 1 | # 2 | # (C) Semantix Information Technologies. 3 | # 4 | # Semantix Information Technologies is licensing the code of the 5 | # Data Modelling Tools (DMT) in the following dual-license mode: 6 | # 7 | # Commercial Developer License: 8 | # The DMT Commercial Developer License is the suggested version 9 | # to use for the development of proprietary and/or commercial software. 10 | # This version is for developers/companies who do not want to comply 11 | # with the terms of the GNU Lesser General Public License version 2.1. 12 | # 13 | # GNU LGPL v. 2.1: 14 | # This version of DMT is the one to use for the development of 15 | # applications, when you are willing to comply with the terms of the 16 | # GNU Lesser General Public License version 2.1. 17 | # 18 | # Note that in both cases, there are no charges (royalties) for the 19 | # generated code. 20 | # 21 | # This is an evolving test implementation of mapping ASN.1 constructs 22 | # to SDL. It is used by the backend of Semantix's code generator A. 23 | 24 | # import re 25 | 26 | from ..commonPy import asnParser 27 | from ..commonPy.cleanupNodes import SetOfBadTypenames 28 | from ..commonPy.asnAST import AsnBasicNode, AsnSequenceOrSet, AsnSequenceOrSetOf, AsnEnumerated, AsnChoice 29 | from ..commonPy.asnParser import AST_Leaftypes 30 | 31 | g_outputDir = "" 32 | g_asnFile = "" 33 | 34 | 35 | def Version() -> None: 36 | print("Code generator: " + "$Id: og_A_mapper.py 2382 2012-06-22 08:35:33Z ttsiodras $") # pragma: no cover 37 | 38 | 39 | def OnStartup(unused_modelingLanguage: str, asnFile: str, outputDir: str, unused_badTypes: SetOfBadTypenames) -> None: 40 | global g_asnFile 41 | g_asnFile = asnFile 42 | global g_outputDir 43 | g_outputDir = outputDir 44 | 45 | 46 | def OnBasic(unused_nodeTypename: str, unused_node: AsnBasicNode, unused_leafTypeDict: AST_Leaftypes) -> None: 47 | pass 48 | 49 | 50 | def OnSequence(unused_nodeTypename: str, unused_node: AsnSequenceOrSet, unused_leafTypeDict: AST_Leaftypes) -> None: 51 | pass 52 | 53 | 54 | def OnSet(unused_nodeTypename: str, unused_node: AsnSequenceOrSet, unused_leafTypeDict: AST_Leaftypes) -> None: 55 | pass # pragma: nocover 56 | 57 | 58 | def OnEnumerated(unused_nodeTypename: str, unused_node: AsnEnumerated, unused_leafTypeDict: AST_Leaftypes) -> None: 59 | pass 60 | 61 | 62 | def OnSequenceOf(unused_nodeTypename: str, unused_node: AsnSequenceOrSetOf, unused_leafTypeDict: AST_Leaftypes) -> None: 63 | pass 64 | 65 | 66 | def OnSetOf(unused_nodeTypename: str, unused_node: AsnSequenceOrSetOf, unused_leafTypeDict: AST_Leaftypes) -> None: 67 | pass # pragma: nocover 68 | 69 | 70 | def OnChoice(unused_nodeTypename: str, unused_node: AsnChoice, unused_leafTypeDict: AST_Leaftypes) -> None: 71 | pass 72 | 73 | # obsolete, now the grammar is re-created from the AST (PrintGrammarFromAST) 74 | # 75 | # def ClearUp(text): 76 | # outputText = "" 77 | # lParen = 0 78 | # for c in text: 79 | # if c == '(': 80 | # lParen += 1 81 | # if c == ')': 82 | # lParen -= 1 83 | # if 0 == lParen: 84 | # outputText += c.replace('-', '_') 85 | # else: 86 | # outputText += c 87 | # return outputText 88 | 89 | 90 | def OnShutdown(unused_badTypes: SetOfBadTypenames) -> None: 91 | # text = open(g_asnFile, 'r').read() 92 | # text = re.sub(r'^.*BEGIN', 'Datamodel DEFINITIONS ::= BEGIN', text) 93 | # text = re.sub(r'--.*', '', text) 94 | outputFile = open(g_outputDir + "DataView.pr", 'w') 95 | outputFile.write('Datamodel DEFINITIONS ::= BEGIN\n\n') 96 | asnParser.PrintGrammarFromAST(outputFile) 97 | outputFile.write('END\n') 98 | outputFile.close() 99 | -------------------------------------------------------------------------------- /dmt/A_mappers/rtds_A_mapper.py: -------------------------------------------------------------------------------- 1 | # 2 | # (C) Semantix Information Technologies. 3 | # 4 | # Semantix Information Technologies is licensing the code of the 5 | # Data Modelling Tools (DMT) in the following dual-license mode: 6 | # 7 | # Commercial Developer License: 8 | # The DMT Commercial Developer License is the suggested version 9 | # to use for the development of proprietary and/or commercial software. 10 | # This version is for developers/companies who do not want to comply 11 | # with the terms of the GNU Lesser General Public License version 2.1. 12 | # 13 | # GNU LGPL v. 2.1: 14 | # This version of DMT is the one to use for the development of 15 | # applications, when you are willing to comply with the terms of the 16 | # GNU Lesser General Public License version 2.1. 17 | # 18 | # Note that in both cases, there are no charges (royalties) for the 19 | # generated code. 20 | # 21 | '''Implementation of mapping ASN.1 constructs 22 | to RTDS. It is used by the backend of Semantix's code generator A.''' 23 | 24 | import re 25 | 26 | from ..commonPy.cleanupNodes import SetOfBadTypenames 27 | from ..commonPy.asnParser import AST_Leaftypes, AsnNode 28 | from ..commonPy.asnAST import AsnSequenceOrSet, AsnSequenceOrSetOf, AsnEnumerated, AsnChoice 29 | 30 | g_outputDir = "" 31 | g_asnFile = "" 32 | 33 | 34 | def Version() -> None: 35 | print("Code generator: " + "$Id: og_A_mapper.py 1879 2010-05-17 10:13:12Z ttsiodras $") # pragma: no cover 36 | 37 | 38 | def OnStartup(unused_modelingLanguage: str, asnFile: str, outputDir: str, unused_badTypes: SetOfBadTypenames) -> None: 39 | global g_asnFile 40 | g_asnFile = asnFile 41 | global g_outputDir 42 | g_outputDir = outputDir 43 | 44 | 45 | def OnBasic(unused_nodeTypename: str, unused_node: AsnNode, unused_leafTypeDict: AST_Leaftypes) -> None: 46 | pass 47 | 48 | 49 | def OnSequence(unused_nodeTypename: str, unused_node: AsnSequenceOrSet, unused_leafTypeDict: AST_Leaftypes) -> None: 50 | pass 51 | 52 | 53 | def OnSet(unused_nodeTypename: str, unused_node: AsnSequenceOrSet, unused_leafTypeDict: AST_Leaftypes) -> None: 54 | pass # pragma: no cover 55 | 56 | 57 | def OnEnumerated(unused_nodeTypename: str, unused_node: AsnEnumerated, unused_leafTypeDict: AST_Leaftypes) -> None: 58 | pass 59 | 60 | 61 | def OnSequenceOf(unused_nodeTypename: str, unused_node: AsnSequenceOrSetOf, unused_leafTypeDict: AST_Leaftypes) -> None: 62 | pass 63 | 64 | 65 | def OnSetOf(unused_nodeTypename: str, unused_node: AsnSequenceOrSetOf, unused_leafTypeDict: AST_Leaftypes) -> None: 66 | pass # pragma: no cover 67 | 68 | 69 | def OnChoice(unused_nodeTypename: str, unused_node: AsnChoice, unused_leafTypeDict: AST_Leaftypes) -> None: 70 | pass 71 | 72 | 73 | # obsolete, now the grammar is re-created from the AST (PrintGrammarFromAST) 74 | # 75 | # def ClearUp(text): 76 | # outputText = "" 77 | # lParen = 0 78 | # for c in text: 79 | # if c == '(': 80 | # lParen += 1 81 | # if c == ')': 82 | # lParen -= 1 83 | # if 0 == lParen: 84 | # outputText += c.replace('-', '_') 85 | # else: 86 | # outputText += c 87 | # return outputText 88 | 89 | def OnShutdown(unused_badTypes: SetOfBadTypenames) -> None: 90 | # text = open(g_asnFile, 'r').read() 91 | # text = re.sub(r'^.*BEGIN', 'Datamodel DEFINITIONS ::= BEGIN', text) 92 | # text = re.sub(r'--.*', '', text) 93 | # outputFile = open(g_outputDir + "DataView.pr", 'w') 94 | # outputFile.write('Datamodel DEFINITIONS ::= BEGIN\n\n') 95 | # import commonPy.xmlASTtoAsnAST 96 | # commonPy.xmlASTtoAsnAST.PrintGrammarFromAST(outputFile) 97 | # outputFile.write('END\n') 98 | # outputFile.close() 99 | 100 | outputFile = open(g_outputDir + "RTDSdataView.asn", 'w') 101 | outputFile.write(re.sub(r'^.*BEGIN', 'RTDSdataView DEFINITIONS ::= BEGIN', open(g_asnFile, 'r').read())) 102 | outputFile.close() 103 | -------------------------------------------------------------------------------- /dmt/A_mappers/vdm_A_mapper.py: -------------------------------------------------------------------------------- 1 | # 2 | # Wrapper around vdm.stg (packaged in the ASN1SCC compiler) 3 | # 4 | ''' 5 | This contains the implementation of model level mapping of 6 | ASN.1 constructs to VDM (via the excellent StringTemplate 7 | file created by Maxime Perrotin. 8 | ''' 9 | 10 | import os 11 | import sys 12 | from distutils import spawn 13 | 14 | from typing import List, Union 15 | from ..commonPy.utility import panic 16 | from ..commonPy.cleanupNodes import SetOfBadTypenames 17 | from ..commonPy.asnAST import AsnBasicNode, AsnSequenceOrSet, AsnSequenceOrSetOf, AsnEnumerated, AsnChoice 18 | from ..commonPy.asnParser import AST_Leaftypes 19 | 20 | 21 | def Version() -> None: 22 | print("Code generator: " + "$Id: vdm_A_mapper.py 2382 2012-06-22 08:35:33Z ttsiodras $") # pragma: no cover 23 | 24 | 25 | # Especially for the C mapper, since we need to pass the complete ASN.1 files list to ASN1SCC, 26 | # the second param is not asnFile, it is asnFiles 27 | 28 | 29 | def OnStartup(unused_modelingLanguage: str, asnFile: Union[str, List[str]], outputDir: str, unused_badTypes: SetOfBadTypenames) -> None: # pylint: disable=invalid-sequence-index 30 | # print "Use ASN1SCC to generate the structures for '%s'" % asnFile 31 | asn1SccPath = spawn.find_executable('asn1.exe') 32 | if not asn1SccPath: 33 | panic("ASN1SCC seems to be missing from your system (asn1.exe not found in PATH).\n") # pragma: no cover 34 | asn1SccFolder = os.path.dirname(asn1SccPath) 35 | cmd = ("mono " if sys.platform.startswith('linux') else "") 36 | cmd += "\"{}\" -customStg \"{}\"/vdm.stg:\"{}\"/out.vdm \"".format( 37 | asn1SccPath, asn1SccFolder, outputDir) 38 | if isinstance(asnFile, str): 39 | cmd += asnFile + "\"" 40 | else: 41 | cmd += "\" \"".join(asnFile) + "\"" 42 | if os.system(cmd) != 0: 43 | panic("ASN1SCC failed...") 44 | else: 45 | print("Generated:", os.path.realpath("\"{}\"/out.vdm".format(outputDir)).replace('/"./"/', '')) 46 | 47 | 48 | def OnBasic(unused_nodeTypename: str, unused_node: AsnBasicNode, unused_leafTypeDict: AST_Leaftypes) -> None: 49 | pass # pragma: no cover 50 | 51 | 52 | def OnSequence(unused_nodeTypename: str, unused_node: AsnSequenceOrSet, unused_leafTypeDict: AST_Leaftypes) -> None: 53 | pass # pragma: no cover 54 | 55 | 56 | def OnSet(unused_nodeTypename: str, unused_node: AsnSequenceOrSet, unused_leafTypeDict: AST_Leaftypes) -> None: 57 | pass # pragma: no cover 58 | 59 | 60 | def OnEnumerated(unused_nodeTypename: str, unused_node: AsnEnumerated, unused_leafTypeDict: AST_Leaftypes) -> None: 61 | pass # pragma: no cover 62 | 63 | 64 | def OnSequenceOf(unused_nodeTypename: str, unused_node: AsnSequenceOrSetOf, unused_leafTypeDict: AST_Leaftypes) -> None: 65 | pass # pragma: no cover 66 | 67 | 68 | def OnSetOf(unused_nodeTypename: str, unused_node: AsnSequenceOrSetOf, unused_leafTypeDict: AST_Leaftypes) -> None: 69 | pass # pragma: no cover 70 | 71 | 72 | def OnChoice(unused_nodeTypename: str, unused_node: AsnChoice, unused_leafTypeDict: AST_Leaftypes) -> None: 73 | pass # pragma: no cover 74 | 75 | 76 | def OnShutdown(unused_badTypes: SetOfBadTypenames) -> None: 77 | pass # pragma: no cover 78 | -------------------------------------------------------------------------------- /dmt/B_mappers/Makefile: -------------------------------------------------------------------------------- 1 | all: makeParser runTest 2 | 3 | makeParser: AadlParser.py 4 | 5 | AadlParser.py: aadl.g 6 | rm -f AadlLexer.py AadlParser.py 7 | runantlr -o . aadl.g || { echo You need to apt-get install antlr ; exit 1 ; } 8 | 9 | runTest: 10 | ./antlr.main.py < PierreToyExampleSystem.aadl 11 | -------------------------------------------------------------------------------- /dmt/B_mappers/PierreToyExampleSystem.aadl: -------------------------------------------------------------------------------- 1 | PACKAGE Functional_view 2 | PUBLIC 3 | 4 | SUBPROGRAM Dispatcher 5 | FEATURES 6 | TC : IN PARAMETER DataTypes::T_TC; 7 | END Dispatcher; 8 | 9 | SUBPROGRAM IMPLEMENTATION Dispatcher.AADL 10 | CALLS { 11 | TC_Parser : SUBPROGRAM TC_Parser.AADL; 12 | Tc_1 : SUBPROGRAM TC.POS; 13 | Tc_2 : SUBPROGRAM TC.PRO; 14 | }; 15 | CONNECTIONS 16 | PARAMETER TC -> TC_Parser.TC; 17 | PARAMETER TC_Parser.Param -> Tc_1.POS; 18 | PARAMETER TC_Parser.Param -> Tc_2.POS; 19 | PROPERTIES 20 | Source_Language => "Lustre"; 21 | END Dispatcher.AADL; 22 | 23 | SUBPROGRAM TC_Parser 24 | FEATURES 25 | TC : IN PARAMETER DataTypes::T_TC; 26 | Id : OUT PARAMETER DataTypes::T_POS; 27 | Param : OUT PARAMETER DataTypes::T_POS; 28 | PROPERTIES 29 | Source_Language => "Lustre"; 30 | END TC_Parser; 31 | 32 | SUBPROGRAM IMPLEMENTATION TC_Parser.AADL 33 | END TC_Parser.AADL; 34 | 35 | SUBPROGRAM TC 36 | FEATURES 37 | POS : IN PARAMETER DataTypes::T_POS; 38 | END TC; 39 | 40 | SUBPROGRAM IMPLEMENTATION TC.POS 41 | CALLS { 42 | Write : SUBPROGRAM Write.AADL; 43 | }; 44 | CONNECTIONS 45 | PARAMETER POS -> Write.POS; 46 | END TC.POS; 47 | 48 | SUBPROGRAM IMPLEMENTATION TC.PRO 49 | CALLS { 50 | Boost_Order : SUBPROGRAM Boost_Order.AADL; 51 | }; 52 | CONNECTIONS 53 | PARAMETER POS -> Boost_Order.POS; 54 | END TC.PRO; 55 | 56 | SUBPROGRAM Write 57 | FEATURES 58 | POS : IN PARAMETER DataTypes::T_POS; 59 | END Write; 60 | 61 | SUBPROGRAM Boost_Order 62 | FEATURES 63 | POS : IN PARAMETER DataTypes::T_POS; 64 | END Boost_Order; 65 | 66 | END Functional_view; 67 | -------------------------------------------------------------------------------- /dmt/B_mappers/VHDL-templates.tar.bz2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ttsiodras/DataModellingTools/980dda80cc05f85d7e3b56537c2aecd4ce2b8c76/dmt/B_mappers/VHDL-templates.tar.bz2 -------------------------------------------------------------------------------- /dmt/B_mappers/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | """ 5 | aadl2glueC : B mappers -generate code that convert from/to ASN1SCC 6 | """ 7 | 8 | from ..commonPy import __version__ 9 | -------------------------------------------------------------------------------- /dmt/B_mappers/ada_B_mapper.py: -------------------------------------------------------------------------------- 1 | # 2 | # (C) Semantix Information Technologies. 3 | # 4 | # Semantix Information Technologies is licensing the code of the 5 | # Data Modelling Tools (DMT) in the following dual-license mode: 6 | # 7 | # Commercial Developer License: 8 | # The DMT Commercial Developer License is the suggested version 9 | # to use for the development of proprietary and/or commercial software. 10 | # This version is for developers/companies who do not want to comply 11 | # with the terms of the GNU Lesser General Public License version 2.1. 12 | # 13 | # GNU LGPL v. 2.1: 14 | # This version of DMT is the one to use for the development of 15 | # applications, when you are willing to comply with the terms of the 16 | # GNU Lesser General Public License version 2.1. 17 | # 18 | # Note that in both cases, there are no charges (royalties) for the 19 | # generated code. 20 | # 21 | ''' 22 | This is the implementation of the code mapper for Ada code. 23 | As initially envisioned, ASSERT technology is not supposed 24 | to support manually-made systems. A migration path, however, 25 | that allows legacy hand-written code and modelling-tool 26 | generated code to co-exist, can be beneficial in allowing 27 | for a smooth transition. To that end, this backend (as well as 28 | the C one) are written. 29 | 30 | This is a backend for Semantix's code generator B (aadl2glueC). 31 | 32 | Ada is a member of the asynchronous "club" (SDL, etc); 33 | The subsystem developer (or rather, the APLC developer) is using 34 | native Ada code to work with code generated by modelling tools. 35 | To that end, this backend creates "glue" functions for input and 36 | output parameters, which have Ada callable interfaces. 37 | ''' 38 | 39 | # from commonPy.utility import panic 40 | # from recursiveMapper import RecursiveMapper 41 | # from asynchronousTool import ASynchronousToolGlueGenerator 42 | 43 | from . import c_B_mapper 44 | from ..commonPy.asnAST import AsnNode 45 | from ..commonPy.asnParser import AST_Lookup, AST_Leaftypes 46 | 47 | isAsynchronous = True 48 | cBackend = None 49 | 50 | 51 | def OnStartup(unused_modelingLanguage: str, asnFile: str, outputDir: str, maybeFVname: str, useOSS: bool) -> None: 52 | global cBackend 53 | # 2009-02-10: Since we now use ASN1SCC structures as dumpables (even for Ada) 54 | # we no longer need Ada-specific Dumpable structures. 55 | cBackend = c_B_mapper.C_GlueGenerator() 56 | cBackend.OnStartup("C", asnFile, outputDir, maybeFVname, useOSS) 57 | 58 | 59 | def OnBasic(nodeTypename: str, node: AsnNode, leafTypeDict: AST_Leaftypes, names: AST_Lookup) -> None: 60 | cBackend.OnBasic(nodeTypename, node, leafTypeDict, names) 61 | 62 | 63 | def OnSequence(nodeTypename: str, node: AsnNode, leafTypeDict: AST_Leaftypes, names: AST_Lookup) -> None: 64 | cBackend.OnSequence(nodeTypename, node, leafTypeDict, names) 65 | 66 | 67 | def OnSet(nodeTypename: str, node: AsnNode, leafTypeDict: AST_Leaftypes, names: AST_Lookup) -> None: 68 | cBackend.OnSet(nodeTypename, node, leafTypeDict, names) # pragma: nocover 69 | 70 | 71 | def OnEnumerated(nodeTypename: str, node: AsnNode, leafTypeDict: AST_Leaftypes, names: AST_Lookup) -> None: 72 | cBackend.OnEnumerated(nodeTypename, node, leafTypeDict, names) 73 | 74 | 75 | def OnSequenceOf(nodeTypename: str, node: AsnNode, leafTypeDict: AST_Leaftypes, names: AST_Lookup) -> None: 76 | cBackend.OnSequenceOf(nodeTypename, node, leafTypeDict, names) 77 | 78 | 79 | def OnSetOf(nodeTypename: str, node: AsnNode, leafTypeDict: AST_Leaftypes, names: AST_Lookup) -> None: 80 | cBackend.OnSetOf(nodeTypename, node, leafTypeDict, names) # pragma: nocover 81 | 82 | 83 | def OnChoice(nodeTypename: str, node: AsnNode, leafTypeDict: AST_Leaftypes, names: AST_Lookup) -> None: 84 | cBackend.OnChoice(nodeTypename, node, leafTypeDict, names) 85 | 86 | 87 | def OnShutdown(unused_modelingLanguage: str, asnFile: str, maybeFVname: str) -> None: 88 | cBackend.OnShutdown("C", asnFile, maybeFVname) 89 | -------------------------------------------------------------------------------- /dmt/B_mappers/antlr.main.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from . import AadlLexer 3 | from . import AadlParser 4 | import commonPy.aadlAST 5 | import commonPy.utility 6 | import antlr 7 | import sys 8 | 9 | 10 | def main(): 11 | if len(sys.argv) > 1: 12 | L = AadlLexer.Lexer(sys.argv[1]) 13 | else: 14 | L = AadlLexer.Lexer() 15 | P = AadlParser.Parser(L) 16 | P.setFilename(L.getFilename()) 17 | 18 | try: 19 | P.aadl_specification() 20 | except antlr.ANTLRException as e: 21 | commonPy.utility.panic("Error: %s\n" % (str(e))) 22 | 23 | SystemsAndImplementations = commonPy.aadlAST.g_subProgramImplementations[:] 24 | SystemsAndImplementations.extend(commonPy.aadlAST.g_threadImplementations[:]) 25 | SystemsAndImplementations.extend(commonPy.aadlAST.g_processImplementations[:]) 26 | for si in SystemsAndImplementations: 27 | sp, sp_impl, modelingLanguage, fv_name = si[0], si[1], si[2], si[3] 28 | sp = commonPy.aadlAST.g_apLevelContainers[sp] 29 | print(sp._id + "." + sp_impl, "(", modelingLanguage, ") FV_name:", fv_name) 30 | for param in sp._params: 31 | print("\t", end=' ') 32 | if isinstance(param, commonPy.aadlAST.InParam): 33 | print("IN", end=' ') 34 | elif isinstance(param, commonPy.aadlAST.OutParam): 35 | print("OUT", end=' ') 36 | elif isinstance(param, commonPy.aadlAST.InOutParam): 37 | print("INOUT", end=' ') 38 | if isinstance(param._signal, commonPy.aadlAST.Signal): 39 | print("\t", param._id, ":", param._signal._asnFilename, param._signal._asnNodename, "(", param._sourceElement._encoding, ")") 40 | else: 41 | print("\t", param._id, ":", param._signal, "(", param._sourceElement._encoding, ")") 42 | print() 43 | if len(sp._connections): 44 | print("\tConnections:") 45 | for pair in sp._connections: 46 | print("\t\tfrom", pair._from._componentId + ':' + pair._from._portId, "to", pair._to._componentId + ':' + pair._to._portId) 47 | print() 48 | 49 | if __name__ == "__main__": 50 | main() 51 | -------------------------------------------------------------------------------- /dmt/B_mappers/module_protos.py: -------------------------------------------------------------------------------- 1 | from types import ModuleType 2 | 3 | from ..commonPy.asnAST import AsnNode # NOQA pylint: disable=unused-import 4 | from ..commonPy.aadlAST import ApLevelContainer, Param # NOQA pylint: disable=unused-import 5 | from ..commonPy.asnParser import Filename, Typename, AST_Lookup, AST_TypesOfFile, AST_Leaftypes # NOQA pylint: disable=unused-import 6 | 7 | 8 | class Sync_B_Mapper(ModuleType): 9 | def OnStartup( 10 | self, modelingLanguage: str, asnFile: str, sp: ApLevelContainer, 11 | sp_impl: str, outputDir: str, maybeFVname: str, useOSS: bool) -> None: 12 | pass 13 | 14 | def OnBasic( 15 | self, nodeTypename: str, node: AsnNode, sp: ApLevelContainer, 16 | sp_impl: str, param: Param, leafTypeDict: AST_Leaftypes, 17 | names: AST_Lookup) -> None: 18 | pass 19 | 20 | def OnSequence( 21 | self, nodeTypename: str, node: AsnNode, sp: ApLevelContainer, 22 | sp_impl: str, param: Param, leafTypeDict: AST_Leaftypes, 23 | names: AST_Lookup) -> None: 24 | pass 25 | 26 | def OnSet( 27 | self, nodeTypename: str, node: AsnNode, sp: ApLevelContainer, 28 | sp_impl: str, param: Param, leafTypeDict: AST_Leaftypes, 29 | names: AST_Lookup) -> None: 30 | pass 31 | 32 | def OnChoice( 33 | self, nodeTypename: str, node: AsnNode, sp: ApLevelContainer, 34 | sp_impl: str, param: Param, leafTypeDict: AST_Leaftypes, 35 | names: AST_Lookup) -> None: 36 | pass 37 | 38 | def OnSequenceOf( 39 | self, nodeTypename: str, node: AsnNode, sp: ApLevelContainer, 40 | sp_impl: str, param: Param, leafTypeDict: AST_Leaftypes, 41 | names: AST_Lookup) -> None: 42 | pass 43 | 44 | def OnSetOf( 45 | self, nodeTypename: str, node: AsnNode, sp: ApLevelContainer, 46 | sp_impl: str, param: Param, leafTypeDict: AST_Leaftypes, 47 | names: AST_Lookup) -> None: 48 | pass 49 | 50 | def OnEnumerated( 51 | self, nodeTypename: str, node: AsnNode, sp: ApLevelContainer, 52 | sp_impl: str, param: Param, leafTypeDict: AST_Leaftypes, 53 | names: AST_Lookup) -> None: 54 | pass 55 | 56 | def OnShutdown( 57 | self, modelingLanguage: str, asnFile: str, sp: ApLevelContainer, 58 | sp_impl: str, maybeFVname: str) -> None: 59 | pass 60 | 61 | def OnFinal( 62 | self) -> None: 63 | pass 64 | 65 | 66 | class Async_B_Mapper(ModuleType): 67 | def OnStartup( 68 | self, modelingLanguage: str, asnFile: str, outputDir: str, 69 | maybeFVname: str, useOSS: bool) -> None: 70 | pass 71 | 72 | def OnBasic( 73 | self, nodeTypename: str, node: AsnNode, 74 | leafTypeDict: AST_Leaftypes, names: AST_Lookup) -> None: 75 | pass 76 | 77 | def OnSequence( 78 | self, nodeTypename: str, node: AsnNode, 79 | leafTypeDict: AST_Leaftypes, names: AST_Lookup) -> None: 80 | pass 81 | 82 | def OnSet( 83 | self, nodeTypename: str, node: AsnNode, 84 | leafTypeDict: AST_Leaftypes, names: AST_Lookup) -> None: 85 | pass 86 | 87 | def OnChoice( 88 | self, nodeTypename: str, node: AsnNode, 89 | leafTypeDict: AST_Leaftypes, names: AST_Lookup) -> None: 90 | pass 91 | 92 | def OnSequenceOf( 93 | self, nodeTypename: str, node: AsnNode, 94 | leafTypeDict: AST_Leaftypes, names: AST_Lookup) -> None: 95 | pass 96 | 97 | def OnSetOf( 98 | self, nodeTypename: str, node: AsnNode, 99 | leafTypeDict: AST_Leaftypes, names: AST_Lookup) -> None: 100 | pass 101 | 102 | def OnEnumerated( 103 | self, nodeTypename: str, node: AsnNode, 104 | leafTypeDict: AST_Leaftypes, names: AST_Lookup) -> None: 105 | pass 106 | 107 | def OnShutdown( 108 | self, modelingLanguage: str, asnFile: str, maybeFVname: str) -> None: 109 | pass 110 | -------------------------------------------------------------------------------- /dmt/B_mappers/qgenada_B_mapper.py: -------------------------------------------------------------------------------- 1 | # 2 | # (C) Semantix Information Technologies. 3 | # 4 | # Copyright 2014-2015 IB Krates 5 | # QGenc code generator integration 6 | # 7 | # Semantix Information Technologies is licensing the code of the 8 | # Data Modelling Tools (DMT) in the following dual-license mode: 9 | # 10 | # Commercial Developer License: 11 | # The DMT Commercial Developer License is the suggested version 12 | # to use for the development of proprietary and/or commercial software. 13 | # This version is for developers/companies who do not want to comply 14 | # with the terms of the GNU Lesser General Public License version 2.1. 15 | # 16 | # GNU LGPL v. 2.1: 17 | # This version of DMT is the one to use for the development of 18 | # applications, when you are willing to comply with the terms of the 19 | # GNU Lesser General Public License version 2.1. 20 | # 21 | # Note that in both cases, there are no charges (royalties) for the 22 | # generated code. 23 | # 24 | ''' 25 | This is the implementation of the code mapper for Ada code. 26 | As initially envisioned, ASSERT technology is not supposed 27 | to support manually-made systems. A migration path, however, 28 | that allows legacy hand-written code and modelling-tool 29 | generated code to co-exist, can be beneficial in allowing 30 | for a smooth transition. To that end, this backend (as well as 31 | the C one) are written. 32 | 33 | This is a backend for Semantix's code generator B (aadl2glueC). 34 | 35 | Ada is a member of the asynchronous "club" (SDL, etc); 36 | The subsystem developer (or rather, the APLC developer) is using 37 | native Ada code to work with code generated by modelling tools. 38 | To that end, this backend creates "glue" functions for input and 39 | output parameters, which have Ada callable interfaces. 40 | ''' 41 | 42 | # from commonPy.utility import panic 43 | # from recursiveMapper import RecursiveMapper 44 | # from asynchronousTool import ASynchronousToolGlueGenerator 45 | 46 | from . import c_B_mapper 47 | from ..commonPy.asnAST import AsnBasicNode, AsnSequence, AsnSet, AsnEnumerated, AsnSequenceOf, AsnSetOf, AsnChoice 48 | from ..commonPy.asnParser import AST_Lookup, AST_Leaftypes 49 | 50 | isAsynchronous = True 51 | cBackend = None 52 | 53 | 54 | # All the ada B mapper is now Obsolete, we are using ASN1SCC for Dumpables 55 | 56 | 57 | def OnStartup(unused_modelingLanguage: str, asnFile: str, outputDir: str, maybeFVname: str, useOSS: bool) -> None: 58 | global cBackend 59 | # 2009-02-10: Since we now use ASN1SCC structures as dumpables (even for Ada) 60 | # we no longer need these Ada-specific Dumpable structures. 61 | cBackend = c_B_mapper.C_GlueGenerator() 62 | cBackend.OnStartup("C", asnFile, outputDir, maybeFVname, useOSS) 63 | 64 | 65 | def OnBasic(nodeTypename: str, node: AsnBasicNode, leafTypeDict: AST_Leaftypes, names: AST_Lookup) -> None: 66 | cBackend.OnBasic(nodeTypename, node, leafTypeDict, names) 67 | 68 | 69 | def OnSequence(nodeTypename: str, node: AsnSequence, leafTypeDict: AST_Leaftypes, names: AST_Lookup) -> None: 70 | cBackend.OnSequence(nodeTypename, node, leafTypeDict, names) 71 | 72 | 73 | def OnSet(nodeTypename: str, node: AsnSet, leafTypeDict: AST_Leaftypes, names: AST_Lookup) -> None: 74 | cBackend.OnSet(nodeTypename, node, leafTypeDict, names) # pragma: nocover 75 | 76 | 77 | def OnEnumerated(nodeTypename: str, node: AsnEnumerated, leafTypeDict: AST_Leaftypes, names: AST_Lookup) -> None: 78 | cBackend.OnEnumerated(nodeTypename, node, leafTypeDict, names) 79 | 80 | 81 | def OnSequenceOf(nodeTypename: str, node: AsnSequenceOf, leafTypeDict: AST_Leaftypes, names: AST_Lookup) -> None: 82 | cBackend.OnSequenceOf(nodeTypename, node, leafTypeDict, names) 83 | 84 | 85 | def OnSetOf(nodeTypename: str, node: AsnSetOf, leafTypeDict: AST_Leaftypes, names: AST_Lookup) -> None: 86 | cBackend.OnSetOf(nodeTypename, node, leafTypeDict, names) # pragma: nocover 87 | 88 | 89 | def OnChoice(nodeTypename: str, node: AsnChoice, leafTypeDict: AST_Leaftypes, names: AST_Lookup) -> None: 90 | cBackend.OnChoice(nodeTypename, node, leafTypeDict, names) 91 | 92 | 93 | def OnShutdown(unused_modelingLanguage: str, asnFile: str, maybeFVname: str) -> None: 94 | cBackend.OnShutdown("C", asnFile, maybeFVname) 95 | -------------------------------------------------------------------------------- /dmt/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | """ 5 | DMT - Data Modelling Technologies 6 | """ 7 | -------------------------------------------------------------------------------- /dmt/badTypes.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # vim: set expandtab ts=8 sts=4 shiftwidth=4 3 | # 4 | # (C) Semantix Information Technologies. 5 | # 6 | # Semantix Information Technologies is licensing the code of the 7 | # Data Modelling Tools (DMT) in the following dual-license mode: 8 | # 9 | # Commercial Developer License: 10 | # The DMT Commercial Developer License is the suggested version 11 | # to use for the development of proprietary and/or commercial software. 12 | # This version is for developers/companies who do not want to comply 13 | # with the terms of the GNU Lesser General Public License version 2.1. 14 | # 15 | # GNU LGPL v. 2.1: 16 | # This version of DMT is the one to use for the development of 17 | # applications, when you are willing to comply with the terms of the 18 | # GNU Lesser General Public License version 2.1. 19 | # 20 | # Note that in both cases, there are no charges (royalties) for the 21 | # generated code. 22 | # 23 | ''' 24 | Code Integrator 25 | 26 | This is the core of the "glue" generators that Semantix developed for 27 | the European research project ASSERT. It has been enhanced in the 28 | context of Data Modelling and Data Modelling Tuning projects, 29 | and continuous to evolve over the course of other projects. 30 | 31 | This code starts by reading the AADL specification of the system. 32 | It then generates the runtime bridge-code that will map the message 33 | data structures from those generated by the Semantix Certified ASN.1 34 | compiler to/from those generated by the modeling tool used to 35 | functionally model the APLC subsystem (e.g. SCADE, ObjectGeode, 36 | Matlab/Simulink, C, Ada, etc). 37 | 38 | The code generation is done via user-visible (and editable) backends. 39 | 40 | There are three kinds of backends: 41 | 42 | 1. Synchronous backends 43 | ======================= 44 | 45 | For these, the working logic is: 46 | 47 | for each subprogram implementation 48 | Load B mapper 49 | call OnStartup 50 | for each subprogram param 51 | Call OnBasic/OnSequence/OnEnumerated etc 52 | call OnShutdown 53 | 54 | That is, there is OnStartup/OnInteger/OnSequence/.../OnShutdown cycle 55 | done PER EACH SUBPROGRAM. 56 | 57 | 2. Asynchronous backends 58 | ======================== 59 | 60 | Asynchronous backends are only generating standalone encoders and decoders 61 | (they are not doing this per sp.param). 62 | 63 | The working logic is therefore different 64 | 65 | OnStartup called ONCE for each async backend in use (used by this system's PIs) 66 | Via the asynchronous.py, after visiting all params and collecting them, 67 | for each asn.1 type that is actually used (at least once) as a param: 68 | Call Encoder and Decoder 69 | Call OnShutdown ONCE for each async backend in use (used by this system's PIs) 70 | 71 | 3. Special backends 72 | =================== 73 | 74 | GUI, Python, (VHDL?), etc... 75 | 76 | These have custom requirements, so each one is handled by specific AADL2GLUEC 77 | code. As it is now, the pattern follows that of the synchronous backends, 78 | but with an extra call to OnFinal at the end. 79 | ''' 80 | 81 | import os 82 | import sys 83 | 84 | from typing import cast, Optional, Dict, List, Tuple, Any # NOQA pylint: disable=unused-import 85 | 86 | from .commonPy.cleanupNodes import DiscoverBadTypes 87 | from .commonPy.asnParser import Filename, Typename, AST_Lookup, AST_TypesOfFile, AST_Leaftypes # NOQA pylint: disable=unused-import 88 | from .commonPy.asnAST import AsnNode # NOQA pylint: disable=unused-import 89 | from .commonPy.aadlAST import ApLevelContainer, Param # NOQA pylint: disable=unused-import 90 | from .commonPy import asnParser # NOQA pylint: disable=unused-import 91 | from .commonPy import verify # NOQA pylint: disable=unused-import 92 | from .commonPy.utility import panic # NOQA pylint: disable=unused-import 93 | 94 | 95 | def main() -> None: 96 | if "-v" in sys.argv: 97 | import pkg_resources # pragma: no cover 98 | version = pkg_resources.require("dmt")[0].version # pragma: no cover 99 | print("badTypes v" + str(version)) # pragma: no cover 100 | sys.exit(1) # pragma: no cover 101 | 102 | # No other options must remain in the cmd line... 103 | if len(sys.argv) < 2: 104 | panic('Usage: %s input1.asn [input2.asn] ...\n' % sys.argv[0]) # pragma: no cover 105 | for f in sys.argv[1:]: 106 | if not os.path.isfile(f): 107 | panic("'%s' is not a file!\n" % f) # pragma: no cover 108 | 109 | asn1files = sys.argv[1:] 110 | asnParser.ParseAsnFileList(asn1files) 111 | names = asnParser.g_names 112 | for node in names.values(): 113 | verify.VerifyRanges(node, names) 114 | 115 | # If some AST nodes must be skipped (for any reason), go learn about them 116 | badTypes = DiscoverBadTypes() 117 | print("\n".join(badTypes)) 118 | 119 | 120 | if __name__ == "__main__": 121 | if "-pdb" in sys.argv: 122 | sys.argv.remove("-pdb") # pragma: no cover 123 | import pdb # pragma: no cover pylint: disable=wrong-import-position,wrong-import-order 124 | pdb.run('main()') # pragma: no cover 125 | else: 126 | main() 127 | -------------------------------------------------------------------------------- /dmt/commonPy/__init__.py.in: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | """ 5 | This module contains the shared API for parsing ASN.1 and AADL 6 | and performing code generation via AST traversals. 7 | """ 8 | from . import configMT 9 | from . import asnParser 10 | from . import asnAST 11 | from . import aadlAST 12 | from . import utility 13 | from . import createInternalTypes 14 | from . import verify 15 | from . import recursiveMapper 16 | from . import cleanupNodes 17 | 18 | import pkg_resources # pragma: no cover 19 | __version__ = "2.2-@SCM_REVISION@" 20 | 21 | 22 | def print_version() -> None: 23 | print("TASTE Data Modelling Tools version {}\n\n" 24 | "The following tools are available:\n" 25 | " asn2aadlPlus - Convert ASN.1 models to AADL\n" 26 | " asn2dataModel - TASTE A Mappers (from ASN.1 to C, Python, etc.)\n" 27 | " aadl2glueC - TASTE B Mappers (from ASN.1+AADL to glue code)\n" 28 | " msgPrinter - Generate serializers of ASN.1 instances\n" 29 | " msgPrinterASN1 - Generate serializers of ASN.1 instances (other encodings)\n" 30 | " smp2asn - SMP2 to ASN.1 converter\n".format(__version__)) 31 | -------------------------------------------------------------------------------- /dmt/commonPy/aadlAST.py: -------------------------------------------------------------------------------- 1 | # (C) Semantix Information Technologies. 2 | # 3 | # Semantix Information Technologies is licensing the code of the 4 | # Data Modelling Tools (DMT) in the following dual-license mode: 5 | # 6 | # Commercial Developer License: 7 | # The DMT Commercial Developer License is the appropriate version 8 | # to use for the development of proprietary and/or commercial software. 9 | # This version is for developers/companies who do not want to share 10 | # the source code they develop with others or otherwise comply with the 11 | # terms of the GNU Lesser General Public License version 3. 12 | # 13 | # GNU LGPL v. 2.1: 14 | # This version of DMT is the one to use for the development of 15 | # non-commercial applications, when you are willing to comply 16 | # with the terms of the GNU Lesser General Public License version 3. 17 | # 18 | # The features of the two licenses are summarized below: 19 | # 20 | # Commercial 21 | # Developer LGPL 22 | # License 23 | # 24 | # License cost License fee charged No license fee 25 | # 26 | # Must provide source 27 | # code changes to DMT No, modifications can Yes, all source code 28 | # be closed must be provided back 29 | # 30 | # Can create Yes, that is, No, applications are subject 31 | # proprietary no source code needs to the LGPL and all source code 32 | # applications to be disclosed must be made available 33 | # 34 | # Support Yes, 12 months of No, but available separately 35 | # premium technical for purchase 36 | # support 37 | # 38 | # Charge for Runtimes None None 39 | 40 | from typing import Tuple, Union, Dict, Any, List # NOQA pylint: disable=unused-import 41 | 42 | g_apLevelContainers = {} # type: Dict[str, ApLevelContainer] 43 | 44 | g_subProgramImplementations = [] # type: List[Tuple[str,str,str,str]] 45 | g_processImplementations = [] # type: List[Tuple[str,str,str,str]] 46 | g_threadImplementations = [] # type: List[Tuple[str,str,str,str]] 47 | 48 | # AST classes 49 | 50 | 51 | class AadlParameter: 52 | def __init__(self, direction: str, typ: str) -> None: 53 | assert direction in ['IN', 'OUT', 'INOUT'] 54 | self._direction = direction 55 | self._type = typ 56 | self._encoding = '' 57 | 58 | 59 | class AadlSubProgramFeature: 60 | def __init__(self, iid: str, parameter: AadlParameter) -> None: 61 | self._id = iid 62 | self._parameter = parameter 63 | 64 | 65 | class AadlPropertyAssociationNoModes: 66 | def __init__(self, name: str, pe: Any) -> None: 67 | self._name = name 68 | self._propertyExpressionOrList = pe 69 | 70 | 71 | class AadlPort: 72 | def __init__(self, direction: str, typ: str) -> None: 73 | self._direction = direction 74 | self._type = typ 75 | self._encoding = '' 76 | 77 | 78 | class AadlEventPort: 79 | def __init__(self, direction: str, sp: 'ApLevelContainer') -> None: 80 | self._direction = direction 81 | self._sp = sp 82 | self._encoding = '' 83 | 84 | def __repr__(self) -> str: 85 | result = "AadlEventPort(" + self._direction + "," 86 | if self._sp: 87 | result += str(self._sp) 88 | result += ")" 89 | return result 90 | 91 | 92 | class AadlEventDataPort(AadlPort): 93 | def __init__(self, direction: str, typ: str) -> None: 94 | AadlPort.__init__(self, direction, typ) 95 | 96 | 97 | class AadlThreadFeature: 98 | def __init__(self, iid: str, port: AadlPort) -> None: 99 | assert isinstance(port, AadlPort) 100 | self._id = iid 101 | self._port = port 102 | 103 | 104 | class AadlProcessFeature: 105 | def __init__(self, iid: str, port: AadlPort) -> None: 106 | assert isinstance(port, AadlPort) 107 | self._id = iid 108 | self._port = port 109 | 110 | 111 | class AadlContainedPropertyAssociation: 112 | def __init__(self, name: str, value: Any) -> None: 113 | self._name = name 114 | self._value = value 115 | 116 | 117 | class Signal: 118 | def __init__(self, asnFilename: str, asnNodename: str, asnSize: int) -> None: 119 | self._asnFilename = asnFilename 120 | self._asnNodename = asnNodename 121 | self._asnSize = asnSize 122 | 123 | 124 | # class Port: 125 | # def __init__(self, signal): 126 | # self._signal = signal 127 | # 128 | # 129 | # class DualPort(Port): 130 | # def __init__(self, signal): 131 | # Port.__init__(self, signal) 132 | # 133 | # 134 | # class UniPort(Port): 135 | # def __init__(self, signal): 136 | # Port.__init__(self, signal) 137 | # 138 | # 139 | # class IncomingUniPort(UniPort): 140 | # def __init__(self, signal): 141 | # UniPort.__init__(self, signal) 142 | # 143 | # 144 | # class OutgoingUniPort(UniPort): 145 | # def __init__(self, signal): 146 | # UniPort.__init__(self, signal) 147 | 148 | 149 | class Param: 150 | def __init__(self, 151 | aplcID: str, 152 | iid: str, 153 | signal: Signal, 154 | sourceElement: Union[AadlPort, AadlEventDataPort, AadlParameter]) -> None: 155 | self._id = iid 156 | # It is the Process, Thread or Subprogram ID 157 | self._aplcID = aplcID 158 | # Could be string (i.e. AADL DataType name) or Signal (i.e. asnFilename, asnNodename) 159 | self._signal = signal 160 | self._sourceElement = sourceElement # Could be AadlPort, AadlEventDataPort, AadlParameter 161 | 162 | 163 | class InParam(Param): 164 | def __init__(self, 165 | aplcID: str, 166 | iid: str, 167 | signal: Signal, 168 | sourceElement: Union[AadlPort, AadlEventDataPort, AadlParameter]) -> None: 169 | Param.__init__(self, aplcID, iid, signal, sourceElement) 170 | 171 | 172 | class OutParam(Param): 173 | def __init__(self, 174 | aplcID: str, 175 | iid: str, 176 | signal: Signal, 177 | sourceElement: Union[AadlPort, AadlEventDataPort, AadlParameter]) -> None: 178 | Param.__init__(self, aplcID, iid, signal, sourceElement) 179 | 180 | 181 | class InOutParam(Param): 182 | def __init__(self, 183 | aplcID: str, 184 | iid: str, 185 | signal: Signal, 186 | sourceElement: Union[AadlPort, AadlEventDataPort, AadlParameter]) -> None: 187 | Param.__init__(self, aplcID, iid, signal, sourceElement) 188 | 189 | 190 | class UniquePortIdentifier: 191 | def __init__(self, componentId: str, portId: str) -> None: 192 | self._componentId = componentId 193 | self._portId = portId 194 | 195 | 196 | class ApLevelContainer: 197 | def __init__(self, iid: str) -> None: 198 | self._id = iid 199 | self._params = [] # type: List[Param] 200 | self._connections = [] # type: List[Connection] 201 | self._language = None # type: str 202 | 203 | def AddConnection(self, srcUniquePortId: UniquePortIdentifier, destUniquePortId: UniquePortIdentifier) -> None: 204 | if srcUniquePortId._componentId is None: 205 | srcUniquePortId._componentId = self._id 206 | if destUniquePortId._componentId is None: 207 | destUniquePortId._componentId = self._id 208 | self._connections.append(Connection(srcUniquePortId, destUniquePortId)) 209 | 210 | def AddParam(self, param: Param) -> None: 211 | self._params.append(param) 212 | 213 | def SetLanguage(self, language: str) -> None: 214 | self._language = language 215 | 216 | 217 | class Connection: 218 | def __init__(self, fromC: UniquePortIdentifier, toC: UniquePortIdentifier) -> None: 219 | self._from = fromC 220 | self._to = toC 221 | -------------------------------------------------------------------------------- /dmt/commonPy/cleanupNodes.py: -------------------------------------------------------------------------------- 1 | # (C) Semantix Information Technologies, 2 | # Neuropublic, 3 | # European Space Agency 4 | # 5 | # The license of the Data Modelling Tools (DMT) is GPL with Runtime Exception 6 | 7 | ''' 8 | Rules to gather the list of types that must be skipped 9 | ''' 10 | 11 | from typing import Set, Union, Dict # NOQA 12 | 13 | from . import asnParser 14 | from .asnAST import ( 15 | AsnAsciiString, AsnChoice, AsnSet, AsnSequenceOf, AsnSequence, 16 | AsnMetaMember, AsnSetOf, AsnNode 17 | ) 18 | 19 | SetOfBadTypenames = Set[str] 20 | 21 | 22 | def DiscoverBadTypes() -> SetOfBadTypenames: 23 | ''' 24 | This returns a dictionary that tells us which types to skip 25 | pver during type mappings. For now, it includes IA5Strings 26 | and types whose descendants end up having such a field. 27 | ''' 28 | badTypes = set() # type: SetOfBadTypenames 29 | cache = {} # type: Dict[AsnNode, bool] 30 | 31 | names = asnParser.g_names 32 | 33 | def CheckNodeForIA5(node_or_str: Union[AsnNode, str]) -> bool: 34 | if isinstance(node_or_str, str): 35 | node = names[node_or_str] # type: AsnNode 36 | else: 37 | node = node_or_str 38 | if node in cache: 39 | return cache[node] 40 | if isinstance(node, AsnAsciiString): 41 | cache[node] = True 42 | return True 43 | elif isinstance(node, (AsnChoice, AsnSequence, AsnSet)): 44 | for child in node._members: 45 | if isinstance(child[1], AsnAsciiString): 46 | cache[node] = True 47 | return cache[node] 48 | cache[node] = any( 49 | CheckNodeForIA5(names[child[1]._containedType]) 50 | for child in node._members 51 | if isinstance(child[1], AsnMetaMember)) 52 | return cache[node] 53 | elif isinstance(node, (AsnSequenceOf, AsnSetOf)): 54 | if isinstance(node._containedType, AsnAsciiString): 55 | cache[node] = True 56 | else: 57 | cache[node] = \ 58 | isinstance(node._containedType, str) and \ 59 | CheckNodeForIA5(names[node._containedType]) 60 | return cache[node] 61 | cache[node] = False 62 | return cache[node] 63 | 64 | # Hack for IA5Strings (IA5s are used in TASTE's runtime configuration spec) 65 | while True: 66 | foundOne = False 67 | for nodeTypename in names: 68 | nodeAST = names[nodeTypename] 69 | if nodeTypename not in badTypes and CheckNodeForIA5(nodeAST): 70 | badTypes.add(nodeTypename) 71 | foundOne = True 72 | if not foundOne: 73 | break 74 | return badTypes 75 | 76 | # vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 77 | -------------------------------------------------------------------------------- /dmt/commonPy/configMT.py: -------------------------------------------------------------------------------- 1 | # (C) Semantix Information Technologies. 2 | # 3 | # Semantix Information Technologies is licensing the code of the 4 | # Data Modelling Tools (DMT) in the following dual-license mode: 5 | # 6 | # Commercial Developer License: 7 | # The DMT Commercial Developer License is the appropriate version 8 | # to use for the development of proprietary and/or commercial software. 9 | # This version is for developers/companies who do not want to share 10 | # the source code they develop with others or otherwise comply with the 11 | # terms of the GNU Lesser General Public License version 3. 12 | # 13 | # GNU LGPL v. 2.1: 14 | # This version of DMT is the one to use for the development of 15 | # non-commercial applications, when you are willing to comply 16 | # with the terms of the GNU Lesser General Public License version 3. 17 | # 18 | # The features of the two licenses are summarized below: 19 | # 20 | # Commercial 21 | # Developer LGPL 22 | # License 23 | # 24 | # License cost License fee charged No license fee 25 | # 26 | # Must provide source 27 | # code changes to DMT No, modifications can Yes, all source code 28 | # be closed must be provided back 29 | # 30 | # Can create Yes, that is, No, applications are subject 31 | # proprietary no source code needs to the LGPL and all source code 32 | # applications to be disclosed must be made available 33 | # 34 | # Support Yes, 12 months of No, but available separately 35 | # premium technical for purchase 36 | # support 37 | # 38 | # Charge for Runtimes None None 39 | # 40 | import os 41 | g_bOnlySubprograms = False 42 | debugParser = False 43 | verbose = False 44 | showCode = False 45 | outputDir = "." + os.sep 46 | -------------------------------------------------------------------------------- /dmt/commonPy/recursiveMapper.py: -------------------------------------------------------------------------------- 1 | # 2 | # (C) Semantix Information Technologies. 3 | # 4 | # Semantix Information Technologies is licensing the code of the 5 | # Data Modelling Tools (DMT) in the following dual-license mode: 6 | # 7 | # Commercial Developer License: 8 | # The DMT Commercial Developer License is the suggested version 9 | # to use for the development of proprietary and/or commercial software. 10 | # This version is for developers/companies who do not want to comply 11 | # with the terms of the GNU Lesser General Public License version 3. 12 | # 13 | # GNU LLGPL v. 2.1: 14 | # This version of DMT is the one to use for the development of 15 | # applications, when you are willing to comply with the terms of the 16 | # GNU Lesser General Public License version 3. 17 | # 18 | # Note that in both cases, there are no charges (royalties) for the 19 | # generated code. 20 | # 21 | import re 22 | from typing import Union, List, Dict, TypeVar, Generic 23 | 24 | from .utility import panicWithCallStack 25 | from .asnAST import ( 26 | AsnSequence, AsnSet, AsnChoice, AsnSequenceOf, AsnSetOf, AsnEnumerated, 27 | AsnMetaMember, AsnNode, AsnInt, AsnReal, AsnBool, AsnOctetString) 28 | from .asnParser import AST_Leaftypes, AST_Lookup 29 | 30 | 31 | TSrc = TypeVar('TSrc') 32 | TDest = TypeVar('TDest') 33 | 34 | 35 | # noinspection PyMethodMayBeStatic 36 | class RecursiveMapperGeneric(Generic[TSrc, TDest]): 37 | 38 | def maybeElse(self, childNo: int) -> str: # pylint: disable=no-self-use 39 | if childNo == 1: 40 | return "" 41 | else: 42 | return "else " 43 | 44 | def CleanName(self, fieldName: str) -> str: # pylint: disable=no-self-use 45 | return re.sub(r'[^a-zA-Z0-9_]', '_', fieldName) 46 | 47 | def Version(self) -> None: # pylint: disable=no-self-use 48 | panicWithCallStack("Method undefined in a RecursiveMapper...") 49 | 50 | def MapInteger(self, unused_srcVar: TSrc, unused_destVar: TDest, unused_node: AsnInt, unused_leafTypeDict: AST_Leaftypes, unused_names: AST_Lookup) -> List[str]: # pylint: disable=no-self-use,invalid-sequence-index 51 | panicWithCallStack("Method undefined in a RecursiveMapper...") 52 | 53 | def MapReal(self, unused_srcVar: TSrc, unused_destVar: TDest, unused_node: AsnReal, unused_leafTypeDict: AST_Leaftypes, unused_names: AST_Lookup) -> List[str]: # pylint: disable=no-self-use,invalid-sequence-index 54 | panicWithCallStack("Method undefined in a RecursiveMapper...") 55 | 56 | def MapBoolean(self, unused_srcVar: TSrc, unused_destVar: TDest, unused_node: AsnBool, unused_leafTypeDict: AST_Leaftypes, unused_names: AST_Lookup) -> List[str]: # pylint: disable=no-self-use,invalid-sequence-index 57 | panicWithCallStack("Method undefined in a RecursiveMapper...") 58 | 59 | def MapOctetString(self, unused_srcVar: TSrc, unused_destVar: TDest, unused_node: AsnOctetString, unused_leafTypeDict: AST_Leaftypes, unused_names: AST_Lookup) -> List[str]: # pylint: disable=no-self-use,invalid-sequence-index 60 | panicWithCallStack("Method undefined in a RecursiveMapper...") 61 | 62 | def MapEnumerated(self, unused_srcVar: TSrc, unused_destVar: TDest, unused_node: AsnEnumerated, unused_leafTypeDict: AST_Leaftypes, unused_names: AST_Lookup) -> List[str]: # pylint: disable=no-self-use,invalid-sequence-index 63 | panicWithCallStack("Method undefined in a RecursiveMapper...") 64 | 65 | def MapSequence(self, unused_srcVar: TSrc, unused_destVar: TDest, unused_node: AsnSequence, unused_leafTypeDict: AST_Leaftypes, unused_names: AST_Lookup) -> List[str]: # pylint: disable=no-self-use,invalid-sequence-index 66 | panicWithCallStack("Method undefined in a RecursiveMapper...") 67 | 68 | def MapSet(self, unused_srcVar: TSrc, unused_destVar: TDest, unused_node: AsnSet, unused_leafTypeDict: AST_Leaftypes, unused_names: AST_Lookup) -> List[str]: # pylint: disable=no-self-use,invalid-sequence-index 69 | panicWithCallStack("Method undefined in a RecursiveMapper...") 70 | 71 | def MapChoice(self, unused_srcVar: TSrc, unused_destVar: TDest, unused_node: AsnChoice, unused_leafTypeDict: AST_Leaftypes, unused_names: AST_Lookup) -> List[str]: # pylint: disable=no-self-use,invalid-sequence-index 72 | panicWithCallStack("Method undefined in a RecursiveMapper...") 73 | 74 | def MapSequenceOf(self, unused_srcVar: TSrc, unused_destVar: TDest, unused_node: AsnSequenceOf, unused_leafTypeDict: AST_Leaftypes, unused_names: AST_Lookup) -> List[str]: # pylint: disable=no-self-use,invalid-sequence-index 75 | panicWithCallStack("Method undefined in a RecursiveMapper...") 76 | 77 | def MapSetOf(self, unused_srcVar: TSrc, unused_destVar: TDest, unused_node: AsnSetOf, unused_leafTypeDict: AST_Leaftypes, unused_names: AST_Lookup) -> List[str]: # pylint: disable=no-self-use,invalid-sequence-index 78 | panicWithCallStack("Method undefined in a RecursiveMapper...") 79 | 80 | def Map(self, 81 | srcVar: TSrc, 82 | destVar: TDest, 83 | node_or_str: Union[str, AsnNode], 84 | leafTypeDict: Dict[str, str], 85 | names: Dict[str, AsnNode]) -> List[str]: # pylint: disable=invalid-sequence-index 86 | if isinstance(node_or_str, str): 87 | node = names[node_or_str] # type: AsnNode 88 | else: 89 | node = node_or_str 90 | lines = [] # type: List[str] 91 | if isinstance(node, AsnInt): 92 | lines.extend(self.MapInteger(srcVar, destVar, node, leafTypeDict, names)) 93 | elif isinstance(node, AsnReal): 94 | lines.extend(self.MapReal(srcVar, destVar, node, leafTypeDict, names)) 95 | elif isinstance(node, AsnBool): 96 | lines.extend(self.MapBoolean(srcVar, destVar, node, leafTypeDict, names)) 97 | elif isinstance(node, AsnOctetString): 98 | lines.extend(self.MapOctetString(srcVar, destVar, node, leafTypeDict, names)) 99 | elif isinstance(node, AsnSequence): 100 | lines.extend(self.MapSequence(srcVar, destVar, node, leafTypeDict, names)) 101 | elif isinstance(node, AsnSet): 102 | lines.extend(self.MapSet(srcVar, destVar, node, leafTypeDict, names)) 103 | elif isinstance(node, AsnChoice): 104 | lines.extend(self.MapChoice(srcVar, destVar, node, leafTypeDict, names)) 105 | elif isinstance(node, AsnSequenceOf): 106 | lines.extend(self.MapSequenceOf(srcVar, destVar, node, leafTypeDict, names)) 107 | elif isinstance(node, AsnSetOf): 108 | lines.extend(self.MapSetOf(srcVar, destVar, node, leafTypeDict, names)) 109 | elif isinstance(node, AsnEnumerated): 110 | lines.extend(self.MapEnumerated(srcVar, destVar, node, leafTypeDict, names)) 111 | elif isinstance(node, AsnMetaMember): 112 | lines.extend(self.Map(srcVar, destVar, names[node._containedType], leafTypeDict, names)) 113 | else: 114 | panicWithCallStack("unsupported %s (%s)" % (str(node.__class__), node.Location())) 115 | return lines 116 | 117 | 118 | # pylint: disable=no-self-use 119 | RecursiveMapper = RecursiveMapperGeneric[str, str] 120 | 121 | 122 | # vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 123 | -------------------------------------------------------------------------------- /dmt/commonPy/utility.py: -------------------------------------------------------------------------------- 1 | # (C) Semantix Information Technologies. 2 | # 3 | # Semantix Information Technologies is licensing the code of the 4 | # Data Modelling Tools (DMT) in the following dual-license mode: 5 | # 6 | # Commercial Developer License: 7 | # The DMT Commercial Developer License is the appropriate version 8 | # to use for the development of proprietary and/or commercial software. 9 | # This version is for developers/companies who do not want to share 10 | # the source code they develop with others or otherwise comply with the 11 | # terms of the GNU Lesser General Public License version 3. 12 | # 13 | # GNU LGPL v. 2.1: 14 | # This version of DMT is the one to use for the development of 15 | # non-commercial applications, when you are willing to comply 16 | # with the terms of the GNU Lesser General Public License version 3. 17 | # 18 | # The features of the two licenses are summarized below: 19 | # 20 | # Commercial 21 | # Developer LGPL 22 | # License 23 | # 24 | # License cost License fee charged No license fee 25 | # 26 | # Must provide source 27 | # code changes to DMT No, modifications can Yes, all source code 28 | # be closed must be provided back 29 | # 30 | # Can create Yes, that is, No, applications are subject 31 | # proprietary no source code needs to the LGPL and all source code 32 | # applications to be disclosed must be made available 33 | # 34 | # Support Yes, 12 months of No, but available separately 35 | # premium technical for purchase 36 | # support 37 | # 38 | # Charge for Runtimes None None 39 | # 40 | import sys 41 | import os 42 | import re 43 | import platform 44 | import traceback 45 | 46 | from typing import Dict, Union, Match, Any # NOQA pylint: disable=unused-import 47 | from mypy_extensions import NoReturn # NOQA pylint: disable=unused-import 48 | 49 | from . import configMT 50 | 51 | 52 | def inform(fmt: str, *args: Any) -> None: 53 | if configMT.verbose: 54 | print(fmt % args) 55 | 56 | 57 | def warn(fmt: str, *args: Any) -> None: 58 | sys.stderr.write(("WARNING: " + fmt) % args) 59 | sys.stderr.write("\n") 60 | 61 | 62 | def panic(x: str) -> NoReturn: 63 | if not x.endswith("\n"): 64 | x += "\n" 65 | sys.stderr.write("\n" + chr(27) + "[32m" + x + chr(27) + "[0m\n") 66 | sys.exit(1) 67 | 68 | 69 | def panicWithCallStack(msg: str) -> NoReturn: 70 | if configMT.verbose: 71 | sys.stderr.write("\n" + chr(27) + "[32m" + msg + chr(27) + "[0m\n") 72 | sys.stderr.write( 73 | "\nCall stack was:\n%s\n" % "".join(traceback.format_stack())) 74 | sys.exit(1) 75 | else: 76 | panic(msg) 77 | 78 | 79 | def lcfirst(word: str) -> str: 80 | if word: 81 | return word[:1].lower() + word[1:] 82 | else: 83 | return word 84 | 85 | 86 | def ucfirst(word: str) -> str: 87 | if word: 88 | return word[:1].upper() + word[1:] 89 | else: 90 | return word 91 | 92 | 93 | def collapseCAPSgroups(word: str) -> str: 94 | while 1: 95 | m = re.match('^(.*?)([A-Z][A-Z]+)(.*?)$', word) 96 | if m: 97 | word = m.group(1) + lcfirst(m.group(2)) + m.group(3) 98 | else: 99 | break 100 | return word 101 | 102 | 103 | def readContexts(tapNumbers: str) -> Dict[str, str]: 104 | data = {} 105 | for line in open(tapNumbers, "r").readlines(): 106 | line = line.rstrip(os.linesep) 107 | lista = line.split(":") 108 | data[lista[0]] = lista[1] 109 | return data 110 | 111 | 112 | class Matcher: 113 | def __init__(self, pattern: str, flags: Any = 0) -> None: 114 | self._pattern = re.compile(pattern, flags) 115 | self._lastOne = None # type: Union[str, None] 116 | self._match = None # type: Union[Match, None] 117 | self._search = None # type: Union[Match, None] 118 | 119 | def match(self, line: str) -> Match: 120 | self._match = re.match(self._pattern, line) 121 | self._lastOne = 'Match' 122 | return self._match 123 | 124 | def search(self, line: str) -> Match: 125 | self._search = re.search(self._pattern, line) 126 | self._lastOne = 'Search' 127 | return self._search 128 | 129 | def group(self, idx: int) -> str: # pylint: disable=inconsistent-return-statements 130 | if self._lastOne == 'Match': 131 | return self._match.group(idx) 132 | elif self._lastOne == 'Search': 133 | return self._search.group(idx) 134 | else: 135 | panic( 136 | "Matcher group called with index " 137 | "%d before match/search!\n" % idx) 138 | 139 | def groups(self) -> Any: # pylint: disable=inconsistent-return-statements 140 | if self._lastOne == 'Match': 141 | return self._match.groups() 142 | elif self._lastOne == 'Search': 143 | return self._search.groups() 144 | else: 145 | panic("Matcher groups called with match/search!\n") 146 | 147 | 148 | def mysystem(cmd: str) -> int: 149 | p = platform.system() 150 | if p == "Windows" or p.startswith("CYGWIN"): 151 | return os.system('"' + cmd + '"') 152 | else: 153 | return os.system(cmd) 154 | 155 | # vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 156 | -------------------------------------------------------------------------------- /dmt/commonPy/verify.py: -------------------------------------------------------------------------------- 1 | # 2 | # (C) Semantix Information Technologies. 3 | # 4 | # Semantix Information Technologies is licensing the code of the 5 | # Data Modelling Tools (DMT) in the following dual-license mode: 6 | # 7 | # Commercial Developer License: 8 | # The DMT Commercial Developer License is the suggested version 9 | # to use for the development of proprietary and/or commercial software. 10 | # This version is for developers/companies who do not want to comply 11 | # with the terms of the GNU Lesser General Public License version 3. 12 | # 13 | # GNU LLGPL v. 2.1: 14 | # This version of DMT is the one to use for the development of 15 | # applications, when you are willing to comply with the terms of the 16 | # GNU Lesser General Public License version 3. 17 | # 18 | # Note that in both cases, there are no charges (royalties) for the 19 | # generated code. 20 | # 21 | ''' 22 | This module checks that all ASN.1 types are using the appropriate 23 | constraint (ASSERT-wise). 24 | ''' 25 | 26 | from typing import Dict, Union # NOQA 27 | 28 | from .utility import panic 29 | 30 | from . import asnAST 31 | from .asnAST import AsnNode 32 | 33 | 34 | def VerifyNodeRange(node: AsnNode) -> None: 35 | '''This function checks that 36 | - INTEGERs 37 | - REALs 38 | - STRINGs 39 | - and SEQUENCE/SET OFs 40 | 41 | ...are equipped with the necessary range constructs. 42 | If they are not, a runtime error is generated, with a report 43 | on the exact location of the offending type in the ASN.1 grammar.''' 44 | if isinstance(node, asnAST.AsnInt): 45 | if not node._range: 46 | panic("INTEGER (in %s) must have a range constraint inside ASN.1,\n" 47 | "or else we might lose accuracy during runtime!" % node.Location()) 48 | 49 | elif isinstance(node, asnAST.AsnReal): 50 | if not node._range: 51 | panic("REAL (in %s) must have a range constraint inside ASN.1,\n" 52 | "or else we might lose accuracy during runtime!" % node.Location()) 53 | else: 54 | # ASN1SCC uses C double for ASN.1 REAL. 55 | # this allows values from -1.7976931348623157E308 to 1.7976931348623157E308 56 | if node._range[0] < -1.7976931348623157E308: 57 | panic("REAL (in %s) must have a low limit >= -1.7976931348623157E308\n" % 58 | node.Location()) 59 | if node._range[1] > 1.7976931348623157E308: 60 | panic("REAL (in %s) must have a high limit <= 1.7976931348623157E308\n" % 61 | node.Location()) 62 | 63 | elif isinstance(node, asnAST.AsnString): 64 | if not node._range: 65 | panic("string (in %s) must have SIZE range set!\n" % node.Location()) 66 | 67 | elif isinstance(node, (asnAST.AsnSequenceOf, asnAST.AsnSetOf)): 68 | if not node._range: 69 | panic("SequenceOf (in %s) must have SIZE range set!\n" % node.Location()) 70 | 71 | elif isinstance(node, asnAST.AsnEnumerated): 72 | if any(x[1] is None for x in node._members): 73 | panic("ENUMERATED must have integer value for each enum! (%s)" % node.Location()) 74 | 75 | 76 | def VerifyRanges(node_or_str: Union[str, AsnNode], names: Dict[str, AsnNode]) -> None: 77 | '''This function recursively traverses the AST, 78 | calling VerifyNodeRange for each Node.''' 79 | if isinstance(node_or_str, str): 80 | node = names[node_or_str] # type: AsnNode 81 | else: 82 | node = node_or_str 83 | if isinstance(node, asnAST.AsnMetaMember): 84 | node = names[node._containedType] 85 | 86 | if isinstance(node, asnAST.AsnBasicNode): 87 | VerifyNodeRange(node) 88 | elif isinstance(node, (asnAST.AsnSequence, asnAST.AsnChoice, asnAST.AsnSet)): 89 | # Bug fixed in ASN1SCC - this check is no longer needed 90 | # if 0 == len(node._members): 91 | # panic( 92 | # "Empty SEQUENCE/SETs are not allowed. Please add at least one field in (%s)\n" 93 | # % node.Location()) 94 | for child in node._members: 95 | VerifyRanges(child[1], names) 96 | elif isinstance(node, (asnAST.AsnSequenceOf, asnAST.AsnSetOf)): 97 | VerifyNodeRange(node) 98 | VerifyRanges(node._containedType, names) 99 | elif isinstance(node, asnAST.AsnEnumerated): 100 | VerifyNodeRange(node) 101 | else: 102 | panic("VerifyRanges: Unexpected %s\n" % str(node)) 103 | 104 | # vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 105 | -------------------------------------------------------------------------------- /dmt/commonPy2/AadlParserTokenTypes.txt: -------------------------------------------------------------------------------- 1 | // $ANTLR 2.7.7 (20160127): aadl.g -> AadlParserTokenTypes.txt$ 2 | AadlParser // output token vocab name 3 | PACKAGE="package"=4 4 | END="end"=5 5 | SEMI=6 6 | PUBLIC="public"=7 7 | PRIVATE="private"=8 8 | IDENT=9 9 | DOUBLECOLON=10 10 | NONE="none"=11 11 | THREAD="thread"=12 12 | EXTENDS="extends"=13 13 | GROUP="group"=14 14 | PROCESS="process"=15 15 | SYSTEM="system"=16 16 | SUBPROGRAM="subprogram"=17 17 | DATA="data"=18 18 | PROCESSOR="processor"=19 19 | MEMORY="memory"=20 20 | BUS="bus"=21 21 | DEVICE="device"=22 22 | DOT=23 23 | IMPL="implementation"=24 24 | FEATURES="features"=25 25 | COLON=26 26 | REFINED="refined"=27 27 | TO="to"=28 28 | PROVIDES="provides"=29 29 | REQUIRES="requires"=30 30 | REFINES="refines"=31 31 | TYPE="type"=32 32 | SUBCOMPONENTS="subcomponents"=33 33 | ANNEX="annex"=34 34 | ANNEX_TEXT=35 35 | PROPERTY="property"=36 36 | SET="set"=37 37 | IS="is"=38 38 | BOOLEAN="aadlboolean"=39 39 | STRING="aadlstring"=40 40 | ENUMERATION="enumeration"=41 41 | LPAREN=42 42 | COMMA=43 43 | RPAREN=44 44 | UNITS="units"=45 45 | ASSIGN=46 46 | STAR=47 47 | REAL="aadlreal"=48 48 | INTEGER="aadlinteger"=49 49 | DOTDOT=50 50 | PLUS=51 51 | MINUS=52 52 | NUMERIC_LIT=53 53 | RANGE="range"=54 54 | OF="of"=55 55 | CLASSIFIER="classifier"=56 56 | REFERENCE="reference"=57 57 | CONNECTIONS="connections"=58 58 | SERVER="server"=59 59 | ACCESS="access"=60 60 | INHERIT="inherit"=61 61 | APPLIES="applies"=62 62 | ALL="all"=63 63 | MODE="mode"=64 64 | PORT="port"=65 65 | EVENT="event"=66 66 | FLOW="flow"=67 67 | PARAMETER="parameter"=68 68 | LIST="list"=69 69 | CONSTANT="constant"=70 70 | DELTA="delta"=71 71 | PROPERTIES="properties"=72 72 | LCURLY=73 73 | RCURLY=74 74 | ASSIGNPLUS=75 75 | VALUE="value"=76 76 | IN="in"=77 77 | BINDING="binding"=78 78 | LBRACKET=79 79 | RBRACKET=80 80 | OR="or"=81 81 | AND="and"=82 82 | TRUE="true"=83 83 | FALSE="false"=84 84 | NOT=85 85 | STRING_LITERAL=86 86 | CALLS="calls"=87 87 | MODES="modes"=88 88 | INITIAL="initial"=89 89 | LTRANS=90 90 | RTRANS=91 91 | ARROW=92 92 | OUT="out"=93 93 | INVERSE="inverse"=94 94 | DARROW=95 95 | FLOWS="flows"=96 96 | SOURCE="source"=97 97 | SINK="sink"=98 98 | PATH="path"=99 99 | AADLSPEC=100 100 | NOTT="not"=101 101 | TRANSITIONS="transitions"=102 102 | HASH=103 103 | DIGIT=104 104 | EXPONENT=105 105 | INT_EXPONENT=106 106 | EXTENDED_DIGIT=107 107 | BASED_INTEGER=108 108 | BASE=109 109 | ESC=110 110 | HEX_DIGIT=111 111 | WS=112 112 | SL_COMMENT=113 113 | -------------------------------------------------------------------------------- /dmt/commonPy2/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ttsiodras/DataModellingTools/980dda80cc05f85d7e3b56537c2aecd4ce2b8c76/dmt/commonPy2/__init__.py -------------------------------------------------------------------------------- /dmt/commonPy2/aadlAST.py: -------------------------------------------------------------------------------- 1 | # (C) Semantix Information Technologies. 2 | # 3 | # Semantix Information Technologies is licensing the code of the 4 | # Data Modelling Tools (DMT) in the following dual-license mode: 5 | # 6 | # Commercial Developer License: 7 | # The DMT Commercial Developer License is the appropriate version 8 | # to use for the development of proprietary and/or commercial software. 9 | # This version is for developers/companies who do not want to share 10 | # the source code they develop with others or otherwise comply with the 11 | # terms of the GNU Lesser General Public License version 3. 12 | # 13 | # GNU LGPL v. 2.1: 14 | # This version of DMT is the one to use for the development of 15 | # non-commercial applications, when you are willing to comply 16 | # with the terms of the GNU Lesser General Public License version 3. 17 | # 18 | # The features of the two licenses are summarized below: 19 | # 20 | # Commercial 21 | # Developer LGPL 22 | # License 23 | # 24 | # License cost License fee charged No license fee 25 | # 26 | # Must provide source 27 | # code changes to DMT No, modifications can Yes, all source code 28 | # be closed must be provided back 29 | # 30 | # Can create Yes, that is, No, applications are subject 31 | # proprietary no source code needs to the LGPL and all source code 32 | # applications to be disclosed must be made available 33 | # 34 | # Support Yes, 12 months of No, but available separately 35 | # premium technical for purchase 36 | # support 37 | # 38 | # Charge for Runtimes None None 39 | # 40 | #g_nodes = [] 41 | g_signals = {} 42 | g_apLevelContainers = {} 43 | 44 | g_subProgramImplementations = [] 45 | g_processImplementations = [] 46 | g_threadImplementations = [] 47 | 48 | g_systems = {} 49 | 50 | # AST classes 51 | 52 | 53 | class AadlParameter: 54 | def __init__(self, direction, type): 55 | assert direction in ['IN', 'OUT', 'INOUT'] 56 | self._direction = direction 57 | self._type = type 58 | 59 | 60 | class AadlSubProgramFeature: 61 | def __init__(self, id, parameter): 62 | self._id = id 63 | self._parameter = parameter 64 | 65 | 66 | class AadlPropertyAssociationNoModes: 67 | def __init__(self, name, pe): 68 | self._name = name 69 | self._propertyExpressionOrList = pe 70 | 71 | 72 | class AadlPort: 73 | def __init__(self, direction, type): 74 | self._direction = direction 75 | self._type = type 76 | 77 | 78 | class AadlEventPort: 79 | def __init__(self, direction, sp): 80 | self._direction = direction 81 | self._sp = sp 82 | 83 | def __repr__(self): 84 | result = "AadlEventPort("+self._direction+"," 85 | if self._sp: 86 | result+=self._sp 87 | result+=")" 88 | return result 89 | 90 | 91 | class AadlEventDataPort(AadlPort): 92 | def __init__(self, direction, type): 93 | AadlPort.__init__(self, direction, type) 94 | 95 | 96 | class AadlThreadFeature: 97 | def __init__(self, id, port): 98 | assert(isinstance(port, AadlPort)) 99 | self._id = id 100 | self._port = port 101 | 102 | 103 | class AadlProcessFeature: 104 | def __init__(self, id, port): 105 | assert(isinstance(port, AadlPort)) 106 | self._id = id 107 | self._port = port 108 | 109 | 110 | class AadlContainedPropertyAssociation: 111 | def __init__(self, name, value): 112 | self._name = name 113 | self._value = value 114 | 115 | 116 | class Signal: 117 | def __init__(self, asnFilename, asnNodename, asnSize): 118 | self._asnFilename = asnFilename 119 | self._asnNodename = asnNodename 120 | self._asnSize = asnSize 121 | 122 | 123 | class Port: 124 | def __init__(self, signal): 125 | self._signal = signal 126 | 127 | 128 | class DualPort(Port): 129 | def __init__(self, signal): 130 | Port.__init__(self, signal) 131 | 132 | 133 | class UniPort(Port): 134 | def __init__(self, signal): 135 | Port.__init__(self, signal) 136 | 137 | 138 | class IncomingUniPort(UniPort): 139 | def __init__(self, signal): 140 | UniPort.__init__(self, signal) 141 | 142 | 143 | class OutgoingUniPort(UniPort): 144 | def __init__(self, signal): 145 | UniPort.__init__(self, signal) 146 | 147 | 148 | class ApLevelContainer: 149 | def __init__(self, id): 150 | self._id = id 151 | self._calls = [] 152 | self._params = [] 153 | self._connections = [] 154 | self._fpgaModes = '' 155 | self._language = None 156 | 157 | def AddCalledAPLC(self, idAPLC): 158 | self._calls.append(idAPLC) 159 | 160 | def AddConnection(self, srcUniquePortId, destUniquePortId): 161 | if srcUniquePortId._componentId is None: 162 | srcUniquePortId._componentId = self._id 163 | if destUniquePortId._componentId is None: 164 | destUniquePortId._componentId = self._id 165 | self._connections.append(Connection(srcUniquePortId, destUniquePortId)) 166 | 167 | def AddParam(self, param): 168 | self._params.append(param) 169 | 170 | def SetLanguage(self, language): 171 | self._language = language 172 | 173 | def SetFPGAModes(self, fpgaModes): 174 | self._fpgaModes = fpgaModes 175 | 176 | class Param: 177 | def __init__(self, aplcID, id, signal, sourceElement): 178 | self._id = id 179 | # It is the Process, Thread or Subprogram ID 180 | self._aplcID = aplcID 181 | # Could be string (i.e. AADL DataType name) or Signal (i.e. asnFilename, asnNodename) 182 | self._signal = signal 183 | self._sourceElement = sourceElement # Could be AadlPort, AadlEventDataPort, AadlParameter 184 | 185 | 186 | class InParam(Param): 187 | def __init__(self, aplcID, id, signal, sourceElement): 188 | Param.__init__(self, aplcID, id, signal, sourceElement) 189 | 190 | 191 | class OutParam(Param): 192 | def __init__(self, aplcID, id, signal, sourceElement): 193 | Param.__init__(self, aplcID, id, signal, sourceElement) 194 | 195 | 196 | class InOutParam(Param): 197 | def __init__(self, aplcID, id, signal, sourceElement): 198 | Param.__init__(self, aplcID, id, signal, sourceElement) 199 | 200 | 201 | class UniquePortIdentifier: 202 | def __init__(self, componentId, portId): 203 | self._componentId = componentId 204 | self._portId = portId 205 | 206 | 207 | class Connection: 208 | def __init__(self, fromC, toC): 209 | self._from = fromC 210 | self._to = toC 211 | -------------------------------------------------------------------------------- /dmt/commonPy2/configMT.py: -------------------------------------------------------------------------------- 1 | # (C) Semantix Information Technologies. 2 | # 3 | # Semantix Information Technologies is licensing the code of the 4 | # Data Modelling Tools (DMT) in the following dual-license mode: 5 | # 6 | # Commercial Developer License: 7 | # The DMT Commercial Developer License is the appropriate version 8 | # to use for the development of proprietary and/or commercial software. 9 | # This version is for developers/companies who do not want to share 10 | # the source code they develop with others or otherwise comply with the 11 | # terms of the GNU Lesser General Public License version 3. 12 | # 13 | # GNU LGPL v. 2.1: 14 | # This version of DMT is the one to use for the development of 15 | # non-commercial applications, when you are willing to comply 16 | # with the terms of the GNU Lesser General Public License version 3. 17 | # 18 | # The features of the two licenses are summarized below: 19 | # 20 | # Commercial 21 | # Developer LGPL 22 | # License 23 | # 24 | # License cost License fee charged No license fee 25 | # 26 | # Must provide source 27 | # code changes to DMT No, modifications can Yes, all source code 28 | # be closed must be provided back 29 | # 30 | # Can create Yes, that is, No, applications are subject 31 | # proprietary no source code needs to the LGPL and all source code 32 | # applications to be disclosed must be made available 33 | # 34 | # Support Yes, 12 months of No, but available separately 35 | # premium technical for purchase 36 | # support 37 | # 38 | # Charge for Runtimes None None 39 | # 40 | import os 41 | g_bOnlySubprograms = False 42 | debugParser = False 43 | inputAadlAST = None 44 | verbose = False 45 | showCode = False 46 | args = [] 47 | outputDir = "." + os.sep 48 | -------------------------------------------------------------------------------- /dmt/commonPy2/utility.py: -------------------------------------------------------------------------------- 1 | # (C) Semantix Information Technologies. 2 | # 3 | # Semantix Information Technologies is licensing the code of the 4 | # Data Modelling Tools (DMT) in the following dual-license mode: 5 | # 6 | # Commercial Developer License: 7 | # The DMT Commercial Developer License is the appropriate version 8 | # to use for the development of proprietary and/or commercial software. 9 | # This version is for developers/companies who do not want to share 10 | # the source code they develop with others or otherwise comply with the 11 | # terms of the GNU Lesser General Public License version 3. 12 | # 13 | # GNU LGPL v. 2.1: 14 | # This version of DMT is the one to use for the development of 15 | # non-commercial applications, when you are willing to comply 16 | # with the terms of the GNU Lesser General Public License version 3. 17 | # 18 | # The features of the two licenses are summarized below: 19 | # 20 | # Commercial 21 | # Developer LGPL 22 | # License 23 | # 24 | # License cost License fee charged No license fee 25 | # 26 | # Must provide source 27 | # code changes to DMT No, modifications can Yes, all source code 28 | # be closed must be provided back 29 | # 30 | # Can create Yes, that is, No, applications are subject 31 | # proprietary no source code needs to the LGPL and all source code 32 | # applications to be disclosed must be made available 33 | # 34 | # Support Yes, 12 months of No, but available separately 35 | # premium technical for purchase 36 | # support 37 | # 38 | # Charge for Runtimes None None 39 | # 40 | import sys 41 | import os 42 | import re 43 | import platform 44 | import traceback 45 | 46 | import configMT 47 | 48 | 49 | def inform(format, *args): 50 | if configMT.verbose: 51 | print(format % args) 52 | 53 | 54 | def warn(format, *args): 55 | sys.stderr.write(("WARNING: " + format) % args) 56 | sys.stderr.write("\n") 57 | 58 | 59 | def panic(x): 60 | if not x.endswith("\n"): 61 | x += "\n" 62 | sys.stderr.write("\n"+chr(27)+"[32m" + x + chr(27) + "[0m\n") 63 | sys.exit(1) 64 | 65 | 66 | def panicWithCallStack(msg): 67 | if configMT.verbose: 68 | sys.stderr.write("\n"+chr(27)+"[32m" + msg + chr(27) + "[0m\n") 69 | sys.stderr.write("\nCall stack was:\n%s\n" % "".join(traceback.format_stack())) 70 | else: 71 | panic(msg) 72 | 73 | 74 | def lcfirst(word): 75 | if len(word): 76 | return word[:1].lower() + word[1:] 77 | else: 78 | return word 79 | 80 | 81 | def ucfirst(word): 82 | if len(word): 83 | return word[:1].upper() + word[1:] 84 | else: 85 | return word 86 | 87 | 88 | def collapseCAPSgroups(word): 89 | while 1: 90 | m = re.match('^(.*?)([A-Z][A-Z]+)(.*?)$', word) 91 | if m: 92 | word = m.group(1) + lcfirst(m.group(2)) + m.group(3) 93 | else: 94 | break 95 | return word 96 | 97 | 98 | def readContexts(tapNumbers): 99 | data={} 100 | for line in open(tapNumbers, "r").readlines(): 101 | line = line.rstrip(os.linesep) 102 | lista = line.split(":") 103 | data[lista[0]] = lista[1] 104 | return data 105 | 106 | 107 | class Matcher: 108 | def __init__(self, pattern, flags=0): 109 | self._pattern = re.compile(pattern, flags) 110 | self._lastOne = None 111 | 112 | def match(self, line): 113 | self._match=re.match(self._pattern, line) 114 | self._lastOne='Match' 115 | return self._match 116 | 117 | def search(self, line): 118 | self._search=re.search(self._pattern, line) 119 | self._lastOne='Search' 120 | return self._search 121 | 122 | def group(self, idx): 123 | if self._lastOne == 'Match': 124 | return self._match.group(idx) 125 | elif self._lastOne == 'Search': 126 | return self._search.group(idx) 127 | else: 128 | return panic("Matcher group called with index %d before match/search!\n" % idx) 129 | 130 | def groups(self): 131 | if self._lastOne == 'Match': 132 | return self._match.groups() 133 | elif self._lastOne == 'Search': 134 | return self._search.groups() 135 | else: 136 | return panic("Matcher groups called with match/search!\n") 137 | 138 | 139 | def mysystem(cmd): 140 | if platform.system() == "Windows" or platform.system().startswith("CYGWIN"): 141 | return os.system('"' + cmd + '"') 142 | else: 143 | return os.system(cmd) 144 | -------------------------------------------------------------------------------- /dmt/parse_aadl.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2 2 | # vim: set expandtab ts=8 sts=4 shiftwidth=4 3 | # 4 | # (C) Semantix Information Technologies. 5 | # 6 | # Semantix Information Technologies is licensing the code of the 7 | # Data Modelling Tools (DMT) in the following dual-license mode: 8 | # 9 | # Commercial Developer License: 10 | # The DMT Commercial Developer License is the suggested version 11 | # to use for the development of proprietary and/or commercial software. 12 | # This version is for developers/companies who do not want to comply 13 | # with the terms of the GNU Lesser General Public License version 2.1. 14 | # 15 | # GNU LGPL v. 2.1: 16 | # This version of DMT is the one to use for the development of 17 | # applications, when you are willing to comply with the terms of the 18 | # GNU Lesser General Public License version 2.1. 19 | # 20 | # Note that in both cases, there are no charges (royalties) for the 21 | # generated code. 22 | # 23 | ''' 24 | AADLv2 parser 25 | ''' 26 | 27 | import os 28 | import sys 29 | 30 | import commonPy2.aadlAST 31 | 32 | #import aadlParser 33 | from commonPy2 import AadlLexer 34 | from commonPy2 import AadlParser 35 | 36 | import antlr 37 | 38 | from commonPy2.utility import panic, inform 39 | 40 | 41 | def ParseAADLfilesAndResolveSignals(): 42 | '''Invokes the ANTLR generated AADL parser, and resolves 43 | all references to AAADL Data types into the param._signal member 44 | of each SUBPROGRAM param.''' 45 | for aadlFilename in sys.argv[1:]: 46 | # Parse AADL system description files 47 | inform("Parsing %s...", aadlFilename) 48 | #aadlParser.ParseInput("\n".join(open(aadlFilename,'r').readlines())) 49 | 50 | L = AadlLexer.Lexer(aadlFilename) 51 | P = AadlParser.Parser(L) 52 | L.setFilename(aadlFilename) 53 | P.setFilename(L.getFilename()) 54 | try: 55 | P.aadl_specification() 56 | except antlr.ANTLRException as e: # pragma: no cover 57 | panic("Error in file '%s': %s\n" % (e.fileName, str(e))) 58 | 59 | # Resolve signal definitions over all input AADL files 60 | for subProgramName, subProgram in \ 61 | commonPy2.aadlAST.g_apLevelContainers.items(): 62 | inform( 63 | "Resolving data definitions in subprogram %s..." % subProgramName) 64 | for param in subProgram._params: 65 | if not isinstance(param._signal, commonPy2.aadlAST.Signal): 66 | if param._signal not in commonPy2.aadlAST.g_signals: 67 | panic("Unknown data type %s in the definition of %s!\n" % ( 68 | param._signal, subProgramName)) # pragma: no cover 69 | param._signal = commonPy2.aadlAST.g_signals[param._signal] 70 | 71 | 72 | def main(): 73 | sys.path.append(os.path.abspath(os.path.dirname(sys.argv[0]))) 74 | astFile = None 75 | if sys.argv.count("-o") != 0: 76 | idx = sys.argv.index("-o") 77 | try: 78 | astFile = os.path.abspath(sys.argv[idx + 1]) 79 | except: # pragma: no cover 80 | panic('Usage: %s -o astFile input1.aadl [input2.aadl] ...\n' % sys.argv[0]) # pragma: no cover 81 | del sys.argv[idx] 82 | del sys.argv[idx] 83 | if "-onlySP" in sys.argv: # pragma: no cover 84 | commonPy2.configMT.g_bOnlySubprograms = True # pragma: no cover 85 | sys.argv.remove("-onlySP") # pragma: no cover 86 | if "-verbose" in sys.argv: 87 | commonPy2.configMT.verbose = True 88 | sys.argv.remove("-verbose") 89 | 90 | # No other options must remain in the cmd line... 91 | if astFile is None or len(sys.argv) < 2: 92 | panic('Usage: %s [-verbose] [-useOSS] [-o dirname] input1.aadl [input2.aadl] ...\n' % sys.argv[0]) # pragma: no cover 93 | commonPy2.configMT.showCode = True 94 | for f in sys.argv[1:]: 95 | if not os.path.isfile(f): 96 | panic("'%s' is not a file!\n" % f) # pragma: no cover 97 | 98 | ParseAADLfilesAndResolveSignals() 99 | serialize_package = { 100 | 'g_signals': commonPy2.aadlAST.g_signals, 101 | 'g_apLevelContainers': commonPy2.aadlAST.g_apLevelContainers, 102 | 'g_subProgramImplementations': commonPy2.aadlAST.g_subProgramImplementations, 103 | 'g_processImplementations': commonPy2.aadlAST.g_processImplementations, 104 | 'g_threadImplementations': commonPy2.aadlAST.g_threadImplementations, 105 | 'g_systems': commonPy2.aadlAST.g_systems 106 | } 107 | import cPickle 108 | cPickle.dump(serialize_package, open(astFile, 'w')) 109 | 110 | if __name__ == "__main__": 111 | if "-pdb" in sys.argv: 112 | sys.argv.remove("-pdb") # pragma: no cover 113 | import pdb # pragma: no cover 114 | pdb.run('main()') # pragma: no cover 115 | else: 116 | main() 117 | -------------------------------------------------------------------------------- /dmt/smp2asn.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | # (C) Semantix Information Technologies. 4 | # 5 | # Semantix Information Technologies is licensing the code of the 6 | # Data Modelling Tools (DMT) in the following dual-license mode: 7 | # 8 | # Commercial Developer License: 9 | # The DMT Commercial Developer License is the suggested version 10 | # to use for the development of proprietary and/or commercial software. 11 | # This version is for developers/companies who do not want to comply 12 | # with the terms of the GNU Lesser General Public License version 2.1. 13 | # 14 | # GNU LGPL v. 2.1: 15 | # This version of DMT is the one to use for the development of 16 | # applications, when you are willing to comply with the terms of the 17 | # GNU Lesser General Public License version 2.1. 18 | # 19 | # Note that in both cases, there are no charges (royalties) for the 20 | # generated code. 21 | # 22 | ''' 23 | SMP2 Catalogues datatypes importer 24 | 25 | This tool parses SMP2 Catalogues, extracts the data types described in them, 26 | and maps them to the corresponding ASN.1 data type declarations. It also 27 | includes logic to merge these types to pre-existing data type declarations 28 | of an ASN.1 file - thus allowing merging of SMP2 designs into TASTE designs 29 | (datatype-wise). 30 | ''' 31 | import os 32 | import sys 33 | import getopt 34 | 35 | from typing import Dict, List # NOQA 36 | 37 | from .commonPy import asnParser 38 | from .commonPy.createInternalTypes import ScanChildren 39 | from .commonPy.asnParser import AST_Lookup # NOQA pylint: disable=unused-import 40 | from .commonPy.commonSMP2 import ( 41 | info, panic, green, white, red, setVerbosity, 42 | DashUnderscoreAgnosticDict, ConvertCatalogueToASN_AST) 43 | 44 | 45 | def usage(coloredMsg: str = "") -> None: 46 | '''Prints help message and aborts. ''' 47 | usageMsg = 'Usage: smp2asn \n\n' \ 48 | 'Where options must include:\n' \ 49 | ' -o, --outAsn1=newAsnGrammar.asn the output ASN.1 grammar, containing\n'\ 50 | ' all the SMP2 types (if -a was used,\n'\ 51 | ' the existing ASN.1 types, too)\n'\ 52 | 'Options may also include:\n'\ 53 | ' -a, --asn1=asnGrammar.asn an input ASN.1 grammar to merge with\n'\ 54 | ' -p, --prune prune unnamed (inner) SMP2-translation types\n'\ 55 | ' -v, --verbose Be more verbose (debugging)\n' \ 56 | ' -h, --help Show this help message\n' 57 | panic(usageMsg, coloredMsg) 58 | 59 | 60 | def MergeASN1_AST(smp2AsnAST: AST_Lookup) -> Dict[str, str]: 61 | '''Merges the ASN.1 AST generated from SMP2 files (smp2AsnAST param) 62 | into the ASN.1 AST stored in asnParser.g_names. Uses smart 63 | merging, i.e. diff-like semantics.''' 64 | typesToAddVerbatim = [] 65 | identicals = {} # type: Dict[str, str] 66 | d = asnParser.g_names 67 | for k, v in smp2AsnAST.items(): 68 | if k in d: 69 | # Type name exists in both trees - is it the same? 70 | if not v.IdenticalPerSMP2(d[k], smp2AsnAST, d): # pragma: no cover 71 | panic(green + k + white + " exists, but is different:\n" + 72 | "it is...\n" + d[k].AsASN1(d) + "\n" + 73 | "but in SMP2 it is...\n" + v.AsASN1(smp2AsnAST)) # pragma: no cover 74 | else: # pragma: no cover 75 | info(1, green, k, white, "exists and is semantically equivalent.") # pragma: no cover 76 | else: 77 | # Find an identical type if possible 78 | for k2, v2 in d.items(): 79 | if v2._isArtificial: 80 | # Avoid mapping to artificially generated inner types 81 | # (see last part of VerifyAndFixAST in asnParser) 82 | continue 83 | if v2.IdenticalPerSMP2(v, d, smp2AsnAST): 84 | info(1, green, k, white, "is identical to", red, k2, white) 85 | identicals[k] = k2 86 | break 87 | else: 88 | info(1, green, k, white, "must be copied (no equivalent type found)...") 89 | typesToAddVerbatim.append(k) 90 | # Merge missing types in asnParser.g_names 91 | for nodeTypename in typesToAddVerbatim: 92 | results = [] # type: List[str] 93 | node = smp2AsnAST[nodeTypename] 94 | # Take care to add dependencies first 95 | ScanChildren(nodeTypename, node, smp2AsnAST, results, isRoot=True, createInnerNodesInNames=False) 96 | info(1, "Will copy", nodeTypename, "(" + str(node.__class__) + ")", ("and " + str(results) if results else '')) 97 | results.append(nodeTypename) 98 | for r in results: 99 | node = smp2AsnAST[r] 100 | d[r] = node 101 | # mypy helped me see that his is impossible (coverage agrees - notice the no cover!) 102 | # if isinstance(node, AsnMetaType): 103 | # asnParser.g_metatypes[r] = r._containedType # pragma: no cover 104 | # d[r] = smp2AsnAST[r._containedType] # pragma: no cover 105 | asnParser.g_typesOfFile.setdefault(node._asnFilename, []).append(r) 106 | return identicals 107 | 108 | 109 | def SaveASN_AST(bPruneUnnamedInnerTASTEtypes: bool, outputAsn1Grammar: str, identicals: Dict[str, str]) -> None: 110 | d = DashUnderscoreAgnosticDict() 111 | for k, v in asnParser.g_names.items(): 112 | d[k] = v 113 | with open(outputAsn1Grammar, 'w') as f: 114 | f.write('DATAVIEW DEFINITIONS AUTOMATIC TAGS ::= BEGIN\n\n') 115 | for k, v in d.items(): 116 | if v._isArtificial: 117 | # Don't emit artificially generated inner types 118 | # (see last part of VerifyAndFixAST in asnParser) 119 | continue 120 | if bPruneUnnamedInnerTASTEtypes and 'TaStE' in k: 121 | # Don't emit artificially generated SMP2 types 122 | # (see smp2_A_mapper) 123 | 124 | # Update 2013-Jul-8: after having ASN1SCC handle unnamed inner types, 125 | # this is now impossible. 126 | continue # pragma: no cover 127 | f.write('-- From ' + v._asnFilename + ' line ' + str(v._lineno) + '\n') 128 | f.write(k + ' ::= ') 129 | f.write(v.AsASN1(d) + "\n\n") 130 | for k2, v2 in identicals.items(): 131 | f.write(k2 + ' ::= ' + v2 + '\n\n') 132 | f.write('END\n') 133 | 134 | 135 | def main() -> int: 136 | try: 137 | optlist, args = getopt.gnu_getopt( 138 | sys.argv[1:], 139 | "hvpi:a:o:", ['help', 'verbose', 'prune', 'smp2=', 'asn1=', 'outAsn1=']) 140 | except: 141 | usage("Invalid parameters passed...") 142 | inputSmp2Files = args 143 | inputAsn1Grammar = "" 144 | outputAsn1Grammar = "" 145 | verboseLevel = 0 146 | bPrune = False 147 | for opt, arg in optlist: 148 | if opt in ("-h", "--help"): 149 | usage() 150 | elif opt in ("-a", "--asn1"): 151 | inputAsn1Grammar = arg 152 | elif opt in ("-o", "--outAsn1"): 153 | outputAsn1Grammar = arg 154 | elif opt in ("-p", "--prune"): 155 | bPrune = True 156 | elif opt in ("-v", "--verbose"): 157 | verboseLevel += 1 158 | setVerbosity(verboseLevel) 159 | 160 | if not inputSmp2Files: 161 | usage("SMP2 catalogues were not provided") 162 | if not outputAsn1Grammar: 163 | usage("Mandatory option (-o newAsnGrammar.asn) missing") # pragma: no cover 164 | 165 | def CheckFileExists(x: str) -> None: 166 | if not os.path.isfile(os.path.realpath(x)): 167 | usage("Input (%s) is not a file" % x) 168 | for f in inputSmp2Files: 169 | CheckFileExists(f) 170 | if inputAsn1Grammar: 171 | CheckFileExists(inputAsn1Grammar) 172 | 173 | smp2AsnAST, unused_idToTypeDict = ConvertCatalogueToASN_AST(inputSmp2Files) 174 | if inputAsn1Grammar: 175 | asnParser.ParseAsnFileList([inputAsn1Grammar]) 176 | identicals = MergeASN1_AST(smp2AsnAST) 177 | SaveASN_AST(bPrune, outputAsn1Grammar, identicals) 178 | return 0 179 | 180 | 181 | if __name__ == '__main__': 182 | for dbg in ["-d", "--debug"]: 183 | if dbg in sys.argv: 184 | sys.argv.remove(dbg) # pragma: no cover 185 | import pdb # pragma: no cover pylint: disable=wrong-import-position,wrong-import-order 186 | pdb.run('main()') # pragma: no cover 187 | break # pragma: no cover 188 | else: 189 | sys.exit(main()) 190 | 191 | # vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 192 | -------------------------------------------------------------------------------- /git-commit-hook/pre-commit: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # An example hook script to verify what is about to be committed. 4 | # Called by "git commit" with no arguments. The hook should 5 | # exit with non-zero status after issuing an appropriate message if 6 | # it wants to stop the commit. 7 | # 8 | # To enable this hook, rename this file to "pre-commit". 9 | 10 | if git rev-parse --verify HEAD >/dev/null 2>&1 11 | then 12 | against=HEAD 13 | else 14 | # Initial commit: diff against an empty tree object 15 | against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 16 | fi 17 | 18 | # If you want to allow non-ASCII filenames set this variable to true. 19 | allownonascii=$(git config --bool hooks.allownonascii) 20 | 21 | # Redirect output to stderr. 22 | exec 1>&2 23 | 24 | # Cross platform projects tend to avoid non-ASCII filenames; prevent 25 | # them from being added to the repository. We exploit the fact that the 26 | # printable range starts at the space character and ends with tilde. 27 | if [ "$allownonascii" != "true" ] && 28 | # Note that the use of brackets around a tr range is ok here, (it's 29 | # even required, for portability to Solaris 10's /usr/bin/tr), since 30 | # the square bracket bytes happen to fall in the designated range. 31 | test $(git diff --cached --name-only --diff-filter=A -z $against | 32 | LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0 33 | then 34 | cat <<\EOF 35 | Error: Attempt to add a non-ASCII file name. 36 | 37 | This can cause problems if you want to work with people on other platforms. 38 | 39 | To be portable it is advisable to rename the file. 40 | 41 | If you know what you are doing you can disable this check using: 42 | 43 | git config hooks.allownonascii true 44 | EOF 45 | exit 1 46 | fi 47 | 48 | make flake8 || exit 1 49 | make pylint || exit 1 50 | 51 | # If there are whitespace errors, print the offending file names and fail. 52 | exec git diff-index --check --cached $against -- 53 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | coverage>=3.7.1 2 | flake8>=3.7.9 3 | mypy==0.530 4 | pyflakes>=1.2.3 5 | pylint>=1.7.0 6 | pytest>=2.6.3 7 | lxml>=3.6.0 8 | astroid>=1.4.6 9 | pycodestyle>=2.0.0 10 | typing==3.5.2.2 11 | typing-extensions 12 | mypy-extensions>=0.3.0 13 | -------------------------------------------------------------------------------- /setup.py.in: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | ''' 4 | Setup file for Linux distribution of the Data Modelling Toolchain (DMT). 5 | 6 | Usage: python setup.py sdist --> to create a tarball 7 | python setup.py install --> to install in python directory 8 | ''' 9 | 10 | from setuptools import setup, find_packages 11 | 12 | setup( 13 | name='dmt', 14 | version="2.2-@SCM_REVISION@", 15 | packages=find_packages(), 16 | author='Thanassis Tsiodras', 17 | author_email='Thanassis.Tsiodras@esa.int', 18 | description='TASTE Data Modelling Technologies based on ASN.1', 19 | long_description=open('README.md').read(), 20 | include_package_data=True, 21 | url='http://taste.tuxfamily.org', 22 | classifiers=[ 23 | 'Programming Language :: Python', 24 | 'License :: OSI Approved :: GNU Lesser General Public License v3 (LGPL)', 25 | 'Operating System :: OS Independent', 26 | 'Programming Language :: Python :: 3.5' 27 | ], 28 | install_requires=[ 29 | 'coverage>=3.7.1', 30 | 'pytest>=2.6.3', 31 | 'pycodestyle>=2.0.0', 32 | 'typing==3.5.2.2', 33 | 'mypy-extensions>=0.3.0', 34 | ], 35 | entry_points={ 36 | 'console_scripts': [ 37 | 'asn2aadlPlus = dmt.asn2aadlPlus:main', 38 | 'asn2dataModel = dmt.asn2dataModel:main', 39 | 'aadl2glueC = dmt.aadl2glueC:main', 40 | 'badTypes = dmt.badTypes:main', 41 | 'msgPrinter = dmt.msgPrinter:main', 42 | 'msgPrinterASN1 = dmt.msgPrinterASN1:main', 43 | 'smp2asn = dmt.smp2asn:main', 44 | 'dmt = dmt.commonPy:print_version' 45 | ] 46 | } 47 | ) 48 | -------------------------------------------------------------------------------- /setup_testdb.sh: -------------------------------------------------------------------------------- 1 | /etc/init.d/postgresql start 2 | su - postgres -c 'createuser ubuntu;' 3 | echo "ALTER USER ubuntu WITH PASSWORD 'tastedb';" | su - postgres -c 'psql -w' 4 | echo '127.0.0.1:5432:*:ubuntu:tastedb' > ~/.pgpass 5 | chmod 0600 ~/.pgpass 6 | echo "GRANT ALL PRIVILEGES ON DATABASE postgres TO ubuntu;" | su - postgres -c 'psql -w' 7 | echo "ALTER USER ubuntu CREATEDB;" | su - postgres -c 'psql -w' 8 | -------------------------------------------------------------------------------- /tests-coverage/ConcurrencyView.aadl: -------------------------------------------------------------------------------- 1 | SYSTEM ConcurrencyView 2 | END ConcurrencyView; 3 | 4 | SYSTEM IMPLEMENTATION ConcurrencyView.others 5 | SUBCOMPONENTS 6 | The_Processor : PROCESSOR The_Processor; 7 | ConcurrencyView_Async : PROCESS ConcurrencyView_Async.others; 8 | PROPERTIES 9 | Actual_Processor_Binding => REFERENCE The_Processor APPLIES TO ConcurrencyView_Async; 10 | END ConcurrencyView.others; 11 | 12 | PROCESSOR The_Processor 13 | PROPERTIES 14 | ARAO::Execution_Platform => Native; 15 | END The_Processor; 16 | 17 | PROCESS ConcurrencyView_Async 18 | END ConcurrencyView_Async; 19 | 20 | PROCESS IMPLEMENTATION ConcurrencyView_Async.others 21 | SUBCOMPONENTS 22 | BASIC_APLC_Cyclic_FV : THREAD BASIC_APLC_Cyclic_FV.others; 23 | BASIC_APLC_Basic_FV : THREAD BASIC_APLC_Basic_FV.others; 24 | CONTROL_APLC_Control_FV : THREAD CONTROL_APLC_Control_FV.others; 25 | CONNECTIONS 26 | EVENT PORT BASIC_APLC_Cyclic_FV.CyclicActivationImplementation -> BASIC_APLC_Basic_FV.CyclicActivationImplementation; 27 | EVENT DATA PORT BASIC_APLC_Basic_FV.BasicTOControl -> CONTROL_APLC_Control_FV.BasicTOControl; 28 | EVENT DATA PORT CONTROL_APLC_Control_FV.ControlUPTOBasic -> BASIC_APLC_Basic_FV.ControlUPTOBasic; 29 | EVENT DATA PORT CONTROL_APLC_Control_FV.ControlDOWNTOBasic -> BASIC_APLC_Basic_FV.ControlDOWNTOBasic; 30 | END ConcurrencyView_Async.others; 31 | 32 | --------------------------------------------------- 33 | -- VM-Level Container: BASIC_APLC_Cyclic_FV 34 | --------------------------------------------------- 35 | 36 | THREAD BASIC_APLC_Cyclic_FV 37 | features 38 | CyclicActivationImplementation : OUT EVENT PORT; 39 | END BASIC_APLC_Cyclic_FV; 40 | 41 | THREAD IMPLEMENTATION BASIC_APLC_Cyclic_FV.others 42 | CALLS { 43 | wrapper : SUBPROGRAM BASIC_APLC_Cyclic_FV_SDL_Ada; 44 | }; 45 | PROPERTIES 46 | Initialize_Entrypoint => "SDL_Wrappers.SDL_Init_Cyclic_FV"; 47 | Dispatch_Protocol => Periodic; 48 | Period => 1000 ms; 49 | ARAO::Priority => 2; 50 | END BASIC_APLC_Cyclic_FV.others; 51 | 52 | SUBPROGRAM BASIC_APLC_Cyclic_FV_SDL_Ada 53 | PROPERTIES 54 | Source_Language => Ada; 55 | Source_Name => "SDL_Wrappers.CyclicActivation"; 56 | Source_Stack_Size => 100 KB; 57 | END BASIC_APLC_Cyclic_FV_SDL_Ada; 58 | 59 | --------------------------------------------------- 60 | -- VM-Level Container: BASIC_APLC_Basic_FV 61 | --------------------------------------------------- 62 | 63 | THREAD BASIC_APLC_Basic_FV 64 | FEATURES 65 | CyclicActivationImplementation : IN EVENT PORT 66 | { Compute_Entrypoint => "SDL_Wrappers.CyclicActivationImplementation"; }; 67 | ControlUPTOBasic : IN EVENT DATA PORT DataView::T_CONTROL_UP_OUT_Buffer.impl 68 | { Compute_Entrypoint => "SDL_Wrappers.ControlUPTOBasic"; }; 69 | ControlDOWNTOBasic : IN EVENT DATA PORT DataView::T_CONTROL_DOWN_OUT_Buffer.impl 70 | { Compute_Entrypoint => "SDL_Wrappers.ControlDOWNTOBasic"; }; 71 | BasicTOControl : OUT EVENT DATA PORT DataView::T_CONTROL_IN_Buffer.impl; 72 | END BASIC_APLC_Basic_FV; 73 | 74 | THREAD IMPLEMENTATION BASIC_APLC_Basic_FV.others 75 | PROPERTIES 76 | Initialize_Entrypoint => "SDL_Wrappers.SDL_Init_Basic_FV"; 77 | Dispatch_Protocol => Sporadic; 78 | Period => 1 ms; 79 | ARAO::Priority => 2; 80 | Source_Stack_Size => 100 KB; 81 | END BASIC_APLC_Basic_FV.others; 82 | 83 | --------------------------------------------------- 84 | -- VM-Level Container: CONTROL_APLC_Control_FV 85 | --------------------------------------------------- 86 | 87 | THREAD CONTROL_APLC_Control_FV 88 | FEATURES 89 | BasicTOControl : IN EVENT DATA PORT DataView::T_CONTROL_IN_Buffer.impl 90 | { Compute_Entrypoint => "SDL_Wrappers.BasicTOControl"; }; 91 | ControlUPTOBasic : OUT EVENT DATA PORT DataView::T_CONTROL_UP_OUT_Buffer.impl; 92 | ControlDOWNTOBasic : OUT EVENT DATA PORT DataView::T_CONTROL_DOWN_OUT_Buffer.impl; 93 | END CONTROL_APLC_Control_FV; 94 | 95 | THREAD IMPLEMENTATION CONTROL_APLC_Control_FV.others 96 | PROPERTIES 97 | Initialize_Entrypoint => "SDL_Wrappers.SDL_Init_Control_FV"; 98 | Dispatch_Protocol => Sporadic; 99 | Period => 1 ms; 100 | ARAO::Priority => 3; 101 | Source_Stack_Size => 100 KB; 102 | END CONTROL_APLC_Control_FV.others; 103 | 104 | --------------------------------------------------- 105 | 106 | --------------------------------------------------- 107 | 108 | SUBPROGRAM CyclicActivationImplementation 109 | END CyclicActivationImplementation; 110 | 111 | SUBPROGRAM IMPLEMENTATION CyclicActivationImplementation.SDL 112 | PROPERTIES 113 | Source_Language => SDL; 114 | assert_properties_extended::FV_Name => "Basic_FV"; 115 | END CyclicActivationImplementation.SDL; 116 | 117 | SUBPROGRAM ControlUPTOBasic 118 | FEATURES 119 | ControlUPTOBasic : IN PARAMETER DataView::T_CONTROL_UP_OUT; 120 | END ControlUPTOBasic; 121 | 122 | SUBPROGRAM IMPLEMENTATION ControlUPTOBasic.SDL 123 | PROPERTIES 124 | Source_Language => SDL; 125 | assert_properties_extended::FV_Name => "Basic_FV"; 126 | END ControlUPTOBasic.SDL; 127 | 128 | SUBPROGRAM ControlDOWNTOBasic 129 | FEATURES 130 | ControlDOWNTOBasic : IN PARAMETER DataView::T_CONTROL_DOWN_OUT; 131 | END ControlDOWNTOBasic; 132 | 133 | SUBPROGRAM IMPLEMENTATION ControlDOWNTOBasic.SDL 134 | PROPERTIES 135 | Source_Language => SDL; 136 | assert_properties_extended::FV_Name => "Basic_FV"; 137 | END ControlDOWNTOBasic.SDL; 138 | 139 | SUBPROGRAM BasicTOControl 140 | FEATURES 141 | BASICTOCONTROL : IN PARAMETER DataView::T_CONTROL_IN; 142 | END BasicTOControl; 143 | 144 | SUBPROGRAM IMPLEMENTATION BasicTOControl.SDL 145 | PROPERTIES 146 | Source_Language => SDL; 147 | assert_properties_extended::FV_Name => "Control_FV"; 148 | END BasicTOControl.SDL; 149 | 150 | SUBPROGRAM APLC_Basic_OP 151 | FEATURES 152 | THRUSTERS_OPENING : IN PARAMETER DataView::T_THRUSTERS_OPENING; 153 | PFS_IWM_ARMING_RELAY_STATUS_ON : IN PARAMETER DataView::T_PFS_IWM_ARMING_RELAY_STATUS_ON; 154 | PFS_HLTC_RED_BUTTON_IS_ON : IN PARAMETER DataView::T_PFS_HLTC_RED_BUTTON_IS_ON; 155 | MSU_ID : IN PARAMETER DataView::T_MSU_ID; 156 | PFS_EWM_MSUY_MSUX_HS : IN PARAMETER DataView::T_PFS_EWM_MSU_MSU_HS; 157 | FTCP_HEALTH_STATUS : IN PARAMETER DataView::T_FTCP_HEALTH_STATUS; 158 | PFS_EWM_DTG12_MSU : IN PARAMETER DataView::T_PFS_EWM_DTG12_MSU; 159 | HLTC : IN PARAMETER DataView::T_HLTC; 160 | END_BOOST_IS_REACHED : IN PARAMETER DataView::T_END_BOOST_IS_REACHED; 161 | SUN_IS_AIMED : IN PARAMETER DataView::T_SUN_IS_AIMED; 162 | PFS_EWC_MSU_PDE_T : OUT PARAMETER DataView::T_PFS_EWC_MSU_PDE_T; 163 | PDE_CMD_A : OUT PARAMETER DataView::T_PDE_CMD_A; 164 | DPU_CMD : OUT PARAMETER DataView::T_DPU_CMD; 165 | SET_PFS_EWC_MSU_DTG_MODE_COARSE : OUT PARAMETER DataView::T_ON_OFF_CMD; 166 | HLTM : OUT PARAMETER DataView::T_HLTM; 167 | PFS_EWM_MSUX_MSUY_HS : OUT PARAMETER DataView::T_PFS_EWM_MSU_MSU_HS; 168 | CAM_MODE : OUT PARAMETER DataView::T_CAM_MODE; 169 | CONTROLLER_TO_BE_ACTIVATED : OUT PARAMETER DataView::T_CONTROLLER_TO_BE_ACTIVATED; 170 | NAVIGATION_OUTPUT : OUT PARAMETER DataView::T_NAVIGATION_OUTPUT; 171 | END APLC_Basic_OP; 172 | 173 | SUBPROGRAM IMPLEMENTATION APLC_Basic_OP.SCADE6 174 | PROPERTIES 175 | Source_Language => SCADE6; 176 | assert_properties_extended::FV_Name => "Basic_op_FV"; 177 | END APLC_Basic_OP.SCADE6; 178 | 179 | SUBPROGRAM IF_Upstream 180 | FEATURES 181 | CAM_MODE : IN PARAMETER DataView::T_CAM_MODE; 182 | CONTROLLER_TO_BE_ACTIVATED : IN PARAMETER DataView::T_CONTROLLER_TO_BE_ACTIVATED; 183 | NAVIGATION_OUTPUT : IN PARAMETER DataView::T_NAVIGATION_OUTPUT; 184 | ESTIMATED_STATE : IN PARAMETER DataView::T_CONTROLLER_STATE; 185 | THRUSTERS_OPENING : OUT PARAMETER DataView::T_THRUSTERS_OPENING; 186 | END IF_Upstream; 187 | 188 | SUBPROGRAM IMPLEMENTATION IF_Upstream.SCADE6 189 | PROPERTIES 190 | Source_Language => SCADE6; 191 | assert_properties_extended::FV_Name => "IF_Upstream_FV"; 192 | END IF_Upstream.SCADE6; 193 | 194 | SUBPROGRAM IF_Downstream 195 | FEATURES 196 | THRUSTERS_OPENING : IN PARAMETER DataView::T_THRUSTERS_OPENING; 197 | CAM_MODE : IN PARAMETER DataView::T_CAM_MODE; 198 | CONTROLLER_TO_BE_ACTIVATED : IN PARAMETER DataView::T_CONTROLLER_TO_BE_ACTIVATED; 199 | NAVIGATION_OUTPUT : IN PARAMETER DataView::T_NAVIGATION_OUTPUT; 200 | END_BOOST_IS_REACHED : OUT PARAMETER DataView::T_END_BOOST_IS_REACHED; 201 | SUN_IS_AIMED : OUT PARAMETER DataView::T_SUN_IS_AIMED; 202 | ESTIMATED_STATE : OUT PARAMETER DataView::T_CONTROLLER_STATE; 203 | END IF_Downstream; 204 | 205 | SUBPROGRAM IMPLEMENTATION IF_Downstream.SCADE6 206 | PROPERTIES 207 | Source_Language => SCADE6; 208 | assert_properties_extended::FV_Name => "IF_Downstream_FV"; 209 | END IF_Downstream.SCADE6; 210 | 211 | SUBPROGRAM CyclicActivation 212 | END CyclicActivation; 213 | 214 | SUBPROGRAM IMPLEMENTATION CyclicActivation.SDL 215 | PROPERTIES 216 | Source_Language => SDL; 217 | assert_properties_extended::FV_Name => "Cyclic_FV"; 218 | END CyclicActivation.SDL; 219 | -------------------------------------------------------------------------------- /tests-coverage/DD_view.aadl: -------------------------------------------------------------------------------- 1 | --------------------------------------------------- 2 | --! File generated by asn2aadlPlus: DO NOT EDIT !-- 3 | --------------------------------------------------- 4 | 5 | package D_view 6 | 7 | public 8 | 9 | -- No more private heap required (we use the space certified compiler) 10 | -- Memory_Required: 0 11 | 12 | DATA TypeNested 13 | PROPERTIES 14 | -- name of the ASN.1 source file: 15 | Source_Text => ("Data_types_choice.asn"); 16 | Source_Language => ASN1; 17 | -- Size of a buffer to cover DER representation: 18 | -- Real message size is 196; suggested aligned message buffer is... 19 | Source_Data_Size => 200 B; 20 | -- name of the corresponding data type in the source file: 21 | Type_Source_Name => "TypeNested"; 22 | END TypeNested; 23 | 24 | -- ENST (Jerome) specific requests 25 | DATA TypeNested_Buffer 26 | END TypeNested_Buffer; 27 | 28 | DATA IMPLEMENTATION TypeNested_Buffer.impl 29 | -- Buffer to hold a marshalled data of type TypeNested 30 | SUBCOMPONENTS 31 | values : data ASSERT_Types::Stream_Element; 32 | PROPERTIES 33 | ARAO::Length => 200; -- Size of the buffer 34 | END TypeNested_Buffer.impl; 35 | 36 | DATA T_POS 37 | PROPERTIES 38 | -- name of the ASN.1 source file: 39 | Source_Text => ("Data_types_choice.asn"); 40 | Source_Language => ASN1; 41 | -- Size of a buffer to cover DER representation: 42 | -- Real message size is 3096; suggested aligned message buffer is... 43 | Source_Data_Size => 3096 B; 44 | -- name of the corresponding data type in the source file: 45 | Type_Source_Name => "T-POS"; 46 | END T_POS; 47 | 48 | -- ENST (Jerome) specific requests 49 | DATA T_POS_Buffer 50 | END T_POS_Buffer; 51 | 52 | DATA IMPLEMENTATION T_POS_Buffer.impl 53 | -- Buffer to hold a marshalled data of type T_POS 54 | SUBCOMPONENTS 55 | values : data ASSERT_Types::Stream_Element; 56 | PROPERTIES 57 | ARAO::Length => 3096; -- Size of the buffer 58 | END T_POS_Buffer.impl; 59 | 60 | DATA T_SETOF 61 | PROPERTIES 62 | -- name of the ASN.1 source file: 63 | Source_Text => ("Data_types_choice.asn"); 64 | Source_Language => ASN1; 65 | -- Size of a buffer to cover DER representation: 66 | -- Real message size is 28; suggested aligned message buffer is... 67 | Source_Data_Size => 32 B; 68 | -- name of the corresponding data type in the source file: 69 | Type_Source_Name => "T-SETOF"; 70 | END T_SETOF; 71 | 72 | -- ENST (Jerome) specific requests 73 | DATA T_SETOF_Buffer 74 | END T_SETOF_Buffer; 75 | 76 | DATA IMPLEMENTATION T_SETOF_Buffer.impl 77 | -- Buffer to hold a marshalled data of type T_SETOF 78 | SUBCOMPONENTS 79 | values : data ASSERT_Types::Stream_Element; 80 | PROPERTIES 81 | ARAO::Length => 32; -- Size of the buffer 82 | END T_SETOF_Buffer.impl; 83 | 84 | DATA T_INT 85 | PROPERTIES 86 | -- name of the ASN.1 source file: 87 | Source_Text => ("Data_types_choice.asn"); 88 | Source_Language => ASN1; 89 | -- Size of a buffer to cover DER representation: 90 | -- Real message size is 4; suggested aligned message buffer is... 91 | Source_Data_Size => 8 B; 92 | -- name of the corresponding data type in the source file: 93 | Type_Source_Name => "T-INT"; 94 | END T_INT; 95 | 96 | -- ENST (Jerome) specific requests 97 | DATA T_INT_Buffer 98 | END T_INT_Buffer; 99 | 100 | DATA IMPLEMENTATION T_INT_Buffer.impl 101 | -- Buffer to hold a marshalled data of type T_INT 102 | SUBCOMPONENTS 103 | values : data ASSERT_Types::Stream_Element; 104 | PROPERTIES 105 | ARAO::Length => 8; -- Size of the buffer 106 | END T_INT_Buffer.impl; 107 | 108 | DATA T_REAL 109 | PROPERTIES 110 | -- name of the ASN.1 source file: 111 | Source_Text => ("Data_types_choice.asn"); 112 | Source_Language => ASN1; 113 | -- Size of a buffer to cover DER representation: 114 | -- Real message size is 13; suggested aligned message buffer is... 115 | Source_Data_Size => 16 B; 116 | -- name of the corresponding data type in the source file: 117 | Type_Source_Name => "T-REAL"; 118 | END T_REAL; 119 | 120 | -- ENST (Jerome) specific requests 121 | DATA T_REAL_Buffer 122 | END T_REAL_Buffer; 123 | 124 | DATA IMPLEMENTATION T_REAL_Buffer.impl 125 | -- Buffer to hold a marshalled data of type T_REAL 126 | SUBCOMPONENTS 127 | values : data ASSERT_Types::Stream_Element; 128 | PROPERTIES 129 | ARAO::Length => 16; -- Size of the buffer 130 | END T_REAL_Buffer.impl; 131 | 132 | DATA TypeEnumerated 133 | PROPERTIES 134 | -- name of the ASN.1 source file: 135 | Source_Text => ("Data_types_choice.asn"); 136 | Source_Language => ASN1; 137 | -- Size of a buffer to cover DER representation: 138 | -- Real message size is 4; suggested aligned message buffer is... 139 | Source_Data_Size => 8 B; 140 | -- name of the corresponding data type in the source file: 141 | Type_Source_Name => "TypeEnumerated"; 142 | END TypeEnumerated; 143 | 144 | -- ENST (Jerome) specific requests 145 | DATA TypeEnumerated_Buffer 146 | END TypeEnumerated_Buffer; 147 | 148 | DATA IMPLEMENTATION TypeEnumerated_Buffer.impl 149 | -- Buffer to hold a marshalled data of type TypeEnumerated 150 | SUBCOMPONENTS 151 | values : data ASSERT_Types::Stream_Element; 152 | PROPERTIES 153 | ARAO::Length => 8; -- Size of the buffer 154 | END TypeEnumerated_Buffer.impl; 155 | 156 | DATA T_STRING 157 | PROPERTIES 158 | -- name of the ASN.1 source file: 159 | Source_Text => ("Data_types_choice.asn"); 160 | Source_Language => ASN1; 161 | -- Size of a buffer to cover DER representation: 162 | -- Real message size is 20; suggested aligned message buffer is... 163 | Source_Data_Size => 24 B; 164 | -- name of the corresponding data type in the source file: 165 | Type_Source_Name => "T-STRING"; 166 | END T_STRING; 167 | 168 | -- ENST (Jerome) specific requests 169 | DATA T_STRING_Buffer 170 | END T_STRING_Buffer; 171 | 172 | DATA IMPLEMENTATION T_STRING_Buffer.impl 173 | -- Buffer to hold a marshalled data of type T_STRING 174 | SUBCOMPONENTS 175 | values : data ASSERT_Types::Stream_Element; 176 | PROPERTIES 177 | ARAO::Length => 24; -- Size of the buffer 178 | END T_STRING_Buffer.impl; 179 | 180 | DATA T_ARR 181 | PROPERTIES 182 | -- name of the ASN.1 source file: 183 | Source_Text => ("Data_types_choice.asn"); 184 | Source_Language => ASN1; 185 | -- Size of a buffer to cover DER representation: 186 | -- Real message size is 28; suggested aligned message buffer is... 187 | Source_Data_Size => 32 B; 188 | -- name of the corresponding data type in the source file: 189 | Type_Source_Name => "T-ARR"; 190 | END T_ARR; 191 | 192 | -- ENST (Jerome) specific requests 193 | DATA T_ARR_Buffer 194 | END T_ARR_Buffer; 195 | 196 | DATA IMPLEMENTATION T_ARR_Buffer.impl 197 | -- Buffer to hold a marshalled data of type T_ARR 198 | SUBCOMPONENTS 199 | values : data ASSERT_Types::Stream_Element; 200 | PROPERTIES 201 | ARAO::Length => 32; -- Size of the buffer 202 | END T_ARR_Buffer.impl; 203 | 204 | DATA T_BOOL 205 | PROPERTIES 206 | -- name of the ASN.1 source file: 207 | Source_Text => ("Data_types_choice.asn"); 208 | Source_Language => ASN1; 209 | -- Size of a buffer to cover DER representation: 210 | -- Real message size is 4; suggested aligned message buffer is... 211 | Source_Data_Size => 8 B; 212 | -- name of the corresponding data type in the source file: 213 | Type_Source_Name => "T-BOOL"; 214 | END T_BOOL; 215 | 216 | -- ENST (Jerome) specific requests 217 | DATA T_BOOL_Buffer 218 | END T_BOOL_Buffer; 219 | 220 | DATA IMPLEMENTATION T_BOOL_Buffer.impl 221 | -- Buffer to hold a marshalled data of type T_BOOL 222 | SUBCOMPONENTS 223 | values : data ASSERT_Types::Stream_Element; 224 | PROPERTIES 225 | ARAO::Length => 8; -- Size of the buffer 226 | END T_BOOL_Buffer.impl; 227 | 228 | DATA T_SET 229 | PROPERTIES 230 | -- name of the ASN.1 source file: 231 | Source_Text => ("Data_types_choice.asn"); 232 | Source_Language => ASN1; 233 | -- Size of a buffer to cover DER representation: 234 | -- Real message size is 14; suggested aligned message buffer is... 235 | Source_Data_Size => 16 B; 236 | -- name of the corresponding data type in the source file: 237 | Type_Source_Name => "T-SET"; 238 | END T_SET; 239 | 240 | -- ENST (Jerome) specific requests 241 | DATA T_SET_Buffer 242 | END T_SET_Buffer; 243 | 244 | DATA IMPLEMENTATION T_SET_Buffer.impl 245 | -- Buffer to hold a marshalled data of type T_SET 246 | SUBCOMPONENTS 247 | values : data ASSERT_Types::Stream_Element; 248 | PROPERTIES 249 | ARAO::Length => 16; -- Size of the buffer 250 | END T_SET_Buffer.impl; 251 | 252 | end D_view; 253 | -------------------------------------------------------------------------------- /tests-coverage/D_view.asn: -------------------------------------------------------------------------------- 1 | MY-MODULE DEFINITIONS ::= BEGIN 2 | 3 | -- Original definition by Alain 4 | --T-POS ::= BOOLEAN 5 | 6 | TypeEnumerated ::= ENUMERATED { 7 | red(0), 8 | green(1), 9 | blue(2) 10 | } 11 | 12 | TypeNested ::= SEQUENCE { 13 | intVal INTEGER(0..10), 14 | intArray SEQUENCE (SIZE (10)) OF INTEGER (0..3), 15 | boolArray SEQUENCE (SIZE (10)) OF T-BOOL, 16 | enumValue TypeEnumerated, 17 | label OCTET STRING (SIZE(10..40)), 18 | bAlpha T-BOOL, 19 | bBeta BOOLEAN, 20 | sString T-STRING, 21 | arr T-ARR 22 | } 23 | 24 | -- A more realistic definition 25 | T-POS2 ::= BOOLEAN 26 | 27 | T-POS ::= SEQUENCE { 28 | longitude REAL(-180.0..180.0), 29 | latitude REAL(-90.0..90.0), 30 | height REAL(30000.0..45000.0), 31 | subTypeArray SEQUENCE (SIZE(10..15)) OF TypeNested 32 | } 33 | 34 | T-ARR ::= SEQUENCE (SIZE (5..6)) OF INTEGER (0..4) 35 | 36 | T-BOOL ::= BOOLEAN 37 | T-INT ::= INTEGER (0..50) 38 | T-REAL ::= REAL (-3.14..3.14) 39 | T-STRING ::= OCTET STRING (SIZE(10..15)) 40 | 41 | END 42 | -------------------------------------------------------------------------------- /tests-coverage/DataTypesSimulink.asn: -------------------------------------------------------------------------------- 1 | MY-MODULE DEFINITIONS AUTOMATIC TAGS ::= BEGIN 2 | 3 | -- Original definition by Alain 4 | --T-POS ::= BOOLEAN 5 | 6 | MyInt ::= INTEGER (0 .. 20) 7 | 8 | My2ndInt ::= MyInt ( 1 .. 18) 9 | 10 | AType ::= SEQUENCE { 11 | blArray SEQUENCE (SIZE(10)) OF BOOLEAN 12 | } 13 | 14 | My2ndAType ::= AType 15 | 16 | TypeEnumerated ::= ENUMERATED { 17 | red(0), 18 | green(1), 19 | blue(2) 20 | } 21 | 22 | My2ndEnumerated ::= TypeEnumerated 23 | 24 | TypeNested ::= SEQUENCE { 25 | intVal INTEGER(0..10), 26 | int2Val INTEGER(-10..10), 27 | int3Val MyInt (10..12), 28 | intArray SEQUENCE (SIZE (10)) OF INTEGER (0..3), 29 | realArray SEQUENCE (SIZE (10)) OF REAL (0.1 .. 3.14), 30 | octStrArray SEQUENCE (SIZE (10)) OF OCTET STRING (SIZE(1..10)), 31 | boolArray SEQUENCE (SIZE (10)) OF T-BOOL, 32 | enumArray SEQUENCE (SIZE (10)) OF TypeEnumerated, 33 | enumValue TypeEnumerated, 34 | enumValue2 ENUMERATED { 35 | truism(0), 36 | falsism(1) 37 | }, 38 | label OCTET STRING (SIZE(10..40)), 39 | bAlpha T-BOOL, 40 | bBeta BOOLEAN, 41 | sString T-STRING, 42 | arr T-ARR, 43 | arr2 T-ARR2 44 | } 45 | 46 | My2ndTypeNested ::= TypeNested 47 | 48 | -- A more realistic definition 49 | T-POS ::= CHOICE { 50 | longitude REAL(-180.0..180.0), 51 | latitude REAL(-90.0..90.0), 52 | height REAL(30000.0..45000.0), 53 | subTypeArray SEQUENCE (SIZE(10..15)) OF TypeNested, 54 | label OCTET STRING (SIZE(50)), 55 | intArray T-ARR, 56 | myIntSet T-SET, 57 | myIntSetOf T-SETOF, 58 | anInt My2ndInt 59 | } 60 | 61 | T-POS-SET ::= SET { 62 | longitude REAL(-180.0..180.0), 63 | latitude REAL(-90.0..90.0), 64 | height REAL(30000.0..45000.0), 65 | subTypeArray SEQUENCE (SIZE(10..15)) OF TypeNested, 66 | label OCTET STRING (SIZE(20..50)), 67 | intArray T-ARR, 68 | myIntSet T-SET, 69 | myIntSetOf T-SETOF 70 | 71 | } 72 | 73 | T-ARR ::= SEQUENCE (SIZE (5..6)) OF INTEGER (0..32764) 74 | 75 | My2ndArr ::= T-ARR 76 | 77 | T-ARR2 ::= SEQUENCE (SIZE (5..6)) OF REAL (0.1 .. 4.2) 78 | 79 | T-ARR3 ::= SEQUENCE (SIZE (5..6)) OF SEQUENCE (SIZE(7)) OF REAL (0.1 .. 4.2) 80 | 81 | T-ARR4 ::= SEQUENCE (SIZE (5..6)) OF SEQUENCE (SIZE(7)) OF REAL (0.1 .. 4.3) 82 | 83 | T-SET ::= SET { 84 | data1 INTEGER(0..131071), 85 | data2 REAL(-100.0 .. 10.0), 86 | data3 INTEGER(-1024..1024), 87 | data4 INTEGER(-1310720..131071) 88 | } 89 | 90 | T-SETOF ::= SET (SIZE (5..6)) OF INTEGER (0..4) 91 | 92 | T-BOOL ::= BOOLEAN 93 | 94 | My2ndBool ::= T-BOOL 95 | 96 | T-INT ::= INTEGER (0..50) 97 | T-REAL ::= REAL (-3.14..3.14) 98 | My2ndReal ::= T-REAL 99 | T-STRING ::= OCTET STRING (SIZE(10..15)) 100 | My2ndString ::= T-STRING 101 | T-FIXEDSTRING ::= OCTET STRING (SIZE(15)) 102 | 103 | T-META ::= T-POS 104 | 105 | myVar MyInt ::= 4 106 | 107 | ConfigString ::= IA5String (SIZE(1..20)) 108 | myStrVar ConfigString ::= "This is a test" 109 | 110 | FixedLenConfigString ::= IA5String (SIZE (5)) 111 | myStrFixed FixedLenConfigString ::= "Hello" 112 | 113 | T-TypeThatMustNotBeMappedExceptInPython ::= SEQUENCE { 114 | config ConfigString, 115 | param INTEGER (0..10), 116 | fixstr FixedLenConfigString DEFAULT "Hello" 117 | } 118 | E ::= INTEGER (0..255|1299)(5) 119 | TypeWithOptional ::= SEQUENCE { 120 | a BOOLEAN OPTIONAL, 121 | b INTEGER (0..255|1299), 122 | c INTEGER (0..255), 123 | d T-TypeThatMustNotBeMappedExceptInPython DEFAULT {config "Config", param 5, fixstr "World"} 124 | } 125 | 126 | push-it T-TypeThatMustNotBeMappedExceptInPython ::= {config "Config", param 5, fixstr "World"} 127 | 128 | SubTypeWithOptional ::= TypeWithOptional (WITH COMPONENTS {a ABSENT, c (42), b (1299)}) 129 | 130 | SuperChoice ::= CHOICE { 131 | first-choice BOOLEAN, 132 | second-choice INTEGER (0..255), 133 | third-choice TypeWithOptional 134 | } 135 | 136 | -- Choice items can be removed in subtypes 137 | SuperRestrictedChoice ::= SuperChoice (WITH COMPONENTS {second-choice ABSENT}) 138 | 139 | 140 | END 141 | -------------------------------------------------------------------------------- /tests-coverage/DataTypesSimulinkVHDL.asn: -------------------------------------------------------------------------------- 1 | MY-MODULE DEFINITIONS AUTOMATIC TAGS ::= BEGIN 2 | 3 | -- Original definition by Alain 4 | --T-POS ::= BOOLEAN 5 | 6 | MyInt ::= INTEGER (0 .. 20) 7 | 8 | My2ndInt ::= MyInt ( 1 .. 18) 9 | 10 | AType ::= SEQUENCE { 11 | blArray SEQUENCE (SIZE(10)) OF BOOLEAN 12 | } 13 | 14 | TypeEnumerated ::= ENUMERATED { 15 | red(0), 16 | green(1), 17 | blue(2) 18 | } 19 | 20 | TypeNested ::= SEQUENCE { 21 | intVal INTEGER(0..10), 22 | int2Val INTEGER(-10..10), 23 | int3Val MyInt (10..12), 24 | intArray SEQUENCE (SIZE (10)) OF INTEGER (0..3), 25 | octStrArray SEQUENCE (SIZE (10)) OF OCTET STRING (SIZE(10..10)), 26 | octStrAray2 SEQUENCE (SIZE (10)) OF OCTET STRING (SIZE(11)), 27 | boolArray SEQUENCE (SIZE (10)) OF T-BOOL, 28 | enumArray SEQUENCE (SIZE (10)) OF TypeEnumerated, 29 | enumValue TypeEnumerated, 30 | enumValue2 ENUMERATED { 31 | truism(0), 32 | falsism(1) 33 | }, 34 | label OCTET STRING (SIZE(40)), 35 | bAlpha T-BOOL, 36 | bBeta BOOLEAN, 37 | arr T-ARR 38 | } 39 | 40 | T-POS ::= CHOICE { 41 | longitude INTEGER(-180..180), 42 | latitude INTEGER(-90..90), 43 | height INTEGER(30000..45000), 44 | subTypeArray SEQUENCE (SIZE(15)) OF TypeNested, 45 | label OCTET STRING (SIZE(50)), 46 | intArray T-ARR, 47 | myIntSet T-SET, 48 | myIntSetOf T-SETOF, 49 | anInt My2ndInt 50 | } 51 | 52 | T-POS-SET ::= SET { 53 | longitude INTEGER(-180..180), 54 | latitude INTEGER(-90..90), 55 | height INTEGER(30000..45000), 56 | subTypeArray SEQUENCE (SIZE(15)) OF TypeNested, 57 | label OCTET STRING (SIZE(50)), 58 | intArray T-ARR, 59 | myIntSet T-SET, 60 | myIntSetOf T-SETOF 61 | 62 | } 63 | 64 | T-ARR ::= SEQUENCE (SIZE (6)) OF INTEGER (0..32764) 65 | 66 | T-ARR3 ::= SEQUENCE (SIZE (6)) OF SEQUENCE (SIZE(7)) OF INTEGER (0 .. 20) 67 | 68 | T-ARR4 ::= SEQUENCE (SIZE (6)) OF SEQUENCE (SIZE(7)) OF INTEGER (0 .. 23) 69 | 70 | T-SET ::= SET { 71 | data1 INTEGER(0..131071), 72 | data3 INTEGER(-1024..1024), 73 | data4 INTEGER(-1310720..131071) 74 | } 75 | 76 | T-SETOF ::= SET (SIZE (6)) OF INTEGER (0..4) 77 | 78 | T-BOOL ::= BOOLEAN 79 | T-INT ::= INTEGER (0..50) 80 | T-STRING ::= OCTET STRING (SIZE(15)) 81 | T-FIXEDSTRING ::= OCTET STRING (SIZE(15)) 82 | 83 | T-META ::= T-POS 84 | 85 | END 86 | -------------------------------------------------------------------------------- /tests-coverage/DataView.pr: -------------------------------------------------------------------------------- 1 | Datamodel DEFINITIONS ::= BEGIN 2 | 3 | AType ::= SEQUENCE { 4 | blArray SEQUENCE (SIZE (10 .. 10)) OF BOOLEAN 5 | } 6 | 7 | TypeEnumerated ::= ENUMERATED { 8 | red(0), 9 | green(1), 10 | blue(2) 11 | } 12 | 13 | TypeNested ::= SEQUENCE { 14 | intVal INTEGER (0 .. 10), 15 | int2Val INTEGER (-10 .. 10), 16 | intArray SEQUENCE (SIZE (10 .. 10)) OF INTEGER (0 .. 3), 17 | realArray SEQUENCE (SIZE (10 .. 10)) OF REAL (0.1 .. 3.14), 18 | octStrArray SEQUENCE (SIZE (10 .. 10)) OF OCTET STRING (SIZE (1 .. 10)), 19 | boolArray SEQUENCE (SIZE (10 .. 10)) OF T_BOOL, 20 | enumArray SEQUENCE (SIZE (10 .. 10)) OF TypeEnumerated, 21 | enumValue TypeEnumerated, 22 | enumValue2 ENUMERATED { 23 | truism(0), 24 | falsism(1) 25 | }, 26 | label OCTET STRING (SIZE (10 .. 40)), 27 | bAlpha T_BOOL, 28 | bBeta BOOLEAN, 29 | sString T_STRING, 30 | arr T_ARR, 31 | arr2 T_ARR2 32 | } 33 | 34 | T_POS ::= CHOICE { 35 | longitude REAL (-180 .. 180), 36 | latitude REAL (-90 .. 90), 37 | height REAL (30000 .. 45000), 38 | subTypeArray SEQUENCE (SIZE (10 .. 15)) OF TypeNested, 39 | label OCTET STRING (SIZE (50 .. 50)), 40 | intArray T_ARR, 41 | myIntSet T_SET, 42 | myIntSetOf T_SETOF 43 | } 44 | 45 | T_POS_SET ::= SET { 46 | longitude REAL (-180 .. 180), 47 | latitude REAL (-90 .. 90), 48 | height REAL (30000 .. 45000), 49 | subTypeArray SEQUENCE (SIZE (10 .. 15)) OF TypeNested, 50 | label OCTET STRING (SIZE (20 .. 50)), 51 | intArray T_ARR, 52 | myIntSet T_SET, 53 | myIntSetOf T_SETOF 54 | } 55 | 56 | T_ARR ::= SEQUENCE (SIZE (5 .. 6)) OF INTEGER (0 .. 32764) 57 | 58 | T_ARR2 ::= SEQUENCE (SIZE (5 .. 6)) OF REAL (0.1 .. 4.2) 59 | 60 | T_ARR3 ::= SEQUENCE (SIZE (5 .. 6)) OF SEQUENCE (SIZE (7 .. 7)) OF REAL (0.1 .. 4.2) 61 | 62 | T_ARR4 ::= SEQUENCE (SIZE (5 .. 6)) OF SEQUENCE (SIZE (7 .. 7)) OF REAL (0.1 .. 4.3) 63 | 64 | T_SET ::= SET { 65 | data1 INTEGER (0 .. 131071), 66 | data2 REAL (-100 .. 10), 67 | data3 INTEGER (-1024 .. 1024), 68 | data4 INTEGER (-1310720 .. 131071) 69 | } 70 | 71 | T_SETOF ::= SET (SIZE (5 .. 6)) OF INTEGER (0 .. 4) 72 | 73 | T_BOOL ::= BOOLEAN 74 | 75 | T_INT ::= INTEGER (0 .. 50) 76 | 77 | T_REAL ::= REAL (-3.14 .. 3.14) 78 | 79 | T_STRING ::= OCTET STRING (SIZE (10 .. 15)) 80 | 81 | T_FIXEDSTRING ::= OCTET STRING (SIZE (15 .. 15)) 82 | 83 | T_META ::= T_POS 84 | 85 | END 86 | -------------------------------------------------------------------------------- /tests-coverage/Data_types.asn: -------------------------------------------------------------------------------- 1 | MY-MODULE DEFINITIONS ::= BEGIN 2 | 3 | -- Original definition by Alain 4 | --T-POS ::= BOOLEAN 5 | 6 | TypeEnumerated ::= ENUMERATED { 7 | red(0), 8 | green(1), 9 | blue(2) 10 | } 11 | 12 | TypeNested ::= SEQUENCE { 13 | intVal INTEGER(0..10), 14 | intArray SEQUENCE (SIZE (10)) OF INTEGER (0..3), 15 | boolArray SEQUENCE (SIZE (10)) OF T-BOOL, 16 | enumValue TypeEnumerated, 17 | label OCTET STRING (SIZE(10..40)), 18 | bAlpha T-BOOL, 19 | bBeta BOOLEAN, 20 | sString T-STRING, 21 | arr T-ARR 22 | } 23 | 24 | -- A more realistic definition 25 | T-POS ::= SEQUENCE { 26 | longitude REAL(-180.0..180.0), 27 | latitude REAL(-90.0..90.0), 28 | height REAL(30000.0..45000.0), 29 | subTypeArray SEQUENCE (SIZE(10..15)) OF TypeNested, 30 | label OCTET STRING (SIZE(20..50)), 31 | intArray T-ARR 32 | 33 | } 34 | 35 | T-ARR ::= SEQUENCE (SIZE (5..6)) OF INTEGER (0..4) 36 | 37 | T-BOOL ::= BOOLEAN 38 | T-INT ::= INTEGER (0..50) 39 | T-REAL ::= REAL (-3.14..3.14) 40 | T-STRING ::= OCTET STRING (SIZE(10..15)) 41 | 42 | END 43 | -------------------------------------------------------------------------------- /tests-coverage/Data_types_choice.asn: -------------------------------------------------------------------------------- 1 | MY-MODULE DEFINITIONS AUTOMATIC TAGS ::= BEGIN 2 | 3 | -- Original definition by Alain 4 | --T-POS ::= BOOLEAN 5 | 6 | TypeEnumerated ::= ENUMERATED { 7 | red(0), 8 | green(1), 9 | blue(2) 10 | } 11 | 12 | TypeNested ::= SEQUENCE { 13 | intVal INTEGER(0..10), 14 | intArray SEQUENCE (SIZE (10)) OF INTEGER (0..3), 15 | boolArray SEQUENCE (SIZE (10)) OF T-BOOL, 16 | enumValue TypeEnumerated, 17 | label OCTET STRING (SIZE(10..40)), 18 | bAlpha T-BOOL, 19 | bBeta BOOLEAN, 20 | sString T-STRING, 21 | arr T-ARR 22 | } 23 | 24 | -- A more realistic definition 25 | T-POS ::= CHOICE { 26 | longitude REAL(-180.0..180.0), 27 | latitude REAL(-90.0..90.0), 28 | height REAL(30000.0..45000.0), 29 | subTypeArray SEQUENCE (SIZE(10..15)) OF TypeNested, 30 | label OCTET STRING (SIZE(20..50)), 31 | intArray T-ARR, 32 | myIntSet T-SET, 33 | myIntSetOf T-SETOF 34 | 35 | } 36 | 37 | T-ARR ::= SEQUENCE (SIZE (5..6)) OF INTEGER (0..4) 38 | 39 | T-SET ::= SET { 40 | data1 INTEGER(0..10), 41 | data2 REAL(-100.0 .. 10.0) 42 | } 43 | 44 | T-SETOF ::= SET (SIZE (5..6)) OF INTEGER (0..4) 45 | 46 | T-BOOL ::= BOOLEAN 47 | T-INT ::= INTEGER (0..50) 48 | T-REAL ::= REAL (-3.14..3.14) 49 | T-STRING ::= OCTET STRING (SIZE(10..15)) 50 | 51 | END 52 | -------------------------------------------------------------------------------- /tests-coverage/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: M2M M2C clean 2 | 3 | all: M2M M2C 4 | 5 | M2M: 6 | $(MAKE) -f Makefile.M2M clean 7 | $(MAKE) -f Makefile.M2M 8 | 9 | M2C: 10 | $(MAKE) -f Makefile.M2C clean 11 | $(MAKE) -f Makefile.M2C 12 | 13 | SMP2: 14 | $(MAKE) -f Makefile.SMP2 clean 15 | $(MAKE) -f Makefile.SMP2 16 | 17 | clean: 18 | $(MAKE) -f Makefile.M2M clean 19 | $(MAKE) -f Makefile.M2C clean 20 | $(MAKE) -f Makefile.SMP2 clean 21 | -------------------------------------------------------------------------------- /tests-coverage/Makefile.M2C: -------------------------------------------------------------------------------- 1 | include common.mk 2 | 3 | VPATH=..:../dmt/B_mappers:../dmt/commonPy 4 | 5 | PYSRC_B := asynchronousTool.py ada_B_mapper.py c_B_mapper.py og_B_mapper.py simulink_B_mapper.py scade6_B_mapper.py pyside_B_mapper.py # vhdl_B_mapper.py 6 | PYSRC_B_COVER := $(PYSRC_B:%.py=___dmt_B_mappers_%.py,cover) 7 | 8 | # Python3.5 includes an older version of typing, which by default has priority over 9 | # the one installed in $HOME/.local via setup.py. 10 | # 11 | # To address this, we find where our pip-installed typing lives: 12 | TYPING_FOLDER:=$(shell pip3 show typing 2>/dev/null | grep ^Location | sed 's,^.*: ,,') 13 | export PYTHONPATH:=..:${TYPING_FOLDER} 14 | 15 | .PHONY: check 16 | 17 | all: $(PYSRC_B_COVER) check 18 | 19 | DataView.aadl: DataTypesSimulink.asn 20 | PYTHONPATH=.. python3 -m dmt.asn2aadlPlus $< $@ 21 | 22 | DataViewVHDL.aadl: DataTypesSimulinkVHDL.asn 23 | PYTHONPATH=.. python3 -m dmt.asn2aadlPlus $< $@ 24 | 25 | ___dmt_B_mappers_%.py,cover: ../dmt/B_mappers/%.py mini_cv.aadl DataView.aadl DataViewVHDL.aadl 26 | @echo Update required: $@ depends on $? 27 | $(MAKE) -f Makefile.M2C clean 28 | mkdir -p output 29 | rm -rf output/* 30 | # LANG=C LC_ALL=C python3 -m coverage run -a -m dmt.aadl2glueC -o output -verbose mini_cv_vhdl.aadl DataViewVHDL.aadl >/dev/null 31 | LANG=C LC_ALL=C python3 -m coverage run -a -m dmt.aadl2glueC -o output -verbose mini_cv.aadl DataView.aadl >/dev/null 32 | LANG=C LC_ALL=C python3 -m coverage run -a -m dmt.aadl2glueC -o output -verbose -useOSS mini_cv.aadl DataView.aadl >/dev/null 33 | LANG=C LC_ALL=C python3 -m coverage annotate -d . ../dmt/aadl2glueC.py ../dmt/B_mappers/*.py ../dmt/commonPy/*.py 34 | 35 | check: 36 | ifneq ($(CIRCLECI),) 37 | @for i in $(PYSRC_B_COVER) ; do echo Checking $$i ... ; ./checkCoverage.pl $$i || { echo $$i failed... ; cp $$i ${CIRCLE_ARTIFACTS} ; exit 1 ; } ; done 38 | else 39 | @for i in $(PYSRC_B_COVER) ; do echo Checking $$i ... ; ./checkCoverage.pl $$i || { ( echo $$i ; ./review.pl $$i ) | less -RS ; echo $$i had issues... ; exit 1 ; } ; done 40 | endif 41 | 42 | clean: 43 | ${COVERAGE} erase 44 | rm -f ./___*,cover 45 | rm -rf output/ 46 | -------------------------------------------------------------------------------- /tests-coverage/Makefile.M2M: -------------------------------------------------------------------------------- 1 | include common.mk 2 | 3 | VPATH=..:../dmt/A_mappers:../dmt/commonPy 4 | 5 | PYSRC_A := ada_A_mapper.py c_A_mapper.py og_A_mapper.py simulink_A_mapper.py python_A_mapper.py scade6_A_mapper.py smp2_A_mapper.py sqlalchemy_A_mapper.py rtds_A_mapper.py qgenada_A_mapper.py qgenc_A_mapper.py 6 | PYSRC_A_COVER := $(PYSRC_A:%.py=___dmt_A_mappers_%.py,cover) 7 | 8 | # Python3.5 includes an older version of typing, which by default has priority over 9 | # the one installed in $HOME/.local via setup.py. 10 | # 11 | # To address this, we find where our pip-installed typing lives: 12 | TYPING_FOLDER:=$(shell pip3 show typing 2>/dev/null | grep ^Location | sed 's,^.*: ,,') 13 | export PYTHONPATH:=..:${TYPING_FOLDER} 14 | 15 | .PHONY: check 16 | 17 | all: $(PYSRC_A_COVER) check 18 | 19 | ___dmt_A_mappers_%.py,cover: ../A_mappers/%.py DataTypesSimulink.asn 20 | @echo Update required: $@ depends on $? 21 | mkdir -p output 22 | rm -rf output/* 23 | LANG=C LC_ALL=C python3 -m coverage run -a -m dmt.asn2dataModel 2>/dev/null || echo -n 24 | LANG=C LC_ALL=C python3 -m coverage run -a -m dmt.asn2dataModel -o output 2>/dev/null || echo -n 25 | LANG=C LC_ALL=C python3 -m coverage run -a -m dmt.asn2dataModel -o output -toRTDS DataTypesSimulink.asn >/dev/null 26 | LANG=C LC_ALL=C python3 -m coverage run -a -m dmt.asn2dataModel -o output -toQGenAda DataTypesSimulink.asn >/dev/null 27 | LANG=C LC_ALL=C python3 -m coverage run -a -m dmt.asn2dataModel -o output -toQGenC DataTypesSimulink.asn >/dev/null 28 | LANG=C LC_ALL=C python3 -m coverage run -a -m dmt.asn2dataModel -o output -verbose -toSIMULINK DataTypesSimulink.asn >/dev/null 29 | LANG=C LC_ALL=C python3 -m coverage run -a -m dmt.asn2dataModel -o output -toOG DataTypesSimulink.asn 30 | LANG=C LC_ALL=C python3 -m coverage run -a -m dmt.asn2dataModel -o output -toAda DataTypesSimulink.asn 31 | LANG=C LC_ALL=C python3 -m coverage run -a -m dmt.asn2dataModel -o output -toC DataTypesSimulink.asn >/dev/null 32 | LANG=C LC_ALL=C python3 -m coverage run -a -m dmt.asn2dataModel -o output -toSMP2 DataTypesSimulink.asn >/dev/null 33 | LANG=C LC_ALL=C python3 -m coverage run -a -m dmt.asn2dataModel -o output -toPython DataTypesSimulink.asn >/dev/null 34 | LANG=C LC_ALL=C python3 -m coverage run -a -m dmt.asn2dataModel -o output -toSCADE6 DataTypesSimulink.asn >/dev/null 35 | LANG=C LC_ALL=C python3 -m coverage run -a -m dmt.asn2dataModel -o output -toSQL DataTypesSimulink.asn >/dev/null 36 | LANG=C LC_ALL=C python3 -m coverage run -a -m dmt.asn2dataModel -o output -toSqlalchemy DataTypesSimulink.asn >/dev/null 37 | LANG=C LC_ALL=C python3 -m coverage annotate -d . ../dmt/asn2dataModel.py ../dmt/A_mappers/*.py ../dmt/commonPy/*.py 38 | 39 | check: 40 | ifneq ($(CIRCLECI),) 41 | @for i in ___dmt_commonPy_createInternalTypes.py,cover ___dmt_asn2dataModel.py,cover $(PYSRC_A_COVER) ; do echo Checking $$i ... ; ./checkCoverage.pl $$i || { echo $$i failed... ; cp $$i ${CIRCLE_ARTIFACTS} ; exit 1 ; } ; done 42 | else 43 | @for i in ___dmt_commonPy_createInternalTypes.py,cover ___dmt_asn2dataModel.py,cover $(PYSRC_A_COVER) ; do echo Checking $$i ... ; ./checkCoverage.pl $$i || { ( echo $$i ; ./review.pl $$i ) | less -RS ; exit 1 ; } ; done 44 | endif 45 | 46 | clean: 47 | ${COVERAGE} erase 48 | rm -f ./___*,cover 49 | -------------------------------------------------------------------------------- /tests-coverage/Makefile.SMP2: -------------------------------------------------------------------------------- 1 | include common.mk 2 | 3 | # Python3.5 includes an older version of typing, which by default has priority over 4 | # the one installed in $HOME/.local via setup.py. 5 | # 6 | # To address this, we find where our pip-installed typing lives: 7 | TYPING_FOLDER:=$(shell pip3 show typing 2>/dev/null | grep ^Location | sed 's,^.*: ,,') 8 | export PYTHONPATH:=..:${TYPING_FOLDER} 9 | 10 | all: 11 | make clean 12 | LANG=C LC_ALL=C python3 -m coverage run -a -m dmt.asn2dataModel -o . -toSMP2 DataTypesSimulink.asn >/dev/null 13 | LANG=C LC_ALL=C python3 -m coverage run -a -m dmt.smp2asn >/dev/null 2>&1 ; exit 0 14 | LANG=C LC_ALL=C python3 -m coverage run -a -m dmt.smp2asn -h >/dev/null 2>&1 ; exit 0 15 | LANG=C LC_ALL=C python3 -m coverage run -a -m dmt.smp2asn -z >/dev/null 2>&1 ; exit 0 16 | LANG=C LC_ALL=C python3 -m coverage run -a -m dmt.smp2asn -o smp2.asn -a nonexisting.asn nonexisting.cat >/dev/null 2>&1 ; exit 0 17 | LANG=C LC_ALL=C python3 -m coverage run -a -m dmt.smp2asn -o smp2.asn -a DataTypesSimulink.asn -v -p datatypessimulink.cat >/dev/null 2>&1 || exit 1 18 | LANG=C LC_ALL=C ${COVERAGE} annotate -d . ../dmt/smp2asn.py ../dmt/commonPy/*.py || exit 1 19 | ifneq ($(CIRCLECI),) 20 | ./checkCoverage.pl ___dmt_smp2asn.py,cover || { echo smp2asn.py failed... ; cp __dmt_smp2asn.py,cover ${CIRCLE_ARTIFACTS} ; exit 1 ; } 21 | else 22 | ./checkCoverage.pl ___dmt_smp2asn.py,cover || { echo smp2asn.py ; ./review.pl ___dmt_smp2asn.py,cover | less -RS ; exit 1 ; } 23 | endif 24 | # ./checkCoverage.pl ___dmt_commonPy_commonSMP2.py,cover || { echo commonSMP2.py ; ./review.pl ___dmt_commonPy_commonSMP2.py,cover | less -RS ; exit 1 ; } 25 | 26 | clean: 27 | ${COVERAGE} erase 28 | rm -f ___*.py,cover smp2.asn datatypessimulink.cat 29 | -------------------------------------------------------------------------------- /tests-coverage/NoenumInt.aadl: -------------------------------------------------------------------------------- 1 | package Data_types 2 | 3 | public 4 | 5 | -- Memory required to encode/decode these messages (aligned to page size: 4096) 6 | -- Memory_Required: 12288 7 | 8 | DATA TypeNested 9 | PROPERTIES 10 | -- name of the ASN.1 source file: 11 | Source_Text => ("NoenumInt.asn"); 12 | -- Size of a buffer to cover DER representation: 13 | -- Real message size is 82; suggested aligned message buffer is... 14 | Source_Data_Size => 128 B; 15 | -- name of the corresponding data type in the source file: 16 | Type_Source_Name => "TypeNested"; 17 | END TypeNested; 18 | 19 | DATA T_POS 20 | PROPERTIES 21 | -- name of the ASN.1 source file: 22 | Source_Text => ("NoenumInt.asn"); 23 | -- Size of a buffer to cover DER representation: 24 | -- Real message size is 1256; suggested aligned message buffer is... 25 | Source_Data_Size => 2048 B; 26 | -- name of the corresponding data type in the source file: 27 | Type_Source_Name => "T-POS"; 28 | END T_POS; 29 | 30 | DATA T_INT 31 | PROPERTIES 32 | -- name of the ASN.1 source file: 33 | Source_Text => ("NoenumInt.asn"); 34 | -- Size of a buffer to cover DER representation: 35 | -- Real message size is 3; suggested aligned message buffer is... 36 | Source_Data_Size => 4 B; 37 | -- name of the corresponding data type in the source file: 38 | Type_Source_Name => "T-INT"; 39 | END T_INT; 40 | 41 | DATA T_REAL 42 | PROPERTIES 43 | -- name of the ASN.1 source file: 44 | Source_Text => ("NoenumInt.asn"); 45 | -- Size of a buffer to cover DER representation: 46 | -- Real message size is 11; suggested aligned message buffer is... 47 | Source_Data_Size => 16 B; 48 | -- name of the corresponding data type in the source file: 49 | Type_Source_Name => "T-REAL"; 50 | END T_REAL; 51 | 52 | DATA TypeEnumerated 53 | PROPERTIES 54 | -- name of the ASN.1 source file: 55 | Source_Text => ("NoenumInt.asn"); 56 | -- Size of a buffer to cover DER representation: 57 | -- Real message size is 3; suggested aligned message buffer is... 58 | Source_Data_Size => 4 B; 59 | -- name of the corresponding data type in the source file: 60 | Type_Source_Name => "TypeEnumerated"; 61 | END TypeEnumerated; 62 | 63 | DATA T_STRING 64 | PROPERTIES 65 | -- name of the ASN.1 source file: 66 | Source_Text => ("NoenumInt.asn"); 67 | -- Size of a buffer to cover DER representation: 68 | -- Real message size is 17; suggested aligned message buffer is... 69 | Source_Data_Size => 32 B; 70 | -- name of the corresponding data type in the source file: 71 | Type_Source_Name => "T-STRING"; 72 | END T_STRING; 73 | 74 | DATA T_ARR 75 | PROPERTIES 76 | -- name of the ASN.1 source file: 77 | Source_Text => ("NoenumInt.asn"); 78 | -- Size of a buffer to cover DER representation: 79 | -- Real message size is 20; suggested aligned message buffer is... 80 | Source_Data_Size => 32 B; 81 | -- name of the corresponding data type in the source file: 82 | Type_Source_Name => "T-ARR"; 83 | END T_ARR; 84 | 85 | DATA T_BOOL 86 | PROPERTIES 87 | -- name of the ASN.1 source file: 88 | Source_Text => ("NoenumInt.asn"); 89 | -- Size of a buffer to cover DER representation: 90 | -- Real message size is 3; suggested aligned message buffer is... 91 | Source_Data_Size => 4 B; 92 | -- name of the corresponding data type in the source file: 93 | Type_Source_Name => "T-BOOL"; 94 | END T_BOOL; 95 | 96 | end Data_types; 97 | -------------------------------------------------------------------------------- /tests-coverage/NoenumInt.asn: -------------------------------------------------------------------------------- 1 | MY-MODULE DEFINITIONS ::= BEGIN 2 | 3 | -- Original definition by Alain 4 | --T-POS ::= BOOLEAN 5 | 6 | TypeEnumerated ::= ENUMERATED { 7 | red, 8 | green(1), 9 | blue(2) 10 | } 11 | 12 | TypeNested ::= SEQUENCE { 13 | intArray SEQUENCE (SIZE (10)) OF INTEGER (0..3), 14 | boolArray SEQUENCE (SIZE (10)) OF T-BOOL, 15 | enumValue TypeEnumerated, 16 | label OCTET STRING (SIZE(10..40)), 17 | bAlpha T-BOOL, 18 | bBeta BOOLEAN, 19 | sString T-STRING, 20 | arr T-ARR 21 | } 22 | 23 | -- A more realistic definition 24 | T-POS ::= SEQUENCE { 25 | longitude REAL(-180.0..180.0), 26 | latitude REAL(-90.0..90.0), 27 | height REAL(30000.0..45000.0), 28 | subTypeArray SEQUENCE (SIZE(10..15)) OF TypeNested, 29 | label OCTET STRING (SIZE(20..50)) 30 | } 31 | 32 | T-ARR ::= SEQUENCE (SIZE (5..6)) OF INTEGER (0..4) 33 | 34 | T-BOOL ::= BOOLEAN 35 | T-INT ::= INTEGER (0..50) 36 | T-REAL ::= REAL (-3.14..3.14) 37 | T-STRING ::= OCTET STRING (SIZE(10..15)) 38 | 39 | END 40 | -------------------------------------------------------------------------------- /tests-coverage/NorangeInt.aadl: -------------------------------------------------------------------------------- 1 | package Data_types 2 | 3 | public 4 | 5 | -- Memory required to encode/decode these messages (aligned to page size: 4096) 6 | -- Memory_Required: 12288 7 | 8 | DATA TypeNested 9 | PROPERTIES 10 | -- name of the ASN.1 source file: 11 | Source_Text => ("NorangeInt.asn"); 12 | -- Size of a buffer to cover DER representation: 13 | -- Real message size is 82; suggested aligned message buffer is... 14 | Source_Data_Size => 128 B; 15 | -- name of the corresponding data type in the source file: 16 | Type_Source_Name => "TypeNested"; 17 | END TypeNested; 18 | 19 | DATA T_POS 20 | PROPERTIES 21 | -- name of the ASN.1 source file: 22 | Source_Text => ("NorangeInt.asn"); 23 | -- Size of a buffer to cover DER representation: 24 | -- Real message size is 1256; suggested aligned message buffer is... 25 | Source_Data_Size => 2048 B; 26 | -- name of the corresponding data type in the source file: 27 | Type_Source_Name => "T-POS"; 28 | END T_POS; 29 | 30 | DATA T_INT 31 | PROPERTIES 32 | -- name of the ASN.1 source file: 33 | Source_Text => ("NorangeInt.asn"); 34 | -- Size of a buffer to cover DER representation: 35 | -- Real message size is 3; suggested aligned message buffer is... 36 | Source_Data_Size => 4 B; 37 | -- name of the corresponding data type in the source file: 38 | Type_Source_Name => "T-INT"; 39 | END T_INT; 40 | 41 | DATA T_REAL 42 | PROPERTIES 43 | -- name of the ASN.1 source file: 44 | Source_Text => ("NorangeInt.asn"); 45 | -- Size of a buffer to cover DER representation: 46 | -- Real message size is 11; suggested aligned message buffer is... 47 | Source_Data_Size => 16 B; 48 | -- name of the corresponding data type in the source file: 49 | Type_Source_Name => "T-REAL"; 50 | END T_REAL; 51 | 52 | DATA TypeEnumerated 53 | PROPERTIES 54 | -- name of the ASN.1 source file: 55 | Source_Text => ("NorangeInt.asn"); 56 | -- Size of a buffer to cover DER representation: 57 | -- Real message size is 3; suggested aligned message buffer is... 58 | Source_Data_Size => 4 B; 59 | -- name of the corresponding data type in the source file: 60 | Type_Source_Name => "TypeEnumerated"; 61 | END TypeEnumerated; 62 | 63 | DATA T_STRING 64 | PROPERTIES 65 | -- name of the ASN.1 source file: 66 | Source_Text => ("NorangeInt.asn"); 67 | -- Size of a buffer to cover DER representation: 68 | -- Real message size is 17; suggested aligned message buffer is... 69 | Source_Data_Size => 32 B; 70 | -- name of the corresponding data type in the source file: 71 | Type_Source_Name => "T-STRING"; 72 | END T_STRING; 73 | 74 | DATA T_ARR 75 | PROPERTIES 76 | -- name of the ASN.1 source file: 77 | Source_Text => ("NorangeInt.asn"); 78 | -- Size of a buffer to cover DER representation: 79 | -- Real message size is 20; suggested aligned message buffer is... 80 | Source_Data_Size => 32 B; 81 | -- name of the corresponding data type in the source file: 82 | Type_Source_Name => "T-ARR"; 83 | END T_ARR; 84 | 85 | DATA T_BOOL 86 | PROPERTIES 87 | -- name of the ASN.1 source file: 88 | Source_Text => ("NorangeInt.asn"); 89 | -- Size of a buffer to cover DER representation: 90 | -- Real message size is 3; suggested aligned message buffer is... 91 | Source_Data_Size => 4 B; 92 | -- name of the corresponding data type in the source file: 93 | Type_Source_Name => "T-BOOL"; 94 | END T_BOOL; 95 | 96 | end Data_types; 97 | -------------------------------------------------------------------------------- /tests-coverage/NorangeInt.asn: -------------------------------------------------------------------------------- 1 | MY-MODULE DEFINITIONS ::= BEGIN 2 | 3 | -- Original definition by Alain 4 | --T-POS ::= BOOLEAN 5 | 6 | TypeEnumerated ::= ENUMERATED { 7 | red(0), 8 | green(1), 9 | blue(2) 10 | } 11 | 12 | TypeNested ::= SEQUENCE { 13 | intVal INTEGER, 14 | intArray SEQUENCE (SIZE (10)) OF INTEGER (0..3), 15 | boolArray SEQUENCE (SIZE (10)) OF T-BOOL, 16 | enumValue TypeEnumerated, 17 | label OCTET STRING (SIZE(10..40)), 18 | bAlpha T-BOOL, 19 | bBeta BOOLEAN, 20 | sString T-STRING, 21 | arr T-ARR 22 | } 23 | 24 | -- A more realistic definition 25 | T-POS ::= SEQUENCE { 26 | longitude REAL(-180.0..180.0), 27 | latitude REAL(-90.0..90.0), 28 | height REAL(30000.0..45000.0), 29 | subTypeArray SEQUENCE (SIZE(10..15)) OF TypeNested, 30 | label OCTET STRING (SIZE(20..50)) 31 | } 32 | 33 | T-ARR ::= SEQUENCE (SIZE (5..6)) OF INTEGER (0..4) 34 | 35 | T-BOOL ::= BOOLEAN 36 | T-INT ::= INTEGER (0..50) 37 | T-REAL ::= REAL (-3.14..3.14) 38 | T-STRING ::= OCTET STRING (SIZE(10..15)) 39 | 40 | END 41 | -------------------------------------------------------------------------------- /tests-coverage/NorangeOct.aadl: -------------------------------------------------------------------------------- 1 | package Data_types 2 | 3 | public 4 | 5 | -- Memory required to encode/decode these messages (aligned to page size: 4096) 6 | -- Memory_Required: 12288 7 | 8 | DATA TypeNested 9 | PROPERTIES 10 | -- name of the ASN.1 source file: 11 | Source_Text => ("NorangeOct.asn"); 12 | -- Size of a buffer to cover DER representation: 13 | -- Real message size is 82; suggested aligned message buffer is... 14 | Source_Data_Size => 128 B; 15 | -- name of the corresponding data type in the source file: 16 | Type_Source_Name => "TypeNested"; 17 | END TypeNested; 18 | 19 | DATA T_POS 20 | PROPERTIES 21 | -- name of the ASN.1 source file: 22 | Source_Text => ("NorangeOct.asn"); 23 | -- Size of a buffer to cover DER representation: 24 | -- Real message size is 1256; suggested aligned message buffer is... 25 | Source_Data_Size => 2048 B; 26 | -- name of the corresponding data type in the source file: 27 | Type_Source_Name => "T-POS"; 28 | END T_POS; 29 | 30 | DATA T_INT 31 | PROPERTIES 32 | -- name of the ASN.1 source file: 33 | Source_Text => ("NorangeOct.asn"); 34 | -- Size of a buffer to cover DER representation: 35 | -- Real message size is 3; suggested aligned message buffer is... 36 | Source_Data_Size => 4 B; 37 | -- name of the corresponding data type in the source file: 38 | Type_Source_Name => "T-INT"; 39 | END T_INT; 40 | 41 | DATA T_REAL 42 | PROPERTIES 43 | -- name of the ASN.1 source file: 44 | Source_Text => ("NorangeOct.asn"); 45 | -- Size of a buffer to cover DER representation: 46 | -- Real message size is 11; suggested aligned message buffer is... 47 | Source_Data_Size => 16 B; 48 | -- name of the corresponding data type in the source file: 49 | Type_Source_Name => "T-REAL"; 50 | END T_REAL; 51 | 52 | DATA TypeEnumerated 53 | PROPERTIES 54 | -- name of the ASN.1 source file: 55 | Source_Text => ("NorangeOct.asn"); 56 | -- Size of a buffer to cover DER representation: 57 | -- Real message size is 3; suggested aligned message buffer is... 58 | Source_Data_Size => 4 B; 59 | -- name of the corresponding data type in the source file: 60 | Type_Source_Name => "TypeEnumerated"; 61 | END TypeEnumerated; 62 | 63 | DATA T_STRING 64 | PROPERTIES 65 | -- name of the ASN.1 source file: 66 | Source_Text => ("NorangeOct.asn"); 67 | -- Size of a buffer to cover DER representation: 68 | -- Real message size is 17; suggested aligned message buffer is... 69 | Source_Data_Size => 32 B; 70 | -- name of the corresponding data type in the source file: 71 | Type_Source_Name => "T-STRING"; 72 | END T_STRING; 73 | 74 | DATA T_ARR 75 | PROPERTIES 76 | -- name of the ASN.1 source file: 77 | Source_Text => ("NorangeOct.asn"); 78 | -- Size of a buffer to cover DER representation: 79 | -- Real message size is 20; suggested aligned message buffer is... 80 | Source_Data_Size => 32 B; 81 | -- name of the corresponding data type in the source file: 82 | Type_Source_Name => "T-ARR"; 83 | END T_ARR; 84 | 85 | DATA T_BOOL 86 | PROPERTIES 87 | -- name of the ASN.1 source file: 88 | Source_Text => ("NorangeOct.asn"); 89 | -- Size of a buffer to cover DER representation: 90 | -- Real message size is 3; suggested aligned message buffer is... 91 | Source_Data_Size => 4 B; 92 | -- name of the corresponding data type in the source file: 93 | Type_Source_Name => "T-BOOL"; 94 | END T_BOOL; 95 | 96 | end Data_types; 97 | -------------------------------------------------------------------------------- /tests-coverage/NorangeOct.asn: -------------------------------------------------------------------------------- 1 | MY-MODULE DEFINITIONS ::= BEGIN 2 | 3 | -- Original definition by Alain 4 | --T-POS ::= BOOLEAN 5 | 6 | TypeEnumerated ::= ENUMERATED { 7 | red(0), 8 | green(1), 9 | blue(2) 10 | } 11 | 12 | TypeNested ::= SEQUENCE { 13 | intArray SEQUENCE (SIZE (10)) OF INTEGER (0..3), 14 | boolArray SEQUENCE (SIZE (10)) OF T-BOOL, 15 | enumValue TypeEnumerated, 16 | label OCTET STRING (SIZE(10..40)), 17 | bAlpha T-BOOL, 18 | bBeta BOOLEAN, 19 | sString T-STRING, 20 | arr T-ARR 21 | } 22 | 23 | -- A more realistic definition 24 | T-POS ::= SEQUENCE { 25 | longitude REAL(-180.0..180.0), 26 | latitude REAL(-90.0..90.0), 27 | height REAL(30000.0..45000.0), 28 | subTypeArray SEQUENCE (SIZE(10..15)) OF TypeNested, 29 | label OCTET STRING (SIZE(20..50)) 30 | } 31 | 32 | T-ARR ::= SEQUENCE (SIZE (5..6)) OF INTEGER (0..4) 33 | 34 | T-BOOL ::= BOOLEAN 35 | T-INT ::= INTEGER (0..50) 36 | T-REAL ::= REAL (-3.14..3.14) 37 | T-STRING ::= OCTET STRING 38 | 39 | END 40 | -------------------------------------------------------------------------------- /tests-coverage/NorangeReal.aadl: -------------------------------------------------------------------------------- 1 | package Data_types 2 | 3 | public 4 | 5 | -- Memory required to encode/decode these messages (aligned to page size: 4096) 6 | -- Memory_Required: 12288 7 | 8 | DATA TypeNested 9 | PROPERTIES 10 | -- name of the ASN.1 source file: 11 | Source_Text => ("NorangeReal.asn"); 12 | -- Size of a buffer to cover DER representation: 13 | -- Real message size is 82; suggested aligned message buffer is... 14 | Source_Data_Size => 128 B; 15 | -- name of the corresponding data type in the source file: 16 | Type_Source_Name => "TypeNested"; 17 | END TypeNested; 18 | 19 | DATA T_POS 20 | PROPERTIES 21 | -- name of the ASN.1 source file: 22 | Source_Text => ("NorangeReal.asn"); 23 | -- Size of a buffer to cover DER representation: 24 | -- Real message size is 1256; suggested aligned message buffer is... 25 | Source_Data_Size => 2048 B; 26 | -- name of the corresponding data type in the source file: 27 | Type_Source_Name => "T-POS"; 28 | END T_POS; 29 | 30 | DATA T_INT 31 | PROPERTIES 32 | -- name of the ASN.1 source file: 33 | Source_Text => ("NorangeReal.asn"); 34 | -- Size of a buffer to cover DER representation: 35 | -- Real message size is 3; suggested aligned message buffer is... 36 | Source_Data_Size => 4 B; 37 | -- name of the corresponding data type in the source file: 38 | Type_Source_Name => "T-INT"; 39 | END T_INT; 40 | 41 | DATA T_REAL 42 | PROPERTIES 43 | -- name of the ASN.1 source file: 44 | Source_Text => ("NorangeReal.asn"); 45 | -- Size of a buffer to cover DER representation: 46 | -- Real message size is 11; suggested aligned message buffer is... 47 | Source_Data_Size => 16 B; 48 | -- name of the corresponding data type in the source file: 49 | Type_Source_Name => "T-REAL"; 50 | END T_REAL; 51 | 52 | DATA TypeEnumerated 53 | PROPERTIES 54 | -- name of the ASN.1 source file: 55 | Source_Text => ("NorangeReal.asn"); 56 | -- Size of a buffer to cover DER representation: 57 | -- Real message size is 3; suggested aligned message buffer is... 58 | Source_Data_Size => 4 B; 59 | -- name of the corresponding data type in the source file: 60 | Type_Source_Name => "TypeEnumerated"; 61 | END TypeEnumerated; 62 | 63 | DATA T_STRING 64 | PROPERTIES 65 | -- name of the ASN.1 source file: 66 | Source_Text => ("NorangeReal.asn"); 67 | -- Size of a buffer to cover DER representation: 68 | -- Real message size is 17; suggested aligned message buffer is... 69 | Source_Data_Size => 32 B; 70 | -- name of the corresponding data type in the source file: 71 | Type_Source_Name => "T-STRING"; 72 | END T_STRING; 73 | 74 | DATA T_ARR 75 | PROPERTIES 76 | -- name of the ASN.1 source file: 77 | Source_Text => ("NorangeReal.asn"); 78 | -- Size of a buffer to cover DER representation: 79 | -- Real message size is 20; suggested aligned message buffer is... 80 | Source_Data_Size => 32 B; 81 | -- name of the corresponding data type in the source file: 82 | Type_Source_Name => "T-ARR"; 83 | END T_ARR; 84 | 85 | DATA T_BOOL 86 | PROPERTIES 87 | -- name of the ASN.1 source file: 88 | Source_Text => ("NorangeReal.asn"); 89 | -- Size of a buffer to cover DER representation: 90 | -- Real message size is 3; suggested aligned message buffer is... 91 | Source_Data_Size => 4 B; 92 | -- name of the corresponding data type in the source file: 93 | Type_Source_Name => "T-BOOL"; 94 | END T_BOOL; 95 | 96 | end Data_types; 97 | -------------------------------------------------------------------------------- /tests-coverage/NorangeReal.asn: -------------------------------------------------------------------------------- 1 | MY-MODULE DEFINITIONS ::= BEGIN 2 | 3 | -- Original definition by Alain 4 | --T-POS ::= BOOLEAN 5 | 6 | TypeEnumerated ::= ENUMERATED { 7 | red(0), 8 | green(1), 9 | blue(2) 10 | } 11 | 12 | TypeNested ::= SEQUENCE { 13 | intArray SEQUENCE (SIZE (10)) OF INTEGER (0..3), 14 | boolArray SEQUENCE (SIZE (10)) OF T-BOOL, 15 | enumValue TypeEnumerated, 16 | label OCTET STRING (SIZE(10..40)), 17 | bAlpha T-BOOL, 18 | bBeta BOOLEAN, 19 | sString T-STRING, 20 | arr T-ARR 21 | } 22 | 23 | -- A more realistic definition 24 | T-POS ::= SEQUENCE { 25 | longitude REAL, 26 | latitude REAL(-90.0..90.0), 27 | height REAL(30000.0..45000.0), 28 | subTypeArray SEQUENCE (SIZE(10..15)) OF TypeNested, 29 | label OCTET STRING (SIZE(20..50)) 30 | } 31 | 32 | T-ARR ::= SEQUENCE (SIZE (5..6)) OF INTEGER (0..4) 33 | 34 | T-BOOL ::= BOOLEAN 35 | T-INT ::= INTEGER (0..50) 36 | T-REAL ::= REAL (-3.14..3.14) 37 | T-STRING ::= OCTET STRING (SIZE(10..15)) 38 | 39 | END 40 | -------------------------------------------------------------------------------- /tests-coverage/NorangeSeqof.aadl: -------------------------------------------------------------------------------- 1 | package Data_types 2 | 3 | public 4 | 5 | -- Memory required to encode/decode these messages (aligned to page size: 4096) 6 | -- Memory_Required: 12288 7 | 8 | DATA TypeNested 9 | PROPERTIES 10 | -- name of the ASN.1 source file: 11 | Source_Text => ("NorangeSeqof.asn"); 12 | -- Size of a buffer to cover DER representation: 13 | -- Real message size is 82; suggested aligned message buffer is... 14 | Source_Data_Size => 128 B; 15 | -- name of the corresponding data type in the source file: 16 | Type_Source_Name => "TypeNested"; 17 | END TypeNested; 18 | 19 | DATA T_POS 20 | PROPERTIES 21 | -- name of the ASN.1 source file: 22 | Source_Text => ("NorangeSeqof.asn"); 23 | -- Size of a buffer to cover DER representation: 24 | -- Real message size is 1256; suggested aligned message buffer is... 25 | Source_Data_Size => 2048 B; 26 | -- name of the corresponding data type in the source file: 27 | Type_Source_Name => "T-POS"; 28 | END T_POS; 29 | 30 | DATA T_INT 31 | PROPERTIES 32 | -- name of the ASN.1 source file: 33 | Source_Text => ("NorangeSeqof.asn"); 34 | -- Size of a buffer to cover DER representation: 35 | -- Real message size is 3; suggested aligned message buffer is... 36 | Source_Data_Size => 4 B; 37 | -- name of the corresponding data type in the source file: 38 | Type_Source_Name => "T-INT"; 39 | END T_INT; 40 | 41 | DATA T_REAL 42 | PROPERTIES 43 | -- name of the ASN.1 source file: 44 | Source_Text => ("NorangeSeqof.asn"); 45 | -- Size of a buffer to cover DER representation: 46 | -- Real message size is 11; suggested aligned message buffer is... 47 | Source_Data_Size => 16 B; 48 | -- name of the corresponding data type in the source file: 49 | Type_Source_Name => "T-REAL"; 50 | END T_REAL; 51 | 52 | DATA TypeEnumerated 53 | PROPERTIES 54 | -- name of the ASN.1 source file: 55 | Source_Text => ("NorangeSeqof.asn"); 56 | -- Size of a buffer to cover DER representation: 57 | -- Real message size is 3; suggested aligned message buffer is... 58 | Source_Data_Size => 4 B; 59 | -- name of the corresponding data type in the source file: 60 | Type_Source_Name => "TypeEnumerated"; 61 | END TypeEnumerated; 62 | 63 | DATA T_STRING 64 | PROPERTIES 65 | -- name of the ASN.1 source file: 66 | Source_Text => ("NorangeSeqof.asn"); 67 | -- Size of a buffer to cover DER representation: 68 | -- Real message size is 17; suggested aligned message buffer is... 69 | Source_Data_Size => 32 B; 70 | -- name of the corresponding data type in the source file: 71 | Type_Source_Name => "T-STRING"; 72 | END T_STRING; 73 | 74 | DATA T_ARR 75 | PROPERTIES 76 | -- name of the ASN.1 source file: 77 | Source_Text => ("NorangeSeqof.asn"); 78 | -- Size of a buffer to cover DER representation: 79 | -- Real message size is 20; suggested aligned message buffer is... 80 | Source_Data_Size => 32 B; 81 | -- name of the corresponding data type in the source file: 82 | Type_Source_Name => "T-ARR"; 83 | END T_ARR; 84 | 85 | DATA T_BOOL 86 | PROPERTIES 87 | -- name of the ASN.1 source file: 88 | Source_Text => ("NorangeSeqof.asn"); 89 | -- Size of a buffer to cover DER representation: 90 | -- Real message size is 3; suggested aligned message buffer is... 91 | Source_Data_Size => 4 B; 92 | -- name of the corresponding data type in the source file: 93 | Type_Source_Name => "T-BOOL"; 94 | END T_BOOL; 95 | 96 | end Data_types; 97 | -------------------------------------------------------------------------------- /tests-coverage/NorangeSeqof.asn: -------------------------------------------------------------------------------- 1 | MY-MODULE DEFINITIONS ::= BEGIN 2 | 3 | -- Original definition by Alain 4 | --T-POS ::= BOOLEAN 5 | 6 | TypeEnumerated ::= ENUMERATED { 7 | green(1), 8 | blue(2) 9 | } 10 | 11 | TypeNested ::= SEQUENCE { 12 | intArray SEQUENCE (SIZE (10)) OF INTEGER (0..3), 13 | boolArray SEQUENCE (SIZE (10)) OF T-BOOL, 14 | enumValue TypeEnumerated, 15 | label OCTET STRING (SIZE(10..40)), 16 | bAlpha T-BOOL, 17 | bBeta BOOLEAN, 18 | sString T-STRING, 19 | arr T-ARR 20 | } 21 | 22 | -- A more realistic definition 23 | T-POS ::= SEQUENCE { 24 | longitude REAL(-180.0..180.0), 25 | latitude REAL(-90.0..90.0), 26 | height REAL(30000.0..45000.0), 27 | subTypeArray SEQUENCE (SIZE(10..15)) OF TypeNested, 28 | label OCTET STRING (SIZE(20..50)) 29 | } 30 | 31 | T-ARR ::= SEQUENCE OF INTEGER (0..4) 32 | 33 | T-BOOL ::= BOOLEAN 34 | T-INT ::= INTEGER (0..50) 35 | T-REAL ::= REAL (-3.14..3.14) 36 | T-STRING ::= OCTET STRING (SIZE(10..15)) 37 | 38 | END 39 | -------------------------------------------------------------------------------- /tests-coverage/README: -------------------------------------------------------------------------------- 1 | Make sure you have installed the python "coverage" tool, 2 | via your distro's package manager or (better) via pip. 3 | 4 | Version used: coverage 3.5.2 5 | -------------------------------------------------------------------------------- /tests-coverage/checkCoverage.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -w 2 | use strict; 3 | 4 | use Term::ANSIColor; 5 | 6 | my $foundDiff = 0; 7 | while(<>) { 8 | next if /pragma: no cover/; 9 | if (/^!/) { 10 | $foundDiff = 1; 11 | } 12 | } 13 | exit $foundDiff; 14 | -------------------------------------------------------------------------------- /tests-coverage/common.mk: -------------------------------------------------------------------------------- 1 | # Detect name of the coverage tool (package named has changed) 2 | 3 | RUN_PYTHON_COVERAGE:=$(shell command -v python3-coverage 2>/dev/null) 4 | RUN_COVERAGE:=$(shell command -v coverage 2>/dev/null) 5 | 6 | ifndef RUN_PYTHON_COVERAGE 7 | 8 | ifndef RUN_COVERAGE 9 | $(error "Neither 'python3-coverage' nor 'coverage' are installed.") 10 | else 11 | COVERAGE:=coverage 12 | endif 13 | 14 | else 15 | COVERAGE:=python3-coverage 16 | endif 17 | 18 | -------------------------------------------------------------------------------- /tests-coverage/createGUIsection.py: -------------------------------------------------------------------------------- 1 | template = ''' 2 | SUBPROGRAM mytestsubsystem%(name)s_PI 3 | FEATURES 4 | my_in_%(name)s:IN PARAMETER DataView::%(name)s {encoding=>UPER;}; 5 | END mytestsubsystem%(name)s_PI; 6 | 7 | SUBPROGRAM IMPLEMENTATION mytestsubsystem%(name)s_PI.GUIPI 8 | PROPERTIES 9 | FV_Name => "mytestsubsystem%(name)s_fv_GUIPI"; 10 | Source_Language => GUI_PI; 11 | END mytestsubsystem%(name)s_PI.GUIPI; 12 | 13 | 14 | 15 | SUBPROGRAM mytestsubsystem%(name)s_RI 16 | FEATURES 17 | my_in_%(name)s:IN PARAMETER DataView::%(name)s {encoding=>UPER;}; 18 | END mytestsubsystem%(name)s_RI; 19 | 20 | SUBPROGRAM IMPLEMENTATION mytestsubsystem%(name)s_RI.GUIRI 21 | PROPERTIES 22 | FV_Name => "mytestsubsystem%(name)s_fv_GUIRI"; 23 | Source_Language => GUI_RI; 24 | END mytestsubsystem%(name)s_RI.GUIRI; 25 | 26 | ''' 27 | 28 | mytypes = [ 29 | 'AType', 30 | 'TypeEnumerated', 31 | 'TypeNested', 32 | 'T_POS', 33 | 'T_POS_SET', 34 | 'T_ARR', 35 | 'T_ARR2', 36 | 'T_ARR3', 37 | 'T_ARR4', 38 | 'T_SET', 39 | 'T_SETOF', 40 | 'T_BOOL', 41 | 'T_INT', 42 | 'T_REAL', 43 | 'T_STRING', 44 | 'T_META' 45 | ] 46 | 47 | for t in mytypes: 48 | print template % {'name':t} 49 | -------------------------------------------------------------------------------- /tests-coverage/gnc.aadl: -------------------------------------------------------------------------------- 1 | package SW 2 | 3 | public 4 | 5 | process P_GNC 6 | features 7 | read_position: in event data port Data_types::T_ARR; 8 | write_position: out event data port Data_types::T_POS; 9 | properties 10 | Period => 100 Ms; 11 | Dispatch_Protocol => Periodic; 12 | Source_Language => Rhapsody; 13 | end P_GNC; 14 | 15 | process implementation P_GNC.P_GNC_Impl 16 | connections 17 | event data port write_position -> P_POS.get_position_from_GNC; 18 | end P_GNC.P_GNC_Impl; 19 | 20 | subprogram P_TMTC 21 | features 22 | tc_from_ground: in parameter Data_types::T_POS; 23 | tc_send: out parameter Data_types::T_POS; 24 | tc_bool : in parameter Data_types::T_BOOL; 25 | tc_int : in parameter Data_types::T_INT; 26 | tc_into : out parameter Data_types::T_INT; 27 | tc_real : in parameter Data_types::T_REAL; 28 | tc_string : in parameter Data_types::T_STRING; 29 | tc_array : in parameter Data_types::T_ARR; 30 | tc_arrayo : out parameter Data_types::T_ARR; 31 | tc_enum : in parameter Data_types::TypeEnumerated; 32 | tc_enumo : out parameter Data_types::TypeEnumerated; 33 | properties 34 | Source_Language => Ada; 35 | end P_TMTC; 36 | 37 | process implementation P_TMTC.P_TMTC_Impl 38 | connections 39 | event data port tc_send -> P_POS.get_position_from_TMTC; 40 | end P_TMTC.P_TMTC_Impl; 41 | 42 | process P_POS 43 | features 44 | provide_position: out event data port Data_types::T_POS; 45 | get_position_from_GNC: in event data port Data_types::T_POS; 46 | get_position_from_TMTC: in event data port Data_types::T_POS; 47 | properties 48 | Source_Language => Ada; 49 | end P_POS; 50 | 51 | process implementation P_POS.P_POS_Impl 52 | connections 53 | event data port provide_position -> P_GNC.read_position; 54 | end P_POS.P_POS_Impl; 55 | 56 | end SW; 57 | -------------------------------------------------------------------------------- /tests-coverage/mini_cv_vhdl.aadl: -------------------------------------------------------------------------------- 1 | SUBPROGRAM mytestsubsystemEmpty 2 | END mytestsubsystemEmpty; 3 | 4 | SUBPROGRAM IMPLEMENTATION mytestsubsystemEmpty.VHDL 5 | PROPERTIES 6 | FV_Name => "mytestsubsystemEmpty_fv_VHDL"; 7 | Source_Language => VHDL; 8 | END mytestsubsystemEmpty.VHDL; 9 | 10 | SUBPROGRAM mytestsubsystemvhdl 11 | FEATURES 12 | my_in_AType:IN PARAMETER DataView::AType {encoding=>UPER;}; 13 | my_in_TypeEnumerated:IN PARAMETER DataView::TypeEnumerated {encoding=>UPER;}; 14 | my_in_TypeNested:IN PARAMETER DataView::TypeNested {encoding=>UPER;}; 15 | my_in_T_POS:IN PARAMETER DataView::T_POS {encoding=>UPER;}; 16 | my_in_T_POS_SET:IN PARAMETER DataView::T_POS_SET {encoding=>UPER;}; 17 | my_in_T_ARR:IN PARAMETER DataView::T_ARR {encoding=>UPER;}; 18 | my_in_T_ARR3:IN PARAMETER DataView::T_ARR3 {encoding=>UPER;}; 19 | my_in_T_ARR4:IN PARAMETER DataView::T_ARR4 {encoding=>UPER;}; 20 | my_in_T_SET:IN PARAMETER DataView::T_SET {encoding=>UPER;}; 21 | my_in_T_SETOF:IN PARAMETER DataView::T_SETOF {encoding=>UPER;}; 22 | my_in_T_BOOL:IN PARAMETER DataView::T_BOOL {encoding=>UPER;}; 23 | my_in_T_INT:IN PARAMETER DataView::T_INT {encoding=>UPER;}; 24 | my_in_T_STRING:IN PARAMETER DataView::T_STRING {encoding=>UPER;}; 25 | my_in_T_META:IN PARAMETER DataView::T_META {encoding=>UPER;}; 26 | my_out_AType:OUT PARAMETER DataView::AType {encoding=>UPER;}; 27 | my_out_TypeEnumerated:OUT PARAMETER DataView::TypeEnumerated {encoding=>UPER;}; 28 | my_out_TypeNested:OUT PARAMETER DataView::TypeNested {encoding=>UPER;}; 29 | my_out_T_POS:OUT PARAMETER DataView::T_POS {encoding=>UPER;}; 30 | my_out_T_POS_SET:OUT PARAMETER DataView::T_POS_SET {encoding=>UPER;}; 31 | my_out_T_ARR:OUT PARAMETER DataView::T_ARR {encoding=>UPER;}; 32 | my_out_T_ARR3:OUT PARAMETER DataView::T_ARR3 {encoding=>UPER;}; 33 | my_out_T_ARR4:OUT PARAMETER DataView::T_ARR4 {encoding=>UPER;}; 34 | my_out_T_SET:OUT PARAMETER DataView::T_SET {encoding=>UPER;}; 35 | my_out_T_SETOF:OUT PARAMETER DataView::T_SETOF {encoding=>UPER;}; 36 | my_out_T_BOOL:OUT PARAMETER DataView::T_BOOL {encoding=>UPER;}; 37 | my_out_T_INT:OUT PARAMETER DataView::T_INT {encoding=>UPER;}; 38 | my_out_T_STRING:OUT PARAMETER DataView::T_STRING {encoding=>UPER;}; 39 | my_out_T_META:OUT PARAMETER DataView::T_META {encoding=>UPER;}; 40 | 41 | your_in_AType:IN PARAMETER DataView::AType {encoding=>Native;}; 42 | your_in_TypeEnumerated:IN PARAMETER DataView::TypeEnumerated {encoding=>Native;}; 43 | your_in_TypeNested:IN PARAMETER DataView::TypeNested {encoding=>Native;}; 44 | your_in_T_POS:IN PARAMETER DataView::T_POS {encoding=>Native;}; 45 | your_in_T_POS_SET:IN PARAMETER DataView::T_POS_SET {encoding=>Native;}; 46 | your_in_T_ARR:IN PARAMETER DataView::T_ARR {encoding=>Native;}; 47 | your_in_T_ARR3:IN PARAMETER DataView::T_ARR3 {encoding=>Native;}; 48 | your_in_T_ARR4:IN PARAMETER DataView::T_ARR4 {encoding=>Native;}; 49 | your_in_T_SET:IN PARAMETER DataView::T_SET {encoding=>Native;}; 50 | your_in_T_SETOF:IN PARAMETER DataView::T_SETOF {encoding=>Native;}; 51 | your_in_T_BOOL:IN PARAMETER DataView::T_BOOL {encoding=>Native;}; 52 | your_in_T_INT:IN PARAMETER DataView::T_INT {encoding=>Native;}; 53 | your_in_T_STRING:IN PARAMETER DataView::T_STRING {encoding=>Native;}; 54 | your_in_T_META:IN PARAMETER DataView::T_META {encoding=>Native;}; 55 | your_out_AType:OUT PARAMETER DataView::AType {encoding=>Native;}; 56 | your_out_TypeEnumerated:OUT PARAMETER DataView::TypeEnumerated {encoding=>Native;}; 57 | your_out_TypeNested:OUT PARAMETER DataView::TypeNested {encoding=>Native;}; 58 | your_out_T_POS:OUT PARAMETER DataView::T_POS {encoding=>Native;}; 59 | your_out_T_POS_SET:OUT PARAMETER DataView::T_POS_SET {encoding=>Native;}; 60 | your_out_T_ARR:OUT PARAMETER DataView::T_ARR {encoding=>Native;}; 61 | your_out_T_ARR3:OUT PARAMETER DataView::T_ARR3 {encoding=>Native;}; 62 | your_out_T_ARR4:OUT PARAMETER DataView::T_ARR4 {encoding=>Native;}; 63 | your_out_T_SET:OUT PARAMETER DataView::T_SET {encoding=>Native;}; 64 | your_out_T_SETOF:OUT PARAMETER DataView::T_SETOF {encoding=>Native;}; 65 | your_out_T_BOOL:OUT PARAMETER DataView::T_BOOL {encoding=>Native;}; 66 | your_out_T_INT:OUT PARAMETER DataView::T_INT {encoding=>Native;}; 67 | your_out_T_STRING:OUT PARAMETER DataView::T_STRING {encoding=>Native;}; 68 | your_out_T_META:OUT PARAMETER DataView::T_META {encoding=>Native;}; 69 | END mytestsubsystemvhdl; 70 | 71 | SUBPROGRAM IMPLEMENTATION mytestsubsystemvhdl.VHDL 72 | PROPERTIES 73 | FV_Name => "mytestsubsystem_fv_VHDL"; 74 | Source_Language => VHDL; 75 | END mytestsubsystemvhdl.VHDL; 76 | 77 | SUBPROGRAM mytestsubsystemvhdl2 78 | FEATURES 79 | my_in_AType:IN PARAMETER DataView::AType {encoding=>UPER;}; 80 | my_in_TypeEnumerated:IN PARAMETER DataView::TypeEnumerated {encoding=>UPER;}; 81 | END mytestsubsystemvhdl2; 82 | 83 | SUBPROGRAM IMPLEMENTATION mytestsubsystemvhdl2.VHDL 84 | PROPERTIES 85 | FV_Name => "mytestsubsystem_fv_VHDL"; 86 | Source_Language => VHDL; 87 | END mytestsubsystemvhdl2.VHDL; 88 | 89 | -------------------------------------------------------------------------------- /tests-coverage/model.aadl: -------------------------------------------------------------------------------- 1 | package AADL_PI_RI 2 | 3 | Public 4 | 5 | SUBPROGRAM computeNative 6 | FEATURES 7 | tc_bool : in parameter D_view::T_BOOL {Encoding=>Native;}; 8 | tc_boolo : out parameter D_view::T_BOOL {Encoding=>Native;}; 9 | tc_int : in parameter D_view::T_INT {Encoding=>Native;}; 10 | tc_into : out parameter D_view::T_INT {Encoding=>Native;}; 11 | tc_real : in parameter D_view::T_REAL {Encoding=>Native;}; 12 | tc_realo : out parameter D_view::T_REAL {Encoding=>Native;}; 13 | tc_string : in parameter D_view::T_STRING {Encoding=>Native;}; 14 | tc_stringo : out parameter D_view::T_STRING {Encoding=>Native;}; 15 | tc_array : in parameter D_view::T_ARR {Encoding=>Native;}; 16 | tc_arrayo : out parameter D_view::T_ARR {Encoding=>Native;}; 17 | tc_enum : in parameter D_view::TypeEnumerated {Encoding=>Native;}; 18 | tc_enumo : out parameter D_view::TypeEnumerated {Encoding=>Native;}; 19 | tc_seq : in parameter D_view::TypeNested {Encoding=>Native;}; 20 | tc_seqo : out parameter D_view::TypeNested {Encoding=>Native;}; 21 | tc_cho : in parameter D_view::T_POS {Encoding=>Native;}; 22 | tc_choo : out parameter D_view::T_POS {Encoding=>Native;}; 23 | tc_set : in parameter D_view::T_SET {Encoding=>Native;}; 24 | tc_seto : out parameter D_view::T_SETOF {Encoding=>Native;}; 25 | END computeNative; 26 | 27 | SUBPROGRAM computeUPER 28 | FEATURES 29 | tc_bool : in parameter D_view::T_BOOL {Encoding=>UPER;}; 30 | tc_boolo : out parameter D_view::T_BOOL {Encoding=>UPER;}; 31 | tc_int : in parameter D_view::T_INT {Encoding=>UPER;}; 32 | tc_into : out parameter D_view::T_INT {Encoding=>UPER;}; 33 | tc_real : in parameter D_view::T_REAL {Encoding=>UPER;}; 34 | tc_realo : out parameter D_view::T_REAL {Encoding=>UPER;}; 35 | tc_string : in parameter D_view::T_STRING {Encoding=>UPER;}; 36 | tc_stringo : out parameter D_view::T_STRING {Encoding=>UPER;}; 37 | tc_array : in parameter D_view::T_ARR {Encoding=>UPER;}; 38 | tc_arrayo : out parameter D_view::T_ARR {Encoding=>UPER;}; 39 | tc_enum : in parameter D_view::TypeEnumerated {Encoding=>UPER;}; 40 | tc_enumo : out parameter D_view::TypeEnumerated {Encoding=>UPER;}; 41 | tc_seq : in parameter D_view::TypeNested {Encoding=>UPER;}; 42 | tc_seqo : out parameter D_view::TypeNested {Encoding=>UPER;}; 43 | tc_cho : in parameter D_view::T_POS {Encoding=>UPER;}; 44 | tc_choo : out parameter D_view::T_POS {Encoding=>UPER;}; 45 | tc_set : in parameter D_view::T_SET {Encoding=>UPER;}; 46 | tc_seto : out parameter D_view::T_SETOF {Encoding=>UPER;}; 47 | END computeUPER; 48 | 49 | --------- 50 | -- Native 51 | --------- 52 | 53 | SUBPROGRAM IMPLEMENTATION computeNative.SCADE5 54 | PROPERTIES 55 | Source_Language => Lustre5; 56 | assert_properties_extended::FV_Name => "compute_native_SCADE5"; 57 | END computeNative.SCADE5; 58 | 59 | SUBPROGRAM IMPLEMENTATION computeNative.SCADE6 60 | PROPERTIES 61 | Source_Language => Lustre6; 62 | assert_properties_extended::FV_Name => "compute_native_SCADE6"; 63 | END computeNative.SCADE6; 64 | 65 | SUBPROGRAM IMPLEMENTATION computeNative.OG 66 | PROPERTIES 67 | Source_Language => SDL; 68 | assert_properties_extended::FV_Name => "compute_native_OG"; 69 | END computeNative.OG; 70 | 71 | SUBPROGRAM IMPLEMENTATION computeNative.C 72 | PROPERTIES 73 | Source_Language => C; 74 | assert_properties_extended::FV_Name => "compute_native_C"; 75 | END computeNative.C; 76 | 77 | SUBPROGRAM IMPLEMENTATION computeNative.Ada 78 | PROPERTIES 79 | Source_Language => Ada; 80 | assert_properties_extended::FV_Name => "compute_native_Ada"; 81 | END computeNative.Ada; 82 | 83 | SUBPROGRAM IMPLEMENTATION computeNative.Simulink 84 | PROPERTIES 85 | Source_Language => Simulink; 86 | assert_properties_extended::FV_Name => "compute_native_Simulink"; 87 | END computeNative.Simulink; 88 | 89 | SUBPROGRAM IMPLEMENTATION computeNative.GUI_PI 90 | PROPERTIES 91 | Source_Language => GUI_PI; 92 | assert_properties_extended::FV_Name => "compute_native_GUI_PI"; 93 | END computeNative.GUI_PI; 94 | 95 | SUBPROGRAM IMPLEMENTATION computeNative.GUI_RI 96 | PROPERTIES 97 | Source_Language => GUI_RI; 98 | assert_properties_extended::FV_Name => "compute_native_GUI_RI"; 99 | END computeNative.GUI_RI; 100 | 101 | --------- 102 | -- UPER 103 | --------- 104 | 105 | SUBPROGRAM IMPLEMENTATION computeUPER.SCADE5 106 | PROPERTIES 107 | Source_Language => Lustre5; 108 | assert_properties_extended::FV_Name => "compute_native_SCADE5"; 109 | END computeUPER.SCADE5; 110 | 111 | SUBPROGRAM IMPLEMENTATION computeUPER.SCADE6 112 | PROPERTIES 113 | Source_Language => Lustre6; 114 | assert_properties_extended::FV_Name => "compute_native_SCADE6"; 115 | END computeUPER.SCADE6; 116 | 117 | SUBPROGRAM IMPLEMENTATION computeUPER.OG 118 | PROPERTIES 119 | Source_Language => SDL; 120 | assert_properties_extended::FV_Name => "compute_native_OG"; 121 | END computeUPER.OG; 122 | 123 | SUBPROGRAM IMPLEMENTATION computeUPER.C 124 | PROPERTIES 125 | Source_Language => C; 126 | assert_properties_extended::FV_Name => "compute_native_C"; 127 | END computeUPER.C; 128 | 129 | SUBPROGRAM IMPLEMENTATION computeUPER.Ada 130 | PROPERTIES 131 | Source_Language => Ada; 132 | assert_properties_extended::FV_Name => "compute_native_Ada"; 133 | END computeUPER.Ada; 134 | 135 | SUBPROGRAM IMPLEMENTATION computeUPER.Simulink 136 | PROPERTIES 137 | Source_Language => Simulink; 138 | assert_properties_extended::FV_Name => "compute_native_Simulink"; 139 | END computeUPER.Simulink; 140 | 141 | SUBPROGRAM IMPLEMENTATION computeUPER.GUI_PI 142 | PROPERTIES 143 | Source_Language => GUI_PI; 144 | assert_properties_extended::FV_Name => "compute_native_GUI_PI"; 145 | END computeUPER.GUI_PI; 146 | 147 | SUBPROGRAM IMPLEMENTATION computeUPER.GUI_RI 148 | PROPERTIES 149 | Source_Language => GUI_RI; 150 | assert_properties_extended::FV_Name => "compute_native_GUI_RI"; 151 | END computeUPER.GUI_RI; 152 | 153 | end AADL_PI_RI; 154 | -------------------------------------------------------------------------------- /tests-coverage/params: -------------------------------------------------------------------------------- 1 | # 2 | # This is an example parameter file 3 | # 4 | SubsystemName=mytestsubsystem 5 | SubsystemTool=Simulink 6 | AsnGrammar=DataTypesSimulink.asn 7 | InParam=my_in_AType:AType 8 | InParam=my_in_TypeEnumerated:TypeEnumerated 9 | InParam=my_in_TypeNested:TypeNested 10 | InParam=my_in_T_POS:T-POS 11 | InParam=my_in_T_POS_SET:T-POS-SET 12 | InParam=my_in_T_ARR:T-ARR 13 | InParam=my_in_T_ARR2:T-ARR2 14 | InParam=my_in_T_ARR3:T-ARR3 15 | InParam=my_in_T_ARR4:T-ARR4 16 | InParam=my_in_T_SET:T-SET 17 | InParam=my_in_T_SETOF:T-SETOF 18 | InParam=my_in_T_BOOL:T-BOOL 19 | InParam=my_in_T_INT:T-INT 20 | InParam=my_in_T_REAL:T-REAL 21 | InParam=my_in_T_STRING:T-STRING 22 | InParam=my_in_T_META:T-META 23 | OutParam=my_out_AType:AType 24 | OutParam=my_out_TypeEnumerated:TypeEnumerated 25 | OutParam=my_out_TypeNested:TypeNested 26 | OutParam=my_out_T_POS:T-POS 27 | OutParam=my_out_T_POS_SET:T-POS-SET 28 | OutParam=my_out_T_ARR:T-ARR 29 | OutParam=my_out_T_ARR2:T-ARR2 30 | OutParam=my_out_T_ARR3:T-ARR3 31 | OutParam=my_out_T_ARR4:T-ARR4 32 | OutParam=my_out_T_SET:T-SET 33 | OutParam=my_out_T_SETOF:T-SETOF 34 | OutParam=my_out_T_BOOL:T-BOOL 35 | OutParam=my_out_T_INT:T-INT 36 | OutParam=my_out_T_REAL:T-REAL 37 | OutParam=my_out_T_STRING:T-STRING 38 | OutParam=my_out_T_META:T-META 39 | -------------------------------------------------------------------------------- /tests-coverage/review.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -w 2 | use strict; 3 | 4 | use Term::ANSIColor; 5 | 6 | while(<>) { 7 | if (/pragma: no cover/) { 8 | print color 'reset'; 9 | print substr($_, 2); 10 | } elsif (/^!/) { 11 | print color 'bold green'; 12 | print substr($_, 2); 13 | } else { 14 | print color 'reset'; 15 | print substr($_, 2); 16 | } 17 | } 18 | print color 'reset'; 19 | -------------------------------------------------------------------------------- /tests-sqlalchemy/.gitignore: -------------------------------------------------------------------------------- 1 | asn2dataModel 2 | -------------------------------------------------------------------------------- /tests-sqlalchemy/LotsOfDataTypes.asn: -------------------------------------------------------------------------------- 1 | MY-MODULE DEFINITIONS AUTOMATIC TAGS ::= BEGIN 2 | 3 | -- Original definition by Alain 4 | --T-POS ::= BOOLEAN 5 | 6 | MyInt ::= INTEGER (0 .. 20) 7 | 8 | My2ndInt ::= MyInt ( 1 .. 18) 9 | 10 | MySeq ::= SEQUENCE { 11 | anInt MyInt, 12 | anotherInt My2ndInt 13 | } 14 | 15 | MyChoice ::= CHOICE { 16 | anInt MyInt, 17 | aReal REAL (0.0 .. 10.0) 18 | } 19 | 20 | AType ::= SEQUENCE { 21 | blArray SEQUENCE (SIZE(10)) OF BOOLEAN 22 | } 23 | 24 | MySuperSeq ::= SEQUENCE { 25 | aSeq MySeq, 26 | anotherSeq MySeq, 27 | anArray T-ARR3, 28 | aString OCTET STRING (SIZE(1..10)) 29 | } 30 | 31 | My2ndAType ::= AType 32 | 33 | TypeEnumerated ::= ENUMERATED { 34 | red(0), 35 | green(1), 36 | blue(2) 37 | } 38 | 39 | My2ndEnumerated ::= TypeEnumerated 40 | 41 | TypeNested ::= SEQUENCE { 42 | intVal INTEGER(0..10), 43 | int2Val INTEGER(-10..10), 44 | int3Val MyInt (10..12), 45 | intArray SEQUENCE (SIZE (10)) OF INTEGER (0..3), 46 | realArray SEQUENCE (SIZE (10)) OF REAL (0.1 .. 3.14), 47 | octStrArray SEQUENCE (SIZE (10)) OF OCTET STRING (SIZE(1..10)), 48 | boolArray SEQUENCE (SIZE (10)) OF T-BOOL, 49 | enumArray SEQUENCE (SIZE (10)) OF TypeEnumerated, 50 | enumValue TypeEnumerated, 51 | enumValue2 ENUMERATED { 52 | truism(0), 53 | falsism(1) 54 | }, 55 | label OCTET STRING (SIZE(10..40)), 56 | bAlpha T-BOOL, 57 | bBeta BOOLEAN, 58 | sString T-STRING, 59 | arr T-ARR, 60 | arr2 T-ARR2 61 | } 62 | 63 | My2ndTypeNested ::= TypeNested 64 | 65 | T-POS ::= CHOICE { 66 | longitude REAL(-180.0..180.0), 67 | latitude REAL(-90.0..90.0), 68 | height REAL(30000.0..45000.0), 69 | subTypeArray SEQUENCE (SIZE(10..15)) OF TypeNested, 70 | label OCTET STRING (SIZE(50)), 71 | intArray T-ARR, 72 | myIntSet T-SET, 73 | myIntSetOf T-SETOF, 74 | anInt My2ndInt 75 | } 76 | 77 | T-POS-SET ::= SET { 78 | longitude REAL(-180.0..180.0), 79 | latitude REAL(-90.0..90.0), 80 | height REAL(30000.0..45000.0), 81 | subTypeArray SEQUENCE (SIZE(10..15)) OF TypeNested, 82 | label OCTET STRING (SIZE(20..50)), 83 | intArray T-ARR, 84 | myIntSet T-SET, 85 | myIntSetOf T-SETOF 86 | 87 | } 88 | 89 | T-ARR ::= SEQUENCE (SIZE (5..6)) OF INTEGER (0..32764) 90 | 91 | My2ndArr ::= T-ARR 92 | 93 | T-ARR2 ::= SEQUENCE (SIZE (5..6)) OF REAL (0.1 .. 4.2) 94 | 95 | T-ARR3 ::= SEQUENCE (SIZE (5..6)) OF SEQUENCE (SIZE(7)) OF REAL (0.1 .. 39.2) 96 | 97 | T-ARR4 ::= SEQUENCE (SIZE (5..6)) OF SEQUENCE (SIZE(7)) OF REAL (0.1 .. 4.3) 98 | 99 | T-SET ::= SET { 100 | data1 INTEGER(0..131071), 101 | data2 REAL(-100.0 .. 10.0), 102 | data3 INTEGER(-1024..1024), 103 | data4 INTEGER(-1310720..131071) 104 | } 105 | 106 | T-SETOF ::= SET (SIZE (5..6)) OF INTEGER (0..4) 107 | 108 | T-BOOL ::= BOOLEAN 109 | 110 | My2ndBool ::= T-BOOL 111 | 112 | T-INT ::= INTEGER (0..50) 113 | T-REAL ::= REAL (-3.14..3.14) 114 | My2ndReal ::= T-REAL 115 | T-STRING ::= OCTET STRING (SIZE(10..15)) 116 | My2ndString ::= T-STRING 117 | T-FIXEDSTRING ::= OCTET STRING (SIZE(15)) 118 | 119 | T-META ::= T-POS 120 | 121 | END 122 | -------------------------------------------------------------------------------- /tests-sqlalchemy/Makefile: -------------------------------------------------------------------------------- 1 | all: cleanDB test 2 | 3 | cleanDB: 4 | # PostgreSQL 5 | /etc/init.d/postgresql restart 6 | # Since postgres takes a while to start, do this until it succeeds 7 | bash -c "while true ; do echo 'drop database if exists circle_test; create database circle_test;' | psql -h 127.0.0.1 -U ubuntu postgres && break ; done" 8 | rm -f sql.log 9 | # 10 | # MySQL (is a toy - disabled related tests) 11 | # echo 'drop database test; create database test;' | mysql -u taste || exit 1 12 | # 13 | # SQLite 14 | rm -f test.db 15 | 16 | clean: 17 | rm -rf asn2dataModel lotsofdatatypes_model.* */*.pyc .coverage 18 | $(MAKE) cleanDB 19 | 20 | build: 21 | if [ ! -d asn2dataModel ] ; then mkdir -p asn2dataModel ; LC_ALL=C asn2dataModel -o asn2dataModel -toPython LotsOfDataTypes.asn ; fi 22 | cd asn2dataModel || exit 1 && make -f Makefile.python 23 | LC_ALL=C asn2dataModel -toSqlalchemy -o asn2dataModel/ LotsOfDataTypes.asn 24 | 25 | debug: |build 26 | ipdb -m ./testSQLengines.py 27 | 28 | test: |build 29 | ./testSQLengines.py 30 | 31 | print: 32 | @for i in MyInt My2ndInt MySeq MyChoice TypeEnumerated MySuperSeq T_ARR T_ARR_indexes T_ARR_elm ; do \ 33 | echo "========" ; \ 34 | echo PostgreSQL Content of $$i ; \ 35 | echo "========" ; \ 36 | echo "select * from \"$$i\" " | psql -h 127.0.0.1 -U ubuntu circle_test ; \ 37 | done 38 | # @for i in MyInt My2ndInt MySeq MyChoice TypeEnumerated MySuperSeq T_ARR T_ARR_indexes T_ARR_elm ; do \ 39 | # echo "========" ; \ 40 | # echo MySQL Content of $$i ; \ 41 | # echo "========" ; \ 42 | # echo "select * from $$i " | mysql -u taste test ; \ 43 | # done | less 44 | @for i in MyInt My2ndInt MySeq MyChoice TypeEnumerated MySuperSeq T_ARR T_ARR_indexes T_ARR_elm ; do \ 45 | echo "========" ; \ 46 | echo SQLite Content of $$i ; \ 47 | echo "========" ; \ 48 | echo "select * from $$i ;" | sqlite3 test.db ; \ 49 | done 50 | -------------------------------------------------------------------------------- /tests-sqlalchemy/commonTests.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import math 3 | 4 | from sqlalchemy import exc 5 | 6 | sys.path.append("asn2dataModel") 7 | import DV 8 | from lotsofdatatypes_model import ( 9 | MyInt_SQL, My2ndInt_SQL, MySeq_SQL, TypeEnumerated_SQL, T_ARR_SQL, 10 | MySuperSeq_SQL, MyChoice_SQL, TypeNested_SQL) 11 | from LotsOfDataTypes_asn import ( 12 | MyInt, My2ndInt, MySeq, TypeEnumerated, T_ARR, MySuperSeq, MyChoice, 13 | TypeNested 14 | ) 15 | 16 | 17 | class AllTests: 18 | def test1_Integer(self): 19 | a = MyInt() 20 | a.Set(2) 21 | aa1 = MyInt_SQL(a) 22 | aid1 = aa1.save(self.session) 23 | self.session.commit() 24 | o1 = MyInt_SQL.loadFromDB(self.session, aid1) 25 | assert a.Get() == o1.data 26 | assert a.Get() == o1.asn1.Get() 27 | 28 | def test2_IntegerWithOverridenConstraints(self): 29 | a = My2ndInt() 30 | a.Set(20) # Valid in referenced type, but overriden in this one 31 | bMustFailAndHasFailed = False 32 | try: 33 | aa2 = My2ndInt_SQL(a) 34 | aid2 = aa2.save(self.session) 35 | except exc.IntegrityError: 36 | bMustFailAndHasFailed = True 37 | assert bMustFailAndHasFailed 38 | self.session.rollback() 39 | a.Set(7) 40 | aa2 = My2ndInt_SQL(a) 41 | aid2 = aa2.save(self.session) 42 | self.session.commit() 43 | o2 = My2ndInt_SQL.loadFromDB(self.session, aid2) 44 | assert a.Get() == o2.data 45 | assert a.Get() == o2.asn1.Get() 46 | 47 | def test3_SimpleSequence(self): 48 | b = MySeq() 49 | b.anInt.Set(16) 50 | b.anotherInt.Set(17) 51 | bb = MySeq_SQL(b) 52 | bid = bb.save(self.session) 53 | self.session.commit() 54 | z = MySeq_SQL.loadFromDB(self.session, bid) 55 | # Via SQLAlchemy 56 | assert b.anInt.Get() == z.anInt.data 57 | assert b.anotherInt.Get() == z.anotherInt.data 58 | # Via ASN.1 59 | assert b.anInt.Get() == z.asn1.anInt.Get() 60 | assert b.anotherInt.Get() == z.asn1.anotherInt.Get() 61 | 62 | def test4_Choice(self): 63 | g = MyChoice() 64 | g.kind.Set(DV.MyChoice_anInt_PRESENT) 65 | g.anInt.Set(12) 66 | gg = MyChoice_SQL(g) 67 | gid = gg.save(self.session) 68 | self.session.commit() 69 | r = MyChoice_SQL.loadFromDB(self.session, gid) 70 | assert g.kind.Get() == r.kind 71 | assert g.anInt.Get() == r.anInt.data 72 | assert g.kind.Get() == r.asn1.kind.Get() 73 | assert g.anInt.Get() == r.asn1.anInt.Get() 74 | 75 | def test5_Enumerated(self): 76 | c = TypeEnumerated() 77 | c.Set(TypeEnumerated.blue) 78 | cc = TypeEnumerated_SQL(c) 79 | cid = cc.save(self.session) 80 | self.session.commit() 81 | w = TypeEnumerated_SQL.loadFromDB(self.session, cid) 82 | assert c.Get() == w.data 83 | assert c.Get() == w.asn1.Get() 84 | 85 | def test6_ArrayOfInts(self): 86 | e = T_ARR() 87 | e.SetLength(6) 88 | for i in xrange(6): 89 | e[i].Set(i*3) 90 | ee = T_ARR_SQL(e) 91 | eid = ee.save(self.session) 92 | self.session.commit() 93 | x = T_ARR_SQL.loadFromDB(self.session, eid) 94 | xa = x.asn1 95 | for idx, idxObj in enumerate(x.arrIndexes_T_ARR): 96 | assert e[idx].Get() == idxObj.data.data 97 | assert e[idx].Get() == xa[idx].Get() 98 | 99 | def test7_ComplexTypeWithNestedNestedArrays(self): 100 | d = MySuperSeq() 101 | d.aSeq.anInt.Set(11) 102 | d.aSeq.anotherInt.Set(12) 103 | d.anotherSeq.anInt.Set(13) 104 | d.anotherSeq.anotherInt.Set(14) 105 | d.anArray.SetLength(6) 106 | for i in xrange(6): 107 | #d.anArray[i].SetLength(7) 108 | for j in xrange(7): 109 | d.anArray[i][j].Set(i*j + 0.5) 110 | d.aString.SetFromPyString("Hello") 111 | dd = MySuperSeq_SQL(d) 112 | did = dd.save(self.session) 113 | self.session.commit() 114 | 115 | y = MySuperSeq_SQL.loadFromDB(self.session, did) 116 | assert d.aSeq.anInt.Get() == y.aSeq.anInt.data 117 | assert d.aSeq.anotherInt.Get() == y.aSeq.anotherInt.data 118 | assert d.anotherSeq.anInt.Get() == y.anotherSeq.anInt.data 119 | assert d.anotherSeq.anotherInt.Get() == y.anotherSeq.anotherInt.data 120 | assert d.aString.GetPyString() == y.aString.data 121 | 122 | yy = y.asn1 123 | assert d.aSeq.anInt.Get() == yy.aSeq.anInt.Get() 124 | assert d.aSeq.anotherInt.Get() == yy.aSeq.anotherInt.Get() 125 | assert d.anotherSeq.anInt.Get() == yy.anotherSeq.anInt.Get() 126 | assert d.anotherSeq.anotherInt.Get() == yy.anotherSeq.anotherInt.Get() 127 | assert d.anArray.GetLength() == yy.anArray.GetLength() 128 | for i in xrange(6): 129 | assert d.anArray[i].GetLength() == yy.anArray[i].GetLength() 130 | for j in xrange(7): 131 | assert d.anArray[i][j].Get() == yy.anArray[i][j].Get() 132 | assert d.aString.GetPyString() == yy.aString.GetPyString() 133 | 134 | def test8_VeryComplexType(self): 135 | e = TypeNested() 136 | e.intVal.Set(5), 137 | e.int2Val.Set(-10) 138 | e.int3Val.Set(12) 139 | for i in xrange(10): 140 | e.intArray[i].Set(i%4) 141 | e.realArray[i].Set(0.1+0.1*i) 142 | e.octStrArray[i].SetFromPyString('hello' + str(i)) 143 | e.boolArray[i].Set(i%2 != 0) 144 | e.enumArray[i].Set(TypeEnumerated.blue) 145 | e.enumValue.Set(TypeEnumerated.red) 146 | e.enumValue2.Set(DV.truism) 147 | e.label.SetFromPyString("Well, this is nice") 148 | e.bAlpha.Set(False) 149 | e.bBeta.Set(True) 150 | e.sString.SetFromPyString("Another string") 151 | e.arr.SetLength(5) 152 | e.arr2.SetLength(5) 153 | for i in xrange(5): 154 | e.arr[i].Set(41*i) 155 | e.arr2[i].Set(0.1+0.1*i) 156 | ee = TypeNested_SQL(e) 157 | eid = ee.save(self.session) 158 | self.session.commit() 159 | 160 | f = TypeNested_SQL.loadFromDB(self.session, eid) 161 | ff = f.asn1 162 | assert e.intVal.Get() == ff.intVal.Get() 163 | assert e.int2Val.Get() == ff.int2Val.Get() 164 | assert e.int3Val.Get() == ff.int3Val.Get() 165 | for i in xrange(10): 166 | assert e.intArray[i].Get() == ff.intArray[i].Get() 167 | assert math.fabs(e.realArray[i].Get() - ff.realArray[i].Get())<1e-10 168 | assert e.octStrArray[i].GetPyString() == ff.octStrArray[i].GetPyString() 169 | assert e.boolArray[i].Get() == ff.boolArray[i].Get() 170 | assert e.enumArray[i].Get() == ff.enumArray[i].Get() 171 | assert e.enumValue.Get() == ff.enumValue.Get() 172 | assert e.enumValue2.Get() == ff.enumValue2.Get() 173 | assert e.label.GetPyString() == ff.label.GetPyString() 174 | assert e.bAlpha.Get() == ff.bAlpha.Get() 175 | assert e.bBeta.Get() == ff.bBeta.Get() 176 | assert e.sString.GetPyString() == ff.sString.GetPyString() 177 | assert ff.arr.GetLength() == 5 178 | assert ff.arr2.GetLength() == 5 179 | for i in xrange(5): 180 | assert e.arr[i].Get() == ff.arr[i].Get() 181 | assert math.fabs(e.arr2[i].Get() - ff.arr2[i].Get()) < 1e-10 182 | -------------------------------------------------------------------------------- /tests-sqlalchemy/diagram.py: -------------------------------------------------------------------------------- 1 | from sqlalchemy import MetaData 2 | from sqlalchemy_schemadisplay import create_schema_graph 3 | 4 | # create the pydot graph object by autoloading all tables via a bound metadata object 5 | graph = create_schema_graph(metadata=MetaData('postgresql+psycopg2://taste:tastedb@localhost/test'), 6 | show_datatypes=False, # The image would get nasty big if we'd show the datatypes 7 | show_indexes=False, # ditto for indexes 8 | rankdir='LR', # From left to right (instead of top to bottom) 9 | concentrate=False # Don't try to join the relation lines together 10 | ) 11 | graph.write_png('/home/assert/Desktop/C_DRIVE/work/dbschema.png') # write out the file 12 | -------------------------------------------------------------------------------- /tests-sqlalchemy/testSQLengines.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2 2 | import os 3 | import sys 4 | sys.path.append("asn2dataModel") 5 | 6 | import logging 7 | import unittest 8 | 9 | from sqlalchemy import create_engine 10 | 11 | from commonTests import AllTests 12 | from lotsofdatatypes_model import Base 13 | 14 | from lotsofdatatypes_model import My2ndInt_SQL 15 | from LotsOfDataTypes_asn import My2ndInt 16 | 17 | logging.basicConfig(filename="sql.log") 18 | logging.getLogger('sqlalchemy.engine').setLevel(logging.INFO) 19 | 20 | 21 | class CompleteTestingOfSQLMapperWithSQLite(AllTests, unittest.TestCase): 22 | #engine = create_engine('sqlite:///:memory:', echo=True) 23 | engine = create_engine('sqlite:///test.db', echo=False) 24 | Base.metadata.create_all(engine) 25 | from sqlalchemy.orm import sessionmaker 26 | 27 | SessionFactory = sessionmaker(bind=engine) 28 | session = SessionFactory() 29 | 30 | 31 | class CompleteTestingOfSQLMapperWithPostgreSQL(AllTests, unittest.TestCase): 32 | #engine = create_engine('sqlite:///:memory:', echo=True) 33 | if os.getenv('CIRCLECI') is None: 34 | dburi = 'postgresql+psycopg2://taste:tastedb@localhost/circle_test' 35 | else: 36 | dburi = 'postgresql+psycopg2://ubuntu:tastedb@localhost/circle_test' 37 | engine = create_engine(dburi, echo=False) 38 | Base.metadata.create_all(engine) 39 | from sqlalchemy.orm import sessionmaker 40 | 41 | SessionFactory = sessionmaker(bind=engine) 42 | session = SessionFactory() 43 | 44 | 45 | #jclass CompleteTestingOfSQLMapperWithMySQL(AllTests, unittest.TestCase): 46 | #j #engine = create_engine('sqlite:///:memory:', echo=True) 47 | #j engine = create_engine( 48 | #j 'mysql://taste:tastedb@localhost/test', echo=False) 49 | #j Base.metadata.create_all(engine) 50 | #j from sqlalchemy.orm import sessionmaker 51 | #j 52 | #j SessionFactory = sessionmaker(bind=engine) 53 | #j session = SessionFactory() 54 | #j 55 | #j def test2_IntegerWithOverridenConstraints(self): 56 | #j a = My2ndInt() 57 | #j # 58 | #j # MySQL does not enforce range constraints. 59 | #j # Stupid DB engine... 60 | #j # 61 | #j ##a.Set(20) # Valid in referenced type, but overriden in this one 62 | #j ##bMustFailAndHasFailed = False 63 | #j ##try: 64 | #j ## aa2 = My2ndInt_SQL(a) 65 | #j ## aid2 = aa2.save(self.session) 66 | #j ##except exc.IntegrityError: 67 | #j ## bMustFailAndHasFailed = True 68 | #j ##assert bMustFailAndHasFailed 69 | #j self.session.rollback() 70 | #j a.Set(7) 71 | #j aa2 = My2ndInt_SQL(a) 72 | #j aid2 = aa2.save(self.session) 73 | #j self.session.commit() 74 | #j o2 = My2ndInt_SQL.loadFromDB(self.session, aid2) 75 | #j assert a.Get() == o2.data 76 | #j assert a.Get() == o2.asn1.Get() 77 | 78 | 79 | if __name__ == "__main__": 80 | unittest.main() 81 | --------------------------------------------------------------------------------