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

update felling job

parent 1675d16b
Pipeline #339817 passed with stage
in 16 seconds
{"thingId": "s3i:feb857f1-3058-4ed4-8826-bbf182cbb16e", "policyId": "s3i:feb857f1-3058-4ed4-8826-bbf182cbb16e", "attributes": {"class": "ml40::Thing", "name": "dt test", "roles": [{"class": "fml40::Harvester"}], "features": [{"class": "fml40::ProvidesProductionData"}, {"class": "fml40::AcceptsFellingJobs"}]}}
\ No newline at end of file
{"thingId": "s3i:b4a0ec9b-66be-4390-b786-9c70b1c017e6", "policyId": "s3i:b4a0ec9b-66be-4390-b786-9c70b1c017e6", "attributes": {"class": "ml40::Thing", "name": "dt test", "roles": [{"class": "fml40::Harvester"}], "features": [{"class": "fml40::ProvidesProductionData"}, {"class": "fml40::AcceptsFellingJobs"}]}}
\ No newline at end of file
"thingId": "s3i:bea74f50-fa6c-4aba-b7f8-90153b401ffc",
"policyId": "s3i:bea74f50-fa6c-4aba-b7f8-90153b401ffc",
"attributes": {
"class": "ml40::Thing",
"name": "created DT Harvester for workshop",
"roles": [
"class": "fml40::Harvester"
"features": [
"class": "fml40::ProvidesProductionData"
"class": "fml40::AcceptsFellingJobs"
"class": "ml40::ManagesJobs"
\ 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"}]}}
\ No newline at end of file
<<<<<<< HEAD
{"thingId": "s3i:b6d1cc6d-896c-40fe-9403-b5b7682b1d03", "policyId": "s3i:b6d1cc6d-896c-40fe-9403-b5b7682b1d03", "attributes": {"class": "ml40::Thing", "name": "test", "roles": [{"class": "fml40::Harvester"}], "features": [{"class": "fml40::ProvidesProductionData"}, {"class": "fml40::AcceptsFellingJobs"}]}}
{"thingId": "s3i:af86ad33-63a4-427b-9914-3f199cd025c4", "policyId": "s3i:af86ad33-63a4-427b-9914-3f199cd025c4", "attributes": {"class": "ml40::Thing", "name": "test", "roles": [{"class": "fml40::Harvester"}], "features": [{"class": "fml40::ProvidesProductionData"}, {"class": "fml40::AcceptsFellingJobs"}]}}
>>>>>>> 0d577bac3a3ae43fd629d56880417b19316cd9c0
......@@ -49,7 +49,7 @@
dt_id = "s3i:b6d1cc6d-896c-40fe-9403-b5b7682b1d03"
dt_secret = "cd4d24d2-f702-4f51-b0cf-6b77a423b33a"
dt_name = "test"
dt_name = "my_dt_harvester"
config_file_name = make_config_file(dt_id=dt_id, name=dt_name, roles="fml40::Harvester",
features=["fml40::ProvidesProductionData", "fml40::AcceptsFellingJobs"])
......@@ -63,9 +63,8 @@
class AcceptsFellingJobsImpl(AcceptsFellingJobs):
def my_accept_job_func(self, job):"I am checking if the felling job can be accepted.")"Checking job with my impl function.")
return self.add_to_job_list(job)
dt_proxy.add_function_impl(AcceptsFellingJobsImpl, "AcceptsFellingJobs")
......@@ -34,8 +34,8 @@
senderUUID=hmi_id, receiverUUID=[receiver], sender_endpoint=hmi_endpoint,
parameters={"identifier": job_proxy.identifier.get()},
parameters={"job": job_proxy.to_json().get()},
......@@ -127,20 +127,23 @@ def build_sub_featrues(thing_ref, feature_proxy, json_feature):
def build(thing_ref, attributes):
thing_proxy = thing_ref.proxy()
roles = attributes.get("roles", [])
if not roles:
APP_LOGGER.critical("Roles: %s is missing" % roles)
APP_LOGGER.debug("Adding roles: %s" % roles)
thing_proxy.roles = roles
for role in roles:
role_name = role.get("class", "")
if not role:
APP_LOGGER.critical("Roles: %s is missing" % role_name)
APP_LOGGER.debug("Adding roles: %s" % role_name)
json_features = attributes.get("features", [])
for json_feature in json_features:
class_name = json_feature.get("class", "")
feature = DT_FACTORY.get(class_name, None)
feature_name = json_feature.get("class", "")
feature = DT_FACTORY.get(feature_name, None)
if not feature:
APP_LOGGER.critical("Feature: %s is missing" % class_name)
APP_LOGGER.critical("Feature: %s is missing" % feature_name)
APP_LOGGER.debug("Adding feature: %s" % class_name)
APP_LOGGER.debug("Adding feature: %s" % feature_name)
feature_ref = feature.start("", thing_ref)
feature_proxy = feature_ref.proxy()
......@@ -177,7 +180,7 @@ def create_dt_ref(model, grant_type, secret, username, password, is_broker_rest,
sys.exit("Incomplete model: roles missing!")
thing_name = attributes.get("name", "")
APP_LOGGER.debug("Creating ditigtal twin %s" % thing_name)
APP_LOGGER.debug("Creating ditigtal twin {} with id {}".format(thing_name, model.get("thingId", "")))
d_t = DT_FACTORY.get(thing_type, ManagingActor)
thing_ref = d_t.start(
from ml.ml40.features.functionalities.accepts_jobs import AcceptsJobs
from import JobStatus
from import FellingJob
from ml.app_logger import APP_LOGGER
......@@ -12,19 +13,27 @@ def __init__(self, name, ref_managing_actor):
def acceptJob(self, job: FellingJob) -> bool:"Checking if the felling job can be accepted.")
if job.get("id") is None or job.get("status") is None:
return False
return self.add_to_job_list(job)
def queryJobStatus(self, identifier):"Checking the job status of job {}".format(identifier))
for job in self.job_list:
if job.get("id") == identifier:"Job {} is now in status {}".format(identifier, job.get("status")))
return {"identifier": identifier, "status": job.get("status")}"Job {} can not be queried".format(identifier))
return {"identifier": identifier, "status": "NOT FOUND"}
def removeJob(self, identifier):"Checking if i can remove the job {}".format(identifier))
for job in self.job_list:
if job.get("id") == identifier:
self.job_list.remove(job)"Job {} removed".format(identifier))
return True"Job {} can not be found".format(identifier))
return False
def from_json(self, json_obj):
......@@ -32,8 +41,10 @@ def from_json(self, json_obj):
def add_to_job_list(self, job):
if job not in self.job_list:
job["status"] =
self.job_list.append(job)"Job accepted!")
return True
else:"This felling job has been already added in job list")"Job has been already accepted!")
return False
\ No newline at end of file
......@@ -83,6 +83,14 @@ def features(self):
def features(self, value):
self.__features = value
def roles(self):
return self.__roles
def roles(self, value):
self.__roles = value
def class_name(self):
return self.__class_name
......@@ -313,7 +321,7 @@ def on_service_request(self, body_json):
receiverUUID=body_json.get("sender", None),
serviceType=body_json.get("serviceType", None),
replyingToUUID=body_json.get("identifier", None),
Markdown is supported
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