Commit c2a89010 authored by Jiahang Chen's avatar Jiahang Chen
Browse files

DEL: unused thins

parent fcf0aa04
Pipeline #350081 passed with stage
in 18 seconds
......@@ -224,5 +224,12 @@ config.py
# venv
venv/*
# log info
logs/*
config.py
\ No newline at end of file
# config
config.py
# pylinc
.pylintrc
setup.cfg
\ 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"
}
]
},
{
"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": "fc86fe53-1fb5-4cb7-96d2-c05c7e548d69",
"thingId": "s3i:c5d5cd58-8786-40b2-8079-5f2de443de36",
"policyId": "s3i:c5d5cd58-8786-40b2-8079-5f2de443de36",
"type": "JohnDeere",
"functionalities": [
{
"type": "AcceptsFellingJobs",
"proxy": "Harvests"
},
{
"type": "Harvests",
"receiver": "s3i:3154edfa-5b04-4a28-b803-d6ec46135c19",
"proxy": "ManageJobs"
},
{
"type": "ManageJobs",
"proxy" : "Forwards"
}
],
"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": "9d34802b-3a2f-4558-8c63-f1af09a68c2d",
"thingId": "s3i:5e83b933-331f-4278-b318-b7fdcb0e4872",
"policyId": "s3i:5e83b933-331f-4278-b318-b7fdcb0e4872",
"type": "Ponsse",
"functionalities": [
{
"type": "AcceptsFellingJobs",
"proxy": "Harvests"
},
{
"type": "Harvests",
"receiver": "s3i:3154edfa-5b04-4a28-b803-d6ec46135c19",
"proxy": "ManageJobs"
},
{
"type": "ManageJobs",
"proxy": "Forwards"
}
],
"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:..."
]
}
]
}
}
{"thingId": "s3i:b4f72a11-fb3d-47a3-b499-e7a88eaa5fe1", "policyId": "s3i:b4f72a11-fb3d-47a3-b499-e7a88eaa5fe1", "attributes": {"class": "ml40::Thing", "name": "my HMI", "roles": [{"class": "ml40::HMI"}], "features": []}}
\ No newline at end of file
{"thingId": "s3i:b6d1cc6d-896c-40fe-9403-b5b7682b1d03", "policyId": "s3i:b6d1cc6d-896c-40fe-9403-b5b7682b1d03", "attributes": {"class": "ml40::Thing", "name": "my_dt_harvester", "roles": [{"class": "fml40::Harvester"}], "features": [{"class": "fml40::ProvidesProductionData"}, {"class": "fml40::AcceptsFellingJobs"}, {"class": "ml40::Composite", "targets": [{"class": "ml40::Thing", "name": "my_engine", "roles": [{"class": "ml40::Engine"}], "features": [{"class": "ml40::RotationalSpeed", "rpm": 2001}]}, {"class": "ml40::Thing", "name": "my_bord_computer", "roles": [{"class": "ml40::MachineUI"}], "features": []}]}]}}
\ No newline at end of file
import sys
sys.path.append("./../")
"""Example implementation of a Komatsu forwarder."""
from fml40.machines.forwarder import Forwarder
class Komatsu(Forwarder):
"""Example implementation of a Komatsu forwarder."""
def __init__(self, idp, config):
"""Constructs the Komatsu forwarder.
:param idp: IdentityProvider object used to ask for an access token.
:param config: A json-object describing the forwarder.
"""
super().__init__(idp, config)
"""Example implentation of a JohnDeere harvester."""
from s3i import TokenType
from fml40.machines.harvester import Harvester
from fml40.app_logger import APP_LOGGER
from fml40.tools import send_request
# TODO: What information may the job argument contain?
class JohnDeere(Harvester):
"""Example implentation of a JohnDeere harvester."""
def __init__(self, idp, config):
super().__init__(idp, config)
APP_LOGGER.info(
"Hello I'm the John Deere Harvester of "
"the FBZ. I can harvest if you send me a "
"felling job."
)
def send_forwarding_job(self, receiver_id, job):
"""Sends a fml40::Forwardingjob message to receiver_id.
:param sender_id:
:param receiver_id: s3i formatted id of the receiver.
:param job:
"""
APP_LOGGER.info("Sending forwarding job.")
receiver_ids = [receiver_id]
access_token = self.idp.get_token(TokenType.ACCESS_TOKEN)
send_request(
access_token,
self.config["thingId"],
receiver_ids,
"fml40::ForwardingJob",
parameters=job,
)
"""Example implentation of a Ponsse harvester."""
from s3i import TokenType
from fml40.machines.harvester import Harvester
from fml40.tools import send_request
from fml40.app_logger import APP_LOGGER
class Ponsse(Harvester):
"""Example implentation of a Ponsse harvester."""
def __init__(self, idp, config):
super().__init__(idp, config)
def send_forwarding_job(self, receiver_id, job):
"""Send a fml40::Forwardingjob message to receiver_id.
:param sender_id:
:param receiver_id: s3i formatted id of the receiver.
:param job:
"""
APP_LOGGER.info("Sending forwarding job.")
receiver_ids = [receiver_id]
access_token = self.idp.get_token(TokenType.ACCESS_TOKEN)
send_request(
access_token,
self.config["thingId"],
receiver_ids,
"fml40::ForwardingJob",
parameters=job,
)
"""Implementation of the digital twin mini tractor driver"""
import json
from s3i import TokenType
from ml.app_logger import APP_LOGGER
from ml.tools import send_request
from ml.tools import decode_message
from ml.tools import verify_message
from ml.thing import Thing
class MiniTractorDriver(Thing):
def __init__(self, idp, config):
APP_LOGGER.info("Hello I'm the mini tractor driver.")
super().__init__(idp, config)
def on_receive(self, msg):
body_str = decode_message(msg)
body_json = json.loads(body_str)
APP_LOGGER.debug(f"Received message: {body_str}")
if verify_message(body_json, "serviceRequest", "fml40::FellingJob"):
job = body_json.get("parameters", {})
func = self.proxy_functionalities["AcceptsFellingJobs"]
func.acceptJob(job)
else:
APP_LOGGER.warning("Not handling message")
def send_fellling_job(self, receiver_id, job):
receiver_ids = [receiver_id]
access_token = self.idp.get_token(TokenType.ACCESS_TOKEN)
send_request(
access_token,
self.config["thingId"],
receiver_ids,
"fml40::FellingJob",
parameters=job,
)
APP_LOGGER.info("FellingJob send")
......@@ -60,7 +60,7 @@
dt = create_dt_ref(model=dt_model, grant_type="client_credentials", secret=dt_secret,
is_broker_rest=True,
is_broker=True, is_repo=True)
is_broker=True, is_repo=False)
class AcceptsFellingJobsImpl(AcceptsFellingJobs):
......
......@@ -61,15 +61,16 @@
felling_job = build_feature(feature=feature_config_json)
serv_req.fillServiceRequest(
senderUUID=hmi_id, receiverUUID=[receiver], sender_endpoint=hmi_endpoint,
serviceType="fml40::AcceptsFellingJobs/removeJob",
#serviceType="fml40::AcceptsFellingJobs/acceptJob",
parameters={"identifier": "s3i:d09214a7-46bb-4672-b4e0-2c0aa0e395a3"},
#parameters={"job": felling_job.to_json()},
#serviceType="fml40::AcceptsFellingJobs/removeJob",
serviceType="fml40::AcceptsFellingJobs/acceptJob",
#parameters={"identifier": "s3i:d09214a7-46bb-4672-b4e0-2c0aa0e395a3"},
parameters={"job": felling_job.to_json()},
msgUUID="s3i:{}".format(uuid.uuid4())
)
getv_req = s3i.GetValueRequest()
rpm_path = "attributes/features/ml40::Composite/targets/ml40::Engine/features/ml40::RotationalSpeed/rpm"
#rpm_path = "attributes/name"
#rpm_path = ""
getv_req.fillGetValueRequest(
senderUUID=hmi_id, receiverUUID=[receiver], sender_endpoint=hmi_endpoint,
......
import logging
import os
APP_LOGGER = logging.getLogger("app_logger")
def setup_logger(dt_name):
"""Creates logger named app_logger.
Logs are printed to stdout and saved to log files under '/logs'.
Each file is names 'dt_name'.log.
:param dt_name: Name of the digital twin.
:returns: Created logger
:rtype: Logger
"""
if not os.path.exists("logs"):
os.mkdir("logs")
app_logger = logging.getLogger('app_logger')
app_logger.setLevel(logging.DEBUG)
log_formatter = logging.Formatter(
"%(asctime)s - %(levelname)s - {}: %(message)s".format(dt_name)
)
stream_handler = logging.StreamHandler()
stream_handler.setFormatter(log_formatter)
stream_handler.setLevel(logging.DEBUG)
file_handler = logging.FileHandler(filename="./logs/{}.log".format(dt_name))
file_handler.setLevel(logging.DEBUG)
file_handler.setFormatter(log_formatter)
app_logger.addHandler(file_handler)
app_logger.addHandler(stream_handler)
return app_logger
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