diff --git a/client/README.md b/client/README.md index 5333073e5..9801dd526 100644 --- a/client/README.md +++ b/client/README.md @@ -13,6 +13,7 @@ cd client yarn install #install the nodejs dependencies yarn format #format .ts[x] and .js[x] files with prettier. yarn syntax #perform linting and static analysis +yarn graph # generate dependency graphs in the code yarn build #build the react app into build/ directory yarn develop #start the development server without building. Great for live edits. @@ -24,18 +25,23 @@ yarn start #start the application yarn clean #clean the directory of temporary files ``` -It is also possible to run different types of tests using the yarn test command by passing different flags: +It is also possible to run different types of tests using the yarn +test command by passing different flags: + ```bash yarn test -a #run all tests yarn test -u #run unit tests yarn test -i #run integration tests yarn test -e #run end-to-end tests ``` + --- ## Authentication -The react client website uses OAuth authentication. The [authentication page](../docs/admin/client/auth.md) provides details on setting up oauth authentication for the client application. +The react client website uses OAuth authentication. +The [authentication page](../docs/admin/client/auth.md) provides details +on setting up oauth authentication for the client application. ## Custom configuration diff --git a/client/script/graph.bash b/client/script/graph.bash index 01ac33756..57f177c8e 100755 --- a/client/script/graph.bash +++ b/client/script/graph.bash @@ -5,5 +5,3 @@ printf "Generate dependency graph for code" madge --image src.svg src madge --image test.svg test -#eval madge --image src.svg "$TS_CONFIG" "$EXTENSIONS" src -#madge --image test.svg --ts-config tsconfig.json --extensions ts,tsx test \ No newline at end of file diff --git a/docs/developer/client/client.md b/docs/developer/client/client.md index b2993bc27..0f78d8fc4 100644 --- a/docs/developer/client/client.md +++ b/docs/developer/client/client.md @@ -6,4 +6,14 @@ being developed as a React single page web application. A dependency graph for the entire codebase of the react application is: -![React website dependency graph](client-dep-graph.svg) +## Dependency Graphs + +The figures are the dependency graphs generated from the code. + +### src directory + +![src dependency graph](src.svg) + +### test directory + +![test dependency graph](test.svg) diff --git a/docs/developer/servers/lib/lib-ms.md b/docs/developer/servers/lib/lib-ms.md index 0f896f44b..740b93e55 100644 --- a/docs/developer/servers/lib/lib-ms.md +++ b/docs/developer/servers/lib/lib-ms.md @@ -175,3 +175,15 @@ sequenceDiagram deactivate FR ``` + +## Dependency Graphs + +The figures are the dependency graphs generated from the code. + +### src directory + +![src dependency graph](src.svg) + +### test directory + +![test dependency graph](test.svg) diff --git a/docs/developer/servers/lib/src-dep-graph.svg b/docs/developer/servers/lib/src-dep-graph.svg deleted file mode 100644 index 546c00137..000000000 --- a/docs/developer/servers/lib/src-dep-graph.svg +++ /dev/null @@ -1,193 +0,0 @@ - - - - - - -G - - - -../util.ts - -../util.ts - - - -app.module.ts - -app.module.ts - - - -app.module.ts->../util.ts - - - - - -files/files.module.ts - -files/files.module.ts - - - -app.module.ts->files/files.module.ts - - - - - -files/resolvers/files.resolver.ts - -files/resolvers/files.resolver.ts - - - -files/files.module.ts->files/resolvers/files.resolver.ts - - - - - -files/services/files-service.factory.ts - -files/services/files-service.factory.ts - - - -files/files.module.ts->files/services/files-service.factory.ts - - - - - -files/services/gitlab-files.service.ts - -files/services/gitlab-files.service.ts - - - -files/files.module.ts->files/services/gitlab-files.service.ts - - - - - -files/services/local-files.service.ts - -files/services/local-files.service.ts - - - -files/files.module.ts->files/services/local-files.service.ts - - - - - -files/resolvers/files.resolver.ts->files/services/files-service.factory.ts - - - - - -files/interfaces/files.service.interface.ts - -files/interfaces/files.service.interface.ts - - - -files/resolvers/files.resolver.ts->files/interfaces/files.service.interface.ts - - - - - -types.ts - -types.ts - - - -files/resolvers/files.resolver.ts->types.ts - - - - - -files/services/files-service.factory.ts->files/services/gitlab-files.service.ts - - - - - -files/services/files-service.factory.ts->files/services/local-files.service.ts - - - - - -files/services/files-service.factory.ts->files/interfaces/files.service.interface.ts - - - - - -files/services/gitlab-files.service.ts->files/interfaces/files.service.interface.ts - - - - - -files/services/gitlab-files.service.ts->types.ts - - - - - -files/queries.ts - -files/queries.ts - - - -files/services/gitlab-files.service.ts->files/queries.ts - - - - - -files/services/local-files.service.ts->files/interfaces/files.service.interface.ts - - - - - -files/services/local-files.service.ts->types.ts - - - - - -files/interfaces/files.service.interface.ts->types.ts - - - - - -main.ts - -main.ts - - - -main.ts->app.module.ts - - - - - diff --git a/docs/developer/servers/lib/src.svg b/docs/developer/servers/lib/src.svg new file mode 100644 index 000000000..21aabe4d7 --- /dev/null +++ b/docs/developer/servers/lib/src.svg @@ -0,0 +1,193 @@ + + + + + + +G + + + +../util.ts + +../util.ts + + + +app.module.ts + +app.module.ts + + + +app.module.ts->../util.ts + + + + + +files/files.module.ts + +files/files.module.ts + + + +app.module.ts->files/files.module.ts + + + + + +files/resolvers/files.resolver.ts + +files/resolvers/files.resolver.ts + + + +files/files.module.ts->files/resolvers/files.resolver.ts + + + + + +files/services/files-service.factory.ts + +files/services/files-service.factory.ts + + + +files/files.module.ts->files/services/files-service.factory.ts + + + + + +files/services/gitlab-files.service.ts + +files/services/gitlab-files.service.ts + + + +files/files.module.ts->files/services/gitlab-files.service.ts + + + + + +files/services/local-files.service.ts + +files/services/local-files.service.ts + + + +files/files.module.ts->files/services/local-files.service.ts + + + + + +files/resolvers/files.resolver.ts->files/services/files-service.factory.ts + + + + + +files/interfaces/files.service.interface.ts + +files/interfaces/files.service.interface.ts + + + +files/resolvers/files.resolver.ts->files/interfaces/files.service.interface.ts + + + + + +types.ts + +types.ts + + + +files/resolvers/files.resolver.ts->types.ts + + + + + +files/services/files-service.factory.ts->files/services/gitlab-files.service.ts + + + + + +files/services/files-service.factory.ts->files/services/local-files.service.ts + + + + + +files/services/files-service.factory.ts->files/interfaces/files.service.interface.ts + + + + + +files/services/gitlab-files.service.ts->files/interfaces/files.service.interface.ts + + + + + +files/services/gitlab-files.service.ts->types.ts + + + + + +files/queries.ts + +files/queries.ts + + + +files/services/gitlab-files.service.ts->files/queries.ts + + + + + +files/services/local-files.service.ts->files/interfaces/files.service.interface.ts + + + + + +files/services/local-files.service.ts->types.ts + + + + + +files/interfaces/files.service.interface.ts->types.ts + + + + + +main.ts + +main.ts + + + +main.ts->app.module.ts + + + + + diff --git a/docs/developer/servers/lib/test.svg b/docs/developer/servers/lib/test.svg new file mode 100644 index 000000000..7d86c4853 --- /dev/null +++ b/docs/developer/servers/lib/test.svg @@ -0,0 +1,337 @@ + + + + + + +G + + + +../src/app.module.ts + +../src/app.module.ts + + + +../src/files/files.module.ts + +../src/files/files.module.ts + + + +../src/app.module.ts->../src/files/files.module.ts + + + + + +../util.ts + +../util.ts + + + +../src/app.module.ts->../util.ts + + + + + +../src/files/resolvers/files.resolver.ts + +../src/files/resolvers/files.resolver.ts + + + +../src/files/files.module.ts->../src/files/resolvers/files.resolver.ts + + + + + +../src/files/services/files-service.factory.ts + +../src/files/services/files-service.factory.ts + + + +../src/files/files.module.ts->../src/files/services/files-service.factory.ts + + + + + +../src/files/services/gitlab-files.service.ts + +../src/files/services/gitlab-files.service.ts + + + +../src/files/files.module.ts->../src/files/services/gitlab-files.service.ts + + + + + +../src/files/services/local-files.service.ts + +../src/files/services/local-files.service.ts + + + +../src/files/files.module.ts->../src/files/services/local-files.service.ts + + + + + +../src/files/resolvers/files.resolver.ts->../src/files/services/files-service.factory.ts + + + + + +../src/files/interfaces/files.service.interface.ts + +../src/files/interfaces/files.service.interface.ts + + + +../src/files/resolvers/files.resolver.ts->../src/files/interfaces/files.service.interface.ts + + + + + +../src/types.ts + +../src/types.ts + + + +../src/files/resolvers/files.resolver.ts->../src/types.ts + + + + + +../src/files/services/files-service.factory.ts->../src/files/services/gitlab-files.service.ts + + + + + +../src/files/services/files-service.factory.ts->../src/files/services/local-files.service.ts + + + + + +../src/files/services/files-service.factory.ts->../src/files/interfaces/files.service.interface.ts + + + + + +../src/files/services/gitlab-files.service.ts->../src/files/interfaces/files.service.interface.ts + + + + + +../src/files/services/gitlab-files.service.ts->../src/types.ts + + + + + +../src/files/queries.ts + +../src/files/queries.ts + + + +../src/files/services/gitlab-files.service.ts->../src/files/queries.ts + + + + + +../src/files/services/local-files.service.ts->../src/files/interfaces/files.service.interface.ts + + + + + +../src/files/services/local-files.service.ts->../src/types.ts + + + + + +../src/files/interfaces/files.service.interface.ts->../src/types.ts + + + + + +e2e/app.e2e.spec.ts + +e2e/app.e2e.spec.ts + + + +e2e/app.e2e.spec.ts->../src/app.module.ts + + + + + +testUtil.ts + +testUtil.ts + + + +e2e/app.e2e.spec.ts->testUtil.ts + + + + + +integration/files.service.integration.spec.ts + +integration/files.service.integration.spec.ts + + + +integration/files.service.integration.spec.ts->../src/files/resolvers/files.resolver.ts + + + + + +integration/files.service.integration.spec.ts->../src/files/services/files-service.factory.ts + + + + + +integration/files.service.integration.spec.ts->../src/files/services/gitlab-files.service.ts + + + + + +integration/files.service.integration.spec.ts->../src/files/services/local-files.service.ts + + + + + +integration/files.service.integration.spec.ts->testUtil.ts + + + + + +unit/files-service.factory.unit.spec.ts + +unit/files-service.factory.unit.spec.ts + + + +unit/files-service.factory.unit.spec.ts->../src/files/services/files-service.factory.ts + + + + + +unit/files-service.factory.unit.spec.ts->../src/files/services/gitlab-files.service.ts + + + + + +unit/files-service.factory.unit.spec.ts->../src/files/services/local-files.service.ts + + + + + +unit/files-service.factory.unit.spec.ts->../src/files/interfaces/files.service.interface.ts + + + + + +unit/files.resolver.unit.spec.ts + +unit/files.resolver.unit.spec.ts + + + +unit/files.resolver.unit.spec.ts->../src/files/resolvers/files.resolver.ts + + + + + +unit/files.resolver.unit.spec.ts->../src/files/services/files-service.factory.ts + + + + + +unit/files.resolver.unit.spec.ts->../src/files/interfaces/files.service.interface.ts + + + + + +unit/files.resolver.unit.spec.ts->testUtil.ts + + + + + +unit/gitlab-files.service.unit.spec.ts + +unit/gitlab-files.service.unit.spec.ts + + + +unit/gitlab-files.service.unit.spec.ts->../src/files/services/gitlab-files.service.ts + + + + + +unit/gitlab-files.service.unit.spec.ts->testUtil.ts + + + + + +unit/local-files.service.unit.spec.ts + +unit/local-files.service.unit.spec.ts + + + +unit/local-files.service.unit.spec.ts->../src/files/services/local-files.service.ts + + + + + +unit/local-files.service.unit.spec.ts->testUtil.ts + + + + + diff --git a/docs/user/digital-twins/lifecycle.md b/docs/user/digital-twins/lifecycle.md index 5373131c8..0bf0e8d98 100644 --- a/docs/user/digital-twins/lifecycle.md +++ b/docs/user/digital-twins/lifecycle.md @@ -1,10 +1,25 @@ # :recycle: Digital Twin Lifecycle +The physical products in the real world have product lifecycle. +A simplified four-stage product life is illustrated here. + +A digital twin tracking the physical products (twins) need +to track and evolve in conjunction with the corresponding +physical twin. + +The possible activities undertaken in each lifecycle phases +are illustrated in the figure. + ![DT-PT Lifecycle](lifecycle-four-stages.png) ## Lifecycle Phases -A DT lifecycle consists of **explore, create, execute, save, analyse, evolve** and **terminate** phases. +The four phase lifecycle has been extended to a lifecycle with +eight phases. The new phase names and the typical activities +undertaken in each phase are outlined in this section. + + A DT lifecycle consists of **explore, create, execute, save, analyse, evolve** + and **terminate** phases. | Phase | Main Activities | |:----|:----| @@ -16,17 +31,28 @@ A DT lifecycle consists of **explore, create, execute, save, analyse, evolve** a | **save** | involves saving the state of DT to enable future recovery. | | **terminate** | stop the execution of DT. | -A complete digital twin will support all the phases but it is not mandatory. +A digital twin faithfully tracking the physical twin lifecycle will have to +support all the phases. It is also possible for digital twin engineers to add +more phases to digital they are developing. Thus it is important for +the DTaaS software platform needs to accommodate needs of different DTs. + +A potential linear representation of the tasks undertaken in +a digital twin lifecycle are shown here. ![Digital Twin Lifecycle](lifecycle.png) -It is possible to map the lifecycle phases identified so far with the **Build-Use-Share** approach +Again this is only a one possible pathway. Users are at liberty to +alter the sequence of steps. + +It is possible to map the lifecycle phases identified so far with +the **Build-Use-Share** approach of the DTaaS software platform. ![DT Lifecycle and Build-Use-Share](build-use-share.png) -Even though not mandatory, having a coding structure makes it easy to -manage DT lifecycle phases. It is recommended to have the following structure +Even though not mandatory, having a matching coding structure makes it easy to +for users to create and manage their DTs within the DTaaS. +It is recommended to have the following structure: ```text workspace/ @@ -41,11 +67,14 @@ workspace/ terminate ``` -A dedicated program exists for each phase of DT lifecycle. Each program can be as simple as a script that launches other programs or sends messages to a live digital twin. +A dedicated program exists for each phase of DT lifecycle. Each program +can be as simple as a script that launches other programs or sends messages +to a live digital twin. ## Examples -Here are the programs / scripts to manage three phases in the lifecycle of **mass-spring-damper DT**. +Here are the programs / scripts to manage three phases in +the lifecycle of **mass-spring-damper DT**. ```bash title="lifecycle/execute" #!/bin/bash @@ -57,16 +86,21 @@ java -jar /workspace/common/tools/maestro-2.3.0-jar-with-dependencies.jar \ output-dir>debug.log 2>&1 ``` -The execute phases uses the DT configuration, FMU models and Maestro tool to execute the digital twin. The script also stores the output of cosimulation in `/workspace/data/mass-spring-damper/output`. +The execute phases uses the DT configuration, FMU models and Maestro tool +to execute the digital twin. The script also stores the output of +cosimulation in `/workspace/data/mass-spring-damper/output`. -It is possible for a DT not to support a specific lifecycle phase. This intention can be specified with an empty script and a helpful message if deemed necessary. +It is possible for a DT not to support a specific lifecycle phase. +This intention can be specified with an empty script and a helpful message +if deemed necessary. ```bash title="lifecycle/analyze" #!/bin/bash printf "operation is not supported on this digital twin" ``` -The lifecycle programs can call other programs in the code base. In the case of `lifecycle/terminate` program, it is calling another script to do the necessary job. +The lifecycle programs can call other programs in the code base. In the case of +`lifecycle/terminate` program, it is calling another script to do the necessary job. ```bash title="lifecycle/terminate" #!/bin/bash diff --git a/servers/execution/runner/.madgerc b/servers/execution/runner/.madgerc new file mode 100644 index 000000000..4425cb8ef --- /dev/null +++ b/servers/execution/runner/.madgerc @@ -0,0 +1,18 @@ +{ + "fontSize": "10px", + "tsconfig": "tsconfig.json", + "fileExtensions": ["ts", "tsx", "js", "jsx"], + "backgroundColor": "#FFFFFF", + "textColor": "#FFFFFF", + "nodeColor": "black", + "noDependencyColor": "green", + "cyclicNodeColor": "red", + "edgeColor": "green", + "graphVizOptions": { + "G": { + "rankdir": "TB", + "layout": "neato", + "splines": "curved" + } + } +} \ No newline at end of file diff --git a/servers/execution/runner/README.md b/servers/execution/runner/README.md index 723b2119f..4be89aa9e 100644 --- a/servers/execution/runner/README.md +++ b/servers/execution/runner/README.md @@ -20,6 +20,7 @@ One digital twin runner is responsible for execution of a digital twin. ```bash yarn install # Install dependencies for the microservice yarn syntax # analyzes source code for potential errors, style violations, and other issues, +yarn graph # generate dependency graphs in the code yarn build # compile ES6 files into ES5 javascript files and copy all JS files into build/ directory yarn test # run tests yarn test:nocov # run the tests but do not report coverage diff --git a/servers/execution/runner/script/graph.bash b/servers/execution/runner/script/graph.bash index af6695dc1..57f177c8e 100755 --- a/servers/execution/runner/script/graph.bash +++ b/servers/execution/runner/script/graph.bash @@ -1,6 +1,7 @@ #!/bin/bash PATH="$(yarn bin):$PATH" export PATH -printf "Generate graph for source code" -madge --image src.svg --ts-config tsconfig.json --extensions ts,tsx src -madge --image test.svg --ts-config tsconfig.json --extensions ts,tsx test \ No newline at end of file +printf "Generate dependency graph for code" + +madge --image src.svg src +madge --image test.svg test diff --git a/servers/lib/.madgerc b/servers/lib/.madgerc new file mode 100644 index 000000000..4425cb8ef --- /dev/null +++ b/servers/lib/.madgerc @@ -0,0 +1,18 @@ +{ + "fontSize": "10px", + "tsconfig": "tsconfig.json", + "fileExtensions": ["ts", "tsx", "js", "jsx"], + "backgroundColor": "#FFFFFF", + "textColor": "#FFFFFF", + "nodeColor": "black", + "noDependencyColor": "green", + "cyclicNodeColor": "red", + "edgeColor": "green", + "graphVizOptions": { + "G": { + "rankdir": "TB", + "layout": "neato", + "splines": "curved" + } + } +} \ No newline at end of file diff --git a/servers/lib/README.md b/servers/lib/README.md index e9ba81fdd..5080e8b94 100644 --- a/servers/lib/README.md +++ b/servers/lib/README.md @@ -68,6 +68,7 @@ nohup yarn start & disown ```bash yarn install # Install dependencies for the microservice yarn syntax # analyzes source code for potential errors, style violations, and other issues, +yarn graph # generate dependency graphs in the code yarn build # compile ES6 files into ES5 javascript files and copy all JS files into build/ directory yarn test -a # run all tests yarn test -e # run end-to-end tests diff --git a/servers/lib/script/graph.bash b/servers/lib/script/graph.bash index af6695dc1..4546da092 100755 --- a/servers/lib/script/graph.bash +++ b/servers/lib/script/graph.bash @@ -1,6 +1,7 @@ #!/bin/bash PATH="$(yarn bin):$PATH" export PATH -printf "Generate graph for source code" -madge --image src.svg --ts-config tsconfig.json --extensions ts,tsx src -madge --image test.svg --ts-config tsconfig.json --extensions ts,tsx test \ No newline at end of file +printf "Generate dependency graph for code" + +madge --image src.svg src +madge --image test.svg test \ No newline at end of file