Skip to main content

Scheduler for tasks generated from Lotlan files

Project description

LoTLan Scheduler

Unit-Tests

Scheduler for LoTLan tasks. Parses LoTLan files and accepts events defined in the files to schedule.

The repository for the LoTLan grammar can be found here

Task examples

You can find many LoTLan files / examples in the LoTLan Scheduler repository or in the official Documentation

Quickstart / Example

Here is an example how the scheduler can be used

import sys

from lotlan_scheduler.scheduler import LotlanScheduler
from lotlan_scheduler.api.event import Event

# gets called for each materialflow that is waiting for
# the triggeredBy condition to be satisfied
# event information contains info about the events in tb
def cb_triggered_by(mf_uuid, _uuid, event_information):
    print("cb_triggered_by from mf: " + str(mf_uuid))
    print("UUID: " + str(_uuid), "Event_Info: " + str(event_information))
    # foreach event in event_information

# gets called when triggeredBy condition is satisfied
# transport_orders contains the next transport orders which 
# can be executed
def cb_next_to(mf_uuid, transport_orders):
    print("cb_next_to from mf: " + str(mf_uuid))
    print(str(transport_orders))

# gets called for each materialflow that is waiting for
# the finishedBy condition to be satisfied
# event information contains info about the events in fb
def cb_finished_by(mf_uuid, _uuid, event_information):
    print("cb_finished_by from mf: " + str(mf_uuid))
    print("UUID: " + str(_uuid), "Event_Info: " + str(event_information))

# gets called if a task with the id _uuid has finished
def cb_task_finished(mf_uuid, _uuid):
    print("cb_task_finished from mf: " + str(mf_uuid))
    print("task with uuid " + str(_uuid) + " finished")

# gets called if every task is finished
# will never be called if the LoTLan file contains a cycle
def cb_all_finished(mf_uuid):
    print("cb_all_finished from mf: " + str(mf_uuid))


def main():
    test_flag = False
    lotlan_string = ""

    if len(sys.argv) >= 2:
        if sys.argv[1] == "--test":
            test_flag = True
            with open(sys.argv[2], 'r') as file:
                lotlan_string = file.read()
        else:
            with open(sys.argv[1], 'r') as file:
                lotlan_string = file.read()

        lotlan_logic = LotlanScheduler(lotlan_string, test_flag)
        material_flows = lotlan_logic.get_materialflows()

        for material_flow in material_flows:
            material_flow.register_callback_triggered_by(cb_triggered_by)
            material_flow.register_callback_next_to(cb_next_to)
            material_flow.register_callback_finished_by(cb_finished_by)
            material_flow.register_callback_task_finished(cb_task_finished)
            material_flow.register_callback_all_finished(cb_all_finished)
            material_flow.start()

        material_flow_running = True
        while (material_flow_running):
            _input = str(input("Wait for input:>"))
            mf_number = 0
            uid = 0
            input_name = "buttonPressed"
            input_value = "True"

            if _input != "":
                mf_number, uid, input_name, input_value = _input.split(" ")

            mf_number = int(mf_number)

            if mf_number < len(material_flows):
                material_flows[mf_number].fire_event(str(uid), Event(input_name, "", "bool", input_value == "True"))

            # check if a material flow is still running
            # if every material flow is finished we are done otherwise continue
            material_flow_running = False
            for mf in material_flows:
                if mf.is_running() is True:
                    material_flow_running = True

if __name__ == '__main__':
    main()

License

LoTLan Scheduler is licensed under the terms of the Apache license. See LICENCSE for more information.

Contributors

Peter Detzner, Maximilian Hoerstrup, Dominik Lux

Conference

P. Detzner, T. Kirks and J. Jost, "A Novel Task Language for Natural Interaction in Human-Robot Systems for Warehouse Logistics", 2019 14th International Conference on Computer Science & Education (ICCSE), Toronto, ON, Canada, 2019, pp. 725-730.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Lotlan_Scheduler-1.1.2.tar.gz (44.0 kB view details)

Uploaded Source

File details

Details for the file Lotlan_Scheduler-1.1.2.tar.gz.

File metadata

  • Download URL: Lotlan_Scheduler-1.1.2.tar.gz
  • Upload date:
  • Size: 44.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/50.3.1 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5

File hashes

Hashes for Lotlan_Scheduler-1.1.2.tar.gz
Algorithm Hash digest
SHA256 42d7534f97faa3f5fc929782f02c7d22bf598e07913fd82e7ff4ccabf66323f0
MD5 46529846e57c870dba8d06224a75508a
BLAKE2b-256 0e4053b6eed0e54b7864a59a5da51b7ece61ba6820e96db3c63f179ecc025b72

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page