Commit 1997a351 authored by Jiahang Chen's avatar Jiahang Chen
Browse files

Merge branch 'dev_chen' into 'master'

Dev chen

See merge request !4
parents 9a6e6366 d63592b5
Pipeline #358531 passed with stage
in 14 seconds
build
dist
*mypy_cache
**/__pycache__/
*.py[cod]
.vscode
......@@ -8,9 +11,225 @@ logs
.python-version
*.org
*.sh
/configs/
!/configs/config_forest.json
!/configs/config_forwarder_komatsu.json
!/configs/config_harvester_john_deere.json
!/configs/config_harvester_ponsse.json
scripts/credentials
\ No newline at end of file
credentials/*.json
credentials/*.txt
!./credentials/collection.txt.gpg
# Created by https://www.gitignore.io/api/python,pycharm+all
# Edit at https://www.gitignore.io/?templates=python,pycharm+all
### PyCharm+all ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
# Generated files
.idea/**/contentModel.xml
# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
# Gradle
.idea/**/gradle.xml
.idea/**/libraries
# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr
# CMake
cmake-build-*/
# Mongo Explorer plugin
.idea/**/mongoSettings.xml
# File-based project format
*.iws
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
# Editor-based Rest Client
.idea/httpRequests
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser
### PyCharm+all Patch ###
# Ignores the whole .idea folder and all .iml files
# See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360
.idea/
# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023
*.iml
modules.xml
.idea/misc.xml
*.ipr
# Sonarlint plugin
.idea/sonarlint
### Python ###
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/
# Translations
*.mo
*.pot
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# pyenv
.python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# celery beat schedule file
celerybeat-schedule
# SageMath parsed files
*.sage.py
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# Mr Developer
.mr.developer.cfg
.project
.pydevproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
# End of https://www.gitignore.io/api/python,pycharm+all
# don't commit actual config file
config.py
# venv
venv/*
# log info
logs/*
# config
config.py
# pylinc
.pylintrc
setup.cfg
\ No newline at end of file
......@@ -18,3 +18,4 @@ wheel:
- public
only:
- master
- dev_chen
[Master]
init-hook = 'import sys; sys.path.append("./"); sys.path.append("/home/r2d2m/.pyenv/versions/3.6.6/envs/fml40-venv-3.6.6/lib/python3.6/site-packages/")'
\ No newline at end of file
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.
\ No newline at end of file
fml40-reference-implementation
==============================
Reference implementation of the forest modelling language 4.0 (fml 4.0) which is explained in a KWH 4.0 white paper (not public yet).
To use the fml40 reference implementation package in your own project you can install it using the latest [wheel](https://git.rwth-aachen.de/kwh40/fml40-reference-implementation/-/jobs/artifacts/master/raw/public/fml40-0.1-py3-none-any.whl?job=wheel).
To install this wheel, go to the respective directory or switch to your designated virtual environment and install the .whl file, just run pip install https://git.rwth-aachen.de/kwh40/fml40-reference-implementation/-/jobs/artifacts/master/raw/public/fml40-0.1-py3-none-any.whl?job=wheel
Reference implementation of the forest modelling language 4.0 (fml 4.0) which is explained in a [KWH 4.0 white paper](https://www.kwh40.de/wp-content/uploads/2020/03/KWH40-Standpunkt-fml40-Version-1.0.pdf).
To use the fml40 reference implementation package in your own project you can install it using the latest [wheel](https://git.rwth-aachen.de/kwh40/fml40-reference-implementation/-/jobs/artifacts/master/raw/public/ml-0.1-py3-none-any.whl?job=wheel).
To install this wheel, go to the respective directory or switch to your designated virtual environment and install the .whl file, just run pip install https://git.rwth-aachen.de/kwh40/fml40-reference-implementation/-/jobs/artifacts/master/raw/public/ml-0.1-py3-none-any.whl?job=wheel
Features
--------
- launching digital twins in single shot or persistent mode via `fml40s.py`
- launching digital twins in persistent mode via `fml40s.py`
- extending the capabilities with user defined digital twins
Requirements
......@@ -19,65 +19,62 @@
Installation
------------
Run `pip install -m requirements`
Run `pip install -m requirements` in your virtual environment. To create a virtual environment run `mkvirtualenv <ENV_NAME>` and `workon <ENV_NAME>`
Usage
-----
A digital twin can be launched in persistent mode by executing
``` example
python fml40s.py launch <path to config file>
```
python fml40s.py launch <CONFIG_FILE>
```
all the config files must be located in the folder `configs`.
For more options call just run
If called with `--singleshot` option the digital twin receives all available messages, potentially sends some messages and shuts down afterwards.
For more options call
``` example
```
python fml40s.py -h
```
Extending with user defined classes
-----------------------------------
A new thing can be implemented by creating a python class which inherits from [ManagingActor](#managing-actor) or an existing [machine](#machines). In order to use the class, it has to be registered to `DT_FACTORY` within `fml40s.py`.
Config files
------------
A valid configuration consists of exactly one json object. Mandatory fields of the json object are
- client\_secret,
- thingId and
- type
- thingId
- policyId and
- attributes
MyDigitalTwin.json:
``` example
{
"client_secret": "secret",
"thingId": "s3i:id",
"type": "Komatsu",
"functionalities": [
{
"type": "AcceptsForwardingJobs",
"proxy": "Forwards"
}
}
```
Optionally a list named `functionalities` can be defined. The objects contained by this list specify the [functionalities](#functionalities) a thing has. Currently a list entry has the following structure:
"policyId": "s3i:id",
"attributes": {
"class": "ml40::Thing",
"name": "my digital twin",
"roles": [
{
"class": "fml40::Harvester"
}
],
"features": [
{
"class": "fml40::ProvidesProductionData"
},
{
"class": "ml40::Location",
"longitude": 5.03424,
"latitude": 52.52345
}
]
``` example
{
"type": "Harvests",
"receiver": "s3i:3154edfa-5b04-4a28-b803-d6ec46135c19",
"proxy": "ManageJobs"
}
}
```
In both cases `type` has to match the exact class name of the thing or functionality. The fields `proxy` and `receiver` are option. `proxy` can be used to specify a functionality that will be executed afterwards. If this functionality is going to send messages, the id of the receiving thing has to be declared in `receiver`.
Structure
---------
......@@ -86,26 +83,19 @@ ### Configs
This folder contains example configuration files in json format for some digital twins.
### Functionalities
This directory includes the implementations of the functionalities as described in the fml40 white paper.
### Machines
Contains base classes for machines. The base classes are implemented as *Managing Actors* since these actors always manage different functionalities, which are *Managed Actors*.
### ml
### Managed Actor
This directory includes the implementations of the fml40 python reference implementation as described in the fml40 white paper.
A managed actor is an actor with reference to the [pykka](https://www.pykka.org/en/latest/) implementation. To instantiate a managed actor, an associated *Managing Actor* is needed. The managed actor registers at this managing actor.
### Managing Actor
### demo
A managing actor has a dict *proxyFunctionalities* that lists all actors/functionalities the managing actor manages. The dict assigns the names of the managed actor to their proxy reference (see also [pykka proxies](https://www.pykka.org/en/latest/api/proxies/)). Also, the managing actor stops all its managed actors listed in its dict before it is stopped itself.
Example of creating and launching a harvester. Additionally, a hmi is created to communicate with the harvester using S³I-B protocol.
### Tools
### logs
Implements service functions that can be used. Currently, also S³I interface functions like *sending a service request* are implemented here. These kind of functions should be outsourced in an *interfaces* directory soon.
is composed of the logging files of the created digital twins.
### Customer code example
### tests
Example implementation of a JohnDeere harvester, Ponsse harvester and Komatsu forwader.
contains all test scripts (currently in development)
\ No newline at end of file
{
"client_secret": "d48971ab-2c22-47d5-a8dc-86079a2c4cb6",
"thingId": "s3i:a8b7da14-9e43-47f0-a876-cfd1ca38a9e1",
"policyID": "s3i:a8b7da14-9e43-47f0-a876-cfd1ca38a9e1",
"type": "Forest",
"attributes": {
"class": "ml40::Thing",
"name": "WZL-Demo Wald",
"roles": [
{
"class": "fml40::Forest"
}
],
"components": [
{
"class": "fml40::InventoryData",
"data": {
"class": "fml::AbstractInventory"
}
},
"s3i:...",
"s3i:..."
]
},
"requests": {
"msg_1": {
"msg_type": "fml40::FellingJob",
"receivers": [
"s3i:c5d5cd58-8786-40b2-8079-5f2de443de36",
"s3i:5e83b933-331f-4278-b318-b7fdcb0e4872"
]
}
}
}
{
"client_secret": "432f0bfc-9a13-4551-a4cd-b94b054cdadf",
"thingId": "s3i:3154edfa-5b04-4a28-b803-d6ec46135c19",
"policyId": "s3i:3154edfa-5b04-4a28-b803-d6ec46135c19",
"type": "Komatsu",
"functionalities": [
{
"type": "AcceptsForwardingJobs",
"proxy": "Forwards"
}
],
"attributes": {
"class": "ml40::Thing",
"name": "Komatsu Forwarder",
"roles": [
{
"class": "fml40::Forwarder"
}
],
"features": [
{
"class": "fml40::AcceptsProximityAlert"
},
{
"class": "fml40::AcceptsForwardingJobs"
},
{
"class": "fml40::Forwards"
},
{
"class": "ml40::Location",
"longitude": 6.2492276,
"latitude": 50.808797
},
{
"class": "ml40::Shared",
"targets": [
"s3i:..."
]
},
{
"class": "ml40::Composite",
"targets": [
{
"class": "ml40::Thing",
"roles": [
"ml40::Engine"
],
"name": "Motor",
"identifier": "s3i:...",
"features": [
{
"class": "ml40::RotationalSpeed",
"rpm": "3000"