2023-06-28 19:02:11 +02:00
|
|
|
from typing import Dict, Any, TYPE_CHECKING
|
|
|
|
|
|
|
|
from pyhon.parameter.program import HonParameterProgram
|
|
|
|
|
|
|
|
if TYPE_CHECKING:
|
|
|
|
from pyhon.appliance import HonAppliance
|
|
|
|
|
|
|
|
|
2023-05-29 18:58:50 +02:00
|
|
|
class ApplianceBase:
|
2023-06-28 19:02:11 +02:00
|
|
|
def __init__(self, appliance: "HonAppliance"):
|
2023-05-29 18:58:50 +02:00
|
|
|
self.parent = appliance
|
|
|
|
|
2023-06-28 19:02:11 +02:00
|
|
|
def attributes(self, data: Dict[str, Any]) -> Dict[str, Any]:
|
2023-05-29 18:58:50 +02:00
|
|
|
program_name = "No Program"
|
2023-06-13 00:12:29 +02:00
|
|
|
if program := int(str(data.get("parameters", {}).get("prCode", "0"))):
|
2023-06-08 19:50:56 +02:00
|
|
|
if start_cmd := self.parent.settings.get("startProgram.program"):
|
2023-06-28 19:02:11 +02:00
|
|
|
if isinstance(start_cmd, HonParameterProgram) and (
|
|
|
|
ids := start_cmd.ids
|
|
|
|
):
|
2023-06-08 19:50:56 +02:00
|
|
|
program_name = ids.get(program, program_name)
|
2023-05-29 18:58:50 +02:00
|
|
|
data["programName"] = program_name
|
2023-06-08 19:50:56 +02:00
|
|
|
return data
|
2023-05-29 18:58:50 +02:00
|
|
|
|
2023-06-28 19:02:11 +02:00
|
|
|
def settings(self, settings: Dict[str, Any]) -> Dict[str, Any]:
|
2023-05-29 18:58:50 +02:00
|
|
|
return settings
|