harvesterSecretary.py 966 Bytes
Newer Older
lenekaethe's avatar
lenekaethe committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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!")