Files
core/nodes/vork_node_wait.py
2025-09-26 14:59:59 +05:00

73 lines
2.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from typing import Dict, Any
from core import VorkNode
from core.form_descriptors import get_form_descriptor
from model_nodes.node_wait_models import (
WaitNodeData,
WaitNodeLinks,
WaitNodeCoreSchema,
WaitNodeCoreSchemaData
)
class VorkNodeWait(VorkNode):
def __init__(self, data: Dict[str, Any], links: Dict[str, Any] = None):
"""
Инициализация узла wait
"""
super().__init__(data, links or {})
@property
def id(self) -> str:
return "WAIT"
@classmethod
def form(cls) -> Dict[str, Any]:
"""
Возвращает статический дескриптор формы для узла Wait
"""
return get_form_descriptor("WAIT")
def validate(self) -> WaitNodeCoreSchema:
"""
Валидирует данные узла wait и возвращает схему
"""
try:
# Валидируем данные узла
validated_data = self.validate_data()
# Валидируем связи узла
validated_links = self.validate_links()
# Создаем данные портов
node_data = WaitNodeCoreSchemaData(
then_port_number=0,
)
# Создаем схему с валидированными данными
return WaitNodeCoreSchema(
ps_id=validated_data.ps_id,
node_type=validated_data.node_type,
parent_id=validated_links.parent_id,
parent_port_number=validated_links.parent_port_number,
data=node_data
)
except Exception as e:
print(f"Wait node validation error: {e}")
raise
def validate_data(self) -> WaitNodeData:
"""
Валидирует данные узла wait
"""
return WaitNodeData(**self.data)
def validate_links(self) -> WaitNodeLinks:
"""
Валидирует связи узла wait
"""
return WaitNodeLinks(**self.links)
def process(self, context):
pass