Git Product home page Git Product logo

digitaltwinframework's Introduction

DigitalTwinFramework

Dependencies

This repository hosts the source code for DigitalTwinFramework,

1️⃣ The code is written in Python 3.9
2️⃣ All the Python dependencies are specified in the requirements.txt
3️⃣ The LIA OVGU development uses eclipse editor, accordingly eclipse related project files are provided in the repository.

Installing Dependencies

pip3 install -r requirements.txt

Configuration

The source code is associated with a .env file, all the configuration variables are specified in it.


LIA_AAS_RESTAPI_DOMAIN_INTERN=localhost
LIA_AAS_RESTAPI_DOMAIN_EXTERN=localhost
LIA_AAS_RESTAPI_PORT_EXTERN=60012
LIA_AAS_RESTAPI_PORT_INTERN=60012
LIA_AAS_MQTT_HOST=localhost
LIA_AAS_MQTT_PORT=1883
LIA_preferedI40EndPoint=MQTT
LIA_REGISTRYENDPOINT=http://liabroker.ddns.net:9021/i40commu
LIA_AAS_PACKAGE=AAS_LIA_Demonstrator.json
LIA_PUBSUB_LISTNER_HOST=localhost
LIA_PUBSUB_LISTNER_PORT=4051
LIA_SECURITY_ENABLED=Y
LIA_AUTHENTICATION_SERVER=22
LIA_PATH2SIGNINGKEY=identityserver.test.rsa.pem
LIA_PATH2AUTHCERT=identityserver.test.rsa.cer
LIA_NAMESPACE=ovgu.de

Running

  1. The base python program is organized inside the src/main subdirectory.
    python3.9 dtserver.py

AAS Registry Rest API Services

The table 2 provides list of rest services the DigitalTwinFramework provides, it also lists down the allowed operations for each of the service. The services are as per the guidelines of AAS Detail Part 2.

{aasIdentifier} = idShort or global unique identifier of AAS or global unique identifier of the aaset that the AAS is representing
{submodelIdentifier} = idShort or global unique identifier of Submodel

HTTP URI GET PUT DELETE POST
http://localhost:60012/shells ✔️ ✔️
http://localhost:60012/shells/{path:aasIdentifier} ✔️ ✔️ ✔️
http://localhost:60012/shells/{path:aasIdentifier}/aas ✔️ ✔️
http://localhost:60012/shells/{path:aasIdentifier}/aas/submodels ✔️ ✔️
http://localhost:60012/shells/{path:aasIdentifier}/aas/submodels/{path:submodelIdentifier} ✔️
http://localhost:60012/shells/{path:aasIdentifier}/aas/asset-information ✔️ ✔️
http://localhost:60012/shells/{path:aasIdentifier}/aas/submodels ✔️
http://localhost:60012/shells/{path:aasIdentifier}/aas/submodels/{path:submodelIdentifier}/submodel ✔️ ✔️
http://localhost:60012/shells/{path:aasIdentifier}/aas/submodels/{path:submodelIdentifier}/submodel/submodel-elements ✔️ ✔️
http://localhost:60012/shells/{path:aasIdentifier}/aas/submodels/{path:submodelIdentifier}/submodel/submodel-elements/{path:idShortPath} ✔️ ✔️ ✔️ ✔️
http://localhost:60012/shells/{path:aasIdentifier}/aas/submodels/{path:submodelIdentifier}/submodel/submodel-elements/{path:idShortPath}/attachment ✔️ ✔️
http://localhost:60012/submodels ✔️ ✔️
http://localhost:60012/submodels/{path:submodelIdentifier} ✔️ ✔️
http://localhost:60012/submodels/{path:submodelIdentifier}/submodel ✔️ ✔️
http://localhost:60012/submodels/{path:submodelIdentifier}/submodel/submodel-elements ✔️ ✔️
http://localhost:60012/submodels/{path:submodelIdentifier}/submodel/submodel-elements/{path:idShortPath} ✔️ ✔️ ✔️ ✔️
http://localhost:60012/submodels/{path:submodelIdentifier}/submodel/submodel-elements/{path:idShortPath}/attachment ✔️ ✔️
http://localhost:60012/concept-descriptions ✔️ ✔️
http://localhost:60012/concept-descriptions/{path:cdIdentifier} ✔️ ✔️ ✔️
http://localhost:60012/shells/{path:aasIdentifier}/aas/skills/{path:skillName}/skill ✔️

Back Ground

Actors.

In DigitalTwinFramework the concept skills represent the behavior of the type 3 AAS. These skills are modelled as Actors. The interactions between the Actors happens with exchange the [I4.0 Messages](https://github.com/harishpakala/I40_Language_Semantics)

Interaction Protocols represent structured sequence of messages exchanged between multiple partners / actors to achieve a specified goal (Example : Three-Way Handhake Protocol). An instance / execution of an interaction protocol is associated with a specific conversationID, all the messages wihtin the concersation have the same conversationID within I4.0 frame part. Each skilll in a Interaction Protocol is specific Role Name. There could be multiple skills with same Role Name.

The Python source-code created by the Actor machine creator contains a set of classes. Each Step represents a specific Step and the entire Actor is represensted by another class, that coordinates it's execution.

Each Actor is associated with a specific queue within in the DigitalTwinFramework framework.

Transitions between the Steps are expected due to one of the three event-types a) Inbound Message, b) Internal Trigger c) External Trigger.

