mirror of
https://github.com/tiqi-group/pydase.git
synced 2025-06-13 00:07:11 +02:00
feat: adding support for enums
- handling fronend upates - adding serialization for DataService classes - adapting notification emission
This commit is contained in:
@ -3,6 +3,7 @@ import os
|
||||
import signal
|
||||
import threading
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
from enum import Enum
|
||||
from types import FrameType
|
||||
from typing import Any, Optional
|
||||
|
||||
@ -147,7 +148,11 @@ class Server:
|
||||
"data": {
|
||||
"parent_path": parent_path,
|
||||
"name": name,
|
||||
"value": value,
|
||||
"value": value.name
|
||||
if isinstance(
|
||||
value, Enum
|
||||
) # enums are not JSON serializable
|
||||
else value,
|
||||
}
|
||||
},
|
||||
)
|
||||
|
@ -1,3 +1,4 @@
|
||||
from enum import Enum
|
||||
from pathlib import Path
|
||||
from typing import Any, TypedDict
|
||||
|
||||
@ -55,6 +56,10 @@ class WebAPI:
|
||||
attr = getattr(self.service, data["name"])
|
||||
if isinstance(attr, DataService):
|
||||
attr.apply_updates(data["value"])
|
||||
elif isinstance(attr, Enum):
|
||||
setattr(
|
||||
self.service, data["name"], attr.__class__[data["value"]["value"]]
|
||||
)
|
||||
else:
|
||||
setattr(self.service, data["name"], data["value"])
|
||||
|
||||
|
Reference in New Issue
Block a user