├── .github └── workflows │ ├── mac.yml │ ├── main.yml │ └── windows.yml ├── .gitignore ├── .gitmodules ├── CMakeLists.txt ├── LICENSE ├── README.md ├── README_MAC.md ├── bcgconv ├── CMakeLists.txt ├── bcg2jani.c ├── bcg2tralab.cpp └── maxprog.cpp ├── compiletime.cmake ├── dft2lnt ├── ASTDFTBuilder.h ├── ASTLNTBuilder.h ├── ASTPrinter.h ├── ASTValidator.h ├── ASTVisitor.h ├── CADP.cpp ├── CADP.h ├── CMakeLists.txt ├── ConsoleWriter.cpp ├── ConsoleWriter.h ├── DFTCalculationResult.cpp ├── DFTCalculationResult.h ├── DFTree.cpp ├── DFTree.h ├── DFTreePrinter.cpp ├── DFTreePrinter.h ├── DFTreeValidator.cpp ├── DFTreeValidator.h ├── FileSystem.cpp ├── FileSystem.h ├── FileWriter.cpp ├── FileWriter.h ├── MessageFormatter.cpp ├── MessageFormatter.h ├── Settings.h ├── Shell.cpp ├── Shell.h ├── System.cpp ├── System.h ├── compiler.cpp ├── compiler.h ├── decnumber.h ├── dft2lnt.cpp ├── dft2lnt.h ├── dft_ast.cpp ├── dft_ast.h ├── dft_parser.cpp ├── dft_parser.h ├── dft_parser_location.h ├── dft_types.h ├── dftnodes │ ├── .DS_Store │ ├── BasicEvent.cpp │ ├── BasicEvent.h │ ├── Gate.h │ ├── GateAnd.h │ ├── GateFDEP.h │ ├── GateOr.h │ ├── GatePAnd.h │ ├── GatePor.h │ ├── GateSAnd.h │ ├── GateSEQ.h │ ├── GateVoting.h │ ├── GateWSP.h │ ├── Inspection.h │ ├── Node.cpp │ ├── Node.h │ ├── RepairUnit.h │ ├── Replacement.h │ └── nodes.h ├── files.cpp ├── files.h ├── lexer.l.lpp ├── parser.y.ypp ├── query.h └── yyheader.h ├── dft2lntc ├── CMakeLists.txt ├── DFTreeAUTNodeBuilder.cpp ├── DFTreeAUTNodeBuilder.h ├── DFTreeBCGNodeBuilder.cpp ├── DFTreeBCGNodeBuilder.h ├── DFTreeEXPBuilder.cpp ├── DFTreeEXPBuilder.h ├── DFTreeNodeBuilder.cpp ├── DFTreeNodeBuilder.h ├── automata │ ├── automata.cpp │ ├── automata.h │ ├── automaton.cpp │ ├── automaton.h │ ├── be.cpp │ ├── be.h │ ├── fdep.cpp │ ├── fdep.h │ ├── insp.cpp │ ├── insp.h │ ├── pand.cpp │ ├── pand.h │ ├── signals.h │ ├── spare.cpp │ ├── spare.h │ ├── voting.cpp │ └── voting.h ├── dft2lntc.cpp ├── modularize.cpp └── modularize.h ├── dftcalc ├── CMakeLists.txt ├── checker.h ├── dftcalc.cpp ├── dftcalc.h ├── executor.cpp ├── executor.h ├── imca.cpp ├── imca.h ├── modest.cpp ├── modest.h ├── mrmc.cpp ├── mrmc.h ├── storm.cpp └── storm.h ├── dfttest ├── CMakeLists.txt ├── TestOutput.cpp ├── TestOutput.h ├── TestResult.cpp ├── TestResult.h ├── TestRun.cpp ├── TestRun.h ├── dfttest.cpp ├── dfttest.h ├── test.cpp └── test.h ├── package ├── debian │ ├── changelog │ ├── compat │ ├── control │ ├── copyright │ ├── rules │ └── source │ │ └── format └── dftcalc.spec ├── puptol ├── bin │ └── scripts │ │ └── dftcalc │ │ ├── dodftcalc.sh │ │ ├── downloaddatasets.sh │ │ ├── plotandstore.sh │ │ ├── plotdatasets.sh │ │ ├── settings │ │ └── topng.sh ├── data │ └── shared │ │ └── dftcalc │ │ ├── README │ │ ├── cases │ │ ├── cas.dft │ │ ├── mcs.dft │ │ └── mcs_4CM.dft │ │ ├── erl2_2.bcg │ │ ├── example.dft │ │ ├── ftpp4.dft │ │ ├── prob.txt │ │ ├── repair.dft │ │ ├── reuse.dft │ │ ├── test1.dft │ │ ├── test1_err.dft │ │ ├── test2.dft │ │ ├── test3.dft │ │ └── test_all.dft ├── html │ └── dftcalc │ │ ├── css │ │ ├── font-awesome.min.css │ │ ├── skel.css │ │ ├── style-mobile.css │ │ ├── style-mobilep.css │ │ ├── style-narrow.css │ │ ├── style-narrower.css │ │ ├── style-normal.css │ │ ├── style-wide.css │ │ └── style.css │ │ ├── files │ │ └── fmt-logo.png │ │ ├── fonts │ │ ├── fontawesome-webfont.eot │ │ ├── fontawesome-webfont.ttf │ │ └── fontawesome-webfont.woff │ │ ├── index.html │ │ ├── js │ │ ├── init.js │ │ ├── jquery.dropotron.min.js │ │ ├── jquery.min.js │ │ ├── jquery.scrollgress.min.js │ │ ├── jquery.scrolly.min.js │ │ ├── jquery.scrollzer.min.js │ │ ├── skel-layers.min.js │ │ └── skel.min.js │ │ └── play │ │ ├── markup.css │ │ └── style.css └── json │ ├── dftcalc-scen.json │ └── dftcalc.json ├── share ├── CMakeLists.txt └── dft2lnt │ ├── CMakeLists.txt │ ├── lntnodes │ ├── TEMPLATE_BE.lnt │ ├── TEMPLATE_BE_DUMMY.lnt │ ├── TEMPLATE_COMMON.lnt │ ├── TEMPLATE_COMMON_APH_REPAIR.lnt │ ├── TEMPLATE_COMMON_REPAIR.lnt │ ├── TEMPLATE_FDEP.lnt │ ├── TEMPLATE_INSPECTION.lnt │ ├── TEMPLATE_PAND.lnt │ ├── TEMPLATE_PAND_SMALL.lnt │ ├── TEMPLATE_PERIODIC_REPAIRUNIT.lnt │ ├── TEMPLATE_POR.lnt │ ├── TEMPLATE_REPAIRUNIT.lnt │ ├── TEMPLATE_REPAIRUNIT_ARB.lnt │ ├── TEMPLATE_REPAIRUNIT_ND.lnt │ ├── TEMPLATE_REPAIRUNIT_PRIO.lnt │ ├── TEMPLATE_SEQUENCE_AND.lnt │ ├── TEMPLATE_SPARE.lnt │ └── TEMPLATE_VOTING_REPAIR.lnt │ └── tests │ ├── and.dft │ ├── be.dft │ ├── cas.dft │ ├── cps.dft │ ├── deathegg.dft │ ├── dftsim.test │ ├── fdep.dft │ ├── ftpp_complex.dft │ ├── ftpp_large.dft │ ├── ftpp_standard.dft │ ├── ftpp_weibull.dft │ ├── mdcs.dft │ ├── mdcs2.dft │ ├── mp.dft │ ├── or.dft │ ├── pand.dft │ ├── simple.test │ ├── spare.dft │ ├── spare2.dft │ ├── spare3.dft │ ├── tripple.test │ ├── tripple_and.dft │ ├── tripple_and2.dft │ ├── tripple_and2_c.dft │ ├── tripple_and_c.dft │ ├── tripple_or.dft │ ├── tripple_or2.dft │ ├── tripple_or2_c.dft │ ├── tripple_or_c.dft │ ├── tripple_pand.dft │ ├── tripple_pand2.dft │ ├── tripple_pand2_c.dft │ ├── tripple_pand_c.dft │ └── voting.dft └── test ├── README ├── WQDN.dft ├── expect-fail.txt ├── repair-exact.dft ├── repair-exact2.dft ├── repair-pand.dft ├── repair-prob.dft ├── repair-res.dft ├── repair-spare.dft ├── simple-fdep.dft ├── test.ps1 ├── test.sh └── tests.txt /.github/workflows/mac.yml: -------------------------------------------------------------------------------- 1 | name: Compile and Test on MacOS 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | build: 7 | runs-on: macos-13 8 | steps: 9 | - uses: actions/checkout@v4 10 | - uses: actions/setup-java@v4 11 | with: 12 | java-version: 17 13 | distribution: temurin 14 | - name: Install dependencies 15 | run: brew install bison flex yaml-cpp gsl 16 | - name: Set environment variables 17 | run: | 18 | echo "NUMCORES=$(system_profiler SPHardwareDataType | grep 'Number of Cores' | grep -o '[[:digit:]]\+')" > $GITHUB_ENV 19 | echo /usr/local/opt/bison/bin >> $GITHUB_PATH 20 | echo /usr/local/opt/flex/bin >> $GITHUB_PATH 21 | echo ${{github.workspace}}/imrmc/bin >> $GITHUB_PATH 22 | echo ${{github.workspace}}/dftroot/bin >> $GITHUB_PATH 23 | - name: Prepare to build DFTCalc 24 | run: mkdir build && cd build && cmake -DDFTROOT=$GITHUB_WORKSPACE/dftroot .. 25 | - name: Compile DFTCalc 26 | run: cd build && make -j$NUMCORES install 27 | - name: Checkout DFTRES 28 | uses: actions/checkout@v4 29 | with: 30 | repository: utwente-fmt/DFTRES 31 | path: DFTRES 32 | - name: Get cache revisions 33 | id: cache-revs 34 | run: | 35 | cd DFTRES && echo "dftres=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT 36 | echo "imrmc=$(git ls-remote git://git.ennoruijters.nl/imrmc.git | grep '\srefs/heads/master$' | grep -o '^[0-9a-z]\+')" >> $GITHUB_OUTPUT 37 | - name: Cache DFTRES 38 | id: cache-dftres 39 | uses: actions/cache@v4 40 | with: 41 | path: DFTRES/DFTRES.jar 42 | key: ${{ runner.os }}-dftres-${{ steps.cache-revs.outputs.dftres }} 43 | - name: Compile DFTRES if needed 44 | if: steps.cache-dftres.outputs.cache-hit != 'true' 45 | run: cd DFTRES && make jar 46 | - name: Cache IMRMC 47 | id: cache-imrmc 48 | uses: actions/cache@v4 49 | with: 50 | path: imrmc/bin/imrmc 51 | key: ${{ runner.os }}-imrmc-${{ steps.cache-revs.outputs.imrmc }} 52 | - name: Checkout IMRMC 53 | if: steps.cache-imrmc.outputs.cache-hit != 'true' 54 | run: git clone --depth 1 git://git.ennoruijters.nl/imrmc.git imrmc 55 | - name: Compile IMRMC 56 | if: steps.cache-imrmc.outputs.cache-hit != 'true' 57 | run: cd imrmc && make all -j$NUMCORES 58 | - name: Tests 59 | env: 60 | DFTRES: ${{github.workspace}}/DFTRES 61 | run: cd test && bash test.sh --exact --imrmc 62 | - name: Upload artifacts 63 | uses: actions/upload-artifact@v4 64 | if: ${{ always() }} 65 | with: 66 | name: test-results 67 | path: test/output 68 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: Compile and Test 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | build: 7 | runs-on: ubuntu-22.04 8 | steps: 9 | - uses: actions/checkout@v4 10 | - uses: actions/setup-java@v4 11 | with: 12 | java-version: 17 13 | distribution: temurin 14 | - name: Ready dependencies 15 | run: | 16 | curl https://www.ennoruijters.nl/package.gpg | sudo apt-key add - 17 | echo "deb http://packages.ennoruijters.nl jammy main" | sudo tee -a /etc/apt/sources.list 18 | sudo apt update 19 | sudo apt-cache show storm | grep Version | sed -e 's/Version: /STORM_VERSION=/' >> $GITHUB_ENV 20 | sudo mkdir apt-archive 21 | - name: APT cache 22 | uses: actions/cache@v4 23 | with: 24 | path: apt-archive.tar 25 | key: ${{ runner.os }}-apt-${{ env.STORM_VERSION }} 26 | - name: Install dependencies 27 | run: | 28 | if [ -e apt-archive.tar ]; then sudo tar xf apt-archive.tar; fi 29 | sudo apt-get -o dir::cache=$GITHUB_WORKSPACE/apt-archive install libfl-dev libbison-dev libyaml-cpp-dev libgsl-dev storm 30 | sudo tar cf apt-archive.tar apt-archive/archives 31 | - name: Prepare to build DFTCalc 32 | run: mkdir build && cd build && cmake -DDFTROOT=$GITHUB_WORKSPACE/dftroot .. 33 | - name: Compile DFTCalc 34 | run: cd build && make -j4 install 35 | - name: Checkout DFTRES 36 | uses: actions/checkout@v4 37 | with: 38 | repository: utwente-fmt/DFTRES 39 | path: DFTRES 40 | - name: Set PATHs 41 | run: | 42 | echo ${{github.workspace}}/imrmc/bin >> $GITHUB_PATH 43 | echo ${{github.workspace}}/dftroot/bin >> $GITHUB_PATH 44 | - name: Get cache revisions 45 | id: cache-revs 46 | run: | 47 | cd DFTRES && echo "dftres=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT 48 | echo "imrmc=$(git ls-remote git://git.ennoruijters.nl/imrmc.git | grep '\srefs/heads/master$' | grep -o '^[0-9a-z]\+')" >> $GITHUB_OUTPUT 49 | echo "imrmc-march=$(gcc -march=native -E -v - &1 | grep cc1 | sha256sum | grep -o '^[0-9a-z]\+')" >> $GITHUB_OUTPUT 50 | - name: Cache DFTRES 51 | id: cache-dftres 52 | uses: actions/cache@v4 53 | with: 54 | path: DFTRES/DFTRES.jar 55 | key: ${{ runner.os }}-dftres-${{ steps.cache-revs.outputs.dftres }} 56 | - name: Compile DFTRES if needed 57 | if: steps.cache-dftres.outputs.cache-hit != 'true' 58 | run: cd DFTRES && make jar 59 | - name: Cache IMRMC 60 | id: cache-imrmc 61 | uses: actions/cache@v4 62 | with: 63 | path: imrmc/bin/imrmc 64 | key: ${{ runner.os }}-imrmc-${{ steps.cache-revs.outputs.imrmc }}-${{ steps.cache-revs.outputs.imrmc-march }} 65 | - name: Checkout IMRMC 66 | if: steps.cache-imrmc.outputs.cache-hit != 'true' 67 | run: git clone --depth 1 git://git.ennoruijters.nl/imrmc.git imrmc 68 | - name: Compile IMRMC 69 | if: steps.cache-imrmc.outputs.cache-hit != 'true' 70 | run: cd imrmc && make all -j4 71 | - name: Tests 72 | env: 73 | DFTRES: ${{github.workspace}}/DFTRES 74 | run: cd test && bash test.sh --exact --imrmc && bash test.sh --exact --storm && bash test.sh --storm 75 | - name: Upload artifacts 76 | uses: actions/upload-artifact@v4 77 | if: ${{ always() }} 78 | with: 79 | name: test-results 80 | path: test/output 81 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .cproject 2 | .project 3 | .settings 4 | CMakeCache.txt 5 | CMakeFiles 6 | Makefile 7 | project.* 8 | ./bin 9 | *.cmake 10 | install_manifest.txt 11 | yaml-cpp.pc 12 | yaml-cpp/libyaml-cpp.a 13 | dft2lnt/lexer.l.cpp 14 | dft2lnt/lexer.l.h 15 | dft2lnt/libdft2lnt.a 16 | dft2lnt/parser.y.cpp 17 | dft2lnt/parser.y.hpp 18 | dft2lnt/parser.y.output 19 | dft2lntc/compiletime.h 20 | dft2lntc/dft2lntc 21 | dftcalc/compiletime.h 22 | dftcalc/dftcalc 23 | dfttest/compiletime.h 24 | dfttest/dfttest 25 | test/output 26 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/utwente-fmt/dftcalc/aaaa84595404f4522a6d01718f45dd953184c92a/.gitmodules -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(dftcalc-suite) 2 | 3 | cmake_minimum_required(VERSION 3.0) 4 | 5 | if(CMAKE_BUILD_TYPE STREQUAL "") 6 | message("Defaulting to Release configuration") 7 | set(CMAKE_BUILD_TYPE "Release") 8 | endif() 9 | 10 | message("Building configuration: ${CMAKE_BUILD_TYPE}") 11 | if(CMAKE_BUILD_TYPE STREQUAL "Debug") 12 | add_definitions(-DDEBUG=1 -DYYDEBUG=1) 13 | set (BISON_CFLAGS "${BISON_CFLAGS} --verbose") 14 | endif() 15 | 16 | set(DFTROOT "/opt/dft2lntroot" CACHE PATH "") 17 | 18 | message(STATUS "NOTE: When installed, dft2lnt will be installed in ${DFTROOT}") 19 | message(STATUS " You can change this behaviour by running cmake with:") 20 | message(STATUS " -DDFTROOT=/path/to/dft2lntroot") 21 | 22 | add_subdirectory(dft2lnt) 23 | add_subdirectory(dft2lntc) 24 | add_subdirectory(dftcalc) 25 | add_subdirectory(dfttest) 26 | if(DEFINED ENV{CADP}) 27 | add_subdirectory(bcgconv) 28 | endif() 29 | add_subdirectory(share) 30 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012-2019 University of Twente 2 | Copyright (c) 2019-2021 Enno Ruijters 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all 12 | copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | SOFTWARE. 21 | -------------------------------------------------------------------------------- /README_MAC.md: -------------------------------------------------------------------------------- 1 | # Compilation on MacOS (tested on Catalina): 2 | 3 | ## Compiling DFTCalc 4 | 5 | - Install XCode from the App Store to install the compiler etc. 6 | 7 | - XCode ships with out-of-date versions of bison and flex, and does not 8 | include cmake and yaml-cpp. To install (current versions of) the 9 | dependencies: 10 | - Install [Homebrew](https://brew.sh/) 11 | - Run `brew install cmake yaml-cpp flex bison` 12 | - Follow Brew's instruction and put into `~/.zshrc`: 13 | ``` 14 | export PATH="/usr/local/opt/bison/bin:/usr/local/opt/flex/bin:$PATH" 15 | ``` 16 | 17 | - Compile and install as usual 18 | ``` 19 | mkdir build && cd build && cmake -DDFTROOT=/usr/local .. && make && sudo make install 20 | ``` 21 | 22 | ## Compiling DFTRES 23 | 24 | - Obtain [DFTRES](https://github.com/utwente-fmt/DFTRES) 25 | - In DFTRES's folder, run `make jar` 26 | - Add to your `~/.zshrc`: 27 | ``` 28 | export DFTRES="" 29 | ``` 30 | 31 | ## Install [Storm](https://stormchecker.org) 32 | 33 | - Add the Storm homebrew /tap/ and install Storm 34 | ``` 35 | brew tap moves-rwth/storm 36 | brew install stormchecker 37 | ``` 38 | -------------------------------------------------------------------------------- /bcgconv/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project (bcgconv) 2 | set (bcg2jani_VERSION_MAJOR 1) 3 | set (bcg2jani_VERSION_MINOR 3) 4 | set (bcg2jani_VERSION_PATCH 4) 5 | 6 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -Wall -Wextra") 7 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -Wall -Wextra") 8 | 9 | include_directories($ENV{CADP}/incl) 10 | 11 | ## Specify the executable and its sources 12 | add_executable(bcg2jani bcg2jani.c) 13 | add_executable(bcg2tralab bcg2tralab.cpp) 14 | add_executable(maxprog maxprog.cpp) 15 | 16 | ## POST_BUILD: copy the executable to the bin/ folder 17 | set(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin) 18 | 19 | ## Installation 20 | install (TARGETS bcg2jani DESTINATION bin) 21 | install (TARGETS bcg2tralab DESTINATION bin) 22 | install (TARGETS maxprog DESTINATION bin) 23 | 24 | LINK_DIRECTORIES($ENV{CADP}) 25 | find_library(BCG_LIB BCG) 26 | find_library(BCG_IO_LIB BCG_IO) 27 | target_link_libraries(bcg2jani "${BCG_LIB}" "${BCG_IO_LIB}") 28 | target_link_libraries(bcg2tralab "${BCG_LIB}" "${BCG_IO_LIB}") 29 | target_link_libraries(maxprog "${BCG_LIB}" "${BCG_IO_LIB}") 30 | -------------------------------------------------------------------------------- /compiletime.cmake: -------------------------------------------------------------------------------- 1 | if (${NO_GIT}) 2 | set(GIT "GIT-NOTFOUND") 3 | else() 4 | find_program(GIT git) 5 | endif() 6 | 7 | if (${GIT} STREQUAL "GIT-NOTFOUND") 8 | set(git_output "UNKNOWN") 9 | set(git_changed 0) 10 | set(git_version "v${FALLBACK_VERSION}?") 11 | else() 12 | execute_process( 13 | COMMAND ${GIT} rev-parse --verify HEAD 14 | OUTPUT_VARIABLE git_output OUTPUT_STRIP_TRAILING_WHITESPACE 15 | ) 16 | execute_process( 17 | COMMAND ${GIT} describe HEAD 18 | OUTPUT_VARIABLE git_descr OUTPUT_STRIP_TRAILING_WHITESPACE 19 | ) 20 | execute_process( 21 | COMMAND ${GIT} diff --exit-code 22 | OUTPUT_QUIET 23 | ERROR_QUIET 24 | RESULT_VARIABLE git_changed 25 | ) 26 | set(git_version "*.*.*") 27 | execute_process( 28 | COMMAND ${GIT} describe --tags --match=v[0-9]* --abbrev=0 29 | OUTPUT_VARIABLE git_version OUTPUT_STRIP_TRAILING_WHITESPACE 30 | ) 31 | execute_process( 32 | COMMAND ${GIT} branch 33 | OUTPUT_VARIABLE git_test OUTPUT_STRIP_TRAILING_WHITESPACE 34 | ) 35 | 36 | if (git_version STREQUAL git_descr) 37 | else() 38 | set(git_version ${git_version}+) 39 | endif() 40 | endif() 41 | 42 | string(TIMESTAMP date "%Y-%m-%d %H:%M:%S") 43 | 44 | file(WRITE ${OUTPUT_FILE} 45 | "/** 46 | * Generated at compile time on ${date} 47 | */ 48 | #define DFT2LNTROOT \"${DFTROOT}\" 49 | #define COMPILETIME_DATE \"${date}\" 50 | #define COMPILETIME_GITREV \"${git_output}\" 51 | #define COMPILETIME_GITCHANGED ${git_changed} 52 | #define COMPILETIME_GITVERSION \"${git_version}\" 53 | ") 54 | -------------------------------------------------------------------------------- /dft2lnt/ASTLNTBuilder.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ASTLNTBuilder.h 3 | * 4 | * Part of dft2lnt library - a library containing read/write operations for DFT 5 | * files in Galileo format and translating DFT specifications into Lotos NT. 6 | * 7 | * @author Freark van der Berg 8 | */ 9 | 10 | #ifndef ASTLNTBUILDER_H 11 | #define ASTLNTBUILDER_H 12 | 13 | #include 14 | 15 | #include "dft_ast.h" 16 | #include "dft_parser.h" 17 | #include "ASTVisitor.h" 18 | 19 | namespace DFT { 20 | 21 | class ASTLNTBuilder: public DFT::ASTVisitor { 22 | private: 23 | DFT::AST::ASTNodes* ast; 24 | Parser* parser; 25 | DFT::DFTree* dft; 26 | public: 27 | 28 | ASTLNTBuilder(DFT::AST::ASTNodes* ast, Parser* parser): ast(ast), parser(parser), dft(NULL) { 29 | } 30 | 31 | DFT::DFTree* build() { 32 | dft = new DFT::DFTree(); 33 | return dft; 34 | } 35 | 36 | virtual int visitTopLevel(DFT::AST::ASTTopLevel* topLevel) { 37 | } 38 | virtual int visitBasicEvent(DFT::AST::ASTBasicEvent* basicEvent) { 39 | } 40 | virtual int visitGate(DFT::AST::ASTGate* gate) { 41 | } 42 | virtual int visitPage(DFT::AST::ASTPage* page) { 43 | } 44 | virtual int visitAttribute(DFT::AST::ASTAttribute* attribute) { 45 | } 46 | virtual int visitAttrib(DFT::AST::ASTAttrib* attrib) { 47 | } 48 | virtual int visitAttribFloat(DFT::AST::ASTAttribFloat* af) { 49 | } 50 | virtual int visitAttribNumber(DFT::AST::ASTAttribNumber* an) { 51 | } 52 | virtual int visitAttribString(DFT::AST::ASTAttribString* as) { 53 | } 54 | }; 55 | 56 | } // Namespace: DFT 57 | 58 | #endif // ASTLNTBUILDER_H 59 | -------------------------------------------------------------------------------- /dft2lnt/CADP.cpp: -------------------------------------------------------------------------------- 1 | #include "CADP.h" 2 | 3 | const YAML::Node& operator>>(const YAML::Node& node, DFT::CADP::BCGInfo& bcgInfo) { 4 | if(const YAML::Node itemNode = node["states"]) { 5 | bcgInfo.states = itemNode.as(); 6 | } 7 | if(const YAML::Node itemNode = node["transitions"]) { 8 | bcgInfo.transitions = itemNode.as(); 9 | } 10 | return node; 11 | } 12 | 13 | YAML::Emitter& operator<<(YAML::Emitter& out, const DFT::CADP::BCGInfo& bcgInfo) { 14 | out << YAML::BeginMap; 15 | if(bcgInfo.states>0) out << YAML::Key << "states" << YAML::Value << bcgInfo.states; 16 | if(bcgInfo.transitions>0) out << YAML::Key << "transitions" << YAML::Value << bcgInfo.transitions; 17 | out << YAML::EndMap; 18 | return out; 19 | } 20 | -------------------------------------------------------------------------------- /dft2lnt/CADP.h: -------------------------------------------------------------------------------- 1 | #ifndef CADP_H 2 | #define CADP_H 3 | 4 | #include 5 | 6 | #include "Shell.h" 7 | #include "yaml-cpp/yaml.h" 8 | 9 | namespace DFT { 10 | 11 | class CADP { 12 | public: 13 | 14 | class BCGInfo { 15 | public: 16 | int states; 17 | int transitions; 18 | BCGInfo(): 19 | states(0), 20 | transitions(0) { 21 | } 22 | 23 | bool willWriteSomething() const { 24 | return states>0 25 | || transitions>0 26 | ; 27 | } 28 | 29 | }; 30 | 31 | static std::string getRoot() { 32 | char* root = getenv((const char*)"CADP"); 33 | std::string cadp = root?string(root):""; 34 | 35 | // \ to / 36 | { 37 | char buf[cadp.length()+1]; 38 | for(int i=cadp.length();i--;) { 39 | if(cadp[i]=='\\') 40 | buf[i] = '/'; 41 | else 42 | buf[i] = cadp[i]; 43 | } 44 | buf[cadp.length()] = '\0'; 45 | if(buf[cadp.length()-1]=='/') { 46 | buf[cadp.length()-1] = '\0'; 47 | } 48 | cadp = string(buf); 49 | } 50 | return cadp; 51 | } 52 | 53 | static bool BCG_Info(File bcgFile, BCGInfo& bcgInfo) { 54 | if(!FileSystem::exists(bcgFile)) { 55 | return true; 56 | } 57 | 58 | File statFile; 59 | char tempfilename[] = P_tmpdir "/cadpXXXXXX"; 60 | close(mkstemp(tempfilename)); 61 | statFile = File(string(tempfilename)); 62 | 63 | Shell::system("bcg_info " + bcgFile.getFileRealPath(),".",statFile.getFileRealPath(),"",5,NULL); 64 | 65 | std::ifstream log(statFile.getFileRealPath()); 66 | if(!log.is_open()) { 67 | return true; 68 | } 69 | 70 | char buffer[300]; 71 | while(log.getline(buffer,300)) { 72 | if(buffer[0]=='\t') { 73 | const char* c = buffer+1; 74 | while(*c && isdigit(*c)) c++; 75 | if(!strncmp(" states",c,7)) { 76 | sscanf(buffer," %i",&bcgInfo.states); 77 | } else if(!strncmp(" transitions",c,12)) { 78 | sscanf(buffer," %i",&bcgInfo.transitions); 79 | } 80 | } 81 | } 82 | 83 | return false; 84 | } 85 | }; 86 | 87 | } // Namespace: DFT 88 | 89 | const YAML::Node& operator>>(const YAML::Node& node, DFT::CADP::BCGInfo& bcgInfo); 90 | YAML::Emitter& operator<<(YAML::Emitter& out, const DFT::CADP::BCGInfo& bcgInfo); 91 | 92 | #endif 93 | -------------------------------------------------------------------------------- /dft2lnt/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ## DFT2LNT Library project 2 | project (dft2lnt) 3 | set (dft2lnt_VERSION_MAJOR 1) 4 | set (dft2lnt_VERSION_MINOR 4) 5 | set (dft2lnt_VERSION_PATCH 1) 6 | 7 | ## Needed for bison and flex 8 | cmake_minimum_required (VERSION 3.0) 9 | 10 | ## Make sure we have Bison and FLEX available 11 | find_package(BISON 3.3) 12 | find_package(FLEX 2.6.3) 13 | 14 | if (MSVC) 15 | add_compile_options(/std:c++17) 16 | else() 17 | add_compile_options(-std=c++17) 18 | endif() 19 | 20 | ## Include source directory and the build directory (for generated files) 21 | include_directories( 22 | ${CMAKE_CURRENT_BINARY_DIR} 23 | ${CMAKE_CURRENT_SOURCE_DIR} 24 | ) 25 | 26 | if(DEFINED ENV{CADP}) 27 | set(CADP_SOURCES CADP.cpp) 28 | else() 29 | set(CADP_SOURCES) 30 | endif() 31 | 32 | ## Generate parser and lexer files to the target directory, because they depend on the selected Build (Debug/Release) 33 | ## We need to explicitely state that we want a lexer header file 34 | bison_target(par ${CMAKE_CURRENT_SOURCE_DIR}/parser.y.ypp ${CMAKE_CURRENT_BINARY_DIR}/parser.y.cpp COMPILE_FLAGS "${BISON_CFLAGS}") 35 | if (WIN32) 36 | flex_target(lex ${CMAKE_CURRENT_SOURCE_DIR}/lexer.l.lpp ${CMAKE_CURRENT_BINARY_DIR}/lexer.l.cpp COMPILE_FLAGS --wincompat DEFINES_FILE ${CMAKE_CURRENT_BINARY_DIR}/lexer.l.h) 37 | else() 38 | flex_target(lex ${CMAKE_CURRENT_SOURCE_DIR}/lexer.l.lpp ${CMAKE_CURRENT_BINARY_DIR}/lexer.l.cpp DEFINES_FILE ${CMAKE_CURRENT_BINARY_DIR}/lexer.l.h) 39 | endif() 40 | ADD_FLEX_BISON_DEPENDENCY(lex par) 41 | 42 | ## By default the header is not cleaned up (nor built) 43 | set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES ${CMAKE_CURRENT_BINARY_DIR}/lexer.l.h) 44 | 45 | ## Specify the library and its sources 46 | add_library(dft2lnt 47 | dft2lnt.cpp 48 | dft_ast.cpp 49 | dft_parser.cpp 50 | dftnodes/BasicEvent.cpp 51 | dftnodes/Node.cpp 52 | DFTree.cpp 53 | DFTreeValidator.cpp 54 | DFTreePrinter.cpp 55 | DFTCalculationResult.cpp 56 | files.cpp 57 | FileWriter.cpp 58 | ConsoleWriter.cpp 59 | compiler.cpp 60 | MessageFormatter.cpp 61 | Shell.cpp 62 | FileSystem.cpp 63 | System.cpp 64 | ${CADP_SOURCES} 65 | ${BISON_par_OUTPUTS} ${FLEX_lex_OUTPUTS} 66 | ) 67 | 68 | # Find yaml-cpp 69 | find_path(YAML_INCLUDE_PATH "yaml-cpp/yaml.h") 70 | 71 | if(UNIX AND NOT APPLE AND NOT WIN32) 72 | target_link_libraries(dft2lnt rt) 73 | endif() 74 | 75 | target_include_directories(dft2lnt PRIVATE ${YAML_INCLUDE_PATH}) 76 | 77 | if (NOT DEFINED LIB_INSTALL_DIR) 78 | if (DEFINED CMAKE_INSTALL_LIBDIR) 79 | set(LIB_INSTALL_DIR "lib") 80 | else() 81 | set(LIB_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}) 82 | endif() 83 | endif() 84 | 85 | ## Installation 86 | install (TARGETS dft2lnt DESTINATION ${LIB_INSTALL_DIR}) 87 | install (FILES dft2lnt.h DESTINATION include/dft2lnt) 88 | -------------------------------------------------------------------------------- /dft2lnt/DFTCalculationResult.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DFTCalculationResult.h 3 | * 4 | * Part of dft2lnt library - a library containing read/write operations for DFT 5 | * files in Galileo format and translating DFT specifications into Lotos NT. 6 | * 7 | * @author Freark van der Berg 8 | */ 9 | 10 | #ifndef DFTCALCULATIONRESULT_H 11 | #define DFTCALCULATIONRESULT_H 12 | 13 | #include "Shell.h" 14 | #include "yaml-cpp/yaml.h" 15 | #include "decnumber.h" 16 | #include "query.h" 17 | 18 | namespace DFT { 19 | class DFTCalculationResultItem { 20 | public: 21 | std::string missionTime; 22 | std::string mrmcCommand; 23 | Query query; 24 | std::string exactString; 25 | decnumber<> lowerBound, upperBound; 26 | bool exactBounds; 27 | DFTCalculationResultItem() : lowerBound(0), upperBound(1) { } 28 | DFTCalculationResultItem(Query query) : lowerBound(0), upperBound(1) { 29 | this->query = query; 30 | mrmcCommand = query.toString(); 31 | missionTime = query.upperBound.str(); 32 | } 33 | std::string valStr(size_t deltaDigits = 3) const; 34 | }; 35 | 36 | class DFTCalculationResult { 37 | public: 38 | Shell::RunStatistics stats; 39 | std::vector failProbs; 40 | }; 41 | } // Namespace: DFT 42 | 43 | const YAML::Node& operator>>(const YAML::Node& node, DFT::DFTCalculationResult& result); 44 | YAML::Emitter& operator<<(YAML::Emitter& out, const DFT::DFTCalculationResult& result); 45 | 46 | const YAML::Node& operator>>(const YAML::Node& node, map& resultMap); 47 | YAML::Emitter& operator<<(YAML::Emitter& out, const map& resultMap); 48 | 49 | const YAML::Node& operator>>(const YAML::Node& node, DFT::DFTCalculationResultItem& result); 50 | YAML::Emitter& operator<<(YAML::Emitter& out, const DFT::DFTCalculationResultItem& result); 51 | 52 | const YAML::Node& operator>>(const YAML::Node& node, vector& resultVector); 53 | YAML::Emitter& operator<<(YAML::Emitter& out, const vector& resultVector); 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /dft2lnt/DFTreePrinter.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * DFTreePrinter.cpp 3 | * 4 | * Part of dft2lnt library - a library containing read/write operations for DFT 5 | * files in Galileo format and translating DFT specifications into Lotos NT. 6 | * 7 | * @author Freark van der Berg 8 | */ 9 | 10 | #include "DFTreePrinter.h" 11 | #include 12 | 13 | DFT::DFTreePrinter::DFTreePrinter(DFT::DFTree* dft, CompilerContext* cc): 14 | dft(dft), 15 | cc(cc) { 16 | 17 | } 18 | 19 | int DFT::DFTreePrinter::print(std::ostream& out) { 20 | assert(dft->getTopNode()); 21 | out << "toplevel \"" << dft->getTopNode()->getName() << "\";" << std::endl; 22 | 23 | std::vector& nodes = dft->getNodes(); 24 | for(DFT::Nodes::Node* node: nodes) { 25 | assert(node); 26 | if(node->isBasicEvent()) { 27 | DFT::Nodes::BasicEvent* be = static_cast(node); 28 | DFT::DFTreePrinter::printBasicEvent(out,be); 29 | } else if(node->isGate()) { 30 | DFT::Nodes::Gate* gate = static_cast(node); 31 | DFT::DFTreePrinter::printGate(out,gate); 32 | } else { 33 | out << "UnknownNode"; 34 | } 35 | out << std::endl; 36 | } 37 | return 0; 38 | } 39 | 40 | int DFT::DFTreePrinter::printBasicEvent(std::ostream& out, const DFT::Nodes::BasicEvent* basicEvent) { 41 | assert(basicEvent); 42 | out << "\"" << basicEvent->getName() << "\""; 43 | streamsize ss_old = out.precision(); 44 | out.precision(10); 45 | if (basicEvent->getLambda() != decnumber<>(-1)) 46 | out << " lambda=" << fixed << basicEvent->getLambda().str(); 47 | if (basicEvent->getProb() != decnumber<>(1)) 48 | out << " prob=" << fixed << basicEvent->getProb().str(); 49 | out << " dorm=" << basicEvent->getDorm().str(); 50 | if(basicEvent->getPhases()>1){ 51 | out << " phases=" << basicEvent->getPhases(); 52 | } 53 | if(basicEvent->getInterval()>0){ 54 | out << " interval=" << basicEvent->getInterval(); 55 | } 56 | if(basicEvent->getMaintain()>0){ 57 | out << " maintain=" << basicEvent->getMaintain(); 58 | } 59 | if(basicEvent->isRepairable() && basicEvent->getRepair() >= 0) 60 | out << " repair=" << basicEvent->getRepair(); 61 | if(!basicEvent->getRes().is_zero()) 62 | out << " res=" << basicEvent->getRes().str(); 63 | out.precision(ss_old); 64 | out << ";"; 65 | if(basicEvent->getFailed()) { 66 | out << " /*FAILED*/"; 67 | } 68 | return 0; 69 | } 70 | 71 | int DFT::DFTreePrinter::printGate(std::ostream& out, const DFT::Nodes::Gate* gate) { 72 | assert(gate); 73 | out << "\"" << gate->getName() << "\""; 74 | out << " " << gate->getTypeStr(); 75 | if(DFT::Nodes::Node::typeMatch(gate->getType(),DFT::Nodes::GateFDEPType)) { 76 | const DFT::Nodes::GateFDEP* fdep = static_cast(gate); 77 | printGateFDEP(out,fdep); 78 | } else { 79 | if(gate->matchesType(DFT::Nodes::InspectionType)) { 80 | const DFT::Nodes::Inspection *insp; 81 | insp = static_cast(gate); 82 | out << insp->getLambda().str(); 83 | } 84 | for(DFT::Nodes::Node* node: gate->getChildren()) { 85 | out << " \"" << node->getName() << "\""; 86 | } 87 | out << ";"; 88 | } 89 | return 0; 90 | } 91 | 92 | int DFT::DFTreePrinter::printGateFDEP(std::ostream& out, const DFT::Nodes::GateFDEP* gate) { 93 | assert(gate); 94 | out << " \"" << gate->getEventSource()->getName() << "\""; 95 | for(DFT::Nodes::Node* node: gate->getDependers()) { 96 | out << " \"" << node->getName() << "\""; 97 | } 98 | out << ";"; 99 | return 0; 100 | } 101 | -------------------------------------------------------------------------------- /dft2lnt/DFTreePrinter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DFTreePrinter.h 3 | * 4 | * Part of dft2lnt library - a library containing read/write operations for DFT 5 | * files in Galileo format and translating DFT specifications into Lotos NT. 6 | * 7 | * @author Freark van der Berg 8 | */ 9 | 10 | namespace DFT { 11 | class DFTreePrinter; 12 | } 13 | 14 | #ifndef DFTREEPRINTER_H 15 | #define DFTREEPRINTER_H 16 | 17 | #include "DFTree.h" 18 | #include "compiler.h" 19 | 20 | namespace DFT { 21 | 22 | class DFTreePrinter { 23 | private: 24 | DFT::DFTree* dft; 25 | CompilerContext* cc; 26 | 27 | int validateReferences(); 28 | public: 29 | DFTreePrinter(DFT::DFTree* dft, CompilerContext* cc); 30 | virtual ~DFTreePrinter() { 31 | } 32 | 33 | int print (std::ostream& out); 34 | int printBasicEvent (std::ostream& out, const DFT::Nodes::BasicEvent* basicEvent); 35 | int printGate (std::ostream& out, const DFT::Nodes::Gate* gate); 36 | int printGateFDEP (std::ostream& out, const DFT::Nodes::GateFDEP* gate); 37 | 38 | }; 39 | 40 | } // Namespace: DFT 41 | 42 | #endif // DFTREEPRINTER_H 43 | -------------------------------------------------------------------------------- /dft2lnt/DFTreeValidator.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DFTreeValidator.h 3 | * 4 | * Part of dft2lnt library - a library containing read/write operations for DFT 5 | * files in Galileo format and translating DFT specifications into Lotos NT. 6 | * 7 | * @author Freark van der Berg 8 | */ 9 | 10 | namespace DFT { 11 | class DFTreeValidator; 12 | } 13 | 14 | #ifndef DFTREEVALIDATOR_H 15 | #define DFTREEVALIDATOR_H 16 | 17 | #include "DFTree.h" 18 | #include "compiler.h" 19 | 20 | namespace DFT { 21 | 22 | /** 23 | * Validates the DFT. 24 | * Note that a DFT generated from a valid AST should be guaranteed valid. 25 | */ 26 | class DFTreeValidator { 27 | private: 28 | DFT::DFTree* dft; 29 | CompilerContext* cc; 30 | 31 | int validateReferences(); 32 | int validateSingleParent(); 33 | int validateNodes(); 34 | int validateBasicEvent(const DFT::Nodes::BasicEvent& be); 35 | int validateGate(const DFT::Nodes::Gate& gate); 36 | public: 37 | 38 | /** 39 | * Constructs a new DFTreeValidator using the specified DFT and 40 | * CompilerContext. 41 | * @param dft The DFT to be validated. 42 | * @param cc The CompilerConstruct used for eg error reports. 43 | */ 44 | DFTreeValidator(DFT::DFTree* dft, CompilerContext* cc); 45 | 46 | virtual ~DFTreeValidator() { 47 | } 48 | 49 | /** 50 | * Start the validation process using the DFT specified in teh constructor. 51 | * Returns whether the DFT is valid or not. 52 | * @return true: valid DFT, false: invalid DFT 53 | */ 54 | int validate(); 55 | 56 | }; 57 | 58 | } // Namespace: DFT 59 | 60 | #endif // DFTREEVALIDATOR_H 61 | -------------------------------------------------------------------------------- /dft2lnt/FileWriter.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * FileWriter.cpp 3 | * 4 | * Part of a general library. 5 | * 6 | * @author Freark van der Berg 7 | */ 8 | 9 | #include "FileWriter.h" 10 | 11 | const FileWriter::FileWriterOption FileWriter::_pop(FileWriter::FileWriterOption::POP); 12 | const FileWriter::FileWriterOption FileWriter::_push(FileWriter::FileWriterOption::PUSH); -------------------------------------------------------------------------------- /dft2lnt/Settings.h: -------------------------------------------------------------------------------- 1 | #ifndef SETTINGS_H 2 | #define SETTINGS_H 3 | 4 | #include 5 | #include 6 | 7 | class SettingsValue: public std::string { 8 | public: 9 | SettingsValue() { 10 | } 11 | SettingsValue(const std::string& str): std::string(str) { 12 | } 13 | SettingsValue& operator=(const std::string& str) { 14 | *this = SettingsValue(str); 15 | return *this; 16 | } 17 | 18 | inline bool isOn() const { 19 | return (*this)=="1" || (*this)=="true" || (*this)=="T" || (*this)=="on"; 20 | } 21 | inline bool isOff() const { 22 | return (*this)=="0" || (*this)=="false" || (*this)=="F" || (*this)=="off"; 23 | } 24 | 25 | operator bool() { 26 | return isOn(); 27 | } 28 | }; 29 | 30 | class Settings: public std::unordered_map { 31 | public: 32 | enum class Switch { 33 | UNDEFINED = 0, 34 | ON = 1, 35 | OFF = 2, 36 | NEITHER = 3, 37 | NUMBER_OF 38 | }; 39 | public: 40 | Switch asSwitch(const std::string& setting) { 41 | auto it = find(setting); 42 | if(it != end()) { 43 | const SettingsValue& value = it->second; 44 | if(value.isOn()) { 45 | return Switch::ON; 46 | } else if(value.isOff()) { 47 | return Switch::OFF; 48 | } else { 49 | return Switch::NEITHER; 50 | } 51 | } else { 52 | return Switch::UNDEFINED; 53 | } 54 | } 55 | }; 56 | 57 | #endif -------------------------------------------------------------------------------- /dft2lnt/System.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * System.cpp 3 | * 4 | * Part of a general library. 5 | * 6 | * Adapted by Gerjan Stokkink to support Mac OS X. 7 | * 8 | * @author Freark van der Berg 9 | */ 10 | 11 | #ifndef WIN32 12 | # include 13 | # include 14 | #endif 15 | #include 16 | #include "System.h" 17 | 18 | System::Timer::Timer() { 19 | reset(); 20 | } 21 | 22 | System::Timer* System::Timer::create() { 23 | return new Timer(); 24 | } 25 | 26 | void System::Timer::reset() { 27 | #if SYSTEM_TIMER_BACKEND == SYSTEM_TIMER_BACKEND_WINDOWS 28 | QueryPerformanceFrequency(&freq); 29 | QueryPerformanceCounter(&start); 30 | #endif 31 | #if SYSTEM_TIMER_BACKEND == SYSTEM_TIMER_BACKEND_APPLE 32 | gettimeofday(&start, (void *)NULL); 33 | #endif 34 | #if SYSTEM_TIMER_BACKEND == SYSTEM_TIMER_BACKEND_MONOTONIC_RAW 35 | clock_gettime(CLOCK_MONOTONIC_RAW, &start); 36 | #endif 37 | #if SYSTEM_TIMER_BACKEND == SYSTEM_TIMER_BACKEND_MONOTONIC 38 | clock_gettime(CLOCK_MONOTONIC, &start); 39 | #endif 40 | } 41 | 42 | double System::Timer::getElapsedSeconds() { 43 | #if SYSTEM_TIMER_BACKEND == SYSTEM_TIMER_BACKEND_WINDOWS 44 | LARGE_INTEGER now; 45 | QueryPerformanceCounter(&now); 46 | return (double)(now.QuadPart-start.QuadPart) / (double)(freq.QuadPart) ; 47 | #endif 48 | #if SYSTEM_TIMER_BACKEND == SYSTEM_TIMER_BACKEND_APPLE 49 | timeval now; 50 | gettimeofday(&now, (void *)NULL); 51 | return (double)(now.tv_sec -start.tv_sec ) 52 | + (double)(now.tv_usec-start.tv_usec)*0.000001; 53 | #endif 54 | #if SYSTEM_TIMER_BACKEND == SYSTEM_TIMER_BACKEND_MONOTONIC_RAW 55 | timespec now; 56 | clock_gettime(CLOCK_MONOTONIC_RAW, &now); 57 | return (double)(now.tv_sec -start.tv_sec ) 58 | + (double)(now.tv_nsec-start.tv_nsec)*0.000000001; 59 | #endif 60 | #if SYSTEM_TIMER_BACKEND == SYSTEM_TIMER_BACKEND_MONOTONIC 61 | timespec now; 62 | clock_gettime(CLOCK_MONOTONIC, &now); 63 | return (double)(now.tv_sec -start.tv_sec ) 64 | + (double)(now.tv_nsec-start.tv_nsec)*0.000000001; 65 | #endif 66 | } 67 | 68 | void System::sleep(uint64_t ms) { 69 | #ifdef WIN32 70 | Sleep(ms); 71 | #else 72 | usleep(ms*1000); 73 | #endif 74 | } 75 | 76 | void System::generateUUID(size_t bytes,std::string& uuid) { 77 | static uint64_t lastTime; 78 | static uint64_t currentTime; 79 | static std::uniform_int_distribution hex {0,15}; // distribution that maps to the ints 1..6 80 | static std::default_random_engine re {}; // the default engine uuid.empty; 81 | do { 82 | currentTime = getCurrentTimeMicros(); 83 | } while(currentTime==lastTime); 84 | lastTime = currentTime; 85 | re.seed(currentTime); 86 | uuid.clear(); 87 | uuid.reserve(bytes*2); 88 | for(unsigned int i=0; i 20 | #include 21 | #include 22 | #ifdef WIN32 23 | # define WIN32_LEAN_AND_MEAN // Omit rarely-used and architecture-specific stuff from WIN32 24 | # include 25 | # define SYSTEM_TIMER_BACKEND SYSTEM_TIMER_BACKEND_WINDOWS 26 | #elif defined __APPLE__ 27 | # define SYSTEM_TIMER_BACKEND SYSTEM_TIMER_BACKEND_APPLE 28 | #elif defined CLOCK_MONOTONIC_RAW && defined CLOCKS_MONO && CLOCKS_MONO == CLOCK_MONOTONIC_RAW 29 | # define SYSTEM_TIMER_BACKEND SYSTEM_TIMER_BACKEND_MONOTONIC_RAW 30 | #else 31 | # define SYSTEM_TIMER_BACKEND SYSTEM_TIMER_BACKEND_MONOTONIC 32 | #endif 33 | 34 | class System { 35 | public: 36 | class Timer { 37 | private: 38 | #if SYSTEM_TIMER_BACKEND == SYSTEM_TIMER_BACKEND_WINDOWS 39 | LARGE_INTEGER freq; 40 | LARGE_INTEGER start; 41 | #endif 42 | #if SYSTEM_TIMER_BACKEND == SYSTEM_TIMER_BACKEND_APPLE 43 | timeval start; 44 | #endif 45 | #if SYSTEM_TIMER_BACKEND == SYSTEM_TIMER_BACKEND_MONOTONIC_RAW 46 | timespec start; 47 | #endif 48 | #if SYSTEM_TIMER_BACKEND == SYSTEM_TIMER_BACKEND_MONOTONIC 49 | timespec start; 50 | #endif 51 | public: 52 | Timer(); 53 | Timer* create(); 54 | void reset(); 55 | double getElapsedSeconds(); 56 | }; 57 | 58 | static void sleep(uint64_t ms); 59 | 60 | static void generateUUID(size_t bytes,std::string& uuid); 61 | 62 | static uint64_t getCurrentTimeMillis(); 63 | static uint64_t getCurrentTimeMicros(); 64 | }; 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /dft2lnt/compiler.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * compiler.h 3 | * 4 | * Part of dft2lnt library - a library containing read/write operations for DFT 5 | * files in Galileo format and translating DFT specifications into Lotos NT. 6 | * 7 | * @author Freark van der Berg 8 | */ 9 | 10 | #include 11 | 12 | #include "compiler.h" 13 | #include "FileSystem.h" 14 | 15 | bool CompilerContext::testWritable(std::string fileName) { 16 | File file(fileName); 17 | File folder(file.getPathTo()); 18 | 19 | if(FileSystem::exists(File(fileName))) { 20 | if(FileSystem::hasAccessTo(file,W_OK)) { 21 | return true; 22 | } else { 23 | reportError("no permission to open outputfile '" + fileName + "' for writing"); 24 | return false; 25 | } 26 | } else if(folder.isWritableDirectory()) { 27 | return true; 28 | } else { 29 | reportError("unable to open outputfile '" + fileName + "' for writing"); 30 | return false; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /dft2lnt/compiler.h: -------------------------------------------------------------------------------- 1 | /* 2 | * compiler.h 3 | * 4 | * Part of dft2lnt library - a library containing read/write operations for DFT 5 | * files in Galileo format and translating DFT specifications into Lotos NT. 6 | * 7 | * @author Freark van der Berg 8 | */ 9 | 10 | #ifndef COMPILER_H 11 | #define COMPILER_H 12 | 13 | // Maximum number of nested files using include statements 14 | #define MAX_FILE_NESTING 100 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include "ConsoleWriter.h" 22 | #include "dft_parser_location.h" 23 | #include "MessageFormatter.h" 24 | 25 | /** 26 | * Every file is associated with an instance of this struct 27 | */ 28 | typedef struct FileContext { 29 | FILE* fileHandle; 30 | std::string filename; 31 | Location loc; 32 | 33 | /** 34 | * Creates a new FileContext object. 35 | */ 36 | FileContext(): 37 | fileHandle(NULL), 38 | filename("") { 39 | } 40 | 41 | /** 42 | * Creates a new FileContext object with the specified settings. 43 | */ 44 | FileContext(FILE* fileHandle, std::string& filename, Location& loc): 45 | fileHandle(fileHandle), 46 | filename(filename), 47 | loc(loc) { 48 | } 49 | } FileContext; 50 | 51 | /** 52 | * The compiler context contains settings and data related to the compilation 53 | * of a file and its dependencies. 54 | */ 55 | class CompilerContext: public MessageFormatter { 56 | private: 57 | std::string name; 58 | public: 59 | map types; 60 | FileContext fileContext[MAX_FILE_NESTING]; // max file nesting of MAX_FILE_NESTING allowed 61 | int fileContexts; 62 | 63 | /** 64 | * Creates a new compiler context with a specific name. 65 | */ 66 | CompilerContext(std::ostream& out): MessageFormatter(out), name("") { 67 | } 68 | 69 | virtual ~CompilerContext() { 70 | } 71 | 72 | /** 73 | * Push the specified FileContext on the stack. 74 | * @param The FileContext to be pushed on the stack. 75 | * @return false: success, true: error 76 | */ 77 | bool pushFileContext(FileContext context) { 78 | if(fileContexts>=MAX_FILE_NESTING) { 79 | reportError("Max file nesting (100) surpassed"); 80 | return true; 81 | } else { 82 | fileContext[fileContexts] = context; 83 | ++fileContexts; 84 | } 85 | return false; 86 | } 87 | 88 | /** 89 | * Pop the top FileContext from the stack. 90 | * @return false: success, true: error 91 | */ 92 | bool popFileContext() { 93 | --fileContexts; 94 | return false; 95 | } 96 | 97 | /** 98 | * Returns the current number of file contexts. 99 | * @return The current number of file contexts. 100 | */ 101 | int getFileContexts() const { 102 | return fileContexts; 103 | } 104 | 105 | /** 106 | * Returns a reference to the FileContext at the specified location 107 | * on the stack. 108 | * @param i The position in the stack of the FileContext that will be 109 | * returned. 110 | * @return The FileContext at the specified location. 111 | */ 112 | FileContext& getFileContext(int i) { 113 | assert(0<=i && i < MAX_FILE_NESTING && "getFileContext(i): invalid i"); 114 | return fileContext[i]; 115 | } 116 | 117 | /** 118 | * Tests if the specified file is allowed to be written to. 119 | * If using a relative path, take the working directory into account. 120 | * @param fileName The path+name of the file to test. 121 | * @return true: writable, false: not writable. 122 | */ 123 | virtual bool testWritable(std::string fileName); 124 | 125 | }; 126 | 127 | #endif // COMPILER_H 128 | -------------------------------------------------------------------------------- /dft2lnt/dft2lnt.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * dft2lnt.cpp 3 | * 4 | * Part of dft2lnt library - a library containing read/write operations for DFT 5 | * files in Galileo format and translating DFT specifications into Lotos NT. 6 | * 7 | * @author Freark van der Berg 8 | */ 9 | 10 | #include 11 | 12 | #include "dft2lnt.h" 13 | 14 | const std::string DFT2LNT::LNTSUBROOT ("/share/dft2lnt/lntnodes"); 15 | const std::string DFT2LNT::BCGSUBROOT ("/share/dft2lnt/bcgnodes"); 16 | const std::string DFT2LNT::TESTSUBROOT("/share/dft2lnt/tests"); 17 | 18 | const std::string DFT2LNT::AUT_CACHE_DIR ("/autnodes"); 19 | -------------------------------------------------------------------------------- /dft2lnt/dft2lnt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * dft2lnt.h 3 | * 4 | * Part of dft2lnt library - a library containing read/write operations for DFT 5 | * files in Galileo format and translating DFT specifications into Lotos NT. 6 | * 7 | * @author Freark van der Berg 8 | */ 9 | 10 | #ifndef DFT2LNT_H 11 | #define DFT2LNT_H 12 | 13 | #include "DFTree.h" 14 | #include "ConsoleWriter.h" 15 | #include "compiler.h" 16 | 17 | class DFT2LNT { 18 | public: 19 | static const std::string LNTSUBROOT; 20 | static const std::string BCGSUBROOT; 21 | static const std::string TESTSUBROOT; 22 | static const std::string AUT_CACHE_DIR; 23 | }; 24 | 25 | #endif // DFT2LNT_H 26 | -------------------------------------------------------------------------------- /dft2lnt/dft_ast.cpp: -------------------------------------------------------------------------------- 1 | #include "dft_ast.h" 2 | 3 | DFT::AST::ASTTopLevel::~ASTTopLevel() { 4 | if(topNode) delete topNode; 5 | } 6 | 7 | DFT::AST::ASTAttribString::~ASTAttribString() { 8 | if(value) delete value; 9 | } 10 | 11 | DFT::AST::ASTAttribute::~ASTAttribute() { 12 | if(value) delete value; 13 | } 14 | 15 | void DFT::AST::ASTTopLevel::setTopNode(ASTIdentifier* topNode) { 16 | if(this->topNode) delete this->topNode; 17 | this->topNode = topNode; 18 | } 19 | -------------------------------------------------------------------------------- /dft2lnt/dft_parser.h: -------------------------------------------------------------------------------- 1 | /* 2 | * dft_parser.h 3 | * 4 | * Part of dft2lnt library - a library containing read/write operations for DFT 5 | * files in Galileo format and translating DFT specifications into Lotos NT. 6 | * 7 | * @author Freark van der Berg 8 | */ 9 | 10 | class Parser; 11 | 12 | #ifndef DFT_PARSER_H 13 | #define DFT_PARSER_H 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #include "dft_ast.h" 21 | #include "dft2lnt.h" 22 | #include "dft_parser_location.h" 23 | 24 | using namespace std; 25 | 26 | extern Parser* pp; 27 | 28 | /* An opaque pointer. */ 29 | #ifndef YY_TYPEDEF_YY_SCANNER_T 30 | #define YY_TYPEDEF_YY_SCANNER_T 31 | typedef void* yyscan_t; 32 | #endif 33 | 34 | 35 | /** 36 | * Creates a new parser. 37 | */ 38 | class Parser { 39 | private: 40 | FILE* file; 41 | std::string fileName; 42 | 43 | CompilerContext* compilerContext; 44 | public: 45 | yyscan_t scanner; 46 | 47 | /** 48 | * Constructs a new parser using the specified file properties and 49 | * CompilerContext. The CompilerContext will be used to generate 50 | * errors and warnings. 51 | * Call parser() to start parsing. 52 | */ 53 | Parser(FILE* file, std::string fileName, CompilerContext* compilerContext): file(file), fileName(fileName), compilerContext(compilerContext) { 54 | assert(compilerContext); 55 | } 56 | 57 | /** 58 | * Start the parsing. The parsing will start with the file specified in 59 | * the constructor. The specified CompilerContext will be used to generate 60 | * errors and warnings. 61 | * The parser will build the AST along the way and return it. 62 | * @return The list of ASTNodes parsed from the source. 63 | */ 64 | DFT::AST::ASTNodes* parse(); 65 | 66 | /** 67 | * Start parsing at the specified file. After the parsing of this file is 68 | * done, yywrap() will be automatically called, which will call popFile(). 69 | * After the specified file has been parser, the parser will continue where 70 | * it paused with the previous file on the stack. If there is no previous 71 | * file, the parsing is done and parse() will return. 72 | */ 73 | FILE* pushFile(std::string fileName); 74 | 75 | /** 76 | * Pops the last file from the parse stack. See pushFile() for more. 77 | * @return UNDECIDED 78 | */ 79 | int popFile(); 80 | 81 | /** 82 | * Returns the current source file where the Parser is currently at. 83 | * @return he current source file where the Parser is currently at. 84 | */ 85 | std::string getCurrentFileName(); 86 | 87 | /** 88 | * Returns the current source location where the Parser is currently at. 89 | * @return he current source location where the Parser is currently at. 90 | */ 91 | Location getCurrentLocation(); 92 | 93 | /** 94 | * Returns the CompilerContext used by this Parser. 95 | * @return The CompilerContext used by this Parser. 96 | */ 97 | CompilerContext* getCC() { return compilerContext; } 98 | }; 99 | 100 | #endif // DFT_PARSER_H -------------------------------------------------------------------------------- /dft2lnt/dft_types.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/utwente-fmt/dftcalc/aaaa84595404f4522a6d01718f45dd953184c92a/dft2lnt/dft_types.h -------------------------------------------------------------------------------- /dft2lnt/dftnodes/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/utwente-fmt/dftcalc/aaaa84595404f4522a6d01718f45dd953184c92a/dft2lnt/dftnodes/.DS_Store -------------------------------------------------------------------------------- /dft2lnt/dftnodes/BasicEvent.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * BasicEvent.cpp 3 | * 4 | * Part of dft2lnt library - a library containing read/write operations for DFT 5 | * files in Galileo format and translating DFT specifications into Lotos NT. 6 | * 7 | * @author Freark van der Berg 8 | */ 9 | 10 | #include 11 | #include 12 | 13 | const std::string CalculationModeUNDEFINED = "undefined"; 14 | const std::string CalculationModeEXPONENTIAL = "exponential"; 15 | const std::string CalculationModePROB = "probability"; 16 | const std::string CalculationModeWEIBULL = "weibull"; 17 | const std::string CalculationModeAPH = "aph"; 18 | const std::string& DFT::Nodes::BE::getCalculationModeStr(CalculationMode mode) { 19 | switch(mode) { 20 | case DFT::Nodes::BE::CalculationMode::EXPONENTIAL: 21 | return CalculationModeEXPONENTIAL; 22 | case DFT::Nodes::BE::CalculationMode::PROBABILITY: 23 | return CalculationModePROB; 24 | case DFT::Nodes::BE::CalculationMode::WEIBULL: 25 | return CalculationModeWEIBULL; 26 | case DFT::Nodes::BE::CalculationMode::APH: 27 | return CalculationModeAPH; 28 | default: 29 | return CalculationModeUNDEFINED; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /dft2lnt/dftnodes/Gate.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Gate.h 3 | * 4 | * Part of dft2lnt library - a library containing read/write operations for DFT 5 | * files in Galileo format and translating DFT specifications into Lotos NT. 6 | * 7 | * @author Freark van der Berg 8 | */ 9 | 10 | #ifndef GATE_H 11 | #define GATE_H 12 | 13 | #include 14 | #include "Node.h" 15 | 16 | using namespace std; 17 | 18 | namespace DFT { 19 | namespace Nodes { 20 | 21 | class Gate: public Node { 22 | private: 23 | std::vector children; 24 | int repairableChildren; 25 | protected: 26 | Gate(Location loc, std::string name, DFT::Nodes::NodeType nodeType): Node(loc,name,nodeType) { 27 | } 28 | public: 29 | 30 | /** 31 | * Returns the list of children of this Gate. 32 | * @return The list of children of this Gate. 33 | */ 34 | std::vector& getChildren() { return children; } 35 | const std::vector& getChildren() const { return const_cast&>(children); } 36 | 37 | /** 38 | * Returns the list of repairable children of this Gate. 39 | * @return The list of repairable children of this Gate. 40 | */ 41 | const int getRepairableChildren() const{ return repairableChildren; } 42 | 43 | /** 44 | * Adds the specified Node to this Node's list of children. 45 | * @param child The Node to add to this Node's list of children. 46 | */ 47 | void addChild(Node* child) { children.push_back(child); } 48 | 49 | /** 50 | * Adds the specified Node to this Node's list of children. 51 | * @param child The Node to add to this Node's list of children. 52 | */ 53 | void delChild(int n) { children.erase(children.begin()+n); } 54 | 55 | /** 56 | * Adds the specified Node to this Node's list of repairable children. 57 | * @param child The Node to add to this Node's list of repairable children. 58 | */ 59 | void setRepairableChildren(int nr) { repairableChildren=nr; } 60 | 61 | virtual ~Gate() { 62 | } 63 | virtual void addReferencesTo(std::vector& nodeList) { 64 | for(size_t i=0; i dependers; 23 | public: 24 | GateFDEP(Location loc, std::string name): 25 | Gate(loc,name,GateFDEPType) { 26 | } 27 | virtual ~GateFDEP() { 28 | } 29 | 30 | void setDependers(vector dependers) { 31 | this->dependers = dependers; 32 | } 33 | vector& getDependers() { 34 | return dependers; 35 | } 36 | const vector& getDependers() const { 37 | return dependers; 38 | } 39 | virtual bool outputIsDumb() const { return true; } 40 | 41 | DFT::Nodes::Node* getEventSource() const { 42 | if(getChildren().size()!=1) return NULL; 43 | else return getChildren()[0]; 44 | } 45 | }; 46 | 47 | } // Namespace: Nodes 48 | } // Namespace: DFT 49 | 50 | #endif // GATEPAND_H 51 | -------------------------------------------------------------------------------- /dft2lnt/dftnodes/GateOr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * GateOr.h 3 | * 4 | * Part of dft2lnt library - a library containing read/write operations for DFT 5 | * files in Galileo format and translating DFT specifications into Lotos NT. 6 | * 7 | * @author Freark van der Berg 8 | */ 9 | 10 | class GateOr; 11 | 12 | #ifndef GATEOR_H 13 | #define GATEOR_H 14 | 15 | #include "Gate.h" 16 | 17 | namespace DFT { 18 | namespace Nodes { 19 | 20 | class GateOr: public Gate { 21 | private: 22 | 23 | public: 24 | GateOr(Location loc, std::string name): 25 | Gate(loc,name,GateOrType) { 26 | } 27 | virtual ~GateOr() { 28 | } 29 | }; 30 | 31 | } // Namespace: Nodes 32 | } // Namespace: DFT 33 | 34 | #endif // GATEOR_H 35 | -------------------------------------------------------------------------------- /dft2lnt/dftnodes/GatePAnd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * GatePAnd.h 3 | * 4 | * Part of dft2lnt library - a library containing read/write operations for DFT 5 | * files in Galileo format and translating DFT specifications into Lotos NT. 6 | * 7 | * @author Freark van der Berg 8 | */ 9 | 10 | class GatePAnd; 11 | 12 | #ifndef GATEPAND_H 13 | #define GATEPAND_H 14 | 15 | #include "Gate.h" 16 | 17 | namespace DFT { 18 | namespace Nodes { 19 | 20 | class GatePAnd: public Gate { 21 | private: 22 | 23 | public: 24 | GatePAnd(Location loc, std::string name): 25 | Gate(loc,name,GatePAndType) { 26 | } 27 | virtual ~GatePAnd() { 28 | } 29 | }; 30 | 31 | } // Namespace: Nodes 32 | } // Namespace: DFT 33 | 34 | #endif // GATEPAND_H 35 | -------------------------------------------------------------------------------- /dft2lnt/dftnodes/GatePor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * GatePOR.h 3 | * 4 | * Part of dft2lnt library - a library containing read/write operations for DFT 5 | * files in Galileo format and translating DFT specifications into Lotos NT. 6 | * 7 | * @author Florian Arnold and extended by Dennis Guck 8 | */ 9 | 10 | class GatePor; 11 | 12 | #ifndef GATEPOR_H 13 | #define GATEPOR_H 14 | 15 | #include "Gate.h" 16 | 17 | namespace DFT { 18 | namespace Nodes { 19 | 20 | class GatePor: public Gate { 21 | private: 22 | 23 | public: 24 | GatePor(Location loc, std::string name): 25 | Gate(loc,name,GatePorType) { 26 | } 27 | virtual ~GatePor() { 28 | } 29 | }; 30 | 31 | } // Namespace: Nodes 32 | } // Namespace: DFT 33 | 34 | #endif // GatePOR_H 35 | -------------------------------------------------------------------------------- /dft2lnt/dftnodes/GateSAnd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * GateSAnd.h sequence AND without sharing and whatsoever 3 | * 4 | * Part of dft2lnt library - a library containing read/write operations for DFT 5 | * files in Galileo format and translating DFT specifications into Lotos NT. 6 | * 7 | * @author Dennis Guck 8 | */ 9 | 10 | class GateAnd; 11 | 12 | #ifndef GATESAND_H 13 | #define GATESAND_H 14 | 15 | #include "Gate.h" 16 | 17 | namespace DFT { 18 | namespace Nodes { 19 | 20 | class GateSAnd: public Gate { 21 | private: 22 | 23 | public: 24 | GateSAnd(Location loc, std::string name): 25 | Gate(loc,name,GateSAndType) { 26 | } 27 | virtual ~GateSAnd() { 28 | } 29 | }; 30 | 31 | } // Namespace: Nodes 32 | } // Namespace: DFT 33 | 34 | #endif // GATESAND_H 35 | -------------------------------------------------------------------------------- /dft2lnt/dftnodes/GateSEQ.h: -------------------------------------------------------------------------------- 1 | /* 2 | * GateSeq.h sequence enforcer 3 | * 4 | * Part of dft2lnt library - a library containing read/write operations for DFT 5 | * files in Galileo format and translating DFT specifications into Lotos NT. 6 | * 7 | * @author Enno Ruijters 8 | */ 9 | 10 | class GateSeq; 11 | 12 | #include "Gate.h" 13 | 14 | namespace DFT { 15 | namespace Nodes { 16 | 17 | class GateSeq: public Gate { 18 | private: 19 | 20 | public: 21 | GateSeq(Location loc, std::string name): 22 | Gate(loc,name,GateSeqType) { 23 | } 24 | virtual ~GateSeq() { 25 | } 26 | }; 27 | 28 | } // Namespace: Nodes 29 | } // Namespace: DFT 30 | -------------------------------------------------------------------------------- /dft2lnt/dftnodes/GateVoting.h: -------------------------------------------------------------------------------- 1 | /* 2 | * GateVoting.h 3 | * 4 | * Part of dft2lnt library - a library containing read/write operations for DFT 5 | * files in Galileo format and translating DFT specifications into Lotos NT. 6 | * 7 | * @author Freark van der Berg 8 | */ 9 | 10 | class GateVoting; 11 | 12 | #ifndef GATEVOTING_H 13 | #define GATEVOTING_H 14 | 15 | #include 16 | #include "Gate.h" 17 | 18 | namespace DFT { 19 | namespace Nodes { 20 | 21 | class GateVoting: public Gate { 22 | private: 23 | int threshold; 24 | int total; 25 | mutable std::string cachedName; 26 | public: 27 | GateVoting(Location loc, std::string name, int threshold, int total): 28 | Gate(loc,name,GateVotingType), 29 | threshold(threshold), 30 | total(total) { 31 | } 32 | virtual ~GateVoting() { 33 | } 34 | 35 | int getThreshold() const {return threshold;} 36 | int getTotal() const {return total;} 37 | 38 | virtual const std::string& getTypeStr() const { 39 | if(cachedName.empty()) { 40 | std::stringstream ss; 41 | ss << threshold; 42 | ss << "of"; 43 | ss << total; 44 | cachedName = ss.str(); 45 | } 46 | return cachedName; 47 | } 48 | }; 49 | 50 | } // Namespace: Nodes 51 | } // Namespace: DFT 52 | 53 | #endif // GATEVOTING_H 54 | -------------------------------------------------------------------------------- /dft2lnt/dftnodes/GateWSP.h: -------------------------------------------------------------------------------- 1 | /* 2 | * GateWSP.h 3 | * 4 | * Part of dft2lnt library - a library containing read/write operations for DFT 5 | * files in Galileo format and translating DFT specifications into Lotos NT. 6 | * 7 | * @author Freark van der Berg 8 | */ 9 | 10 | class GateVoting; 11 | 12 | #ifndef GATEWSP_H 13 | #define GATEWSP_H 14 | 15 | #include "Gate.h" 16 | 17 | namespace DFT { 18 | namespace Nodes { 19 | 20 | class GateWSP: public Gate { 21 | private: 22 | 23 | public: 24 | GateWSP(Location loc, std::string name): 25 | Gate(loc,name,GateWSPType) { 26 | } 27 | virtual ~GateWSP() { 28 | } 29 | virtual bool usesDynamicActivation() const { return true; } 30 | }; 31 | 32 | } // Namespace: Nodes 33 | } // Namespace: DFT 34 | 35 | #endif // GATEWSP_H 36 | -------------------------------------------------------------------------------- /dft2lnt/dftnodes/Inspection.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Inspection.h 3 | * 4 | * Part of dft2lnt library - a library containing read/write operations for DFT 5 | * files in Galileo format and translating DFT specifications into Lotos NT. 6 | * 7 | * @author Dennis Guck 8 | */ 9 | 10 | class Inspection; 11 | 12 | #ifndef INSPECTION_H 13 | #define INSPECTION_H 14 | 15 | #include "Gate.h" 16 | 17 | namespace DFT { 18 | namespace Nodes { 19 | 20 | class Inspection: public Gate { 21 | private: 22 | int phases; 23 | decnumber<> lambda; 24 | mutable std::string cachedName; 25 | public: 26 | Inspection(Location loc, std::string name, int phases, decnumber<> lambda): 27 | Gate(loc,name,InspectionType), 28 | phases(phases), 29 | lambda(lambda) { 30 | } 31 | virtual ~Inspection() { 32 | } 33 | 34 | virtual bool outputIsDumb() const { return true; } 35 | 36 | virtual bool repairsChildren() const { return true; } 37 | 38 | int getPhases() const {return phases;} 39 | decnumber<> getLambda() const {return lambda;} 40 | 41 | virtual const std::string& getTypeStr() const { 42 | if(cachedName.empty()) { 43 | std::stringstream ss; 44 | if (phases > 1) 45 | ss << phases; 46 | ss << "insp"; 47 | cachedName = ss.str(); 48 | } 49 | return cachedName; 50 | } 51 | 52 | virtual void setChildRepairs() 53 | { 54 | for (size_t i = 0; i < getChildren().size(); i++) { 55 | DFT::Nodes::Node *child = getChildren().at(i); 56 | if (child->isBasicEvent()) 57 | child->setRepairable(true); 58 | } 59 | } 60 | }; 61 | } // Namespace: Nodes 62 | } // Namespace: DFT 63 | 64 | #endif // INSPECTION_H 65 | -------------------------------------------------------------------------------- /dft2lnt/dftnodes/Node.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Node.cpp 3 | * 4 | * Part of dft2lnt library - a library containing read/write operations for DFT 5 | * files in Galileo format and translating DFT specifications into Lotos NT. 6 | * 7 | * @author Freark van der Berg 8 | * @modified by Dennis Guck 9 | */ 10 | 11 | #include "Node.h" 12 | #include "Gate.h" 13 | #include "GateFDEP.h" 14 | #include 15 | #include 16 | 17 | namespace DFT { 18 | namespace Nodes { 19 | 20 | const std::string Node::BasicEventStr("be"); 21 | const std::string Node::GateAndStr("and"); 22 | const std::string Node::GateSAndStr("sand"); 23 | const std::string Node::GateOrStr("or"); 24 | const std::string Node::GateWSPStr("wsp"); 25 | const std::string Node::GatePAndStr("pand"); 26 | const std::string Node::GatePorStr("por"); 27 | const std::string Node::GateVotingStr("voting"); 28 | const std::string Node::GateFDEPStr("fdep"); 29 | const std::string Node::UnknownStr("XXX"); 30 | const std::string Node::RepairUnitStr("ru"); 31 | const std::string Node::RepairUnitFcfsStr("ru_f"); 32 | const std::string Node::RepairUnitPrioStr("ru_p"); 33 | const std::string Node::RepairUnitNdStr("ru_nd"); 34 | const std::string Node::InspectionStr("inspection"); 35 | const std::string Node::ReplacementStr("replacement"); 36 | 37 | bool Node::hasInspectionModule(void) const { 38 | for (Gate *g : parents) { 39 | Node *n = (Node *)g; 40 | if (n->matchesType(Nodes::InspectionType)) 41 | return true; 42 | } 43 | return false; 44 | } 45 | 46 | bool Node::hasRepairModule(void) const { 47 | for (Gate *g : parents) { 48 | Node *n = (Node *)g; 49 | if (n->matchesType(Nodes::RepairUnitAnyType)) 50 | return true; 51 | } 52 | return false; 53 | } 54 | 55 | bool Node::isIndependentSubtree(void) const { 56 | if (parents.size() > 1) 57 | return false; 58 | if (parents.size() == 0) 59 | return true; 60 | std::unordered_set to_explore, subtree; 61 | to_explore.insert(this); 62 | while (to_explore.size() != 0) { 63 | const Node *current = *to_explore.begin(); 64 | to_explore.erase(current); 65 | subtree.insert(current); 66 | if (current->isGate()) { 67 | const Gate *g = static_cast(current); 68 | for (Node *c : g->getChildren()) { 69 | if (subtree.find(c) == subtree.end()) 70 | to_explore.insert(c); 71 | } 72 | if (g->matchesType(DFT::Nodes::NodeType::GateFDEPType)) { 73 | const GateFDEP *f = static_cast(g); 74 | for (Node *c : f->getDependers()) { 75 | if (subtree.find(c) == subtree.end()) 76 | to_explore.insert(c); 77 | } 78 | } 79 | } 80 | if (current == this) 81 | continue; 82 | for (Node *par : current->parents) { 83 | if (subtree.find(par) == subtree.end()) 84 | to_explore.insert(par); 85 | } 86 | for (Node *par : current->triggers) { 87 | if (subtree.find(par) == subtree.end()) 88 | to_explore.insert(par); 89 | } 90 | } 91 | Node *parent = static_cast(parents[0]); 92 | return subtree.find(parent) == subtree.end(); 93 | } 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /dft2lnt/dftnodes/RepairUnit.h: -------------------------------------------------------------------------------- 1 | /* 2 | * RepairUnit.h 3 | * 4 | * Part of dft2lnt library - a library containing read/write operations for DFT 5 | * files in Galileo format and translating DFT specifications into Lotos NT. 6 | * 7 | * @author Dennis Guck 8 | */ 9 | 10 | class RepairUnit; 11 | 12 | #ifndef REPAIRUNIT_H 13 | #define REPAIRUNIT_H 14 | 15 | #include "Gate.h" 16 | 17 | namespace DFT { 18 | namespace Nodes { 19 | 20 | class RepairUnit: public Gate { 21 | private: 22 | vector dependers; 23 | public: 24 | RepairUnit(Location loc, std::string name): 25 | Gate(loc,name,RepairUnitType) { 26 | } 27 | RepairUnit(Location loc, std::string name, NodeType type): 28 | Gate(loc,name,type) { 29 | } 30 | virtual ~RepairUnit() { 31 | } 32 | 33 | void setDependers(vector dependers) { 34 | this->dependers = dependers; 35 | } 36 | vector& getDependers() { 37 | return dependers; 38 | } 39 | const vector& getDependers() const { 40 | return dependers; 41 | } 42 | virtual bool outputIsDumb() const { return true; } 43 | 44 | DFT::Nodes::Node* getEventSource() const { 45 | if(getChildren().size()!=1) return NULL; 46 | else return getChildren()[0]; 47 | } 48 | }; 49 | 50 | } // Namespace: Nodes 51 | } // Namespace: DFT 52 | 53 | #endif // REPAIRUNIT_H 54 | -------------------------------------------------------------------------------- /dft2lnt/dftnodes/Replacement.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Replacement.h 3 | * 4 | * Part of dft2lnt library - a library containing read/write operations for DFT 5 | * files in Galileo format and translating DFT specifications into Lotos NT. 6 | * 7 | * @author Dennis Guck 8 | */ 9 | 10 | class Replacement; 11 | 12 | #ifndef REPLACEMENT_H 13 | #define REPLACEMENT_H 14 | 15 | #include "Gate.h" 16 | 17 | namespace DFT { 18 | namespace Nodes { 19 | 20 | class Replacement: public Gate { 21 | private: 22 | vector dependers; 23 | int phases; 24 | double lambda; 25 | mutable std::string cachedName; 26 | public: 27 | Replacement(Location loc, std::string name, int phases, double lambda): 28 | Gate(loc,name,ReplacementType), 29 | phases(phases), 30 | lambda(lambda) { 31 | } 32 | virtual ~Replacement() { 33 | } 34 | 35 | void setDependers(vector dependers) { 36 | this->dependers = dependers; 37 | } 38 | vector& getDependers() { 39 | return dependers; 40 | } 41 | const vector& getDependers() const { 42 | return dependers; 43 | } 44 | virtual bool outputIsDumb() const { return true; } 45 | 46 | DFT::Nodes::Node* getEventSource() const { 47 | if(getChildren().size()!=1) return NULL; 48 | else return getChildren()[0]; 49 | } 50 | 51 | int getPhases() const {return phases;} 52 | double getLambda() const {return lambda;} 53 | 54 | virtual const std::string& getTypeStr() const { 55 | if(cachedName.empty()) { 56 | std::stringstream ss; 57 | ss << phases; 58 | ss << "rep"; 59 | //ss << lambda; 60 | cachedName = ss.str(); 61 | } 62 | return cachedName; 63 | } 64 | 65 | }; 66 | 67 | } // Namespace: Nodes 68 | } // Namespace: DFT 69 | 70 | #endif // REPLACEMENT_H 71 | -------------------------------------------------------------------------------- /dft2lnt/dftnodes/nodes.h: -------------------------------------------------------------------------------- 1 | /* 2 | * nodes.h 3 | * 4 | * Part of dft2lnt library - a library containing read/write operations for DFT 5 | * files in Galileo format and translating DFT specifications into Lotos NT. 6 | * 7 | * @author Freark van der Berg extended by Dennis Guck 8 | */ 9 | 10 | #ifndef NODES_H 11 | #define NODES_H 12 | 13 | // nodes.h includes all nodes 14 | #include "dftnodes/Node.h" 15 | #include "dftnodes/BasicEvent.h" 16 | #include "dftnodes/Gate.h" 17 | #include "dftnodes/GateAnd.h" 18 | #include "dftnodes/GateOr.h" 19 | #include "dftnodes/GateVoting.h" 20 | #include "dftnodes/GateWSP.h" 21 | #include "dftnodes/GatePAnd.h" 22 | #include "dftnodes/GatePor.h" 23 | #include "dftnodes/GateSAnd.h" 24 | #include "dftnodes/GateSEQ.h" 25 | #include "dftnodes/GateFDEP.h" 26 | #include "dftnodes/RepairUnit.h" 27 | #include "dftnodes/Inspection.h" 28 | #include "dftnodes/Replacement.h" 29 | 30 | #endif // NODES_H 31 | -------------------------------------------------------------------------------- /dft2lnt/files.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * files.cpp 3 | * 4 | * Part of dft2lnt library - a library containing read/write operations for DFT 5 | * files in Galileo format and translating DFT specifications into Lotos NT. 6 | * 7 | * @author Freark van der Berg 8 | */ 9 | 10 | #include "files.h" 11 | #include 12 | 13 | const std::string DFT::Files::Unknown (""); 14 | const std::string DFT::Files::BasicEvent ("be_cold"); 15 | const std::string DFT::Files::GateAnd ("and"); 16 | const std::string DFT::Files::GateOr ("or"); 17 | const std::string DFT::Files::GateVoting ("voting"); 18 | 19 | const std::string DFT::FileExtensions::DFT ("dft"); 20 | const std::string DFT::FileExtensions::LOTOS ("lotos"); 21 | const std::string DFT::FileExtensions::LOTOSNT ("lnt"); 22 | const std::string DFT::FileExtensions::BCG ("bcg"); 23 | const std::string DFT::FileExtensions::SVL ("svl"); 24 | const std::string DFT::FileExtensions::EXP ("exp"); 25 | 26 | -------------------------------------------------------------------------------- /dft2lnt/files.h: -------------------------------------------------------------------------------- 1 | #ifndef FILES_H 2 | #define FILES_H 3 | 4 | #include 5 | 6 | namespace DFT { 7 | 8 | /** 9 | * The Lotos NT specification files of DFT nodes 10 | */ 11 | namespace Files { 12 | extern const std::string Unknown; 13 | extern const std::string BasicEvent; 14 | extern const std::string GateAnd; 15 | extern const std::string GateOr; 16 | extern const std::string GateVoting; 17 | } 18 | 19 | /** 20 | * The file extensions used throughout dft2lnt 21 | */ 22 | namespace FileExtensions { 23 | extern const std::string DFT; 24 | extern const std::string LOTOS; 25 | extern const std::string LOTOSNT; 26 | extern const std::string BCG; 27 | extern const std::string SVL; 28 | extern const std::string EXP; 29 | } 30 | 31 | } // Namespace: DFT 32 | 33 | #endif // FILES_H -------------------------------------------------------------------------------- /dft2lnt/query.h: -------------------------------------------------------------------------------- 1 | #ifndef DFTCALC_QUERY_H 2 | #define DFTCALC_QUERY_H 3 | #include 4 | #include 5 | #include "decnumber.h" 6 | 7 | enum query_type { UNSPECIFIED, TIMEBOUND, UNBOUNDED, STEADY, EXPECTEDTIME, CUSTOM }; 8 | 9 | class Query { 10 | public: 11 | enum query_type type; 12 | bool min; /* If false, default to max */ 13 | decnumber<> lowerBound, upperBound, step; /* step == -1 for single time */ 14 | std::string customQuery; 15 | decnumber<> errorBound; 16 | bool errorBoundSet; 17 | 18 | Query() :type(UNSPECIFIED), lowerBound(-1), upperBound(-1), step(-1), errorBound("1e-6") {} 19 | 20 | std::string toString() { 21 | switch (type) { 22 | case UNSPECIFIED: 23 | return "?"; 24 | case CUSTOM: 25 | return customQuery; 26 | case TIMEBOUND: 27 | if (step != -1) 28 | return "P(F[in list] FAIL)"; 29 | if (lowerBound == 0) 30 | return "P(F[<=" + upperBound.str() + "] FAIL)"; 31 | else 32 | return "P(F[" + lowerBound.str() + ", " + upperBound.str() + "] FAIL)"; 33 | case STEADY: 34 | return "S(FAILED)"; 35 | case EXPECTEDTIME: 36 | return "MTTF(FAIL)"; 37 | case UNBOUNDED: 38 | return "P(F FAIL)"; 39 | default: 40 | throw std::logic_error("Unknown query type"); 41 | } 42 | } 43 | }; 44 | 45 | /* Defined in mrmc.cpp */ 46 | void expandRangeQueries(std::vector &queries); 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /dft2lnt/yyheader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * yyheader.h 3 | * 4 | * Part of dft2lnt library - a library containing read/write operations for DFT 5 | * files in Galileo format and translating DFT specifications into Lotos NT. 6 | * 7 | * @author Freark van der Berg 8 | */ 9 | 10 | #ifndef YYHEADER_H 11 | #define YYHEADER_H 12 | 13 | class Parser; 14 | 15 | int yyparse(Parser* parser, yyscan_t scanner, DFT::AST::ASTNodes** result_nodes); 16 | int yylex(YYSTYPE * yylval_param,YYLTYPE * yylloc_param ,yyscan_t yyscanner); 17 | void yyerror(Location* location, Parser* parser, yyscan_t scanner, DFT::AST::ASTNodes** result_nodes, const char *str); 18 | extern int yydebug; 19 | extern int yychar; 20 | extern "C" int yywrap(yyscan_t scanner); 21 | 22 | #endif // YYHEADER_H -------------------------------------------------------------------------------- /dft2lntc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ## The DFT2LNT Compiler project 2 | project (dft2lntc) 3 | set (dft2lntc_VERSION_MAJOR 1) 4 | set (dft2lntc_VERSION_MINOR 4) 5 | set (dft2lntc_VERSION_PATCH 0) 6 | set (dft2lntc_VERSION "${dft2lntc_VERSION_MAJOR}.${dft2lntc_VERSION_MINOR}.${dft2lntc_VERSION_PATCH}") 7 | 8 | ## Not sure if needed 9 | cmake_minimum_required (VERSION 3.0) 10 | 11 | if (MSVC) 12 | add_compile_options(/std:c++17) 13 | else() 14 | add_compile_options(-std=c++17) 15 | endif() 16 | 17 | if (DEFINED ENV{CADP}) 18 | add_definitions(-DHAVE_CADP) 19 | endif() 20 | 21 | ## Include source directory, the build directory (for generated files) and the dft2lnt library path 22 | include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../dft2lnt) 23 | 24 | if (DEFINED ENV{CADP}) 25 | set(ADDITIONAL_SOURCES DFTreeBCGNodeBuilder.cpp) 26 | else() 27 | set(ADDITIONAL_SOURCES) 28 | endif() 29 | 30 | 31 | ## Specify the executable and its sources 32 | add_executable(dft2lntc 33 | dft2lntc.cpp 34 | modularize.cpp 35 | DFTreeAUTNodeBuilder.cpp 36 | DFTreeEXPBuilder.cpp 37 | DFTreeNodeBuilder.cpp 38 | ${CMAKE_CURRENT_BINARY_DIR}/compiletime.h 39 | automata/automata.cpp 40 | automata/automaton.cpp 41 | automata/be.cpp 42 | automata/fdep.cpp 43 | automata/insp.cpp 44 | automata/spare.cpp 45 | automata/voting.cpp 46 | automata/pand.cpp 47 | ${ADDITIONAL_SOURCES} 48 | ) 49 | 50 | ## Depends on: 51 | ## - dft2lnt (libdft2lnt.a) 52 | add_dependencies(dft2lntc dft2lnt) 53 | 54 | # Find yaml.h on MacOS with Homebrew 55 | find_path(YAML_INCLUDE_PATH "yaml-cpp/yaml.h") 56 | target_include_directories(dft2lntc PRIVATE ${YAML_INCLUDE_PATH}) 57 | 58 | find_library(YAML_CPP_LIB yaml-cpp) 59 | if("${YAML_CPP_LIB}" STREQUAL "YAML_CPP_LIB-NOTFOUND") 60 | set(YAML_CPP_LIB yaml-cpp) 61 | endif() 62 | 63 | ## Link with: 64 | ## - libdft2lnt.a 65 | ## - yaml-cpp 66 | target_link_libraries(dft2lntc dft2lnt ${YAML_CPP_LIB}) 67 | if (WIN32) 68 | target_link_libraries(dft2lntc pathcch) 69 | endif() 70 | 71 | ## POST_BUILD: copy the executable to the bin/ folder 72 | set(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin) 73 | 74 | ## Installation 75 | install (TARGETS dft2lntc DESTINATION bin) 76 | 77 | # Generate compile time information 78 | set(GENINFOFILE ${CMAKE_CURRENT_BINARY_DIR}/compiletime.h) 79 | get_property(gendepSOURCES TARGET dft2lntc PROPERTY SOURCES) 80 | LIST(REMOVE_ITEM gendepSOURCES ${GENINFOFILE}) 81 | if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../.git/HEAD") 82 | set(GIT_HEAD_DEPENDENCY "${CMAKE_CURRENT_SOURCE_DIR}/../.git/HEAD") 83 | set(NO_GIT 0) 84 | else() 85 | set(GIT_HEAD_DEPENDENCY "") 86 | set(NO_GIT 1) 87 | endif() 88 | add_custom_command( 89 | OUTPUT ${GENINFOFILE} 90 | DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/../compiletime.cmake 91 | ${gendepSOURCES} 92 | ${GIT_HEAD_DEPENDENCY} 93 | COMMAND ${CMAKE_COMMAND} 94 | -DOUTPUT_FILE=${GENINFOFILE} 95 | -DDFTROOT=${DFTROOT} 96 | -DFALLBACK_VERSION=${dft2lntc_VERSION} 97 | -DNO_GIT=${NO_GIT} 98 | -P ${CMAKE_CURRENT_SOURCE_DIR}/../compiletime.cmake 99 | ) 100 | -------------------------------------------------------------------------------- /dft2lntc/DFTreeAUTNodeBuilder.h: -------------------------------------------------------------------------------- 1 | #include "automata/automata.h" 2 | #include "dft2lnt.h" 3 | #include "DFTreeNodeBuilder.h" 4 | #include 5 | 6 | namespace DFT{ 7 | class DFTreeAUTNodeBuilder : public DFTreeNodeBuilder { 8 | public: 9 | static const unsigned int VERSION; 10 | 11 | DFTreeAUTNodeBuilder(std::string cacheDir, DFT::DFTree* dft, CompilerContext* cc) 12 | :DFTreeNodeBuilder(dft, cc), 13 | autRoot(cacheDir + DFT2LNT::AUT_CACHE_DIR + "/") 14 | { } 15 | 16 | virtual std::string getFileForNode(const Nodes::Node& node); 17 | virtual std::string getFileForTopLevel(); 18 | virtual std::string getRoot() { 19 | return autRoot; 20 | } 21 | virtual int generate(); 22 | 23 | private: 24 | set alreadyGenerated; 25 | std::string autRoot; 26 | 27 | int generate(const Nodes::Node &node); 28 | }; 29 | } /* Namespace DFT */ 30 | -------------------------------------------------------------------------------- /dft2lntc/DFTreeNodeBuilder.cpp: -------------------------------------------------------------------------------- 1 | #include "DFTreeNodeBuilder.h" 2 | #include "automata/automata.h" 3 | #include 4 | 5 | std::string DFT::DFTreeNodeBuilder::getNodeName(const DFT::Nodes::Node& node) { 6 | std::stringstream ss; 7 | 8 | if(node.getType()==DFT::Nodes::GateVotingType) 9 | ss << "v"; 10 | else if(node.getType()==DFT::Nodes::InspectionType) 11 | ss << "i"; 12 | else if(node.getType()==DFT::Nodes::ReplacementType) 13 | ss << "r"; 14 | else if (node.getType() == DFT::Nodes::RepairUnitNdType) { 15 | const DFT::Nodes::Gate& gate = *static_cast(&node); 16 | ss << "ru_nd_" << gate.getChildren().size(); 17 | return ss.str(); 18 | } 19 | 20 | ss << node.getTypeStr(); 21 | if(node.isBasicEvent()) { 22 | const DFT::Nodes::BasicEvent& be = *static_cast(&node); 23 | if(be.getMu().is_zero()) { 24 | ss << "_cold"; 25 | } 26 | if(be.getMaintain()>0) { 27 | ss << "_maintain"; 28 | } 29 | if(!be.hasRepairModule()) { 30 | if (be.hasInspectionModule()) 31 | ss << "_im"; 32 | else if (be.isRepairable()) 33 | ss << "_repair"; 34 | } else if(be.isRepairable()) { 35 | if (be.hasInspectionModule()) 36 | ss << "_imrm"; 37 | else 38 | ss << "_rm"; 39 | } 40 | if(be.getLambda().is_zero()) { 41 | ss << "_dummy"; 42 | } 43 | if(be.getFailed()) { 44 | ss << "_failed"; 45 | } 46 | if(be.getPhases()>1){ 47 | ss << "_erl" << be.getPhases(); 48 | } 49 | if(be.getInterval()>0){ 50 | ss << "_interval" << be.getInterval(); 51 | } 52 | if (be.isAlwaysActive()) 53 | ss << "_aa"; 54 | } else if(node.isGate()) { 55 | const DFT::Nodes::Gate& gate = *static_cast(&node); 56 | ss << "_c" << gate.getChildren().size(); 57 | if(node.getType()==DFT::Nodes::GateVotingType) { 58 | const DFT::Nodes::GateVoting& gateVoting = *static_cast(&node); 59 | ss << "_t" << gateVoting.getThreshold(); 60 | } if(node.getType()==DFT::Nodes::GateFDEPType) { 61 | const DFT::Nodes::GateFDEP& gateFDEP = *static_cast(&node); 62 | ss << "_d" << gateFDEP.getDependers().size(); 63 | } if(node.getType()==DFT::Nodes::ReplacementType) { 64 | const DFT::Nodes::Replacement& replacement = *static_cast(&node); 65 | ss << "_p" << replacement.getPhases(); 66 | } 67 | if(node.isRepairable()) { 68 | ss << "_r"; 69 | } 70 | if (node.isAlwaysActive()) 71 | ss << "_aa"; 72 | } else { 73 | assert(0 && "getNodeName(): Unknown node type"); 74 | } 75 | 76 | return ss.str(); 77 | } 78 | -------------------------------------------------------------------------------- /dft2lntc/DFTreeNodeBuilder.h: -------------------------------------------------------------------------------- 1 | #ifndef DFTREENODEBUILDER_H 2 | #define DFTREENODEBUILDER_H 3 | 4 | #include "DFTree.h" 5 | #include "compiler.h" 6 | 7 | namespace DFT { 8 | class DFTreeNodeBuilder { 9 | protected: 10 | const DFT::DFTree* dft; 11 | CompilerContext* cc; 12 | 13 | static std::string getNodeName(const DFT::Nodes::Node& node); 14 | public: 15 | DFTreeNodeBuilder(DFT::DFTree* dft, CompilerContext* cc) 16 | :dft(dft), cc(cc) 17 | { } 18 | 19 | /** 20 | * Returns the Lotos NT File needed for the specified node. 21 | * @return he Lotos NT File needed for the specified node. 22 | */ 23 | virtual std::string getFileForNode(const Nodes::Node& node) = 0; 24 | virtual std::string getFileForTopLevel() = 0; 25 | virtual std::string getRoot() = 0; 26 | virtual int generate() = 0; 27 | }; 28 | } /* Namespace DFT */ 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /dft2lntc/automata/automata.cpp: -------------------------------------------------------------------------------- 1 | #include "automata/signals.h" 2 | #include 3 | -------------------------------------------------------------------------------- /dft2lntc/automata/automata.h: -------------------------------------------------------------------------------- 1 | #include "automata/signals.h" 2 | #include "automata/automaton.h" 3 | 4 | #include "automata/be.h" 5 | #include "automata/voting.h" 6 | #include "automata/pand.h" 7 | #include "automata/spare.h" 8 | #include "automata/insp.h" 9 | #include "automata/fdep.h" 10 | -------------------------------------------------------------------------------- /dft2lntc/automata/automaton.cpp: -------------------------------------------------------------------------------- 1 | #include "automata/automaton.h" 2 | #include 3 | 4 | void automaton::write(std::ostream &out) 5 | { 6 | const state *init = initial_state(); 7 | add_state(init->copy()); 8 | size_t pos = 0; 9 | size_t n_transitions = 0; 10 | while (pos < states.size()) { 11 | state *s = states[pos]; 12 | s->initialize_outgoing(); 13 | pos++; 14 | } 15 | tau_collapse(); 16 | for (const state *s : states) 17 | n_transitions += s->outgoing.size(); 18 | out << "des (0, " << n_transitions << ", " << states.size() 19 | << ")\n"; 20 | for (pos = 0; pos < states.size(); pos++) { 21 | for (auto transition : states[pos]->outgoing) { 22 | out << "(" << pos << ", \"" 23 | << transition.first << "\", " 24 | << transition.second << ") " 25 | //<< (std::string) *states[pos] 26 | << "\n"; 27 | } 28 | } 29 | } 30 | 31 | static void merge(std::set> &target, 32 | const std::set> &source) 33 | { 34 | for (auto &entry : source) 35 | target.emplace(entry.first, entry.second); 36 | } 37 | 38 | void automaton::tau_collapse() 39 | { 40 | for (state *s : states) { 41 | auto it = s->outgoing.begin(); 42 | for (; it != s->outgoing.end(); ++it) { 43 | if (it->first == "") { 44 | size_t t = it->second; 45 | s->outgoing.erase(it); 46 | merge(s->outgoing, states[t]->outgoing); 47 | it = s->outgoing.begin(); 48 | } 49 | } 50 | } 51 | std::vector reachable(states.size()); 52 | reachable[0] = true; 53 | bool change = true; 54 | while (change) { 55 | change = false; 56 | for (size_t i = 0; i < states.size(); i++) { 57 | if (!reachable[i]) 58 | continue; 59 | for (auto &trans : states[i]->outgoing) { 60 | if (!reachable[trans.second]) { 61 | change = true; 62 | reachable[trans.second] = true; 63 | } 64 | } 65 | } 66 | } 67 | for (size_t i = 0; i < states.size(); i++) { 68 | if (!reachable[i]) 69 | states[i]->outgoing.clear(); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /dft2lntc/automata/automaton.h: -------------------------------------------------------------------------------- 1 | #ifndef AUTOMATA_H 2 | #define AUTOMATA_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | /* Warning to new automata: 12 | * Internal actions can be indicated by leaving the action empty. 13 | * However, these will be collapsed before the automaton is output. 14 | * The tau-reduction does not consider probabilistic behaviour (as 15 | * stochastic behaviour may not be known before the later renaming 16 | * step), and will produce incorrect results if a tau-action decides 17 | * what stochastic transitions will be enabled. 18 | */ 19 | class automaton { 20 | public: 21 | class state { 22 | private: 23 | std::set> outgoing; 24 | automaton * parent; 25 | 26 | protected: 27 | state(automaton *parent) 28 | :parent(parent) 29 | { } 30 | 31 | virtual void initialize_outgoing() = 0; 32 | void add_transition(std::string label, const state &target) { 33 | size_t target_num = parent->add_state(&target); 34 | outgoing.emplace(std::make_pair(label, target_num)); 35 | } 36 | 37 | public: 38 | virtual size_t hashcode() const noexcept = 0; 39 | virtual bool operator==(const state &other) const noexcept = 0; 40 | virtual state *copy() const = 0; 41 | 42 | virtual ~state() { } 43 | 44 | virtual operator std::string() const { 45 | return ""; 46 | } 47 | 48 | automaton *get_parent() { 49 | return parent; 50 | } 51 | 52 | const automaton *get_parent() const { 53 | return parent; 54 | } 55 | 56 | friend class automaton; 57 | }; 58 | 59 | class stateHash { 60 | public: 61 | size_t operator()(const state * const &s) const { 62 | return s->hashcode(); 63 | } 64 | }; 65 | 66 | class ptr_equal { 67 | public: 68 | size_t operator()(const state * const &s1, 69 | const state * const &s2) const 70 | { 71 | return *s1 == *s2; 72 | } 73 | }; 74 | 75 | virtual const state *initial_state() const = 0; 76 | 77 | void write(std::ostream &out); 78 | 79 | virtual ~automaton() { 80 | for (state *entry : states) { 81 | delete entry; 82 | } 83 | } 84 | 85 | private: 86 | std::unordered_map stateNums; 87 | std::vector states; 88 | 89 | size_t add_state(const state *newState) { 90 | auto existing = stateNums.find(newState); 91 | if (existing != stateNums.end()) 92 | return existing->second; 93 | state *copy = newState->copy(); 94 | copy->outgoing.clear(); 95 | size_t ret = stateNums.size(); 96 | stateNums.emplace(copy, ret); 97 | states.emplace_back(copy); 98 | return ret; 99 | } 100 | 101 | void tau_collapse(); 102 | }; 103 | 104 | #endif 105 | -------------------------------------------------------------------------------- /dft2lntc/automata/fdep.cpp: -------------------------------------------------------------------------------- 1 | #include "automata/fdep.h" 2 | 3 | namespace automata { 4 | using namespace signals; 5 | 6 | void fdep::fdep_state::initialize_outgoing() { 7 | const fdep *par = (const fdep *)get_parent(); 8 | 9 | fdep_state target = *this; 10 | target.failed = true; 11 | add_transition(FAIL(1), target); 12 | 13 | target = *this; 14 | target.act = 1; 15 | add_transition(ACTIVATE(0, false), target); 16 | 17 | if (act == 1 && !par->trigger_always_active) { 18 | target = *this; 19 | target.act = 0; 20 | add_transition(ACTIVATE(1, true), target); 21 | } 22 | 23 | /* Nondeterministically fail the dependers after trigger 24 | * failure. 25 | */ 26 | if (failed) { 27 | for (size_t i = 0; i < par->total; i++) { 28 | if (!notified[i]) { 29 | target = *this; 30 | target.notified[i] = true; 31 | add_transition(FAIL(i + 2), target); 32 | } 33 | } 34 | } 35 | } 36 | 37 | fdep::fdep_state::operator std::string() const { 38 | std::string ret = "["; 39 | ret += std::to_string(act); 40 | if (failed) 41 | ret += ", failed"; 42 | ret += ", {"; 43 | for (size_t i = 0; i < notified.size(); i++) 44 | ret += notified[i] ? "T" : "F"; 45 | ret += "}]"; 46 | return ret; 47 | } 48 | 49 | } /* Namespace automata */ 50 | -------------------------------------------------------------------------------- /dft2lntc/automata/fdep.h: -------------------------------------------------------------------------------- 1 | #ifndef AUTOMATA_H 2 | #include "automata/automata.h" 3 | #endif 4 | 5 | #ifndef AUTOMATA_FDEP_H 6 | #define AUTOMATA_FDEP_H 7 | #include "dftnodes/GateFDEP.h" 8 | #include 9 | 10 | namespace automata { 11 | class fdep : public automaton { 12 | const size_t total; 13 | const bool trigger_always_active : 1; 14 | 15 | class fdep_state : public automaton::state { 16 | private: 17 | size_t act; 18 | std::vector notified; 19 | bool failed : 1; 20 | 21 | fdep_state(fdep *parent) 22 | :automaton::state(parent), 23 | act(0), 24 | notified(parent->total), 25 | failed(0) 26 | { } 27 | 28 | friend class fdep; 29 | 30 | public: 31 | size_t hashcode() const noexcept { 32 | size_t ret = act << 1; 33 | ret += failed; 34 | ret *= 33; 35 | ret += std::hash>()(notified); 36 | return ret; 37 | } 38 | 39 | virtual state *copy() const { 40 | return new fdep_state(*this); 41 | } 42 | 43 | bool operator==(const state &other) const noexcept { 44 | if (get_parent() != other.get_parent()) 45 | return 0; 46 | const fdep_state &o = static_cast(other); 47 | return act == o.act 48 | && notified == o.notified 49 | && failed == o.failed; 50 | } 51 | 52 | virtual operator std::string() const; 53 | 54 | protected: 55 | virtual void initialize_outgoing(); 56 | }; 57 | 58 | fdep_state initial_fdep_state; 59 | 60 | public: 61 | fdep(const DFT::Nodes::GateFDEP &gate) 62 | : total(gate.getDependers().size()), 63 | trigger_always_active(gate.getChildren()[0]->isAlwaysActive()), 64 | initial_fdep_state(this) 65 | { } 66 | 67 | const state *initial_state() const { 68 | return &initial_fdep_state; 69 | } 70 | }; 71 | }; 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /dft2lntc/automata/insp.cpp: -------------------------------------------------------------------------------- 1 | #include "automata/insp.h" 2 | 3 | namespace automata { 4 | using namespace signals; 5 | 6 | void insp::insp_state::initialize_outgoing() { 7 | size_t i; 8 | const insp *par = (const insp *)get_parent(); 9 | 10 | for (i = 1; i <= par->total; i++) { 11 | insp_state target = *this; 12 | target.signal = true; 13 | add_transition(INSPECT(i), target); 14 | } 15 | 16 | if (counter < par->phases) { 17 | insp_state target = *this; 18 | target.counter++; 19 | if (target.counter == par->phases && !signal) 20 | target.counter = 0; 21 | add_transition(RATE_INSPECTION(1), target); 22 | } 23 | 24 | if (counter == par->phases) { 25 | insp_state target = *this; 26 | target.counter = 0; 27 | target.signal = false; 28 | add_transition(REPAIR(0), target); 29 | } 30 | } 31 | 32 | insp::insp_state::operator std::string() const { 33 | std::string ret = "["; 34 | ret += std::to_string(counter); 35 | if (signal) 36 | ret += ", signalled"; 37 | ret += "]"; 38 | return ret; 39 | } 40 | 41 | } /* Namespace automata */ 42 | -------------------------------------------------------------------------------- /dft2lntc/automata/insp.h: -------------------------------------------------------------------------------- 1 | #ifndef AUTOMATA_H 2 | #include "automata/automata.h" 3 | #endif 4 | 5 | #ifndef AUTOMATA_INSP_H 6 | #define AUTOMATA_INSP_H 7 | #include "dftnodes/Inspection.h" 8 | 9 | namespace automata { 10 | class insp : public automaton { 11 | const size_t total; 12 | const size_t phases; 13 | 14 | class insp_state : public automaton::state { 15 | private: 16 | size_t counter; 17 | bool signal : 1; 18 | 19 | insp_state(insp *parent) 20 | :automaton::state(parent), 21 | counter(0), signal(0) 22 | { } 23 | 24 | friend class insp; 25 | 26 | public: 27 | size_t hashcode() const noexcept { 28 | return (counter << 1) + signal; 29 | } 30 | 31 | virtual state *copy() const { 32 | return new insp_state(*this); 33 | } 34 | 35 | bool operator==(const state &other) const noexcept { 36 | if (get_parent() != other.get_parent()) 37 | return 0; 38 | const insp_state &o = static_cast(other); 39 | return counter == o.counter 40 | && signal == o.signal; 41 | } 42 | 43 | virtual operator std::string() const; 44 | 45 | protected: 46 | virtual void initialize_outgoing(); 47 | }; 48 | 49 | insp_state initial_insp_state; 50 | 51 | public: 52 | insp(const DFT::Nodes::Inspection &gate) 53 | : total(gate.getChildren().size()), 54 | phases(gate.getPhases() ? gate.getPhases() : 1), 55 | initial_insp_state(this) 56 | { } 57 | 58 | const state *initial_state() const { 59 | return &initial_insp_state; 60 | } 61 | }; 62 | }; 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /dft2lntc/automata/pand.cpp: -------------------------------------------------------------------------------- 1 | #include "automata/pand.h" 2 | 3 | namespace automata { 4 | using namespace signals; 5 | 6 | void pand::pand_state::initialize_outgoing() { 7 | if (terminated) 8 | return; 9 | 10 | pand_state target(*this); 11 | if (impossible) { 12 | target.terminated = 1; 13 | add_transition(GATE_IMPOSSIBLE, target); 14 | return; 15 | } 16 | size_t i; 17 | const pand *par = (const pand *)get_parent(); 18 | 19 | for (i = 1; i <= par->total; i++) { 20 | target = *this; 21 | if (!failed[i]) { 22 | target.failed[i] = 1; 23 | target.nr_failed++; 24 | if (i == in_order_mark + 1) 25 | target.in_order_mark = i; 26 | } 27 | add_transition(FAIL(i), target); 28 | } 29 | 30 | for (i = 1; i <= par->total; i++) { 31 | target = *this; 32 | if (!par->repairable || !failed[i]) { 33 | target.impossible = 1; 34 | } else { 35 | target.failed[i] = 0; 36 | target.nr_failed--; 37 | if (i <= in_order_mark) 38 | target.in_order_mark = i - 1; 39 | } 40 | add_transition(ONLINE(i), target); 41 | } 42 | 43 | if (in_order_mark == par->total && !done) { 44 | target = *this; 45 | target.done = true; 46 | add_transition(FAIL(0), target); 47 | } 48 | 49 | if (in_order_mark < par->total && done) { 50 | target = *this; 51 | target.done = false; 52 | add_transition(ONLINE(0), target); 53 | } 54 | 55 | target = *this; 56 | if (!par->always_active) { 57 | if (nr_active == 0) 58 | target.nr_active = 1; 59 | } 60 | add_transition(ACTIVATE(0, false), target); 61 | 62 | target = *this; 63 | target.impossible = 1; 64 | add_transition(DEACTIVATE(0, false), target); 65 | 66 | if (nr_active > 0) { 67 | target = *this; 68 | if (nr_active < par->total) 69 | target.nr_active = nr_active + 1; 70 | else 71 | target.nr_active = 0; 72 | add_transition(ACTIVATE(nr_active, true), target); 73 | } 74 | } 75 | 76 | pand::pand_state::operator std::string() const { 77 | if (terminated) 78 | return "[]"; 79 | if (impossible) 80 | return "[IMPOSSIBLE]"; 81 | std::string ret = "["; 82 | ret += std::to_string(nr_failed); 83 | ret += ", io="; 84 | ret += std::to_string(in_order_mark); 85 | ret += ", act="; 86 | ret += std::to_string(nr_active); 87 | if (done) 88 | ret += ", done"; 89 | ret += ", {"; 90 | for (size_t i = 0; i < failed.size(); i++) { 91 | if (!failed[i]) 92 | ret += 'A'; 93 | else 94 | ret += 'F'; 95 | } 96 | ret += "}]"; 97 | return ret; 98 | } 99 | 100 | } /* Namespace automata */ 101 | -------------------------------------------------------------------------------- /dft2lntc/automata/pand.h: -------------------------------------------------------------------------------- 1 | #ifndef AUTOMATA_H 2 | #include "automata/automata.h" 3 | #endif 4 | 5 | #ifndef AUTOMATA_PAND_H 6 | #define AUTOMATA_PAND_H 7 | #include "dftnodes/GatePAnd.h" 8 | #include 9 | 10 | namespace automata { 11 | class pand : public automaton { 12 | const size_t total; 13 | const bool repairable : 1; 14 | const bool always_active : 1; 15 | 16 | class pand_state : public automaton::state { 17 | private: 18 | std::vector failed; 19 | size_t nr_failed = 0; 20 | size_t nr_active = 0; 21 | size_t in_order_mark = 0; 22 | bool done : 1; 23 | bool impossible : 1; 24 | bool terminated : 1; 25 | 26 | pand_state(pand *parent) 27 | :automaton::state(parent), 28 | failed(parent->total + 1), 29 | nr_failed(0), nr_active(0), in_order_mark(0), 30 | done(0), impossible(0), terminated(0) 31 | { } 32 | 33 | friend class pand; 34 | 35 | public: 36 | size_t hashcode() const noexcept { 37 | if (terminated) 38 | return 0; 39 | if (impossible) 40 | return 1; 41 | size_t ret = 2; 42 | ret = (ret * 33) + nr_failed; 43 | ret = (ret * 33) + nr_active; 44 | ret = (ret * 33) + in_order_mark; 45 | ret = (ret * 33) + done; 46 | ret = (ret * 33) + std::hash>()(failed); 47 | return ret; 48 | } 49 | 50 | virtual state *copy() const { 51 | return new pand_state(*this); 52 | } 53 | 54 | bool operator==(const state &other) const noexcept { 55 | if (get_parent() != other.get_parent()) 56 | return 0; 57 | const pand_state &o = static_cast(other); 58 | if (terminated) 59 | return o.terminated; 60 | if (o.terminated) 61 | return 0; 62 | if (impossible) 63 | return o.impossible; 64 | if (o.impossible) 65 | return 0; 66 | return nr_failed == o.nr_failed 67 | && nr_active == o.nr_active 68 | && in_order_mark == o.in_order_mark 69 | && done == o.done 70 | && failed == o.failed; 71 | } 72 | 73 | virtual operator std::string() const; 74 | 75 | protected: 76 | virtual void initialize_outgoing(); 77 | }; 78 | 79 | pand_state initial_pand_state; 80 | 81 | public: 82 | pand(const DFT::Nodes::GatePAnd &gate) 83 | : total(gate.getChildren().size()), 84 | repairable(total), 85 | always_active(gate.isAlwaysActive()), 86 | initial_pand_state(this) 87 | { 88 | } 89 | 90 | const state *initial_state() const { 91 | return &initial_pand_state; 92 | } 93 | }; 94 | }; 95 | 96 | #endif 97 | -------------------------------------------------------------------------------- /dft2lntc/automata/signals.h: -------------------------------------------------------------------------------- 1 | #ifndef AUTOMATA_SIGNALS_H 2 | #define AUTOMATA_SIGNALS_H 3 | #include 4 | 5 | namespace automata { 6 | namespace signals { 7 | static inline const std::string GATE_FAIL("FAIL"); 8 | static inline const std::string GATE_ACTIVATE("ACTIVATE"); 9 | static inline const std::string GATE_DEACTIVATE("DEACTIVATE"); 10 | /* REPAIR?: Insp to BE: Start repairing 11 | * REPAIR!: BE to RU: In need of repair. 12 | */ 13 | static inline const std::string GATE_REPAIR("REPAIR"); 14 | /* REPAIRED: BE to RU: Repair finished */ 15 | static inline const std::string GATE_REPAIRED("REPAIRED"); 16 | static inline const std::string GATE_ONLINE("ONLINE"); 17 | static inline const std::string GATE_RATE_FAIL("RATE_FAIL"); 18 | static inline const std::string GATE_RATE_PERIOD("RATE_PERIOD"); 19 | static inline const std::string GATE_RATE_REPAIR("RATE_REPAIR"); 20 | static inline const std::string GATE_RATE_INSPECTION("RATE_INSPECTION"); 21 | /* REPAIRING: RU to BE: Start repair time */ 22 | static inline const std::string GATE_REPAIRING("REPAIRING"); 23 | static inline const std::string GATE_INSPECT("INSPECT"); 24 | static inline const std::string GATE_IMPOSSIBLE("IMPOSSIBLE"); 25 | 26 | static inline std::string ACTIVATE(size_t num, bool direction) { 27 | std::string ret = GATE_ACTIVATE + " !"; 28 | ret += std::to_string(num); 29 | ret += " !"; 30 | ret += direction ? "TRUE" : "FALSE"; 31 | return ret; 32 | } 33 | 34 | static inline std::string DEACTIVATE(size_t num, bool direction) { 35 | std::string ret = GATE_DEACTIVATE + " !"; 36 | ret += std::to_string(num); 37 | ret += " !"; 38 | ret += direction ? "TRUE" : "FALSE"; 39 | return ret; 40 | } 41 | 42 | static inline std::string FAIL(size_t num) { 43 | std::string ret = GATE_FAIL + " !"; 44 | ret += std::to_string(num); 45 | return ret; 46 | } 47 | 48 | static inline std::string ONLINE(size_t num) { 49 | std::string ret = GATE_ONLINE + " !"; 50 | ret += std::to_string(num); 51 | return ret; 52 | } 53 | 54 | static inline std::string RATE_FAIL(size_t num1, size_t num2) { 55 | std::string ret = GATE_RATE_FAIL + " !"; 56 | ret += std::to_string(num1); 57 | ret += " !"; 58 | ret += std::to_string(num2); 59 | return ret; 60 | } 61 | 62 | static inline std::string RATE_INSPECTION(size_t num) { 63 | std::string ret = GATE_RATE_INSPECTION + " !"; 64 | ret += std::to_string(num); 65 | return ret; 66 | } 67 | 68 | static inline std::string INSPECT(size_t num) { 69 | std::string ret = GATE_INSPECT + " !"; 70 | ret += std::to_string(num); 71 | return ret; 72 | } 73 | 74 | static inline std::string REPAIR(bool direction) { 75 | std::string ret = GATE_REPAIR + " !"; 76 | ret += direction ? "TRUE" : "FALSE"; 77 | return ret; 78 | } 79 | 80 | static inline std::string REPAIR(int num) { 81 | std::string ret = GATE_REPAIR + " !"; 82 | ret += std::to_string(num); 83 | return ret; 84 | } 85 | 86 | static inline std::string REPAIRING(size_t num) { 87 | std::string ret = GATE_REPAIRING + " !"; 88 | ret += std::to_string(num); 89 | return ret; 90 | } 91 | 92 | static inline std::string REPAIRED(size_t num) { 93 | std::string ret = GATE_REPAIRED + " !"; 94 | ret += std::to_string(num); 95 | return ret; 96 | } 97 | }; 98 | }; 99 | 100 | #endif 101 | -------------------------------------------------------------------------------- /dft2lntc/automata/spare.h: -------------------------------------------------------------------------------- 1 | #ifndef AUTOMATA_H 2 | #include "automata/automata.h" 3 | #endif 4 | 5 | #ifndef AUTOMATA_SPARE_H 6 | #define AUTOMATA_SPARE_H 7 | #include "dftnodes/GateWSP.h" 8 | #include 9 | 10 | namespace automata { 11 | class spare : public automaton { 12 | const size_t total; 13 | bool repairable : 1; 14 | const bool always_active : 1; 15 | 16 | class spare_state : public automaton::state { 17 | private: 18 | set unfailed; 19 | set unclaimed; 20 | size_t repairing_deactivate; 21 | size_t cur_using; 22 | size_t prev_using; 23 | bool done : 1; 24 | bool activated : 1; 25 | bool impossible : 1; 26 | bool terminated : 1; 27 | 28 | spare_state(spare *parent) 29 | :automaton::state(parent), 30 | repairing_deactivate(0), 31 | cur_using(parent->always_active ? 1 : 0), 32 | prev_using(0), done(0), 33 | activated(parent->always_active), 34 | impossible(0), terminated(0) 35 | { 36 | for (size_t i = 1; i <= parent->total; i++) { 37 | unfailed.insert(i); 38 | unclaimed.insert(i); 39 | } 40 | } 41 | 42 | void add_transition(std::string label, spare_state &target); 43 | friend class spare; 44 | 45 | public: 46 | size_t hashcode() const noexcept { 47 | if (terminated) 48 | return 0; 49 | if (impossible) 50 | return 1; 51 | size_t ret = cur_using; 52 | ret = (ret * 33) + repairing_deactivate; 53 | ret = (ret * 33) + prev_using; 54 | ret = (ret * 33) + done; 55 | ret = (ret * 33) + activated; 56 | for (size_t i : unfailed) 57 | ret = (ret * 33) + i; 58 | for (size_t i : unclaimed) 59 | ret = (ret * 31) + i; 60 | return ret; 61 | } 62 | 63 | virtual state *copy() const { 64 | return new spare_state(*this); 65 | } 66 | 67 | bool operator==(const state &other) const noexcept { 68 | if (get_parent() != other.get_parent()) 69 | return 0; 70 | const spare_state &o = static_cast(other); 71 | if (terminated) 72 | return o.terminated; 73 | if (o.terminated) 74 | return 0; 75 | if (impossible) 76 | return o.impossible; 77 | if (o.impossible) 78 | return 0; 79 | return done == o.done 80 | && repairing_deactivate == o.repairing_deactivate 81 | && cur_using == o.cur_using 82 | && prev_using == o.prev_using 83 | && activated == o.activated 84 | && unfailed == o.unfailed 85 | && unclaimed == o.unclaimed; 86 | } 87 | 88 | virtual operator std::string() const; 89 | 90 | protected: 91 | virtual void initialize_outgoing(); 92 | }; 93 | 94 | spare_state initial_spare_state; 95 | 96 | public: 97 | spare(const DFT::Nodes::GateWSP &gate) 98 | : total(gate.getChildren().size()), 99 | always_active(gate.isAlwaysActive()), 100 | initial_spare_state(this) 101 | { 102 | for (const auto *child : gate.getChildren()) { 103 | if (child->isRepairable()) { 104 | repairable = true; 105 | break; 106 | } 107 | } 108 | } 109 | 110 | const state *initial_state() const { 111 | return &initial_spare_state; 112 | } 113 | }; 114 | }; 115 | 116 | #endif 117 | -------------------------------------------------------------------------------- /dft2lntc/automata/voting.cpp: -------------------------------------------------------------------------------- 1 | #include "automata/voting.h" 2 | 3 | namespace automata { 4 | using namespace signals; 5 | 6 | void voting::voting_state::initialize_outgoing() { 7 | if (terminated) 8 | return; 9 | 10 | voting_state target(*this); 11 | if (impossible) { 12 | target.terminated = 1; 13 | add_transition(GATE_IMPOSSIBLE, target); 14 | return; 15 | } 16 | size_t nr_act, i; 17 | const voting *par = (const voting *)get_parent(); 18 | 19 | if (running) { 20 | nr_act = 1; 21 | while (nr_act > 0 && activated[nr_act]) { 22 | if (nr_act == par->total) 23 | nr_act = 0; 24 | else 25 | nr_act++; 26 | } 27 | } else { 28 | nr_act = par->total; 29 | while (nr_act > 0 && !activated[nr_act]) 30 | nr_act--; 31 | } 32 | 33 | for (i = 1; i <= par->total; i++) { 34 | target = *this; 35 | if (!received[i]) { 36 | target.received[i] = 1; 37 | target.nr_failed++; 38 | if (target.nr_failed == par->threshold && !done) 39 | target.emit_fail = 1; 40 | } 41 | add_transition(FAIL(i), target); 42 | } 43 | 44 | if (emit_fail && !done) { 45 | target = *this; 46 | target.done = 1; 47 | target.emit_fail = 0; 48 | add_transition(FAIL(0), target); 49 | } 50 | 51 | for (i = 1; i <= par->total; i++) { 52 | target = *this; 53 | if (i > par->repairable || !received[i]) { 54 | target.impossible = 1; 55 | } else { 56 | target.received[i] = 0; 57 | target.nr_failed--; 58 | } 59 | add_transition(ONLINE(i), target); 60 | } 61 | 62 | if (done && nr_failed < par->threshold) { 63 | target = *this; 64 | target.done = 0; 65 | add_transition(ONLINE(0), target); 66 | } 67 | 68 | if (!par->always_active) { 69 | target = *this; 70 | target.running = true; 71 | add_transition(ACTIVATE(0, false), target); 72 | } 73 | 74 | target = *this; 75 | if (!par->always_active) { 76 | target.running = false; 77 | } else { 78 | target.impossible = true; 79 | } 80 | add_transition(DEACTIVATE(0, false), target); 81 | 82 | if (running && nr_act) { 83 | target = *this; 84 | target.activated[nr_act] = 1; 85 | add_transition(ACTIVATE(nr_act, true), target); 86 | } 87 | 88 | if (!running && nr_act) { 89 | target = *this; 90 | target.activated[nr_act] = 0; 91 | add_transition(DEACTIVATE(nr_act, true), target); 92 | } 93 | } 94 | 95 | voting::voting_state::operator std::string() const { 96 | if (terminated) 97 | return "[]"; 98 | if (impossible) 99 | return "[IMPOSSIBLE]"; 100 | std::string ret = "["; 101 | ret += std::to_string(nr_failed); 102 | if (done) 103 | ret += ", done"; 104 | if (running) 105 | ret += ", running"; 106 | ret += ", {"; 107 | for (size_t i = 0; i < received.size(); i++) { 108 | if (!received[i] && !activated[i]) 109 | ret += 'I'; 110 | if (!received[i] && activated[i]) 111 | ret += 'A'; 112 | if (received[i] && !activated[i]) 113 | ret += 'F'; 114 | if (!received[i] && !activated[i]) 115 | ret += 'f'; 116 | } 117 | ret += "}]"; 118 | return ret; 119 | } 120 | 121 | } /* Namespace automata */ 122 | -------------------------------------------------------------------------------- /dft2lntc/automata/voting.h: -------------------------------------------------------------------------------- 1 | #ifndef AUTOMATA_H 2 | #include "automata/automata.h" 3 | #endif 4 | 5 | #ifndef AUTOMATA_VOTING_H 6 | #define AUTOMATA_VOTING_H 7 | #include "dftnodes/GateOr.h" 8 | #include "dftnodes/GateAnd.h" 9 | #include "dftnodes/GateVoting.h" 10 | #include 11 | 12 | namespace automata { 13 | class voting : public automaton { 14 | const size_t total; 15 | const size_t threshold; 16 | const size_t repairable; 17 | const bool always_active : 1; 18 | 19 | class voting_state : public automaton::state { 20 | private: 21 | size_t nr_failed = 0; 22 | bool emit_fail : 1; 23 | bool done : 1; 24 | bool running : 1; 25 | bool impossible : 1; 26 | bool terminated : 1; 27 | std::vector received; 28 | std::vector activated; 29 | 30 | voting_state(voting *parent) 31 | :automaton::state(parent), 32 | emit_fail(0), 33 | done(0), running(0), 34 | impossible(0), terminated(0), 35 | received(parent->total + 1), 36 | activated(parent->total + 1) 37 | { } 38 | 39 | friend class voting; 40 | 41 | public: 42 | size_t hashcode() const noexcept { 43 | if (terminated) 44 | return 0; 45 | if (impossible) 46 | return 1; 47 | size_t ret = 2; 48 | ret = (ret * 33) + emit_fail; 49 | ret = (ret * 33) + nr_failed; 50 | ret = (ret * 33) + done; 51 | ret = (ret * 33) + running; 52 | ret = (ret * 33) + std::hash>()(received); 53 | ret = (ret * 33) + std::hash>()(activated); 54 | return ret; 55 | } 56 | 57 | virtual state *copy() const { 58 | return new voting_state(*this); 59 | } 60 | 61 | bool operator==(const state &other) const noexcept { 62 | if (get_parent() != other.get_parent()) 63 | return 0; 64 | const voting_state &o = static_cast(other); 65 | if (terminated) 66 | return o.terminated; 67 | if (o.terminated) 68 | return 0; 69 | if (impossible) 70 | return o.impossible; 71 | if (o.impossible) 72 | return 0; 73 | return nr_failed == o.nr_failed 74 | && emit_fail == o.emit_fail 75 | && done == o.done 76 | && running == o.running 77 | && received == o.received 78 | && activated == o.activated; 79 | } 80 | 81 | virtual operator std::string() const; 82 | 83 | protected: 84 | virtual void initialize_outgoing(); 85 | }; 86 | 87 | voting_state initial_voting_state; 88 | 89 | public: 90 | voting(const DFT::Nodes::GateOr &gate) 91 | : total(gate.getChildren().size()), 92 | threshold(1), 93 | repairable(total), 94 | always_active(gate.isAlwaysActive()), 95 | initial_voting_state(this) 96 | { 97 | } 98 | 99 | voting(const DFT::Nodes::GateAnd &gate) 100 | : total(gate.getChildren().size()), 101 | threshold(gate.getChildren().size()), 102 | repairable(total), 103 | always_active(gate.isAlwaysActive()), 104 | initial_voting_state(this) 105 | { 106 | } 107 | 108 | voting(const DFT::Nodes::GateVoting &gate) 109 | : total(gate.getChildren().size()), 110 | threshold(gate.getThreshold()), 111 | repairable(total), 112 | always_active(gate.isAlwaysActive()), 113 | initial_voting_state(this) 114 | { 115 | } 116 | 117 | const state *initial_state() const { 118 | return &initial_voting_state; 119 | } 120 | }; 121 | }; 122 | 123 | #endif 124 | -------------------------------------------------------------------------------- /dft2lntc/modularize.cpp: -------------------------------------------------------------------------------- 1 | #include "modularize.h" 2 | #include "dftnodes/nodes.h" 3 | #include 4 | #include 5 | #include 6 | 7 | static void writeModules(std::ostream &out, DFT::DFTree *dft, DFT::Nodes::Node *root) 8 | { 9 | if (root->matchesType(DFT::Nodes::NodeType::BasicEventType)) { 10 | DFT::Nodes::BasicEvent *be; 11 | be = static_cast(root); 12 | if (be->getLambda() == -1) { 13 | out << "=" << be->getProb().str() << "\n"; 14 | return; 15 | } 16 | } 17 | if (root->outputIsDumb()) { 18 | out << "=0\n"; 19 | return; 20 | } 21 | if (!(root->matchesType(DFT::Nodes::NodeType::GateAndType) 22 | || root->matchesType(DFT::Nodes::NodeType::GateOrType) 23 | || root->matchesType(DFT::Nodes::NodeType::GateVotingType))) 24 | { 25 | out << "M" << root->getName() << "\n"; 26 | return; 27 | } 28 | DFT::Nodes::Gate *g = static_cast(root); 29 | std::vector children = g->getChildren(); 30 | for (DFT::Nodes::Node *child : children) { 31 | if (!child->isIndependentSubtree()) { 32 | out << "M" << root->getName() << "\n"; 33 | return; 34 | } 35 | } 36 | if (root->matchesType(DFT::Nodes::NodeType::GateAndType)) 37 | out << "*" << children.size() << "\n"; 38 | else if (root->matchesType(DFT::Nodes::NodeType::GateOrType)) 39 | out << "+" << children.size() << "\n"; 40 | else { 41 | DFT::Nodes::GateVoting *v; 42 | v = static_cast(root); 43 | out << "/" << v->getThreshold() <<" "<< children.size() << "\n"; 44 | } 45 | for (DFT::Nodes::Node *child : children) 46 | writeModules(out, dft, child); 47 | } 48 | 49 | void writeModules(std::string filename, DFT::DFTree *dft) 50 | { 51 | DFT::Nodes::Node *root = dft->getTopNode(); 52 | if (filename.empty()) 53 | writeModules(std::cout, dft, root); 54 | else { 55 | ofstream out(filename, std::ofstream::out); 56 | writeModules(out, dft, root); 57 | out.close(); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /dft2lntc/modularize.h: -------------------------------------------------------------------------------- 1 | #include "DFTree.h" 2 | 3 | void writeModules(std::string filename, DFT::DFTree *dft); 4 | -------------------------------------------------------------------------------- /dftcalc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ## The DFT2LNT Compiler project 2 | project (dftcalc) 3 | set (dftcalc_VERSION_MAJOR 1) 4 | set (dftcalc_VERSION_MINOR 4) 5 | set (dftcalc_VERSION_PATCH 0) 6 | set (dftcalc_VERSION "${dftcalc_VERSION_MAJOR}.${dftcalc_VERSION_MINOR}.${dftcalc_VERSION_PATCH}") 7 | 8 | ## Not sure if needed 9 | cmake_minimum_required (VERSION 3.0) 10 | 11 | if (MSVC) 12 | add_definitions(/std:c++17) 13 | else() 14 | add_definitions(-std=c++17) 15 | endif() 16 | 17 | if(DEFINED ENV{CADP}) 18 | add_definitions(-DHAVE_CADP) 19 | endif() 20 | 21 | ## Include source directory, the build directory (for generated files) and the dft2lnt library path 22 | include_directories( 23 | ${CMAKE_CURRENT_BINARY_DIR} 24 | ${CMAKE_CURRENT_SOURCE_DIR} 25 | ${CMAKE_CURRENT_SOURCE_DIR}/../dft2lnt 26 | ) 27 | 28 | ## Specify the executable and its sources 29 | add_executable(dftcalc 30 | dftcalc.cpp 31 | imca.cpp 32 | storm.cpp 33 | executor.cpp 34 | mrmc.cpp 35 | modest.cpp 36 | ${CMAKE_CURRENT_BINARY_DIR}/compiletime.h 37 | ) 38 | 39 | ## Depends on: 40 | ## - dft2lnt (libdft2lnt.a) 41 | add_dependencies(dftcalc dft2lnt) 42 | 43 | # Find yaml.h on MacOS with Homebrew 44 | find_path(YAML_INCLUDE_PATH "yaml-cpp/yaml.h") 45 | target_include_directories(dftcalc PRIVATE ${YAML_INCLUDE_PATH}) 46 | 47 | ## Link with: 48 | ## - libdft2lnt.a 49 | ## - yaml-cpp 50 | find_library(YAML_CPP_LIB yaml-cpp) 51 | if("${YAML_CPP_LIB}" STREQUAL "YAML_CPP_LIB-NOTFOUND") 52 | set(YAML_CPP_LIB yaml-cpp) 53 | endif() 54 | target_link_libraries(dftcalc dft2lnt ${YAML_CPP_LIB}) 55 | 56 | if (WIN32) 57 | target_link_libraries(dftcalc pathcch) 58 | endif() 59 | 60 | if(UNIX AND NOT APPLE AND NOT WIN32) 61 | target_link_libraries(dftcalc rt) 62 | endif() 63 | 64 | ## POST_BUILD: copy the executable to the bin/ folder 65 | set(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin) 66 | 67 | ## Installation 68 | install (TARGETS dftcalc DESTINATION bin) 69 | 70 | # Generate compile time information 71 | set(GENINFOFILE ${CMAKE_CURRENT_BINARY_DIR}/compiletime.h) 72 | get_property(gendepSOURCES TARGET dftcalc PROPERTY SOURCES) 73 | LIST(REMOVE_ITEM gendepSOURCES ${GENINFOFILE}) 74 | if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../.git/HEAD") 75 | set(GIT_HEAD_DEPENDENCY "${CMAKE_CURRENT_SOURCE_DIR}/../.git/HEAD") 76 | set(NO_GIT 0) 77 | else() 78 | set(GIT_HEAD_DEPENDENCY "") 79 | set(NO_GIT 1) 80 | endif() 81 | add_custom_command( 82 | OUTPUT ${GENINFOFILE} 83 | DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/../compiletime.cmake 84 | ${gendepSOURCES} 85 | ${GIT_HEAD_DEPENDENCY} 86 | COMMAND ${CMAKE_COMMAND} 87 | -DOUTPUT_FILE=${GENINFOFILE} 88 | -DDFTROOT=${DFTROOT} 89 | -DFALLBACK_VERSION=${dftcalc_VERSION} 90 | -DNO_GIT=${NO_GIT} 91 | -P ${CMAKE_CURRENT_SOURCE_DIR}/../compiletime.cmake 92 | ) 93 | -------------------------------------------------------------------------------- /dftcalc/checker.h: -------------------------------------------------------------------------------- 1 | #ifndef DFTCALC_CHECKER_H 2 | #define DFTCALC_CHECKER_H 3 | 4 | #include "MessageFormatter.h" 5 | #include "query.h" 6 | #include "executor.h" 7 | #include "DFTCalculationResult.h" 8 | #include 9 | #include 10 | 11 | namespace DFT { 12 | extern const int VERBOSITY_FLOW; /* Defined in dftcalc.cpp */ 13 | }; 14 | 15 | class Checker { 16 | protected: 17 | MessageFormatter *messageFormatter; 18 | DFT::CommandExecutor *exec; 19 | 20 | public: 21 | Checker(MessageFormatter *mf, DFT::CommandExecutor *exec) 22 | :messageFormatter(mf), exec(exec) 23 | {} 24 | 25 | /* Analyze the provided queries on the given model, returning 26 | * lower and upper bounds on the results. 27 | * The returned queries need not be the same ones (in 28 | * particular, a [min, max, step] query should probably be 29 | * returned as one query per time), but the set of returned 30 | * queries should be identical when given the same set of input 31 | * queries. 32 | */ 33 | virtual std::vector analyze( 34 | std::vector queries) = 0; 35 | 36 | virtual ~Checker() 37 | {} 38 | }; 39 | #endif 40 | -------------------------------------------------------------------------------- /dftcalc/executor.cpp: -------------------------------------------------------------------------------- 1 | #include "executor.h" 2 | #include "Shell.h" 3 | #include 4 | 5 | using std::string; 6 | const int VERBOSITY_EXECUTIONS = 2; 7 | 8 | void DFT::CommandExecutor::printOutput(const File& file, int status) { 9 | string* outContents = FileSystem::load(file); 10 | if(outContents) { 11 | mf->notifyHighlighted("** OUTPUT of " + file.getFileName() + " **"); 12 | if (status) 13 | mf->message(*outContents, MessageFormatter::MessageType::Error); 14 | else 15 | mf->message(*outContents); 16 | mf->notifyHighlighted("** END output of " + file.getFileName() + " **"); 17 | delete outContents; 18 | } 19 | } 20 | 21 | string DFT::CommandExecutor::genInputFile(std::string extension) { 22 | return workingDir + "/" + baseFile + "." 23 | + std::to_string(commandNum) + "." + extension; 24 | } 25 | 26 | string DFT::CommandExecutor::runCommand(std::string command, 27 | std::vector arguments, 28 | std::string cmdName, 29 | std::vector outputFiles, 30 | File *inputFile) 31 | { 32 | Shell::SystemOptions sysOps; 33 | sysOps.verbosity = VERBOSITY_EXECUTIONS; 34 | sysOps.cwd = workingDir; 35 | sysOps.command = command; 36 | sysOps.arguments = arguments; 37 | string base = workingDir + "/" + baseFile + "." 38 | + std::to_string(commandNum++) + "." + cmdName; 39 | sysOps.reportFile = base + ".report"; 40 | sysOps.errFile = base + ".err"; 41 | sysOps.outFile = base + ".out"; 42 | if (inputFile != nullptr) 43 | sysOps.inFile = inputFile->getFileRealPath(); 44 | int result = Shell::system(sysOps); 45 | 46 | if(result) { 47 | printOutput(File(sysOps.outFile), result); 48 | printOutput(File(sysOps.errFile), result); 49 | return ""; 50 | } 51 | for (File expected : outputFiles) { 52 | if (!FileSystem::exists(expected)) { 53 | printOutput(File(sysOps.outFile), result); 54 | printOutput(File(sysOps.errFile), result); 55 | return ""; 56 | } 57 | } 58 | if (mf->getVerbosity() >= 5) { 59 | printOutput(File(sysOps.outFile), result); 60 | printOutput(File(sysOps.errFile), result); 61 | } 62 | return sysOps.outFile; 63 | } 64 | -------------------------------------------------------------------------------- /dftcalc/executor.h: -------------------------------------------------------------------------------- 1 | #ifndef DFTCALC_EXECUTOR_H 2 | #define DFTCALC_EXECUTOR_H 3 | #include "MessageFormatter.h" 4 | #include "FileSystem.h" 5 | 6 | namespace DFT{ 7 | class CommandExecutor { 8 | private: 9 | MessageFormatter *mf; 10 | int commandNum; 11 | 12 | public: 13 | const std::string baseFile; 14 | const std::string workingDir; 15 | CommandExecutor(MessageFormatter *mf, std::string workingDir, 16 | std::string baseFile) 17 | : mf(mf), commandNum(0), 18 | baseFile(baseFile), workingDir(workingDir) 19 | {} 20 | 21 | void printOutput(const File& file, int status); 22 | 23 | std::string genInputFile(std::string extension); 24 | 25 | std::string runCommand(std::string command, 26 | std::vector arguments, 27 | std::string cmdName, 28 | std::vector outputFiles = std::vector(), 29 | File *inputFile = nullptr 30 | ); 31 | 32 | std::string runCommand(std::string command, 33 | std::vector arguments, 34 | std::string cmdName, 35 | File outputFile) 36 | { 37 | std::vector outputs; 38 | outputs.push_back(outputFile); 39 | return runCommand(command, arguments, cmdName, outputs); 40 | } 41 | 42 | std::string runCommand(std::string command, 43 | std::string cmdName, 44 | File outputFile) 45 | { 46 | std::vector outputs; 47 | outputs.push_back(outputFile); 48 | return runCommand(command, std::vector(), cmdName, outputs); 49 | } 50 | 51 | std::string runCommand(std::string command, 52 | std::string cmdName) 53 | { 54 | return runCommand(command, std::vector(), cmdName, std::vector()); 55 | } 56 | }; 57 | }; 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /dftcalc/imca.h: -------------------------------------------------------------------------------- 1 | /* 2 | * imca.h 3 | * 4 | * Part of dft2lnt library - a library containing read/write operations for DFT 5 | * files in Galileo format and translating DFT specifications into Lotos NT. 6 | * 7 | * @author Dennis Guck, Enno Ruijters 8 | */ 9 | 10 | #ifndef IMCA_H 11 | #define IMCA_H 12 | 13 | #include "FileSystem.h" 14 | #include "decnumber.h" 15 | #include "query.h" 16 | #include "checker.h" 17 | #include "executor.h" 18 | #include 19 | 20 | class IMCARunner : public Checker { 21 | const File imcaExec; 22 | const File modelFile; 23 | 24 | public: 25 | IMCARunner(MessageFormatter *mf, DFT::CommandExecutor *exec, 26 | File imcaExec, File maFile) 27 | :Checker(mf, exec), imcaExec(imcaExec), modelFile(maFile) 28 | {} 29 | 30 | virtual std::vector analyze(vector queries); 31 | }; 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /dftcalc/modest.h: -------------------------------------------------------------------------------- 1 | /* 2 | * modest.h 3 | * 4 | * Part of dft2lnt library - a library containing read/write operations for DFT 5 | * files in Galileo format and translating DFT specifications into Lotos NT. 6 | * 7 | * @author Enno Ruijters, based on imca.h by Dennis Guck 8 | */ 9 | 10 | #ifndef MODEST_H 11 | #define MODEST_H 12 | 13 | #include "FileSystem.h" 14 | #include "decnumber.h" 15 | #include "checker.h" 16 | #include 17 | 18 | class ModestRunner : public Checker{ 19 | private: 20 | const File janiFile; 21 | const std::string modestCmd; 22 | std::vector getCommandOptions(Query q); 23 | public: 24 | ModestRunner(MessageFormatter *mf, DFT::CommandExecutor *exec, 25 | std::string modestCmd, File model) 26 | :Checker(mf, exec), janiFile(model), modestCmd(modestCmd) 27 | {} 28 | 29 | virtual std::vector analyze(vector queries); 30 | }; 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /dftcalc/mrmc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * mrmc.h 3 | * 4 | * Part of dft2lnt library - a library containing read/write operations for DFT 5 | * files in Galileo format and translating DFT specifications into Lotos NT. 6 | * 7 | * @author Freark van der Berg 8 | */ 9 | 10 | #ifndef MRMC_H 11 | #define MRMC_H 12 | 13 | #include "FileSystem.h" 14 | #include "decnumber.h" 15 | #include "checker.h" 16 | #include "query.h" 17 | #include "executor.h" 18 | #include 19 | 20 | class MRMCRunner : public Checker { 21 | private: 22 | const std::string goalLabel; 23 | const File modelFile, labFile; 24 | const bool isCtmdp; 25 | const File mrmcExec; 26 | public: 27 | MRMCRunner(MessageFormatter *mf, DFT::CommandExecutor *exec, 28 | bool imrmc, File executable, File model, File lab) 29 | :Checker(mf, exec), 30 | goalLabel(imrmc ? "marked" : "reach"), 31 | modelFile(model), labFile(lab), 32 | isCtmdp(!imrmc), 33 | mrmcExec(executable) 34 | {} 35 | 36 | virtual std::vector analyze(vector queries); 37 | }; 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /dftcalc/storm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * storm.h 3 | * 4 | * Part of dft2lnt library - a library containing read/write operations for DFT 5 | * files in Galileo format and translating DFT specifications into Lotos NT. 6 | * 7 | * @author Enno Ruijters, based on imca.h by Dennis Guck 8 | */ 9 | 10 | #ifndef STORM_H 11 | #define STORM_H 12 | 13 | #include "FileSystem.h" 14 | #include "decnumber.h" 15 | #include "checker.h" 16 | #include 17 | 18 | class StormRunner : public Checker{ 19 | private: 20 | const File janiFile; 21 | const File stormExec; 22 | void getCommandOptions(Query q, std::vector &opts); 23 | bool runExact; 24 | bool mayHaveNondeterminism; 25 | public: 26 | StormRunner(MessageFormatter *mf, DFT::CommandExecutor *exec, 27 | File stormExec, File model, bool exact, bool maybeNonDet) 28 | :Checker(mf, exec), 29 | janiFile(model), stormExec(stormExec), runExact(exact), 30 | mayHaveNondeterminism(maybeNonDet) 31 | {} 32 | 33 | virtual std::vector analyze(vector queries); 34 | }; 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /dfttest/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ## The DFT2LNT Compiler project 2 | project (dfttest) 3 | set (dfttest_VERSION_MAJOR 1) 4 | set (dfttest_VERSION_MINOR 4) 5 | set (dfttest_VERSION_PATCH 0) 6 | set (dfttest_VERSION "${dfttest_VERSION_MAJOR}.${dfttest_VERSION_MINOR}.${dfttest_VERSION_PATCH}") 7 | 8 | ## Not sure if needed 9 | cmake_minimum_required (VERSION 3.0) 10 | if (MSVC) 11 | add_definitions(/std:c++17) 12 | else() 13 | add_definitions(-std=c++17) 14 | endif() 15 | 16 | ## Include source directory, the build directory (for generated files) and the dft2lnt library path 17 | include_directories( 18 | ${CMAKE_CURRENT_BINARY_DIR} 19 | ${CMAKE_CURRENT_SOURCE_DIR} 20 | ${CMAKE_CURRENT_SOURCE_DIR}/../dft2lnt 21 | ${CMAKE_CURRENT_SOURCE_DIR}/../dftcalc 22 | ) 23 | 24 | ## Link directories 25 | #link_directories(${CMAKE_CURRENT_BINARY_DIR}/../dft2lnt) 26 | 27 | if (DEFINED ENV{CADP}) 28 | add_definitions(-DHAVE_CADP) 29 | endif() 30 | 31 | ## Specify the executable and its sources 32 | add_executable(dfttest 33 | dfttest.cpp 34 | test.cpp 35 | TestResult.cpp 36 | TestOutput.cpp 37 | TestRun.cpp 38 | ${CMAKE_CURRENT_BINARY_DIR}/compiletime.h 39 | ) 40 | 41 | ## Depends on: 42 | ## - dft2lnt (libdft2lnt.a) 43 | add_dependencies(dfttest dft2lnt) 44 | 45 | # Find yaml.h on MacOS with Homebrew 46 | find_path(YAML_INCLUDE_PATH "yaml-cpp/yaml.h") 47 | target_include_directories(dfttest PRIVATE ${YAML_INCLUDE_PATH}) 48 | 49 | ## Link with: 50 | ## - libdft2lnt.a 51 | ## - yaml-cpp 52 | find_library(YAML_CPP_LIB yaml-cpp) 53 | if("${YAML_CPP_LIB}" STREQUAL "YAML_CPP_LIB-NOTFOUND") 54 | set(YAML_CPP_LIB yaml-cpp) 55 | endif() 56 | target_link_libraries(dfttest 57 | dft2lnt 58 | ${YAML_CPP_LIB} 59 | ) 60 | 61 | if (WIN32) 62 | target_link_libraries(dfttest pathcch) 63 | endif() 64 | 65 | set(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin) 66 | 67 | ## Installation 68 | install (TARGETS dfttest DESTINATION bin) 69 | 70 | # Generate compile time information 71 | set(GENINFOFILE ${CMAKE_CURRENT_BINARY_DIR}/compiletime.h) 72 | get_property(gendepSOURCES TARGET dfttest PROPERTY SOURCES) 73 | LIST(REMOVE_ITEM gendepSOURCES ${GENINFOFILE}) 74 | if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../.git/HEAD") 75 | set(GIT_HEAD_DEPENDENCY "${CMAKE_CURRENT_SOURCE_DIR}/../.git/HEAD") 76 | set(NO_GIT 0) 77 | else() 78 | set(GIT_HEAD_DEPENDENCY "") 79 | set(NO_GIT 1) 80 | endif() 81 | add_custom_command( 82 | OUTPUT ${GENINFOFILE} 83 | DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/../compiletime.cmake 84 | ${gendepSOURCES} 85 | ${GIT_HEAD_DEPENDENCY} 86 | COMMAND ${CMAKE_COMMAND} 87 | -DOUTPUT_FILE=${GENINFOFILE} 88 | -DDFTROOT=${DFTROOT} 89 | -DFALLBACK_VERSION=${dfttest_VERSION} 90 | -DNO_GIT=${NO_GIT} 91 | -P ${CMAKE_CURRENT_SOURCE_DIR}/../compiletime.cmake 92 | ) 93 | -------------------------------------------------------------------------------- /dfttest/TestOutput.h: -------------------------------------------------------------------------------- 1 | namespace Test { 2 | class OutputFormatter; 3 | class OutputFormatterNice; 4 | } 5 | 6 | #ifndef TESTOUTPUT_H 7 | #define TESTOUTPUT_H 8 | 9 | #include 10 | #include "TestResult.h" 11 | #include "TestRun.h" 12 | 13 | namespace Test { 14 | 15 | enum OutputMode { 16 | OutputNone = 0, 17 | OutputNice = 1, 18 | OutputLaTeX, 19 | OutputCSV, 20 | OutputModeCount 21 | }; 22 | 23 | 24 | class OutputFormatter { 25 | public: 26 | virtual void displaySuiteStart(TestRun* testRun) = 0; 27 | virtual void displaySuiteEnd(TestRun* testRun) = 0; 28 | virtual void displayTestStart(TestRun* testRun, TestSpecification* test) = 0; 29 | virtual void displayTestEnd(TestRun* testRun, TestSpecification* test) = 0; 30 | virtual void displayTestResult(TestRun* testRun, TestSpecification* test, const string& timeStamp, const string& iteration, TestResult* result, bool cached, const ResultStatus& resultStatus) = 0; 31 | }; 32 | 33 | class OutputFormatterNice: public OutputFormatter { 34 | virtual void displaySuiteStart(TestRun* testRun); 35 | virtual void displaySuiteEnd(TestRun* testRun); 36 | virtual void displayTestStart(TestRun* testRun, TestSpecification* test); 37 | virtual void displayTestEnd(TestRun* testRun, TestSpecification* test); 38 | virtual void displayTestResult(TestRun* testRun, TestSpecification* test, const string& timeStamp, const string& iteration, TestResult* result, bool cached, const ResultStatus& resultStatus); 39 | }; 40 | 41 | class OutputFormatterLaTeX: public OutputFormatter { 42 | virtual void displaySuiteStart(TestRun* testRun); 43 | virtual void displaySuiteEnd(TestRun* testRun); 44 | virtual void displayTestStart(TestRun* testRun, TestSpecification* test); 45 | virtual void displayTestEnd(TestRun* testRun, TestSpecification* test); 46 | virtual void displayTestResult(TestRun* testRun, TestSpecification* test, const string& timeStamp, const string& iteration, TestResult* result, bool cached, const ResultStatus& resultStatus); 47 | std::string escapeUnderscore(const std::string& str) { 48 | std::string n; 49 | n.reserve(str.length()+1); 50 | for(char c: str) { 51 | if(c=='_') n += '\\'; 52 | n += c; 53 | } 54 | return n; 55 | } 56 | }; 57 | 58 | } // Namespace: Test 59 | 60 | #endif -------------------------------------------------------------------------------- /dfttest/TestResult.cpp: -------------------------------------------------------------------------------- 1 | #include "TestResult.h" 2 | 3 | const YAML::Node& Test::TestResult::readYAMLNode(const YAML::Node& node) { 4 | readYAMLNodeSpecific(node); 5 | if(const YAML::Node itemNode = node["stats"]) { 6 | itemNode >> stats; 7 | } 8 | return node; 9 | } 10 | 11 | YAML::Emitter& Test::TestResult::writeYAMLNode(YAML::Emitter& out) const { 12 | out << YAML::BeginMap; 13 | out << YAML::Key << "stats" << YAML::Value << stats; 14 | writeYAMLNodeSpecific(out); 15 | out << YAML::EndMap; 16 | return out; 17 | } 18 | 19 | -------------------------------------------------------------------------------- /dfttest/TestResult.h: -------------------------------------------------------------------------------- 1 | namespace Test { 2 | class TestResult; 3 | class TestResultColumn; 4 | } 5 | 6 | #ifndef TESTRESULT_H 7 | #define TESTRESULT_H 8 | 9 | #include 10 | #include "Shell.h" 11 | #include "yaml-cpp/yaml.h" 12 | 13 | namespace Test { 14 | 15 | enum ResultStatus { 16 | UNKNOWN = 0, 17 | OK = 1, 18 | FAILED, 19 | VERIFIEDOK, 20 | ResultStatusCount 21 | }; 22 | 23 | /** 24 | * Results from the execution of an interation of a test 25 | */ 26 | class TestResult { 27 | public: 28 | /// The stats hold resource usage and time elapsed 29 | Shell::RunStatistics stats; 30 | 31 | TestResult() { 32 | } 33 | 34 | virtual void readYAMLNodeSpecific(const YAML::Node& node) {} 35 | virtual void writeYAMLNodeSpecific(YAML::Emitter& out) const {} 36 | 37 | const YAML::Node& readYAMLNode(const YAML::Node& node); 38 | 39 | YAML::Emitter& writeYAMLNode(YAML::Emitter& out) const; 40 | 41 | virtual bool isValid() { return true; } 42 | virtual bool isEqual(TestResult* other) { return true; } 43 | }; 44 | 45 | /** 46 | * Describes a single test result column. 47 | */ 48 | class TestResultColumn { 49 | public: 50 | /// A unique ID to distinguish the column (e.g. in maps) 51 | std::string id; 52 | 53 | /// The name of the column that should be displayed at the top 54 | std::string name; 55 | 56 | /// The unit of the values in this column 57 | std::string unit; 58 | 59 | /// Whether to align the results left or right 60 | bool alignRight; 61 | TestResultColumn(): 62 | id(""), 63 | name(""), 64 | alignRight(false) { 65 | } 66 | TestResultColumn(const std::string id, const std::string name, const std::string unit, bool alignRight): 67 | id(id), 68 | name(name), 69 | unit(unit), 70 | alignRight(alignRight) { 71 | } 72 | }; 73 | 74 | } // Namespace: Test 75 | 76 | #endif -------------------------------------------------------------------------------- /package/debian/changelog: -------------------------------------------------------------------------------- 1 | dftcalc (@VERSION) @DISTRO; urgency=low 2 | 3 | * Initial packaged release 4 | 5 | -- Enno Ruijters Tue, 27 Apr 2021 18:00:00 +0200 6 | -------------------------------------------------------------------------------- /package/debian/compat: -------------------------------------------------------------------------------- 1 | 10 2 | -------------------------------------------------------------------------------- /package/debian/control: -------------------------------------------------------------------------------- 1 | Source: dftcalc 2 | Maintainer: Enno Ruijters 3 | Section: science 4 | Priority: optional 5 | Standards-Version: 4.3.0 6 | Build-Depends: debhelper (>= 9), cmake, libfl-dev, libyaml-cpp-dev, libgsl-dev, bison (>=2:3.3), storm (>=1.6.2), dftres (>=1.0.2), bc 7 | 8 | Package: dftcalc 9 | Architecture: any 10 | Depends: ${shlibs:Depends}, ${misc:Depends}, storm (>=1.6.2), dftres (>=1.0.2) 11 | Description: A Dynamic Fault Tree calculator for reliability and availability 12 | -------------------------------------------------------------------------------- /package/debian/copyright: -------------------------------------------------------------------------------- 1 | MIT 2 | -------------------------------------------------------------------------------- /package/debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | export DEB_BUILD_MAINT_OPTIONS = hardening=+all 3 | export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic 4 | export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed 5 | 6 | %: 7 | dh $@ 8 | 9 | override_dh_auto_configure: 10 | dh_auto_configure -- -DDFTROOT=/usr 11 | 12 | override_dh_auto_test: 13 | cd test && PATH="$(PATH):../bin" DFT2LNTROOT=$(PWD) HOME=/tmp sh test.sh --storm 14 | #cd test && PATH="$(PATH):../bin" DFT2LNTROOT=$(PWD) HOME=/tmp dftcalc -vvvvv -p -s --exact --storm repair-spare.dft 15 | # Disable the following line on Debian buster, where the version 16 | # of Storm is compiled with a older version of Z3, and therefore 17 | # unable to perform all the tests. 18 | cd test && PATH="$(PATH):../bin" DFT2LNTROOT=$(PWD) HOME=/tmp sh test.sh --exact --storm #disable-for-buster 19 | -------------------------------------------------------------------------------- /package/debian/source/format: -------------------------------------------------------------------------------- 1 | 3.0 (native) 2 | -------------------------------------------------------------------------------- /package/dftcalc.spec: -------------------------------------------------------------------------------- 1 | Name: dftcalc 2 | Version: @VERSION 3 | Release: 1%{?dist} 4 | Summary: A Dynamic Fault Tree calculator for reliability and availability 5 | 6 | License: MIT 7 | URL: https://github.com/utwente-fmt/dftcalc 8 | Source0: %{name}-%{version}.tar.xz 9 | 10 | BuildRequires: cmake gcc-c++, flex-devel >= 2.6.3, flex >= 2.6.3, bison >= 3.3, bc 11 | BuildRequires: gsl-devel >= 2.6, yaml-cpp-devel >= 0.6.3 12 | BuildRequires: storm >= 1.6.2, dftres >= 1.0.2 13 | Requires: storm >= 1.6.2, dftres >= 1.0.2 14 | 15 | %description 16 | A Dynamic Fault Tree calculator for reliability and availability. 17 | 18 | %prep 19 | %setup -q 20 | 21 | %build 22 | %cmake -DDFTROOT=%{_prefix} 23 | %cmake_build 24 | 25 | %check 26 | cd test && PATH="$PATH:$(pwd)/../bin" DFT2LNTROOT=$PWD/.. HOME=/tmp sh test.sh 27 | 28 | %install 29 | %cmake_install 30 | rm %{buildroot}%{_prefix}/include/dft2lnt/dft2lnt.h 31 | rmdir %{buildroot}%{_prefix}/include/dft2lnt 32 | 33 | %files 34 | %license LICENSE 35 | %dir %{_prefix}/share/dft2lnt 36 | %dir %{_prefix}/share/dft2lnt/tests 37 | %{_prefix}/share/dft2lnt/tests/* 38 | %{_bindir}/dftcalc 39 | %{_bindir}/dft2lntc 40 | %{_bindir}/dfttest 41 | %{_libdir}/libdft2lnt.so 42 | -------------------------------------------------------------------------------- /puptol/bin/scripts/dftcalc/downloaddatasets.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Get the aliases and functions 4 | export HOME=/home/dftcalc 5 | if [ -f $HOME/.bashrc ]; then 6 | . $HOME/.bashrc 7 | fi 8 | 9 | d=`echo $0 |sed 's/[^/]*$//' ` 10 | # echo $d 11 | . $d/settings 12 | 13 | 14 | # var TOOL is set by settings 15 | # env vars PUPTOLROOT and SESSION are set by puptol 16 | 17 | 18 | PLOTSTYLE=linespoints 19 | if [ "X$OMITPOINTS" = "Xomitpoints" ] 20 | then 21 | PLOTSTYLE=lines 22 | fi 23 | 24 | 25 | # echo arg: "$@" 1>&2 26 | #for arg in "$@" 27 | #do 28 | # echo "arg: ($arg)" 1>&2 29 | #done 30 | 31 | mkdir $TOOLTMPDIR 32 | # next cd is necessary because dft2bcg wants to write a temporary file in current working directory 33 | cd $TOOLTMPDIR 34 | 35 | 36 | lastmttf="" 37 | for item in "$@" 38 | do 39 | a="data/session/$SESSION/$TOOL/uploads/$item" 40 | #a=`echo $item | sed -e 's/^own/data/g' -e 's/datasets/uploads/g' ` 41 | #echo testing "($PUPTOLROOT/$a/mttf)" 1>&2 42 | if [ -r "$PUPTOLROOT/$a/mttf" ] 43 | then 44 | lastmttf=$PUPTOLROOT/$a/mttf 45 | fi 46 | done 47 | 48 | itemsLost="" 49 | sepLost="" 50 | files="" 51 | touch $filesToTar 52 | dirToTarFrom="$PUPTOLROOT/data/session/$SESSION/$TOOL/uploads" 53 | for item in "$@" 54 | do 55 | a="data/session/$SESSION/$TOOL/uploads/$item" 56 | #a=`echo $item | sed -e 's/^own/data/g' -e 's/datasets/uploads/g' ` 57 | # echo testing: $PUPTOLROOT/$a/data 1>&2 58 | if [ -r "$PUPTOLROOT/$a/data" ] 59 | then 60 | echo "$item" >> $filesToTar 61 | files="$files $PUPTOLROOT/$a" 62 | else 63 | itemsLost="${itemsLost}${sepLost}${item}" 64 | sepLost=", " 65 | if [ -r "$PUPTOLROOT/data/session/$SESSION/$TOOL/datasets/$item" ] 66 | then 67 | mv "$PUPTOLROOT/data/session/$SESSION/$TOOL/datasets/$item" "$PUPTOLROOT/data/session/$SESSION/$TOOL/datasets/$item.hidden" 68 | fi 69 | fi 70 | done 71 | 72 | if [ "X$itemsLost" != "X" ] 73 | then 74 | echo "One or more datasets ($itemsLost) could not be found. Maybe your session expired?" 1>&2 75 | echo "Rereading the list of datasets." 1>&2 76 | echo "refresh" 1>&$PUPTOL_DFTCALC_datasets_refresh_FD 77 | exit 0 78 | elif [ "X$files" = "X" ] 79 | then 80 | echo "Nothing to download" 1>&2 81 | exit 0 82 | fi 83 | 84 | cd $dirToTarFrom 85 | if tar cf - -T $filesToTar | gzip > "$sesfilepfx/download$$.tar.gz" 86 | then 87 | # TODO: pass the tgz file to the browser, as result, with the right mime-type 88 | # configure a separate file descriptor for it in puptol config? 89 | echo "$sesurlpfx/download$$.tar.gz?Content-Disposition=selected-datasets.tar.gz |-=-| the gzip-ed tar-file containing your selected data set(s)" 1>&$PUPTOL_DOWNLOAD_FD 90 | # echo "Please save your selected data sets by saving gzip-ed tar file containing datasets" 91 | else 92 | echo "internal error: could not generate gzipped tar file" 1>&2 93 | fi 94 | 95 | -------------------------------------------------------------------------------- /puptol/bin/scripts/dftcalc/settings: -------------------------------------------------------------------------------- 1 | # env var NAME is set by puptol from the Name field of the experiment configuration 2 | TOOL=$NAME 3 | 4 | if [ "X$TEMPDIR" = "X" ] 5 | then 6 | TEMPDIR=/tmp 7 | fi 8 | 9 | tmperrtxt=$TEMPDIR/$TOOL$pid.err.txt 10 | tmppng=$TEMPDIR/$TOOL$pid.png 11 | tmppfx=$TEMPDIR/$TOOL$pid 12 | tmpdft=$TEMPDIR/$TOOL$pid.dft 13 | tmpcandft=$TEMPDIR/$TOOL$pid-can.dft 14 | tmptxt=$TEMPDIR/$TOOL$pid-tmp.txt 15 | tmpcsv=$TEMPDIR/$TOOL$pid.csv 16 | tmpcurvecsv=$TEMPDIR/$TOOL$pid-curve.csv 17 | tmppntcsv=$TEMPDIR/$TOOL$pid-pnt.csv 18 | tmpmemrec=$TEMPDIR/$TOOL$pid-memrec.txt 19 | filesToTar=$TEMPDIR/$TOOL$pid-filesToTar 20 | 21 | sesfilepfx=$PUPTOLROOT/data/session/$SESSION 22 | sesurlpfx=$PUPTOLURLPFX/$TOOL/own/$SESSION 23 | 24 | dft=$TOOL$pid.dft 25 | png=$TOOL$pid.png 26 | svg=$TOOL$pid.svg 27 | csv=$TOOL$pid.csv 28 | plotdata=$TOOL$pid.plot 29 | plotcmd=$TOOL$pid.gnuplot 30 | 31 | TOOLTMPDIR=$TEMPDIR/$TOOL$pid 32 | export TOOLTMPDIR 33 | 34 | gnuplot=gnuplot 35 | 36 | if [ "$MODELCHECKER" != "--mrmc" ] && [ "$MODELCHECKER" != "--imca" ] && [ "$MODELCHECKER" != "--storm" ] && [ "$MODELCHECKER" != "--imrmc" ] && [ "$MODELCHECKER" != "--exact" ] ; then 37 | MODELCHECKER="--storm"; 38 | fi 39 | 40 | # set default dftcalc version (for when no version is given in web-request): 41 | if [ "X$VERSION" = "X" ] 42 | then 43 | VERSION=next 44 | fi 45 | 46 | # ======================================= 47 | # for input validation 48 | 49 | errorfound=0 50 | # NOTE: it is VERY important that the VERSION value has the form of an identifier: 51 | # no embedded whitespace, quotes, or other funny characters 52 | # NOTE: no longer, each valid version must be mentioned below (otherwise it is refused as 'not valid') 53 | testVersionValue () { 54 | #if ! validate-env-by-rx $1 "${2}: not a valid version" '^(master)|(old)$' 1>&2 55 | #then 56 | # errorfound=1 57 | #el 58 | if ! $PUPTOLROOT/bin/validate-env-by-rx $1 "${2}: internal error: version contains illegal characters (not an identifier)" '^([a-zA-Z0-9_.-]*)$' 1>&2 59 | then 60 | errorfound=1 61 | fi 62 | } 63 | testRealValue () { 64 | if ! $PUPTOLROOT/bin/validate-env-by-rx $1 "${2}: not a valid real number" '^[ \t]*[0123456789E.-]+[ \t]*$' 1>&2 65 | then 66 | errorfound=1 67 | fi 68 | } 69 | testVerbosityValue () { 70 | if ! $PUPTOLROOT/bin/validate-env-by-rx $1 "${2}: not a valid verbosity value" '^[ \t]*--verbose=off[ \t]*$' '^[ \t]*--verbose=[0123456-]+[ \t]*$' 1>&2 71 | then 72 | errorfound=1 73 | fi 74 | } 75 | testColorValue () { 76 | if ! $PUPTOLROOT/bin/validate-env-by-rx $1 "${2}: not a valid color value" '^[ \t]*--color[ \t]*$' '^[ \t]*$' 1>&2 77 | then 78 | errorfound=1 79 | fi 80 | } 81 | testIdentifierListValue () { 82 | if ! $PUPTOLROOT/bin/validate-env-by-rx $1 "${2}: not a valid list of identifiers" '^$' '^[a-zA-Z0-9_, \t]+$' 1>&2 83 | then 84 | errorfound=1 85 | fi 86 | } 87 | testDataSetNameValue () { 88 | if ! $PUPTOLROOT/bin/validate-env-by-rx $1 "${2}: not a valid data set name" '^$' '^[a-zA-Z0-9_, \t\\+\\-]+$' 1>&2 89 | then 90 | errorfound=1 91 | fi 92 | } 93 | # return implicit boolean value: exit status of last command (i.e. the test command, [ ]) 94 | # returns true (exit status value 0) when there are errors 95 | # and false otherwise 96 | errorsfound () { 97 | [ X$errorfound != X0 ] 98 | } 99 | 100 | -------------------------------------------------------------------------------- /puptol/data/shared/dftcalc/README: -------------------------------------------------------------------------------- 1 | README file for examples of CORAL 2 | 3 | -------------------------------------------------------------------------------- 4 | test1.dft 5 | 6 | A simple DFT consisting of a 2/3 voting gate and 3 exponentially distributed 7 | basic events. 8 | 9 | Example usage: coral -f test1.dft -t 1.0 2.0 3.0 10 | Computes the unreliabilities for timepoints 1.0, 2.0, and 3.0 and writes them 11 | to standard output. 12 | 13 | -------------------------------------------------------------------------------- 14 | test2.dft 15 | 16 | A simple non-deterministic DFT. 17 | 18 | Example usage: coral -f test2.dft -t 1.0 2.0 3.0 19 | Computes the maximal* unreliabilities for timepoints 1.0, 2.0, and 3.0 and 20 | writes them to standard output. 21 | 22 | -------------------------------------------------------------------------------- 23 | test3.dft 24 | 25 | A simple DFT consisting of a 2/3 voting gate, 2 exponentially distributed 26 | basic events and one PH-distributed basic event. Note: uses file erl2_2.bcg. 27 | 28 | Example usage: coral -f test3.dft -t 1.0 2.0 3.0 29 | Computes the unreliabilities for timepoints 1.0, 2.0, and 3.0 and writes them 30 | to standard output. 31 | 32 | -------------------------------------------------------------------------------- 33 | test_all.dft 34 | 35 | A simple DFT which uses all DFT features. Note: uses file erl2_2.bcg. 36 | 37 | Example usage: coral -f test_all.dft -t 1.0 2.0 3.0 38 | Computes the maximal* unreliabilities for timepoints 1.0, 2.0, and 3.0 and 39 | writes them to standard output. 40 | 41 | -------------------------------------------------------------------------------- 42 | ftpp4.dft 43 | 44 | A DFT from a case study modeling a fault-tolerant parallel processor system. 45 | 46 | Example usage: coral -f ftpp4.dft -i 100 10000 100 -O example.csv 47 | Computes the unreliabilities for timepoints 100 to 10000 in steps of 100 48 | time-units and writes the results to a comma-separated file example.csv. 49 | This file can be used to generate a plot using gnuplot. A sample gnuplot 50 | script is provided in the file example_plot.gp. 51 | Example usage: gnuplot example_plot.gp 52 | The resulting figure can be found in the file example_plot.ps. 53 | 54 | -------------------------------------------------------------------------------- 55 | reuse.dft 56 | 57 | A DFT which reuses the "test1.dft" model. The DFT consists of an AND-gate with 58 | 2 inputs which are 2 copies of the "test1.dft" model. To succesfully analyze 59 | this system the composed I/O-IMC for "test1.dft" has to be generated first. 60 | 61 | Example usage: 62 | coral -f test1.dft -C test1 -a 63 | coral -f reuse.dft -t 1.0 2.0 3.0 64 | 65 | Constructs first the composed model for "test1.dft" and uses it to compute 66 | the unreliabities of "reuse.dft" for timepoints 1.0, 2.0, and 3.0. 67 | 68 | -------------------------------------------------------------------------------- 69 | test1_err.dft 70 | 71 | Example of a DFT-file with a syntax error. 72 | 73 | Example usage: coral -f test3.dft -t 1.0 2.0 3.0 74 | An error message should be generated. 75 | 76 | *Maximal for all untimed schedulers on the globally-uniformized CTMDP. 77 | -------------------------------------------------------------------------------- /puptol/data/shared/dftcalc/cases/cas.dft: -------------------------------------------------------------------------------- 1 | toplevel "SYSTEM"; 2 | "SYSTEM" or "FDEP" "CPU" "MOTOR" "PUMPS"; 3 | "FDEP" fdep "TRIGGER" "P" "B"; 4 | "TRIGGER" or "CS" "SS"; 5 | "CPU" wsp "P" "B"; 6 | "MOTOR" or "SWITCH" "MOTORS"; 7 | "SWITCH" pand "MS" "MA"; 8 | "MOTORS" csp "MA" "MB"; 9 | "PUMPS" and "PUMP1" "PUMP2"; 10 | "PUMP1" csp "PA" "PS"; 11 | "PUMP2" csp "PB" "PS"; 12 | "P" lambda=5.0e-5 dorm=0; 13 | "B" lambda=5.0e-5 dorm=0.5; 14 | "CS" lambda=2.0e-5 dorm=0; 15 | "SS" lambda=2.0e-5 dorm=0; 16 | "MS" lambda=1.0e-6 dorm=0; 17 | "MA" lambda=1.0e-4 dorm=0; 18 | "MB" lambda=1.0e-4 dorm=0; 19 | "PA" lambda=1.0e-4 dorm=0; 20 | "PB" lambda=1.0e-4 dorm=0; 21 | "PS" lambda=1.0e-4 dorm=0; 22 | -------------------------------------------------------------------------------- /puptol/data/shared/dftcalc/cases/mcs.dft: -------------------------------------------------------------------------------- 1 | toplevel "System"; 2 | "System" or "BUS" "CM"; 3 | "CM" and "CM1" "CM2"; 4 | "CM1" or "DISK1" "POWER1" "MEMORY1"; 5 | "CM2" or "DISK2" "POWER2" "MEMORY2"; 6 | "DISK1" wsp "D11" "D12"; 7 | "DISK2" wsp "D21" "D22"; 8 | "POWER1" or "P1" "PS"; 9 | "POWER2" or "P2" "PS"; 10 | "MEMORY1" wsp "M1" "M3"; 11 | "MEMORY2" wsp "M2" "M3"; 12 | "BUS" lambda=0.0002 dorm=0; 13 | "P1" lambda=0.05 dorm=0; 14 | "P2" lambda=0.05 dorm=0; 15 | "PS" lambda=0.6 dorm=0; 16 | "D11" lambda=8.0 dorm=0; 17 | "D12" lambda=8.0 dorm=0.5; 18 | "D21" lambda=8.0 dorm=0; 19 | "D22" lambda=8.0 dorm=0.5; 20 | "M1" lambda=0.003 dorm=0; 21 | "M2" lambda=0.003 dorm=0; 22 | "M3" lambda=0.003 dorm=0.5; 23 | -------------------------------------------------------------------------------- /puptol/data/shared/dftcalc/cases/mcs_4CM.dft: -------------------------------------------------------------------------------- 1 | toplevel "System"; 2 | "System" or "BUS" "CM"; 3 | "CM" and "CM1" "CM2" "CM3" "CM4"; 4 | "CM1" or "DISK1" "POWER1" "MEMORY1"; 5 | "CM2" or "DISK2" "POWER2" "MEMORY2"; 6 | "CM3" or "DISK3" "POWER3" "MEMORY3"; 7 | "CM4" or "DISK4" "POWER4" "MEMORY4"; 8 | "DISK1" wsp "D11" "D12"; 9 | "DISK2" wsp "D21" "D22"; 10 | "DISK3" wsp "D31" "D32"; 11 | "DISK4" wsp "D41" "D42"; 12 | "POWER1" or "P1" "PS"; 13 | "POWER2" or "P2" "PS"; 14 | "POWER3" or "P3" "PS2"; 15 | "POWER4" or "P4" "PS2"; 16 | "MEMORY1" wsp "M1" "M3" "M4"; 17 | "MEMORY2" wsp "M2" "M3" "M4"; 18 | "MEMORY3" wsp "M31" "M3"; 19 | "MEMORY4" wsp "M41" "M4"; 20 | "BUS" lambda=0.0002 dorm=0; 21 | "P1" lambda=0.05 dorm=0; 22 | "P2" lambda=0.05 dorm=0; 23 | "P3" lambda=0.05 dorm=0; 24 | "P4" lambda=0.05 dorm=0; 25 | "PS" lambda=0.6 dorm=0; 26 | "PS2" lambda=0.6 dorm=0; 27 | "D11" lambda=8.0 dorm=0; 28 | "D12" lambda=8.0 dorm=0.5; 29 | "D21" lambda=8.0 dorm=0; 30 | "D22" lambda=8.0 dorm=0.5; 31 | "D31" lambda=8.0 dorm=0; 32 | "D32" lambda=8.0 dorm=0.5; 33 | "D41" lambda=8.0 dorm=0; 34 | "D42" lambda=8.0 dorm=0.5; 35 | "M1" lambda=0.003 dorm=0; 36 | "M2" lambda=0.003 dorm=0; 37 | "M31" lambda=0.003 dorm=0; 38 | "M41" lambda=0.003 dorm=0; 39 | "M3" lambda=0.003 dorm=0.5; 40 | "M4" lambda=0.003 dorm=0.5; 41 | -------------------------------------------------------------------------------- /puptol/data/shared/dftcalc/erl2_2.bcg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/utwente-fmt/dftcalc/aaaa84595404f4522a6d01718f45dd953184c92a/puptol/data/shared/dftcalc/erl2_2.bcg -------------------------------------------------------------------------------- /puptol/data/shared/dftcalc/example.dft: -------------------------------------------------------------------------------- 1 | toplevel "A"; 2 | "A" 2of3 "B" "C" "D"; 3 | "B" lambda=0.1 dorm=0; 4 | "C" lambda=0.2 dorm=0; 5 | "D" lambda=0.3 dorm=0; 6 | -------------------------------------------------------------------------------- /puptol/data/shared/dftcalc/ftpp4.dft: -------------------------------------------------------------------------------- 1 | toplevel "System"; 2 | "System" or "triadA" "triadB" "triadC" "triadD" "fA" "fB" "fC" "fD"; 3 | 4 | "triadA" 2of3 "aA" "bA" "cA"; 5 | "aA" csp "TAA" "TAS"; 6 | "bA" csp "TAB" "TAS"; 7 | "cA" csp "TAC" "TAS"; 8 | 9 | "triadB" 2of3 "aB" "bB" "cB"; 10 | "aB" csp "TBA" "TBS"; 11 | "bB" csp "TBB" "TBS"; 12 | "cB" csp "TBC" "TBS"; 13 | 14 | "triadC" 2of3 "aC" "bC" "cC"; 15 | "aC" csp "TCA" "TCS"; 16 | "bC" csp "TCB" "TCS"; 17 | "cC" csp "TCC" "TCS"; 18 | 19 | "triadD" 2of3 "aD" "bD" "cD"; 20 | "aD" csp "TDA" "TDS"; 21 | "bD" csp "TDB" "TDS"; 22 | "cD" csp "TDC" "TDS"; 23 | 24 | "fA" fdep "NEA" "TAA" "TBA" "TCA" "TDA"; 25 | "fB" fdep "NEB" "TAB" "TBB" "TCB" "TDB"; 26 | "fC" fdep "NEC" "TAC" "TBC" "TCC" "TDC"; 27 | "fD" fdep "NED" "TAS" "TBS" "TCS" "TDS"; 28 | 29 | 30 | "NEA" lambda=0.000017 dorm=1; 31 | "NEB" lambda=0.000017 dorm=1; 32 | "NEC" lambda=0.000017 dorm=1; 33 | "NED" lambda=0.000017 dorm=1; 34 | 35 | "TAA" lambda=0.00011 dorm=0; 36 | "TAB" lambda=0.00011 dorm=0; 37 | "TAC" lambda=0.00011 dorm=0; 38 | "TAS" lambda=0.00011 dorm=0; 39 | 40 | "TBA" lambda=0.00011 dorm=0; 41 | "TBB" lambda=0.00011 dorm=0; 42 | "TBC" lambda=0.00011 dorm=0; 43 | "TBS" lambda=0.00011 dorm=0; 44 | 45 | "TCA" lambda=0.00011 dorm=0; 46 | "TCB" lambda=0.00011 dorm=0; 47 | "TCC" lambda=0.00011 dorm=0; 48 | "TCS" lambda=0.00011 dorm=0; 49 | 50 | "TDA" lambda=0.00011 dorm=0; 51 | "TDB" lambda=0.00011 dorm=0; 52 | "TDC" lambda=0.00011 dorm=0; 53 | "TDS" lambda=0.00011 dorm=0; 54 | -------------------------------------------------------------------------------- /puptol/data/shared/dftcalc/prob.txt: -------------------------------------------------------------------------------- 1 | Time, Unreliability 2 | 1.0, 0.0799543 3 | -------------------------------------------------------------------------------- /puptol/data/shared/dftcalc/repair.dft: -------------------------------------------------------------------------------- 1 | toplevel "A"; 2 | "A" 2of3 "B" "C" "D"; 3 | "B" lambda=0.1 dorm=0 phases=1 interval=1; 4 | "C" lambda=0.2 dorm=0 phases=1 interval=1; 5 | "D" lambda=0.3 dorm=0 phases=1 interval=1; 6 | "R" 2insp4 "B" "C" "D"; 7 | -------------------------------------------------------------------------------- /puptol/data/shared/dftcalc/reuse.dft: -------------------------------------------------------------------------------- 1 | toplevel "X"; 2 | "X" and "Y" "Z"; 3 | "Y" aph="test1.bcg"; 4 | "Z" aph="test1.bcg"; 5 | 6 | -------------------------------------------------------------------------------- /puptol/data/shared/dftcalc/test1.dft: -------------------------------------------------------------------------------- 1 | toplevel "A"; 2 | "A" 2of3 "B" "C" "D"; 3 | "B" lambda=0.1 dorm=0; 4 | "C" lambda=0.2 dorm=0; 5 | "D" lambda=0.3 dorm=0; 6 | -------------------------------------------------------------------------------- /puptol/data/shared/dftcalc/test1_err.dft: -------------------------------------------------------------------------------- 1 | toplevel "A"; 2 | "A" 2of3 "B" "C" "D"; 3 | "B" laambda=0.1 dorm=0; 4 | "C" lambda=0.2 dorm=0; 5 | "D" lambda=0.3 dorm=0; 6 | -------------------------------------------------------------------------------- /puptol/data/shared/dftcalc/test2.dft: -------------------------------------------------------------------------------- 1 | toplevel "A"; 2 | "A" or "B" "C" "D"; 3 | "B" fdep "E" "F" "G"; 4 | "C" pand "F" "G"; 5 | "D" lambda=0.1 dorm=0; 6 | "E" lambda=0.0001 dorm=0; 7 | "F" lambda=0.4 dorm=0; 8 | "G" lambda=0.8 dorm=0; 9 | -------------------------------------------------------------------------------- /puptol/data/shared/dftcalc/test3.dft: -------------------------------------------------------------------------------- 1 | toplevel "A1"; 2 | "A1" 2of3 "B" "C" "D"; 3 | "B" lambda=0.1 dorm=0; 4 | "C" lambda=0.2 dorm=0; 5 | "D" aph="erl2_2.bcg"; 6 | -------------------------------------------------------------------------------- /puptol/data/shared/dftcalc/test_all.dft: -------------------------------------------------------------------------------- 1 | toplevel "A1"; 2 | "A1" 2of3 "B" "B2" "C" "D"; 3 | "B" fdep "B1" "B3" "B4"; 4 | "B1" lambda=0.04 dorm=0; 5 | "B2" pand "B3" "B4"; 6 | "B3" lambda=0.3 dorm=0; 7 | "B4" lambda=0.2 dorm=0; 8 | "C" or "C1" "C2" "C3"; 9 | "C1" wsp "C1P" "CS"; 10 | "C1P" lambda=0.1 dorm=0; 11 | "C2" wsp "C2P" "CS"; 12 | "C2P" lambda=0.1 dorm=0; 13 | "C3" wsp "C3P" "CS"; 14 | "C3P" lambda=0.1 dorm=0; 15 | "CS" wsp "CS1" "CS2"; 16 | "CS1" lambda=0.2 dorm=0.5; 17 | "CS2" lambda=0.2 dorm=0.1; 18 | "D" aph="erl2_2.bcg"; 19 | -------------------------------------------------------------------------------- /puptol/html/dftcalc/css/style-narrow.css: -------------------------------------------------------------------------------- 1 | /* 2 | Alpha by HTML5 UP 3 | html5up.net | @n33co 4 | Free for personal and commercial use under the CCA 3.0 license (html5up.net/license) 5 | */ 6 | 7 | /* Basic */ 8 | 9 | body, input, select, textarea { 10 | font-size: 12pt; 11 | } 12 | -------------------------------------------------------------------------------- /puptol/html/dftcalc/css/style-normal.css: -------------------------------------------------------------------------------- 1 | /* 2 | Alpha by HTML5 UP 3 | html5up.net | @n33co 4 | Free for personal and commercial use under the CCA 3.0 license (html5up.net/license) 5 | */ 6 | 7 | /* Basic */ 8 | 9 | body, input, select, textarea { 10 | font-size: 12pt; 11 | } 12 | 13 | /* Header */ 14 | 15 | .dropotron.level-0 { 16 | font-size: 1em; 17 | } 18 | 19 | /* Banner */ 20 | 21 | #banner { 22 | background-attachment: scroll; 23 | } 24 | 25 | #banner h2 { 26 | font-size: 3.5em; 27 | } 28 | -------------------------------------------------------------------------------- /puptol/html/dftcalc/css/style-wide.css: -------------------------------------------------------------------------------- 1 | /* 2 | Alpha by HTML5 UP 3 | html5up.net | @n33co 4 | Free for personal and commercial use under the CCA 3.0 license (html5up.net/license) 5 | */ 6 | 7 | /* Basic */ 8 | 9 | body, input, select, textarea { 10 | font-size: 14pt; 11 | } 12 | 13 | /* Banner */ 14 | 15 | #banner { 16 | padding: 10em 0 18em 0; 17 | } 18 | -------------------------------------------------------------------------------- /puptol/html/dftcalc/files/fmt-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/utwente-fmt/dftcalc/aaaa84595404f4522a6d01718f45dd953184c92a/puptol/html/dftcalc/files/fmt-logo.png -------------------------------------------------------------------------------- /puptol/html/dftcalc/fonts/fontawesome-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/utwente-fmt/dftcalc/aaaa84595404f4522a6d01718f45dd953184c92a/puptol/html/dftcalc/fonts/fontawesome-webfont.eot -------------------------------------------------------------------------------- /puptol/html/dftcalc/fonts/fontawesome-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/utwente-fmt/dftcalc/aaaa84595404f4522a6d01718f45dd953184c92a/puptol/html/dftcalc/fonts/fontawesome-webfont.ttf -------------------------------------------------------------------------------- /puptol/html/dftcalc/fonts/fontawesome-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/utwente-fmt/dftcalc/aaaa84595404f4522a6d01718f45dd953184c92a/puptol/html/dftcalc/fonts/fontawesome-webfont.woff -------------------------------------------------------------------------------- /puptol/html/dftcalc/js/jquery.scrollgress.min.js: -------------------------------------------------------------------------------- 1 | /* jquery.scrollgress vx.x | (c) n33 | n33.co @n33co | MIT */ 2 | (function(){var e="scrollwatchResume",t="length",n="removeData",r="data",i="scrollwatch-state",s="scrollwatch-suspended",o="scrollgress-suspended",u="setTimeout",a="trigger",f="scroll",l="scrollwatchSuspend",c=!0,h="scrollwatch",p=null,d="top",v="rangeMin",m="rangeMax",g="scrollgress",y=!1,b="anchor",w="unscrollwatch",E="unscrollgress",S="element",x="-id",T="scroll.",N="height",C="scrollTop",k="center",L="bottom",A=$(window),O=$(document),M=1e3;jQuery.fn[e]=function(){var l,c;if(this[t]==0)return $(this);if(this[t]>1){for(l=0;l1){for(e=0;e1){for(n=0;n=a[v],n=a[m]===y||e<=a[m];if(t&&n){f[r](i,1),a.on&&a.on(f),w&&(w(f,c),w=p);return}}if(s==1||s==-1){t=a[v]!==y&&ea[m];if(t||n){f[r](i,0),a.off&&a.off(f),w&&(w(f,y),w=p);return}}},w?0:a.delay)},{anchor:a[b]},h),f},jQuery.fn[w]=function(){var e,r;if(this[t]==0)return $(this);if(this[t]>1){for(e=0;e1){for(s=0;s0?s=Math.max(0,s-u.easing/100):s<0&&(s=Math.min(0,s+u.easing/100)),e(s,l)})[a](f),l},jQuery.fn[E]=function(e){var i,s,o,u;if(this[t]==0)return $(this);if(this[t]>1){for(i=0;i1&&(n=e(a)).length>0&&(s=n.offset().top,u.hasClass("scrolly-centered")?o=s-(e(window).height()-n.outerHeight())/2:(o=Math.max(s,0),i&&(typeof i=="function"?o-=i():o-=i)),t.preventDefault(),e("body,html").stop().animate({scrollTop:o},r,"swing"))}),s}})(jQuery); -------------------------------------------------------------------------------- /puptol/html/dftcalc/js/jquery.scrollzer.min.js: -------------------------------------------------------------------------------- 1 | /* jquery.scrollzer v0.2 | (c) n33 | n33.co @n33co | MIT + GPLv2 */ 2 | jQuery.scrollzer=function(e,t){var n=!1,r="object",i="clearTimeout",s="setTimeout",o="removeClass",u="scrollzer-locked",a="activeClassName",f=jQuery(window),l=jQuery(document);f.load(function(){var c,h,p,d,v,m,g,y,b,w,E=jQuery.extend({activeClassName:"active",suffix:"-link",pad:50,firstHack:n,lastHack:n},t),S=[],x=jQuery();for(c in e){p=jQuery("#"+e[c]),d=jQuery("#"+e[c]+E.suffix);if(p.length<1||d.length<1)continue;h={},h.link=d,h[r]=p,S[e[c]]=h,x=x.add(d)}y=function(){var e;for(c in S)e=S[c],e.start=Math.ceil(e[r].offset().top)-E.pad,e.end=e.start+Math.ceil(e[r].innerHeight());f.trigger("scroll")},f.resize(function(){window[i](g),g=window[s](y,250)}),w=function(){x[o](u)},f.scroll(function(){var e=0,t=n;v=f.scrollTop(),window[i](b),b=window[s](w,250);for(c in S)c!=m&&v>=S[c].start&&v<=S[c].end&&(m=c,t=!0),e++;E.lastHack&&v+f.height()>=l.height()&&(m=c,t=!0),t&&!x.hasClass(u)&&(x[o](E[a]),S[m].link.addClass(E[a]))}),f.trigger("resize")})}; -------------------------------------------------------------------------------- /puptol/html/dftcalc/play/markup.css: -------------------------------------------------------------------------------- 1 | pre.example, pre.src { 2 | background-color: white; 3 | overflow: auto; 4 | padding: 1ex 1em; 5 | margin: 0.5ex 3em 0.5ex 1em; 6 | border: thin dotted #AE0A00; 7 | line-height: 130%; 8 | } 9 | 10 | h1, h2, h3, h4, 11 | #body ul > li:before { 12 | color: #AE0A00; 13 | } 14 | 15 | h3, h4 { 16 | margin-top: 2ex; 17 | margin-bottom: 0.5ex; 18 | } 19 | 20 | h1 + p, h2 + p, h3 + p, h4 + p { 21 | margin-top: 0; 22 | } 23 | 24 | p + p { 25 | margin-top: 2ex; 26 | } 27 | 28 | /* Kludge around having to reset dl.contents */ 29 | #make-targets-list dl { 30 | margin-left: 2em; 31 | } 32 | 33 | #make-targets-list dt:after { 34 | content: ":"; 35 | font-weight: bold; 36 | } 37 | 38 | #make-targets-list dl dd:empty + dt { 39 | margin-top: 0; 40 | } 41 | 42 | #make-targets-list dl dd + dt { 43 | margin-top: 1.5ex; 44 | } 45 | 46 | 47 | #content h2 { 48 | padding-bottom: 0.2ex; 49 | border-bottom: 2px solid #AE0A00; 50 | clear: both; 51 | } 52 | 53 | #content div.contents:before { 54 | content: "Contents"; 55 | font-weight: bolder; 56 | text-align: center; 57 | display: block; 58 | color: white; 59 | background-color: #AE0A00; 60 | margin: 0; 61 | padding: 0.4ex 0.5em; 62 | } 63 | 64 | #content .contents { 65 | float: right; 66 | margin: 0 0 0 1em; 67 | padding: 0; 68 | max-width: 50%; 69 | font-size: smaller; 70 | background-color: #e8e8ff; 71 | border: thin solid #AE0A00; 72 | } 73 | 74 | #content .contents > dl { 75 | padding: 0 1em; 76 | } 77 | 78 | /* */ 79 | .verse { 80 | font-size: smaller; 81 | } 82 | 83 | /* counters */ 84 | body { 85 | counter-reset: section subsection; 86 | } 87 | 88 | .counters .contents > dl { 89 | counter-reset: toc-section; 90 | } 91 | 92 | .counters .contents > dl > dt:before { 93 | counter-increment: toc-section; 94 | content: counter(toc-section) ". "; 95 | } 96 | 97 | .counters h2:before { 98 | counter-increment: section; 99 | content: counter(section) ". "; 100 | } 101 | 102 | .counters h2 { 103 | counter-reset: subsection; 104 | } 105 | 106 | .counters h3:before { 107 | counter-increment: subsection; 108 | content: counter(section) "." counter(subsection) ". "; 109 | } 110 | -------------------------------------------------------------------------------- /puptol/html/dftcalc/play/style.css: -------------------------------------------------------------------------------- 1 | @import url("../css/skel.css"); 2 | @import url("../css/style.css"); 3 | @import url("../css/style-wide.css"); 4 | -------------------------------------------------------------------------------- /share/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(dft2lnt) 2 | -------------------------------------------------------------------------------- /share/dft2lnt/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ## DFT2LNT Library project 2 | project (dftmisc) 3 | 4 | ## Needed for bison and flex 5 | cmake_minimum_required (VERSION 3.0) 6 | 7 | set(CMAKE_INSTALL_PREFIX ${DFTROOT} CACHE INTERNAL "" FORCE) 8 | 9 | ## Installation 10 | FILE(GLOB dftfiles "${CMAKE_CURRENT_SOURCE_DIR}/tests/*.dft") 11 | FILE(GLOB testfiles "${CMAKE_CURRENT_SOURCE_DIR}/tests/*.test") 12 | 13 | if(DEFINED ENV{CADP}) 14 | install (DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/lntnodes" 15 | DESTINATION share/dft2lnt 16 | FILE_PERMISSIONS OWNER_READ 17 | GROUP_READ 18 | WORLD_READ 19 | 20 | DIRECTORY_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE 21 | GROUP_READ GROUP_WRITE GROUP_EXECUTE 22 | WORLD_READ WORLD_WRITE WORLD_EXECUTE 23 | ) 24 | install (DIRECTORY 25 | DESTINATION share/dft2lnt/bcgnodes/ 26 | DIRECTORY_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE 27 | GROUP_READ GROUP_WRITE GROUP_EXECUTE 28 | WORLD_READ WORLD_WRITE WORLD_EXECUTE 29 | ) 30 | endif() 31 | 32 | install (FILES ${dftfiles} 33 | DESTINATION share/dft2lnt/tests 34 | PERMISSIONS OWNER_READ 35 | GROUP_READ 36 | WORLD_READ 37 | ) 38 | install (FILES ${testfiles} 39 | DESTINATION share/dft2lnt/tests 40 | PERMISSIONS OWNER_READ 41 | GROUP_READ 42 | WORLD_READ 43 | ) 44 | -------------------------------------------------------------------------------- /share/dft2lnt/lntnodes/TEMPLATE_BE_DUMMY.lnt: -------------------------------------------------------------------------------- 1 | module TEMPLATE_BE_DUMMY(TEMPLATE_COMMON) is 2 | 3 | process BEproc [FAIL : NAT_CHANNEL, ACTIVATE : NAT_BOOL_CHANNEL] (total: NAT, initial: STATUS) is 4 | var 5 | status : STATUS 6 | in 7 | status := initial; 8 | loop 9 | select 10 | 11 | (* 12 | * Activating the dummy is allowed, but 13 | * pointless. 14 | *) 15 | ACTIVATE (?0,FALSE) 16 | 17 | (* 18 | * The BE can be made to fail by an external 19 | * trigger event. 20 | *) 21 | [] 22 | var nr : NAT in 23 | FAIL (?nr) where (0 < nr) and (nr <= total) 24 | end var; 25 | if (not (status == FAILING) or not (status == FAILED)) then 26 | status := FAILING 27 | end if 28 | 29 | (* 30 | * When this BE is in the FAILING state (caused by 31 | * an external trigger) signal this to the system 32 | * using FAIL !0 and go into the FAILED state. 33 | *) 34 | [] 35 | if (status == FAILING) then 36 | FAIL (!0 of NAT); 37 | status := FAILED 38 | end if 39 | end select 40 | end loop 41 | end var 42 | end process 43 | end module 44 | -------------------------------------------------------------------------------- /share/dft2lnt/lntnodes/TEMPLATE_COMMON.lnt: -------------------------------------------------------------------------------- 1 | module TEMPLATE_COMMON is 2 | channel NAT_CHANNEL is (NAT) end channel 3 | channel NAT_NAT_CHANNEL is (NAT,NAT) end channel 4 | channel NAT_BOOL_CHANNEL is (NAT,BOOL) end channel 5 | 6 | type STATUS is 7 | DORMANT, ACTIVE, FAILING, FAILED 8 | with "==", "!=" 9 | end type 10 | end module 11 | 12 | -------------------------------------------------------------------------------- /share/dft2lnt/lntnodes/TEMPLATE_COMMON_APH_REPAIR.lnt: -------------------------------------------------------------------------------- 1 | module TEMPLATE_COMMON_APH_REPAIR is 2 | 3 | -- channel typing 4 | channel NAT_CHANNEL is (NAT) end channel 5 | channel NAT_NAT_CHANNEL is (NAT,NAT) end channel 6 | channel NAT_BOOL_CHANNEL is (NAT,BOOL) end channel 7 | channel BOOL_CHANNEL is (BOOL) end channel 8 | 9 | -- The status of the DFT components 10 | type STATUS is 11 | UP, FAILED, FAILING, DOWN, FAILSAFE 12 | with "==", "!=" 13 | end type 14 | 15 | type REPAIR_STATUS is 16 | NONE, NEEDED, WAITING, BUSY, DONE 17 | with "==", "!=" 18 | end type 19 | end module 20 | -------------------------------------------------------------------------------- /share/dft2lnt/lntnodes/TEMPLATE_COMMON_REPAIR.lnt: -------------------------------------------------------------------------------- 1 | module TEMPLATE_COMMON_REPAIR is 2 | 3 | -- channel typing 4 | channel NAT_CHANNEL is (NAT) end channel 5 | channel NAT_NAT_CHANNEL is (NAT,NAT) end channel 6 | channel NAT_BOOL_CHANNEL is (NAT,BOOL) end channel 7 | 8 | -- The status of the DFT components 9 | type STATUS is 10 | UP, ACTIVE, FAILED_ACTIVE, FAILED_INACTIVE, DOWN_ACTIVE, DOWN_INACTIVE, UNAVAILABLE_ACTIVE, UNAVAILABLE_INACTIVE, AVAILABLE_ACTIVE, AVAILABLE_INACTIVE, REPAIRING_ACTIVE, REPAIRING_INACTIVE 11 | with "==", "!=" 12 | end type 13 | 14 | end module 15 | -------------------------------------------------------------------------------- /share/dft2lnt/lntnodes/TEMPLATE_FDEP.lnt: -------------------------------------------------------------------------------- 1 | module TEMPLATE_FDEP(TEMPLATE_COMMON) is 2 | 3 | process FDEP [FAIL : NAT_CHANNEL, ACTIVATE : NAT_BOOL_CHANNEL] (total : NAT, notified : BOOL_ARRAY, trigger_always_active : BOOL) is 4 | var 5 | nr : NAT, 6 | act : NAT, 7 | failed : BOOL 8 | in 9 | failed := FALSE; 10 | act := 0; 11 | loop 12 | select 13 | 14 | (* 15 | * Listen for the source (trigger) event to be triggered. 16 | * Set failed to TRUE, to enable the propagation of 17 | * the event to the dependers. 18 | *) 19 | FAIL (?nr) where (nr == (1)); 20 | failed := TRUE 21 | 22 | (* 23 | * If the dependers should be notified of the failure of the 24 | * source, do this one at a time, in a nondeterministic fashion. 25 | * Array notified holds which dependers are notified. 26 | *) 27 | [] 28 | if (failed) then 29 | nr := 1 of NAT; 30 | loop fail in 31 | select 32 | 33 | (* In the loop we either notify the current depender, 34 | * associated with the current value of nr ... 35 | *) 36 | if( nr <= (total) ) then 37 | if not (notified[nr]) then 38 | FAIL (!(nr+1)); 39 | notified[nr] := TRUE; 40 | break fail 41 | end if 42 | end if 43 | 44 | (* ... or we continue with the next depender. 45 | * Reaching the end is always possible, but doesn't 46 | * generate a transition in the resulting system. 47 | *) 48 | [] 49 | if nr < total then 50 | nr := nr + 1 51 | else 52 | break fail 53 | end if 54 | end select 55 | end loop 56 | end if 57 | 58 | (* 59 | * If this node is activated, enable the activation of the source. 60 | *) 61 | [] 62 | ACTIVATE (?nr,FALSE) where nr == (0 of NAT); 63 | if (act == 0 of NAT) then 64 | act := 1 of NAT 65 | end if 66 | 67 | (* 68 | * If the source should be activated, do so and disable the 69 | * activation of the source. 70 | *) 71 | [] 72 | if ((act == 1 of NAT) and not(trigger_always_active)) then 73 | ACTIVATE (!1 of NAT,TRUE); 74 | act := 0 of NAT 75 | end if 76 | end select 77 | end loop 78 | end var 79 | end process 80 | 81 | 82 | end module 83 | 84 | -------------------------------------------------------------------------------- /share/dft2lnt/lntnodes/TEMPLATE_INSPECTION.lnt: -------------------------------------------------------------------------------- 1 | module TEMPLATE_INSPECTION(TEMPLATE_COMMON) is 2 | 3 | process INSPECTION [INSPECT : NAT_CHANNEL, REPAIR : NAT_CHANNEL, RATE_INSPECTION : NAT_CHANNEL] (total: NAT, phases: NAT) is 4 | var 5 | nr : NAT, 6 | counter : NAT, 7 | signal : BOOL 8 | in 9 | counter := 0; 10 | signal := FALSE; 11 | loop 12 | select 13 | -- listen for inspection 14 | INSPECT (?nr) where (0 < nr) and (nr <= total); 15 | if (not (signal)) then 16 | signal := TRUE 17 | end if 18 | 19 | -- phases 20 | [] 21 | if(counter < phases) then 22 | RATE_INSPECTION(!1 of NAT); 23 | counter := counter + 1; 24 | if((counter == phases) and not(signal)) then 25 | counter := 0 26 | end if 27 | end if 28 | 29 | [] 30 | if((counter == phases) and signal) then 31 | REPAIR (!0 of NAT); 32 | counter := 0; 33 | signal := FALSE 34 | end if 35 | end select 36 | end loop 37 | end var 38 | end process 39 | 40 | end module 41 | -------------------------------------------------------------------------------- /share/dft2lnt/lntnodes/TEMPLATE_PAND.lnt: -------------------------------------------------------------------------------- 1 | module TEMPLATE_PAND(TEMPLATE_COMMON) is 2 | 3 | process PAND [IMPOSSIBLE : none, FAIL : NAT_CHANNEL, 4 | ACTIVATE : NAT_BOOL_CHANNEL, ONLINE: NAT_CHANNEL] 5 | (total : NAT, always_active : BOOL, repairable : BOOL) is 6 | var 7 | failed : BOOL_ARRAY, 8 | nr_failed: NAT, 9 | in_order_mark : NAT, 10 | done : BOOL, 11 | nr_act : NAT 12 | in 13 | done := FALSE; 14 | failed := BOOL_ARRAY(FALSE); 15 | nr_act := 0; 16 | nr_failed := 0; 17 | in_order_mark := 0; 18 | loop 19 | select 20 | 21 | (* 22 | * Listen for any child to be triggered. 23 | *) 24 | var nr : NAT in 25 | FAIL (?nr) where (0 < nr) and (nr <= total); 26 | if (nr == (in_order_mark + 1)) then 27 | in_order_mark := nr 28 | end if; 29 | if not(failed[nr]) then 30 | nr_failed := nr_failed + 1 31 | end if; 32 | failed[nr] := TRUE 33 | end var 34 | 35 | (* 36 | * Listen for any child to be repaired. 37 | *) 38 | 39 | [] 40 | var nr : NAT in 41 | if repairable then 42 | ONLINE (?nr) where (0 < nr) and (nr <= total); 43 | if (nr <= in_order_mark) then 44 | in_order_mark := nr - 1 45 | end if; 46 | if not(failed[nr]) then 47 | IMPOSSIBLE; stop 48 | end if; 49 | failed[nr] := FALSE; 50 | nr_failed := nr_failed - 1 51 | end if 52 | end var 53 | 54 | (* 55 | * Checks if all the children have failed and if they failed in 56 | * the right order. If this is the case, the PAnd fails and 57 | * notifies its parents. 58 | *) 59 | [] 60 | if (in_order_mark == total) and not(done) then 61 | FAIL (!0 of NAT); 62 | done := TRUE 63 | end if 64 | 65 | [] 66 | if (in_order_mark < total) and done then 67 | ONLINE(!0 of NAT); 68 | done := FALSE 69 | end if 70 | 71 | (* 72 | * If this node is activated, enable the activation of the source. 73 | *) 74 | [] 75 | ACTIVATE (!0 of NAT, !FALSE); 76 | if (not(always_active)) then 77 | if (nr_act == 0 of NAT) then 78 | nr_act := 1 of NAT 79 | end if 80 | end if 81 | 82 | (* 83 | * If the children should be activated, do so, one by one, 84 | * from left to right. 85 | *) 86 | [] 87 | if (nr_act > 0) then 88 | ACTIVATE (!nr_act,TRUE); 89 | if nr_act < total then 90 | nr_act := nr_act + 1 91 | else 92 | nr_act := 0 93 | end if 94 | end if 95 | end select 96 | end loop 97 | end var 98 | end process 99 | end module 100 | -------------------------------------------------------------------------------- /share/dft2lnt/lntnodes/TEMPLATE_PAND_SMALL.lnt: -------------------------------------------------------------------------------- 1 | module TEMPLATE_PAND(TEMPLATE_COMMON) is 2 | 3 | process PAND [FAIL : NAT_CHANNEL, ACTIVATE : NAT_BOOL_CHANNEL] (total : NAT, failed : NAT_ARRAY) is 4 | var 5 | nr_failed : NAT, 6 | done : BOOL, 7 | never_fail: BOOL, 8 | nr : NAT, 9 | last : NAT, 10 | nr_act: NAT 11 | in 12 | done := FALSE; 13 | nr_failed := 1 of NAT; 14 | nr_act := 0 of NAT; 15 | never_fail := FALSE; 16 | loop 17 | select 18 | 19 | (* 20 | * Listen for any child to be triggered. 21 | * If this happens, we add the localNodeID of the failing node to 22 | * the list of failed nodes. 23 | * The PAnd children should all fail from left to right. Note that 24 | * for a PAnd with two children supporting repair, the following 25 | * sequence would cause the PAnd to fail: 26 | * - Fail B 27 | * - Fail A 28 | * - Repair B 29 | * - Fail B 30 | *) 31 | FAIL (?nr) where (0 < nr) and (nr <= total) and not(never_fail); 32 | if(nr == nr_failed) then 33 | nr_failed:=nr_failed+1 34 | else 35 | never_fail:=TRUE 36 | end if; 37 | nr := 0 38 | 39 | (* 40 | * Checks if all the children have failed and if they failed in 41 | * the right order. If this is the case, the PAnd fails and 42 | * notifies its parents. 43 | *) 44 | [] 45 | if (nr_failed > total) and not (done) and not(never_fail) then 46 | FAIL (!0 of NAT); done := TRUE 47 | end if 48 | 49 | (* 50 | * If this node is activated, enable the activation of the source. 51 | *) 52 | [] 53 | ACTIVATE (?nr,FALSE) where (nr == (0 of NAT)); 54 | if (nr_act == 0 of NAT) then 55 | nr_act := 1 of NAT 56 | end if 57 | 58 | (* 59 | * If the children should be activated, do so, one by one, 60 | * from left to right. 61 | *) 62 | [] 63 | if (nr_act > 0) then 64 | ACTIVATE (!nr_act,TRUE); 65 | if nr_act < total then 66 | nr_act := nr_act + 1 67 | else 68 | nr_act := 0 69 | end if 70 | end if 71 | end select 72 | end loop 73 | end var 74 | end process 75 | 76 | 77 | end module 78 | -------------------------------------------------------------------------------- /share/dft2lnt/lntnodes/TEMPLATE_PERIODIC_REPAIRUNIT.lnt: -------------------------------------------------------------------------------- 1 | module TEMPLATE_PERIODIC_REPAIRUNIT(TEMPLATE_COMMON_REPAIR) is 2 | 3 | process REPLACEMENT [REPAIR : NAT_CHANNEL, REPAIRED : NAT_BOOL_CHANNEL, RATE_PERIOD : NAT_CHANNEL] (total : NAT, phases : NAT) is 4 | var 5 | nr : NAT, 6 | signal : BOOL, 7 | counter : NAT 8 | in 9 | signal := FALSE; 10 | counter := 0; 11 | loop 12 | select 13 | -- listen for repaire signal 14 | REPAIR (?nr) where (0 < nr) and (nr <= total); 15 | if (not (signal)) then 16 | signal := TRUE 17 | end if 18 | 19 | 20 | [] 21 | if((counter == phases) or signal) then 22 | REPAIRED(!1 of NAT,TRUE); 23 | counter := 0; 24 | signal := FALSE 25 | end if 26 | 27 | -- phases 28 | [] 29 | if((counter < phases) and not(signal)) then 30 | RATE_PERIOD(!1 of NAT); 31 | counter := counter + 1 32 | end if 33 | 34 | end select 35 | end loop 36 | end var 37 | end process 38 | 39 | end module 40 | -------------------------------------------------------------------------------- /share/dft2lnt/lntnodes/TEMPLATE_POR.lnt: -------------------------------------------------------------------------------- 1 | module TEMPLATE_POR(TEMPLATE_COMMON) is 2 | 3 | process POR [FAIL : NAT_CHANNEL, ACTIVATE : NAT_BOOL_CHANNEL] (total : NAT, received : BOOL_ARRAY) is 4 | var 5 | done : BOOL, 6 | failed : BOOL, 7 | failed_before : BOOL, 8 | nr : NAT, 9 | nr_act: NAT 10 | in 11 | done := FALSE; 12 | failed := FALSE; 13 | failed_before := FALSE; 14 | nr_act := 0 of NAT; 15 | loop 16 | select 17 | 18 | (* 19 | * Listen for any child to be triggered. 20 | * If the first child fails before all others, start the failure procedure of the gate 21 | *) 22 | FAIL (?nr) where (1 < nr) and (nr <= total); 23 | if ((not(failed)) and (not(received[nr]))) then 24 | received[nr] := TRUE; 25 | failed_before := TRUE 26 | end if; 27 | nr := 0 28 | 29 | (* 30 | * If the first child fails before all others, start the failure procedure of the gate 31 | *) 32 | [] 33 | FAIL (?nr) where (nr == 1); 34 | if ((not(failed_before)) and (not(received[nr]))) then 35 | received[nr] := TRUE; 36 | failed := TRUE 37 | end if; 38 | nr := 0 39 | 40 | (* 41 | * If this node is activated, enable the activation of the source. 42 | *) 43 | [] 44 | ACTIVATE (?nr,FALSE) where (nr == (0 of NAT)); 45 | if (nr_act == 0 of NAT) then 46 | nr_act := 1 of NAT 47 | end if 48 | 49 | (* 50 | * If the children should be activated, do so, one by one, 51 | * from left to right. 52 | *) 53 | [] 54 | if (nr_act > 0) then 55 | ACTIVATE (!nr_act,TRUE); 56 | if nr_act < total then 57 | nr_act := nr_act + 1 58 | else 59 | nr_act := 0 60 | end if 61 | end if 62 | 63 | (* 64 | * Failure Procedure for the POR gate 65 | *) 66 | [] 67 | if ((failed) and (not(done))) then 68 | FAIL (!0 of NAT); 69 | done := TRUE 70 | end if 71 | end select 72 | end loop 73 | end var 74 | end process 75 | 76 | 77 | end module 78 | -------------------------------------------------------------------------------- /share/dft2lnt/lntnodes/TEMPLATE_REPAIRUNIT.lnt: -------------------------------------------------------------------------------- 1 | module TEMPLATE_REPAIRUNIT(TEMPLATE_COMMON) is 2 | 3 | process REPAIRUNIT [REPAIR : NAT_CHANNEL, REPAIRED : NAT_BOOL_CHANNEL, RATE_REPAIR : NAT_NAT_CHANNEL] (total : NAT, repair_needed : BOOL_ARRAY, repair_queue : NAT_ARRAY) is 4 | var 5 | nr : NAT, 6 | nr_re : NAT, 7 | nr_queue : NAT, 8 | nr_signal : NAT, 9 | idx : NAT 10 | in 11 | nr_queue := 0; 12 | nr_signal := 0; 13 | idx := 0; 14 | loop 15 | select 16 | -- listen for repair 17 | REPAIR (?nr) where (0 < nr) and (nr <= total); 18 | if (not (repair_needed[nr])) then 19 | repair_needed[nr] := TRUE; 20 | nr_queue := nr_queue + 1; 21 | repair_queue[nr] := nr_queue 22 | end if 23 | 24 | -- repair with FCFS strategy 25 | [] 26 | if ((nr_queue > 0) and (nr_signal == 0)) then 27 | idx := idx + 1; 28 | loop repair in 29 | if ((repair_needed[idx]) and (repair_queue[idx] == 1)) then 30 | nr_queue := nr_queue - 1; 31 | nr_signal := 1; 32 | RATE_REPAIR (!1 of NAT,idx of NAT); 33 | break repair 34 | end if; 35 | idx := idx + 1; 36 | if(idx > total) then 37 | break repair 38 | end if 39 | end loop; 40 | idx := 1; 41 | loop decrement in 42 | if(repair_needed[idx]) then 43 | repair_queue[idx] := repair_queue[idx] - 1 44 | end if; 45 | idx := idx + 1; 46 | if(idx > total) then 47 | break decrement 48 | end if 49 | end loop; 50 | idx := 0 51 | end if 52 | 53 | -- signal the repair with FCFS strategy 54 | [] 55 | if (nr_signal > 0) then 56 | idx := idx+ 1; 57 | loop signal in 58 | if((repair_needed[idx]) and (repair_queue[idx] == 0)) then 59 | nr_signal := 0; 60 | repair_needed[idx] := FALSE; 61 | REPAIRED(!idx,TRUE); 62 | break signal 63 | end if; 64 | idx := idx + 1; 65 | if(idx > total) then 66 | break signal 67 | end if 68 | end loop; 69 | idx := 0 70 | end if 71 | 72 | 73 | end select 74 | end loop 75 | end var 76 | end process 77 | 78 | end module 79 | -------------------------------------------------------------------------------- /share/dft2lnt/lntnodes/TEMPLATE_REPAIRUNIT_ARB.lnt: -------------------------------------------------------------------------------- 1 | module TEMPLATE_REPAIRUNIT_ARB(TEMPLATE_COMMON) is 2 | 3 | process REPAIRUNIT [REPAIR : NAT_CHANNEL, REPAIRED : NAT_BOOL_CHANNEL, RATE_REPAIR : NAT_NAT_CHANNEL] (total : NAT, repair_needed : BOOL_ARRAY, repaired : BOOL_ARRAY) is 4 | var 5 | nr : NAT, 6 | idx : NAT, 7 | nr_queue : NAT, 8 | signal : BOOL 9 | in 10 | idx := 0; 11 | nr_queue := 0; 12 | signal := FALSE; 13 | loop 14 | select 15 | -- listen for repair 16 | REPAIR (?nr) where (0 < nr) and (nr <= total); 17 | if (not (repair_needed[nr])) then 18 | repair_needed[nr] := TRUE; 19 | nr_queue := nr_queue + 1 20 | end if; 21 | nr := 0 22 | 23 | -- repair with any strategy 24 | [] 25 | if (nr_queue > 0) then 26 | if ((0 < idx) and (idx <= total) and (repair_needed[idx]) and (not(repaired[idx]))) then 27 | repaired[idx] := TRUE; 28 | nr_queue := nr_queue - 1; 29 | signal := TRUE; 30 | RATE_REPAIR (!1 of NAT,idx of NAT) 31 | end if 32 | end if 33 | 34 | -- look for all BCs 35 | [] 36 | if(not(signal)) then 37 | if (idx < total) then 38 | idx := idx+1 39 | else 40 | idx := 0 41 | end if 42 | end if 43 | 44 | -- signal the repair signal of repaired BC 45 | [] 46 | if (signal) then 47 | if((0 < idx) and (idx <= total) and (repair_needed[idx]) and (repaired[idx])) then 48 | signal := FALSE; 49 | repair_needed[idx] := FALSE; 50 | repaired[idx] := FALSE; 51 | REPAIRED(!idx,TRUE); 52 | idx := idx+1 53 | elsif (idx < total) then 54 | idx := idx+1 55 | end if 56 | end if 57 | 58 | end select 59 | end loop 60 | end var 61 | end process 62 | 63 | end module 64 | -------------------------------------------------------------------------------- /share/dft2lnt/lntnodes/TEMPLATE_REPAIRUNIT_ND.lnt: -------------------------------------------------------------------------------- 1 | module TEMPLATE_REPAIRUNIT_ND(TEMPLATE_COMMON) is 2 | 3 | process REPAIRUNIT_ND [REPAIR : NAT_CHANNEL, 4 | REPAIRED : NAT_CHANNEL, 5 | REPAIRING : NAT_BOOL_CHANNEL, 6 | IMPOSSIBLE : none] 7 | (total : NAT) 8 | is 9 | var 10 | nr : NAT, 11 | repair_needed : BOOL_ARRAY, 12 | repair_busy : NAT, 13 | idx : NAT 14 | in 15 | repair_needed := BOOL_ARRAY(FALSE); 16 | repair_busy := 0 of NAT; 17 | loop 18 | select 19 | -- listen for repair 20 | REPAIR (?nr) where (0 < nr) and (nr <= total); 21 | if (repair_busy == nr) then 22 | IMPOSSIBLE; stop 23 | end if; 24 | repair_needed[nr] := TRUE 25 | 26 | -- Pick any BE in need of repair and start it. 27 | [] if (repair_busy == 0) then 28 | idx := any NAT where (idx > 0) and (idx <= total); 29 | if repair_needed[idx] then 30 | repair_needed[idx] := FALSE; 31 | repair_busy := idx; 32 | REPAIRING(!idx, TRUE) 33 | end if 34 | end if 35 | 36 | -- Someone else is repairing the BE 37 | [] 38 | REPAIRING(?nr, FALSE) where 39 | (0 < nr) and (nr <= total); 40 | repair_needed[nr] := FALSE; 41 | if nr == repair_busy then 42 | IMPOSSIBLE; stop 43 | end if 44 | 45 | -- Ignore any BE that says it's done. 46 | [] 47 | REPAIRED (?nr) where (0 < nr) and (nr <= total); 48 | if (nr == repair_busy) then 49 | repair_needed[nr] := FALSE; 50 | repair_busy := 0 51 | end if 52 | end select 53 | end loop 54 | end var 55 | end process 56 | 57 | end module 58 | -------------------------------------------------------------------------------- /share/dft2lnt/lntnodes/TEMPLATE_REPAIRUNIT_PRIO.lnt: -------------------------------------------------------------------------------- 1 | module TEMPLATE_REPAIRUNIT_PRIO(TEMPLATE_COMMON) is 2 | 3 | process REPAIRUNIT [REPAIR : NAT_CHANNEL, REPAIRED : NAT_BOOL_CHANNEL, RATE_REPAIR : NAT_NAT_CHANNEL] (total : NAT, repair_needed : BOOL_ARRAY, repaired : BOOL_ARRAY, priority : NAT_ARRAY) is 4 | var 5 | nr : NAT, 6 | nr_repair : NAT, 7 | nr_queue : NAT, 8 | signal : BOOL, 9 | idx : NAT, 10 | prio : NAT, 11 | itt : NAT, 12 | prio_tmp : NAT 13 | in 14 | idx := 0; 15 | nr_queue := 0; 16 | signal := FALSE; 17 | nr_repair := 0; 18 | prio:=0; 19 | prio_tmp := 0; 20 | itt:=0; 21 | loop 22 | select 23 | -- listen for repair 24 | REPAIR (?nr) where (0 < nr) and (nr <= total); 25 | if (not (repair_needed[nr]) and (not(repaired[nr]))) then 26 | repair_needed[nr] := TRUE; 27 | nr_queue := nr_queue + 1; 28 | if(prio < priority[nr]) then 29 | prio := priority[nr] 30 | end if 31 | end if 32 | 33 | -- repair with priority strategy 34 | [] 35 | if ((nr_queue > 0) and not(signal)) then 36 | if ((0 < idx) and (idx <= total) and (repair_needed[idx]) and (not(repaired[idx]))) then 37 | if(priority[idx] == prio) then 38 | repaired[idx] := TRUE; 39 | nr_queue := nr_queue - 1; 40 | signal := TRUE; 41 | RATE_REPAIR (!1 of NAT,idx of NAT); 42 | prio:=0 43 | end if 44 | end if 45 | end if 46 | 47 | -- look for all BCs 48 | [] 49 | if(not(signal)) then 50 | if (idx < total) then 51 | idx := idx+1 52 | else 53 | idx := 0 54 | end if 55 | end if 56 | 57 | -- signal the repair signal of repaired BC 58 | [] 59 | if (signal) then 60 | if((0 < idx) and (idx <= total) and (repair_needed[idx]) and (repaired[idx])) then 61 | signal := FALSE; 62 | repair_needed[idx] := FALSE; 63 | repaired[idx] := FALSE; 64 | REPAIRED(!idx,TRUE); 65 | if(nr_queue==0) then 66 | prio:=0; 67 | prio_tmp:=0 68 | else 69 | itt:=1; 70 | prio_tmp:=0; 71 | loop check in 72 | if((repair_needed[itt]) and (prio_tmp < priority[itt])) then 73 | prio_tmp:=priority[itt] 74 | end if; 75 | itt := itt+1; 76 | if(itt > total) then 77 | break check 78 | end if 79 | end loop; 80 | prio:=prio_tmp 81 | end if 82 | elsif (idx < total) then 83 | idx := idx+1 84 | end if 85 | end if 86 | 87 | end select 88 | end loop 89 | end var 90 | end process 91 | 92 | end module 93 | -------------------------------------------------------------------------------- /share/dft2lnt/lntnodes/TEMPLATE_SEQUENCE_AND.lnt: -------------------------------------------------------------------------------- 1 | module TEMPLATE_SEQUENCE_AND(TEMPLATE_COMMON) is 2 | 3 | process SEQUENCE_AND [FAIL : NAT_CHANNEL, ACTIVATE : NAT_BOOL_CHANNEL] 4 | (threshold : NAT, total : NAT, received : BOOL_ARRAY, 5 | always_active : BOOL) is 6 | var 7 | nr : NAT, 8 | done : BOOL, 9 | nr_act : NAT, 10 | active : BOOL, 11 | activated : BOOL_ARRAY 12 | in 13 | nr_act := 0; 14 | done := FALSE; 15 | active := always_active; 16 | activated := BOOL_ARRAY(FALSE); 17 | if always_active then 18 | nr_act := 1; 19 | activated[1] := TRUE 20 | end if; 21 | loop 22 | select 23 | 24 | (* 25 | * Listen for any child to be triggered. 26 | * If this happens, we remember this by setting the boolean 27 | * in the received array to TRUE. We also decrement the threshold. 28 | *) 29 | FAIL (?nr) where (nr > 0) and (nr == nr_act) and (nr <= total) and (active); 30 | if not (received[nr]) and (threshold > 0) and not (done) and (active) then 31 | received[nr] := TRUE; 32 | nr_act := nr_act+1; 33 | threshold := threshold - 1; 34 | if(nr_act <= total) then 35 | ACTIVATE (!nr_act,TRUE) 36 | end if 37 | end if 38 | 39 | (* 40 | * If the threshold reaches 0, this means the threshold number 41 | * of children have failed out of the total number of children. 42 | * Thus, the Voting node fails and notifies its parents. 43 | *) 44 | [] 45 | if (threshold == 0) and not (done) then 46 | FAIL (!0 of NAT); done := TRUE 47 | end if; 48 | nr := 0 49 | 50 | (* 51 | * If this node is activated, enable the activation procedure. 52 | *) 53 | [] 54 | ACTIVATE (?nr,FALSE) where nr == (0 of NAT); 55 | if (nr_act == 0 of NAT) and not (done) and (threshold > 0) then 56 | nr_act := 1 of NAT 57 | end if 58 | 59 | (* 60 | * If the children should be activated, do so, one by one, 61 | * from left to right. 62 | *) 63 | [] 64 | if (nr_act >= 1) and not (done) and (threshold > 0) then 65 | if not (activated[nr_act]) then 66 | ACTIVATE (!nr_act,TRUE); 67 | activated[nr_act] := TRUE; 68 | active := TRUE 69 | end if 70 | end if 71 | end select 72 | end loop 73 | end var 74 | end process 75 | 76 | 77 | end module 78 | -------------------------------------------------------------------------------- /share/dft2lnt/lntnodes/TEMPLATE_VOTING_REPAIR.lnt: -------------------------------------------------------------------------------- 1 | module TEMPLATE_VOTING_REPAIR(TEMPLATE_COMMON_REPAIR) is 2 | 3 | process VOTING_K [IMPOSSIBLE : none, 4 | FAIL : NAT_CHANNEL, 5 | ACTIVATE : NAT_BOOL_CHANNEL, 6 | DEACTIVATE : NAT_BOOL_CHANNEL, 7 | ONLINE : NAT_CHANNEL] 8 | (threshold : NAT, total : NAT, repairable : NAT, always_active : BOOL) 9 | is var 10 | nr : NAT, 11 | done : BOOL, 12 | running : BOOL, 13 | nr_failed : NAT, 14 | received : BOOL_ARRAY, 15 | activated : BOOL_ARRAY, 16 | nr_act : NAT 17 | in 18 | received := BOOL_ARRAY(FALSE); 19 | activated := BOOL_ARRAY(FALSE); 20 | done := FALSE; 21 | nr_failed := 0; 22 | nr_act := 0; 23 | running := FALSE; 24 | loop 25 | while (nr_act > 0 and running and activated[nr_act]) loop 26 | if nr_act < total then 27 | nr_act := nr_act + 1 28 | else 29 | nr_act := 0 30 | end if 31 | end loop; 32 | while (nr_act > 0 and not(running) and not(activated[nr_act])) loop 33 | nr_act := nr_act - 1 34 | end loop; 35 | 36 | select 37 | 38 | (* 39 | * Listen for any child to be triggered. 40 | * If this happens, we remember this by setting the boolean 41 | * in the received array to TRUE. We also decrement the threshold. 42 | *) 43 | FAIL (?nr) where (0 < nr) and (nr <= total); 44 | if not (received[nr]) then 45 | received[nr] := TRUE; 46 | nr_failed := nr_failed + 1 47 | end if 48 | 49 | (* 50 | * If the threshold reaches 0, this means the threshold number 51 | * of children have failed out of the total number of children. 52 | * Thus, the Voting node fails and notifies its parents. 53 | *) 54 | [] 55 | if (nr_failed >= threshold) and not (done) then 56 | FAIL (!0 of NAT); 57 | done := TRUE 58 | end if 59 | 60 | -- increase decrease failed components if component gets repaired 61 | [] 62 | ONLINE (?nr) where (0 < nr) and (nr <= total); 63 | if ((nr > repairable) or (not(received[nr]))) then 64 | IMPOSSIBLE; 65 | loop null end loop 66 | else 67 | received[nr] := FALSE; 68 | nr_failed := nr_failed - 1 69 | end if 70 | 71 | -- send up signal if voting is working again 72 | [] 73 | if((done) and (nr_failed < threshold)) then 74 | done := FALSE; 75 | ONLINE(!0 of NAT) 76 | end if 77 | 78 | (* 79 | * If this node is activated, enable the activation procedure. 80 | *) 81 | [] 82 | if not(always_active) then 83 | ACTIVATE (?nr,FALSE) where nr == (0 of NAT); 84 | nr_act := 1 of NAT; 85 | running := TRUE 86 | end if 87 | 88 | [] 89 | DEACTIVATE (0 of NAT,FALSE); 90 | if not(always_active) then 91 | nr_act := total; 92 | running := FALSE 93 | else 94 | IMPOSSIBLE; 95 | loop null end loop 96 | end if 97 | 98 | (* 99 | * If the children should be activated, do so, one by one, 100 | * from left to right. 101 | *) 102 | [] 103 | if (nr_act > 0 and running) then 104 | activated[nr_act] := TRUE; 105 | ACTIVATE (!nr_act,TRUE); 106 | if nr_act < total then 107 | nr_act := nr_act + 1 108 | else 109 | nr_act := 0 110 | end if 111 | end if 112 | 113 | (* 114 | * If the children should be deactivated, do so, one 115 | * by one, from right to left. 116 | *) 117 | [] 118 | if (nr_act > 0 and not(running)) then 119 | activated[nr_act] := FALSE; 120 | DEACTIVATE (!nr_act,TRUE); 121 | nr_act := nr_act - 1 122 | end if 123 | end select 124 | end loop 125 | end var 126 | end process 127 | end module 128 | -------------------------------------------------------------------------------- /share/dft2lnt/tests/and.dft: -------------------------------------------------------------------------------- 1 | toplevel "A"; 2 | "A" and "B" "C"; 3 | "B" lambda=0.5 dorm=3; 4 | "C" lambda=0.5 dorm=3; 5 | 6 | -------------------------------------------------------------------------------- /share/dft2lnt/tests/be.dft: -------------------------------------------------------------------------------- 1 | toplevel "A"; 2 | "A" lambda=0.5 dorm=3; 3 | 4 | -------------------------------------------------------------------------------- /share/dft2lnt/tests/cas.dft: -------------------------------------------------------------------------------- 1 | toplevel "System"; 2 | "System" or "CPUfdep" "CPUunit" "Motorunit" "Pumpunit"; 3 | 4 | "CPUfdep" fdep "trigger" "P" "B"; 5 | "trigger" or "CS" "SS"; 6 | "CS" lambda=0.2 dorm=0; 7 | "SS" lambda=0.2 dorm=0; 8 | "CPUunit" wsp "P" "B"; 9 | "P" lambda=0.5 dorm=0; 10 | "B" lambda=0.5 dorm=0.5; 11 | 12 | "Motorunit" or "MP" "Motors"; 13 | "MP" pand "MS" "MA"; 14 | "Motors" csp "MA" "MB"; 15 | "MS" lambda=0.01 dorm=0; 16 | "MA" lambda=1 dorm=0; 17 | "MB" lambda=1 dorm=0; 18 | 19 | "Pumpunit" and "PumpA" "PumpB"; 20 | "PumpA" csp "PA" "PS"; 21 | "PumpB" csp "PB" "PS"; 22 | "PA" lambda=1 dorm=0; 23 | "PB" lambda=1 dorm=0; 24 | "PS" lambda=1 dorm=0; 25 | -------------------------------------------------------------------------------- /share/dft2lnt/tests/cps.dft: -------------------------------------------------------------------------------- 1 | toplevel "System"; 2 | 3 | "System" pand "A" "B"; 4 | 5 | "A" and "AA" "AB" "AC" "AD"; 6 | 7 | "B" pand "C" "D"; 8 | 9 | "C" and "CA" "CB" "CC" "CD"; 10 | 11 | "D" and "DA" "DB" "DC" "DD"; 12 | 13 | "AA" lambda=1 dorm=0; 14 | "AB" lambda=1 dorm=0; 15 | "AC" lambda=1 dorm=0; 16 | "AD" lambda=1 dorm=0; 17 | 18 | "CA" lambda=1 dorm=0; 19 | "CB" lambda=1 dorm=0; 20 | "CC" lambda=1 dorm=0; 21 | "CD" lambda=1 dorm=0; 22 | 23 | "DA" lambda=1 dorm=0; 24 | "DB" lambda=1 dorm=0; 25 | "DC" lambda=1 dorm=0; 26 | "DD" lambda=1 dorm=0; 27 | -------------------------------------------------------------------------------- /share/dft2lnt/tests/deathegg.dft: -------------------------------------------------------------------------------- 1 | toplevel "DeathEgg"; 2 | "DeathEgg" or "DeathEggProxy" "DeathEggServer" "CampusPowerDependency" "ProxyPowerDependency"; 3 | "DeathEggServer" or "CampusNET" "DES_Disks"; 4 | "DES_Disks" and "DES_Disks_RAID1" "DES_Disks_RAID2"; 5 | "DES_Disks_RAID1" and "DES_Disk_1" "DES_Disk_2"; 6 | "DES_Disks_RAID2" and "DES_Disk_3" "DES_Disk_4"; 7 | "DeathEggProxy" lambda=0.01 dorm=0; 8 | "DES_Disk_1" lambda=0.01 dorm=0; 9 | "DES_Disk_2" lambda=0.01 dorm=0; 10 | "DES_Disk_3" lambda=0.01 dorm=0; 11 | "DES_Disk_4" lambda=0.01 dorm=0; 12 | "CampusPowerDependency" fdep "CampusPower" "DeathEggServer"; 13 | "ProxyPowerDependency" fdep "ProxyPower" "DeathEggProxy"; 14 | "CampusPower" lambda=0.01 dorm=0; 15 | "CampusNET" lambda=0.01 dorm=0; 16 | "ProxyPower" lambda=0.01 dorm=0; -------------------------------------------------------------------------------- /share/dft2lnt/tests/fdep.dft: -------------------------------------------------------------------------------- 1 | toplevel "System"; 2 | "System" or "Power" "Machine"; 3 | "Power" fdep "B_Power" "P" "B"; 4 | "Machine" or "P" "B"; 5 | 6 | "B_Power" lambda=0.5 dorm=0; 7 | "P" lambda=0.5 dorm=0; 8 | "B" lambda=0.5 dorm=0.5; 9 | -------------------------------------------------------------------------------- /share/dft2lnt/tests/ftpp_complex.dft: -------------------------------------------------------------------------------- 1 | toplevel "System"; 2 | "System" or "triadA" "triadB" "triadC" "triadD" "fA" "fB" "fC" "fD"; 3 | 4 | "triadA" 2of3 "aA" "bA" "cA"; 5 | "aA" csp "TAA" "TAS"; 6 | "bA" csp "TAB" "TAS"; 7 | "cA" csp "TAC" "TAS"; 8 | 9 | "triadB" 2of3 "aB" "bB" "cB"; 10 | "aB" csp "TBA" "TBS"; 11 | "bB" csp "TBB" "TBS"; 12 | "cB" csp "TBC" "TBS"; 13 | 14 | "triadC" 2of3 "aC" "bC" "cC"; 15 | "aC" csp "TCA" "TCS"; 16 | "bC" csp "TCB" "TCS"; 17 | "cC" csp "TCC" "TCS"; 18 | 19 | "triadD" 2of3 "aD" "bD" "cD"; 20 | "aD" csp "TDA" "TDS"; 21 | "bD" csp "TDB" "TDS"; 22 | "cD" csp "TDC" "TDS"; 23 | 24 | "fA" fdep "NEA" "TAA" "TBA" "TCA" "TDA"; 25 | "fB" fdep "NEB" "TAB" "TBB" "TCB" "TDB"; 26 | "fC" fdep "NEC" "TAC" "TBC" "TCC" "TDC"; 27 | "fD" fdep "NED" "TAS" "TBS" "TCS" "TDS"; 28 | 29 | 30 | "NEA" lambda=0.017 dorm=1; 31 | "NEB" lambda=0.017 dorm=1; 32 | "NEC" lambda=0.017 dorm=1; 33 | "NED" lambda=0.017 dorm=1; 34 | 35 | "TAA" or "cpuAA" "memAA"; 36 | "memAA" csp "memAA1" "memAA2"; 37 | "cpuAA" lambda=0.11 dorm=0; 38 | "memAA1" lambda=0.11 dorm=0; 39 | "memAA2" lambda=0.11 dorm=0; 40 | 41 | "TAB" or "cpuAB" "memAB"; 42 | "memAB" csp "memAB1" "memAB2"; 43 | "cpuAB" lambda=0.11 dorm=0; 44 | "memAB1" lambda=0.11 dorm=0; 45 | "memAB2" lambda=0.11 dorm=0; 46 | 47 | "TAC" or "cpuAC" "memAC"; 48 | "memAC" csp "memAC1" "memAC2"; 49 | "cpuAC" lambda=0.11 dorm=0; 50 | "memAC1" lambda=0.11 dorm=0; 51 | "memAC2" lambda=0.11 dorm=0; 52 | 53 | "TAS" or "cpuAS" "memAS"; 54 | "memAS" csp "memAS1" "memAS2"; 55 | "cpuAS" lambda=0.11 dorm=0; 56 | "memAS1" lambda=0.11 dorm=0; 57 | "memAS2" lambda=0.11 dorm=0; 58 | 59 | "TBA" or "cpuBA" "memBA"; 60 | "memBA" csp "memBA1" "memBA2"; 61 | "cpuBA" lambda=0.11 dorm=0; 62 | "memBA1" lambda=0.11 dorm=0; 63 | "memBA2" lambda=0.11 dorm=0; 64 | 65 | "TBB" or "cpuBB" "memBB"; 66 | "memBB" csp "memBB1" "memBB2"; 67 | "cpuBB" lambda=0.11 dorm=0; 68 | "memBB1" lambda=0.11 dorm=0; 69 | "memBB2" lambda=0.11 dorm=0; 70 | 71 | "TBC" or "cpuBC" "memBC"; 72 | "memBC" csp "memBC1" "memBC2"; 73 | "cpuBC" lambda=0.11 dorm=0; 74 | "memBC1" lambda=0.11 dorm=0; 75 | "memBC2" lambda=0.11 dorm=0; 76 | 77 | "TBS" or "cpuBS" "memBS"; 78 | "memBS" csp "memBS1" "memBS2"; 79 | "cpuBS" lambda=0.11 dorm=0; 80 | "memBS1" lambda=0.11 dorm=0; 81 | "memBS2" lambda=0.11 dorm=0; 82 | 83 | "TCA" or "cpuCA" "memCA"; 84 | "memCA" csp "memCA1" "memCA2"; 85 | "cpuCA" lambda=0.11 dorm=0; 86 | "memCA1" lambda=0.11 dorm=0; 87 | "memCA2" lambda=0.11 dorm=0; 88 | 89 | "TCB" or "cpuCB" "memCB"; 90 | "memCB" csp "memCB1" "memCB2"; 91 | "cpuCB" lambda=0.11 dorm=0; 92 | "memCB1" lambda=0.11 dorm=0; 93 | "memCB2" lambda=0.11 dorm=0; 94 | 95 | "TCC" or "cpuCC" "memCC"; 96 | "memCC" csp "memCC1" "memCC2"; 97 | "cpuCC" lambda=0.11 dorm=0; 98 | "memCC1" lambda=0.11 dorm=0; 99 | "memCC2" lambda=0.11 dorm=0; 100 | 101 | "TCS" or "cpuCS" "memCS"; 102 | "memCS" csp "memCS1" "memCS2"; 103 | "cpuCS" lambda=0.11 dorm=0; 104 | "memCS1" lambda=0.11 dorm=0; 105 | "memCS2" lambda=0.11 dorm=0; 106 | 107 | "TDA" or "cpuDA" "memDA"; 108 | "memDA" csp "memDA1" "memDA2"; 109 | "cpuDA" lambda=0.11 dorm=0; 110 | "memDA1" lambda=0.11 dorm=0; 111 | "memDA2" lambda=0.11 dorm=0; 112 | 113 | "TDB" or "cpuDB" "memDB"; 114 | "memDB" csp "memDB1" "memDB2"; 115 | "cpuDB" lambda=0.11 dorm=0; 116 | "memDB1" lambda=0.11 dorm=0; 117 | "memDB2" lambda=0.11 dorm=0; 118 | 119 | "TDC" or "cpuDC" "memDC"; 120 | "memDC" csp "memDC1" "memDC2"; 121 | "cpuDC" lambda=0.11 dorm=0; 122 | "memDC1" lambda=0.11 dorm=0; 123 | "memDC2" lambda=0.11 dorm=0; 124 | 125 | "TDS" or "cpuDS" "memDS"; 126 | "memDS" csp "memDS1" "memDS2"; 127 | "cpuDS" lambda=0.11 dorm=0; 128 | "memDS1" lambda=0.11 dorm=0; 129 | "memDS2" lambda=0.11 dorm=0; 130 | -------------------------------------------------------------------------------- /share/dft2lnt/tests/ftpp_large.dft: -------------------------------------------------------------------------------- 1 | toplevel "System"; 2 | "System" or "triadA" "triadB" "triadC" "triadD" "fA" "fB" "fC" "fD" "fE"; 3 | 4 | "triadA" 3of4 "aA" "bA" "cA" "dA"; 5 | "aA" csp "TAA" "TAS"; 6 | "bA" csp "TAB" "TAS"; 7 | "cA" csp "TAC" "TAS"; 8 | "dA" csp "TAD" "TAS"; 9 | 10 | "triadB" 3of4 "aB" "bB" "cB" "dB"; 11 | "aB" csp "TBA" "TBS"; 12 | "bB" csp "TBB" "TBS"; 13 | "cB" csp "TBC" "TBS"; 14 | "dB" csp "TBD" "TBS"; 15 | 16 | "triadC" 3of4 "aC" "bC" "cC" "dC"; 17 | "aC" csp "TCA" "TCS"; 18 | "bC" csp "TCB" "TCS"; 19 | "cC" csp "TCC" "TCS"; 20 | "dC" csp "TCD" "TCS"; 21 | 22 | "triadD" 3of4 "aD" "bD" "cD" "dD"; 23 | "aD" csp "TDA" "TDS"; 24 | "bD" csp "TDB" "TDS"; 25 | "cD" csp "TDC" "TDS"; 26 | "dD" csp "TDD" "TDS"; 27 | 28 | "fA" fdep "NEA" "TAA" "TBA" "TCA" "TDA"; 29 | "fB" fdep "NEB" "TAB" "TBB" "TCB" "TDB"; 30 | "fC" fdep "NEC" "TAC" "TBC" "TCC" "TDC"; 31 | "fD" fdep "NED" "TAD" "TBD" "TCD" "TDD"; 32 | "fE" fdep "NEE" "TAS" "TBS" "TCS" "TDS"; 33 | 34 | 35 | "NEA" lambda=0.017 dorm=1; 36 | "NEB" lambda=0.017 dorm=1; 37 | "NEC" lambda=0.017 dorm=1; 38 | "NED" lambda=0.017 dorm=1; 39 | "NEE" lambda=0.017 dorm=1; 40 | 41 | "TAA" lambda=0.11 dorm=0; 42 | "TAB" lambda=0.11 dorm=0; 43 | "TAC" lambda=0.11 dorm=0; 44 | "TAD" lambda=0.11 dorm=0; 45 | "TAS" lambda=0.11 dorm=0; 46 | 47 | "TBA" lambda=0.11 dorm=0; 48 | "TBB" lambda=0.11 dorm=0; 49 | "TBC" lambda=0.11 dorm=0; 50 | "TBD" lambda=0.11 dorm=0; 51 | "TBS" lambda=0.11 dorm=0; 52 | 53 | "TCA" lambda=0.11 dorm=0; 54 | "TCB" lambda=0.11 dorm=0; 55 | "TCC" lambda=0.11 dorm=0; 56 | "TCD" lambda=0.11 dorm=0; 57 | "TCS" lambda=0.11 dorm=0; 58 | 59 | "TDA" lambda=0.11 dorm=0; 60 | "TDB" lambda=0.11 dorm=0; 61 | "TDC" lambda=0.11 dorm=0; 62 | "TDD" lambda=0.11 dorm=0; 63 | "TDS" lambda=0.11 dorm=0; 64 | -------------------------------------------------------------------------------- /share/dft2lnt/tests/ftpp_standard.dft: -------------------------------------------------------------------------------- 1 | toplevel "System"; 2 | "System" or "triadA" "triadB" "triadC" "triadD" "fA" "fB" "fC" "fD"; 3 | 4 | "triadA" 2of3 "aA" "bA" "cA"; 5 | "aA" csp "TAA" "TAS"; 6 | "bA" csp "TAB" "TAS"; 7 | "cA" csp "TAC" "TAS"; 8 | 9 | "triadB" 2of3 "aB" "bB" "cB"; 10 | "aB" csp "TBA" "TBS"; 11 | "bB" csp "TBB" "TBS"; 12 | "cB" csp "TBC" "TBS"; 13 | 14 | "triadC" 2of3 "aC" "bC" "cC"; 15 | "aC" csp "TCA" "TCS"; 16 | "bC" csp "TCB" "TCS"; 17 | "cC" csp "TCC" "TCS"; 18 | 19 | "triadD" 2of3 "aD" "bD" "cD"; 20 | "aD" csp "TDA" "TDS"; 21 | "bD" csp "TDB" "TDS"; 22 | "cD" csp "TDC" "TDS"; 23 | 24 | "fA" fdep "NEA" "TAA" "TBA" "TCA" "TDA"; 25 | "fB" fdep "NEB" "TAB" "TBB" "TCB" "TDB"; 26 | "fC" fdep "NEC" "TAC" "TBC" "TCC" "TDC"; 27 | "fD" fdep "NED" "TAS" "TBS" "TCS" "TDS"; 28 | 29 | 30 | "NEA" lambda=0.017 dorm=1; 31 | "NEB" lambda=0.017 dorm=1; 32 | "NEC" lambda=0.017 dorm=1; 33 | "NED" lambda=0.017 dorm=1; 34 | 35 | "TAA" lambda=0.11 dorm=0; 36 | "TAB" lambda=0.11 dorm=0; 37 | "TAC" lambda=0.11 dorm=0; 38 | "TAS" lambda=0.11 dorm=0; 39 | 40 | "TBA" lambda=0.11 dorm=0; 41 | "TBB" lambda=0.11 dorm=0; 42 | "TBC" lambda=0.11 dorm=0; 43 | "TBS" lambda=0.11 dorm=0; 44 | 45 | "TCA" lambda=0.11 dorm=0; 46 | "TCB" lambda=0.11 dorm=0; 47 | "TCC" lambda=0.11 dorm=0; 48 | "TCS" lambda=0.11 dorm=0; 49 | 50 | "TDA" lambda=0.11 dorm=0; 51 | "TDB" lambda=0.11 dorm=0; 52 | "TDC" lambda=0.11 dorm=0; 53 | "TDS" lambda=0.11 dorm=0; 54 | -------------------------------------------------------------------------------- /share/dft2lnt/tests/ftpp_weibull.dft: -------------------------------------------------------------------------------- 1 | toplevel "System"; 2 | "System" or "triadA" "triadB" "triadC" "triadD" "fA" "fB" "fC" "fD"; 3 | 4 | "triadA" 2of3 "aA" "bA" "cA"; 5 | "aA" csp "TAA" "TAS"; 6 | "bA" csp "TAB" "TAS"; 7 | "cA" csp "TAC" "TAS"; 8 | 9 | "triadB" 2of3 "aB" "bB" "cB"; 10 | "aB" csp "TBA" "TBS"; 11 | "bB" csp "TBB" "TBS"; 12 | "cB" csp "TBC" "TBS"; 13 | 14 | "triadC" 2of3 "aC" "bC" "cC"; 15 | "aC" csp "TCA" "TCS"; 16 | "bC" csp "TCB" "TCS"; 17 | "cC" csp "TCC" "TCS"; 18 | 19 | "triadD" 2of3 "aD" "bD" "cD"; 20 | "aD" csp "TDA" "TDS"; 21 | "bD" csp "TDB" "TDS"; 22 | "cD" csp "TDC" "TDS"; 23 | 24 | "fA" fdep "NEA" "TAA" "TBA" "TCA" "TDA"; 25 | "fB" fdep "NEB" "TAB" "TBB" "TCB" "TDB"; 26 | "fC" fdep "NEC" "TAC" "TBC" "TCC" "TDC"; 27 | "fD" fdep "NED" "TAS" "TBS" "TCS" "TDS"; 28 | 29 | 30 | "NEA" rate=58.82352941 shape=2 dorm=1; 31 | "NEB" rate=58.82352941 shape=2 dorm=1; 32 | "NEC" rate=58.82352941 shape=2 dorm=1; 33 | "NED" rate=58.82352941 shape=2 dorm=1; 34 | 35 | "TAA" lambda=0.11 dorm=0; 36 | "TAB" lambda=0.11 dorm=0; 37 | "TAC" lambda=0.11 dorm=0; 38 | "TAS" lambda=0.11 dorm=0; 39 | 40 | "TBA" lambda=0.11 dorm=0; 41 | "TBB" lambda=0.11 dorm=0; 42 | "TBC" lambda=0.11 dorm=0; 43 | "TBS" lambda=0.11 dorm=0; 44 | 45 | "TCA" lambda=0.11 dorm=0; 46 | "TCB" lambda=0.11 dorm=0; 47 | "TCC" lambda=0.11 dorm=0; 48 | "TCS" lambda=0.11 dorm=0; 49 | 50 | "TDA" lambda=0.11 dorm=0; 51 | "TDB" lambda=0.11 dorm=0; 52 | "TDC" lambda=0.11 dorm=0; 53 | "TDS" lambda=0.11 dorm=0; 54 | -------------------------------------------------------------------------------- /share/dft2lnt/tests/mdcs.dft: -------------------------------------------------------------------------------- 1 | toplevel "System"; 2 | 3 | "System" or "S" "N"; 4 | 5 | "N" lambda=2e-5 dorm=0; 6 | 7 | "S" and "CMA" "CMB"; 8 | 9 | "CMA" or "DiskA" "PA" "MemA"; 10 | "DiskA" wsp "DAA" "DAB"; 11 | "PA" lambda=500e-5 dorm=0; 12 | "MemA" wsp "MA" "MC"; 13 | "DAA" lambda=80000e-5 dorm=0.5; 14 | "DAB" lambda=80000e-5 dorm=0.5; 15 | "MA" lambda=30e-5 dorm=0; 16 | 17 | "CMB" or "DiskB" "PB" "MemB"; 18 | "DiskB" wsp "DBA" "DBB"; 19 | "PB" lambda=500e-5 dorm=0; 20 | "MemB" wsp "MB" "MC"; 21 | "DBA" lambda=80000e-5 dorm=0.5; 22 | "DBB" lambda=80000e-5 dorm=0.5; 23 | "MB" lambda=30e-5 dorm=0; 24 | 25 | "MC" lambda=30e-5 dorm=0.5; 26 | 27 | -------------------------------------------------------------------------------- /share/dft2lnt/tests/mdcs2.dft: -------------------------------------------------------------------------------- 1 | toplevel "System"; 2 | "System" or "S" "N"; 3 | "N" lambda=0.0000200000 dorm=0.0000000000; 4 | "S" and "CMA" "CMB"; 5 | "CMA" or "DiskA" "PA" "MemA"; 6 | "DiskA" wsp "DAA" "DAB"; 7 | "PA" lambda=0.0049999999 dorm=0.0000000000; 8 | "MemA" wsp "MA" "MC"; 9 | "DAA" lambda=0.8000000119 dorm=0.5000000000; 10 | "DAB" lambda=0.8000000119 dorm=0.5000000000; 11 | "MA" lambda=0.0003000000 dorm=0.0000000000; 12 | "CMB" or "DiskB" "PB" "MemB"; 13 | "DiskB" wsp "DBA" "DBB"; 14 | "PB" lambda=0.0049999999 dorm=0.0000000000; 15 | "MemB" wsp "MB" "MC"; 16 | "DBA" lambda=0.8000000119 dorm=0.5000000000; 17 | "DBB" lambda=0.8000000119 dorm=0.5000000000; 18 | "MB" lambda=0.0003000000 dorm=0.0000000000; 19 | "MC" lambda=0.0003000000 dorm=0.5000000000; 20 | -------------------------------------------------------------------------------- /share/dft2lnt/tests/mp.dft: -------------------------------------------------------------------------------- 1 | toplevel "A"; 2 | "A" or "B" "C"; 3 | "B" or "D" "E"; 4 | "C" or "F" "E"; 5 | "D" lambda=0.1 dorm=0; 6 | "E" lambda=0.2 dorm=0; 7 | "F" lambda=0.3 dorm=0; 8 | -------------------------------------------------------------------------------- /share/dft2lnt/tests/or.dft: -------------------------------------------------------------------------------- 1 | toplevel "A"; 2 | "A" or "B" "C"; 3 | "B" lambda=0.5 dorm=3; 4 | "C" lambda=0.5 dorm=3; 5 | 6 | -------------------------------------------------------------------------------- /share/dft2lnt/tests/pand.dft: -------------------------------------------------------------------------------- 1 | toplevel "A"; 2 | "A" pand "B" "C"; 3 | "B" lambda=0.5 dorm=3; 4 | "C" lambda=0.5 dorm=3; 5 | 6 | -------------------------------------------------------------------------------- /share/dft2lnt/tests/simple.test: -------------------------------------------------------------------------------- 1 | - fullname: Basic Event, 1 time unit 2 | longdesc: "" 3 | dft: be.dft 4 | verified: 5 | manual: 0.3934693 6 | - fullname: Basic Event, 2 time units 7 | longdesc: "" 8 | dft: be.dft 9 | timeunits: 2 10 | verified: 11 | manual: 0.6321206 12 | - fullname: Basic Event, 10 time units 13 | longdesc: "" 14 | dft: be.dft 15 | timeunits: 10 16 | verified: 17 | manual: 0.9932621 18 | - fullname: And 19 | longdesc: "" 20 | dft: and.dft 21 | verified: 22 | manual: 0.1548181 23 | - fullname: Or 24 | longdesc: "" 25 | dft: or.dft 26 | verified: 27 | manual: 0.6321206 28 | - fullname: PAnd 29 | longdesc: "" 30 | dft: pand.dft 31 | verified: 32 | manual: 0.0774091 33 | - fullname: FDEP 34 | longdesc: "" 35 | dft: fdep.dft 36 | verified: 37 | manual: 0.7768698 38 | - fullname: Spare 39 | longdesc: "" 40 | dft: spare.dft 41 | verified: 42 | manual: 0.1118531 43 | - fullname: 2 Spares with common spare 44 | longdesc: "" 45 | dft: spare2.dft 46 | verified: 47 | manual: 0.2905027 48 | - fullname: 3 Spares with common spare 49 | longdesc: "" 50 | dft: spare3.dft 51 | verified: 52 | manual: 0.4660673 53 | -------------------------------------------------------------------------------- /share/dft2lnt/tests/spare.dft: -------------------------------------------------------------------------------- 1 | toplevel "A"; 2 | "A" wsp "I" "M"; 3 | "I" lambda=0.5 dorm=0.3; 4 | "M" lambda=0.5 dorm=0.3; 5 | 6 | -------------------------------------------------------------------------------- /share/dft2lnt/tests/spare2.dft: -------------------------------------------------------------------------------- 1 | toplevel "A"; 2 | "A" or "B" "C"; 3 | "B" wsp "I" "J"; 4 | "C" wsp "M" "J"; 5 | "I" lambda=0.5 dorm=0.3; 6 | "J" lambda=0.5 dorm=0.3; 7 | "M" lambda=0.5 dorm=0.3; 8 | 9 | -------------------------------------------------------------------------------- /share/dft2lnt/tests/spare3.dft: -------------------------------------------------------------------------------- 1 | toplevel "A"; 2 | "A" or "B" "C" "D"; 3 | "B" wsp "I" "M"; 4 | "C" wsp "J" "M"; 5 | "D" wsp "K" "M"; 6 | "I" lambda=0.5 dorm=0.3; 7 | "J" lambda=0.5 dorm=0.3; 8 | "K" lambda=0.5 dorm=0.3; 9 | "M" lambda=0.5 dorm=0.3; 10 | 11 | -------------------------------------------------------------------------------- /share/dft2lnt/tests/tripple.test: -------------------------------------------------------------------------------- 1 | - fullname: Tripple And 2 | longdesc: "" 3 | dft: tripple_and.dft 4 | verified: 5 | comparison: 0.0239687 6 | - fullname: Tripple And Comparison 7 | longdesc: "" 8 | dft: tripple_and_c.dft 9 | - fullname: Tripple And (merging branches) 10 | longdesc: "" 11 | dft: tripple_and2.dft 12 | verified: 13 | comparison: 0.0609162 14 | - fullname: Tripple And (merging branches Comparison) 15 | longdesc: "" 16 | dft: tripple_and2_c.dft 17 | - fullname: Tripple Or 18 | longdesc: "" 19 | dft: tripple_or.dft 20 | verified: 21 | comparison: 0.8646647 22 | - fullname: Tripple Or Comparison 23 | longdesc: "" 24 | dft: tripple_or_c.dft 25 | - fullname: Tripple Or (merging branches) 26 | longdesc: "" 27 | dft: tripple_or2.dft 28 | verified: 29 | comparison: 0.7768698 30 | - fullname: Tripple Or (merging branches Comparison) 31 | longdesc: "" 32 | dft: tripple_or2_c.dft 33 | - fullname: Tripple PAnd 34 | longdesc: "" 35 | dft: tripple_pand.dft 36 | verified: 37 | manual: 0.0009987 38 | - fullname: Tripple PAnd Comparison 39 | longdesc: "" 40 | dft: tripple_pand_c.dft 41 | verified: 42 | manual: 0.0009987 43 | - fullname: Tripple PAnd (merging branches) 44 | longdesc: "" 45 | dft: tripple_pand2.dft 46 | verified: 47 | manual: 0.0101527 48 | - fullname: Tripple PAnd (merging branches Comparison) 49 | longdesc: "" 50 | dft: tripple_pand2_c.dft 51 | verified: 52 | manual: 0.0101527 -------------------------------------------------------------------------------- /share/dft2lnt/tests/tripple_and.dft: -------------------------------------------------------------------------------- 1 | toplevel "A"; 2 | "A" and "B" "C"; 3 | "B" and "BE1" "BE2"; 4 | "C" and "BE3" "BE4"; 5 | "BE1" lambda=0.5 dorm=3; 6 | "BE2" lambda=0.5 dorm=3; 7 | "BE3" lambda=0.5 dorm=3; 8 | "BE4" lambda=0.5 dorm=3; 9 | 10 | -------------------------------------------------------------------------------- /share/dft2lnt/tests/tripple_and2.dft: -------------------------------------------------------------------------------- 1 | toplevel "A"; 2 | "A" and "B" "C"; 3 | "B" and "BE1" "BE2"; 4 | "C" and "BE2" "BE3"; 5 | "BE1" lambda=0.5 dorm=3; 6 | "BE2" lambda=0.5 dorm=3; 7 | "BE3" lambda=0.5 dorm=3; 8 | 9 | -------------------------------------------------------------------------------- /share/dft2lnt/tests/tripple_and2_c.dft: -------------------------------------------------------------------------------- 1 | toplevel "A"; 2 | "A" and "BE1" "BE2" "BE3"; 3 | "BE1" lambda=0.5 dorm=3; 4 | "BE2" lambda=0.5 dorm=3; 5 | "BE3" lambda=0.5 dorm=3; 6 | 7 | -------------------------------------------------------------------------------- /share/dft2lnt/tests/tripple_and_c.dft: -------------------------------------------------------------------------------- 1 | toplevel "A"; 2 | "A" and "BE1" "BE2" "BE3" "BE4"; 3 | "BE1" lambda=0.5 dorm=3; 4 | "BE2" lambda=0.5 dorm=3; 5 | "BE3" lambda=0.5 dorm=3; 6 | "BE4" lambda=0.5 dorm=3; 7 | 8 | -------------------------------------------------------------------------------- /share/dft2lnt/tests/tripple_or.dft: -------------------------------------------------------------------------------- 1 | toplevel "A"; 2 | "A" or "B" "C"; 3 | "B" or "BE1" "BE2"; 4 | "C" or "BE3" "BE4"; 5 | "BE1" lambda=0.5 dorm=3; 6 | "BE2" lambda=0.5 dorm=3; 7 | "BE3" lambda=0.5 dorm=3; 8 | "BE4" lambda=0.5 dorm=3; 9 | 10 | -------------------------------------------------------------------------------- /share/dft2lnt/tests/tripple_or2.dft: -------------------------------------------------------------------------------- 1 | toplevel "A"; 2 | "A" or "B" "C"; 3 | "B" or "BE1" "BE2"; 4 | "C" or "BE2" "BE3"; 5 | "BE1" lambda=0.5 dorm=3; 6 | "BE2" lambda=0.5 dorm=3; 7 | "BE3" lambda=0.5 dorm=3; 8 | 9 | -------------------------------------------------------------------------------- /share/dft2lnt/tests/tripple_or2_c.dft: -------------------------------------------------------------------------------- 1 | toplevel "A"; 2 | "A" or "BE1" "BE2" "BE3"; 3 | "BE1" lambda=0.5 dorm=3; 4 | "BE2" lambda=0.5 dorm=3; 5 | "BE3" lambda=0.5 dorm=3; 6 | 7 | -------------------------------------------------------------------------------- /share/dft2lnt/tests/tripple_or_c.dft: -------------------------------------------------------------------------------- 1 | toplevel "A"; 2 | "A" or "BE1" "BE2" "BE3" "BE4"; 3 | "BE1" lambda=0.5 dorm=3; 4 | "BE2" lambda=0.5 dorm=3; 5 | "BE3" lambda=0.5 dorm=3; 6 | "BE4" lambda=0.5 dorm=3; 7 | 8 | -------------------------------------------------------------------------------- /share/dft2lnt/tests/tripple_pand.dft: -------------------------------------------------------------------------------- 1 | toplevel "A"; 2 | "A" pand "B" "BE4"; 3 | "B" pand "C" "BE3"; 4 | "C" pand "BE1" "BE2"; 5 | "BE1" lambda=0.5 dorm=3; 6 | "BE2" lambda=0.5 dorm=3; 7 | "BE3" lambda=0.5 dorm=3; 8 | "BE4" lambda=0.5 dorm=3; 9 | 10 | -------------------------------------------------------------------------------- /share/dft2lnt/tests/tripple_pand2.dft: -------------------------------------------------------------------------------- 1 | toplevel "A"; 2 | "A" pand "B" "C"; 3 | "B" pand "BE1" "BE2"; 4 | "C" pand "BE2" "BE3"; 5 | "BE1" lambda=0.5 dorm=3; 6 | "BE2" lambda=0.5 dorm=3; 7 | "BE3" lambda=0.5 dorm=3; 8 | 9 | -------------------------------------------------------------------------------- /share/dft2lnt/tests/tripple_pand2_c.dft: -------------------------------------------------------------------------------- 1 | toplevel "A"; 2 | "A" pand "BE1" "BE2" "BE3"; 3 | "BE1" lambda=0.5 dorm=3; 4 | "BE2" lambda=0.5 dorm=3; 5 | "BE3" lambda=0.5 dorm=3; 6 | 7 | -------------------------------------------------------------------------------- /share/dft2lnt/tests/tripple_pand_c.dft: -------------------------------------------------------------------------------- 1 | toplevel "A"; 2 | "A" pand "BE1" "BE2" "BE3" "BE4"; 3 | "BE1" lambda=0.5 dorm=3; 4 | "BE2" lambda=0.5 dorm=3; 5 | "BE3" lambda=0.5 dorm=3; 6 | "BE4" lambda=0.5 dorm=3; 7 | 8 | -------------------------------------------------------------------------------- /share/dft2lnt/tests/voting.dft: -------------------------------------------------------------------------------- 1 | toplevel "A"; 2 | "A" 2of3 "B" "C" "D"; 3 | "B" lambda=0.5 dorm=3; 4 | "C" lambda=0.5 dorm=3; 5 | "D" lambda=0.5 dorm=3; 6 | 7 | -------------------------------------------------------------------------------- /test/README: -------------------------------------------------------------------------------- 1 | This directory contains automated tests of DFTCalc. 2 | 3 | To run the tests, execute 'sh test.sh [options]', where [options] is a 4 | list of options accepted by DFTCalc (e.g. --exact or -M). If you have a 5 | lot of time on your hands, run 'sh test.sh --all [options]', which will 6 | automatically run the tests with all the model checkers and converters, 7 | and with and without modularization. 8 | 9 | The tests are listed in 'tests.txt', formatted as: 10 | filename "options" reference_result 11 | where the options should specify the metric to calculate (and -M for 12 | large trees for which non-modular analysis is impractical), and the 13 | reference result should be an interval known to contain the true value. 14 | -------------------------------------------------------------------------------- /test/WQDN.dft: -------------------------------------------------------------------------------- 1 | toplevel "System"; 2 | "System" or "POE" "Deterioration" "Contamination" "Permeation" "Biofilm" "Intrusion" "Disinfectant"; 3 | "POE" and "Source" "Treatment"; 4 | "Treatment" and "TreatmentUnits" "Staff"; 5 | "Deterioration" or "Leaching" "Corrosion"; 6 | "Leaching" and "MetallicLeach" "ConduciveLeach"; 7 | "Corrosion" and "MetallicCorr" "ConduciveCorr"; 8 | "Contamination" and "Threat" "Vulnerability"; 9 | "Vulnerability" or "PhysGeo" "Monitoring"; 10 | "Permeation" and "Plastic" "Hydrocarbon" "ConducivePerm"; 11 | "Biofilm" and "Organic" "Detention" "ConduciveBiofilm"; 12 | "Intrusion" and "Pathway" "LOPressure" "Contaminants"; 13 | "Pathway" or "PipesGaskets" "Maintenance" "CrossConnect"; 14 | "Disinfectant" or "DBP" "DisinfectantLoss"; 15 | "DBP" and "OrganicDBP" "DisinfectantConcDBP" "ConduciveDBP"; 16 | "DisinfectantLoss" and "OrganicDL" "DisinfectantConcDL" "ConduciveDL"; 17 | "Source" prob=0.2; 18 | "LOPressure" prob=0.1; 19 | "Contaminants" prob=0.05; 20 | "Threat" prob=0.05; 21 | "Plastic" prob=0.05; 22 | "Hydrocarbon" prob=0.05; 23 | "ConducivePerm" prob=0.05; 24 | "Organic" prob=0.05; 25 | "Detention" prob=0.05; 26 | "ConduciveBiofilm" prob=0.1; 27 | "TreatmentUnits" prob=0.2; 28 | "Staff" prob=0.3; 29 | "PipesGaskets" prob=0.1; 30 | "Maintenance" prob=0.1; 31 | "CrossConnect" prob=0.1; 32 | "MetallicLeach" prob=0.95; 33 | "ConduciveLeach" prob=0.05; 34 | "MetallicCorr" prob=0.95; 35 | "ConduciveCorr" prob=0.1; 36 | "PhysGeo" prob=0.1; 37 | "Monitoring" prob=0.2; 38 | "OrganicDBP" prob=0.05; 39 | "DisinfectantConcDBP" prob=0.1; 40 | "ConduciveDBP" prob=0.1; 41 | "OrganicDL" prob=0.05; 42 | "DisinfectantConcDL" prob=0.1; 43 | "ConduciveDL" prob=0.1; 44 | -------------------------------------------------------------------------------- /test/expect-fail.txt: -------------------------------------------------------------------------------- 1 | repair-exact.dft !"--imrmc" 2 | repair-exact2.dft !"--imrmc" 3 | -------------------------------------------------------------------------------- /test/repair-exact.dft: -------------------------------------------------------------------------------- 1 | toplevel "A"; 2 | "A" and "B" "C"; 3 | "I" insp3 "A" "B" "C"; 4 | "B" lambda=1 dorm=1 phases=1 interval=1; 5 | "C" lambda=1 dorm=1 phases=1 interval=1; 6 | -------------------------------------------------------------------------------- /test/repair-exact2.dft: -------------------------------------------------------------------------------- 1 | toplevel "A"; 2 | "A" and "B" "C"; 3 | "I1" insp3 "B"; 4 | "I2" insp2 "C"; 5 | "B" lambda=0.1 dorm=1 phases=1 interval=1; 6 | "C" lambda=0.1 dorm=1 phases=1 interval=1; 7 | -------------------------------------------------------------------------------- /test/repair-pand.dft: -------------------------------------------------------------------------------- 1 | toplevel "A"; 2 | "A" pand "B" "C"; 3 | "I" 2insp2 "B" "C"; 4 | "B" lambda=0.1 dorm=1 phases=1 interval=1; 5 | "C" lambda=0.1 dorm=1 phases=1 interval=1; 6 | -------------------------------------------------------------------------------- /test/repair-prob.dft: -------------------------------------------------------------------------------- 1 | toplevel "A"; 2 | "I" 2insp2 "A"; 3 | "A" lambda=0.1 prob=0.4 interval=1; 4 | -------------------------------------------------------------------------------- /test/repair-res.dft: -------------------------------------------------------------------------------- 1 | toplevel "A"; 2 | "A" and "B" "C"; 3 | "B" lambda=1 repair=1; 4 | "C" lambda=10 res=0.9 repair=1; 5 | -------------------------------------------------------------------------------- /test/repair-spare.dft: -------------------------------------------------------------------------------- 1 | toplevel "A"; 2 | "A" csp "B" "C"; 3 | "I" 2insp2 "A" "B" "C"; 4 | "B" lambda=0.1 dorm=1 phases=1 interval=1; 5 | "C" lambda=0.1 dorm=1 phases=1 interval=1; 6 | -------------------------------------------------------------------------------- /test/simple-fdep.dft: -------------------------------------------------------------------------------- 1 | toplevel "System"; 2 | "System" or "A" "B"; 3 | "F" fdep "C" "B"; 4 | "A" lambda=0.1; 5 | "B" lambda=0.2; 6 | "C" lambda=0.3; 7 | -------------------------------------------------------------------------------- /test/tests.txt: -------------------------------------------------------------------------------- 1 | repair-spare.dft "-s" 446/53361 2 | repair-pand.dft "-s" 223/53361 3 | repair-prob.dft "-u" 0.4 4 | WQDN.dft "-M -u" 0.16254539595015734248166373164453125 5 | simple-fdep.dft "-t 1" 0.451188363905973[5551; 6162] 6 | repair-res.dft "-s" 0.25 7 | repair-exact.dft "-t 5" 0.9754975012608097028555692652122260396859329911240258397122[4; 5] 8 | repair-exact2.dft "-t 5" 0.0839488543054934861182115574624[6;7] 9 | --------------------------------------------------------------------------------