Skip to content

llucax/frequenz-dispatch-python

 
 

Repository files navigation

Dispatch Highlevel Interface

Build Status PyPI Package Docs

Introduction

A highlevel interface for the dispatch API. The interface is made of the dispatch actor which should run once per microgrid. It provides two channels for clients:

  • "new_dispatches" for newly created dispatches
  • "ready_dispatches" for dispatches that are ready to be executed

Example Usage

async def run():
    # dispatch helper sends out dispatches when they are due
    dispatch_arrived = dispatch_helper.new_dispatches().new_receiver()
    dispatch_ready = dispatch_helper.ready_dispatches().new_receiver()

    async for selected in select(dispatch_ready, dispatch_arrived):
        if selected_from(selected, dispatch_arrived):
            dispatch = selected.value
            match dispatch.type:
                case DISPATCH_TYPE_BATTERY_CHARGE:
                    battery_pool = microgrid.battery_pool(dispatch.battery_set, task_id)
                    battery_pool.set_charge(dispatch.power)
            ...
        if selected_from(selected, dispatch_ready):
            dispatch = selected.value
            log.info("New dispatch arrived %s", dispatch)

Supported Platforms

The following platforms are officially supported (tested):

  • Python: 3.11
  • Operating System: Ubuntu Linux 20.04
  • Architectures: amd64, arm64

Contributing

If you want to know how to build this project and contribute to it, please check out the Contributing Guide.

About

High-level interface to the services provided by the dispatch API

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%