Start changing to dict instead of string actions.

This commit is contained in:
Marek Wolan
2023-09-06 12:51:47 +01:00
parent 1dccceaf56
commit 4f89adb19a
3 changed files with 198 additions and 4 deletions

View File

@@ -1,7 +1,7 @@
# flake8: noqa
"""Core of the PrimAITE Simulator."""
from abc import ABC, abstractmethod
from typing import Callable, Dict, List, Optional, Union
from typing import Callable, ClassVar, Dict, List, Optional, Union
from uuid import uuid4
from pydantic import BaseModel, ConfigDict
@@ -42,7 +42,7 @@ class Action(BaseModel):
the action can be performed or not.
"""
func: Callable[[List[str], Dict], None]
func: Callable[[Dict], None]
"""
``func`` is a function that accepts a request and a context dict. Typically this would be a lambda function
that invokes a class method of your SimComponent. For example if the component is a node and the action is for
@@ -74,7 +74,7 @@ class ActionManager(BaseModel):
actions: Dict[str, Action] = {}
"""maps action verb to an action object."""
def __call__(self, request: List[str], context: Dict) -> None:
def __call__(self, request: Dict, context: Dict) -> None:
"""
Process an action request.