125 lines
5.0 KiB
Python
125 lines
5.0 KiB
Python
# coding: utf-8
|
|
|
|
"""
|
|
Jungfraujoch
|
|
|
|
API to control Jungfraujoch developed by the Paul Scherrer Institute (Switzerland). Jungfraujoch is a data acquisition and analysis system for pixel array detectors, primarly PSI JUNGFRAU. Jungfraujoch uses FPGA boards to acquire data at high data rates.
|
|
|
|
The version of the OpenAPI document: 1.0.0-rc.17
|
|
Contact: filip.leonarski@psi.ch
|
|
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
|
|
Do not edit the class manually.
|
|
""" # noqa: E501
|
|
|
|
|
|
from __future__ import annotations
|
|
import pprint
|
|
import re # noqa: F401
|
|
import json
|
|
|
|
from pydantic import BaseModel, ConfigDict
|
|
from typing import Any, ClassVar, Dict, List, Optional
|
|
from jfjoch_client.models.broker_status import BrokerStatus
|
|
from jfjoch_client.models.calibration_statistics_inner import CalibrationStatisticsInner
|
|
from jfjoch_client.models.detector_status import DetectorStatus
|
|
from jfjoch_client.models.fpga_status_inner import FpgaStatusInner
|
|
from jfjoch_client.models.measurement_statistics import MeasurementStatistics
|
|
from typing import Optional, Set
|
|
from typing_extensions import Self
|
|
|
|
class JfjochStatistics(BaseModel):
|
|
"""
|
|
Pool statistics for Jungfraujoch to reduce transfers between frontend and jfjoch_broker
|
|
""" # noqa: E501
|
|
detector: Optional[DetectorStatus] = None
|
|
measurement: Optional[MeasurementStatistics] = None
|
|
broker: Optional[BrokerStatus] = None
|
|
fpga: Optional[List[FpgaStatusInner]] = None
|
|
calibration: Optional[List[CalibrationStatisticsInner]] = None
|
|
__properties: ClassVar[List[str]] = ["detector", "measurement", "broker", "fpga", "calibration"]
|
|
|
|
model_config = ConfigDict(
|
|
populate_by_name=True,
|
|
validate_assignment=True,
|
|
protected_namespaces=(),
|
|
)
|
|
|
|
|
|
def to_str(self) -> str:
|
|
"""Returns the string representation of the model using alias"""
|
|
return pprint.pformat(self.model_dump(by_alias=True))
|
|
|
|
def to_json(self) -> str:
|
|
"""Returns the JSON representation of the model using alias"""
|
|
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
|
|
return json.dumps(self.to_dict())
|
|
|
|
@classmethod
|
|
def from_json(cls, json_str: str) -> Optional[Self]:
|
|
"""Create an instance of JfjochStatistics from a JSON string"""
|
|
return cls.from_dict(json.loads(json_str))
|
|
|
|
def to_dict(self) -> Dict[str, Any]:
|
|
"""Return the dictionary representation of the model using alias.
|
|
|
|
This has the following differences from calling pydantic's
|
|
`self.model_dump(by_alias=True)`:
|
|
|
|
* `None` is only added to the output dict for nullable fields that
|
|
were set at model initialization. Other fields with value `None`
|
|
are ignored.
|
|
"""
|
|
excluded_fields: Set[str] = set([
|
|
])
|
|
|
|
_dict = self.model_dump(
|
|
by_alias=True,
|
|
exclude=excluded_fields,
|
|
exclude_none=True,
|
|
)
|
|
# override the default output from pydantic by calling `to_dict()` of detector
|
|
if self.detector:
|
|
_dict['detector'] = self.detector.to_dict()
|
|
# override the default output from pydantic by calling `to_dict()` of measurement
|
|
if self.measurement:
|
|
_dict['measurement'] = self.measurement.to_dict()
|
|
# override the default output from pydantic by calling `to_dict()` of broker
|
|
if self.broker:
|
|
_dict['broker'] = self.broker.to_dict()
|
|
# override the default output from pydantic by calling `to_dict()` of each item in fpga (list)
|
|
_items = []
|
|
if self.fpga:
|
|
for _item_fpga in self.fpga:
|
|
if _item_fpga:
|
|
_items.append(_item_fpga.to_dict())
|
|
_dict['fpga'] = _items
|
|
# override the default output from pydantic by calling `to_dict()` of each item in calibration (list)
|
|
_items = []
|
|
if self.calibration:
|
|
for _item_calibration in self.calibration:
|
|
if _item_calibration:
|
|
_items.append(_item_calibration.to_dict())
|
|
_dict['calibration'] = _items
|
|
return _dict
|
|
|
|
@classmethod
|
|
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
|
"""Create an instance of JfjochStatistics from a dict"""
|
|
if obj is None:
|
|
return None
|
|
|
|
if not isinstance(obj, dict):
|
|
return cls.model_validate(obj)
|
|
|
|
_obj = cls.model_validate({
|
|
"detector": DetectorStatus.from_dict(obj["detector"]) if obj.get("detector") is not None else None,
|
|
"measurement": MeasurementStatistics.from_dict(obj["measurement"]) if obj.get("measurement") is not None else None,
|
|
"broker": BrokerStatus.from_dict(obj["broker"]) if obj.get("broker") is not None else None,
|
|
"fpga": [FpgaStatusInner.from_dict(_item) for _item in obj["fpga"]] if obj.get("fpga") is not None else None,
|
|
"calibration": [CalibrationStatisticsInner.from_dict(_item) for _item in obj["calibration"]] if obj.get("calibration") is not None else None
|
|
})
|
|
return _obj
|
|
|
|
|