Sample Step

class Hello(AStep):
    message_in =  ["Ping",]       
    
    def initialize(self):
        # Gaurd variables for enabling the transitions
        self.SendAck_Enabled = True 
            
    def actions(self) -> None:
        if (self.wait_untill_timeout(10)):
            message = self.receive(WaitforHi.message_in[0])
            self.save_in_message(message)
        
    def transitions(self) -> object:
        if (self.SendAck_Enabled):
            return "SendAck"

A Hello Step formatted as per DigitalTwinFramework and the Actor Machine creator.

  • The Hello Step inherits the class Abstract class Step source-code.
  • The static variable message_in represents the list of messages that the Actor is expected to receive in the specific Step.
  • This class provides a set of guard conditions reequired for transitions to the next Step. All the logic to the be executed within the Hello Step needs to be written in the actions() method.
  • The transitions() method should not be edited.
  • For every next Step a boolean guard variable will be provided in the constructor of the class, extracted from the JSON file. All the guard variables are defaulted to True.
  • The developer needs to disable gaurd variable (False) in the actions() method, for the Step that is not the next one.
  • The DigitalTwinFramework framework takes care and hide the complete mechanism behind the exchange of I4.0 messages between the skills.

Send and Receive Methods

receive(msg_in)

Returns the first message from the inbound queue of type msg_in, if there is no message the method returns None.


receive_all(msg_in)

Returns all the messages from the inbound queue of type msg_in, if there is no message the method returns an empty list.


I4.0 Message creation Method

create_i40_message(msg_out,conversationId,receiverId,receiverRole)

Creates an I4.0 message of type 'msg_out' with a specific 'conversationId'. The senderRole will the SKill that has called this method. The receiverRole is destination skill. The combination of receiverId and receiverRole is expected to be unique within the specific interaction. The senderId or the receiverId represents unique Id of the type3 AAS to which the SKill is attached.


Saving the I4.0 messages to the backend Methods

save_in_message(msg)

Copies the contents of an inbound I4.0 messsage to backend.


save_out_message(msg_in)

Copies the contents of an outbound I4.0 messsage to backend.


AASx Data Access Methods

GetSubmodelById(submodelId)

Returns the submodel of the specified submodelId. In case the submodel is not present or any internal error it returns error.


GetSubmodelELementByIdshoortPath(submodelId)

Returns the submodel-element of the specified submodelId and IdShortPath combination. In case the submodel-element is not present or any internal error it returns error.


save_submodel(submodel)

The replaces the existing submodel with the new submodel specified. Successful updation will return True, else returns False.


Predefined guard Methods

wait_untill_timeout(timer)

The Control waits untill a specific number of seconds as assigned to argument to the method.


wait_untill_message(message_count,msg_types)

The Control waits untill a specific number of messaages are arrived in the buffer of the message type specified as an argument msg_types (List of strings).


wait_untill_message_timeout(message_count,timer,msg_types)

The Control waits untill a specific number of messaages are arrived in the buffer of the message type specified as an argument msg_types (List of strings). However if the timer expires, the control returns.


Data access between Steps of a Actor

Every Actor is provided by tape by the DigitalTwinFramework framework. Each entry in the tape is key value pair.

push(key,value)

Push a data element 'value' to the tape with an associated 'key'.


retrieve(key)

Returns the value associated with the specific key.


flush()

Clears the tapes, removes all the key,value pairs. Usually it is done afer an iteration of the Actor.


Controller class of a AccessProvider Actor

class AccessProvider(Actor): ''' classdocs '''

def __init__(self):
    '''
    Constructor
    '''      
    Actor.__init__(self,"AccessProvider",
                   "www.admin-shell.io/interaction/3WayHandshake",
                   "Access Provision","Start")
                    

def start(self):
    self.run("Start")

Logs

The python project maintains a logger, all the important aspects regarding its functionality are captured with logger. The entire log information is stored into .LOG files under the src > main > logs folder.

Issues

If you want to request new features or report bug submit a new issue

License

Python AAS Registry is Licensed under Apache 2.0, the complete license text including the copy rights is included under License.txt

  • APScheduler,python-snap7,jsonschema,aiocoap,hbmqtt MIT License
  • Flask,werkzeug, Flask-RESTful, python-dotenv BSD-3-Clause
  • requests Apache License, Version 2.0
  • paho-mqtt Eclipse Public License 2.0 and the Eclipse Distribution License 1.0

digitaltwinframework's People

Contributors

harishpakala avatar hapakala avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.