optivgi.threads¶
Provides worker thread functions for running Opti-VGI tasks asynchronously.
These functions are designed to be run in separate threads, allowing the main application to remain responsive while handling periodic scheduling tasks or reacting to external events.
- optivgi.threads.timer_thread_worker(event_queue)¶
Worker function for a timer thread.
This function sleeps until the start of the next minute and then puts a “Timer Event” message onto the provided event queue. It runs in an infinite loop.
- Parameters:
event_queue (
Queue
) – The queue to which timer events will be added.
- optivgi.threads.scm_worker(event_queue, translation_cls, algorithm_cls)¶
Worker function for the main Smart Charging Management (SCM) logic.
This function continuously monitors an event queue. When an event is received, it instantiates the provided Translation and Algorithm classes and executes the main SCM logic using scm_runner. It handles potential exceptions during the process and ensures the event queue task is marked as done.
It operates within the context manager provided by the Translation.
- Parameters:
event_queue (
Queue
) – The queue from which events are retrieved. Processing stops if None is received.translation_cls (
Type
[Translation
]) – The class type of the Translation layer implementation to use. Must inherit from optivgi.translation.Translation.algorithm_cls (
Type
[Algorithm
]) – The class type of the SCM Algorithm implementation to use. Must inherit from optivgi.scm.algorithm.Algorithm.