WAGO Python WAGO PLC Library

module tasks

Task management.

This module holds the classes responsible for task management.

  • Tasks: manage task and variable collection in an application script
  • Task: a single task
  • Scheduler: task scheduler

Global Variables

  • LOG_FILE
  • stop_time
  • stop_duration
  • task

function stop_handler

stop_handler(signum, frame)

function cont_handler

cont_handler(signum, frame)

class Task

Represent a PLC task.

  • cycle: one task cycle

method __init__

__init__(
    plc_obj,
    var_mapping: dict[str, Any],
    name: str,
    entry: Callable[, dict[str, str | int | bool]],
    cycle_ms: int = 100,
    priority: int = 15,
    watchdog_ms: int = 400000,
    sensitivity: int = 0
)

Configure the task.

Raise ValueError if priority or sensitivity are not within the allowed ranges. Raise NotDefinedError via _get_input_vars if there are undefined variables in the input parameters.

name: task name entry: task function cycle_ms: call cycle time in ms priority: a priority from 1 (highest) to 15 watchdog_ms: maximum runtime in ms before watchdog interrupts sensitivity: sensitivity from 0 (highest) to 10


method cycle

cycle() → None

Run one task cycle.


class Tasks

Manage task registration per program.

This class collects all variables, the task function and, if, given, its configuration. It can be instantiated in the main script.

method __init__

__init__()

method register

register(
    _func: Callable[, dict[str, str | int | bool]] = None,
    name: str = '',
    cycle_ms: int = 100,
    watchdog_ms: int = 400000,
    priority: int = 15,
    sensitivity: int = 0
)

Register a task. Only one is currently allowed.

name: task name cycle_ms: call cycle time in ms priority: a priority from 1 (highest) to 15 entry: task function watchdog_ms: maximum runtime in ms before watchdog interrupts sensitivity: sensitivity from 0 (highest) to 10


method setup

setup(func: Callable[[], dict[str, Any]]) → None

Retrieve variables from function in script.

func: a function that returns all variables as a dict


class Scheduler

A task scheduler.

  • run_tasks: run the collected tasks

method __init__

__init__(tasks: list[Task], plc_obj: Controller) → None

Configure the scheduler.

tasks: list of task objects to run plc_obj: the controller object


method run_tasks

run_tasks()

Scheduler to run all tasks in cycles.


This file was automatically generated via lazydocs.