Commit f91be628 authored by lenekaethe's avatar lenekaethe
Browse files

Initial commit

parents
**/__pycache__/
*.py[cod]
.vscode
*$py.class
\ No newline at end of file
from Ponsse_Harvester.harvesterMessageDistributer import HarvesterMessageDistributer
from Ponsse_Harvester.harvesterServices import HarvesterServices
from Ponsse_Harvester.harvesterSecretary import HarvesterSecretary
from harvesterServices import HarvesterServices
from harvesterSecretary import HarvesterSecretary
import json
import sys, os
PACKAGE_PARENT = '..'
SCRIPT_DIR = os.path.dirname(os.path.realpath(os.path.join(os.getcwd(), os.path.expanduser(__file__))))
sys.path.append(os.path.normpath(os.path.join(SCRIPT_DIR, PACKAGE_PARENT)))
from digitalTwin import MessageDistributer
class HarvesterMessageDistributer(MessageDistributer):
def __init__ (self, idp):
super().__init__(idp, HarvesterServices, HarvesterSecretary)
def on_receive(self, body):
"""This function is called when the Message Distributer gets something told. In this case, whenever the harvester receives a message.
"""
body_str = body.decode('utf8').replace("'", '"').replace(
"True", "true"). replace("False", "false") # convert bytes to str
body_json = json.loads(body_str)
print("Message received: ", body_json["messageType"], ":", body_json["serviceType"])
if body_json["messageType"] == "serviceRequest":
if body_json["serviceType"] == "fml40::FellingJob":
self.secretary_proxy.acceptsFellingJobs()
return "I'm the Message Distribution Actor and I distributed your message to one of my highly qualified actors"
\ No newline at end of file
import sys, os
PACKAGE_PARENT = '..'
SCRIPT_DIR = os.path.dirname(os.path.realpath(os.path.join(os.getcwd(), os.path.expanduser(__file__))))
sys.path.append(os.path.normpath(os.path.join(SCRIPT_DIR, PACKAGE_PARENT)))
from digitalTwin import Secretary, tools
class HarvesterSecretary(Secretary):
def __init__(self, idp, ref_dt):
super().__init__(idp, ref_dt)
def acceptsFellingJobs(self):
print("I took the felling job.")
# Condition to send the FellingJob to the harvesting unit
self.ref.harvesting()
def manageJobs(self):
#get the data that is relevant for forwarder
#find the right forwarder
komatsu_id = tools.dir_search_with_name(self.idp, "Komatsu Forwarder")
komatsu_endpoints = tools.dir_id_to_defualtEndpoints(self.idp, komatsu_id)
tools.service_request(self.idp, "johnDeere_harvester", "fml40::ForwardingJob", komatsu_endpoints)
print("I send the forwarding Job!")
import sys, os
PACKAGE_PARENT = '..'
SCRIPT_DIR = os.path.dirname(os.path.realpath(os.path.join(os.getcwd(), os.path.expanduser(__file__))))
sys.path.append(os.path.normpath(os.path.join(SCRIPT_DIR, PACKAGE_PARENT)))
from digitalTwin import Services
import uuid
class HarvesterServices(Services):
def __init__(self, idp):
super().__init__(idp)
def harvesting(self):
print("I am harvesting right now! So much fun!")
self.secretary.manageJobs()
\ No newline at end of file
from s3i import IdentityProvider, Directory, Broker, GetValueRequest, ServiceReply, ServiceRequest, TokenType
import uuid
import json
import jwt
import base64
import time
import datetime
import requests
import threading
import pykka
import sys, os
PACKAGE_PARENT = '..'
SCRIPT_DIR = os.path.dirname(os.path.realpath(os.path.join(os.getcwd(), os.path.expanduser(__file__))))
sys.path.append(os.path.normpath(os.path.join(SCRIPT_DIR, PACKAGE_PARENT)))
import config
import importlib
configData = importlib.import_module("config."+"johnDeere_harvester")
import digitalTwin
from Ponsse_Harvester import HarvesterMessageDistributer
print("Hello I'm the John Deere Harvester of the FBZ. I can harvest if you send me a felling job.")
def callback(ch, method, properties, body):
msgDis_ref.tell(body)
if __name__ == "__main__":
idp = IdentityProvider(grant_type='client_credentials', identity_provider_url="https://idp.s3i.vswf.dev/",
realm='KWH', client_id=configData.DATA["thingId"], client_secret=configData.CLIENT_SECRET)
access_token = idp.get_token(TokenType.ACCESS_TOKEN)
s3i_broker = Broker(
auth_form='Username/Password', username=" ", password=access_token, host="rabbitmq.s3i.vswf.dev")
msgDis_ref = HarvesterMessageDistributer.start(idp)
s3i_broker.receive("s3ibs://"+configData.DATA["thingId"], callback) #TODO get own Endpoint with Dir
\ No newline at end of file
from Komatsu_Forwarder.forwarderMessageDistributer import ForwarderMessageDistributer
from Komatsu_Forwarder.forwarderServices import ForwarderServices
from Komatsu_Forwarder.forwarderSecretary import ForwarderSecretary
from forwarderServices import ForwarderServices
from forwarderSecretary import ForwarderSecretary
import json
import sys, os
PACKAGE_PARENT = '..'
SCRIPT_DIR = os.path.dirname(os.path.realpath(os.path.join(os.getcwd(), os.path.expanduser(__file__))))
sys.path.append(os.path.normpath(os.path.join(SCRIPT_DIR, PACKAGE_PARENT)))
from digitalTwin import MessageDistributer
class ForwarderMessageDistributer(MessageDistributer):
def __init__ (self, idp):
super().__init__(idp, ForwarderServices, ForwarderSecretary)
def on_receive(self, body):
"""This function is called when the Message Distributer gets something told. In this case, whenever the harvester receives a message.
"""
body_str = body.decode('utf8').replace("'", '"').replace(
"True", "true"). replace("False", "false") # convert bytes to str
body_json = json.loads(body_str)
print("Message received: ", body_json["messageType"], ":", body_json["serviceType"])
if body_json["messageType"] == "serviceRequest":
if body_json["serviceType"] == "fml40::ForwardingJob":
self.secretary_proxy.acceptsForwardingJobs()
return "I'm the Message Distribution Actor and I distributed your message to one of my highly qualified actors"
\ No newline at end of file
import sys, os
PACKAGE_PARENT = '..'
SCRIPT_DIR = os.path.dirname(os.path.realpath(os.path.join(os.getcwd(), os.path.expanduser(__file__))))
sys.path.append(os.path.normpath(os.path.join(SCRIPT_DIR, PACKAGE_PARENT)))
from digitalTwin import Secretary, tools
class ForwarderSecretary(Secretary):
def __init__(self, idp, ref_dt):
super().__init__(idp, ref_dt)
def acceptsForwardingJobs(self):
print("I took the forwarding job.")
# Condition to send the FellingJob to the harvesting unit
self.ref.forwarding()
import sys, os
PACKAGE_PARENT = '..'
SCRIPT_DIR = os.path.dirname(os.path.realpath(os.path.join(os.getcwd(), os.path.expanduser(__file__))))
sys.path.append(os.path.normpath(os.path.join(SCRIPT_DIR, PACKAGE_PARENT)))
from digitalTwin import Services
import uuid
class ForwarderServices(Services):
def __init__(self, idp):
super().__init__(idp)
def forwarding(self):
print("I am forwarding right now! So much fun!")
\ No newline at end of file
from s3i import IdentityProvider, Directory, Broker, GetValueRequest, ServiceReply, ServiceRequest, TokenType
import uuid
import json
import jwt
import base64
import time
import datetime
import requests
import threading
import pykka
import sys, os
PACKAGE_PARENT = '..'
SCRIPT_DIR = os.path.dirname(os.path.realpath(os.path.join(os.getcwd(), os.path.expanduser(__file__))))
sys.path.append(os.path.normpath(os.path.join(SCRIPT_DIR, PACKAGE_PARENT)))
import config
import importlib
configData = importlib.import_module("config."+"komatsu_forwarder")
import digitalTwin
from Komatsu_Forwarder import ForwarderMessageDistributer
print("Hello I'm the Komatsu Forwarder. I can forward if you send me a forwarding job.")
def callback(ch, method, properties, body):
msgDis_ref.tell(body)
if __name__ == "__main__":
idp = IdentityProvider(grant_type='client_credentials', identity_provider_url="https://idp.s3i.vswf.dev/",
realm='KWH', client_id=configData.DATA["thingId"], client_secret=configData.CLIENT_SECRET)
access_token = idp.get_token(TokenType.ACCESS_TOKEN)
s3i_broker = Broker(
auth_form='Username/Password', username=" ", password=access_token, host="rabbitmq.s3i.vswf.dev")
msgDis_ref = ForwarderMessageDistributer.start(idp)
s3i_broker.receive("s3ibs://"+configData.DATA["thingId"], callback) #TODO get own Endpoint with Dir
\ No newline at end of file
from Ponsse_Harvester.harvesterMessageDistributer import HarvesterMessageDistributer
from Ponsse_Harvester.harvesterServices import HarvesterServices
from Ponsse_Harvester.harvesterSecretary import HarvesterSecretary
from harvesterServices import HarvesterServices
from harvesterSecretary import HarvesterSecretary
import json
import sys, os
PACKAGE_PARENT = '..'
SCRIPT_DIR = os.path.dirname(os.path.realpath(os.path.join(os.getcwd(), os.path.expanduser(__file__))))
sys.path.append(os.path.normpath(os.path.join(SCRIPT_DIR, PACKAGE_PARENT)))
from digitalTwin import MessageDistributer
class HarvesterMessageDistributer(MessageDistributer):
def __init__ (self, idp):
super().__init__(idp, HarvesterServices, HarvesterSecretary)
def on_receive(self, body):
"""This function is called when the Message Distributer gets something told. In this case, whenever the harvester receives a message.
"""
body_str = body.decode('utf8').replace("'", '"').replace(
"True", "true"). replace("False", "false") # convert bytes to str
body_json = json.loads(body_str)
print("Message received: ", body_json["messageType"], ":", body_json["serviceType"])
if body_json["messageType"] == "serviceRequest":
if body_json["serviceType"] == "fml40::FellingJob":
self.secretary_proxy.acceptsFellingJobs()
return "I'm the Message Distribution Actor and I distributed your message to one of my highly qualified actors"
\ No newline at end of file
import sys, os
PACKAGE_PARENT = '..'
SCRIPT_DIR = os.path.dirname(os.path.realpath(os.path.join(os.getcwd(), os.path.expanduser(__file__))))
sys.path.append(os.path.normpath(os.path.join(SCRIPT_DIR, PACKAGE_PARENT)))
from digitalTwin import Secretary, tools
class HarvesterSecretary(Secretary):
def __init__(self, idp, ref_dt):
super().__init__(idp, ref_dt)
def acceptsFellingJobs(self):
print("I took the felling job.")
# Condition to send the FellingJob to the harvesting unit
self.ref.harvesting()
def manageJobs(self):
#get the data that is relevant for forwarder
#find the right forwarder
komatsu_id = tools.dir_search_with_name(self.idp, "Komatsu Forwarder")
komatsu_endpoints = tools.dir_id_to_defualtEndpoints(self.idp, komatsu_id)
tools.service_request(self.idp, "ponsse_harvester", "fml40::ForwardingJob", komatsu_endpoints)
print("I send the forwarding Job!")
import sys, os
PACKAGE_PARENT = '..'
SCRIPT_DIR = os.path.dirname(os.path.realpath(os.path.join(os.getcwd(), os.path.expanduser(__file__))))
sys.path.append(os.path.normpath(os.path.join(SCRIPT_DIR, PACKAGE_PARENT)))
from digitalTwin import Services
import uuid
class HarvesterServices(Services):
def __init__(self, idp):
super().__init__(idp)
def harvesting(self):
print("I am harvesting right now! So much fun!")
self.secretary.manageJobs()
\ No newline at end of file
from s3i import IdentityProvider, Directory, Broker, GetValueRequest, ServiceReply, ServiceRequest, TokenType
import uuid
import json
import jwt
import base64
import time
import datetime
import requests
import threading
import pykka
import sys, os
PACKAGE_PARENT = '..'
SCRIPT_DIR = os.path.dirname(os.path.realpath(os.path.join(os.getcwd(), os.path.expanduser(__file__))))
sys.path.append(os.path.normpath(os.path.join(SCRIPT_DIR, PACKAGE_PARENT)))
import config
import importlib
configData = importlib.import_module("config."+"ponsse_harvester")
import digitalTwin
from Ponsse_Harvester import HarvesterMessageDistributer
print("Hello I'm the Ponsse Harvester. I can harvest if you send me a felling job.")
def callback(ch, method, properties, body):
msgDis_ref.tell(body)
if __name__ == "__main__":
idp = IdentityProvider(grant_type='client_credentials', identity_provider_url="https://idp.s3i.vswf.dev/",
realm='KWH', client_id=configData.DATA["thingId"], client_secret=configData.CLIENT_SECRET)
access_token = idp.get_token(TokenType.ACCESS_TOKEN)
s3i_broker = Broker(
auth_form='Username/Password', username=" ", password=access_token, host="rabbitmq.s3i.vswf.dev")
msgDis_ref = HarvesterMessageDistributer.start(idp)
s3i_broker.receive("s3ibs://"+configData.DATA["thingId"], callback) #TODO get own Endpoint with Dir
\ No newline at end of file
from os.path import dirname, basename, isfile, join
import glob
modules = glob.glob(join(dirname(__file__), "*.py"))
__all__ = [ basename(f)[:-3] for f in modules if isfile(f) and not f.endswith('__init__.py')]
#rom config.forwarder import *
import config
\ No newline at end of file
DATA = {
"thingId": "s3i:c5d5cd58-8786-40b2-8079-5f2de443de36",
"policyId": "s3i:c5d5cd58-8786-40b2-8079-5f2de443de36",
"attributes": {
"class": "ml40::Thing",
"name": "John Deere Harvester FBZ",
"roles": [{"class": "fml40::Harvester"}],
"features": [
{"class": "fml40::AcceptsProximityAlert"},
{"class": "fml40::AcceptsFellingJobs"},
{"class": "fml40::Harvests"},
{"class": "ml40::ManagesJobs"},
{"class": "fml40::ProvidesProductionData"},
{
"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"
}]
},
{
"class": "ml40::Thing",
"roles": ["ml40::Crane"],
"name": "Kran",
"identifier": "s3i:...",
"features": [{
"class": "ml40::Composite",
"targets": [{
"class": "ml40::Thing",
"roles": ["fml40::HarvestingHead"],
"name": "Harvesterkopf",
"identifier": "s3i:...",
"features": [{"class": "fml40::Grabs"}]
}]
}]
},
{
"class": "ml40::Thing",
"roles": ["ml40::MachineUI"],
"name": "Bordcomputer",
"identifier": "s3i:..."
}
]
}
]
}
}
CLIENT_SECRET = "fc86fe53-1fb5-4cb7-96d2-c05c7e548d69"
\ No newline at end of file
DATA = {
"thingId": "s3i:3154edfa-5b04-4a28-b803-d6ec46135c19",
"policyId": "s3i:3154edfa-5b04-4a28-b803-d6ec46135c19",
"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"
}]
},
{
"class": "ml40::Thing",
"roles": ["ml40::Crane"],
"name": "Kran",
"identifier": "s3i:...",
"features": [{
"class": "ml40::Composite",
"targets": [{
"class": "ml40::Thing",
"roles": ["fml40::ForwarderCrane"],
"name": "Forwarder Kran",
"identifier": "s3i:...",
"features": [{"class": "fml40::Grabs"}]
}]
}]
},
{
"class": "ml40::Thing",
"roles": ["ml40::MachineUI"],
"name": "Bordcomputer",
"identifier": "s3i:..."
}
]
}
]
}
}
CLIENT_SECRET = "432f0bfc-9a13-4551-a4cd-b94b054cdadf"
\ No newline at end of file
DATA = {
"thingId": "s3i:5e83b933-331f-4278-b318-b7fdcb0e4872",
"policyId": "s3i:5e83b933-331f-4278-b318-b7fdcb0e4872",
"attributes": {
"class": "ml40::Thing",
"name": "Ponsse Harvester",
"roles": [{"class": "fml40::Harvester"}],
"features": [
{"class": "fml40::AcceptsProximityAlert"},
{"class": "fml40::AcceptsFellingJobs"},
{"class": "fml40::Harvests"},
{"class": "ml40::ManagesJobs"},
{"class": "fml40::ProvidesProductionData"},
{
"class": "ml40::Location",
"longitude": 6.2492276,
"latitude": 50.808797
},
{
"class": "ml40::Shared",
"targets": ["s3i:..."]
}
]
}
}
CLIENT_SECRET = "9d34802b-3a2f-4558-8c63-f1af09a68c2d"
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment