Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop-cfs-spec' into develop. Close #252.
**Description** The cFS backend is lacking in features when compared with other backends like ROS and F'. In particular, it doesn't accept a specification as input, which means that the user must take an additional step of extracting the variable names and handlers from the spec before using the `cfs` command. The `cfs` command should accept the same flags as other commands like `ros` and `fprime`, use an input spec if provided, and accept selecting the format for the file and the properties, as well as an external pre-filter or pre-processor. **Type** - Feature: Add to cFS backend features available in other backends. **Additional context** None. **Requester** - Ivan Perez. **Method to check presence of bug** Not applicable (not a bug). **Expected result** The `cfs` command accepts the same flags as other commands like `ros` and `fprime`, uses an input spec if provided to determine the variables and handlers to use in the cFS application, accepts selecting the format for the file and the properties, and can filter properties via an external pre-filter. The following dockerfile checks that the `cfs` command now accepts a spec as input file, as well as the file format and property format flags, and that a variables or handlers file are no longer required, and that the generated cFS app mentions both the property name listed in the original spec and the input required by that property, after which it prints the message "Success": ``` --- Dockerfile-252 FROM ubuntu:focal ENV DEBIAN_FRONTEND=noninteractive RUN apt-get update RUN apt-get install --yes \ curl g++ gcc git libgmp3-dev libz-dev make pkg-config RUN mkdir -p $HOME/.local/bin ENV PATH=$PATH:/root/.local/bin/ RUN curl https://downloads.haskell.org/~ghcup/0.1.17.7/x86_64-linux-ghcup-0.1.17.7 -o $HOME/.local/bin/ghcup RUN chmod a+x $HOME/.local/bin/ghcup ENV PATH=$PATH:/root/.ghcup/bin/ RUN ghcup install ghc 9.10 RUN ghcup install cabal 3.12 RUN ghcup set ghc 9.10.1 RUN cabal update ADD document.json /tmp/document.json ADD json-format.cfg /tmp/json-format.cfg ADD cfs-variable-db /tmp/cfs-variable-db SHELL ["/bin/bash", "-c"] CMD git clone $REPO \ && cd $NAME \ && git checkout $COMMIT \ && cabal install ogma-cli:ogma \ && ogma cfs --input-file /tmp/document.json --variable-db /tmp/cfs-variable-db --app-target-dir cfs/ --input-format /tmp/json-format.cfg --prop-format literal \ && grep -q '^position_t position;' cfs/fsw/src/copilot_cfs.c \ && grep -q 'PositionSafe' cfs/fsw/src/copilot_cfs.c \ && echo "Complete Success" --- document.json { "Example": { "internal_variables": [], "external_variables": [ {"name":"position", "type":"position_t", "meaning": "Position of the vehicle"} ], "properties": [ { "id": "PositionSafe", "formula": "PTLTL.alwaysBeen (position # x < 100 && position # y < 100)", "text": "The vehicle stays withing a rectangle with side 100 meters" } ] } } --- json-format.cfg JSONFormat { specInternalVars = Just "..internal_variables[*]" , specInternalVarId = ".name" , specInternalVarExpr = ".meaning" , specInternalVarType = Just ".type" , specExternalVars = Just "..external_variables[*]" , specExternalVarId = ".name" , specExternalVarType = Just ".type" , specRequirements = "..properties[*]" , specRequirementId = ".id" , specRequirementDesc = Just ".text" , specRequirementExpr = ".formula" } --- cfs-variable-db ("position", "position_t", "POSITION_MID", "Position") ``` Command (substitute variables based on new path after merge): ```sh $ docker run -e "REPO=https://github.com/NASA/ogma" -e "NAME=ogma" -e "COMMIT=<HASH>" -it ogma-verify-252 ``` **Solution implemented** Modify cFS backend in `ogma-core` by porting over features from the ROS and FPrime backends to read and process input specifications. Modify cFS CLI to expose new arguments, and remove default value from argument that is no longer mandatory. Update README to document the new arguments available. **Further notes** None.
- Loading branch information