Skip to content

Commit 6e4ba0c

Browse files
authored
wip (#323)
* wip * ui dev * a lot of ui dev * more features working * more development * remove redundant css rules * update bootstrap deps * more dev * a lot of new stuff * add markdown background gradients * attempt to set initial focus * minor border tweaks * auto focus channel filter when changing tab * focus channel table when toggling * auto focus tab filter on open * more focus scenarios * use browser's suggestion for 'passive' * more features * add title to checkbox * wip * sa fixes * comment * fixes for firefox * minor fixes * use new vcorelib def and fifo * fix minor issue for touch interface * remove source mapping lines * add websocket restarting * upgrades for markdown dir stuff * fix markdown page gradients * finish unit testing * sa
1 parent c7f80e7 commit 6e4ba0c

File tree

123 files changed

+1814
-486
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

123 files changed

+1814
-486
lines changed

.github/workflows/python-package.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ jobs:
7878
7979
- run: |
8080
mk python-release owner=libre-embedded \
81-
repo=runtimepy version=5.14.2
81+
repo=runtimepy version=5.15.0
8282
if: |
8383
matrix.python-version == '3.12'
8484
&& matrix.system == 'ubuntu-latest'

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
=====================================
33
generator=datazen
44
version=3.2.3
5-
hash=d3dcde1ba35cb14decfc6881b6a2d4e6
5+
hash=db8f45762873863c99d4d7d8f996d2fb
66
=====================================
77
-->
88

9-
# runtimepy ([5.14.2](https://pypi.org/project/runtimepy/))
9+
# runtimepy ([5.15.0](https://pypi.org/project/runtimepy/))
1010

1111
[![python](https://img.shields.io/pypi/pyversions/runtimepy.svg)](https://pypi.org/project/runtimepy/)
1212
![Build Status](https://github.com/libre-embedded/runtimepy/workflows/Python%20Package/badge.svg)

ifgen.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
includes:
3+
- config/python/ifgen/settings.yaml
4+
- config/python/ifgen/sample.yaml
5+
- package://ifgen/plugins/struct_receiver.yaml
6+
7+
cpp_dir: []
8+
python_dir: [tests]
9+
namespace: [tests]

local/configs/package.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ time_command: true
88

99
requirements:
1010
- aiofiles
11-
- vcorelib>=3.6.0
12-
- svgen>=0.7.12
11+
- vcorelib>=3.6.2
12+
- svgen>=0.8.0
1313
- websockets
1414
- psutil
1515
- "windows-curses; sys_platform == 'win32' and python_version < '3.12'"

local/variables/package.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
22
major: 5
3-
minor: 14
4-
patch: 2
3+
minor: 15
4+
patch: 0
55
entry: runtimepy

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta:__legacy__"
44

55
[project]
66
name = "runtimepy"
7-
version = "5.14.2"
7+
version = "5.15.0"
88
description = "A framework for implementing Python services."
99
readme = "README.md"
1010
requires-python = ">=3.12"

runtimepy/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# =====================================
22
# generator=datazen
33
# version=3.2.3
4-
# hash=f2469e97ed5a3a48c5347357f12c3554
4+
# hash=58f166da9bc0561c671ef04c334d585d
55
# =====================================
66

77
"""
@@ -10,7 +10,7 @@
1010

1111
DESCRIPTION = "A framework for implementing Python services."
1212
PKG_NAME = "runtimepy"
13-
VERSION = "5.14.2"
13+
VERSION = "5.15.0"
1414

1515
# runtimepy-specific content.
1616
METRICS_NAME = "metrics"

runtimepy/channel/__init__.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,7 @@
2929
from runtimepy.primitives.int import Uint64 as _Uint64
3030
from runtimepy.primitives.types import AnyPrimitiveType as _AnyPrimitiveType
3131
from runtimepy.registry.item import RegistryItem as _RegistryItem
32-
33-
Literal = int | float | bool
34-
Default = _Optional[Literal]
35-
Controls = dict[str, Literal | dict[str, Literal]]
32+
from runtimepy.ui.controls import Controls, Default
3633

3734

3835
class Channel(_RegistryItem, _EnumMixin, _Generic[_T]):

runtimepy/channel/environment/__init__.py

Lines changed: 93 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
"""
44

55
# built-in
6+
from contextlib import ExitStack as _ExitStack
67
from typing import Iterator as _Iterator
8+
from typing import Optional
9+
from typing import cast as _cast
710

811
# internal
9-
from runtimepy.channel import Default as _Default
1012
from runtimepy.channel.environment.array import (
1113
ArrayChannelEnvironment as _ArrayChannelEnvironment,
1214
)
@@ -19,6 +21,23 @@
1921
from runtimepy.channel.environment.telemetry import (
2022
TelemetryChannelEnvironment as _TelemetryChannelEnvironment,
2123
)
24+
from runtimepy.codec.protocol import Protocol as _Protocol
25+
from runtimepy.codec.protocol.base import FieldSpec as _FieldSpec
26+
from runtimepy.primitives import AnyPrimitive
27+
from runtimepy.ui.controls import Controls, Default, bit_slider
28+
29+
30+
def regular_channel_controls(
31+
primitive: AnyPrimitive, commandable: bool
32+
) -> Optional[Controls]:
33+
"""Get channel controls for a regular primitive."""
34+
35+
controls = None
36+
37+
if commandable and primitive.kind.is_integer and primitive.kind.bits <= 32:
38+
controls = bit_slider(primitive.kind.bits, primitive.kind.signed)
39+
40+
return controls
2241

2342

2443
class ChannelEnvironment(
@@ -29,13 +48,85 @@ class ChannelEnvironment(
2948
):
3049
"""A class integrating channel and enumeration registries."""
3150

51+
def register_protocol(
52+
self, protocol: _Protocol, commandable: bool
53+
) -> None:
54+
"""Register protocol elements as named channels and fields."""
55+
56+
# Register any new enumerations.
57+
self.enums.register_from_other(protocol.enum_registry)
58+
59+
# need to handle defaults
60+
61+
for item in protocol.build:
62+
# Handle regular primitive fields.
63+
if isinstance(item, _FieldSpec):
64+
if item.is_array():
65+
assert item.array_length is not None
66+
with self.names_pushed(item.name):
67+
for idx in range(item.array_length):
68+
primitive = protocol.get_primitive(
69+
item.name, index=idx
70+
)
71+
self.channel(
72+
str(idx),
73+
kind=primitive,
74+
commandable=commandable,
75+
enum=item.enum,
76+
controls=regular_channel_controls(
77+
primitive, commandable
78+
),
79+
)
80+
else:
81+
primitive = protocol.get_primitive(item.name)
82+
self.channel(
83+
item.name,
84+
kind=primitive,
85+
commandable=commandable,
86+
enum=item.enum,
87+
controls=regular_channel_controls(
88+
primitive, commandable
89+
),
90+
)
91+
92+
# Handle nested protocols.
93+
elif isinstance(item[0], str):
94+
name = item[0]
95+
candidates = protocol.serializables[name]
96+
if isinstance(candidates[0], _Protocol):
97+
with self.names_pushed(name):
98+
for idx, candidate in enumerate(candidates):
99+
with _ExitStack() as stack:
100+
# Enter array-index namespace if applicable.
101+
if len(candidates) > 1:
102+
stack.enter_context(
103+
self.names_pushed(str(idx))
104+
)
105+
106+
self.register_protocol(
107+
_cast(_Protocol, candidate), commandable
108+
)
109+
110+
# Handle bit fields.
111+
elif isinstance(item[0], int):
112+
fields = protocol.get_fields(item[0])
113+
for field in fields.fields.values():
114+
field.commandable = commandable
115+
# add sliders for non enum non bool (check enum fields too)
116+
self.add_fields(
117+
item[1],
118+
fields,
119+
commandable=commandable,
120+
controls=bit_slider(fields.raw.kind.bits, False),
121+
)
122+
32123
def search_names(
33124
self, pattern: str, exact: bool = False
34125
) -> _Iterator[str]:
35126
"""Search for names belonging to this environment."""
36127
yield from self.channels.names.search(pattern, exact=exact)
37128

38-
def set_default(self, key: str, default: _Default) -> None:
129+
def set_default(self, key: str, default: Default) -> None:
39130
"""Set a new default value for a channel."""
40131

41132
chan, _ = self[key]

0 commit comments

Comments
 (0)