IOMapper - billbreit/BitWiseApps GitHub Wiki

Under Construction

IOMapper is a generalization of external bind requests, hiding details that the main 'controller' application doesn't need to know, the gritty 'how to' mechanism of determining call structure and marshalling parameters.

Basic structures:

values VolatileDict source of all values, very dynamic. Can be defined and owned externally to iomapper.
iomap dict key/value 'action key' / Map Definition
read_keys list[str] action keys for read_cycle, to sync the values dict with state of external objects, can trigger a chain of actions
local_values dict key names / references to objects local to IOMapper
transforms dict transform values returned into values in the values dict

The Map Definition is a namedtuple structure for mapping requests to calls.

wrap item/attr getter or item/attr setter
target function name or parameter for item/attr setter
params list of key names for the values dict
vreturn key name of value to update in the values dict
chain list of action keys for function(s) in the iom dict, post-processing, mostly for sync of values in values dict.

IOMapper being driven by a controller.

IOMapper Overview

A more detailed view:

Note that there is an 'undefined' transitional state in the values dict, which can be in a mixed state reflecting both old and new values. Using action 'set_a' would require updating the value of a, which would be inconsistent until set_a is executed and the update chain synchronizes the dependent values.

IOMapper Detail

In an async world, there may need to be a locked state for the VolatileDict, or a locking 'bitint' for sets of individual value keys.


asyncio dir from MicroPython, implementing maybe one third of Python 3.9 methods:

>>> import asyncio as a
>>> dir(a)
[  '__class__', '__getattr__', '__name__', '__dict__', '__file__', '__path__', '__version__', '_attrs',  
   'CancelledError', 'Task', 'TaskQueue',    'Event', 'IOQueue', 'Lock', 'Loop', 'SingletonGenerator', 
   'StreamReader', 'StreamWriter', 'ThreadSafeFlag', 'TimeoutError',
   'run', 'select', 'sleep', 'sleep_ms', 'sys', 'ticks_add', 'ticks_diff',  'core', 'create_task', 'current_task',
   'event', 'gather', 'get_event_loop', 'new_event_loop', 'open_connection', 'run_until_complete', 'start_server',
   'stream', 'ticks', 'wait_for', 'wait_for_ms']
⚠️ **GitHub.com Fallback** ⚠️